diff --git a/apisupport/apisupport.installer.maven/build.xml b/apisupport/apisupport.installer.maven/build.xml deleted file mode 100644 index b65dc4c41fcd..000000000000 --- a/apisupport/apisupport.installer.maven/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Builds, tests, and runs the project org.netbeans.modules.apisupport.installer.maven - - diff --git a/apisupport/apisupport.installer.maven/manifest.mf b/apisupport/apisupport.installer.maven/manifest.mf deleted file mode 100644 index 2fe320acc11b..000000000000 --- a/apisupport/apisupport.installer.maven/manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: false -OpenIDE-Module: org.netbeans.modules.apisupport.installer.maven -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/installer/maven/Bundle.properties -OpenIDE-Module-Specification-Version: 1.50 - diff --git a/apisupport/apisupport.installer.maven/nbproject/project.properties b/apisupport/apisupport.installer.maven/nbproject/project.properties deleted file mode 100644 index 3b054ca8045d..000000000000 --- a/apisupport/apisupport.installer.maven/nbproject/project.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -is.eager=true -javac.source=1.8 -javac.compilerargs=-Xlint -Xlint:-serial diff --git a/apisupport/apisupport.installer.maven/nbproject/project.xml b/apisupport/apisupport.installer.maven/nbproject/project.xml deleted file mode 100644 index 73bf722a1300..000000000000 --- a/apisupport/apisupport.installer.maven/nbproject/project.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - org.netbeans.modules.apisupport.project - - - org.netbeans.modules.apisupport.installer.maven - - - org.apache.tools.ant.module - - - - 3 - 3.39 - - - - org.netbeans.libs.nbi.ant - - 1.2 - - - - org.netbeans.libs.nbi.engine - - 1.0 - - - - org.netbeans.modules.apisupport.installer - - - - 1.2 - - - - org.netbeans.modules.maven - - - - 2 - 2.0 - - - - org.netbeans.modules.maven.embedder - - - - 2 - 2.54 - - - - org.netbeans.modules.project.ant - - - - 1 - 1.62 - - - - org.netbeans.modules.projectapi - - - - 1 - 1.29 - - - - org.netbeans.modules.projectuiapi - - - - 1 - 1.78 - - - - org.netbeans.modules.projectuiapi.base - - - - 1 - 1.78 - - - - org.openide.awt - - - - 7.20 - - - - org.openide.dialogs - - - - 7.14 - - - - org.openide.execution - - - - 9.0 - - - - org.openide.filesystems - - - - 9.0 - - - - org.openide.modules - - - - 7.14 - - - - org.openide.util - - - - 9.3 - - - - org.openide.util.lookup - - - - 8.0 - - - - org.openide.util.ui - - - - 9.3 - - - - - - - diff --git a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/Bundle.properties b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/Bundle.properties deleted file mode 100644 index 7bb86009f0a5..000000000000 --- a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/Bundle.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -OpenIDE-Module-Display-Category=Developing NetBeans -OpenIDE-Module-Name=Legacy Maven NetBeans Platform Application Installer -OpenIDE-Module-Short-Description=Module for creating installers for Maven NetBeans Platform-based applications (prior to 3.7 plugin). - - diff --git a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java deleted file mode 100644 index f9562769ebbf..000000000000 --- a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.apisupport.installer.maven.actions; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import org.apache.maven.artifact.versioning.ComparableVersion; -import org.apache.tools.ant.module.api.support.ActionUtils; -import org.netbeans.api.project.Project; -import org.netbeans.modules.apisupport.installer.ui.SuiteInstallerProjectProperties; -import org.netbeans.modules.maven.api.NbMavenProject; -import org.netbeans.modules.maven.api.PluginPropertyUtils; -import org.netbeans.spi.project.support.ant.PropertyUtils; -import org.openide.DialogDescriptor; -import org.openide.DialogDisplayer; -import org.openide.ErrorManager; -import org.openide.NotifyDescriptor; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionRegistration; -import org.openide.awt.DynamicMenuContent; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; -import org.openide.filesystems.FileUtil; -import org.openide.modules.InstalledFileLocator; -import org.openide.util.ContextAwareAction; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.RequestProcessor; -import org.openide.util.Utilities; - -/** - * - * @author Dmitry Lipin - */ -@ActionID(id = "org.netbeans.modules.apisupport.installer.maven.actions.BuildInstallersAction", category = "Project") -@ActionRegistration(displayName = "#CTL_BuildInstallers", lazy=false) -@ActionReference(position = 1290, path = "Projects/org-netbeans-modules-maven/Actions") -public final class BuildInstallersAction extends AbstractAction implements ContextAwareAction { - - public BuildInstallersAction() { - putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers")); - } - - public - @Override - void actionPerformed(ActionEvent e) { - assert false; - } - - public - @Override - Action createContextAwareInstance(Lookup actionContext) { - return new ContextBuildInstaller(actionContext); - } - - static class ContextBuildInstaller extends AbstractAction { - - private final Lookup actionContext; - - public ContextBuildInstaller(Lookup actionContext) { - this.actionContext = actionContext; - putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers")); - putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); - Project project = actionContext.lookup(Project.class); - if (project == null) { - setEnabled(false); //#224115 - } else { - NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); - if (watcher == null - || !NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) { - setEnabled(false); - } else { - String version = PluginPropertyUtils.getPluginVersion(watcher.getMavenProject(), "org.codehaus.mojo", "nbm-maven-plugin"); - if (version == null || new ComparableVersion(version).compareTo(new ComparableVersion("3.7-SNAPSHOT")) >= 0) { - setEnabled(false); // now handled by maven.apisupport - } - } - } - } - - @SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") // mkdirs - public - @Override - void actionPerformed(ActionEvent e) { - Project project = actionContext.lookup(Project.class); - NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); - if (watcher != null && NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) { - - //Preferences prefs = SuiteInstallerProjectProperties.prefs(project); - File suiteLocation = FileUtil.toFile(project.getProjectDirectory()); - //FileObject propertiesFile = project.getProjectDirectory().getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH); - String zipName = watcher.getMavenProject().getArtifactId() - + "-" - + watcher.getMavenProject().getVersion() - + ".zip"; - File zipFile = new File(suiteLocation, "target/" + zipName); - Logger.getLogger(BuildInstallersAction.class.getName()).log( - Level.WARNING, "Running Build Installers action for (existing={1}) zip file {0}", - new Object[]{zipFile, zipFile.exists()}); - - Preferences prefs = SuiteInstallerProjectProperties.prefs(project); - - - - - String appName = watcher.getMavenProject().getParent().getArtifactId(); - - File appIconIcnsFile = null; - String licenseType = prefs.get(SuiteInstallerProjectProperties.LICENSE_TYPE, null); - File licenseFile = null; - String licenseFileProp = prefs.get(SuiteInstallerProjectProperties.LICENSE_FILE, null); - if (licenseFileProp != null) { - licenseFile = PropertyUtils.resolveFile(suiteLocation, licenseFileProp); - //if(!licenseFile.exists()) { - // licenseFile = null; - //} - } - - //${harness.dir}/etc/applicationIcon.icns - appIconIcnsFile = new File(InstalledFileLocator.getDefault().locate( - "etc/applicationIcon.icns", - "org.netbeans.modules.apisupport.harness", false).getAbsolutePath().replace("\\", "/")); - - if (licenseFile == null && licenseType != null && !licenseType.equals(SuiteInstallerProjectProperties.LICENSE_TYPE_NO)) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.FINE, "License type defined to {0}", licenseType); - String licenseResource = null; - try { - licenseResource = NbBundle.getMessage(SuiteInstallerProjectProperties.class, - "SuiteInstallerProjectProperties.license.file." + licenseType); - } catch (MissingResourceException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, "License resource not found"); - } - - if (licenseResource != null) { - InputStream is = null; - try { - URL url = new URL(licenseResource); - is = url.openStream(); - if (is != null) { - licenseFile = Files.createTempFile("license", ".txt").toFile(); - licenseFile.getParentFile().mkdirs(); - licenseFile.deleteOnExit(); - - OutputStream os = new FileOutputStream(licenseFile); - byte[] bytes = new byte[4096]; - int read = 0; - while ((read = is.read(bytes)) > 0) { - os.write(bytes, 0, read); - } - os.flush(); - os.close(); - } else { - Logger.getLogger(BuildInstallersAction.class.getName()).log( - Level.WARNING, "License resource {0} not found", licenseResource); - } - } catch (MalformedURLException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, - "Can`t parse URL", ex); - } catch (IOException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, - "Input/Output error", ex); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - } - } - } - } - } - - //Logger.getLogger(BuildInstallersAction.class.getName()).warning("actionPerformed for " + suiteLocation); - Properties props = new Properties(); - File parentProjectDir = watcher.getMavenProject().getParent().getBasedir(); - //Logger.getLogger(MavenBuildInstallersAction.class.getName()).warning("parent dir " + parentProjectDir); - props.put("suite.location", parentProjectDir.getAbsolutePath().replace("\\", "/")); - props.put("suite.dist.zip", zipFile.getAbsolutePath().replace("\\", "/")); - props.put("suite.dist.directory", new File(suiteLocation, "target").getAbsolutePath().replace("\\", "/")); - props.put("installer.build.dir", new File(suiteLocation, "target/installerbuild").getAbsolutePath().replace("\\", "/")); - props.put("installers.file.prefix", - watcher.getMavenProject().getArtifactId() - + "-" + watcher.getMavenProject().getVersion()); - - props.put("suite.nbi.product.uid", - appName.replaceAll("[0-9]+", "").replace("_", "-").toLowerCase(Locale.ENGLISH)); - - - props.put("nbi.stub.location", InstalledFileLocator.getDefault().locate( - "nbi/stub", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.stub.common.location", InstalledFileLocator.getDefault().locate( - "nbi/.common", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - - props.put( - "nbi.ant.tasks.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-ant-tasks.jar", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.registries.management.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-registries-management.jar", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.engine.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-engine.jar", - "org.netbeans.libs.nbi.engine", false).getAbsolutePath().replace("\\", "/")); - if (licenseFile != null) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.FINE, - "License file is at {0}, exist = {1}", new Object[]{licenseFile, licenseFile.exists()}); - props.put( - "nbi.license.file", licenseFile.getAbsolutePath()); - } - - List platforms = new ArrayList(); - - boolean installerConfDefined = false; - for (String k : new String[]{ - SuiteInstallerProjectProperties.GENERATE_FOR_WINDOWS, - SuiteInstallerProjectProperties.GENERATE_FOR_LINUX, - SuiteInstallerProjectProperties.GENERATE_FOR_SOLARIS, - SuiteInstallerProjectProperties.GENERATE_FOR_MAC - }) { - if (prefs.getBoolean(k, false)) { - installerConfDefined = true; - platforms.add(k.replaceFirst("^os-", "")); - } - } - if (!installerConfDefined) { - if (Utilities.isWindows()) { - platforms.add("windows"); - } else if (Utilities.getOperatingSystem() == Utilities.OS_LINUX) { - platforms.add("linux"); - } else if (Utilities.getOperatingSystem() == Utilities.OS_SOLARIS) { - platforms.add("solaris"); - } else if (Utilities.isMac()) { - platforms.add("macosx"); - } - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < platforms.size(); i++) { - if (i != 0) { - sb.append(" "); - } - sb.append(platforms.get(i)); - } - if (sb.length() == 0) { - //nothing to build - RequestProcessor.getDefault().post(new Runnable() { - - public - @Override - void run() { - DialogDescriptor d = new DialogDescriptor( - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Message"), - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Title")); - d.setModal(true); - JButton accept = new JButton(NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.OK")); - accept.setDefaultCapable(true); - d.setOptions(new Object[]{ - accept}); - d.setMessageType(NotifyDescriptor.WARNING_MESSAGE); - if (DialogDisplayer.getDefault().notify(d).equals(accept)) { - //SuiteCustomizer cpi = prj.getLookup().lookup(org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer.class); - //cpi.showCustomizer(SuiteCustomizer.APPLICATION, SuiteCustomizer.APPLICATION_CREATE_STANDALONE_APPLICATION); - } - } - }); - return; - } - - props.put("generate.installer.for.platforms", - sb.toString()); - - - - File javaHome = new File(System.getProperty("java.home")); - if (new File(javaHome, - "lib/rt.jar").exists() && javaHome.getName().equals("jre")) { - javaHome = javaHome.getParentFile(); - } - props.put( - "generator-jdk-location-forward-slashes", javaHome.getAbsolutePath().replace("\\", "/")); - /* - props.put( - "generated-installers-location-forward-slashes", - new File(suiteLocation, "dist").getAbsolutePath().replace("\\", "/")); - */ - - /* - if(appIcon!=null) { - File appIconFile = new File(appIcon); - if(!appIconFile.equals(appIconFile.getAbsoluteFile())) { - //path is relative to suite directory - appIconFile = new File(suiteLocation, appIcon); - } - props.put( - "nbi.icon.file", appIconFile.getAbsolutePath()); - - } - */ - - if (appIconIcnsFile != null) { - props.put( - "nbi.dock.icon.file", appIconIcnsFile.getAbsolutePath()); - } - - try { - ActionUtils.runTarget(findGenXml(), new String[]{"build"}, props); - } catch (FileStateInvalidException ex) { - ErrorManager.getDefault().getInstance("org.netbeans.modules.apisupport.project").notify(ex); // NOI18N - } catch (IOException ex) { - ErrorManager.getDefault().getInstance("org.netbeans.modules.apisupport.project").notify(ex); // NOI18N - } - } - } - - private static FileObject findGenXml() { - return FileUtil.toFileObject(InstalledFileLocator.getDefault().locate( - "nbi/stub/template.xml", - "org.netbeans.libs.nbi.ant", false)); - } - } -} diff --git a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/Bundle.properties b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/Bundle.properties deleted file mode 100644 index e4699d7e7fd1..000000000000 --- a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/Bundle.properties +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -CTL_BuildInstallers=Build Installers -BuildInstallersAction.NotApp.Warning.Message=\ - In order to create installers this project should be switched to standalone application.\n\ - Open project properties, switch to Application panel and set type to Standalone Application. -BuildInstallersAction.NotApp.Warning.Title=Warning -BuildInstallersAction.NotApp.Warning.OK=OK - -BuildInstallersAction.NotConfigured.Warning.Message=\ - In order to create installers please select at least one target platform.\n\ - Open project properties, switch to Installer panel and configure installer settings. -BuildInstallersAction.NotConfigured.Warning.Title=Warning -BuildInstallersAction.NotConfigured.Warning.OK=OK \ No newline at end of file diff --git a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/ui/ExtraPanel.java b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/ui/ExtraPanel.java deleted file mode 100644 index bd46d9179cec..000000000000 --- a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/ui/ExtraPanel.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.modules.apisupport.installer.maven.ui; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import javax.swing.JComponent; -import org.apache.maven.artifact.versioning.ComparableVersion; -import org.netbeans.api.project.Project; -import static org.netbeans.modules.apisupport.installer.maven.ui.Bundle.*; -import org.netbeans.modules.apisupport.installer.ui.InstallerPanel; -import org.netbeans.modules.apisupport.installer.ui.SuiteInstallerProjectProperties; -import org.netbeans.modules.maven.api.NbMavenProject; -import org.netbeans.modules.maven.api.PluginPropertyUtils; -import org.netbeans.spi.project.ui.support.ProjectCustomizer; -import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category; -import org.openide.util.Exceptions; -import org.openide.util.Lookup; -import org.openide.util.NbBundle.Messages; - -/** - * - * @author Dmitry Lipin - */ - -@ProjectCustomizer.CompositeCategoryProvider.Registration( - projectType="org-netbeans-modules-maven", - position=1100 -) -public class ExtraPanel implements ProjectCustomizer.CompositeCategoryProvider { - - @Messages("LBL_InstallerPanel=Installer") - @Override - public Category createCategory(Lookup context) { - Project project = context.lookup(Project.class); - NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); - if (watcher!=null && - NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) { - String version = PluginPropertyUtils.getPluginVersion(watcher.getMavenProject(), "org.codehaus.mojo", "nbm-maven-plugin"); - if (version == null || new ComparableVersion(version).compareTo(new ComparableVersion("3.7-SNAPSHOT")) >= 0) { - return null; // now handled by maven.apisupport - } - return ProjectCustomizer.Category.create( - "Installer", - LBL_InstallerPanel(), - null, - (ProjectCustomizer.Category[])null); - } - return null; - } - - @Messages("LBL_deprecated=Using deprecated Ant-based installer creator. Upgrade to 3.7+ plugin to fix.") - public @Override JComponent createComponent(Category category, Lookup context) { - Project project = context.lookup(Project.class); - SuiteInstallerProjectProperties installerProjectProperties = - new SuiteInstallerProjectProperties(project); - // use OkListener to create new configuration first - category.setStoreListener(new SavePropsListener(installerProjectProperties)); - category.setErrorMessage(LBL_deprecated()); - return new InstallerPanel(installerProjectProperties); - } - - private static class SavePropsListener implements ActionListener { - - private SuiteInstallerProjectProperties installerProps; - - public SavePropsListener(SuiteInstallerProjectProperties props) { - installerProps = props; - } - - public @Override void actionPerformed(ActionEvent e) { - try { - installerProps.store(); - } catch (IOException ioe) { - Exceptions.printStackTrace(ioe); - } - } -} -} - diff --git a/apisupport/apisupport.installer/build.xml b/apisupport/apisupport.installer/build.xml deleted file mode 100644 index e9a7ac868432..000000000000 --- a/apisupport/apisupport.installer/build.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/apisupport/apisupport.installer/manifest.mf b/apisupport/apisupport.installer/manifest.mf deleted file mode 100644 index 4d3e10fdea9d..000000000000 --- a/apisupport/apisupport.installer/manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: false -OpenIDE-Module: org.netbeans.modules.apisupport.installer -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/apisupport/installer/Bundle.properties -OpenIDE-Module-Specification-Version: 1.51 - diff --git a/apisupport/apisupport.installer/nbproject/org-netbeans-modules-apisupport-installer.sig b/apisupport/apisupport.installer/nbproject/org-netbeans-modules-apisupport-installer.sig deleted file mode 100644 index 8ed2081accff..000000000000 --- a/apisupport/apisupport.installer/nbproject/org-netbeans-modules-apisupport-installer.sig +++ /dev/null @@ -1,649 +0,0 @@ -#Signature file v4.1 -#Version 1.50 - -CLSS public abstract java.awt.Component -cons protected init() -fld protected javax.accessibility.AccessibleContext accessibleContext -fld public final static float BOTTOM_ALIGNMENT = 1.0 -fld public final static float CENTER_ALIGNMENT = 0.5 -fld public final static float LEFT_ALIGNMENT = 0.0 -fld public final static float RIGHT_ALIGNMENT = 1.0 -fld public final static float TOP_ALIGNMENT = 0.0 -innr protected BltBufferStrategy -innr protected FlipBufferStrategy -innr protected abstract AccessibleAWTComponent -innr public final static !enum BaselineResizeBehavior -intf java.awt.MenuContainer -intf java.awt.image.ImageObserver -intf java.io.Serializable -meth protected boolean requestFocus(boolean) -meth protected boolean requestFocusInWindow(boolean) -meth protected final void disableEvents(long) -meth protected final void enableEvents(long) -meth protected java.awt.AWTEvent coalesceEvents(java.awt.AWTEvent,java.awt.AWTEvent) -meth protected java.lang.String paramString() -meth protected void firePropertyChange(java.lang.String,boolean,boolean) -meth protected void firePropertyChange(java.lang.String,int,int) -meth protected void firePropertyChange(java.lang.String,java.lang.Object,java.lang.Object) -meth protected void processComponentEvent(java.awt.event.ComponentEvent) -meth protected void processEvent(java.awt.AWTEvent) -meth protected void processFocusEvent(java.awt.event.FocusEvent) -meth protected void processHierarchyBoundsEvent(java.awt.event.HierarchyEvent) -meth protected void processHierarchyEvent(java.awt.event.HierarchyEvent) -meth protected void processInputMethodEvent(java.awt.event.InputMethodEvent) -meth protected void processKeyEvent(java.awt.event.KeyEvent) -meth protected void processMouseEvent(java.awt.event.MouseEvent) -meth protected void processMouseMotionEvent(java.awt.event.MouseEvent) -meth protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent) -meth public <%0 extends java.util.EventListener> {%%0}[] getListeners(java.lang.Class<{%%0}>) -meth public boolean action(java.awt.Event,java.lang.Object) - anno 0 java.lang.Deprecated() -meth public boolean areFocusTraversalKeysSet(int) -meth public boolean contains(int,int) -meth public boolean contains(java.awt.Point) -meth public boolean getFocusTraversalKeysEnabled() -meth public boolean getIgnoreRepaint() -meth public boolean gotFocus(java.awt.Event,java.lang.Object) - anno 0 java.lang.Deprecated() -meth public boolean handleEvent(java.awt.Event) - anno 0 java.lang.Deprecated() -meth public boolean hasFocus() -meth public boolean imageUpdate(java.awt.Image,int,int,int,int,int) -meth public boolean inside(int,int) - anno 0 java.lang.Deprecated() -meth public boolean isBackgroundSet() -meth public boolean isCursorSet() -meth public boolean isDisplayable() -meth public boolean isDoubleBuffered() -meth public boolean isEnabled() -meth public boolean isFocusCycleRoot(java.awt.Container) -meth public boolean isFocusOwner() -meth public boolean isFocusTraversable() - anno 0 java.lang.Deprecated() -meth public boolean isFocusable() -meth public boolean isFontSet() -meth public boolean isForegroundSet() -meth public boolean isLightweight() -meth public boolean isMaximumSizeSet() -meth public boolean isMinimumSizeSet() -meth public boolean isOpaque() -meth public boolean isPreferredSizeSet() -meth public boolean isShowing() -meth public boolean isValid() -meth public boolean isVisible() -meth public boolean keyDown(java.awt.Event,int) - anno 0 java.lang.Deprecated() -meth public boolean keyUp(java.awt.Event,int) - anno 0 java.lang.Deprecated() -meth public boolean lostFocus(java.awt.Event,java.lang.Object) - anno 0 java.lang.Deprecated() -meth public boolean mouseDown(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean mouseDrag(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean mouseEnter(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean mouseExit(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean mouseMove(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean mouseUp(java.awt.Event,int,int) - anno 0 java.lang.Deprecated() -meth public boolean postEvent(java.awt.Event) - anno 0 java.lang.Deprecated() -meth public boolean prepareImage(java.awt.Image,int,int,java.awt.image.ImageObserver) -meth public boolean prepareImage(java.awt.Image,java.awt.image.ImageObserver) -meth public boolean requestFocusInWindow() -meth public final java.lang.Object getTreeLock() -meth public final void dispatchEvent(java.awt.AWTEvent) -meth public float getAlignmentX() -meth public float getAlignmentY() -meth public int checkImage(java.awt.Image,int,int,java.awt.image.ImageObserver) -meth public int checkImage(java.awt.Image,java.awt.image.ImageObserver) -meth public int getBaseline(int,int) -meth public int getHeight() -meth public int getWidth() -meth public int getX() -meth public int getY() -meth public java.awt.Color getBackground() -meth public java.awt.Color getForeground() -meth public java.awt.Component getComponentAt(int,int) -meth public java.awt.Component getComponentAt(java.awt.Point) -meth public java.awt.Component locate(int,int) - anno 0 java.lang.Deprecated() -meth public java.awt.Component$BaselineResizeBehavior getBaselineResizeBehavior() -meth public java.awt.ComponentOrientation getComponentOrientation() -meth public java.awt.Container getFocusCycleRootAncestor() -meth public java.awt.Container getParent() -meth public java.awt.Cursor getCursor() -meth public java.awt.Dimension getMaximumSize() -meth public java.awt.Dimension getMinimumSize() -meth public java.awt.Dimension getPreferredSize() -meth public java.awt.Dimension getSize() -meth public java.awt.Dimension getSize(java.awt.Dimension) -meth public java.awt.Dimension minimumSize() - anno 0 java.lang.Deprecated() -meth public java.awt.Dimension preferredSize() - anno 0 java.lang.Deprecated() -meth public java.awt.Dimension size() - anno 0 java.lang.Deprecated() -meth public java.awt.Font getFont() -meth public java.awt.FontMetrics getFontMetrics(java.awt.Font) -meth public java.awt.Graphics getGraphics() -meth public java.awt.GraphicsConfiguration getGraphicsConfiguration() -meth public java.awt.Image createImage(int,int) -meth public java.awt.Image createImage(java.awt.image.ImageProducer) -meth public java.awt.Point getLocation() -meth public java.awt.Point getLocation(java.awt.Point) -meth public java.awt.Point getLocationOnScreen() -meth public java.awt.Point getMousePosition() -meth public java.awt.Point location() - anno 0 java.lang.Deprecated() -meth public java.awt.Rectangle bounds() - anno 0 java.lang.Deprecated() -meth public java.awt.Rectangle getBounds() -meth public java.awt.Rectangle getBounds(java.awt.Rectangle) -meth public java.awt.Toolkit getToolkit() -meth public java.awt.dnd.DropTarget getDropTarget() -meth public java.awt.event.ComponentListener[] getComponentListeners() -meth public java.awt.event.FocusListener[] getFocusListeners() -meth public java.awt.event.HierarchyBoundsListener[] getHierarchyBoundsListeners() -meth public java.awt.event.HierarchyListener[] getHierarchyListeners() -meth public java.awt.event.InputMethodListener[] getInputMethodListeners() -meth public java.awt.event.KeyListener[] getKeyListeners() -meth public java.awt.event.MouseListener[] getMouseListeners() -meth public java.awt.event.MouseMotionListener[] getMouseMotionListeners() -meth public java.awt.event.MouseWheelListener[] getMouseWheelListeners() -meth public java.awt.im.InputContext getInputContext() -meth public java.awt.im.InputMethodRequests getInputMethodRequests() -meth public java.awt.image.ColorModel getColorModel() -meth public java.awt.image.VolatileImage createVolatileImage(int,int) -meth public java.awt.image.VolatileImage createVolatileImage(int,int,java.awt.ImageCapabilities) throws java.awt.AWTException -meth public java.beans.PropertyChangeListener[] getPropertyChangeListeners() -meth public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String) -meth public java.lang.String getName() -meth public java.lang.String toString() -meth public java.util.Locale getLocale() -meth public java.util.Set getFocusTraversalKeys(int) -meth public javax.accessibility.AccessibleContext getAccessibleContext() -meth public void add(java.awt.PopupMenu) -meth public void addComponentListener(java.awt.event.ComponentListener) -meth public void addFocusListener(java.awt.event.FocusListener) -meth public void addHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener) -meth public void addHierarchyListener(java.awt.event.HierarchyListener) -meth public void addInputMethodListener(java.awt.event.InputMethodListener) -meth public void addKeyListener(java.awt.event.KeyListener) -meth public void addMouseListener(java.awt.event.MouseListener) -meth public void addMouseMotionListener(java.awt.event.MouseMotionListener) -meth public void addMouseWheelListener(java.awt.event.MouseWheelListener) -meth public void addNotify() -meth public void addPropertyChangeListener(java.beans.PropertyChangeListener) -meth public void addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) -meth public void applyComponentOrientation(java.awt.ComponentOrientation) -meth public void deliverEvent(java.awt.Event) - anno 0 java.lang.Deprecated() -meth public void disable() - anno 0 java.lang.Deprecated() -meth public void doLayout() -meth public void enable() - anno 0 java.lang.Deprecated() -meth public void enable(boolean) - anno 0 java.lang.Deprecated() -meth public void enableInputMethods(boolean) -meth public void firePropertyChange(java.lang.String,byte,byte) -meth public void firePropertyChange(java.lang.String,char,char) -meth public void firePropertyChange(java.lang.String,double,double) -meth public void firePropertyChange(java.lang.String,float,float) -meth public void firePropertyChange(java.lang.String,long,long) -meth public void firePropertyChange(java.lang.String,short,short) -meth public void hide() - anno 0 java.lang.Deprecated() -meth public void invalidate() -meth public void layout() - anno 0 java.lang.Deprecated() -meth public void list() -meth public void list(java.io.PrintStream) -meth public void list(java.io.PrintStream,int) -meth public void list(java.io.PrintWriter) -meth public void list(java.io.PrintWriter,int) -meth public void move(int,int) - anno 0 java.lang.Deprecated() -meth public void nextFocus() - anno 0 java.lang.Deprecated() -meth public void paint(java.awt.Graphics) -meth public void paintAll(java.awt.Graphics) -meth public void print(java.awt.Graphics) -meth public void printAll(java.awt.Graphics) -meth public void remove(java.awt.MenuComponent) -meth public void removeComponentListener(java.awt.event.ComponentListener) -meth public void removeFocusListener(java.awt.event.FocusListener) -meth public void removeHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener) -meth public void removeHierarchyListener(java.awt.event.HierarchyListener) -meth public void removeInputMethodListener(java.awt.event.InputMethodListener) -meth public void removeKeyListener(java.awt.event.KeyListener) -meth public void removeMouseListener(java.awt.event.MouseListener) -meth public void removeMouseMotionListener(java.awt.event.MouseMotionListener) -meth public void removeMouseWheelListener(java.awt.event.MouseWheelListener) -meth public void removeNotify() -meth public void removePropertyChangeListener(java.beans.PropertyChangeListener) -meth public void removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) -meth public void repaint() -meth public void repaint(int,int,int,int) -meth public void repaint(long) -meth public void repaint(long,int,int,int,int) -meth public void requestFocus() -meth public void reshape(int,int,int,int) - anno 0 java.lang.Deprecated() -meth public void resize(int,int) - anno 0 java.lang.Deprecated() -meth public void resize(java.awt.Dimension) - anno 0 java.lang.Deprecated() -meth public void revalidate() -meth public void setBackground(java.awt.Color) -meth public void setBounds(int,int,int,int) -meth public void setBounds(java.awt.Rectangle) -meth public void setComponentOrientation(java.awt.ComponentOrientation) -meth public void setCursor(java.awt.Cursor) -meth public void setDropTarget(java.awt.dnd.DropTarget) -meth public void setEnabled(boolean) -meth public void setFocusTraversalKeys(int,java.util.Set) -meth public void setFocusTraversalKeysEnabled(boolean) -meth public void setFocusable(boolean) -meth public void setFont(java.awt.Font) -meth public void setForeground(java.awt.Color) -meth public void setIgnoreRepaint(boolean) -meth public void setLocale(java.util.Locale) -meth public void setLocation(int,int) -meth public void setLocation(java.awt.Point) -meth public void setMaximumSize(java.awt.Dimension) -meth public void setMinimumSize(java.awt.Dimension) -meth public void setName(java.lang.String) -meth public void setPreferredSize(java.awt.Dimension) -meth public void setSize(int,int) -meth public void setSize(java.awt.Dimension) -meth public void setVisible(boolean) -meth public void show() - anno 0 java.lang.Deprecated() -meth public void show(boolean) - anno 0 java.lang.Deprecated() -meth public void transferFocus() -meth public void transferFocusBackward() -meth public void transferFocusUpCycle() -meth public void update(java.awt.Graphics) -meth public void validate() -supr java.lang.Object - -CLSS public java.awt.Container -cons public init() -innr protected AccessibleAWTContainer -meth protected java.lang.String paramString() -meth protected void addImpl(java.awt.Component,java.lang.Object,int) -meth protected void processContainerEvent(java.awt.event.ContainerEvent) -meth protected void processEvent(java.awt.AWTEvent) -meth protected void validateTree() -meth public <%0 extends java.util.EventListener> {%%0}[] getListeners(java.lang.Class<{%%0}>) -meth public boolean areFocusTraversalKeysSet(int) -meth public boolean isAncestorOf(java.awt.Component) -meth public boolean isFocusCycleRoot() -meth public boolean isFocusCycleRoot(java.awt.Container) -meth public boolean isFocusTraversalPolicySet() -meth public boolean isValidateRoot() -meth public final boolean isFocusTraversalPolicyProvider() -meth public final void setFocusTraversalPolicyProvider(boolean) -meth public float getAlignmentX() -meth public float getAlignmentY() -meth public int countComponents() - anno 0 java.lang.Deprecated() -meth public int getComponentCount() -meth public int getComponentZOrder(java.awt.Component) -meth public java.awt.Component add(java.awt.Component) -meth public java.awt.Component add(java.awt.Component,int) -meth public java.awt.Component add(java.lang.String,java.awt.Component) -meth public java.awt.Component findComponentAt(int,int) -meth public java.awt.Component findComponentAt(java.awt.Point) -meth public java.awt.Component getComponent(int) -meth public java.awt.Component getComponentAt(int,int) -meth public java.awt.Component getComponentAt(java.awt.Point) -meth public java.awt.Component locate(int,int) - anno 0 java.lang.Deprecated() -meth public java.awt.Component[] getComponents() -meth public java.awt.Dimension getMaximumSize() -meth public java.awt.Dimension getMinimumSize() -meth public java.awt.Dimension getPreferredSize() -meth public java.awt.Dimension minimumSize() - anno 0 java.lang.Deprecated() -meth public java.awt.Dimension preferredSize() - anno 0 java.lang.Deprecated() -meth public java.awt.FocusTraversalPolicy getFocusTraversalPolicy() -meth public java.awt.Insets getInsets() -meth public java.awt.Insets insets() - anno 0 java.lang.Deprecated() -meth public java.awt.LayoutManager getLayout() -meth public java.awt.Point getMousePosition(boolean) -meth public java.awt.event.ContainerListener[] getContainerListeners() -meth public java.util.Set getFocusTraversalKeys(int) -meth public void add(java.awt.Component,java.lang.Object) -meth public void add(java.awt.Component,java.lang.Object,int) -meth public void addContainerListener(java.awt.event.ContainerListener) -meth public void addNotify() -meth public void addPropertyChangeListener(java.beans.PropertyChangeListener) -meth public void addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) -meth public void applyComponentOrientation(java.awt.ComponentOrientation) -meth public void deliverEvent(java.awt.Event) - anno 0 java.lang.Deprecated() -meth public void doLayout() -meth public void invalidate() -meth public void layout() - anno 0 java.lang.Deprecated() -meth public void list(java.io.PrintStream,int) -meth public void list(java.io.PrintWriter,int) -meth public void paint(java.awt.Graphics) -meth public void paintComponents(java.awt.Graphics) -meth public void print(java.awt.Graphics) -meth public void printComponents(java.awt.Graphics) -meth public void remove(int) -meth public void remove(java.awt.Component) -meth public void removeAll() -meth public void removeContainerListener(java.awt.event.ContainerListener) -meth public void removeNotify() -meth public void setComponentZOrder(java.awt.Component,int) -meth public void setFocusCycleRoot(boolean) -meth public void setFocusTraversalKeys(int,java.util.Set) -meth public void setFocusTraversalPolicy(java.awt.FocusTraversalPolicy) -meth public void setFont(java.awt.Font) -meth public void setLayout(java.awt.LayoutManager) -meth public void transferFocusDownCycle() -meth public void update(java.awt.Graphics) -meth public void validate() -supr java.awt.Component - -CLSS public abstract interface java.awt.MenuContainer -meth public abstract boolean postEvent(java.awt.Event) - anno 0 java.lang.Deprecated() -meth public abstract java.awt.Font getFont() -meth public abstract void remove(java.awt.MenuComponent) - -CLSS public abstract interface java.awt.image.ImageObserver -fld public final static int ABORT = 128 -fld public final static int ALLBITS = 32 -fld public final static int ERROR = 64 -fld public final static int FRAMEBITS = 16 -fld public final static int HEIGHT = 2 -fld public final static int PROPERTIES = 4 -fld public final static int SOMEBITS = 8 -fld public final static int WIDTH = 1 -meth public abstract boolean imageUpdate(java.awt.Image,int,int,int,int,int) - -CLSS public abstract interface java.io.Serializable - -CLSS public java.lang.Object -cons public init() -meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException -meth protected void finalize() throws java.lang.Throwable -meth public boolean equals(java.lang.Object) -meth public final java.lang.Class getClass() -meth public final void notify() -meth public final void notifyAll() -meth public final void wait() throws java.lang.InterruptedException -meth public final void wait(long) throws java.lang.InterruptedException -meth public final void wait(long,int) throws java.lang.InterruptedException -meth public int hashCode() -meth public java.lang.String toString() - -CLSS public abstract interface javax.accessibility.Accessible -meth public abstract javax.accessibility.AccessibleContext getAccessibleContext() - -CLSS public abstract interface javax.swing.ComboBoxModel<%0 extends java.lang.Object> -intf javax.swing.ListModel<{javax.swing.ComboBoxModel%0}> -meth public abstract java.lang.Object getSelectedItem() -meth public abstract void setSelectedItem(java.lang.Object) - -CLSS public abstract javax.swing.JComponent -cons public init() -fld protected javax.swing.event.EventListenerList listenerList -fld protected javax.swing.plaf.ComponentUI ui -fld public final static int UNDEFINED_CONDITION = -1 -fld public final static int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1 -fld public final static int WHEN_FOCUSED = 0 -fld public final static int WHEN_IN_FOCUSED_WINDOW = 2 -fld public final static java.lang.String TOOL_TIP_TEXT_KEY = "ToolTipText" -innr public abstract AccessibleJComponent -intf java.io.Serializable -meth protected boolean isPaintingOrigin() -meth protected boolean processKeyBinding(javax.swing.KeyStroke,java.awt.event.KeyEvent,int,boolean) -meth protected boolean requestFocusInWindow(boolean) -meth protected java.awt.Graphics getComponentGraphics(java.awt.Graphics) -meth protected java.lang.String paramString() -meth protected void fireVetoableChange(java.lang.String,java.lang.Object,java.lang.Object) throws java.beans.PropertyVetoException -meth protected void paintBorder(java.awt.Graphics) -meth protected void paintChildren(java.awt.Graphics) -meth protected void paintComponent(java.awt.Graphics) -meth protected void printBorder(java.awt.Graphics) -meth protected void printChildren(java.awt.Graphics) -meth protected void printComponent(java.awt.Graphics) -meth protected void processComponentKeyEvent(java.awt.event.KeyEvent) -meth protected void processKeyEvent(java.awt.event.KeyEvent) -meth protected void processMouseEvent(java.awt.event.MouseEvent) -meth protected void processMouseMotionEvent(java.awt.event.MouseEvent) -meth protected void setUI(javax.swing.plaf.ComponentUI) -meth public <%0 extends java.util.EventListener> {%%0}[] getListeners(java.lang.Class<{%%0}>) -meth public boolean contains(int,int) -meth public boolean getAutoscrolls() -meth public boolean getInheritsPopupMenu() -meth public boolean getVerifyInputWhenFocusTarget() -meth public boolean isDoubleBuffered() -meth public boolean isManagingFocus() - anno 0 java.lang.Deprecated() -meth public boolean isOpaque() -meth public boolean isOptimizedDrawingEnabled() -meth public boolean isPaintingTile() -meth public boolean isRequestFocusEnabled() -meth public boolean isValidateRoot() -meth public boolean requestDefaultFocus() - anno 0 java.lang.Deprecated() -meth public boolean requestFocus(boolean) -meth public boolean requestFocusInWindow() -meth public final boolean isPaintingForPrint() -meth public final java.lang.Object getClientProperty(java.lang.Object) -meth public final javax.swing.ActionMap getActionMap() -meth public final javax.swing.InputMap getInputMap() -meth public final javax.swing.InputMap getInputMap(int) -meth public final void putClientProperty(java.lang.Object,java.lang.Object) -meth public final void setActionMap(javax.swing.ActionMap) -meth public final void setInputMap(int,javax.swing.InputMap) -meth public float getAlignmentX() -meth public float getAlignmentY() -meth public int getBaseline(int,int) -meth public int getConditionForKeyStroke(javax.swing.KeyStroke) -meth public int getDebugGraphicsOptions() -meth public int getHeight() -meth public int getWidth() -meth public int getX() -meth public int getY() -meth public java.awt.Component getNextFocusableComponent() - anno 0 java.lang.Deprecated() -meth public java.awt.Component$BaselineResizeBehavior getBaselineResizeBehavior() -meth public java.awt.Container getTopLevelAncestor() -meth public java.awt.Dimension getMaximumSize() -meth public java.awt.Dimension getMinimumSize() -meth public java.awt.Dimension getPreferredSize() -meth public java.awt.Dimension getSize(java.awt.Dimension) -meth public java.awt.FontMetrics getFontMetrics(java.awt.Font) -meth public java.awt.Graphics getGraphics() -meth public java.awt.Insets getInsets() -meth public java.awt.Insets getInsets(java.awt.Insets) -meth public java.awt.Point getLocation(java.awt.Point) -meth public java.awt.Point getPopupLocation(java.awt.event.MouseEvent) -meth public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent) -meth public java.awt.Rectangle getBounds(java.awt.Rectangle) -meth public java.awt.Rectangle getVisibleRect() -meth public java.awt.event.ActionListener getActionForKeyStroke(javax.swing.KeyStroke) -meth public java.beans.VetoableChangeListener[] getVetoableChangeListeners() -meth public java.lang.String getToolTipText() -meth public java.lang.String getToolTipText(java.awt.event.MouseEvent) -meth public java.lang.String getUIClassID() -meth public javax.swing.InputVerifier getInputVerifier() -meth public javax.swing.JPopupMenu getComponentPopupMenu() -meth public javax.swing.JRootPane getRootPane() -meth public javax.swing.JToolTip createToolTip() -meth public javax.swing.KeyStroke[] getRegisteredKeyStrokes() -meth public javax.swing.TransferHandler getTransferHandler() -meth public javax.swing.border.Border getBorder() -meth public javax.swing.event.AncestorListener[] getAncestorListeners() -meth public static boolean isLightweightComponent(java.awt.Component) -meth public static java.util.Locale getDefaultLocale() -meth public static void setDefaultLocale(java.util.Locale) -meth public void addAncestorListener(javax.swing.event.AncestorListener) -meth public void addNotify() -meth public void addVetoableChangeListener(java.beans.VetoableChangeListener) -meth public void computeVisibleRect(java.awt.Rectangle) -meth public void disable() - anno 0 java.lang.Deprecated() -meth public void enable() - anno 0 java.lang.Deprecated() -meth public void firePropertyChange(java.lang.String,boolean,boolean) -meth public void firePropertyChange(java.lang.String,char,char) -meth public void firePropertyChange(java.lang.String,int,int) -meth public void grabFocus() -meth public void hide() - anno 0 java.lang.Deprecated() -meth public void paint(java.awt.Graphics) -meth public void paintImmediately(int,int,int,int) -meth public void paintImmediately(java.awt.Rectangle) -meth public void print(java.awt.Graphics) -meth public void printAll(java.awt.Graphics) -meth public void registerKeyboardAction(java.awt.event.ActionListener,java.lang.String,javax.swing.KeyStroke,int) -meth public void registerKeyboardAction(java.awt.event.ActionListener,javax.swing.KeyStroke,int) -meth public void removeAncestorListener(javax.swing.event.AncestorListener) -meth public void removeNotify() -meth public void removeVetoableChangeListener(java.beans.VetoableChangeListener) -meth public void repaint(java.awt.Rectangle) -meth public void repaint(long,int,int,int,int) -meth public void requestFocus() -meth public void resetKeyboardActions() -meth public void reshape(int,int,int,int) - anno 0 java.lang.Deprecated() -meth public void revalidate() -meth public void scrollRectToVisible(java.awt.Rectangle) -meth public void setAlignmentX(float) -meth public void setAlignmentY(float) -meth public void setAutoscrolls(boolean) -meth public void setBackground(java.awt.Color) -meth public void setBorder(javax.swing.border.Border) -meth public void setComponentPopupMenu(javax.swing.JPopupMenu) -meth public void setDebugGraphicsOptions(int) -meth public void setDoubleBuffered(boolean) -meth public void setEnabled(boolean) -meth public void setFocusTraversalKeys(int,java.util.Set) -meth public void setFont(java.awt.Font) -meth public void setForeground(java.awt.Color) -meth public void setInheritsPopupMenu(boolean) -meth public void setInputVerifier(javax.swing.InputVerifier) -meth public void setMaximumSize(java.awt.Dimension) -meth public void setMinimumSize(java.awt.Dimension) -meth public void setNextFocusableComponent(java.awt.Component) - anno 0 java.lang.Deprecated() -meth public void setOpaque(boolean) -meth public void setPreferredSize(java.awt.Dimension) -meth public void setRequestFocusEnabled(boolean) -meth public void setToolTipText(java.lang.String) -meth public void setTransferHandler(javax.swing.TransferHandler) -meth public void setVerifyInputWhenFocusTarget(boolean) -meth public void setVisible(boolean) -meth public void unregisterKeyboardAction(javax.swing.KeyStroke) -meth public void update(java.awt.Graphics) -meth public void updateUI() -supr java.awt.Container - -CLSS public javax.swing.JPanel -cons public init() -cons public init(boolean) -cons public init(java.awt.LayoutManager) -cons public init(java.awt.LayoutManager,boolean) -innr protected AccessibleJPanel -intf javax.accessibility.Accessible -meth protected java.lang.String paramString() -meth public java.lang.String getUIClassID() -meth public javax.accessibility.AccessibleContext getAccessibleContext() -meth public javax.swing.plaf.PanelUI getUI() -meth public void setUI(javax.swing.plaf.PanelUI) -meth public void updateUI() -supr javax.swing.JComponent - -CLSS public abstract interface javax.swing.ListModel<%0 extends java.lang.Object> -meth public abstract int getSize() -meth public abstract void addListDataListener(javax.swing.event.ListDataListener) -meth public abstract void removeListDataListener(javax.swing.event.ListDataListener) -meth public abstract {javax.swing.ListModel%0} getElementAt(int) - -CLSS public org.netbeans.modules.apisupport.installer.ui.ExtraPanel -cons public init() -intf org.netbeans.spi.project.ui.support.ProjectCustomizer$CompositeCategoryProvider -meth public javax.swing.JComponent createComponent(org.netbeans.spi.project.ui.support.ProjectCustomizer$Category,org.openide.util.Lookup) -meth public org.netbeans.spi.project.ui.support.ProjectCustomizer$Category createCategory(org.openide.util.Lookup) -supr java.lang.Object -hcls SavePropsListener - -CLSS public org.netbeans.modules.apisupport.installer.ui.InstallerPanel -cons public init(org.netbeans.modules.apisupport.installer.ui.SuiteInstallerProjectProperties) -supr javax.swing.JPanel -hfds installerProps,jCheckBox1,jCheckBox2,jCheckBox3,jCheckBox4,jCheckBox5,jLabel2,jSeparator1,jSeparator2,licenseComboBox,licenseLabel,pack200Info - -CLSS public org.netbeans.modules.apisupport.installer.ui.LicenseComboBoxModel -cons public init(org.netbeans.api.project.Project,java.util.List,java.util.List) -intf javax.swing.ComboBoxModel -meth public int getSize() -meth public java.lang.Object getElementAt(int) -meth public java.lang.Object getSelectedItem() -meth public java.lang.String getName() -meth public java.util.List getNames() -meth public java.util.List getTypes() -meth public void addListDataListener(javax.swing.event.ListDataListener) -meth public void removeListDataListener(javax.swing.event.ListDataListener) -meth public void setSelectedItem(java.lang.Object) -supr java.lang.Object -hfds listeners,names,selectedItem,selectedItemFromList,suiteProject,types - -CLSS public org.netbeans.modules.apisupport.installer.ui.SuiteInstallerProjectProperties -cons public init(org.netbeans.api.project.Project) -fld public final static java.lang.String GENERATE_FOR_LINUX = "os-linux" -fld public final static java.lang.String GENERATE_FOR_MAC = "os-macosx" -fld public final static java.lang.String GENERATE_FOR_SOLARIS = "os-solaris" -fld public final static java.lang.String GENERATE_FOR_WINDOWS = "os-windows" -fld public final static java.lang.String LICENSE_FILE = "license-file" -fld public final static java.lang.String LICENSE_TYPE = "license-type" -fld public final static java.lang.String LICENSE_TYPE_CUSTOM = "custom" -fld public final static java.lang.String LICENSE_TYPE_FILE = "file" -fld public final static java.lang.String LICENSE_TYPE_NO = "no" -meth public static java.util.prefs.Preferences prefs(org.netbeans.api.project.Project) -meth public void store() throws java.io.IOException -supr java.lang.Object -hfds licenseModel,linuxModel,macModel,solarisModel,suiteProject,windowsModel - -CLSS public final org.netbeans.spi.project.ui.support.ProjectCustomizer -innr public abstract interface static CategoryComponentProvider -innr public abstract interface static CompositeCategoryProvider -innr public final static Category -meth public static java.awt.Dialog createCustomizerDialog(java.lang.String,org.openide.util.Lookup,java.lang.String,java.awt.event.ActionListener,java.awt.event.ActionListener,org.openide.util.HelpCtx) - anno 4 org.netbeans.api.annotations.common.NonNull() - anno 5 org.netbeans.api.annotations.common.NullAllowed() -meth public static java.awt.Dialog createCustomizerDialog(java.lang.String,org.openide.util.Lookup,java.lang.String,java.awt.event.ActionListener,org.openide.util.HelpCtx) - anno 4 org.netbeans.api.annotations.common.NonNull() -meth public static java.awt.Dialog createCustomizerDialog(org.netbeans.spi.project.ui.support.ProjectCustomizer$Category[],org.netbeans.spi.project.ui.support.ProjectCustomizer$CategoryComponentProvider,java.lang.String,java.awt.event.ActionListener,java.awt.event.ActionListener,org.openide.util.HelpCtx) - anno 4 org.netbeans.api.annotations.common.NonNull() - anno 5 org.netbeans.api.annotations.common.NullAllowed() -meth public static java.awt.Dialog createCustomizerDialog(org.netbeans.spi.project.ui.support.ProjectCustomizer$Category[],org.netbeans.spi.project.ui.support.ProjectCustomizer$CategoryComponentProvider,java.lang.String,java.awt.event.ActionListener,org.openide.util.HelpCtx) - anno 4 org.netbeans.api.annotations.common.NonNull() -meth public static javax.swing.ComboBoxModel encodingModel(java.lang.String) -meth public static javax.swing.ListCellRenderer encodingRenderer() -supr java.lang.Object -hfds LOG -hcls DelegateCategoryProvider,EncodingModel,EncodingRenderer - -CLSS public abstract interface static org.netbeans.spi.project.ui.support.ProjectCustomizer$CompositeCategoryProvider - outer org.netbeans.spi.project.ui.support.ProjectCustomizer -innr public abstract interface static !annotation Registration -innr public abstract interface static !annotation Registrations -meth public abstract javax.swing.JComponent createComponent(org.netbeans.spi.project.ui.support.ProjectCustomizer$Category,org.openide.util.Lookup) -meth public abstract org.netbeans.spi.project.ui.support.ProjectCustomizer$Category createCategory(org.openide.util.Lookup) - diff --git a/apisupport/apisupport.installer/nbproject/project.properties b/apisupport/apisupport.installer/nbproject/project.properties deleted file mode 100644 index 11ef6581274d..000000000000 --- a/apisupport/apisupport.installer/nbproject/project.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -javac.source=1.8 -javac.compilerargs=-Xlint -Xlint:-serial -nbm.module.author=Dmitry Lipin diff --git a/apisupport/apisupport.installer/nbproject/project.xml b/apisupport/apisupport.installer/nbproject/project.xml deleted file mode 100644 index 26074fcc6a55..000000000000 --- a/apisupport/apisupport.installer/nbproject/project.xml +++ /dev/null @@ -1,188 +0,0 @@ - - - - org.netbeans.modules.apisupport.project - - - org.netbeans.modules.apisupport.installer - - - org.apache.tools.ant.module - - - - 3 - 3.39 - - - - org.netbeans.api.annotations.common - - - - 1 - 1.4 - - - - org.netbeans.libs.nbi.ant - - 1.0 - - - - org.netbeans.libs.nbi.engine - - 1.0 - - - - org.netbeans.modules.project.ant - - - - 1 - 1.62 - - - - org.netbeans.modules.projectapi - - - - 1 - 1.29 - - - - org.netbeans.modules.projectuiapi - - - - 1 - 1.78 - - - - org.openide.awt - - - - 7.20 - - - - org.openide.dialogs - - - - 7.14 - - - - org.openide.execution - - - - 9.0 - - - - org.openide.filesystems - - - - 9.0 - - - - org.openide.filesystems.nb - - - - 9.0 - - - - org.openide.loaders - - - - 7.61 - - - - org.openide.modules - - - - 7.14 - - - - org.openide.nodes - - - - 7.13 - - - - org.openide.util.ui - - - - 9.3 - - - - org.openide.util - - - - 9.3 - - - - org.openide.util.lookup - - - - 8.0 - - - - org.openide.windows - - - - 6.31 - - - - - org.netbeans.modules.apisupport.installer.maven - org.netbeans.modules.apisupport.installer.ui - - - - diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/Bundle.properties b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/Bundle.properties deleted file mode 100644 index bc8a274432d3..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/Bundle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -OpenIDE-Module-Display-Category=Developing NetBeans -OpenIDE-Module-Name=RCP Installers -OpenIDE-Module-Short-Description=Module for creating installers for NetBeans Platform-based applications - diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java deleted file mode 100644 index f707ceec5633..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.apisupport.installer.actions; - -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import org.netbeans.api.annotations.common.SuppressWarnings; -import org.openide.ErrorManager; -import org.netbeans.api.project.Project; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionRegistration; -import org.openide.filesystems.FileUtil; -import org.openide.util.ContextAwareAction; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.apache.tools.ant.module.api.support.ActionUtils; -import org.netbeans.api.project.ProjectUtils; -import org.netbeans.modules.apisupport.installer.ui.SuiteInstallerProjectProperties; -import org.netbeans.spi.project.support.ant.AntProjectHelper; -import org.netbeans.spi.project.support.ant.PropertyUtils; -import org.openide.DialogDescriptor; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.filesystems.FileObject; -import org.openide.filesystems.FileStateInvalidException; -import org.openide.modules.InstalledFileLocator; -import org.openide.util.RequestProcessor; -import org.openide.util.Utilities; - -@ActionID(id = "org.netbeans.modules.apisupport.installer.actions.BuildInstallersAction", category = "Project") -@ActionRegistration(displayName = "#CTL_BuildInstallers", /* XXX might work to be context action on List */ lazy=false) -@ActionReference(position = 400, path = "Projects/org-netbeans-modules-apisupport-project-suite-package/Actions") -public final class BuildInstallersAction extends AbstractAction implements ContextAwareAction { - - public BuildInstallersAction() { - putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers")); - } - - public @Override void actionPerformed(ActionEvent e) { - assert false; - } - - public @Override Action createContextAwareInstance(Lookup actionContext) { - return new ContextBuildInstaller(actionContext); - } - - static class ContextBuildInstaller extends AbstractAction { - - private final Lookup actionContext; - - public ContextBuildInstaller(Lookup actionContext) { - this.actionContext = actionContext; - putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers")); - } - - @SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") // mkdirs - public @Override void actionPerformed(ActionEvent e) { - for (Project prj : actionContext.lookupAll(Project.class)) { - Preferences prefs = SuiteInstallerProjectProperties.prefs(prj); - File suiteLocation = FileUtil.toFile(prj.getProjectDirectory()); - String appName = ""; - String appIcon = null; - String appIconIcns = null; - File appIconIcnsFile = null; - String licenseType = prefs.get(SuiteInstallerProjectProperties.LICENSE_TYPE, null); - File licenseFile = null; - String licenseFileProp = prefs.get(SuiteInstallerProjectProperties.LICENSE_FILE, null); - if (licenseFileProp != null) { - licenseFile = PropertyUtils.resolveFile(suiteLocation, licenseFileProp); - //if(!licenseFile.exists()) { - // licenseFile = null; - //} - } - - try { - FileObject propertiesFile = prj.getProjectDirectory().getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH); - InputStream is = propertiesFile.getInputStream(); - Properties ps = new Properties(); - try { - ps.load(is); - } finally { - is.close(); - } - appName = ps.getProperty("app.name"); - if (appName != null && appName.contains("$")) { - appName = ProjectUtils.getInformation(prj).getName(); - } - - appIcon = ps.getProperty("app.icon"); - appIconIcns = ps.getProperty("app.icon.icns", null); - if(appIconIcns!=null) { - appIconIcnsFile = PropertyUtils.resolveFile(suiteLocation, appIconIcns); - } else { - //${harness.dir}/etc/applicationIcon.icns - appIconIcnsFile = new File(InstalledFileLocator.getDefault().locate( - "etc/applicationIcon.icns", - "org.netbeans.modules.apisupport.harness", false).getAbsolutePath().replace("\\", "/")); - } - - - if (appName == null) { - //suite, not standalone app - RequestProcessor.getDefault().post(new Runnable() { - public @Override void run() { - DialogDescriptor d = new DialogDescriptor( - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.Message"), - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.Title")); - d.setModal(true); - JButton accept = new JButton(NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotApp.Warning.OK")); - accept.setDefaultCapable(true); - d.setOptions(new Object[]{ - accept}); - d.setMessageType(NotifyDescriptor.WARNING_MESSAGE); - if (DialogDisplayer.getDefault().notify(d).equals(accept)) { - //SuiteCustomizer cpi = prj.getLookup().lookup(org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer.class); - //cpi.showCustomizer(SuiteCustomizer.APPLICATION, SuiteCustomizer.APPLICATION_CREATE_STANDALONE_APPLICATION); - } - } - }); - - return; - } - } catch (IOException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, "Cannot load properties", ex); - } - - - if (licenseFile==null && licenseType != null && !licenseType.equals(SuiteInstallerProjectProperties.LICENSE_TYPE_NO)) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.FINE, "License type defined to {0}", licenseType); - String licenseResource = null; - try { - licenseResource = NbBundle.getMessage(SuiteInstallerProjectProperties.class, - "SuiteInstallerProjectProperties.license.file." + licenseType); - } catch (MissingResourceException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, "License resource not found"); - } - - if (licenseResource != null) { - InputStream is = null; - try { - URL url = new URL(licenseResource); - is = url.openStream(); - if (is != null) { - licenseFile = Files.createTempFile("license", ".txt").toFile(); - licenseFile.getParentFile().mkdirs(); - licenseFile.deleteOnExit(); - - OutputStream os = new FileOutputStream(licenseFile); - byte[] bytes = new byte[4096]; - int read = 0; - while ((read = is.read(bytes)) > 0) { - os.write(bytes, 0, read); - } - os.flush(); - os.close(); - } else { - Logger.getLogger(BuildInstallersAction.class.getName()).log( - Level.WARNING, "License resource {0} not found", licenseResource); - } - } catch (MalformedURLException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, - "Can`t parse URL", ex); - } catch (IOException ex) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.WARNING, - "Input/Output error", ex); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - } - } - } - } - } - - //Logger.getLogger(BuildInstallersAction.class.getName()).warning("actionPerformed for " + suiteLocation); - Properties props = new Properties(); - props.put("suite.location", suiteLocation.getAbsolutePath().replace("\\", "/")); - props.put("suite.nbi.product.uid", - appName.replaceAll("[0-9]+", "").replace("_", "-").toLowerCase(Locale.ENGLISH)); - - - props.put("nbi.stub.location", InstalledFileLocator.getDefault().locate( - "nbi/stub", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.stub.common.location", InstalledFileLocator.getDefault().locate( - "nbi/.common", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - - props.put( - "nbi.ant.tasks.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-ant-tasks.jar", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.registries.management.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-registries-management.jar", - "org.netbeans.libs.nbi.ant", false).getAbsolutePath().replace("\\", "/")); - props.put( - "nbi.engine.jar", InstalledFileLocator.getDefault().locate( - "modules/ext/nbi-engine.jar", - "org.netbeans.libs.nbi.engine", false).getAbsolutePath().replace("\\", "/")); - if (licenseFile != null) { - Logger.getLogger(BuildInstallersAction.class.getName()).log(Level.FINE, - "License file is at {0}, exist = {1}", new Object[] {licenseFile, licenseFile.exists()}); - props.put( - "nbi.license.file", licenseFile.getAbsolutePath()); - } - - List platforms = new ArrayList(); - - boolean installerConfDefined = false; - for (String k : new String[] { - SuiteInstallerProjectProperties.GENERATE_FOR_WINDOWS, - SuiteInstallerProjectProperties.GENERATE_FOR_LINUX, - SuiteInstallerProjectProperties.GENERATE_FOR_SOLARIS, - SuiteInstallerProjectProperties.GENERATE_FOR_MAC - }) { - if (prefs.getBoolean(k, false)) { - installerConfDefined = true; - platforms.add(k.replaceFirst("^os-", "")); - } - } - if (!installerConfDefined) { - if (Utilities.isWindows()) { - platforms.add("windows"); - } else if (Utilities.getOperatingSystem() == Utilities.OS_LINUX) { - platforms.add("linux"); - } else if (Utilities.getOperatingSystem() == Utilities.OS_SOLARIS) { - platforms.add("solaris"); - } else if (Utilities.isMac()) { - platforms.add("macosx"); - } - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < platforms.size(); i++) { - if (i != 0) { - sb.append(" "); - } - sb.append(platforms.get(i)); - } - if (sb.length() == 0) { - //nothing to build - RequestProcessor.getDefault().post(new Runnable() { - public @Override void run() { - DialogDescriptor d = new DialogDescriptor( - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Message"), - NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.Title")); - d.setModal(true); - JButton accept = new JButton(NbBundle.getMessage(BuildInstallersAction.class, "BuildInstallersAction.NotConfigured.Warning.OK")); - accept.setDefaultCapable(true); - d.setOptions(new Object[]{ - accept}); - d.setMessageType(NotifyDescriptor.WARNING_MESSAGE); - if (DialogDisplayer.getDefault().notify(d).equals(accept)) { - //SuiteCustomizer cpi = prj.getLookup().lookup(org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer.class); - //cpi.showCustomizer(SuiteCustomizer.APPLICATION, SuiteCustomizer.APPLICATION_CREATE_STANDALONE_APPLICATION); - } - } - }); - return; - } - - props.put("generate.installer.for.platforms", - sb.toString()); - - - - File javaHome = new File(System.getProperty("java.home")); - if (new File(javaHome, - "lib/rt.jar").exists() && javaHome.getName().equals("jre")) { - javaHome = javaHome.getParentFile(); - } - props.put( - "generator-jdk-location-forward-slashes", javaHome.getAbsolutePath().replace("\\", "/")); - /* - props.put( - "generated-installers-location-forward-slashes", - new File(suiteLocation, "dist").getAbsolutePath().replace("\\", "/")); - */ - - if(appIcon!=null) { - File appIconFile = new File(appIcon); - if(!appIconFile.equals(appIconFile.getAbsoluteFile())) { - //path is relative to suite directory - appIconFile = new File(suiteLocation, appIcon); - } - props.put( - "nbi.icon.file", appIconFile.getAbsolutePath()); - - } - - if(appIconIcnsFile!=null) { - props.put( - "nbi.dock.icon.file", appIconIcnsFile.getAbsolutePath()); - } - - try { - ActionUtils.runTarget(findGenXml(), new String[]{"build"}, props); - } catch (FileStateInvalidException ex) { - ErrorManager.getDefault().getInstance("org.netbeans.modules.apisupport.project").notify(ex); // NOI18N - } catch (IOException ex) { - ErrorManager.getDefault().getInstance("org.netbeans.modules.apisupport.project").notify(ex); // NOI18N - } - } - - } - - - private static FileObject findGenXml() { - return FileUtil.toFileObject(InstalledFileLocator.getDefault().locate( - "nbi/stub/template.xml", - "org.netbeans.libs.nbi.ant", false)); - } - } -} - - diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/Bundle.properties b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/Bundle.properties deleted file mode 100644 index eb3928437c81..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/Bundle.properties +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -CTL_BuildInstallers=Installers -BuildInstallersAction.NotApp.Warning.Message=\ - In order to create installers this project should be switched to standalone application.\n\ - Open project properties, switch to Application panel and set type to Standalone Application. -BuildInstallersAction.NotApp.Warning.Title=Warning -BuildInstallersAction.NotApp.Warning.OK=OK - -BuildInstallersAction.NotConfigured.Warning.Message=\ - In order to create installers please select at least one target platform.\n\ - Open project properties, switch to Installer panel and configure installer settings. -BuildInstallersAction.NotConfigured.Warning.Title=Warning -BuildInstallersAction.NotConfigured.Warning.OK=OK \ No newline at end of file diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/Apache-2.0 b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/Apache-2.0 deleted file mode 100644 index d64569567334..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/Apache-2.0 +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-1.0 b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-1.0 deleted file mode 100644 index d8a159735177..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-1.0 +++ /dev/null @@ -1,380 +0,0 @@ -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - -1.1. "Contributor" means each individual or entity that -creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the -Original Software, prior Modifications used by a -Contributor (if any), and the Modifications made by that -particular Contributor. - -1.3. "Covered Software" means (a) the Original Software, or -(b) Modifications, or (c) the combination of files -containing Original Software with files containing -Modifications, in each case including portions thereof. - -1.4. "Executable" means the Covered Software in any form -other than Source Code. - -1.5. "Initial Developer" means the individual or entity -that first makes Original Software available under this -License. - -1.6. "Larger Work" means a work which combines Covered -Software or portions thereof with code not governed by the -terms of this License. - -1.7. "License" means this document. - -1.8. "Licensable" means having the right to grant, to the -maximum extent possible, whether at the time of the initial -grant or subsequently acquired, any and all of the rights -conveyed herein. - -1.9. "Modifications" means the Source Code and Executable -form of any of the following: - -A. Any file that results from an addition to, -deletion from or modification of the contents of a -file containing Original Software or previous -Modifications; - -B. Any new file that contains any part of the -Original Software or previous Modification; or - -C. Any new file that is contributed or otherwise made -available under the terms of this License. - -1.10. "Original Software" means the Source Code and -Executable form of computer software code that is -originally released under this License. - -1.11. "Patent Claims" means any patent claim(s), now owned -or hereafter acquired, including without limitation, -method, process, and apparatus claims, in any patent -Licensable by grantor. - -1.12. "Source Code" means (a) the common form of computer -software code in which modifications are made and (b) -associated documentation included in or with such code. - -1.13. "You" (or "Your") means an individual or a legal -entity exercising rights under, and complying with all of -the terms of, this License. For legal entities, "You" -includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this -definition, "control" means (a) the power, direct or -indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership -of more than fifty percent (50%) of the outstanding shares -or beneficial ownership of such entity. - -2. License Grants. - -2.1. The Initial Developer Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, the -Initial Developer hereby grants You a world-wide, -royalty-free, non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Initial Developer, -to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or -portions thereof), with or without Modifications, -and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using or selling of Original Software, to make, have -made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or -portions thereof). - -(c) The licenses granted in Sections 2.1(a) and (b) -are effective on the date Initial Developer first -distributes or otherwise makes the Original Software -available to a third party under the terms of this -License. - -(d) Notwithstanding Section 2.1(b) above, no patent -license is granted: (1) for code that You delete from -the Original Software, or (2) for infringements -caused by: (i) the modification of the Original -Software, or (ii) the combination of the Original -Software with other software or devices. - -2.2. Contributor Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, each -Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Contributor to -use, reproduce, modify, display, perform, sublicense -and distribute the Modifications created by such -Contributor (or portions thereof), either on an -unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using, or selling of Modifications made by that -Contributor either alone and/or in combination with -its Contributor Version (or portions of such -combination), to make, use, sell, offer for sale, -have made, and/or otherwise dispose of: (1) -Modifications made by that Contributor (or portions -thereof); and (2) the combination of Modifications -made by that Contributor with its Contributor Version -(or portions of such combination). - -(c) The licenses granted in Sections 2.2(a) and -2.2(b) are effective on the date Contributor first -distributes or otherwise makes the Modifications -available to a third party. - -(d) Notwithstanding Section 2.2(b) above, no patent -license is granted: (1) for any code that Contributor -has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party -modifications of Contributor Version, or (ii) the -combination of Modifications made by that Contributor -with other software (except as part of the -Contributor Version) or other devices; or (3) under -Patent Claims infringed by Covered Software in the -absence of Modifications made by that Contributor. - -3. Distribution Obligations. - -3.1. Availability of Source Code. - -Any Covered Software that You distribute or otherwise make -available in Executable form must also be made available in -Source Code form and that Source Code form must be -distributed only under the terms of this License. You must -include a copy of this License with every copy of the -Source Code form of the Covered Software You distribute or -otherwise make available. You must inform recipients of any -such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a -reasonable manner on or through a medium customarily used -for software exchange. - -3.2. Modifications. - -The Modifications that You create or to which You -contribute are governed by the terms of this License. You -represent that You believe Your Modifications are Your -original creation(s) and/or You have sufficient rights to -grant the rights conveyed by this License. - -3.3. Required Notices. - -You must include a notice in each of Your Modifications -that identifies You as the Contributor of the Modification. -You may not remove or alter any copyright, patent or -trademark notices contained within the Covered Software, or -any notices of licensing or any descriptive text giving -attribution to any Contributor or the Initial Developer. - -3.4. Application of Additional Terms. - -You may not offer or impose any terms on any Covered -Software in Source Code form that alters or restricts the -applicable version of this License or the recipients' -rights hereunder. You may choose to offer, and to charge a -fee for, warranty, support, indemnity or liability -obligations to one or more recipients of Covered Software. -However, you may do so only on Your own behalf, and not on -behalf of the Initial Developer or any Contributor. You -must make it absolutely clear that any such warranty, -support, indemnity or liability obligation is offered by -You alone, and You hereby agree to indemnify the Initial -Developer and every Contributor for any liability incurred -by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.5. Distribution of Executable Versions. - -You may distribute the Executable form of the Covered -Software under the terms of this License or under the terms -of a license of Your choice, which may contain terms -different from this License, provided that You are in -compliance with the terms of this License and that the -license for the Executable form does not attempt to limit -or alter the recipient's rights in the Source Code form -from the rights set forth in this License. If You -distribute the Covered Software in Executable form under a -different license, You must make it absolutely clear that -any terms which differ from this License are offered by You -alone, not by the Initial Developer or Contributor. You -hereby agree to indemnify the Initial Developer and every -Contributor for any liability incurred by the Initial -Developer or such Contributor as a result of any such terms -You offer. - -3.6. Larger Works. - -You may create a Larger Work by combining Covered Software -with other code not governed by the terms of this License -and distribute the Larger Work as a single product. In such -a case, You must make sure the requirements of this License -are fulfilled for the Covered Software. - -4. Versions of the License. - -4.1. New Versions. - -Sun Microsystems, Inc. is the initial license steward and -may publish revised and/or new versions of this License -from time to time. Each version will be given a -distinguishing version number. Except as provided in -Section 4.3, no one other than the license steward has the -right to modify this License. - -4.2. Effect of New Versions. - -You may always continue to use, distribute or otherwise -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. If the Initial Developer includes a -notice in the Original Software prohibiting it from being -distributed or otherwise made available under any -subsequent version of the License, You must distribute and -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. Otherwise, You may also choose to -use, distribute or otherwise make the Covered Software -available under the terms of any subsequent version of the -License published by the license steward. - -4.3. Modified Versions. - -When You are an Initial Developer and You want to create a -new license for Your Original Software, You may create and -use a modified version of this License if You: (a) rename -the license and remove any references to the name of the -license steward (except to note that the license differs -from this License); and (b) otherwise make it clear that -the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" -BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED -SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR -PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY -COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE -INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF -ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF -WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF -ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS -DISCLAIMER. - -6. TERMINATION. - -6.1. This License and the rights granted hereunder will -terminate automatically if You fail to comply with terms -herein and fail to cure such breach within 30 days of -becoming aware of the breach. Provisions which, by their -nature, must remain in effect beyond the termination of -this License shall survive. - -6.2. If You assert a patent infringement claim (excluding -declaratory judgment actions) against Initial Developer or -a Contributor (the Initial Developer or Contributor against -whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the -Contributor Version where the Participant is a Contributor -or the Original Software where the Participant is the -Initial Developer) directly or indirectly infringes any -patent, then any and all rights granted directly or -indirectly to You by such Participant, the Initial -Developer (if the Initial Developer is not the Participant) -and all Contributors under Sections 2.1 and/or 2.2 of this -License shall, upon 60 days notice from Participant -terminate prospectively and automatically at the expiration -of such 60 day notice period, unless if within such 60 day -period You withdraw Your claim with respect to the -Participant Software against such Participant either -unilaterally or pursuant to a written agreement with -Participant. - -6.3. In the event of termination under Sections 6.1 or 6.2 -above, all end user licenses that have been validly granted -by You or any distributor hereunder prior to termination -(excluding licenses granted to You by any distributor) -shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT -(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF -COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE -LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN -INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF -LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT -APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO -NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT -APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a "commercial item," as that term is -defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial -computer software" (as that term is defined at 48 C.F.R. -252.227-7014(a)(1)) and "commercial computer software -documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 -through 227.7202-4 (June 1995), all U.S. Government End Users -acquire Covered Software with only those rights set forth herein. -This U.S. Government Rights clause is in lieu of, and supersedes, -any other FAR, DFAR, or other clause or provision that addresses -Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the -extent necessary to make it enforceable. This License shall be -governed by the law of the jurisdiction specified in a notice -contained within the Original Software (except to the extent -applicable law, if any, provides otherwise), excluding such -jurisdiction's conflict-of-law provisions. Any litigation -relating to this License shall be subject to the jurisdiction of -the courts located in the jurisdiction and venue specified in a -notice contained within the Original Software, with the losing -party responsible for costs, including, without limitation, court -costs and reasonable attorneys' fees and expenses. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. Any law or -regulation which provides that the language of a contract shall -be construed against the drafter shall not apply to this License. -You agree that You alone are responsible for compliance with the -United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is -responsible for claims and damages arising, directly or -indirectly, out of its utilization of rights under this License -and You agree to work with Initial Developer and Contributors to -distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission -of liability. diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-GPL-2-CP b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-GPL-2-CP deleted file mode 100644 index 78ba69c73397..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-GPL-2-CP +++ /dev/null @@ -1,826 +0,0 @@ -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - -1.1. "Contributor" means each individual or entity that -creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the -Original Software, prior Modifications used by a -Contributor (if any), and the Modifications made by that -particular Contributor. - -1.3. "Covered Software" means (a) the Original Software, or -(b) Modifications, or (c) the combination of files -containing Original Software with files containing -Modifications, in each case including portions thereof. - -1.4. "Executable" means the Covered Software in any form -other than Source Code. - -1.5. "Initial Developer" means the individual or entity -that first makes Original Software available under this -License. - -1.6. "Larger Work" means a work which combines Covered -Software or portions thereof with code not governed by the -terms of this License. - -1.7. "License" means this document. - -1.8. "Licensable" means having the right to grant, to the -maximum extent possible, whether at the time of the initial -grant or subsequently acquired, any and all of the rights -conveyed herein. - -1.9. "Modifications" means the Source Code and Executable -form of any of the following: - -A. Any file that results from an addition to, -deletion from or modification of the contents of a -file containing Original Software or previous -Modifications; - -B. Any new file that contains any part of the -Original Software or previous Modification; or - -C. Any new file that is contributed or otherwise made -available under the terms of this License. - -1.10. "Original Software" means the Source Code and -Executable form of computer software code that is -originally released under this License. - -1.11. "Patent Claims" means any patent claim(s), now owned -or hereafter acquired, including without limitation, -method, process, and apparatus claims, in any patent -Licensable by grantor. - -1.12. "Source Code" means (a) the common form of computer -software code in which modifications are made and (b) -associated documentation included in or with such code. - -1.13. "You" (or "Your") means an individual or a legal -entity exercising rights under, and complying with all of -the terms of, this License. For legal entities, "You" -includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this -definition, "control" means (a) the power, direct or -indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership -of more than fifty percent (50%) of the outstanding shares -or beneficial ownership of such entity. - -2. License Grants. - -2.1. The Initial Developer Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, the -Initial Developer hereby grants You a world-wide, -royalty-free, non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Initial Developer, -to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or -portions thereof), with or without Modifications, -and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using or selling of Original Software, to make, have -made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or -portions thereof). - -(c) The licenses granted in Sections 2.1(a) and (b) -are effective on the date Initial Developer first -distributes or otherwise makes the Original Software -available to a third party under the terms of this -License. - -(d) Notwithstanding Section 2.1(b) above, no patent -license is granted: (1) for code that You delete from -the Original Software, or (2) for infringements -caused by: (i) the modification of the Original -Software, or (ii) the combination of the Original -Software with other software or devices. - -2.2. Contributor Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, each -Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Contributor to -use, reproduce, modify, display, perform, sublicense -and distribute the Modifications created by such -Contributor (or portions thereof), either on an -unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using, or selling of Modifications made by that -Contributor either alone and/or in combination with -its Contributor Version (or portions of such -combination), to make, use, sell, offer for sale, -have made, and/or otherwise dispose of: (1) -Modifications made by that Contributor (or portions -thereof); and (2) the combination of Modifications -made by that Contributor with its Contributor Version -(or portions of such combination). - -(c) The licenses granted in Sections 2.2(a) and -2.2(b) are effective on the date Contributor first -distributes or otherwise makes the Modifications -available to a third party. - -(d) Notwithstanding Section 2.2(b) above, no patent -license is granted: (1) for any code that Contributor -has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party -modifications of Contributor Version, or (ii) the -combination of Modifications made by that Contributor -with other software (except as part of the -Contributor Version) or other devices; or (3) under -Patent Claims infringed by Covered Software in the -absence of Modifications made by that Contributor. - -3. Distribution Obligations. - -3.1. Availability of Source Code. - -Any Covered Software that You distribute or otherwise make -available in Executable form must also be made available in -Source Code form and that Source Code form must be -distributed only under the terms of this License. You must -include a copy of this License with every copy of the -Source Code form of the Covered Software You distribute or -otherwise make available. You must inform recipients of any -such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a -reasonable manner on or through a medium customarily used -for software exchange. - -3.2. Modifications. - -The Modifications that You create or to which You -contribute are governed by the terms of this License. You -represent that You believe Your Modifications are Your -original creation(s) and/or You have sufficient rights to -grant the rights conveyed by this License. - -3.3. Required Notices. - -You must include a notice in each of Your Modifications -that identifies You as the Contributor of the Modification. -You may not remove or alter any copyright, patent or -trademark notices contained within the Covered Software, or -any notices of licensing or any descriptive text giving -attribution to any Contributor or the Initial Developer. - -3.4. Application of Additional Terms. - -You may not offer or impose any terms on any Covered -Software in Source Code form that alters or restricts the -applicable version of this License or the recipients' -rights hereunder. You may choose to offer, and to charge a -fee for, warranty, support, indemnity or liability -obligations to one or more recipients of Covered Software. -However, you may do so only on Your own behalf, and not on -behalf of the Initial Developer or any Contributor. You -must make it absolutely clear that any such warranty, -support, indemnity or liability obligation is offered by -You alone, and You hereby agree to indemnify the Initial -Developer and every Contributor for any liability incurred -by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.5. Distribution of Executable Versions. - -You may distribute the Executable form of the Covered -Software under the terms of this License or under the terms -of a license of Your choice, which may contain terms -different from this License, provided that You are in -compliance with the terms of this License and that the -license for the Executable form does not attempt to limit -or alter the recipient's rights in the Source Code form -from the rights set forth in this License. If You -distribute the Covered Software in Executable form under a -different license, You must make it absolutely clear that -any terms which differ from this License are offered by You -alone, not by the Initial Developer or Contributor. You -hereby agree to indemnify the Initial Developer and every -Contributor for any liability incurred by the Initial -Developer or such Contributor as a result of any such terms -You offer. - -3.6. Larger Works. - -You may create a Larger Work by combining Covered Software -with other code not governed by the terms of this License -and distribute the Larger Work as a single product. In such -a case, You must make sure the requirements of this License -are fulfilled for the Covered Software. - -4. Versions of the License. - -4.1. New Versions. - -Sun Microsystems, Inc. is the initial license steward and -may publish revised and/or new versions of this License -from time to time. Each version will be given a -distinguishing version number. Except as provided in -Section 4.3, no one other than the license steward has the -right to modify this License. - -4.2. Effect of New Versions. - -You may always continue to use, distribute or otherwise -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. If the Initial Developer includes a -notice in the Original Software prohibiting it from being -distributed or otherwise made available under any -subsequent version of the License, You must distribute and -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. Otherwise, You may also choose to -use, distribute or otherwise make the Covered Software -available under the terms of any subsequent version of the -License published by the license steward. - -4.3. Modified Versions. - -When You are an Initial Developer and You want to create a -new license for Your Original Software, You may create and -use a modified version of this License if You: (a) rename -the license and remove any references to the name of the -license steward (except to note that the license differs -from this License); and (b) otherwise make it clear that -the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" -BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED -SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR -PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY -COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE -INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF -ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF -WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF -ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS -DISCLAIMER. - -6. TERMINATION. - -6.1. This License and the rights granted hereunder will -terminate automatically if You fail to comply with terms -herein and fail to cure such breach within 30 days of -becoming aware of the breach. Provisions which, by their -nature, must remain in effect beyond the termination of -this License shall survive. - -6.2. If You assert a patent infringement claim (excluding -declaratory judgment actions) against Initial Developer or -a Contributor (the Initial Developer or Contributor against -whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the -Contributor Version where the Participant is a Contributor -or the Original Software where the Participant is the -Initial Developer) directly or indirectly infringes any -patent, then any and all rights granted directly or -indirectly to You by such Participant, the Initial -Developer (if the Initial Developer is not the Participant) -and all Contributors under Sections 2.1 and/or 2.2 of this -License shall, upon 60 days notice from Participant -terminate prospectively and automatically at the expiration -of such 60 day notice period, unless if within such 60 day -period You withdraw Your claim with respect to the -Participant Software against such Participant either -unilaterally or pursuant to a written agreement with -Participant. - -6.3. If You assert a patent infringement claim against -Participant alleging that the Participant Software directly -or indirectly infringes any patent where such claim is -resolved (such as by license or settlement) prior to the -initiation of patent infringement litigation, then the -reasonable value of the licenses granted by such Participant -under Sections 2.1 or 2.2 shall be taken into account in -determining the amount or value of any payment or license. - -6.4. In the event of termination under Sections 6.1 or 6.2 -above, all end user licenses that have been validly granted -by You or any distributor hereunder prior to termination -(excluding licenses granted to You by any distributor) -shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT -(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF -COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE -LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN -INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF -LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT -APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO -NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT -APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a "commercial item," as that term is -defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial -computer software" (as that term is defined at 48 C.F.R. -§ 252.227-7014(a)(1)) and "commercial computer software -documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 -through 227.7202-4 (June 1995), all U.S. Government End Users -acquire Covered Software with only those rights set forth herein. -This U.S. Government Rights clause is in lieu of, and supersedes, -any other FAR, DFAR, or other clause or provision that addresses -Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the -extent necessary to make it enforceable. This License shall be -governed by the law of the jurisdiction specified in a notice -contained within the Original Software (except to the extent -applicable law, if any, provides otherwise), excluding such -jurisdiction's conflict-of-law provisions. Any litigation -relating to this License shall be subject to the jurisdiction of -the courts located in the jurisdiction and venue specified in a -notice contained within the Original Software, with the losing -party responsible for costs, including, without limitation, court -costs and reasonable attorneys' fees and expenses. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. Any law or -regulation which provides that the language of a contract shall -be construed against the drafter shall not apply to this License. -You agree that You alone are responsible for compliance with the -United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is -responsible for claims and damages arising, directly or -indirectly, out of its utilization of rights under this License -and You agree to work with Initial Developer and Contributors to -distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission -of liability. - -NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND -DISTRIBUTION LICENSE (CDDL) - -The code released under the CDDL shall be governed by the laws -of the State of California (excluding conflict-of-law provisions). -Any litigation relating to this License shall be subject to the -jurisdiction of the Federal Courts of the Northern District of -California and the state courts of the State of California, with -venue lying in Santa Clara County, California. - - -The GNU General Public License (GPL) -Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim - copies of this license document, but changing it is not - allowed. - - Preamble - -The licenses for most software are designed to take away -your freedom to share and change it. By contrast, the GNU -General Public License is intended to guarantee your freedom -to share and change free software--to make sure the software -is free for all its users. This General Public License -applies to most of the Free Software Foundation's software -and to any other program whose authors commit to using it. -(Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can -apply it to your programs, too. - -When we speak of free software, we are referring to freedom, -not price. Our General Public Licenses are designed to make -sure that you have the freedom to distribute copies of free -software (and charge for this service if you wish), that you -receive source code or can get it if you want it, that you -can change the software or use pieces of it in new free -programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that -forbid anyone to deny you these rights or to ask you to -surrender the rights. These restrictions translate to -certain responsibilities for you if you distribute copies of -the software, or if you modify it. - -For example, if you distribute copies of such a program, -whether gratis or for a fee, you must give the recipients -all the rights that you have. You must make sure that they, -too, receive or can get the source code. And you must show -them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the -software, and (2) offer you this license which gives you -legal permission to copy, distribute and/or modify the -software. - -Also, for each author's protection and ours, we want to make -certain that everyone understands that there is no warranty -for this free software. If the software is modified by -someone else and passed on, we want its recipients to know -that what they have is not the original, so that any -problems introduced by others will not reflect on the -original authors' reputations. - -Finally, any free program is threatened constantly by -software patents. We wish to avoid the danger that -redistributors of a free program will individually obtain -patent licenses, in effect making the program proprietary. -To prevent this, we have made it clear that any patent must -be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution -and modification follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND -MODIFICATION - -0. This License applies to any program or other work which -contains a notice placed by the copyright holder saying it -may be distributed under the terms of this General Public -License. The "Program", below, refers to any such program or -work, and a "work based on the Program" means either the -Program or any derivative work under copyright law: that is -to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into -another language. (Hereinafter, translation is included -without limitation in the term "modification".) Each -licensee is addressed as "you". - -Activities other than copying, distribution and modification -are not covered by this License; they are outside its scope. -The act of running the Program is not restricted, and the -output from the Program is covered only if its contents -constitute a work based on the Program (independent of -having been made by running the Program). Whether that is -true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the -Program's source code as you receive it, in any medium, -provided that you conspicuously and appropriately publish on -each copy an appropriate copyright notice and disclaimer of -warranty; keep intact all the notices that refer to this -License and to the absence of any warranty; and give any -other recipients of the Program a copy of this License along -with the Program. - -You may charge a fee for the physical act of transferring a -copy, and you may at your option offer warranty protection -in exchange for a fee. - -2. You may modify your copy or copies of the Program or any -portion of it, thus forming a work based on the Program, and -copy and distribute such modifications or work under the -terms of Section 1 above, provided that you also meet all of -these conditions: - - a) You must cause the modified files to carry prominent - notices stating that you changed the files and the date - of any change. - - b) You must cause any work that you distribute or - publish, that in whole or in part contains or is derived - from the Program or any part thereof, to be licensed as - a whole at no charge to all third parties under the - terms of this License. - - c) If the modified program normally reads commands - interactively when run, you must cause it, when started - running for such interactive use in the most ordinary - way, to print or display an announcement including an - appropriate copyright notice and a notice that there is - no warranty (or else, saying that you provide a - warranty) and that users may redistribute the program - under these conditions, and telling the user how to view - a copy of this License. (Exception: if the Program - itself is interactive but does not normally print such - an announcement, your work based on the Program is not - required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the -Program, and can be reasonably considered independent and -separate works in themselves, then this License, and its -terms, do not apply to those sections when you distribute -them as separate works. But when you distribute the same -sections as part of a whole which is a work based on the -Program, the distribution of the whole must be on the terms -of this License, whose permissions for other licensees -extend to the entire whole, and thus to each and every part -regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights -or contest your rights to work written entirely by you; -rather, the intent is to exercise the right to control the -distribution of derivative or collective works based on the -Program. - -In addition, mere aggregation of another work not based on -the Program with the Program (or with a work based on the -Program) on a volume of a storage or distribution medium -does not bring the other work under the scope of this -License. - -3. You may copy and distribute the Program (or a work based -on it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you -also do one of the following: - - a) Accompany it with the complete corresponding - machine-readable source code, which must be distributed - under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least - three years, to give any third party, for a charge no - more than your cost of physically performing source - distribution, a complete machine-readable copy of the - corresponding source code, to be distributed under the - terms of Sections 1 and 2 above on a medium customarily - used for software interchange; or, - - c) Accompany it with the information you received as to - the offer to distribute corresponding source code. (This - alternative is allowed only for noncommercial - distribution and only if you received the program in - object code or executable form with such an offer, in - accord with Subsection b above.) - -The source code for a work means the preferred form of the -work for making modifications to it. For an executable work, -complete source code means all the source code for all -modules it contains, plus any associated interface -definition files, plus the scripts used to control -compilation and installation of the executable. However, as -a special exception, the source code distributed need not -include anything that is normally distributed (in either -source or binary form) with the major components (compiler, -kernel, and so on) of the operating system on which the -executable runs, unless that component itself accompanies -the executable. - -If distribution of executable or object code is made by -offering access to copy from a designated place, then -offering equivalent access to copy the source code from the -same place counts as distribution of the source code, even -though third parties are not compelled to copy the source -along with the object code. - -4. You may not copy, modify, sublicense, or distribute the -Program except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense or distribute -the Program is void, and will automatically terminate your -rights under this License. However, parties who have -received copies, or rights, from you under this License will -not have their licenses terminated so long as such parties -remain in full compliance. - -5. You are not required to accept this License, since you -have not signed it. However, nothing else grants you -permission to modify or distribute the Program or its -derivative works. These actions are prohibited by law if you -do not accept this License. Therefore, by modifying or -distributing the Program (or any work based on the Program), -you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or -modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based -on the Program), the recipient automatically receives a -license from the original licensor to copy, distribute or -modify the Program subject to these terms and conditions. -You may not impose any further restrictions on the -recipients' exercise of the rights granted herein. You are -not responsible for enforcing compliance by third parties to -this License. - -7. If, as a consequence of a court judgment or allegation of -patent infringement or for any other reason (not limited to -patent issues), conditions are imposed on you (whether by -court order, agreement or otherwise) that contradict the -conditions of this License, they do not excuse you from the -conditions of this License. If you cannot distribute so as -to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a -consequence you may not distribute the Program at all. For -example, if a patent license would not permit royalty-free -redistribution of the Program by all those who receive -copies directly or indirectly through you, then the only way -you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or -unenforceable under any particular circumstance, the balance -of the section is intended to apply and the section as a -whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to -infringe any patents or other property right claims or to -contest validity of any such claims; this section has the -sole purpose of protecting the integrity of the free -software distribution system, which is implemented by public -license practices. Many people have made generous -contributions to the wide range of software distributed -through that system in reliance on consistent application of -that system; it is up to the author/donor to decide if he or -she is willing to distribute software through any other -system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is -believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is -restricted in certain countries either by patents or by -copyrighted interfaces, the original copyright holder who -places the Program under this License may add an explicit -geographical distribution limitation excluding those -countries, so that distribution is permitted only in or -among countries not thus excluded. In such case, this -License incorporates the limitation as if written in the -body of this License. - -9. The Free Software Foundation may publish revised and/or -new versions of the General Public License from time to -time. Such new versions will be similar in spirit to the -present version, but may differ in detail to address new -problems or concerns. - -Each version is given a distinguishing version number. If -the Program specifies a version number of this License which -applies to it and "any later version", you have the option -of following the terms and conditions either of that version -or of any later version published by the Free Software -Foundation. If the Program does not specify a version number -of this License, you may choose any version ever published -by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into -other free programs whose distribution conditions are -different, write to the author to ask for permission. For -software which is copyrighted by the Free Software -Foundation, write to the Free Software Foundation; we -sometimes make exceptions for this. Our decision will be -guided by the two goals of preserving the free status of all -derivatives of our free software and of promoting the -sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS -NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE -COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM -"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR -IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE -OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE -DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED -TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY -WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED -ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, -SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF -THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT -LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR -LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH -HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the -greatest possible use to the public, the best way to achieve -this is to make it free software which everyone can -redistribute and change under these terms. - -To do so, attach the following notices to the program. It is -safest to attach them to the start of each source file to -most effectively convey the exclusion of warranty; and each -file should have at least the "copyright" line and a pointer -to where the full notice is found. - - One line to give the program's name and a brief idea of - what it does. Copyright (C) - - This program is free software; you can redistribute it - and/or modify it under the terms of the GNU General - Public License as published by the Free Software - Foundation; either version 2 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A - PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General - Public License along with this program; if not, write to - the Free Software Foundation, Inc., 59 Temple Place, - Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and -paper mail. - -If the program is interactive, make it output a short notice -like this when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of - author Gnomovision comes with ABSOLUTELY NO WARRANTY; - for details type `show w'. This is free software, and - you are welcome to redistribute it under certain - conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show -the appropriate parts of the General Public License. Of -course, the commands you use may be called something other -than `show w' and `show c'; they could even be mouse-clicks -or menu items--whatever suits your program. - -You should also get your employer (if you work as a -programmer) or your school, if any, to sign a "copyright -disclaimer" for the program, if necessary. Here is a sample; -alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in - the program `Gnomovision' (which makes passes at - compilers) written by James Hacker. - - signature of Ty Coon, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating -your program into proprietary programs. If your program is a -subroutine library, you may consider it more useful to -permit linking proprietary applications with the library. If -this is what you want to do, use the GNU Library General -Public License instead of this License. - - -"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 - - -Certain source files distributed by Sun Microsystems, Inc. -are subject to the following clarification and special -exception to the GPL Version 2, but only where Sun has expressly -included in the particular source file's header the words -"Sun designates this particular file as subject to the -"Classpath" exception as provided by Sun in the License file -that accompanied this code." - -Linking this library statically or dynamically with other -modules is making a combined work based on this library. -Thus, the terms and conditions of the GNU General Public -License Version 2 cover the whole combination. - -As a special exception, the copyright holders of this -library give you permission to link this library with -independent modules to produce an executable, regardless of -the license terms of these independent modules, and to copy -and distribute the resulting executable under terms of your -choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license -of that module. An independent module is a module which is -not derived from or based on this library. If you modify -this library, you may extend this exception to your version -of the library, but you are not obligated to do so. If you -do not wish to do so, delete this exception statement from -your version. diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/Bundle.properties b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/Bundle.properties deleted file mode 100644 index 696d2cf50f56..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/Bundle.properties +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -LBL_InstallerPanel=Installer - -InstallerPanel.OSLabelWindows=W&indows -InstallerPanel.OSLabelLinux=Li&nux -InstallerPanel.OSLabelMacOS=M&ac OS X -InstallerPanel.OSLabelSolaris=S&olaris - -InstallerPanel.Platforms.Label=Generate installers for: -InstallerPanel.licenseLabel.text=Application &license: -InstallerPanel_License.FileChooser.Title=Select License File... - -SuiteInstallerProjectProperties.license.type.no=No License -SuiteInstallerProjectProperties.license.type.cddl=CDDL 1.0 -SuiteInstallerProjectProperties.license.type.cddl+gplv2=CDDL 1.0 + GPL v2 with ClassPath Exception -SuiteInstallerProjectProperties.license.type.apache.v2=Apache License Version 2.0 -SuiteInstallerProjectProperties.license.type.custom=Select License File... -#InstallerPanel.license.type.custom=Custom... - -#SuiteInstallerProjectProperties.license.file.no= -SuiteInstallerProjectProperties.license.file.cddl=nbres:/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-1.0 -SuiteInstallerProjectProperties.license.file.cddl+gplv2=nbres:/org/netbeans/modules/apisupport/installer/resources/licenses/CDDL-GPL-2-CP -SuiteInstallerProjectProperties.license.file.apache.v2=nbres:/org/netbeans/modules/apisupport/installer/resources/licenses/Apache-2.0 -InstallerPanel.pack200checkBox.text=Use pac&k200 compression -InstallerPanel.Pack200.Description.Text=Note: Pack200 compression significantly (up to 70%) descreases installer size. - -InstallerPanel.OSLabelWindows.AccessibleContext.accessible=Generate installers for Windows platform -InstallerPanel.OSLabelLinux.AccessibleContext.accessible=Generate installers for Linux platform -InstallerPanel.OSLabelMacOS.AccessibleContext.accessible=Generate installers for Mac OS X platform -InstallerPanel.OSLabelSolaris.AccessibleContext.accessible=Generate installers for Solaris platform -InstallerPanel.jCheckBox5.AccessibleContext.accessibleDescription=Select to enable pack200 compression in generated installers -InstallerPanel.licenseComboBox.AccessibleContext.accessibleName=Application license -InstallerPanel.licenseComboBox.AccessibleContext.accessibleDescription=Choose the license which covers the application diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/ExtraPanel.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/ExtraPanel.java deleted file mode 100644 index 68c6c0e82eb7..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/ExtraPanel.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.modules.apisupport.installer.ui; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import javax.swing.JComponent; -import org.netbeans.api.project.Project; -import org.netbeans.spi.project.ui.support.ProjectCustomizer; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.Exceptions; - - -@ProjectCustomizer.CompositeCategoryProvider.Registration( - projectType="org-netbeans-modules-apisupport-project-suite", - position=1000 -) -public class ExtraPanel implements ProjectCustomizer.CompositeCategoryProvider { - - public @Override ProjectCustomizer.Category createCategory(Lookup context) { - return ProjectCustomizer.Category.create( - "Installer", - NbBundle.getMessage(ExtraPanel.class, "LBL_InstallerPanel"), - null, - (ProjectCustomizer.Category[])null); - } - - public @Override JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { - SuiteInstallerProjectProperties installerProjectProperties = new SuiteInstallerProjectProperties(context.lookup(Project.class)); - // use OkListener to create new configuration first - //category.setOkButtonListener(new OkButtonListener(installerProjectProperties, context.lookup(Project.class))); - category.setStoreListener(new SavePropsListener(installerProjectProperties)); - return new InstallerPanel(installerProjectProperties); - } - - private static class SavePropsListener implements ActionListener { - - private SuiteInstallerProjectProperties installerProps; - - public SavePropsListener(SuiteInstallerProjectProperties props) { - installerProps = props; - } - - public @Override void actionPerformed(ActionEvent e) { - try { - installerProps.store(); - } catch (IOException ioe) { - Exceptions.printStackTrace(ioe); - } - } -}} diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.form b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.form deleted file mode 100644 index 9e2d21e3e475..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.form +++ /dev/null @@ -1,228 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.java deleted file mode 100644 index ceddd40366e1..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/InstallerPanel.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.netbeans.modules.apisupport.installer.ui; - -/** - * - * @author Dmitry Lipin - * @author Alexei Mokeev - */ -public class InstallerPanel extends javax.swing.JPanel { - - private SuiteInstallerProjectProperties installerProps; - - /** Creates new form InstallerPanel */ - public InstallerPanel(SuiteInstallerProjectProperties props) { - this.installerProps = props; - initComponents(); - - jCheckBox1.setModel(installerProps.windowsModel); - jCheckBox2.setModel(installerProps.linuxModel); - jCheckBox3.setModel(installerProps.macModel); - jCheckBox4.setModel(installerProps.solarisModel); - - licenseComboBox.setModel(installerProps.licenseModel); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - jLabel2 = new javax.swing.JLabel(); - jCheckBox1 = new javax.swing.JCheckBox(); - jCheckBox2 = new javax.swing.JCheckBox(); - jCheckBox3 = new javax.swing.JCheckBox(); - jCheckBox4 = new javax.swing.JCheckBox(); - jSeparator1 = new javax.swing.JSeparator(); - licenseLabel = new javax.swing.JLabel(); - licenseComboBox = new javax.swing.JComboBox(); - jCheckBox5 = new javax.swing.JCheckBox(); - jSeparator2 = new javax.swing.JSeparator(); - pack200Info = new javax.swing.JLabel(); - - org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.Platforms.Label")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelWindows")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelLinux")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox3, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelMacOS")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox4, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelSolaris")); // NOI18N - - licenseLabel.setLabelFor(licenseComboBox); - org.openide.awt.Mnemonics.setLocalizedText(licenseLabel, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.licenseLabel.text")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(jCheckBox5, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.pack200checkBox.text")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(pack200Info, org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.Pack200.Description.Text")); // NOI18N - pack200Info.setVerticalAlignment(javax.swing.SwingConstants.TOP); - pack200Info.setFocusable(false); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 1122, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jCheckBox1) - .addComponent(jCheckBox2) - .addComponent(jCheckBox3) - .addComponent(jCheckBox4)) - .addGap(53, 53, 53)) - .addGroup(layout.createSequentialGroup() - .addComponent(licenseLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(licenseComboBox, 0, 1027, Short.MAX_VALUE))) - .addGap(0, 0, 0)))) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jCheckBox5, javax.swing.GroupLayout.DEFAULT_SIZE, 1116, Short.MAX_VALUE) - .addContainerGap()) - .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 1122, Short.MAX_VALUE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGap(31, 31, 31) - .addComponent(pack200Info, javax.swing.GroupLayout.DEFAULT_SIZE, 1091, Short.MAX_VALUE) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jCheckBox1) - .addComponent(jLabel2)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jCheckBox2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jCheckBox3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jCheckBox4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(licenseLabel) - .addComponent(licenseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(7, 7, 7) - .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jCheckBox5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pack200Info, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) - .addGap(99, 99, 99)) - ); - - jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.Platforms.Label")); // NOI18N - jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelWindows.AccessibleContext.accessible")); // NOI18N - jCheckBox2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelLinux.AccessibleContext.accessible")); // NOI18N - jCheckBox3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelMacOS.AccessibleContext.accessible")); // NOI18N - jCheckBox4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.OSLabelSolaris.AccessibleContext.accessible")); // NOI18N - licenseComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.licenseComboBox.AccessibleContext.accessibleName")); // NOI18N - licenseComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.licenseComboBox.AccessibleContext.accessibleDescription")); // NOI18N - jCheckBox5.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(InstallerPanel.class, "InstallerPanel.jCheckBox5.AccessibleContext.accessibleDescription")); // NOI18N - }// //GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JCheckBox jCheckBox1; - private javax.swing.JCheckBox jCheckBox2; - private javax.swing.JCheckBox jCheckBox3; - private javax.swing.JCheckBox jCheckBox4; - private javax.swing.JCheckBox jCheckBox5; - private javax.swing.JLabel jLabel2; - private javax.swing.JSeparator jSeparator1; - private javax.swing.JSeparator jSeparator2; - private javax.swing.JComboBox licenseComboBox; - private javax.swing.JLabel licenseLabel; - private javax.swing.JLabel pack200Info; - // End of variables declaration//GEN-END:variables - - -} diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/LicenseComboBoxModel.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/LicenseComboBoxModel.java deleted file mode 100644 index c41896f1598d..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/LicenseComboBoxModel.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.apisupport.installer.ui; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; -import javax.swing.ComboBoxModel; -import javax.swing.JFileChooser; -import javax.swing.event.ListDataEvent; -import javax.swing.event.ListDataListener; -import org.netbeans.api.project.Project; -import org.openide.filesystems.FileChooserBuilder; -import org.openide.filesystems.FileUtil; -import org.openide.util.NbBundle; - -/** - * - * @author Dmitry Lipin - */ -public class LicenseComboBoxModel implements ComboBoxModel { - - private List listeners; - private List names; - private List types; - private String selectedItem; - private boolean selectedItemFromList; - private Project suiteProject; - - public LicenseComboBoxModel(Project suiteProject, List names, List types) { - this.suiteProject = suiteProject; - this.names = new LinkedList(); - this.names.addAll(names); - - this.types = new LinkedList(); - this.types.addAll(types); - - this.listeners = new LinkedList(); - - if (names.size() > 0) { - this.selectedItem = names.get(0); - this.selectedItemFromList = true; - } else { - this.selectedItem = ""; - this.selectedItemFromList = false; - } - } - - public List getTypes() { - return types; - } - - public List getNames() { - return names; - } - - public String getName() { - if (selectedItemFromList) { - return names.get(names.indexOf(selectedItem)); - } else { - return selectedItem; - } - } - - // comboboxmodel //////////////////////////////////////////////////////////// - public void setSelectedItem(Object item) { - String oldSelectedItem = selectedItem; - selectedItem = (String) item; - - if (names.indexOf(item) != -1) { - if (types.get(names.indexOf(selectedItem)).equals( - SuiteInstallerProjectProperties.LICENSE_TYPE_CUSTOM)) { - - File home = FileUtil.toFile(suiteProject.getProjectDirectory()); - File licenseFile = new FileChooserBuilder("installer-license-dir").setTitle(NbBundle.getMessage(LicenseComboBoxModel.class, "InstallerPanel_License.FileChooser.Title")). - setDefaultWorkingDirectory(home).setFilesOnly(true).showOpenDialog(); - if (licenseFile != null) { - names.add(licenseFile.getAbsolutePath()); - types.add(SuiteInstallerProjectProperties.LICENSE_TYPE_FILE); - selectedItem = names.get(names.size() - 1); - } else { - selectedItem = oldSelectedItem; - } - } - selectedItemFromList = true; - } else { - selectedItemFromList = false; - } - - fireContentsChanged(-1); - } - - public Object getSelectedItem() { - return selectedItem; - } - - public int getSize() { - return names.size(); - } - - public Object getElementAt(int index) { - return names.get(index); - } - - public void addListDataListener(ListDataListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - public void removeListDataListener(ListDataListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - // private ////////////////////////////////////////////////////////////////// - private void fireContentsChanged(int index) { - final ListDataListener[] clone; - synchronized (listeners) { - clone = listeners.toArray(new ListDataListener[0]); - } - - final ListDataEvent event = new ListDataEvent( - this, - ListDataEvent.CONTENTS_CHANGED, - index, - index); - - for (ListDataListener listener : clone) { - listener.contentsChanged(event); - } - } -} - diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/SuiteInstallerProjectProperties.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/SuiteInstallerProjectProperties.java deleted file mode 100644 index 828729cdf17a..000000000000 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/ui/SuiteInstallerProjectProperties.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.modules.apisupport.installer.ui; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.ResourceBundle; -import java.util.prefs.Preferences; -import javax.swing.JToggleButton; -import org.netbeans.api.project.Project; -import org.netbeans.api.project.ProjectUtils; -import org.netbeans.spi.project.support.ant.PropertyUtils; -import org.openide.filesystems.FileUtil; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; - -/** - * - * @author avm - */ -public class SuiteInstallerProjectProperties { - - public static final String GENERATE_FOR_WINDOWS = "os-windows"; - public static final String GENERATE_FOR_LINUX = "os-linux"; - public static final String GENERATE_FOR_SOLARIS = "os-solaris"; - public static final String GENERATE_FOR_MAC = "os-macosx"; - - public static final String LICENSE_TYPE = "license-type"; - public static final String LICENSE_TYPE_NO = "no"; - public static final String LICENSE_TYPE_FILE = "file"; - public static final String LICENSE_TYPE_CUSTOM = "custom"; - public static final String LICENSE_FILE = "license-file"; - - private final Project suiteProject; - final JToggleButton.ToggleButtonModel windowsModel; - final JToggleButton.ToggleButtonModel linuxModel; - final JToggleButton.ToggleButtonModel solarisModel; - final JToggleButton.ToggleButtonModel macModel; - final LicenseComboBoxModel licenseModel; - - public SuiteInstallerProjectProperties(Project suiteProject) { - this.suiteProject = suiteProject; - Preferences prefs = prefs(suiteProject); - windowsModel = new JToggleButton.ToggleButtonModel(); - windowsModel.setSelected(prefs.getBoolean(GENERATE_FOR_WINDOWS, Utilities.isWindows())); - linuxModel = new JToggleButton.ToggleButtonModel(); - linuxModel.setSelected(prefs.getBoolean(GENERATE_FOR_LINUX, Utilities.getOperatingSystem() == Utilities.OS_LINUX)); - solarisModel = new JToggleButton.ToggleButtonModel(); - solarisModel.setSelected(prefs.getBoolean(GENERATE_FOR_SOLARIS, Utilities.getOperatingSystem() == Utilities.OS_SOLARIS)); - macModel = new JToggleButton.ToggleButtonModel(); - macModel.setSelected(prefs.getBoolean(GENERATE_FOR_MAC, Utilities.isMac())); - - // license model: - ResourceBundle rb = NbBundle.getBundle(SuiteInstallerProjectProperties.class); - Enumeration keys = rb.getKeys(); - String prefix = "SuiteInstallerProjectProperties.license.type."; - List names = new ArrayList(); - List types = new ArrayList(); - - while (keys.hasMoreElements()) { - String key = keys.nextElement(); - if (key.startsWith(prefix)) { - String type = key.substring(prefix.length()); - String value = NbBundle.getMessage(SuiteInstallerProjectProperties.class, key); - if (type.equals(LICENSE_TYPE_NO)) { - //No License is the first option - names.add(0, value); - types.add(0, type); - } else { - names.add(value); - types.add(type); - } - } - } - licenseModel = new LicenseComboBoxModel(suiteProject, names, types); - - String licenseFileName = prefs.get(LICENSE_FILE, null); - String licenseType = prefs.get(LICENSE_TYPE, null); - if (licenseFileName != null) { - File licenseFile = new File(licenseFileName); - if (!licenseFile.isAbsolute()) { - licenseFile = PropertyUtils.resolveFile(FileUtil.toFile(suiteProject.getProjectDirectory()), licenseFileName); - } - - licenseModel.getNames().add(licenseFile.getAbsolutePath()); - licenseModel.getTypes().add(LICENSE_TYPE_FILE); - String name = licenseModel.getNames().get(licenseModel.getNames().size() - 1); - licenseModel.setSelectedItem(name); - } - - else if (licenseType != null) { - int index = licenseModel.getTypes().indexOf(licenseType); - if (index != -1) { - licenseModel.setSelectedItem(licenseModel.getNames().get(index)); - } - } - } - - public void store() throws IOException { - Preferences prefs = prefs(suiteProject); - prefs.putBoolean(GENERATE_FOR_WINDOWS, windowsModel.isSelected()); - prefs.putBoolean(GENERATE_FOR_LINUX, linuxModel.isSelected()); - prefs.putBoolean(GENERATE_FOR_SOLARIS, solarisModel.isSelected()); - prefs.putBoolean(GENERATE_FOR_MAC, macModel.isSelected()); - String licenseName = (String) licenseModel.getSelectedItem(); - if (licenseName != null) { - int index = licenseModel.getNames().indexOf(licenseName); - if (index != -1) { - String type = licenseModel.getTypes().get(index); - if (type.equals(LICENSE_TYPE_FILE)) { - File suiteLocation = FileUtil.toFile(suiteProject.getProjectDirectory()); - File f = PropertyUtils.resolveFile(suiteLocation, licenseName); - String rel = PropertyUtils.relativizeFile(suiteLocation, f); - if (rel != null) { - prefs.put(LICENSE_FILE, rel); - } else { - prefs.put(LICENSE_FILE, f.getAbsolutePath()); - } - prefs.remove(LICENSE_TYPE); - } else { - prefs.put(LICENSE_TYPE, type); - prefs.remove(LICENSE_FILE); - } - } - } - } - - public static Preferences prefs(Project suiteProject) { - return ProjectUtils.getPreferences(suiteProject, SuiteInstallerProjectProperties.class, true); - } - -} diff --git a/apisupport/apisupport.kit/nbproject/project.xml b/apisupport/apisupport.kit/nbproject/project.xml index 90dd446a617d..a7a6f9a64e61 100644 --- a/apisupport/apisupport.kit/nbproject/project.xml +++ b/apisupport/apisupport.kit/nbproject/project.xml @@ -37,12 +37,6 @@ 1.10 - - org.netbeans.modules.apisupport.installer - - 1.0 - - org.netbeans.modules.apisupport.project diff --git a/harness/libs.nbi.ant/build.xml b/harness/libs.nbi.ant/build.xml deleted file mode 100644 index 926a842863de..000000000000 --- a/harness/libs.nbi.ant/build.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - Builds, tests, and runs the project org.netbeans.libs.nbi.ant - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.ant/licenseinfo.xml b/harness/libs.nbi.ant/licenseinfo.xml deleted file mode 100644 index 1680a996e9b4..000000000000 --- a/harness/libs.nbi.ant/licenseinfo.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-right.png - stub/ext/engine/src/org/mycompany/installer/wizard/wizard-icon.png - stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-left.png - stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-top.png - stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-bottom.png - stub/ext/components/products/helloworld/data/icon.png - stub/ext/components/products/helloworld/data/icon48.png - - - - \ No newline at end of file diff --git a/harness/libs.nbi.ant/manifest.mf b/harness/libs.nbi.ant/manifest.mf deleted file mode 100644 index 53c00ff54b02..000000000000 --- a/harness/libs.nbi.ant/manifest.mf +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: false -OpenIDE-Module: org.netbeans.libs.nbi.ant -OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/nbi/ant/Bundle.properties -OpenIDE-Module-Specification-Version: 1.50 diff --git a/harness/libs.nbi.ant/nbproject/project.properties b/harness/libs.nbi.ant/nbproject/project.properties deleted file mode 100644 index 9214f6ed7dfd..000000000000 --- a/harness/libs.nbi.ant/nbproject/project.properties +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -is.autoload=true -javac.source=1.8 -javac.target=1.8 -javac.compilerargs=-Xlint -Xlint:-serial -extra.module.files=\ - modules/ext/nbi-ant-tasks.jar,\ - modules/ext/nbi-registries-management.jar,\ - nbi/ -nbm.module.author=Dmitry Lipin - diff --git a/harness/libs.nbi.ant/nbproject/project.xml b/harness/libs.nbi.ant/nbproject/project.xml deleted file mode 100644 index 850aa4fff388..000000000000 --- a/harness/libs.nbi.ant/nbproject/project.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - org.netbeans.modules.apisupport.project - - - org.netbeans.libs.nbi.ant - - - org.netbeans.libs.nbi.engine - - - - - - - diff --git a/harness/libs.nbi.ant/src/org/netbeans/libs/nbi/ant/Bundle.properties b/harness/libs.nbi.ant/src/org/netbeans/libs/nbi/ant/Bundle.properties deleted file mode 100644 index 71e0d276a877..000000000000 --- a/harness/libs.nbi.ant/src/org/netbeans/libs/nbi/ant/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -OpenIDE-Module-Display-Category=Infrastructure -OpenIDE-Module-Name=NBI Ant Library diff --git a/harness/libs.nbi.ant/stub/build.properties b/harness/libs.nbi.ant/stub/build.properties deleted file mode 100644 index f57f444f7fba..000000000000 --- a/harness/libs.nbi.ant/stub/build.properties +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -output.dir=${basedir}/build -jarsigner.enabled=false -core.module.name=nbi -ext.module.name=ext - -nbi.all.dir=${basedir}/nbi_all -nbi.core.dir=${nbi.all.dir}/${core.module.name} -nbi.ext.dir=${nbi.all.dir}/${ext.module.name} - -temp.file=${nbi.all.dir}/temp.ant.tmp -environment.properties=${nbi.all.dir}/environment.properties - -context.path.token=/nbi/dev -context.path.replacement=${context.path} - -context.dir.token=ROOT = new File\\(".*?"\\); -context.dir.replacement=ROOT = new File\\("${context.dir}"\); - -custom.tasks.cls={nbi.ant.tasks.jar}${path.separator}{nbi.registries.management.jar}${path.separator}{nbi.engine.jar} -nbi.engine.jar={nbi.engine.jar} - -jdk.home={generator-jdk-location-forward-slashes} -bundles.release.dir={generated-installers-location-forward-slashes} -bundle.files.prefix={generated-installers-prefix} - -target.platforms={product-platforms} -main.product.uid={product-uid} diff --git a/harness/libs.nbi.ant/stub/build.xml b/harness/libs.nbi.ant/stub/build.xml deleted file mode 100644 index 1ca8dbfffb65..000000000000 --- a/harness/libs.nbi.ant/stub/build.xml +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -checkout.sources=false -sources.dir=${nbi.all.dir} -cvs.module=ext - -release.to.server=false -release.registry.dir=${output.dir}/registry-temp - -dont.build.custom.tasks=true -custom.tasks.cls=${custom.tasks.cls} - -build.engine=false - -engine.dist.file.name=nbi-engine.jar -engine.dist.file=${nbi.core.dir}/infra/build/engine/dist/nbi-engine.jar - -packaged.data.dir=${basedir}/cache/packaged -downloads.cache.dir=${basedir}/cache/raw - -jarsigner.enabled=${jarsigner.enabled} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Installer(s) for [${target.platforms}] are available at ${bundles.release.dir} - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/build.xml b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/build.xml deleted file mode 100644 index 170e916a2725..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/build.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - Builds, tests, and runs the project helloworld. - - - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/Bundle.properties b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/Bundle.properties deleted file mode 100644 index bb4a014d52e1..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -product.display.name={product-name} -product.description={product-description} diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon.png b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon.png deleted file mode 100644 index 1b3bcd61d25b..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon48.png b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon48.png deleted file mode 100644 index 8c62b4c0c4de..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/data/icon48.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/manifest.mf b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/manifest.mf deleted file mode 100644 index 7dd53f8c12db..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/manifest.mf +++ /dev/null @@ -1 +0,0 @@ -Configuration-Logic-Class: org.mycompany.ConfigurationLogic \ No newline at end of file diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/build-impl.xml b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/build-impl.xml deleted file mode 100644 index 50e815a86198..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/build-impl.xml +++ /dev/null @@ -1,1067 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/genfiles.properties b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/genfiles.properties deleted file mode 100644 index 825c2635797b..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=b5c7f54a -build.xml.script.CRC32=16bbb630 -build.xml.stylesheet.CRC32=be360661 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b5c7f54a -nbproject/build-impl.xml.script.CRC32=568806dc -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.properties b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.properties deleted file mode 100644 index d9e5b60ea253..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -application.title=helloworld -application.vendor=dlm198383 -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/helloworld.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${reference.NBI_Engine.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -project.NBI_Engine=../../../../nbi/engine -reference.NBI_Engine.jar=${project.NBI_Engine}/dist/nbi-engine.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.xml b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.xml deleted file mode 100644 index 548f82569823..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/nbproject/project.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - org.netbeans.modules.java.j2seproject - - - helloworld - 1.6.5 - - - - - - - - - - NBI_Engine - jar - - jar - clean - jar - - - - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/Bundle.properties b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/Bundle.properties deleted file mode 100644 index 46926bbe0887..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/Bundle.properties +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -CL.app.name={product-simple-name} -CL.desktop.shortcut.name={product-name} -CL.desktop.shortcut.description= -CL.desktop.shortcut.path= -CL.unix.icon.name={product-icon-name} -CL.unix.icon.resource=org/mycompany/{product-icon-name} - - -CL.start.menu.shortcut.name={product-name} -CL.start.menu.shortcut.name.macosx={product-name} -CL.start.menu.shortcut.description= -CL.start.menu.shortcut.path= - -CL.install.desktop=Creating shortcut on desktop -CL.install.start.menu=Creating shortcut in start menu -CL.uninstall.start.menu=Removing Start Menu entries -CL.uninstall.desktop=Removing desktop shortcut -CL.uninstall.remove.userdir=Removing {product-name} userdir - -CL.uninstall.error.start.menu=Cannot remove desktop shortcut -CL.uninstall.error.desktop=Cannot remove Start Menu entries - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java deleted file mode 100644 index c0b0cc332b63..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany; - -import java.util.List; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Locale; -import java.util.Map; -import org.mycompany.wizard.panels.HelloWorldPanel; -import org.mycompany.installer.utils.applications.NetBeansRCPUtils; -import org.netbeans.installer.product.components.ProductConfigurationLogic; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.helper.RemovalMode; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.exceptions.UninstallationException; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.shortcut.FileShortcut; -import org.netbeans.installer.utils.system.shortcut.LocationType; -import org.netbeans.installer.utils.system.shortcut.Shortcut; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.wizard.Wizard; -import org.netbeans.installer.wizard.components.WizardComponent; - -public class ConfigurationLogic extends ProductConfigurationLogic { - - private List wizardComponents; - - // constructor ////////////////////////////////////////////////////////////////// - public ConfigurationLogic() throws InitializationException { - wizardComponents = Wizard.loadWizardComponents( - WIZARD_COMPONENTS_URI, - getClass().getClassLoader()); - } - - public List getWizardComponents() { - return wizardComponents; - } - - @Override - public boolean allowModifyMode() { - return false; - } - - @Override - public void install(Progress progress) throws InstallationException { - final Product product = getProduct(); - final File installLocation = product.getInstallationLocation(); - //final FilesList filesList = product.getInstalledFiles(); - - if (SystemUtils.isMacOS()) { - File f = new File(installLocation, ICON_MACOSX); - if(!f.exists()) { - try { - FileUtils.writeFile(f, - ResourceUtils.getResource(ICON_MACOSX_RESOURCE, - getClass().getClassLoader())); - getProduct().getInstalledFiles().add(f); - } catch (IOException e) { - LogManager.log( - "... cannot handle icns icon " + f, e); // NOI18N - } - } - } - - - - if (Boolean.parseBoolean(getProperty(HelloWorldPanel.CREATE_DESKTOP_SHORTCUT_PROPERTY))) { - LogManager.logIndent( - "creating the desktop shortcut for the application"); // NOI18N - if (!SystemUtils.isMacOS()) { - try { - progress.setDetail(getString("CL.install.desktop")); // NOI18N - - if (SystemUtils.isCurrentUserAdmin()) { - LogManager.log( - "... current user is an administrator " + // NOI18N - "-- creating the shortcut for all users"); // NOI18N - - SystemUtils.createShortcut( - getDesktopShortcut(installLocation), - LocationType.ALL_USERS_DESKTOP); - - product.setProperty( - DESKTOP_SHORTCUT_LOCATION_PROPERTY, - ALL_USERS_PROPERTY_VALUE); - } else { - LogManager.log( - "... current user is an ordinary user " + // NOI18N - "-- creating the shortcut for the current " + // NOI18N - "user only"); // NOI18N - - SystemUtils.createShortcut( - getDesktopShortcut(installLocation), - LocationType.CURRENT_USER_DESKTOP); - - getProduct().setProperty( - DESKTOP_SHORTCUT_LOCATION_PROPERTY, - CURRENT_USER_PROPERTY_VALUE); - } - } catch (NativeException e) { - LogManager.unindent(); - - LogManager.log( - getString("CL.install.error.desktop"), // NOI18N - e); - } - } else { - LogManager.log( - "... skipping this step as we're on Mac OS"); // NOI18N - } - } - LogManager.logUnindent( - "... done"); // NOI18N - - ///////////////////////////////////////////// - // create start menu shortcut - if (Boolean.parseBoolean(getProperty(HelloWorldPanel.CREATE_START_MENU_SHORTCUT_PROPERTY))) { - LogManager.logIndent( - "creating the start menu shortcut for the application"); // NOI18N - try { - progress.setDetail(getString("CL.install.start.menu")); // NOI18N - - if (SystemUtils.isCurrentUserAdmin()) { - LogManager.log( - "... current user is an administrator " + // NOI18N - "-- creating the shortcut for all users"); // NOI18N - - SystemUtils.createShortcut( - getStartMenuShortcut(installLocation), - LocationType.ALL_USERS_START_MENU); - - getProduct().setProperty( - START_MENU_SHORTCUT_LOCATION_PROPERTY, - ALL_USERS_PROPERTY_VALUE); - } else { - LogManager.log( - "... current user is an ordinary user " + // NOI18N - "-- creating the shortcut for the current " + // NOI18N - "user only"); // NOI18N - - SystemUtils.createShortcut( - getStartMenuShortcut(installLocation), - LocationType.CURRENT_USER_START_MENU); - - getProduct().setProperty( - START_MENU_SHORTCUT_LOCATION_PROPERTY, - CURRENT_USER_PROPERTY_VALUE); - } - } catch (NativeException e) { - LogManager.log( - getString("CL.install.error.start.menu"), // NOI18N - e); - } - LogManager.logUnindent( - "... done"); // NOI18N - } - - } - - @Override - public void uninstall(Progress progress) throws UninstallationException { - final Product product = getProduct(); - final File installLocation = product.getInstallationLocation(); - - //NetBeansUtils.warnNetbeansRunning(installLocation); - ///////////////////////////////////////////////////////////////////////////// - if (Boolean.parseBoolean(getProperty(HelloWorldPanel.CREATE_START_MENU_SHORTCUT_PROPERTY))) { - try { - progress.setDetail(getString("CL.uninstall.start.menu")); // NOI18N - - final String shortcutLocation = - getProduct().getProperty(START_MENU_SHORTCUT_LOCATION_PROPERTY); - - if ((shortcutLocation == null) - || shortcutLocation.equals(CURRENT_USER_PROPERTY_VALUE)) { - SystemUtils.removeShortcut( - getStartMenuShortcut(installLocation), - LocationType.CURRENT_USER_START_MENU, - true); - } else { - SystemUtils.removeShortcut( - getStartMenuShortcut(installLocation), - LocationType.ALL_USERS_START_MENU, - true); - } - } catch (NativeException e) { - LogManager.log( - getString("CL.uninstall.error.start.menu"), // NOI18N - e); - } - } - - ///////////////////////////////////////////////////////////////////////////// - if (Boolean.parseBoolean(getProperty(HelloWorldPanel.CREATE_DESKTOP_SHORTCUT_PROPERTY))) { - if (!SystemUtils.isMacOS()) { - try { - progress.setDetail(getString("CL.uninstall.desktop")); // NOI18N - - final String shortcutLocation = getProduct().getProperty( - DESKTOP_SHORTCUT_LOCATION_PROPERTY); - - if ((shortcutLocation == null) - || shortcutLocation.equals(CURRENT_USER_PROPERTY_VALUE)) { - SystemUtils.removeShortcut( - getDesktopShortcut(installLocation), - LocationType.CURRENT_USER_DESKTOP, - false); - } else { - SystemUtils.removeShortcut( - getDesktopShortcut(installLocation), - LocationType.ALL_USERS_DESKTOP, - false); - } - } catch (NativeException e) { - LogManager.log( - getString("CL.uninstall.error.desktop"), // NOI18N - e); - } - } - } - - - if (Boolean.getBoolean("remove.app.userdir")) { - try { - progress.setDetail(getString("CL.uninstall.remove.userdir")); // NOI18N - LogManager.logIndent("Removing application`s userdir... "); - File userDir = NetBeansRCPUtils.getApplicationUserDirFile(installLocation); - LogManager.log("... application userdir location : " + userDir); - if (FileUtils.exists(userDir) && FileUtils.canWrite(userDir)) { - FileUtils.deleteFile(userDir, true); - FileUtils.deleteEmptyParents(userDir); - } - LogManager.log("... application userdir totally removed"); - } catch (IOException e) { - LogManager.log("Can`t remove application userdir", e); - } finally { - LogManager.unindent(); - } - } - - ///////////////////////////////////////////////////////////////////////////// - //remove cluster/update files - /* - try { - progress.setDetail(getString("CL.uninstall.update.files")); // NOI18N - for(String cluster : CLUSTERS) { - File updateDir = new File(installLocation, cluster + File.separator + "update"); - if ( updateDir.exists()) { - FileUtils.deleteFile(updateDir, true); - } - } - } catch (IOException e) { - LogManager.log( - getString("CL.uninstall.error.update.files"), // NOI18N - e); - } - */ - ///////////////////////////////////////////////////////////////////////////// - progress.setPercentage(Progress.COMPLETE); - } - - @Override - public String getExecutable() { - if (SystemUtils.isWindows()) { - return EXECUTABLE_WINDOWS; - } else { - return EXECUTABLE_UNIX; - } - } - - @Override - public String getIcon() { - if (SystemUtils.isWindows()) { - return ICON_WINDOWS; - } else if (SystemUtils.isMacOS()) { - return ICON_MACOSX; - } else { - return ICON_UNIX; - } - } - - public RemovalMode getRemovalMode() { - return RemovalMode.LIST; - } - - @Override - public boolean registerInSystem() { - return true; - } - - @Override - public boolean requireLegalArtifactSaving() { - return false; - } - - @Override - public boolean requireDotAppForMacOs() { - return true; - } - - @Override - public boolean wrapForMacOs() { - return true; - } - - - - private Shortcut getDesktopShortcut(final File directory) { - return getShortcut( - getStrings("CL.desktop.shortcut.name"), // NOI18N - getStrings("CL.desktop.shortcut.description"), // NOI18N - getString("CL.desktop.shortcut.path"), // NOI18N - directory); - } - - private Shortcut getStartMenuShortcut(final File directory) { - if (SystemUtils.isMacOS()) { - return getShortcut( - getStrings("CL.start.menu.shortcut.name.macosx"), // NOI18N - getStrings("CL.start.menu.shortcut.description"), // NOI18N - getString("CL.start.menu.shortcut.path"), // NOI18N - directory); - } else { - return getShortcut( - getStrings("CL.start.menu.shortcut.name"), // NOI18N - getStrings("CL.start.menu.shortcut.description"), // NOI18N - getString("CL.start.menu.shortcut.path"), // NOI18N - directory); - } - } - - private Shortcut getShortcut( - final Map names, - final Map descriptions, - final String relativePath, - final File location) { - final File icon; - final File executable; - - if (SystemUtils.isWindows()) { - icon = new File(location, ICON_WINDOWS); - } else if (SystemUtils.isMacOS()) { - icon = new File(location, ICON_MACOSX); - } else { - icon = new File(location, ICON_UNIX); - LogManager.log("... icon file: " + icon); - if(!FileUtils.exists(icon)) { - LogManager.log("... icon file does not exist: " + icon); - InputStream is = null; - is = ResourceUtils.getResource(ICON_UNIX_RESOURCE, this.getClass().getClassLoader()); - if(is!=null) { - FileOutputStream fos =null; - try { - fos = new FileOutputStream(icon); - StreamUtils.transferData(is, fos); - is.close(); - fos.close(); - getProduct().getInstalledFiles().add(icon); - } catch (IOException e) { - LogManager.log(e); - } finally { - if(fos!=null) { - try { - fos.close(); - } catch (IOException e) { - } - } - } - } - } - } - - if (SystemUtils.isWindows()) { - executable = new File(location, EXECUTABLE_WINDOWS); - } else { - executable = new File(location, EXECUTABLE_UNIX); - } - final String name = names.get(new Locale(StringUtils.EMPTY_STRING)); - final FileShortcut shortcut = new FileShortcut(name, executable); - shortcut.setNames(names); - shortcut.setDescriptions(descriptions); - shortcut.setCategories(SHORTCUT_CATEGORIES); - shortcut.setFileName(SHORTCUT_FILENAME); - shortcut.setIcon(icon); - shortcut.setRelativePath(relativePath); - shortcut.setWorkingDirectory(location); - shortcut.setModifyPath(true); - - return shortcut; - } - public static final String SHORTCUT_FILENAME = - ResourceUtils.getString(ConfigurationLogic.class, "CL.app.name") + ".desktop"; // NOI18N - public static final String[] SHORTCUT_CATEGORIES = new String[]{ - "Application" - }; - public static final String BIN_SUBDIR = - "bin/"; - public static final String EXECUTABLE_WINDOWS = - BIN_SUBDIR - + ResourceUtils.getString(ConfigurationLogic.class, "CL.app.name") + ".exe"; // NOI18N - public static final String EXECUTABLE_UNIX = - BIN_SUBDIR - + ResourceUtils.getString(ConfigurationLogic.class, "CL.app.name"); // NOI18N - public static final String ICON_WINDOWS = - EXECUTABLE_WINDOWS; - public static final String ICON_UNIX = - ResourceUtils.getString(ConfigurationLogic.class, - "CL.unix.icon.name"); // NOI18N - public static final String ICON_UNIX_RESOURCE = - ResourceUtils.getString(ConfigurationLogic.class, - "CL.unix.icon.resource"); // NOI18N - public static final String ICON_MACOSX = - ResourceUtils.getString(ConfigurationLogic.class, "CL.app.name") + ".icns"; // NOI18N - public static final String ICON_MACOSX_RESOURCE = - "org/mycompany/" + ResourceUtils.getString(ConfigurationLogic.class, "CL.app.name") + ".icns"; // NOI18N - public static final String WIZARD_COMPONENTS_URI = - "resource:" + // NOI18N - "org/mycompany/wizard.xml"; // NOI18N - private static final String DESKTOP_SHORTCUT_LOCATION_PROPERTY = - "desktop.shortcut.location"; // NOI18N - private static final String START_MENU_SHORTCUT_LOCATION_PROPERTY = - "start.menu.shortcut.location"; // NOI18N - private static final String ALL_USERS_PROPERTY_VALUE = - "all.users"; // NOI18N - private static final String CURRENT_USER_PROPERTY_VALUE = - "current.user"; // NOI18N -} diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard.xml b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard.xml deleted file mode 100644 index f06c42189af6..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/Bundle.properties b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/Bundle.properties deleted file mode 100644 index 96cb31b914f5..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/Bundle.properties +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -P.title={product-name} Installation -P.description=Choose destination folder. -P.destination.label.text=&Install {product-name} to: -P.destination.button.text=B&rowse..... - -P.create.desktop.shortcut=Create Desktop icon -P.create.start.menu.shortcut.windows=Create Start menu entry -P.create.start.menu.shortcut.unix=Create shortcut in Applications menu -P.create.start.menu.shortcut.macosx=Create icon in Dock - -P.error.contains.non.ascii.chars=The specified installation location cannot contain non-ASCII characters. diff --git a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/HelloWorldPanel.java b/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/HelloWorldPanel.java deleted file mode 100644 index 8f010414dca2..000000000000 --- a/harness/libs.nbi.ant/stub/ext/components/products/helloworld/src/org/mycompany/wizard/panels/HelloWorldPanel.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.wizard.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.io.File; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.swing.NbiCheckBox; -import org.netbeans.installer.wizard.components.panels.DestinationPanel; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -public class HelloWorldPanel extends DestinationPanel { - - public HelloWorldPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(DESTINATION_LABEL_TEXT_PROPERTY, - DEFAULT_DESTINATION_LABEL_TEXT); - setProperty(DESTINATION_BUTTON_TEXT_PROPERTY, - DEFAULT_DESTINATION_BUTTON_TEXT); - - setProperty(ERROR_CONTAINS_NON_ASCII_CHARS, - DEFAULT_ERROR_CONTAINS_NON_ASCII_CHARS); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new HelloWorldPanelUi(this); - } - - return wizardUi; - } - - @Override - public void initialize() { - super.initialize(); - if(getWizard().getProperty(CREATE_DESKTOP_SHORTCUT_PROPERTY) == null) { - getWizard().setProperty(CREATE_DESKTOP_SHORTCUT_PROPERTY, "" + true); - } - if(getWizard().getProperty(CREATE_START_MENU_SHORTCUT_PROPERTY) == null) { - getWizard().setProperty(CREATE_START_MENU_SHORTCUT_PROPERTY, "" + true); - } - } - - - public static class HelloWorldPanelUi extends DestinationPanelUi { - - protected HelloWorldPanel panel; - - public HelloWorldPanelUi(HelloWorldPanel panel) { - super(panel); - - - this.panel = panel; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new HelloWorldPanelSwingUi(panel, container); - } - - return super.getSwingUi(container); - } - } - - public static class HelloWorldPanelSwingUi extends DestinationPanelSwingUi { - - protected HelloWorldPanel panel; - private NbiCheckBox desktopShortcutComboBox; - private NbiCheckBox startMenuShortcutComboBox; - - public HelloWorldPanelSwingUi( - final HelloWorldPanel panel, - final SwingContainer container) { - super(panel, container); - - this.panel = panel; - - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initialize() { - desktopShortcutComboBox.setText(CREATE_DESKTOP_SHORTCUT_NAME); - desktopShortcutComboBox.setSelected(false); - if(Boolean.parseBoolean(panel.getWizard().getProperty(CREATE_DESKTOP_SHORTCUT_PROPERTY))) { - desktopShortcutComboBox.doClick(); - } - - startMenuShortcutComboBox.setText( - SystemUtils.isWindows() ? CREATE_START_MENU_SHORTCUT_NAME_WINDOWS : - (SystemUtils.isMacOS() ? CREATE_START_MENU_SHORTCUT_NAME_MAC : - CREATE_START_MENU_SHORTCUT_NAME_UNIX)); - startMenuShortcutComboBox.setSelected(false); - if(Boolean.parseBoolean(panel.getWizard().getProperty(CREATE_START_MENU_SHORTCUT_PROPERTY))) { - startMenuShortcutComboBox.doClick(); - } - - super.initialize(); - } - - @Override - protected void saveInput() { - super.saveInput(); - panel.getWizard().setProperty( - CREATE_DESKTOP_SHORTCUT_PROPERTY, - StringUtils.EMPTY_STRING + desktopShortcutComboBox.isSelected()); - - panel.getWizard().setProperty( - CREATE_START_MENU_SHORTCUT_PROPERTY, - StringUtils.EMPTY_STRING + startMenuShortcutComboBox.isSelected()); - } - - @Override - protected String validateInput() { - String errorMessage = super.validateInput(); - - if (errorMessage == null) { - // #222846 - non-ascii characters in installation path - File installationFolder = new File(getDestinationPath()); - CharsetEncoder encoder = Charset.forName("US-ASCII").newEncoder(); - if (!encoder.canEncode(installationFolder.getAbsolutePath())) { - return StringUtils.format(panel.getProperty(ERROR_CONTAINS_NON_ASCII_CHARS)); - } - } - - return errorMessage; - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // selectedLocationField //////////////////////////////////////////////// - desktopShortcutComboBox = new NbiCheckBox(); - startMenuShortcutComboBox = new NbiCheckBox(); - - // this ///////////////////////////////////////////////////////////////// - add(desktopShortcutComboBox, new GridBagConstraints( - 0, 2, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(startMenuShortcutComboBox, new GridBagConstraints( - 0, 3, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(7, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - } - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String CREATE_DESKTOP_SHORTCUT_PROPERTY = - "create.desktop.shortcut"; - public static final String CREATE_START_MENU_SHORTCUT_PROPERTY = - "create.start.menu.shortcut"; - public static final String ERROR_CONTAINS_NON_ASCII_CHARS = - "error.contains.non.ascii.chars"; // NOI18N - - public static final String DEFAULT_TITLE = - ResourceUtils.getString(HelloWorldPanel.class, - "P.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(HelloWorldPanel.class, - "P.description"); // NOI18N - public static final String DEFAULT_DESTINATION_LABEL_TEXT = - ResourceUtils.getString(HelloWorldPanel.class, - "P.destination.label.text"); // NOI18N - public static final String DEFAULT_DESTINATION_BUTTON_TEXT = - ResourceUtils.getString(HelloWorldPanel.class, - "P.destination.button.text"); // NOI18N - public static final String CREATE_DESKTOP_SHORTCUT_NAME = - ResourceUtils.getString(HelloWorldPanel.class, - "P.create.desktop.shortcut"); // NOI18N - public static final String CREATE_START_MENU_SHORTCUT_NAME_WINDOWS = - ResourceUtils.getString(HelloWorldPanel.class, - "P.create.start.menu.shortcut.windows"); // NOI18N - public static final String CREATE_START_MENU_SHORTCUT_NAME_UNIX = - ResourceUtils.getString(HelloWorldPanel.class, - "P.create.start.menu.shortcut.unix"); // NOI18N - public static final String CREATE_START_MENU_SHORTCUT_NAME_MAC = - ResourceUtils.getString(HelloWorldPanel.class, - "P.create.start.menu.shortcut.macosx"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_NON_ASCII_CHARS = - ResourceUtils.getString(HelloWorldPanel.class, - "P.error.contains.non.ascii.chars"); // NOI18N -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/build.properties b/harness/libs.nbi.ant/stub/ext/engine/build.properties deleted file mode 100644 index 2e2b203395de..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/build.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -jar.contents.list=data/engine.list -jar.contents.includes=native/** org/** com/apple/** data/clioptions.list data/engine*.properties diff --git a/harness/libs.nbi.ant/stub/ext/engine/build.xml b/harness/libs.nbi.ant/stub/ext/engine/build.xml deleted file mode 100644 index 3127a3c77deb..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/build.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - ${engine.files} - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/engine/manifest.mf b/harness/libs.nbi.ant/stub/ext/engine/manifest.mf deleted file mode 100644 index 464ca3d3fe50..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/manifest.mf +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: org.netbeans.installer.Installer diff --git a/harness/libs.nbi.ant/stub/ext/engine/nbproject/build-impl.xml b/harness/libs.nbi.ant/stub/ext/engine/nbproject/build-impl.xml deleted file mode 100644 index f2dc9cb94f54..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/nbproject/build-impl.xml +++ /dev/null @@ -1,1416 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/engine/nbproject/genfiles.properties b/harness/libs.nbi.ant/stub/ext/engine/nbproject/genfiles.properties deleted file mode 100644 index f72a7831f9c7..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=8f661a73 -build.xml.script.CRC32=f2f0e306 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=a04276f0 -nbproject/build-impl.xml.script.CRC32=9d404b62 -nbproject/build-impl.xml.stylesheet.CRC32=cdba79fa@1.67.1.46 diff --git a/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.properties b/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.properties deleted file mode 100644 index 4cb4b38da34e..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.properties +++ /dev/null @@ -1,81 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -application.title=NetBeans Installer Engine -application.vendor=ks152834 -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/nbi-engine.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -file.reference.reglib-src=../../reglib/src -includes=** -jar.compress=false -javac.classpath=\ - ${reference.NBI_Engine.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.Installer -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -project.NBI_Engine=../../../../nbi/engine -project.NetBeans_Installer_Engine=../../../engine -reference.NBI_Engine.jar=${project.NBI_Engine}/dist/nbi-engine.jar -run.classpath=\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs=-Dnbi.product.bundled.registry.uri=file:/D:/temp/nbi-build/dist/registry-temp/registry.xml -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.xml b/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.xml deleted file mode 100644 index 0b626ab71ba6..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/nbproject/project.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - org.netbeans.modules.java.j2seproject - - - HelloWorld Engine - 1.6.5 - - - - - - - - - - NBI_Engine - jar - - jar - clean - jar - - - - diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/data/engine.properties b/harness/libs.nbi.ant/stub/ext/engine/src/data/engine.properties deleted file mode 100644 index 33d305530a60..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/data/engine.properties +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -nbi.wizard.components.instance.uri=resource:org/mycompany/installer/wizard/wizard-components.xml -nbi.wizard.ui.swing.frame.icon=resource:org/mycompany/installer/wizard/wizard-icon.png -nbi.wizard.ui.swing.frame.title.prefix= {product-name} Installer -nbi.wizard.ui.swing.frame.title.pattern={0} -nbi.macosx.application.directory.name={product-name} Installer -nbi.product.remove.corrupted.products.silently=true - -nbi.wizard.ui.swing.frame.head.right.image=resource:org/mycompany/installer/wizard/wizard-description-background-right.png -nbi.wizard.ui.swing.frame.head.left.image=resource:org/mycompany/installer/wizard/wizard-description-background-left.png - -nbi.wizard.ui.swing.welcome.left.top.image=resource:org/mycompany/installer/wizard/components/panels/resources/welcome-left-top.png -nbi.wizard.ui.swing.welcome.left.bottom.image=resource:org/mycompany/installer/wizard/components/panels/resources/welcome-left-bottom.png - -nbi.local.directory.path=$S{user.home}/.{product-uid}-installer - -nbi.wizard.ui.swing.frame.width.default=600 -nbi.wizard.ui.swing.frame.height.default=500 -nbi.wizard.ui.swing.frame.width.win.classic=588 -nbi.wizard.ui.swing.frame.height.win.classic=442 -nbi.wizard.ui.swing.frame.width.win.xp=600 -nbi.wizard.ui.swing.frame.height.win.xp=450 -nbi.wizard.ui.swing.frame.width.motif=624 -nbi.wizard.ui.swing.frame.height.motif=470 -nbi.wizard.ui.swing.frame.width.metal=624 -nbi.wizard.ui.swing.frame.height.metal=470 -nbi.wizard.ui.swing.frame.width.aqua=640 -nbi.wizard.ui.swing.frame.height.aqua=480 -nbi.wizard.ui.swing.frame.width.gtk=704 -nbi.wizard.ui.swing.frame.height.gtk=528 -nbi.wizard.ui.swing.frame.width.nimbus=624 -nbi.wizard.ui.swing.frame.height.nimbus=512 - - -nbi.wizard.ui.swing.frame.minimum.width.default=600 -nbi.wizard.ui.swing.frame.minimum.height.default=500 -nbi.wizard.ui.swing.frame.minimum.width.win.classic=588 -nbi.wizard.ui.swing.frame.minimum.height.win.classic=442 -nbi.wizard.ui.swing.frame.minimum.width.win.xp=600 -nbi.wizard.ui.swing.frame.minimum.height.win.xp=450 -nbi.wizard.ui.swing.frame.minimum.width.motif=624 -nbi.wizard.ui.swing.frame.minimum.height.motif=470 -nbi.wizard.ui.swing.frame.minimum.width.metal=624 -nbi.wizard.ui.swing.frame.minimum.height.metal=470 -nbi.wizard.ui.swing.frame.minimum.width.aqua=640 -nbi.wizard.ui.swing.frame.minimum.height.aqua=480 -nbi.wizard.ui.swing.frame.minimum.width.gtk=704 -nbi.wizard.ui.swing.frame.minimum.height.gtk=528 -nbi.wizard.ui.swing.frame.minimum.width.nimbus=624 -nbi.wizard.ui.swing.frame.minimum.height.nimbus=512 diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/unix/i18n/launcher.properties b/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/unix/i18n/launcher.properties deleted file mode 100644 index 8680edfab4f8..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/unix/i18n/launcher.properties +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -nlu.jvm.notfoundmessage=Java SE Development Kit (JDK) was not found on this computer\nJDK 7 is required for installing {product-name}. Make sure that the JDK is properly installed and run installer again.\nYou can specify valid JDK location using {0} installer argument.\n\nTo download the JDK, visit http://www.oracle.com/technetwork/java/javase/downloads/index.html -nlu.jvm.usererror=Java Runtime Environment (JRE) was not found at the specified location {0} -nlu.jvm.uncompatible=Unsupported JVM version at {0}.\nTry to specify another JVM location using parameter {1} -nlu.freespace=There is not enough free disk space to extract installation data\n{0} MB of free disk space is required in a temporary folder.\nClean up the disk space and run installer again. You can specify a temporary folder with sufficient disk space using {1} installer argument -nlu.integrity=\nInstaller file {0} seems to be corrupted -nlu.missing.external.resource=Can`t run {product-name} Installer.\nAn external file with necessary data is required but missing:\n{0} -nlu.cannot.create.tmpdir=Cannot create temporary directory {0} -nlu.cannot.extract.bundled.jvm=Cannot extract bundled JVM -nlu.cannot.unpack.jvm.file=Cannot unpack file {0} -nlu.error.verify.bundled.jvm=Cannot verify bundled JVM, try to search JVM on the system - -nlu.running=Running the installer wizard... -nlu.starting=Configuring the installer... -nlu.extracting=Extracting installation data... -nlu.prepare.jvm=Preparing bundled JVM ... -nlu.jvm.search=Searching for JVM on the system... - -nlu.msg.usage=\nUsage: -nlu.arg.javahome=\t{0}\t\tUsing java from for running application -nlu.arg.verbose=\t{0}\t\tUse verbose output -nlu.arg.output=\t{0}\t\tRedirect all output to file -nlu.arg.disable.space.check=\t{0}\t\tDisable free space check -nlu.arg.extract=\t{0}\t[dir]\tExtract all bundled data to .\n\t\t\t\tIf is not specified then extract to the current directory -nlu.arg.tempdir=\t{0}\t\tUse for extracting temporary data -nlu.arg.cpa=\t{0} \tAppend classpath with -nlu.arg.cpp=\t{0} \tPrepend classpath with -nlu.arg.locale=\t{0}\t\tOverride default locale with specified -nlu.arg.silent=\t{0}\t\tRun installer silently -nlu.arg.help=\t{0}\t\tShow this help - - -nlu.java.application.name.macosx={product-name} Installer diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/windows/i18n/launcher.properties b/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/windows/i18n/launcher.properties deleted file mode 100644 index a4c13cfb5cf1..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/native/launcher/windows/i18n/launcher.properties +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -nlw.jvm.notfoundmessage=Java SE Development Kit (JDK) was not found on this computer\nJDK 7 is required for installing {product-name}. Make sure that the JDK is properly installed and run installer again. You can specify valid JDK location using {0} installer argument.\n\nTo download the JDK, visit http://www.oracle.com/technetwork/java/javase/downloads/index.html -nlw.jvm.usererror=Java Runtime Environment (JRE) was not found\nThere is no JRE at the specified location {0} -nlw.jvm.unsupportedversion=Unsupported Java VM version\nThe Java VM at {0} has the unsupported version -nlw.freespace=There is not enough free disk space to extract installation data\n{0} MB of free disk space is required in a temporary folder. Clean up the disk space and run installer again. You can specify a temporary folder with sufficient disk space using {1} installer argument -nlw.tmpdir=Can't create temporary directory\nThe temporary directory for extracting data {0} was not created -nlw.integrity=Installer file is corrupted\nInstaller file {0} seems to be corrupted -nlw.output.error=Data extraction error\nCan't create file {0}!\nThe following error occured :\n{1} -nlw.java.process.error=An error occured while running java process\n{0} -nlw.missing.external.resource=Can`t run {product-name} Installer.\nAn external file with necessary data is required but missing:\n{0} -nlw.bundled.jvm.extract.error=Cannot prepare bundled JVM to run the installer.\nMost probably the bundled JVM is not compatible with the current platform. -nlw.bundled.jvm.verify.error=An error occured while verifying bundled JVM.\nMost probably the bundled JVM is not compatible with the current platform. - -nlw.arg.output={0} \n\tRedirect output to file -nlw.arg.javahome={0} \n\tRun jar file using JVM from -nlw.arg.verbose={0}\n\tUse verbose output -nlw.arg.tempdir={0} \n\tUse for extracting data -nlw.arg.extract={0} [directory]\n\tExtract all bundled data to the specific directory.\n\tIf directory is not specified then extract to the current directory -nlw.arg.classpatha={0} \n\tAppend classpath with -nlw.arg.classpathp={0} \n\tPrepend classpath with -nlw.arg.disable.space.check={0}\n\tDisable free space check -nlw.arg.locale={0} \n\tOverride system default locale with -nlw.arg.silent={0} \n\tRun installer silently -nlw.arg.help={0}\n\tShow help message - - -nlw.msg.create.tmpdir=Creating temporary directory ... -nlw.msg.extract=Extracting data ... -nlw.msg.jvmsearch=Finding JVM on your system ... -nlw.msg.setoptions=Setting command options ... -nlw.msg.running=Running JVM ... -nlw.msg.title=Please wait while the launcher prepares data to run the installer ... -nlw.msg.messagebox.title={product-name} Installer -nlw.msg.progress.title=Configuring the installer ... -nlw.msg.button.error=Exit Installer -nlw.msg.main.title={product-name} Installer diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/Bundle.properties b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/Bundle.properties deleted file mode 100644 index 33168547e5ef..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/Bundle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# NetBeansRCPUtils.java -NU.error.cannot.get.userdir=Can`t get application userdir from {0} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/NetBeansRCPUtils.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/NetBeansRCPUtils.java deleted file mode 100644 index 8aefbf2900ad..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/utils/applications/NetBeansRCPUtils.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.utils.applications; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.system.WindowsNativeUtils; -import org.netbeans.installer.utils.system.WindowsNativeUtils; -import org.netbeans.installer.utils.system.windows.WindowsRegistry; - -public class NetBeansRCPUtils { - - - /** - * Get resolved application user directory - * @param appLocation Application home directory - * @throws IOException if can`t get application default userdir - */ - public static File getApplicationUserDirFile(File appLocation) throws IOException { - String dir = getApplicationUserDir(appLocation); - String userHome = System.getProperty("user.home"); - if(SystemUtils.isWindows()) { - WindowsNativeUtils wnu = (WindowsNativeUtils) SystemUtils.getNativeUtils(); - WindowsRegistry reg = wnu.getWindowsRegistry(); - String key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; - try { - if(reg.keyExists(reg.HKCU, key) && - reg.valueExists(reg.HKCU, key, "AppData")) { - userHome = reg.getStringValue(reg.HKCU, key, "AppData", false); - - } - } catch (NativeException e) { - LogManager.log(e); - } - } - dir = dir.replace(USER_HOME_TOKEN, userHome); - dir = dir.replace(APPNAME_TOKEN, getApplicationName(appLocation)); - return new File(dir); - } - - /** - * Get application user directory as it is written in application`s configuration file - * @param appLocation Application home directory - * @throws IOException if can`t get default userdir - */ - public static String getApplicationUserDir(File appLocation) throws IOException { - File []confFiles = new File(appLocation, "etc").listFiles(new FilenameFilter() { - - public boolean accept(File dir, String name) { - return name.endsWith(".conf"); - } - }); - File conf = null; - if(confFiles.length == 1) { - conf = confFiles[0]; - } else { - for(File f : confFiles) { - String prefix = f.getName().substring(0, f.getName().indexOf(".conf")); - if((SystemUtils.isUnix() && new File(appLocation, "bin/" + prefix).exists()) || - (SystemUtils.isWindows() && new File(appLocation, "bin/" + prefix + ".exe").exists())) { - conf = f; - break; - } - } - } - if(conf == null) { - return null; - } - - String contents = FileUtils.readFile(conf); - Matcher matcher = Pattern.compile( - NEW_LINE_PATTERN + SPACES_PATTERN + - (SystemUtils.isMacOS() ? DEFAULT_USERDIR_MAC : DEFAULT_USERDIR) + - "\"(.*?)\"").matcher(contents); - if(matcher.find() && matcher.groupCount() == 1) { - return matcher.group(1); - } else { - throw new IOException(StringUtils.format( - ERROR_CANNOT_GET_USERDIR_STRING,conf)); - } - } - - /** - * Get application name - i.e. in bin/.exe and etc/.conf - * @param appLocation Application home directory - */ - public static String getApplicationName(File appLocation) { - File []confFiles = new File(appLocation, "etc").listFiles(new FilenameFilter() { - - public boolean accept(File dir, String name) { - return name.endsWith(".conf"); - } - }); - - if(confFiles.length == 1) { - String name = confFiles[0].getName(); - return name.substring(0, name.indexOf(".conf")); - } else { - for(File f : confFiles) { - String name = f.getName(); - String prefix = name.substring(0, name.indexOf(".conf")); - if((SystemUtils.isUnix() && new File(appLocation, "bin/" + prefix).exists()) || - (SystemUtils.isWindows() && new File(appLocation, "bin/" + prefix + ".exe").exists())) { - return prefix; - } - } - } - return null; - } - - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private NetBeansRCPUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - - public static final String NEW_LINE_PATTERN = - "[\r\n|\n|\r]"; // NOI18N - public static final String SPACES_PATTERN = - "\\ *"; // NOI18N - - public static final String DEFAULT_USERDIR = - "default_userdir="; // NOI18N - public static final String DEFAULT_USERDIR_MAC = - "default_mac_userdir="; // NOI18N - - public static final String USER_HOME_TOKEN = - "${HOME}"; // NOI18N - public static final String APPNAME_TOKEN = - "${APPNAME}"; // NOI18N - - public static final String ERROR_CANNOT_GET_USERDIR_STRING = - ResourceUtils.getString(NetBeansRCPUtils.class, - "NU.error.cannot.get.userdir");//NOI18N - - -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/Bundle.properties b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/Bundle.properties deleted file mode 100644 index 514d36f636a6..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/Bundle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -IA.title=Installer Initialization -IA.progress.title=Initialization in progress... -IA.description=Please wait while initialization is completed. \ No newline at end of file diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/InitializeAction.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/InitializeAction.java deleted file mode 100644 index 42b46a52762e..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/actions/InitializeAction.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.wizard.components.actions; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; -import org.netbeans.installer.wizard.components.actions.*; - -public class InitializeAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public InitializeAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - downloadLogic = new DownloadConfigurationLogicAction(); - initReg = new InitializeRegistryAction(); - } - private DownloadConfigurationLogicAction downloadLogic; - private InitializeRegistryAction initReg; - - public void execute() { - final Progress progress = new Progress(); - - //getWizardUi().setProgress(progress); - - - progress.setTitle(getProperty(PROGRESS_TITLE_PROPERTY)); - - //progress.synchronizeDetails(false); - - if (initReg.canExecuteForward()) { - initReg.setWizard(getWizard()); - initReg.execute(); - } - - if (downloadLogic.canExecuteForward()) { - downloadLogic.setWizard(getWizard()); - downloadLogic.execute(); - } - } - - @Override - public boolean isCancelable() { - return false; - } - - public WizardActionUi getWizardUi() { - return null; // this action does not have a ui - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - InitializeAction.class, - "IA.title"); // NOI18N - public static final String PROGRESS_TITLE_PROPERTY = ResourceUtils.getString( - InitializeAction.class, - "IA.progress.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - InitializeAction.class, - "IA.description"); // NOI18N - -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/Bundle.properties b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/Bundle.properties deleted file mode 100644 index 0eb223efcbd0..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/Bundle.properties +++ /dev/null @@ -1,110 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -WP.title={product-name} Introduction -WP.description={product-name} is a really good app -WP.welcome.text=\ -

Welcome to {product-name} Installer Wizard


\ - This program will install {product-name} application on your computer.

\ - Click Next to continue. -WP.already.installed.text=\ -

Welcome to {product-name} Installer Wizard


\ -{0} is already installed at {1}.
It is not possible to install it again.

\ -Click Exit to close this wizard. -WP.already.installed.next.button.text=&Exit -WP.incompatible.platform.text=\ -

Welcome to {product-name} Installer Wizard


\ -The {0} installer was not designed to run on this operating system so it is not possible to install it. \ -Please run the installer for the appropriate platform.

\ -Click Exit to close this wizard. - -PoISP.title=Setup Complete -PoISP.description=Click Finish to finish {product-name} setup. - -PoISP.message.text.success=\ - Installation Complete


\ - {0} has been installed on your computer. -#NOI18N -PoISP.message.content.type.success=text/html - -PoISP.message.text.warnings=\ -Installation Complete


\ -{0} has been installed on your computer but some not critical warnings were encountered.\ -

For more details consult the installation log file:
{1}
- -PoISP.message.text.finish=Click Finish to close this wizard. -PoISP.message.text.finish.content.type=text/html - -#NOI18N -PoISP.message.content.type.warnings=text/html - -PoISP.message.text.errors=Installation Failed


\ - {0} has not been installed on your computer.

\ - Try to run installer again or consult the installation log file for more details:
{1} -#NOI18N -PoISP.message.content.type.errors=text/html - -PoISP.message.text.success.uninstall=\ - Uninstallation Complete


\ - {0} has been uninstalled. -#NOI18N -PoISP.message.content.type.success.uninstall=text/html - -PoISP.message.text.warnings.uninstall=\ - Uninstallation Complete


\ - {0} has been uninstalled with warnings.

\ - For more details consult the installation log file:
{1}
-#NOI18N -PoISP.message.content.type.warnings.uninstall=text/html - -PoISP.message.text.errors.uninstall=Uninstallation Failed

\ -Uninstallation of {0} was not completed.

\ -Try to run uninstaller again or consult the uninstallation log file for more details:
{1}
\ - -#NOI18N -PoISP.message.content.type.errors.uninstall=text/html - -PoISP.message.run.application.now=Launch {0} after the installer closes. - -PoISP.next.button.text=&Finish - - - -################################################################################ -# PreInstallSummaryPanel.java -PrISP.title=Summary -PrISP.description=Click Install to start the installation. -PrISP.description.uninstall=Click Uninstall to start the uninstallation. - -PrISP.installation.folder={0} Installation Folder: -PrISP.uninstall.list.label.text=
Click Uninstall to remove {0} from the system. -PrISP.installation.size=Total Installation Size: -PrISP.download.size=Total Download Size: - -PrISP.next.button.text=&Install -PrISP.next.button.text.uninstall=&Uninstall - -PrISP.error.not.enough.space=Insufficient disk space for proper installation. Additional {1} is required in {0}. -PrISP.error.cannot.check.space=Cannot check the free disk space -PrISP.error.logic.access=Could not access product's configuration logic -PrISP.error.fsroots=Cannot get the list of file system roots -PrISP.error.non.existent.root={0} is set up to be installed to {1} which does not belong to any of the file system roots. -PrISP.error.cannot.write=The wizard does not have write access to {1}, the installation directory of {0}. Please correct the permissions before proceeding. - -PrISP.remove.app.userdir.text=\ -\ -If you wish to remove the application settings directory that stores user configuration data for {0}, check the following option.
-PrISP.remove.app.userdir.checkbox=Remove directory {0} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PostInstallSummaryPanel.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PostInstallSummaryPanel.java deleted file mode 100644 index 5f685def5122..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PostInstallSummaryPanel.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.components.ProductConfigurationLogic; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.swing.NbiCheckBox; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.containers.SwingFrameContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_INSTALL; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_UNINSTALL; - -public class PostInstallSummaryPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - public PostInstallSummaryPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(MESSAGE_TEXT_SUCCESS_PROPERTY, - DEFAULT_MESSAGE_TEXT_SUCCESS); - setProperty(MESSAGE_CONTENT_TYPE_SUCCESS_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_SUCCESS); - setProperty(MESSAGE_TEXT_WARNINGS_PROPERTY, - DEFAULT_MESSAGE_TEXT_WARNINGS); - setProperty(MESSAGE_CONTENT_TYPE_WARNINGS_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_WARNINGS); - setProperty(MESSAGE_TEXT_ERRORS_PROPERTY, - DEFAULT_MESSAGE_TEXT_ERRORS); - setProperty(MESSAGE_CONTENT_TYPE_ERRORS_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_ERRORS); - - setProperty(MESSAGE_TEXT_SUCCESS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_TEXT_SUCCESS_UNINSTALL); - setProperty(MESSAGE_CONTENT_TYPE_SUCCESS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_SUCCESS_UNINSTALL); - setProperty(MESSAGE_TEXT_WARNINGS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_TEXT_WARNINGS_UNINSTALL); - setProperty(MESSAGE_CONTENT_TYPE_WARNINGS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_WARNINGS_UNINSTALL); - setProperty(MESSAGE_TEXT_ERRORS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_TEXT_ERRORS_UNINSTALL); - setProperty(MESSAGE_CONTENT_TYPE_ERRORS_UNINSTALL_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE_ERRORS_UNINSTALL); - - - setProperty(NEXT_BUTTON_TEXT_PROPERTY, - DEFAULT_NEXT_BUTTON_TEXT); - } - - @Override - public boolean isPointOfNoReturn() { - return true; - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PostInstallSummaryPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PostInstallSummaryPanelUi extends WizardPanelUi { - - protected PostInstallSummaryPanel component; - - public PostInstallSummaryPanelUi(PostInstallSummaryPanel component) { - super(component); - - this.component = component; - } - - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PostInstallSummaryPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class PostInstallSummaryPanelSwingUi extends WizardPanelSwingUi { - - protected PostInstallSummaryPanel component; - private NbiTextPane messagePaneInstall; - private NbiTextPane messagePaneUninstall; - - - private NbiTextPane messagePaneFinish; - private NbiCheckBox runAppNow; - private Product app; - - public PostInstallSummaryPanelSwingUi( - final PostInstallSummaryPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - protected void initializeContainer() { - super.initializeContainer(); - - // set up the back button - container.getBackButton().setVisible(false); - container.getBackButton().setEnabled(false); - - // set up the next (or finish) button - container.getNextButton().setVisible(true); - container.getNextButton().setEnabled(true); - - container.getNextButton().setText( - component.getProperty(NEXT_BUTTON_TEXT_PROPERTY)); - - // set up the cancel button - container.getCancelButton().setVisible(false); - container.getCancelButton().setEnabled(false); - } - - @Override - public void evaluateNextButtonClick() { - container.getNextButton().setEnabled(false); - final Product product = app; - if (app != null) { - ProductConfigurationLogic l = null; - try { - l = app.getLogic(); - } catch (InitializationException e) { - } - final File executable = l != null ? new File(app.getInstallationLocation(), l.getExecutable()) : null; - - if (executable != null && runAppNow.isSelected()) { - LogManager.log("... running: " + executable.getAbsolutePath()); - ProcessBuilder pb = new ProcessBuilder(new String[]{executable.getAbsolutePath()}); - try { - pb.start(); - } catch (IOException e) { - LogManager.log(e); - } - - } - } - super.evaluateNextButtonClick(); - } - - protected void initialize() { - final Registry registry = Registry.getInstance(); - final List successfulInstall = registry.getProducts(INSTALLED_SUCCESSFULLY); - final List warningInstall = registry.getProducts(INSTALLED_WITH_WARNINGS); - final List errorInstall = registry.getProducts(FAILED_TO_INSTALL); - - final List successfulUninstall = registry.getProducts(UNINSTALLED_SUCCESSFULLY); - final List warningUninstall = registry.getProducts(UNINSTALLED_WITH_WARNINGS); - final List errorUninstall = registry.getProducts(FAILED_TO_UNINSTALL); - - if (errorInstall.size() > 0) { - messagePaneInstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_ERRORS_PROPERTY)); - messagePaneInstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_ERRORS_PROPERTY), - errorInstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else if (warningInstall.size() > 0) { - messagePaneInstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_WARNINGS_PROPERTY)); - messagePaneInstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_WARNINGS_PROPERTY), - warningInstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else if (successfulInstall.size() > 0) { - messagePaneInstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_SUCCESS_PROPERTY)); - messagePaneInstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_SUCCESS_PROPERTY), - successfulInstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else { - messagePaneInstall.setVisible(false); - } - - messagePaneFinish.setVisible(true); - messagePaneFinish.setContentType(DEFAULT_MESSAGE_FINISH_PROCESS_CONTENT_TYPE); - messagePaneFinish.setText(DEFAULT_MESSAGE_FINISH_PROCESS); - - if (errorUninstall.size() > 0) { - messagePaneUninstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_ERRORS_UNINSTALL_PROPERTY)); - messagePaneUninstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_ERRORS_UNINSTALL_PROPERTY), - errorUninstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else if (warningUninstall.size() > 0) { - messagePaneUninstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_WARNINGS_UNINSTALL_PROPERTY)); - messagePaneUninstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_WARNINGS_UNINSTALL_PROPERTY), - warningUninstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else if (successfulUninstall.size() > 0) { - messagePaneUninstall.setContentType(component.getProperty(MESSAGE_CONTENT_TYPE_SUCCESS_UNINSTALL_PROPERTY)); - messagePaneUninstall.setText(StringUtils.format( - component.getProperty(MESSAGE_TEXT_SUCCESS_UNINSTALL_PROPERTY), - successfulUninstall.get(0).getDisplayName(), - LogManager.getLogFile())); - } else { - messagePaneUninstall.setVisible(false); - } - - - - final List products = new LinkedList(); - products.addAll(successfulInstall); - products.addAll(warningInstall); - runAppNow.setSelected(false); - if (!products.isEmpty()) { - runAppNow.setText(StringUtils.format(DEFAULT_MESSAGE_LAUNCH_APPLICATION_NOW, - products.get(0).getDisplayName())); - runAppNow.doClick(); - app = products.get(0); - } else { - runAppNow.setVisible(false); - } - - - } - - private void initComponents() { - // messagePaneInstall /////////////////////////////////////////////////// - messagePaneInstall = new NbiTextPane(); - - // messagePaneUninstall ///////////////////////////////////////////////// - messagePaneUninstall = new NbiTextPane(); - - // messagePaneRunApplication /////////////////////////////////////////////////// - - - messagePaneFinish = new NbiTextPane(); - - runAppNow = new NbiCheckBox(); - - - // this ///////////////////////////////////////////////////////////////// - add(messagePaneInstall, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(31, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(messagePaneUninstall, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(31, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - add(messagePaneFinish, new GridBagConstraints( - 0, 3, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - /* - add(new NbiPanel(), new GridBagConstraints( - 0, 4, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - */ - add(runAppNow, new GridBagConstraints( - 0, 4, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - - - if (container instanceof SwingFrameContainer) { - final SwingFrameContainer sfc = (SwingFrameContainer) container; - sfc.addWindowListener(new WindowAdapter() { - - @Override - public void windowClosing(WindowEvent event) { - SwingUi currentUi = component.getWizardUi().getSwingUi(container); - if (currentUi != null) { - if (!container.getCancelButton().isEnabled() && // cancel button is disabled - !container.getCancelButton().isVisible() && // no cancel button at this panel - !container.getBackButton().isVisible() && // no back button at this panel - container.getNextButton().isVisible() && // next button is visible - container.getNextButton().isEnabled()) { // and enabled - currentUi.evaluateNextButtonClick(); - sfc.removeWindowListener(this); - } - } - } - }); - } - } - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String MESSAGE_TEXT_SUCCESS_PROPERTY = - "message.text.success"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_SUCCESS_PROPERTY = - "message.content.type.success"; // NOI18N - public static final String MESSAGE_TEXT_WARNINGS_PROPERTY = - "message.text.warnings"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_WARNINGS_PROPERTY = - "message.content.type.warnings"; // NOI18N - public static final String MESSAGE_TEXT_ERRORS_PROPERTY = - "message.text.errors"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_ERRORS_PROPERTY = - "message.content.type.errors"; // NOI18N - public static final String MESSAGE_TEXT_SUCCESS_UNINSTALL_PROPERTY = - "message.text.success.uninstall"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_SUCCESS_UNINSTALL_PROPERTY = - "message.content.type.success.uninstall"; // NOI18N - public static final String MESSAGE_TEXT_WARNINGS_UNINSTALL_PROPERTY = - "message.text.warnings.uninstall"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_WARNINGS_UNINSTALL_PROPERTY = - "message.content.type.warnings.uninstall"; // NOI18N - public static final String MESSAGE_TEXT_ERRORS_UNINSTALL_PROPERTY = - "message.text.errors.uninstall"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_ERRORS_UNINSTALL_PROPERTY = - "message.content.type.errors.uninstall"; // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_SUCCESS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.success"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_SUCCESS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.success"); // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_WARNINGS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.warnings"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_WARNINGS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.warnings"); // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_ERRORS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.errors"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_ERRORS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.errors"); // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_SUCCESS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.success.uninstall"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_SUCCESS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.success.uninstall"); // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_WARNINGS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.warnings.uninstall"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_WARNINGS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.warnings.uninstall"); // NOI18N - public static final String DEFAULT_MESSAGE_TEXT_ERRORS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.errors.uninstall"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE_ERRORS_UNINSTALL = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.content.type.errors.uninstall"); // NOI18N - - public static final String DEFAULT_TITLE = ResourceUtils.getString( - PostInstallSummaryPanel.class, - "PoISP.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.description"); // NOI18N - public static final String DEFAULT_NEXT_BUTTON_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.next.button.text"); // NOI18N - public static final String DEFAULT_MESSAGE_FINISH_PROCESS = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.finish"); // NOI18N - public static final String DEFAULT_MESSAGE_FINISH_PROCESS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.text.finish.content.type"); // NOI18N - public static final String DEFAULT_MESSAGE_LAUNCH_APPLICATION_NOW = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.run.application.now");//NOI18N -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PreInstallSummaryPanel.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PreInstallSummaryPanel.java deleted file mode 100644 index be0ed5448f2c..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/PreInstallSummaryPanel.java +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.wizard.components.panels; - -import java.awt.ComponentOrientation; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.RegistryType; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.mycompany.installer.utils.applications.NetBeansRCPUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.swing.NbiCheckBox; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel.ErrorMessagePanelSwingUi; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel.ErrorMessagePanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -public class PreInstallSummaryPanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - public PreInstallSummaryPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(INSTALLATION_FOLDER_PROPERTY, - DEFAULT_INSTALLATION_FOLDER); - - setProperty(UNINSTALL_LABEL_TEXT_PROPERTY, - DEFAULT_UNINSTALL_LABEL_TEXT); - - setProperty(INSTALLATION_SIZE_PROPERTY, - DEFAULT_INSTALLATION_SIZE); - setProperty(DOWNLOAD_SIZE_PROPERTY, - DEFAULT_DOWNLOAD_SIZE); - - setProperty(NEXT_BUTTON_TEXT_PROPERTY, - DEFAULT_NEXT_BUTTON_TEXT); - - setProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY, - DEFAULT_ERROR_NOT_ENOUGH_SPACE); - setProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY, - DEFAULT_ERROR_CANNOT_CHECK_SPACE); - setProperty(ERROR_LOGIC_ACCESS_PROPERTY, - DEFAULT_ERROR_LOGIC_ACCESS); - setProperty(ERROR_FSROOTS_PROPERTY, - DEFAULT_ERROR_FSROOTS); - setProperty(ERROR_NON_EXISTENT_ROOT_PROPERTY, - DEFAULT_ERROR_NON_EXISTENT_ROOT); - setProperty(ERROR_CANNOT_WRITE_PROPERTY, - DEFAULT_ERROR_CANNOT_WRITE); - setProperty(REMOVE_APP_USERDIR_TEXT_PROPERTY, - DEFAULT_REMOVE_APP_USERDIR_TEXT); - setProperty(REMOVE_APP_USERDIR_CHECKBOX_PROPERTY, - DEFAULT_REMOVE_APP_USERDIR_CHECKBOX); - - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PreInstallSummaryPanelUi(this); - } - - return wizardUi; - } - - @Override - public void initialize() { - final List toInstall = - Registry.getInstance().getProductsToInstall(); - - if (toInstall.size() > 0) { - setProperty(NEXT_BUTTON_TEXT_PROPERTY, DEFAULT_NEXT_BUTTON_TEXT); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - } else { - setProperty(NEXT_BUTTON_TEXT_PROPERTY, DEFAULT_NEXT_BUTTON_TEXT_UNINSTALL); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION_UNINSTALL); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PreInstallSummaryPanelUi extends ErrorMessagePanelUi { - - protected PreInstallSummaryPanel component; - - public PreInstallSummaryPanelUi(PreInstallSummaryPanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PreInstallSummaryPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class PreInstallSummaryPanelSwingUi extends ErrorMessagePanelSwingUi { - - protected PreInstallSummaryPanel component; - private NbiTextPane locationsPane; - private NbiLabel uninstallListLabel; - private NbiTextPane uninstallListPane; - private NbiLabel installationSizeLabel; - private NbiLabel installationSizeValue; - private NbiLabel downloadSizeLabel; - private NbiLabel downloadSizeValue; - private NbiCheckBox removeUserdirCheckbox; - private NbiTextPane removeUserdirPane; - private NbiPanel spacer; - private int gridy = 0; - - public PreInstallSummaryPanelSwingUi( - final PreInstallSummaryPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - - container.getNextButton().setText( - panel.getProperty(NEXT_BUTTON_TEXT_PROPERTY)); - } - - @Override - protected void initialize() { - final Registry registry = Registry.getInstance(); - - final StringBuilder text = new StringBuilder(); - long installationSize = 0; - long downloadSize = 0; - - for (Product product : registry.getProductsToInstall()) { - installationSize += product.getRequiredDiskSpace(); - downloadSize += product.getDownloadSize(); - - - } - - // add top-level components like nb-base, glassfish, tomcat, jdk - for (Product product : registry.getProductsToInstall()) { - text.append(StringUtils.LF); - text.append(StringUtils.format(panel.getProperty(INSTALLATION_FOLDER_PROPERTY), - product.getDisplayName())); - text.append(StringUtils.LF); - text.append(" " + product.getInstallationLocation()); - text.append(StringUtils.LF); - } - locationsPane.setText(text); - - List toUninstall = registry.getProductsToUninstall(); - String uninstallLabelText = toUninstall.size() > 0 ? StringUtils.format( - panel.getProperty(UNINSTALL_LABEL_TEXT_PROPERTY), - toUninstall.get(0).getDisplayName()) : ""; - - uninstallListLabel.setText(uninstallLabelText); - - - installationSizeLabel.setText( - panel.getProperty(INSTALLATION_SIZE_PROPERTY)); - installationSizeValue.setText(StringUtils.formatSize(installationSize)); - - downloadSizeLabel.setText( - panel.getProperty(DOWNLOAD_SIZE_PROPERTY)); - downloadSizeValue.setText(StringUtils.formatSize(downloadSize)); - - if (registry.getProductsToInstall().size() == 0) { - locationsPane.setVisible(false); - installationSizeLabel.setVisible(false); - installationSizeValue.setVisible(false); - } else { - locationsPane.setVisible(true); - installationSizeLabel.setVisible(true); - installationSizeValue.setVisible(true); - } - - if (registry.getProductsToUninstall().size() == 0) { - uninstallListLabel.setVisible(false); - uninstallListPane.setVisible(false); - } else { - uninstallListLabel.setVisible(true); - uninstallListPane.setVisible(true); - } - - downloadSizeLabel.setVisible(false); - downloadSizeValue.setVisible(false); - for (RegistryNode remoteNode : registry.getNodes(RegistryType.REMOTE)) { - if (remoteNode.isVisible()) { - downloadSizeLabel.setVisible(true); - downloadSizeValue.setVisible(true); - } - } - - if (Boolean.getBoolean(REMOVE_APP_USERDIR_PROPERTY)) { - removeUserdirCheckbox.doClick(); - } - - removeUserdirCheckbox.setVisible(false); - removeUserdirPane.setVisible(false); - - for (Product product : Registry.getInstance().getProductsToUninstall()) { - - try { - File installLocation = product.getInstallationLocation(); - LogManager.log("... product installation directory: " + installLocation); - File userDir = NetBeansRCPUtils.getApplicationUserDirFile(installLocation); - LogManager.log("... product userdir: " + userDir); - if (FileUtils.exists(userDir) && FileUtils.canWrite(userDir)) { - removeUserdirCheckbox.setText( - StringUtils.format( - panel.getProperty(REMOVE_APP_USERDIR_CHECKBOX_PROPERTY), - userDir.getAbsolutePath())); - removeUserdirCheckbox.setBorder(new EmptyBorder(0, 0, 0, 0)); - removeUserdirCheckbox.setVisible(true); - - removeUserdirPane.setVisible(true); - removeUserdirPane.setContentType("text/html"); - - removeUserdirPane.setText( - StringUtils.format( - panel.getProperty(REMOVE_APP_USERDIR_TEXT_PROPERTY), - product.getDisplayName())); - - } - break; - } catch (IOException e) { - LogManager.log(e); - } - - } - - //if(productCheckboxList!=null) { - // for(Pair pair : productCheckboxList) { - // pair.getSecond().doClick(); - // } - //} - super.initialize(); - } - - @Override - protected String validateInput() { - try { - if (!Boolean.getBoolean(SystemUtils.NO_SPACE_CHECK_PROPERTY)) { - final List roots = - SystemUtils.getFileSystemRoots(); - final List toInstall = - Registry.getInstance().getProductsToInstall(); - final Map spaceMap = - new HashMap(); - - LogManager.log("Available roots : " + StringUtils.asString(roots)); - - File downloadDataDirRoot = FileUtils.getRoot( - Installer.getInstance().getLocalDirectory(), roots); - long downloadSize = 0; - for (Product product : toInstall) { - downloadSize += product.getDownloadSize(); - } - // the critical check point - we download all the data - spaceMap.put(downloadDataDirRoot, new Long(downloadSize)); - long lastDataSize = 0; - for (Product product : toInstall) { - final File installLocation = product.getInstallationLocation(); - final File root = FileUtils.getRoot(installLocation, roots); - final long productSize = product.getRequiredDiskSpace(); - - LogManager.log(" [" + root + "] <- " + installLocation); - - if (root != null) { - Long ddSize = spaceMap.get(downloadDataDirRoot); - // remove space that was freed after the remove of previos product data - spaceMap.put(downloadDataDirRoot, - Long.valueOf(ddSize - lastDataSize)); - - // add space required for next product installation - Long size = spaceMap.get(root); - size = Long.valueOf( - (size != null ? size.longValue() : 0L) - + productSize); - spaceMap.put(root, size); - lastDataSize = product.getDownloadSize(); - } else { - return StringUtils.format( - panel.getProperty(ERROR_NON_EXISTENT_ROOT_PROPERTY), - product, installLocation); - } - } - - for (Map.Entry it : spaceMap.entrySet()) { - File root = it.getKey(); - - try { - final long availableSpace = SystemUtils.getFreeSpace(root); - final long requiredSpace = it.getValue() + REQUIRED_SPACE_ADDITION; - - if (availableSpace < requiredSpace) { - return StringUtils.format( - panel.getProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY), - root, - StringUtils.formatSize(requiredSpace - availableSpace)); - } - } catch (NativeException e) { - ErrorManager.notifyError( - panel.getProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY), - e); - } - } - } - - final List toUninstall = - Registry.getInstance().getProductsToUninstall(); - for (Product product : toUninstall) { - if (!FileUtils.canWrite(product.getInstallationLocation())) { - return StringUtils.format( - panel.getProperty(ERROR_CANNOT_WRITE_PROPERTY), - product, - product.getInstallationLocation()); - } - } - - } catch (IOException e) { - ErrorManager.notifyError( - panel.getProperty(ERROR_FSROOTS_PROPERTY), e); - } - - return null; - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - gridy = 0; - - // locationsPane //////////////////////////////////////////////////////// - locationsPane = new NbiTextPane(); - - // uninstallListPane //////////////////////////////////////////////////// - uninstallListPane = new NbiTextPane(); - - // uninstallListLabel /////////////////////////////////////////////////// - uninstallListLabel = new NbiLabel(); - uninstallListLabel.setLabelFor(uninstallListPane); - - // installationSizeValue //////////////////////////////////////////////// - installationSizeValue = new NbiLabel(); - //installationSizeValue.setFocusable(true); - - // installationSizeLabel //////////////////////////////////////////////// - installationSizeLabel = new NbiLabel(); - installationSizeLabel.setLabelFor(installationSizeValue); - - // downloadSizeValue //////////////////////////////////////////////////// - downloadSizeValue = new NbiLabel(); - //downloadSizeValue.setFocusable(true); - - // downloadSizeLabel //////////////////////////////////////////////////// - downloadSizeLabel = new NbiLabel(); - downloadSizeLabel.setLabelFor(downloadSizeValue); - - // spacer /////////////////////////////////////////////////////////////// - spacer = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(locationsPane, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(uninstallListLabel, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(uninstallListPane, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(0, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - int gridy0 = gridy; - gridy++; - - removeUserdirPane = new NbiTextPane(); - add(removeUserdirPane, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - removeUserdirCheckbox = new NbiCheckBox(); - add(removeUserdirCheckbox, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 20, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - removeUserdirCheckbox.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - System.setProperty(REMOVE_APP_USERDIR_PROPERTY, - "" + removeUserdirCheckbox.isSelected()); - } - }); - - add(installationSizeLabel, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(22, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(installationSizeValue, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 22, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(downloadSizeLabel, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(downloadSizeValue, new GridBagConstraints( - 0, gridy++, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 22, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacer, new GridBagConstraints( - 0, gridy + 10, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - } - } -///////////////////////////////////////////////////////////////////////////////// -// Constants - public static final String INSTALLATION_FOLDER_PROPERTY = - "installation.folder"; // NOI18N - public static final String UNINSTALL_LABEL_TEXT_PROPERTY = - "uninstall.list.label.text"; // NOI18N - public static final String INSTALLATION_SIZE_PROPERTY = - "installation.size"; // NOI18N - public static final String DOWNLOAD_SIZE_PROPERTY = - "download.size"; // NOI18N - public static final String ERROR_NOT_ENOUGH_SPACE_PROPERTY = - "error.not.enough.space"; // NOI18N - public static final String ERROR_CANNOT_CHECK_SPACE_PROPERTY = - "error.cannot.check.space"; // NOI18N - public static final String ERROR_LOGIC_ACCESS_PROPERTY = - "error.logic.access"; // NOI18N - public static final String ERROR_FSROOTS_PROPERTY = - "error.fsroots"; // NOI18N - public static final String ERROR_NON_EXISTENT_ROOT_PROPERTY = - "error.non.existent.root"; // NOI18N - public static final String ERROR_CANNOT_WRITE_PROPERTY = - "error.cannot.write"; // NOI18N - public static final String REMOVE_APP_USERDIR_PROPERTY = - "remove.app.userdir"; - public static final String REMOVE_APP_USERDIR_TEXT_PROPERTY = - "remove.app.userdir.text"; - public static final String REMOVE_APP_USERDIR_CHECKBOX_PROPERTY = - "remove.app.userdir.checkbox"; - public static final String DEFAULT_TITLE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.description"); // NOI18N - public static final String DEFAULT_DESCRIPTION_UNINSTALL = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.description.uninstall"); // NOI18N - public static final String DEFAULT_INSTALLATION_FOLDER = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.installation.folder"); // NOI18N - public static final String DEFAULT_UNINSTALL_LABEL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.uninstall.list.label.text"); // NOI18N - public static final String DEFAULT_INSTALLATION_SIZE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.installation.size"); // NOI18N - public static final String DEFAULT_DOWNLOAD_SIZE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.download.size"); // NOI18N - public static final String DEFAULT_NEXT_BUTTON_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.next.button.text"); // NOI18N - public static final String DEFAULT_NEXT_BUTTON_TEXT_UNINSTALL = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.next.button.text.uninstall"); // NOI18N - public static final String DEFAULT_ERROR_NOT_ENOUGH_SPACE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.not.enough.space"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_CHECK_SPACE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.cannot.check.space");// NOI18N - public static final String DEFAULT_ERROR_LOGIC_ACCESS = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.logic.access");// NOI18N - public static final String DEFAULT_ERROR_FSROOTS = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.fsroots"); // NOI18N - public static final String DEFAULT_ERROR_NON_EXISTENT_ROOT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.non.existent.root"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_WRITE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.cannot.write"); // NOI18N - public static final String DEFAULT_REMOVE_APP_USERDIR_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.remove.app.userdir.text"); // NOI18N - - public static final String DEFAULT_REMOVE_APP_USERDIR_CHECKBOX = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.remove.app.userdir.checkbox"); // NOI18N - public static final long REQUIRED_SPACE_ADDITION = - 10L * 1024L * 1024L; // 10MB -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/WelcomePanel.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/WelcomePanel.java deleted file mode 100644 index f3a12e2a5488..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/WelcomePanel.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.wizard.components.panels; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.io.File; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel.ErrorMessagePanelSwingUi; -import org.netbeans.installer.wizard.components.panels.ErrorMessagePanel.ErrorMessagePanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -public class WelcomePanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - private Registry bundledRegistry; - private Registry defaultRegistry; - - public WelcomePanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(WELCOME_TEXT_PROPERTY, - DEFAULT_WELCOME_TEXT); - - setProperty(WELCOME_ALREADY_INSTALLED_TEXT_PROPERTY, - DEFAULT_WELCOME_ALREADY_INSTALLED_TEXT); - setProperty(WELCOME_ALREADY_INSTALLED_NEXT_BUTTON_TEXT_PROPERTY, - DEFAULT_WELCOME_ALREADY_INSTALLED_NEXT_BUTTON_TEXT); - - try { - defaultRegistry = Registry.getInstance(); - bundledRegistry = new Registry(); - - final String bundledRegistryUri = System.getProperty( - Registry.BUNDLED_PRODUCT_REGISTRY_URI_PROPERTY); - if (bundledRegistryUri != null) { - bundledRegistry.loadProductRegistry(bundledRegistryUri); - } else { - bundledRegistry.loadProductRegistry( - Registry.DEFAULT_BUNDLED_PRODUCT_REGISTRY_URI); - } - } catch (InitializationException e) { - ErrorManager.notifyError("Cannot load bundled registry", e); - } - - } - - Registry getBundledRegistry() { - return bundledRegistry; - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new WelcomePanelUi(this); - } - - return wizardUi; - } - - @Override - public boolean canExecuteForward() { - return canExecute(); - } - - @Override - public boolean canExecuteBackward() { - return canExecute(); - } - - // private ////////////////////////////////////////////////////////////////////// - private boolean canExecute() { - return bundledRegistry.getNodes().size() > 1; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class WelcomePanelUi extends ErrorMessagePanelUi { - - protected WelcomePanel component; - - public WelcomePanelUi(WelcomePanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new WelcomePanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class WelcomePanelSwingUi extends ErrorMessagePanelSwingUi { - - protected WelcomePanel panel; - private NbiTextPane textPane; - - private NbiPanel leftImagePanel; - ValidatingThread validatingThread; - - public WelcomePanelSwingUi( - final WelcomePanel component, - final SwingContainer container) { - super(component, container); - - this.panel = component; - - initComponents(); - } - - @Override - public String getTitle() { - return null; // the welcome page does not have a title - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - - container.getBackButton().setVisible(false); - } - - @Override - protected void initialize() { - - textPane.setContentType("text/html"); - textPane.setText(StringUtils.format(panel.getProperty(WELCOME_TEXT_PROPERTY))); - List toInstall = Registry.getInstance().getProductsToInstall(); - if(toInstall.isEmpty()) { - List list = panel.getBundledRegistry().getProducts(); - if(list.size() == 1) { - if(SystemUtils.getCurrentPlatform().isCompatibleWith(list.get(0).getPlatforms())) { - File installationLocation = list.get(0).getInstallationLocation(); - textPane.setText( - StringUtils.format( - panel.getProperty(WELCOME_ALREADY_INSTALLED_TEXT_PROPERTY), - list.get(0).getDisplayName(), - installationLocation.getAbsolutePath())); - } else { - textPane.setText( - StringUtils.format( - WELCOME_INCOMPATIBLE_PLATFORM_TEXT, - list.get(0).getDisplayName())); - } - container.getCancelButton().setVisible(false); - container.getNextButton().setText(panel.getProperty( - WELCOME_ALREADY_INSTALLED_NEXT_BUTTON_TEXT_PROPERTY)); - } - } - - super.initialize(); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // textPane ///////////////////////////////////////////////////////////// - textPane = new NbiTextPane(); - - leftImagePanel = new NbiPanel(); - int width = 0; - int height = 0; - final String topLeftImage = SystemUtils.resolveString( - System.getProperty( - WELCOME_PAGE_LEFT_TOP_IMAGE_PROPERTY)); - final String bottomLeftImage = SystemUtils.resolveString( - System.getProperty( - WELCOME_PAGE_LEFT_BOTTOM_IMAGE_PROPERTY)); - - int bottomAnchor = NbiPanel.ANCHOR_BOTTOM_LEFT; - - if (topLeftImage != null) { - leftImagePanel.setBackgroundImage(topLeftImage, ANCHOR_TOP_LEFT); - width = leftImagePanel.getBackgroundImage(NbiPanel.ANCHOR_TOP_LEFT).getIconWidth(); - height += leftImagePanel.getBackgroundImage(NbiPanel.ANCHOR_TOP_LEFT).getIconHeight(); - } - if (bottomLeftImage != null) { - leftImagePanel.setBackgroundImage(bottomLeftImage, bottomAnchor); - width = leftImagePanel.getBackgroundImage(bottomAnchor).getIconWidth(); - height += leftImagePanel.getBackgroundImage(bottomAnchor).getIconHeight(); - } - - leftImagePanel.setPreferredSize(new Dimension(width, height)); - leftImagePanel.setMaximumSize(new Dimension(width, height)); - leftImagePanel.setMinimumSize(new Dimension(width, 0)); - leftImagePanel.setSize(new Dimension(width, height)); - - leftImagePanel.setOpaque(false); - // this ///////////////////////////////////////////////////////////////// - int dy = 0; - add(leftImagePanel, new GridBagConstraints( - 0, 0, // x, y - 1, 100, // width, height - 0.0, 1.0, // weight-x, weight-y - GridBagConstraints.WEST, // anchor - GridBagConstraints.VERTICAL, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - add(textPane, new GridBagConstraints( - 1, dy++, // x, y - 4, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(10, 11, 11, 11), // padding - 0, 0)); // padx, pady - ??? - - NbiTextPane separatorPane = new NbiTextPane(); - - separatorPane = new NbiTextPane(); - add(separatorPane, new GridBagConstraints( - 3, dy, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - - - // move error label after the left welcome image - Component errorLabel = getComponent(0); - getLayout().removeLayoutComponent(errorLabel); - add(errorLabel, new GridBagConstraints( - 1, 99, // x, y - 99, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 4, 0), // padding - 0, 0)); // ??? (padx, pady) - - - } - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(WelcomePanel.class, - "WP.title"); - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(WelcomePanel.class, - "WP.description"); // NOI18N - public static final String WELCOME_TEXT_PROPERTY = - "welcome.text"; // NOI18N - public static final String WELCOME_ALREADY_INSTALLED_TEXT_PROPERTY = - "welcome.already.installed.text"; // NOI18N - public static final String WELCOME_ALREADY_INSTALLED_NEXT_BUTTON_TEXT_PROPERTY = - "welcome.already.installed.next.button.text";//NOI18N - public static final String WELCOME_INCOMPATIBLE_PLATFORM_TEXT = - ResourceUtils.getString(WelcomePanel.class, - "WP.incompatible.platform.text");//NOI18N - - public static final String DEFAULT_WELCOME_ALREADY_INSTALLED_NEXT_BUTTON_TEXT = - ResourceUtils.getString(WelcomePanel.class, - "WP.already.installed.next.button.text");//NOI18N - - public static final String DEFAULT_WELCOME_TEXT = - ResourceUtils.getString(WelcomePanel.class, - "WP.welcome.text"); // NOI18N - - public static final String DEFAULT_WELCOME_ALREADY_INSTALLED_TEXT = - ResourceUtils.getString(WelcomePanel.class, - "WP.already.installed.text"); // NOI18N - - public static final String WELCOME_PAGE_LEFT_TOP_IMAGE_PROPERTY = - "nbi.wizard.ui.swing.welcome.left.top.image";//NOI18N - public static final String WELCOME_PAGE_LEFT_BOTTOM_IMAGE_PROPERTY = - "nbi.wizard.ui.swing.welcome.left.bottom.image";//NOI18N -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-bottom.png b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-bottom.png deleted file mode 100644 index cc8d41418088..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-bottom.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-top.png b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-top.png deleted file mode 100644 index 1e7a2a7c6a53..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/panels/resources/welcome-left-top.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/Bundle.properties b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/Bundle.properties deleted file mode 100644 index 69c1e5866406..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/Bundle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# MainSequence.java -MS.IA.title=Installation -MS.IA.description=Please wait while the installer installs {product-name}. diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/MainSequence.java b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/MainSequence.java deleted file mode 100644 index 9469efb2a73c..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/components/sequences/MainSequence.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mycompany.installer.wizard.components.sequences; - -import org.netbeans.installer.wizard.components.sequences.ProductWizardSequence; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.mycompany.installer.wizard.components.panels.PostInstallSummaryPanel; -import org.mycompany.installer.wizard.components.panels.PreInstallSummaryPanel; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.helper.ExecutionMode; -import org.netbeans.installer.wizard.components.WizardSequence; -import org.netbeans.installer.wizard.components.actions.DownloadConfigurationLogicAction; -import org.netbeans.installer.wizard.components.actions.DownloadInstallationDataAction; -import org.netbeans.installer.wizard.components.actions.InstallAction; -import org.netbeans.installer.wizard.components.actions.UninstallAction; -import org.netbeans.installer.wizard.components.panels.LicensesPanel; - -public class MainSequence extends WizardSequence { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - private DownloadConfigurationLogicAction downloadConfigurationLogicAction; - private LicensesPanel licensesPanel; - private PreInstallSummaryPanel preInstallSummaryPanel; - private UninstallAction uninstallAction; - private DownloadInstallationDataAction downloadInstallationDataAction; - private InstallAction installAction; - private PostInstallSummaryPanel postInstallSummaryPanel; - private Map productSequences; - - public MainSequence() { - downloadConfigurationLogicAction = new DownloadConfigurationLogicAction(); - licensesPanel = new LicensesPanel(); - preInstallSummaryPanel = new PreInstallSummaryPanel(); - uninstallAction = new UninstallAction(); - downloadInstallationDataAction = new DownloadInstallationDataAction(); - installAction = new InstallAction(); - postInstallSummaryPanel = new PostInstallSummaryPanel(); - productSequences = new HashMap(); - - installAction.setProperty(InstallAction.TITLE_PROPERTY, - DEFAULT_IA_TITLE); - installAction.setProperty(InstallAction.DESCRIPTION_PROPERTY, - DEFAULT_IA_DESCRIPTION); - } - - @Override - public void executeForward() { - final Registry registry = Registry.getInstance(); - final List toInstall = registry.getProductsToInstall(); - final List toUninstall = registry.getProductsToUninstall(); - - // remove all current children (if there are any), as the components - // selection has probably changed and we need to rebuild from scratch - getChildren().clear(); - - // the set of wizard components differs greatly depending on the execution - // mode - if we're installing, we ask for input, run a wizard sequence for - // each selected component and then download and install; if we're creating - // a bundle, we only need to download and package things - - if (toInstall.size() > 0) { - addChild(downloadConfigurationLogicAction); - addChild(licensesPanel); - - for (Product product : toInstall) { - if (!productSequences.containsKey(product)) { - productSequences.put( - product, - new ProductWizardSequence(product)); - } - - addChild(productSequences.get(product)); - } - } - - addChild(preInstallSummaryPanel); - - if (toUninstall.size() > 0) { - addChild(uninstallAction); - } - - if (toInstall.size() > 0) { - addChild(downloadInstallationDataAction); - addChild(installAction); - } - - addChild(postInstallSummaryPanel); - - super.executeForward(); - } - - @Override - public boolean canExecuteForward() { - return ExecutionMode.NORMAL == ExecutionMode.getCurrentExecutionMode() && - (Registry.getInstance().getProductsToInstall().size() > 0 || - Registry.getInstance().getProductsToUninstall().size() > 0); - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_IA_TITLE = - ResourceUtils.getString( - MainSequence.class, - "MS.IA.title"); // NOI18N - public static final String DEFAULT_IA_DESCRIPTION = - ResourceUtils.getString( - MainSequence.class, - "MS.IA.description"); // NOI18N - -} diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-components.xml b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-components.xml deleted file mode 100644 index 005253639f37..000000000000 --- a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-components.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-left.png b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-left.png deleted file mode 100644 index 931de16277a3..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-left.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-right.png b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-right.png deleted file mode 100644 index 7470327df0f5..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-description-background-right.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-icon.png b/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-icon.png deleted file mode 100644 index 1b3bcd61d25b..000000000000 Binary files a/harness/libs.nbi.ant/stub/ext/engine/src/org/mycompany/installer/wizard/wizard-icon.png and /dev/null differ diff --git a/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.properties b/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.properties deleted file mode 100644 index e5e9451756dd..000000000000 --- a/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.properties +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../../../../.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the engine sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path=engine - -# name of the engine's distributive file -engine.dist.file.name=nbi-engine.jar - -# we do not need to build anything native for the netbeans-specific engine, as it -# does not contain any native components -build.native=false - -# custom parameter for the netbeans project build script - in case of the netbeans -# nbi engine - the location of the core engine jar file -nb.custom.parameter=-Dreference.NBI_Engine.jar=${core.engine.dist.file} - -# sources parameters; a search-and-replace will be run over the sources after -# check-out, replacing [token] => [value]; regular expressions are not allowed -# * ${sources.params.length} - total number of the parameters -# * indices should start with 1 -# * parameters are not i18n compliant - -sources.params.length=0 diff --git a/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.xml b/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.xml deleted file mode 100644 index 0caaa1477554..000000000000 --- a/harness/libs.nbi.ant/stub/ext/infra/build/engine/build.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the engine use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.properties b/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.properties deleted file mode 100644 index 999c8a9b3fd6..000000000000 --- a/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.properties +++ /dev/null @@ -1,137 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../../../../../.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the products's sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path=components/products/helloworld - -# core product properties: -# * ${product.uid} - product "family" (e.g. nb-ide) -# * ${product.version} - actual products' version; together with the uid it -# forms the unique identifier for the product) -# * ${product.platforms} - the list of platforms that are supported by this -# product (note that this property is not related to native libraries) -product.uid={product-uid} -product.version=1.0.0.0.0 -product.platforms=generic - -# miscellaneous product properties: -# * ${product.status} - default status that the product will have in the -# registry. it is meant to be always "not-installed", unless you want -# something really exotic -# * ${product.offset} - order of the product's node among its parent's -# children, the bigger the offset value, the further the product's node will -# be -# * ${product.expand} - whether to automatically expand the product's node in -# the components tree or not; 'true'/'false' -# * ${product.visible} - whether the product's node is visible or not (note -# that this value will be modified at nbi runtime, 'true' may become 'false' -# if the product is filtered out); 'true'/'false' -# * ${product.features} - list of features that this porduct belongs to; the -# list should be space-separated -product.status=not-installed -product.offset=20000 -product.expand=false -product.visible=true -product.features= - -# list of configuration logic jar files; normally the first one would be the -# distributive file of the product's netbeans project -# * ${product.logic.length} - total number of the files -# * indices should start with 1 -product.logic.length=1 -product.logic.1.path=${nbproject.dist.dir}/${nbproject.dist.file.name} - -# list of product installation data files -# * ${product.data.length} - total number of the files -# * ${product.data.N.uri} - uri at which the installation data file is located -# * ${product.data.N.zip} - whether the data file is a zip archive which needs to -# be extracted or it is a file that should be used directly; 'true'/'false' -# * indices should start with 1 -product.data.length=1 -product.data.1.zip=true -product.data.1.path={product-data-path} -product.data.sub.dir={product-data-sub-dir} - -# modificator for the required disk space parameter; the core value will be the -# sum of unzipped unstallation data files -# * the measurement unit is one byte -product.disk.space.modificator=0 - -# product's requirements (i.e. other products that should be installed -# in order for this product to succesfully install and function) -# * ${product.requirements.length} - total number of the requirements -# * indices should start with 1 -product.requirements.length=0 -#product.requirements.1.uid= -#product.requirements.1.version-lower= -#product.requirements.1.version-upper= - -# product's conflicts (i.e. other products that prevent this product from -# functioning correctly, and thus cannot be installed together with it) -# * ${product.conflicts.length} - total number of the conflicts -# * indices should start with 1 -product.conflicts.length=0 -#product.conflicts.1.uid= -#product.conflicts.1.version-lower= -#product.conflicts.1.version-upper= - -# other products that should be installed prior to this product; these -# dependencies do not imply that the dependent product will be installed at -# all, but if both the current and the dependent product are selected for -# installation, the latter will be installed first -# * ${product.install-afters.length} - total number of the install-afters -# * indices should start with 1 -product.install-afters.length=0 -#product.install-afters.1.uid= - -# additional product's properties; these will appear in the product's -# descriptor and in the registry in the form of -# value tags. -# * ${product.properties.length} - total number of the properties -# * indices should start with 1 -# * properties are not i18n compliant -product.properties.length=3 -product.properties.1.name=installation.location -product.properties.1.value=$N{install}/{product-install-directory-name} -product.properties.2.name=installation.location.windows -product.properties.2.value=$N{install}/{product-install-directory-name-windows} -product.properties.3.name=installation.location.macosx -product.properties.3.value=$N{install}/{product-install-directory-name-macosx}.app - -# sources parameters; a search-and-replace will be run over the sources after -# check-out, replacing [token] => [value]; regular expressions are not allowed -# * ${sources.params.length} - total number of the parameters -# * indices should start with 1 -# * parameters are not i18n compliant -sources.params.length=0 \ No newline at end of file diff --git a/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.xml b/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.xml deleted file mode 100644 index 2e9554907439..000000000000 --- a/harness/libs.nbi.ant/stub/ext/infra/build/products/helloworld/build.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the group use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/harness/libs.nbi.ant/stub/template.xml b/harness/libs.nbi.ant/stub/template.xml deleted file mode 100644 index ec39c97b82fd..000000000000 --- a/harness/libs.nbi.ant/stub/template.xml +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.ant/stub/tmpl.properties b/harness/libs.nbi.ant/stub/tmpl.properties deleted file mode 100644 index aee69ff5592a..000000000000 --- a/harness/libs.nbi.ant/stub/tmpl.properties +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -suite.location=C:/Documents and Settings/Lipin/My Documents/NetBeansProjects/MyApp - -nbi.cluster.location=D:/space/NB-IDE/proto/nbbuild/netbeans/extra - -nbi.stub.location=${nbi.cluster.location}/nbi/stub -nbi.stub.common.location=${nbi.cluster.location}/nbi/.common -nbi.ant.tasks.jar=${nbi.cluster.location}/modules/ext/nbi-ant-tasks.jar -nbi.registries.management.jar=${nbi.cluster.location}/modules/ext/nbi-registries-management.jar -nbi.engine.jar=${nbi.cluster.location}/modules/ext/nbi-engine.jar - -generate.installer.for.platforms=windows linux macosx - -generator-jdk-location-forward-slashes=C:/Program Files/Java/jdk1.5.0_16 - -suite.nbi.product.uid=myapp diff --git a/harness/libs.nbi.engine/build.xml b/harness/libs.nbi.engine/build.xml deleted file mode 100644 index b5c4319b3e77..000000000000 --- a/harness/libs.nbi.engine/build.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - Builds, tests, and runs the project org.netbeans.libs.nbi.engine - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/harness/libs.nbi.engine/external/binaries-list b/harness/libs.nbi.engine/external/binaries-list deleted file mode 100644 index a9e21b6156c3..000000000000 --- a/harness/libs.nbi.engine/external/binaries-list +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -2B892D9E648A792EDB0F705378E06F84C322E208 nbi.engine-external-binaries-11.zip diff --git a/harness/libs.nbi.engine/external/nbi.engine-external-binaries-11-license.txt b/harness/libs.nbi.engine/external/nbi.engine-external-binaries-11-license.txt deleted file mode 100644 index 8112b9fd870b..000000000000 --- a/harness/libs.nbi.engine/external/nbi.engine-external-binaries-11-license.txt +++ /dev/null @@ -1,387 +0,0 @@ -Name: NetBeans Installer Binaries -Description: NetBeans Installer Binaries -Version: 11 -License: CDDL-1.0 -Source: https://netbeans.org/ -Origin: NetBeans - -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - -1.1. "Contributor" means each individual or entity that -creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the -Original Software, prior Modifications used by a -Contributor (if any), and the Modifications made by that -particular Contributor. - -1.3. "Covered Software" means (a) the Original Software, or -(b) Modifications, or (c) the combination of files -containing Original Software with files containing -Modifications, in each case including portions thereof. - -1.4. "Executable" means the Covered Software in any form -other than Source Code. - -1.5. "Initial Developer" means the individual or entity -that first makes Original Software available under this -License. - -1.6. "Larger Work" means a work which combines Covered -Software or portions thereof with code not governed by the -terms of this License. - -1.7. "License" means this document. - -1.8. "Licensable" means having the right to grant, to the -maximum extent possible, whether at the time of the initial -grant or subsequently acquired, any and all of the rights -conveyed herein. - -1.9. "Modifications" means the Source Code and Executable -form of any of the following: - -A. Any file that results from an addition to, -deletion from or modification of the contents of a -file containing Original Software or previous -Modifications; - -B. Any new file that contains any part of the -Original Software or previous Modification; or - -C. Any new file that is contributed or otherwise made -available under the terms of this License. - -1.10. "Original Software" means the Source Code and -Executable form of computer software code that is -originally released under this License. - -1.11. "Patent Claims" means any patent claim(s), now owned -or hereafter acquired, including without limitation, -method, process, and apparatus claims, in any patent -Licensable by grantor. - -1.12. "Source Code" means (a) the common form of computer -software code in which modifications are made and (b) -associated documentation included in or with such code. - -1.13. "You" (or "Your") means an individual or a legal -entity exercising rights under, and complying with all of -the terms of, this License. For legal entities, "You" -includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this -definition, "control" means (a) the power, direct or -indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership -of more than fifty percent (50%) of the outstanding shares -or beneficial ownership of such entity. - -2. License Grants. - -2.1. The Initial Developer Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, the -Initial Developer hereby grants You a world-wide, -royalty-free, non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Initial Developer, -to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or -portions thereof), with or without Modifications, -and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using or selling of Original Software, to make, have -made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or -portions thereof). - -(c) The licenses granted in Sections 2.1(a) and (b) -are effective on the date Initial Developer first -distributes or otherwise makes the Original Software -available to a third party under the terms of this -License. - -(d) Notwithstanding Section 2.1(b) above, no patent -license is granted: (1) for code that You delete from -the Original Software, or (2) for infringements -caused by: (i) the modification of the Original -Software, or (ii) the combination of the Original -Software with other software or devices. - -2.2. Contributor Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, each -Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Contributor to -use, reproduce, modify, display, perform, sublicense -and distribute the Modifications created by such -Contributor (or portions thereof), either on an -unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using, or selling of Modifications made by that -Contributor either alone and/or in combination with -its Contributor Version (or portions of such -combination), to make, use, sell, offer for sale, -have made, and/or otherwise dispose of: (1) -Modifications made by that Contributor (or portions -thereof); and (2) the combination of Modifications -made by that Contributor with its Contributor Version -(or portions of such combination). - -(c) The licenses granted in Sections 2.2(a) and -2.2(b) are effective on the date Contributor first -distributes or otherwise makes the Modifications -available to a third party. - -(d) Notwithstanding Section 2.2(b) above, no patent -license is granted: (1) for any code that Contributor -has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party -modifications of Contributor Version, or (ii) the -combination of Modifications made by that Contributor -with other software (except as part of the -Contributor Version) or other devices; or (3) under -Patent Claims infringed by Covered Software in the -absence of Modifications made by that Contributor. - -3. Distribution Obligations. - -3.1. Availability of Source Code. - -Any Covered Software that You distribute or otherwise make -available in Executable form must also be made available in -Source Code form and that Source Code form must be -distributed only under the terms of this License. You must -include a copy of this License with every copy of the -Source Code form of the Covered Software You distribute or -otherwise make available. You must inform recipients of any -such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a -reasonable manner on or through a medium customarily used -for software exchange. - -3.2. Modifications. - -The Modifications that You create or to which You -contribute are governed by the terms of this License. You -represent that You believe Your Modifications are Your -original creation(s) and/or You have sufficient rights to -grant the rights conveyed by this License. - -3.3. Required Notices. - -You must include a notice in each of Your Modifications -that identifies You as the Contributor of the Modification. -You may not remove or alter any copyright, patent or -trademark notices contained within the Covered Software, or -any notices of licensing or any descriptive text giving -attribution to any Contributor or the Initial Developer. - -3.4. Application of Additional Terms. - -You may not offer or impose any terms on any Covered -Software in Source Code form that alters or restricts the -applicable version of this License or the recipients' -rights hereunder. You may choose to offer, and to charge a -fee for, warranty, support, indemnity or liability -obligations to one or more recipients of Covered Software. -However, you may do so only on Your own behalf, and not on -behalf of the Initial Developer or any Contributor. You -must make it absolutely clear that any such warranty, -support, indemnity or liability obligation is offered by -You alone, and You hereby agree to indemnify the Initial -Developer and every Contributor for any liability incurred -by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.5. Distribution of Executable Versions. - -You may distribute the Executable form of the Covered -Software under the terms of this License or under the terms -of a license of Your choice, which may contain terms -different from this License, provided that You are in -compliance with the terms of this License and that the -license for the Executable form does not attempt to limit -or alter the recipient's rights in the Source Code form -from the rights set forth in this License. If You -distribute the Covered Software in Executable form under a -different license, You must make it absolutely clear that -any terms which differ from this License are offered by You -alone, not by the Initial Developer or Contributor. You -hereby agree to indemnify the Initial Developer and every -Contributor for any liability incurred by the Initial -Developer or such Contributor as a result of any such terms -You offer. - -3.6. Larger Works. - -You may create a Larger Work by combining Covered Software -with other code not governed by the terms of this License -and distribute the Larger Work as a single product. In such -a case, You must make sure the requirements of this License -are fulfilled for the Covered Software. - -4. Versions of the License. - -4.1. New Versions. - -Sun Microsystems, Inc. is the initial license steward and -may publish revised and/or new versions of this License -from time to time. Each version will be given a -distinguishing version number. Except as provided in -Section 4.3, no one other than the license steward has the -right to modify this License. - -4.2. Effect of New Versions. - -You may always continue to use, distribute or otherwise -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. If the Initial Developer includes a -notice in the Original Software prohibiting it from being -distributed or otherwise made available under any -subsequent version of the License, You must distribute and -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. Otherwise, You may also choose to -use, distribute or otherwise make the Covered Software -available under the terms of any subsequent version of the -License published by the license steward. - -4.3. Modified Versions. - -When You are an Initial Developer and You want to create a -new license for Your Original Software, You may create and -use a modified version of this License if You: (a) rename -the license and remove any references to the name of the -license steward (except to note that the license differs -from this License); and (b) otherwise make it clear that -the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" -BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED -SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR -PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY -COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE -INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF -ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF -WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF -ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS -DISCLAIMER. - -6. TERMINATION. - -6.1. This License and the rights granted hereunder will -terminate automatically if You fail to comply with terms -herein and fail to cure such breach within 30 days of -becoming aware of the breach. Provisions which, by their -nature, must remain in effect beyond the termination of -this License shall survive. - -6.2. If You assert a patent infringement claim (excluding -declaratory judgment actions) against Initial Developer or -a Contributor (the Initial Developer or Contributor against -whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the -Contributor Version where the Participant is a Contributor -or the Original Software where the Participant is the -Initial Developer) directly or indirectly infringes any -patent, then any and all rights granted directly or -indirectly to You by such Participant, the Initial -Developer (if the Initial Developer is not the Participant) -and all Contributors under Sections 2.1 and/or 2.2 of this -License shall, upon 60 days notice from Participant -terminate prospectively and automatically at the expiration -of such 60 day notice period, unless if within such 60 day -period You withdraw Your claim with respect to the -Participant Software against such Participant either -unilaterally or pursuant to a written agreement with -Participant. - -6.3. In the event of termination under Sections 6.1 or 6.2 -above, all end user licenses that have been validly granted -by You or any distributor hereunder prior to termination -(excluding licenses granted to You by any distributor) -shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT -(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF -COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE -LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN -INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF -LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT -APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO -NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT -APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a "commercial item," as that term is -defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial -computer software" (as that term is defined at 48 C.F.R. -252.227-7014(a)(1)) and "commercial computer software -documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 -through 227.7202-4 (June 1995), all U.S. Government End Users -acquire Covered Software with only those rights set forth herein. -This U.S. Government Rights clause is in lieu of, and supersedes, -any other FAR, DFAR, or other clause or provision that addresses -Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the -extent necessary to make it enforceable. This License shall be -governed by the law of the jurisdiction specified in a notice -contained within the Original Software (except to the extent -applicable law, if any, provides otherwise), excluding such -jurisdiction's conflict-of-law provisions. Any litigation -relating to this License shall be subject to the jurisdiction of -the courts located in the jurisdiction and venue specified in a -notice contained within the Original Software, with the losing -party responsible for costs, including, without limitation, court -costs and reasonable attorneys' fees and expenses. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. Any law or -regulation which provides that the language of a contract shall -be construed against the drafter shall not apply to this License. -You agree that You alone are responsible for compliance with the -United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is -responsible for claims and damages arising, directly or -indirectly, out of its utilization of rights under this License -and You agree to work with Initial Developer and Contributors to -distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission -of liability. diff --git a/harness/libs.nbi.engine/manifest.mf b/harness/libs.nbi.engine/manifest.mf deleted file mode 100644 index 0b6b0283c15e..000000000000 --- a/harness/libs.nbi.engine/manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: false -OpenIDE-Module: org.netbeans.libs.nbi.engine -OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/nbi/engine/Bundle.properties -OpenIDE-Module-Specification-Version: 1.49 - diff --git a/harness/libs.nbi.engine/nbproject/project.properties b/harness/libs.nbi.engine/nbproject/project.properties deleted file mode 100644 index 4c45742d5702..000000000000 --- a/harness/libs.nbi.engine/nbproject/project.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -is.autoload=true -javac.source=1.8 -javac.compilerargs=-Xlint -Xlint:-serial -extra.module.files=modules/ext/nbi-engine.jar -nbm.module.author=Dmitry Lipin diff --git a/harness/libs.nbi.engine/nbproject/project.xml b/harness/libs.nbi.engine/nbproject/project.xml deleted file mode 100644 index 481c2ad270e5..000000000000 --- a/harness/libs.nbi.engine/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - org.netbeans.modules.apisupport.project - - - org.netbeans.libs.nbi.engine - - - - - diff --git a/harness/libs.nbi.engine/src/org/netbeans/libs/nbi/engine/Bundle.properties b/harness/libs.nbi.engine/src/org/netbeans/libs/nbi/engine/Bundle.properties deleted file mode 100644 index 68caab183c23..000000000000 --- a/harness/libs.nbi.engine/src/org/netbeans/libs/nbi/engine/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -OpenIDE-Module-Display-Category=Infrastructure -OpenIDE-Module-Name=NBI Engine Library diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties index a09de03bb69e..954116eeca75 100644 --- a/nbbuild/cluster.properties +++ b/nbbuild/cluster.properties @@ -720,8 +720,6 @@ nb.cluster.apisupport.depends=\ nb.cluster.harness nb.cluster.apisupport=\ apisupport.ant,\ - apisupport.installer,\ - apisupport.installer.maven,\ apisupport.kit,\ apisupport.project,\ apisupport.refactoring,\ @@ -897,8 +895,6 @@ nb.cluster.harness=\ apisupport.harness,\ jellytools.platform,\ jemmy,\ - libs.nbi.ant,\ - libs.nbi.engine,\ nbjunit,\ o.n.insane diff --git a/nbi/engine/build.properties b/nbi/engine/build.properties deleted file mode 100644 index 6b57b2f5d548..000000000000 --- a/nbi/engine/build.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -ignore.native=false -native.dirname=native -jar.contents.list=data/engine.list -jar.contents.includes=native/** org/** com/apple/** data/clioptions.list data/engine*.properties diff --git a/nbi/engine/build.xml b/nbi/engine/build.xml deleted file mode 100644 index 808464172880..000000000000 --- a/nbi/engine/build.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${engine.files} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/external/applemenu-external-desktop-classes-8.2-license.txt b/nbi/engine/external/applemenu-external-desktop-classes-8.2-license.txt deleted file mode 100644 index f7a0f76927c7..000000000000 --- a/nbi/engine/external/applemenu-external-desktop-classes-8.2-license.txt +++ /dev/null @@ -1,389 +0,0 @@ -Name: External Desktop Classes -Description: Provides java.awt.desktop classes to support compilation on JDK 8. -Version: 8.2 -License: CDDL-1.0 -Source: file://applemenu-external-desktop-classes-8.2.zip -Origin: NetBeans -Type: compile-time -Comment: Allows to build code leveraging JDK 9's java.awt.desktop classes on JDK 8. - -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - -1.1. "Contributor" means each individual or entity that -creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the -Original Software, prior Modifications used by a -Contributor (if any), and the Modifications made by that -particular Contributor. - -1.3. "Covered Software" means (a) the Original Software, or -(b) Modifications, or (c) the combination of files -containing Original Software with files containing -Modifications, in each case including portions thereof. - -1.4. "Executable" means the Covered Software in any form -other than Source Code. - -1.5. "Initial Developer" means the individual or entity -that first makes Original Software available under this -License. - -1.6. "Larger Work" means a work which combines Covered -Software or portions thereof with code not governed by the -terms of this License. - -1.7. "License" means this document. - -1.8. "Licensable" means having the right to grant, to the -maximum extent possible, whether at the time of the initial -grant or subsequently acquired, any and all of the rights -conveyed herein. - -1.9. "Modifications" means the Source Code and Executable -form of any of the following: - -A. Any file that results from an addition to, -deletion from or modification of the contents of a -file containing Original Software or previous -Modifications; - -B. Any new file that contains any part of the -Original Software or previous Modification; or - -C. Any new file that is contributed or otherwise made -available under the terms of this License. - -1.10. "Original Software" means the Source Code and -Executable form of computer software code that is -originally released under this License. - -1.11. "Patent Claims" means any patent claim(s), now owned -or hereafter acquired, including without limitation, -method, process, and apparatus claims, in any patent -Licensable by grantor. - -1.12. "Source Code" means (a) the common form of computer -software code in which modifications are made and (b) -associated documentation included in or with such code. - -1.13. "You" (or "Your") means an individual or a legal -entity exercising rights under, and complying with all of -the terms of, this License. For legal entities, "You" -includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this -definition, "control" means (a) the power, direct or -indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership -of more than fifty percent (50%) of the outstanding shares -or beneficial ownership of such entity. - -2. License Grants. - -2.1. The Initial Developer Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, the -Initial Developer hereby grants You a world-wide, -royalty-free, non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Initial Developer, -to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or -portions thereof), with or without Modifications, -and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using or selling of Original Software, to make, have -made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or -portions thereof). - -(c) The licenses granted in Sections 2.1(a) and (b) -are effective on the date Initial Developer first -distributes or otherwise makes the Original Software -available to a third party under the terms of this -License. - -(d) Notwithstanding Section 2.1(b) above, no patent -license is granted: (1) for code that You delete from -the Original Software, or (2) for infringements -caused by: (i) the modification of the Original -Software, or (ii) the combination of the Original -Software with other software or devices. - -2.2. Contributor Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, each -Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Contributor to -use, reproduce, modify, display, perform, sublicense -and distribute the Modifications created by such -Contributor (or portions thereof), either on an -unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using, or selling of Modifications made by that -Contributor either alone and/or in combination with -its Contributor Version (or portions of such -combination), to make, use, sell, offer for sale, -have made, and/or otherwise dispose of: (1) -Modifications made by that Contributor (or portions -thereof); and (2) the combination of Modifications -made by that Contributor with its Contributor Version -(or portions of such combination). - -(c) The licenses granted in Sections 2.2(a) and -2.2(b) are effective on the date Contributor first -distributes or otherwise makes the Modifications -available to a third party. - -(d) Notwithstanding Section 2.2(b) above, no patent -license is granted: (1) for any code that Contributor -has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party -modifications of Contributor Version, or (ii) the -combination of Modifications made by that Contributor -with other software (except as part of the -Contributor Version) or other devices; or (3) under -Patent Claims infringed by Covered Software in the -absence of Modifications made by that Contributor. - -3. Distribution Obligations. - -3.1. Availability of Source Code. - -Any Covered Software that You distribute or otherwise make -available in Executable form must also be made available in -Source Code form and that Source Code form must be -distributed only under the terms of this License. You must -include a copy of this License with every copy of the -Source Code form of the Covered Software You distribute or -otherwise make available. You must inform recipients of any -such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a -reasonable manner on or through a medium customarily used -for software exchange. - -3.2. Modifications. - -The Modifications that You create or to which You -contribute are governed by the terms of this License. You -represent that You believe Your Modifications are Your -original creation(s) and/or You have sufficient rights to -grant the rights conveyed by this License. - -3.3. Required Notices. - -You must include a notice in each of Your Modifications -that identifies You as the Contributor of the Modification. -You may not remove or alter any copyright, patent or -trademark notices contained within the Covered Software, or -any notices of licensing or any descriptive text giving -attribution to any Contributor or the Initial Developer. - -3.4. Application of Additional Terms. - -You may not offer or impose any terms on any Covered -Software in Source Code form that alters or restricts the -applicable version of this License or the recipients' -rights hereunder. You may choose to offer, and to charge a -fee for, warranty, support, indemnity or liability -obligations to one or more recipients of Covered Software. -However, you may do so only on Your own behalf, and not on -behalf of the Initial Developer or any Contributor. You -must make it absolutely clear that any such warranty, -support, indemnity or liability obligation is offered by -You alone, and You hereby agree to indemnify the Initial -Developer and every Contributor for any liability incurred -by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.5. Distribution of Executable Versions. - -You may distribute the Executable form of the Covered -Software under the terms of this License or under the terms -of a license of Your choice, which may contain terms -different from this License, provided that You are in -compliance with the terms of this License and that the -license for the Executable form does not attempt to limit -or alter the recipient's rights in the Source Code form -from the rights set forth in this License. If You -distribute the Covered Software in Executable form under a -different license, You must make it absolutely clear that -any terms which differ from this License are offered by You -alone, not by the Initial Developer or Contributor. You -hereby agree to indemnify the Initial Developer and every -Contributor for any liability incurred by the Initial -Developer or such Contributor as a result of any such terms -You offer. - -3.6. Larger Works. - -You may create a Larger Work by combining Covered Software -with other code not governed by the terms of this License -and distribute the Larger Work as a single product. In such -a case, You must make sure the requirements of this License -are fulfilled for the Covered Software. - -4. Versions of the License. - -4.1. New Versions. - -Sun Microsystems, Inc. is the initial license steward and -may publish revised and/or new versions of this License -from time to time. Each version will be given a -distinguishing version number. Except as provided in -Section 4.3, no one other than the license steward has the -right to modify this License. - -4.2. Effect of New Versions. - -You may always continue to use, distribute or otherwise -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. If the Initial Developer includes a -notice in the Original Software prohibiting it from being -distributed or otherwise made available under any -subsequent version of the License, You must distribute and -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. Otherwise, You may also choose to -use, distribute or otherwise make the Covered Software -available under the terms of any subsequent version of the -License published by the license steward. - -4.3. Modified Versions. - -When You are an Initial Developer and You want to create a -new license for Your Original Software, You may create and -use a modified version of this License if You: (a) rename -the license and remove any references to the name of the -license steward (except to note that the license differs -from this License); and (b) otherwise make it clear that -the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" -BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED -SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR -PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY -COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE -INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF -ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF -WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF -ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS -DISCLAIMER. - -6. TERMINATION. - -6.1. This License and the rights granted hereunder will -terminate automatically if You fail to comply with terms -herein and fail to cure such breach within 30 days of -becoming aware of the breach. Provisions which, by their -nature, must remain in effect beyond the termination of -this License shall survive. - -6.2. If You assert a patent infringement claim (excluding -declaratory judgment actions) against Initial Developer or -a Contributor (the Initial Developer or Contributor against -whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the -Contributor Version where the Participant is a Contributor -or the Original Software where the Participant is the -Initial Developer) directly or indirectly infringes any -patent, then any and all rights granted directly or -indirectly to You by such Participant, the Initial -Developer (if the Initial Developer is not the Participant) -and all Contributors under Sections 2.1 and/or 2.2 of this -License shall, upon 60 days notice from Participant -terminate prospectively and automatically at the expiration -of such 60 day notice period, unless if within such 60 day -period You withdraw Your claim with respect to the -Participant Software against such Participant either -unilaterally or pursuant to a written agreement with -Participant. - -6.3. In the event of termination under Sections 6.1 or 6.2 -above, all end user licenses that have been validly granted -by You or any distributor hereunder prior to termination -(excluding licenses granted to You by any distributor) -shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT -(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF -COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE -LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN -INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF -LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT -APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO -NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT -APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a "commercial item," as that term is -defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial -computer software" (as that term is defined at 48 C.F.R. -252.227-7014(a)(1)) and "commercial computer software -documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 -through 227.7202-4 (June 1995), all U.S. Government End Users -acquire Covered Software with only those rights set forth herein. -This U.S. Government Rights clause is in lieu of, and supersedes, -any other FAR, DFAR, or other clause or provision that addresses -Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the -extent necessary to make it enforceable. This License shall be -governed by the law of the jurisdiction specified in a notice -contained within the Original Software (except to the extent -applicable law, if any, provides otherwise), excluding such -jurisdiction's conflict-of-law provisions. Any litigation -relating to this License shall be subject to the jurisdiction of -the courts located in the jurisdiction and venue specified in a -notice contained within the Original Software, with the losing -party responsible for costs, including, without limitation, court -costs and reasonable attorneys' fees and expenses. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. Any law or -regulation which provides that the language of a contract shall -be construed against the drafter shall not apply to this License. -You agree that You alone are responsible for compliance with the -United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is -responsible for claims and damages arising, directly or -indirectly, out of its utilization of rights under this License -and You agree to work with Initial Developer and Contributors to -distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission -of liability. diff --git a/nbi/engine/external/binaries-list b/nbi/engine/external/binaries-list deleted file mode 100644 index b647ba5d6883..000000000000 --- a/nbi/engine/external/binaries-list +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -1D14F4B56AD34841339698565B17BBAE755B0E61 applemenu-external-desktop-classes-8.2.zip diff --git a/nbi/engine/lib/readme.txt b/nbi/engine/lib/readme.txt deleted file mode 100644 index 1226c7dbb4ca..000000000000 --- a/nbi/engine/lib/readme.txt +++ /dev/null @@ -1,2 +0,0 @@ -here I put some libs for implementing testserver. -Currently TestServer Jetty-based so that's why here such jars. \ No newline at end of file diff --git a/nbi/engine/manifest.mf b/nbi/engine/manifest.mf deleted file mode 100644 index 464ca3d3fe50..000000000000 --- a/nbi/engine/manifest.mf +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: org.netbeans.installer.Installer diff --git a/nbi/engine/native/build.properties b/nbi/engine/native/build.properties deleted file mode 100644 index 5959d932626a..000000000000 --- a/nbi/engine/native/build.properties +++ /dev/null @@ -1,68 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -#ignore.native= - -native.dist.dir=dist - -native.jnilib.dir=jnilib -native.launcher.dir=launcher -native.cleaner.dir=cleaner - -# Native Library properties -native.jnilib.dir.windows=${native.jnilib.dir}/windows -native.jnilib.dir.linux=${native.jnilib.dir}/linux -native.jnilib.dir.solaris-x86=${native.jnilib.dir}/solaris-x86 -native.jnilib.dir.solaris-sparc=${native.jnilib.dir}/solaris-sparc -native.jnilib.dir.macosx=${native.jnilib.dir}/macosx - -native.jnilib.file.windows.i386=windows-x86.dll -native.jnilib.file.windows.amd64=windows-x64.dll -native.jnilib.file.windows.ia64=windows-ia64.dll -native.jnilib.file.linux.i386=linux.so -native.jnilib.file.linux.amd64=linux-amd64.so -native.jnilib.file.solaris-x86=solaris-x86.so -native.jnilib.file.solaris-sparc=solaris-sparc.so -native.jnilib.file.solaris-amd64=solaris-amd64.so -native.jnilib.file.solaris-sparcv9=solaris-sparcv9.so -native.jnilib.file.macosx=macosx.dylib - - -# Native Launcher Properties -native.launcher.windows.dir=${native.launcher.dir}/windows -native.launcher.windows.stub.file=nlw.exe -native.launcher.windows.stub.src=${native.launcher.windows.dir}/dist/${native.launcher.windows.stub.file} -native.launcher.windows.stub.dst.dir=${native.launcher.windows.dir} -native.launcher.windows.i18n.dir=${native.launcher.windows.dir}/i18n - -native.launcher.unix.dir=${native.launcher.dir}/unix -native.launcher.unix.stub.file=launcher.sh -native.launcher.unix.stub.src=${native.launcher.unix.dir}/src/${native.launcher.unix.stub.file} -native.launcher.unix.stub.dst.dir=${native.launcher.unix.dir} -native.launcher.unix.i18n.dir=${native.launcher.unix.dir}/i18n - - -# Native on-exit cleaner properties -native.cleaner.windows.dir=${native.cleaner.dir}/windows -native.cleaner.windows.srcdir=${native.cleaner.windows.dir}/dist -native.cleaner.windows.file=cleaner.exe - -native.cleaner.unix.dir=${native.cleaner.dir}/unix -native.cleaner.unix.srcdir=${native.cleaner.unix.dir}/src -native.cleaner.unix.file=cleaner.sh diff --git a/nbi/engine/native/build.xml b/nbi/engine/native/build.xml deleted file mode 100644 index 58c97a60ee6c..000000000000 --- a/nbi/engine/native/build.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/native/cleaner/unix/src/cleaner.sh b/nbi/engine/native/cleaner/unix/src/cleaner.sh deleted file mode 100644 index cfae216ebe20..000000000000 --- a/nbi/engine/native/cleaner/unix/src/cleaner.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -deleteFiles() { - testSymlinkErr=`test -L / > /dev/null` - if [ -z "$testSymlinkErr" ] ; then - isSymlink=-L - else - isSymlink=-h - fi - - #wait for main thread to finish... - sleep 3 - waitOnError=1 - tryTimes=3 - list="$1" - if [ -n "$list" ] && [ -f "$list" ] ; then - #echo "Using list file : $list" - itemsNumber=`wc -l $list | sed "s/^\ *//;s/\ .*//" 2>/dev/null` - #echo "Total items : $itemsNumber" - counter=1 - try=$tryTimes - allitems=`cat "$list" 2>/dev/null` - if [ -f "$list" ] ; then - #echo "... remove cleaner list $list" - rm -f "$list" - fi - while [ $counter -le $itemsNumber ] ; do - file=`echo "$allitems" | sed -n "${counter}p" 2>/dev/null` - #echo "entry : $file" - result=1 - if [ -n "$file" ] ; then - #echo "... file not zero" - if [ $isSymlink "$file" ] || [ -f "$file" ] ; then - # file or symlink - #echo "deleting [F] $file" - rm -f "$file" 2>/dev/null 1>&2 - if [ $? -ne 0 ] ; then - #echo "... can't delete $file" - result=0 - fi - elif [ -d "$file" ] ; then - # directory - #echo "deleting [D] $file" - rmdir "$file" 2>/dev/null 1>&2 - if [ $? -ne 0 ] ; then - result=0 - #echo "... can't delete $file" - fi - fi - fi - if [ 0 -eq $result ] ; then - # try to remove it again after a short wait - if [ $try -gt 0 ] ; then - try=`expr "$try" - 1` - sleep $waitOnError - else - #can`t delete.. skip it - result=1 - fi - - fi - if [ 1 -eq $result ] ; then - counter=`expr "$counter" + 1` - try=$tryTimes - fi - done - fi - if [ -f "$0" ] ; then - #echo "... remove cleaner itself $0" - rm -f "$0" - fi -} - -deleteFiles "$@" diff --git a/nbi/engine/native/cleaner/windows/Makefile b/nbi/engine/native/cleaner/windows/Makefile deleted file mode 100644 index 98cf53c0c227..000000000000 --- a/nbi/engine/native/cleaner/windows/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/cleaner/windows/Makefile-vc b/nbi/engine/native/cleaner/windows/Makefile-vc deleted file mode 100644 index b9edda92cf0e..000000000000 --- a/nbi/engine/native/cleaner/windows/Makefile-vc +++ /dev/null @@ -1,59 +0,0 @@ -# -# - - -!include <$(PLATFORM_SDK)/include/win32.mak> - -# define the compiler and linker for all the platforms -CC32="$(VC_2005)\Bin\cl.exe" -L32="$(VC_2005)\Bin\link.exe" - -BUILD_DIR32=.\build\32bit -OUTPUT_FILE32=.\dist\cleaner.exe - -CC32_OPTS=/O1 /Os \ - /I "$(VC_2005)\include" \ - /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" \ - /FD /GS-\ - /Fo"$(BUILD_DIR32)\\" /Fd"$(BUILD_DIR32)\vc80.pdb" \ - /W3 /nologo /c /Wp64 /TC /errorReport:prompt - -LINKING_LIBRARIES=\ - shell32.lib \ - kernel32.lib - -L32_OPTS=\ - /OUT:$(OUTPUT_FILE32) \ - /INCREMENTAL:NO \ - /LIBPATH:"$(PLATFORM_SDK)\Lib" \ - /MANIFEST:NO \ - /NODEFAULTLIB \ - /SUBSYSTEM:WINDOWS \ - /OPT:REF /OPT:ICF \ - /MACHINE:X86 \ - /ERRORREPORT:PROMPT \ - /ENTRY:WinMain \ - $(LINKING_LIBRARIES) - -all: init build-32 - -clean: - - -init: - - md $(BUILD_DIR32) - - md .\dist - - del /Q /S $(BUILD_DIR32) - del /Q $(OUTPUT_FILE32) - -build-32: - Set CPU=i386 - Set Lib=%VC_2005%\Lib;%PLATFORM_SDK%\Lib;%Lib% - Set Include=%PLATFORM_SDK%\Include;%Include% - Set Path=%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%VC_2005_PATH%;%path% - Set APPVER=5.01 - Set TARGETOS=WINNT - - $(CC32) $(CC32_OPTS) .\src\main.c - $(L32) $(L32_OPTS) $(BUILD_DIR32)\main.obj diff --git a/nbi/engine/native/cleaner/windows/nbproject/configurations.xml b/nbi/engine/native/cleaner/windows/nbproject/configurations.xml deleted file mode 100644 index b16b62813592..000000000000 --- a/nbi/engine/native/cleaner/windows/nbproject/configurations.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - src/main.c - - - - - - - Makefile - - - Makefile - 0 - - - - Cygwin - true - true - false - 3 - - - - dist/cleaner - true - - -lshell32 -lkernel32 - - -mno-cygwin -mwindows - - - - 0 - - - - - Cygwin - true - true - false - 3 - - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - - - - diff --git a/nbi/engine/native/cleaner/windows/nbproject/project.properties b/nbi/engine/native/cleaner/windows/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/cleaner/windows/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/cleaner/windows/nbproject/project.xml b/nbi/engine/native/cleaner/windows/nbproject/project.xml deleted file mode 100644 index ded3e3c3ca38..000000000000 --- a/nbi/engine/native/cleaner/windows/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Cleaner : Windows - 0 - - - diff --git a/nbi/engine/native/cleaner/windows/src/main.c b/nbi/engine/native/cleaner/windows/src/main.c deleted file mode 100644 index 43271ffcd8c1..000000000000 --- a/nbi/engine/native/cleaner/windows/src/main.c +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include - - -/* - * cleaner.exe - * - * Deletes a list of files/folders. - * - * The command line syntax is: - * - * arg1: File name containing a list of files/folders to delete. - * - * Requirements for arg1: - * - The arg1 file name MUST be fully qualified. (or be in the same directory - * as the cleaner.exe executable) - * - The file MUST use Windows line ending (CRLF) - * - The file MUST be encoded in UTF-16. The NBI Engine will produce - * this file in Java charset "UNICODE" which effectively means - * UCS-2 BigEndian BOM. Such file will work just fine. - * - Each line in the file is expected to contain a fully qualified file - * or folder name. The entry can be - * - a local file/folder name, e.g. "C:\foo\bar", up to a maximum of 32767 - * chars and thus not subject to the original Windows limitation - * of 260 chars for a path name. - * - a UNC, e.g. "\\servername\sharename\foo\bar", subject to a - * restriction of 260 chars. - * - The list MUST be ordered so that the files in a folder are listed before - * the folder itself. (it is not possible to delete a non-empty folder) - * - * Method of working: - * - * 1. After launch the content of command line arg1 is read into memory - * as one big string. - * 2. The string is chopped into a list by separating at the LINE_SEPARATOR. - * 3. Sleep for 2 seconds to allow the launching process (the JVM) to exit. - * 4. Loop over the list of files/folder to delete. Each file-delete operation - * is spawned into a thread of its own up to a maximum of 64 threads. - * Therefore the delete operations happens in parallel rather than in sequence. - * If 64 threads have been spawned then wait for a thread to exit before - * spawning a new one. (therefore never more than 64 threads) - * For each file delete operation do the following: - * - Check to see if the file exists (by getting its attributes) - * - If file: delete file, if directory: delete directory (these are two - * different calls in the Win32 API). - * - Attempt to delete each file/dir up to 15 times sleeping for 200 ms - * between each attempt. - * 5. Wait for all file-delete threads to exit. - * 6. Delete self, i.e. the "cleaner.exe" executable. - * 7. End - * - * The arg1 file is not deleted. However it can be part of the list itself - * if need be. - * - * Author: Dmitry Lipin, 2007 - * - * - * - * Changes after transition to Apache: - * - * 14-SEP-2019 Lars Bruun-Hansen (lbruun@apache.org) : - * Function comment headers added. - * Main comment header added. - * - */ - - -// Retry functionality: -// SLEEP_DELAY : millis between each attempt at a file delete -// MAX_ATTEMPTS : how many times to attempt to delete a file -const DWORD SLEEP_DELAY = 200; -const DWORD MAX_ATTEMPTS = 15; -const DWORD THREAD_FINISHED = 100; - -// Number of milliseconds to sleep at launch of the application. -const DWORD INITIAL_DELAY = 2000; // 2 seconds seems to be enough to finish java process - -const WCHAR * LINE_SEPARATOR = L"\r\n"; -const WCHAR * UNC_PREFIX = L"\\\\?\\"; // Prefix for extended-length path in Win32 API -const WCHAR * UNC_STD_PREFIX = L"\\\\"; // Prefix for UNC paths, for example: \\servername\share\foo\bar -const DWORD UNC_PREFIX_LENGTH = 4; - -#ifdef _MSC_VER -#define ZERO(x,y) SecureZeroMemory((x),(y)); -#else -#define ZERO(x,y) ZeroMemory((x),(y)); -#endif - - -/* - * Search for the first occurrence of wcs2 within wcs1. - * Returns a pointer to the first occurrence if found. - * If not found, NULL is returned. - */ -WCHAR * search( const WCHAR * wcs1, const WCHAR * wcs2) { - WCHAR *cp = (WCHAR *) wcs1; - WCHAR *s1, *s2; - - if ( !*wcs2) { - return (WCHAR *)wcs1; - } - - while (*cp) { - s1 = cp; - s2 = (WCHAR *) wcs2; - - while ( *s1 && *s2 && !(*s1-*s2) ) { - s1++, s2++; - } - if (!*s2) { - return(cp); - } - cp++; - } - return(NULL); -} - - -typedef struct _list { - WCHAR * item; - struct _list * next; -} LIST; - - -WCHAR * toWCHAR(char * charBuffer, DWORD size) { - DWORD i=0; - WCHAR * buffer; - BOOL hasBOM = (*charBuffer == '\xFF' && *(charBuffer+1) == '\xFE'); - BOOL hasReverseBOM = (*charBuffer == '\xFE' && *(charBuffer+1) == '\xFF'); - - char * realStringPtr = charBuffer; - if (hasBOM || hasReverseBOM) { - size-= 2; - realStringPtr+= 2; - if(hasReverseBOM) { - char c; - for (i = 0 ; i < size/2 ; i++) { - c = charBuffer [2 * i] ; - charBuffer [2 * i] = charBuffer [2 * i + 1] ; - charBuffer [2 * i + 1] = c; - } - } - } - - buffer = (WCHAR*) LocalAlloc(LPTR, sizeof(WCHAR) * (size/2+1)); - ZERO(buffer, sizeof(WCHAR) * (size/2+1)); - for(i=0;i 0) { - result ++; - } - } - return result; -} - -/* - * Produces a string array, 'list', from 'str' by splitting the string - * at each occurrence of LINE_SEPARATOR. - * - * [IN] str: the input - * [OUT] list: string array - * [OUT] number: number of elements in 'list' - * - */ -void getLines(WCHAR *str, WCHAR *** list, DWORD * number) { - WCHAR *ptr = str; - WCHAR *ptr2 = NULL; - DWORD length = 0; - DWORD sepLength = lstrlenW(LINE_SEPARATOR); - DWORD counter = 0; - *number = getLinesNumber(str); - *list = (WCHAR**) LocalAlloc(LPTR, sizeof(WCHAR*) * (*number)); - - if(ptr!=NULL) { - while(counter < (*number)) { - DWORD i = 0 ; - if((ptr2 = search(ptr, LINE_SEPARATOR))!=NULL) { - ptr2 = search(ptr, LINE_SEPARATOR) + sepLength; - length = lstrlenW(ptr) - lstrlenW(ptr2) - sepLength; - (*list) [counter ] = (WCHAR*) LocalAlloc(LPTR, sizeof(WCHAR*)*(length+1)); - ZERO((*list) [counter ], sizeof(WCHAR*)*(length+1)); - for(i=0;i 0) { - (*list)[counter ] = (WCHAR*) LocalAlloc(LPTR, sizeof(WCHAR*)*(length+1)); - ZERO((*list) [counter ], sizeof(WCHAR*)*(length+1)); - for(i=0;i=2) { - WCHAR * buffer = toWCHAR(charBuffer, size + 2); - getLines(buffer, list, number); - LocalFree(buffer); - } - LocalFree(charBuffer); -} - -void deleteFile(WCHAR * filePath) { - BOOL canDelete = TRUE; - DWORD count = 0 ; - WIN32_FILE_ATTRIBUTE_DATA attrs; - DWORD filePathLength = lstrlenW(filePath); - DWORD prefixLength = (filePath == search(filePath, UNC_STD_PREFIX)) ? 0 : UNC_PREFIX_LENGTH; - DWORD length = filePathLength + prefixLength + 1; - WCHAR * file = (WCHAR*) LocalAlloc(LPTR, sizeof(WCHAR) * length); - DWORD i=0; - for(i=0;i0) { - getFreeIndexForNextThread(runningThreads, MAXIMUM_THREADS, &threadCounter); - runningThreads [threadCounter] = CreateThread( NULL, 0, &deleteFileThread, (LPVOID) file, 0, &dwThread ); - threadCounter++; - if(threadCounter==MAXIMUM_THREADS) allThreadsUsed = 1; - } - } - } - - WaitForMultipleObjects(allThreadsUsed ? MAXIMUM_THREADS : threadCounter, - runningThreads, TRUE, INFINITE); - - for(i=0;i - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/native/cleaner/windows/vcproject/NBI Native Cleaner.vcproj.user b/nbi/engine/native/cleaner/windows/vcproject/NBI Native Cleaner.vcproj.user deleted file mode 100644 index a5ca4f998dec..000000000000 --- a/nbi/engine/native/cleaner/windows/vcproject/NBI Native Cleaner.vcproj.user +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/nbi/engine/native/jnilib/.common/src/CommonUtils.c b/nbi/engine/native/jnilib/.common/src/CommonUtils.c deleted file mode 100644 index b66eccd085c5..000000000000 --- a/nbi/engine/native/jnilib/.common/src/CommonUtils.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include - - -#include "CommonUtils.h" - -jbyteArray getStringBytes(JNIEnv* jEnv, jstring jString) { - jbyteArray result = NULL; - - if (jString != NULL) { - jmethodID jGetBytesMethod = (*jEnv)->GetMethodID(jEnv, (*jEnv)->GetObjectClass(jEnv, jString), "getBytes", "()[B"); - - if (jGetBytesMethod != NULL) { - jbyteArray jBuffer = (jbyteArray) (*jEnv)->CallObjectMethod(jEnv, jString, jGetBytesMethod); - - if (jBuffer != NULL) { - jsize jLength = (*jEnv)->GetArrayLength(jEnv, jBuffer); - - result = (*jEnv)->NewByteArray(jEnv, jLength + 1); - if (jLength != 0) { - jbyte* jChars = (*jEnv)->GetByteArrayElements(jEnv, jBuffer, NULL); - (*jEnv)->SetByteArrayRegion(jEnv, result, 0, jLength, jChars); - (*jEnv)->ReleaseByteArrayElements(jEnv, jBuffer, jChars, JNI_ABORT); - } - (*jEnv)->DeleteLocalRef(jEnv, jBuffer); - } - //(*jEnv)->DeleteLocalRef(jEnv, getBytesMethod); - } - } - - return result; -} - - -jstring newStringFromJByteArray(JNIEnv* jEnv, jbyteArray jByteArray, int length) { - jstring result = NULL; - - jclass jStringClass = (*jEnv)->FindClass(jEnv, "java/lang/String"); - if (jStringClass != NULL) { - jmethodID jStringConstructor = (*jEnv)->GetMethodID(jEnv, jStringClass, "", "([BII)V"); - - if (jStringConstructor != NULL) { - result = (jstring) (*jEnv)->NewObject(jEnv, jStringClass, jStringConstructor, jByteArray, 0, length); - //(*jEnv)->DeleteLocalRef(jEnv, stringConstructor); - } - (*jEnv)->DeleteLocalRef(jEnv, jStringClass); - } - - return result; -} - - -jstring newStringFromJCharArray(JNIEnv* jEnv, jcharArray jCharArray, int length) { - jstring result = NULL; - - jclass jStringClass = (*jEnv)->FindClass(jEnv, "java/lang/String"); - if (jStringClass != NULL) { - jmethodID jStringConstructor = (*jEnv)->GetMethodID(jEnv, jStringClass, "", "([CII)V"); - - if (jStringConstructor != NULL) { - result = (jstring) (*jEnv)->NewObject(jEnv, jStringClass, jStringConstructor, jCharArray, 0, length); - } - (*jEnv)->DeleteLocalRef(jEnv, jStringClass); - } - - return result; -} - -jstring getString(JNIEnv* jEnv, const char* chars) { - return (jstring) getStringWithLength(jEnv, chars, (int) STRLEN(chars)); -} - -jstring getStringW(JNIEnv* jEnv, const wchar_t * chars) { - return (jstring) getStringWithLengthW(jEnv, chars, (int) WCSLEN(chars)); -} - -jstring getStringWithLength(JNIEnv* jEnv, const char* chars, int length) { - jstring result = NULL; - - if (chars != NULL) { - if (length == 0) { - result = (*jEnv)->NewString(jEnv, (const jchar *) L"", 0); - } else { - jbyteArray jByteArray = (*jEnv)->NewByteArray(jEnv, length); - - if (jByteArray != NULL) { - (*jEnv)->SetByteArrayRegion(jEnv, jByteArray, 0, length, (jbyte*) chars); - result = newStringFromJByteArray(jEnv, jByteArray, length); - (*jEnv)->DeleteLocalRef(jEnv, jByteArray); - } - } - } - - return result; -} - - -jstring getStringWithLengthW(JNIEnv* jEnv, const wchar_t* chars, int length) { - jstring result = NULL; - - if (chars != NULL) { - if (length == 0) { - result = (*jEnv)->NewString(jEnv, (const jchar *) L"", 0); - } else { - jcharArray jCharArray = (*jEnv)->NewCharArray(jEnv, length); - - if (jCharArray != NULL) { - (*jEnv)->SetCharArrayRegion(jEnv, jCharArray, 0, length, (jchar*) chars); - result = newStringFromJCharArray(jEnv, jCharArray, length); - (*jEnv)->DeleteLocalRef(jEnv, jCharArray); - } - } - } - - return result; -} - - -char* getChars(JNIEnv* jEnv, jstring jString) { - char* result = NULL; - - jbyteArray jByteArray = getStringBytes(jEnv, jString); - if (jByteArray != NULL) { - jbyte* jBytes = (*jEnv)->GetByteArrayElements(jEnv, jByteArray, NULL); - - long index = 0; - if (jBytes != NULL) { - int length = (int) STRLEN((char*) jBytes); - - result = (char*) MALLOC(sizeof(char) * (length + 1)); - if (result != NULL) { - ZERO(result, length); - STRNCPY(result, (char*) jBytes, length); - result[length] = 0; - } - (*jEnv)->ReleaseByteArrayElements(jEnv, jByteArray, jBytes, JNI_ABORT); - } - (*jEnv)->DeleteLocalRef(jEnv, jByteArray); - } - - return result; -} - -char* getStringFromMethod(JNIEnv* jEnv, jobject object, const char* methodName) { - char* result = NULL; - - jclass clazz = (*jEnv)->GetObjectClass(jEnv, object); - if (clazz != NULL) { - jmethodID method = (*jEnv)->GetMethodID(jEnv, clazz, methodName, "()Ljava/lang/String;"); - if (method != NULL) { - jstring string = (jstring) (*jEnv)->CallObjectMethod(jEnv, object, method); - if (string != NULL) { - result = getChars(jEnv, string); - (*jEnv)->DeleteLocalRef(jEnv, string); - } - //(*jEnv)->DeleteLocalRef(jEnv, method); - } - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } - - return result; -} - -wchar_t * getWideStringFromMethod(JNIEnv* jEnv, jobject object, const char* methodName) { - wchar_t* result = NULL; - - jclass clazz = (*jEnv)->GetObjectClass(jEnv, object); - if (clazz != NULL) { - jmethodID method = (*jEnv)->GetMethodID(jEnv, clazz, methodName, "()Ljava/lang/String;"); - if (method != NULL) { - jstring string = (jstring) (*jEnv)->CallObjectMethod(jEnv, object, method); - if (string != NULL) { - result = getWideChars(jEnv, string); - (*jEnv)->DeleteLocalRef(jEnv, string); - } - //(*jEnv)->DeleteLocalRef(jEnv, method); - } - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } - - return result; -} - -jboolean isInstanceOf(JNIEnv* jEnv, jobject object, const char* className) { - jboolean result = 0; - jclass clazz = clazz = (*jEnv)->FindClass(jEnv, className); - - if (clazz != NULL) { - result = (*jEnv)->IsInstanceOf(jEnv, object, clazz); - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } - return result; -} - -jint getIntFromMethod(JNIEnv* jEnv, jobject object, const char* methodName) { - jint value = 0; - - jclass clazz = (*jEnv)->GetObjectClass(jEnv, object); - if (clazz != NULL) { - jmethodID method = (*jEnv)->GetMethodID(jEnv, clazz, methodName, "()I"); - if (method != NULL) { - value = (*jEnv)->CallIntMethod(jEnv, object, method); - } - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } - - return value; -} - -void throwException(JNIEnv* jEnv, const char* message) { - jclass clazz = (*jEnv)->FindClass(jEnv, "org/netbeans/installer/utils/exceptions/NativeException"); - if (clazz != NULL) { - (*jEnv)->ThrowNew(jEnv, clazz, message); - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } -} - -void writeLog(JNIEnv* jEnv, int level, const char* message) { - const char* prefix = "[jni] "; - - jclass clazz = (*jEnv)->FindClass(jEnv, "org/netbeans/installer/utils/LogManager"); - if (clazz != NULL) { - jmethodID method = (*jEnv)->GetStaticMethodID(jEnv, clazz, "log", "(ILjava/lang/String;)V"); - if (method != NULL) { - jstring jMessage = NULL; - int prefix_length = STRLEN(prefix); - int message_length = STRLEN(message); - char* string = (char*) MALLOC(sizeof(char) * (prefix_length + message_length + 1)); - int i = 0; - for(i=0;iCallStaticVoidMethod(jEnv, clazz, method, (jint) level, jMessage); - (*jEnv)->DeleteLocalRef(jEnv, jMessage); - } - - FREE(string); - //(*jEnv)->DeleteLocalRef(jEnv, method); - } - (*jEnv)->DeleteLocalRef(jEnv, clazz); - } -} - -int createDirs(JNIEnv* jEnv, jstring jPath) { - int result = 0; - jclass jFileClass = (*jEnv)->FindClass(jEnv, "java/io/File"); - if (jFileClass != NULL) { - jmethodID jFileConstructor = (*jEnv)->GetMethodID(jEnv, jFileClass, "", "(Ljava/lang/String;)V"); - jmethodID jGetParentFileMethod = (*jEnv)->GetMethodID(jEnv, jFileClass, "getParentFile", "()Ljava/io/File;"); - jmethodID jExistsMethod = (*jEnv)->GetMethodID(jEnv, jFileClass, "exists", "()Z"); - jmethodID jMkdirsMethod = (*jEnv)->GetMethodID(jEnv, jFileClass, "mkdirs", "()Z"); - - if ((jFileConstructor != NULL) && (jGetParentFileMethod != NULL) && (jExistsMethod != NULL) && (jMkdirsMethod != NULL)) { - jobject jFile = (*jEnv)->NewObject(jEnv, jFileClass, jFileConstructor, jPath); - if (jFile != NULL ) { - if(!((*jEnv)->CallBooleanMethod(jEnv, jFile, jExistsMethod))) { - jobject jParent = (*jEnv)->CallObjectMethod(jEnv, jFile, jGetParentFileMethod); - if (jParent != NULL) { - result = (*jEnv)->CallBooleanMethod(jEnv, jParent, jExistsMethod); - if (!result) { - result = (*jEnv)->CallBooleanMethod(jEnv, jParent, jMkdirsMethod); - } - (*jEnv)->DeleteLocalRef(jEnv, jParent); - } - } else { - result = 1; - } - (*jEnv)->DeleteLocalRef(jEnv, jFile); - } - } - (*jEnv)->DeleteLocalRef(jEnv, jFileClass); - } - return result; -} - -int mkdirs(JNIEnv* jEnv, const char *path) { - int result = 1; - jstring jPath = getString(jEnv, path); - if (jPath != NULL) { - result = createDirs(jEnv, jPath); - (*jEnv)->DeleteLocalRef(jEnv, jPath); - } - return result; -} - - -int mkdirsW(JNIEnv* jEnv, const wchar_t *path) { - int result = 1; - jstring jPath = getStringW(jEnv, path); - if (jPath != NULL) { - result = createDirs(jEnv, jPath); - (*jEnv)->DeleteLocalRef(jEnv, jPath); - } - - return result; -} - - - -unsigned char* getByteFromMultiString(JNIEnv *jEnv, jobjectArray jObjectArray, unsigned long* size) { - unsigned short * result = NULL; - - int totalLength = 0; - unsigned int arrayLength = (*jEnv)->GetArrayLength(jEnv, jObjectArray); - jstring jString = NULL; - - unsigned int i, j; // just counters - - for (i = 0; i < arrayLength; i++) { - jString = (jstring) (*jEnv)->GetObjectArrayElement(jEnv, jObjectArray, i); - totalLength += (*jEnv)->GetStringLength(jEnv, jString) + 1; - } - totalLength++; // add null to the end of array - - result = (unsigned short*) MALLOC(sizeof(unsigned short) * totalLength); - if (result != NULL) { - int index = 0 ; - - for (i = 0; i < arrayLength; i++) { - jString = (jstring) (*jEnv)->GetObjectArrayElement(jEnv, jObjectArray, i); - - if (jString != NULL) { - wchar_t * chars = getWideChars(jEnv, jString); - if (chars != NULL) { - for (j = 0; j < (WCSLEN(chars)); j++) { - result[index++] = chars[j]; - } - - FREE(chars); - } - } - result[index++] = '\0'; - } - result[index++] = '\0'; //double \0 at the end - } - * size = sizeof(unsigned short) * totalLength; - return (unsigned char*)result; -} - -wchar_t * getWideChars(JNIEnv *jEnv, jstring jString) { - if(jString==NULL) { - return NULL; - } else { - long length = (*jEnv)->GetStringLength( jEnv, jString); - const jchar * unicodeStr = (*jEnv)->GetStringChars( jEnv, jString, 0 ); - wchar_t * copy = (wchar_t *) MALLOC(sizeof(wchar_t) * (length + 1)); - ZERO(copy, sizeof(wchar_t)*(length + 1)); - WCSNCPY(copy, (const wchar_t *) unicodeStr, length + 1); - (*jEnv)->ReleaseStringChars( jEnv, jString, unicodeStr); - return copy; - } - -} diff --git a/nbi/engine/native/jnilib/.common/src/CommonUtils.h b/nbi/engine/native/jnilib/.common/src/CommonUtils.h deleted file mode 100644 index 8824351a5cc6..000000000000 --- a/nbi/engine/native/jnilib/.common/src/CommonUtils.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#ifdef _MSC_VER -#include -#endif - -#ifndef _CommonUtils_H -#define _CommonUtils_H - - -#ifdef _MSC_VER -#define FREE(x) { if((x)!=NULL) { LocalFree(x); (x)=NULL;}} -#else -#define FREE(x) { if((x)!=NULL) { free(x); (x)=NULL;}} -#endif - -#ifdef _MSC_VER -#define MALLOC(x) LocalAlloc(LPTR, x) -#else -#define MALLOC(x) malloc(x) -#endif - - -#ifdef _MSC_VER -#define ZERO(x,y) SecureZeroMemory((x),(y)) -#else -#define ZERO(x,y) memset((x),0,(y)) -#endif - - -#ifdef _MSC_VER -#define STRLEN(x) lstrlenA(x) -#else -#define STRLEN(x) strlen(x) -#endif - - -#ifdef _MSC_VER -#define WCSLEN(x) ((unsigned long)lstrlenW(x)) -#else -#define WCSLEN(x) ((unsigned long)wcslen(x)) -#endif - - -#ifdef _MSC_VER -#define STRNCPY(x,y,z) lstrcpynA((x),(y),(z)) -#else -#define STRNCPY(x,y,z) strncpy((x),(y),(z)) -#endif - -#ifdef _MSC_VER -#define WCSNCPY(x,y,z) lstrcpynW((x),(y),(z)) -#else -#define WCSNCPY(x,y,z) wcsncpy((x),(y),(z)) -#endif - - -#define LOG_DEBUG 4 -#define LOG_MESSAGE 3 -#define LOG_WARNING 2 -#define LOG_ERROR 1 -#define LOG_CRITICAL 0 - -#ifdef __cplusplus -extern "C" { -#endif - -jbyteArray getStringBytes(JNIEnv* jEnv, jstring jString); - -jstring newStringFromJByteArray(JNIEnv* jEnv, jbyteArray jByteArray, int length); -jstring newStringFromJCharArray(JNIEnv* jEnv, jcharArray jCharArray, int length); - -jstring getString (JNIEnv* jEnv, const char* chars); -jstring getStringW(JNIEnv* jEnv, const wchar_t * chars); - - -jstring getStringWithLength(JNIEnv* jEnv, const char* chars, int length); -jstring getStringWithLengthW(JNIEnv* jEnv, const wchar_t * chars, int length); - -char* getChars(JNIEnv* jEnv, jstring jString); -wchar_t * getWideChars(JNIEnv *jEnv, jstring str); - -char* getStringFromMethod(JNIEnv* jEnv, jobject object, const char* methodName); -wchar_t* getWideStringFromMethod(JNIEnv* jEnv, jobject object, const char* methodName) ; - -jint getIntFromMethod(JNIEnv* jEnv, jobject object, const char* methodName); - -jboolean isInstanceOf(JNIEnv* jEnv, jobject object, const char* className); - -void throwException(JNIEnv* jEnv, const char* message); - -void writeLog(JNIEnv* jEnv, int level, const char* message); - -int mkdirs (JNIEnv* jEnv, const char *path); -int mkdirsW(JNIEnv* jEnv, const wchar_t *path); - -unsigned char* getByteFromMultiString(JNIEnv *jEnv, jobjectArray jObjectArray, unsigned long* size); - -#ifdef __cplusplus -} -#endif -#endif /* _CommonUtils_H */ diff --git a/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.c b/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.c deleted file mode 100644 index 437e270bbf60..000000000000 --- a/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../.common/src/CommonUtils.h" -#include "jni_UnixNativeUtils.h" - - -jboolean statMode(const char *path, int *mode) { - struct stat sb; - if (stat(path, &sb) == 0) { - *mode = sb.st_mode; - return 1; - } else { - return 0; - } -} - - -JNIEXPORT jlong JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_getFreeSpace0(JNIEnv* jEnv, jobject jObject, jstring jPath) { - char* path = getChars(jEnv, jPath); - jlong result = 0; - - struct statvfs fsstat; - if(memset(&fsstat, 0, sizeof(struct statvfs)) != NULL) { - if(statvfs(path, &fsstat) == 0) { - result = (jlong) fsstat.f_frsize; - result *= (jlong) fsstat.f_bfree; - } - } - - - FREE(path); - return result; -} - - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_setPermissions0(JNIEnv *jEnv, jobject jObject, jstring jPath, jint jMode, jint jChange) { - char* path = getChars(jEnv, jPath); - int currentMode = 0 ; - char * msg = NULL; - if(statMode(path, ¤tMode)) { - switch (jChange) { - case MODE_CHANGE_SET: - currentMode |= (S_IRWXU | S_IRWXG | S_IRWXO); - currentMode &= jMode; - break; - case MODE_CHANGE_ADD: - currentMode |= jMode; - break; - case MODE_CHANGE_REMOVE: - currentMode &= ~jMode; - break; - default: - msg = (char*) malloc(sizeof(char) * 60); - memset(msg, 0, sizeof(char) * 60); - sprintf(msg, "Selected change mode (%ld) is not supported", jChange); - throwException(jEnv, msg); - FREE(msg); - FREE(path); - return; - } - chmod(path, currentMode); - } else { - throwException(jEnv, "Can`t get file current permissions"); - } - FREE(path); -} - - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_getPermissions0(JNIEnv *jEnv, jobject jObject, jstring jPath) { - char* path = getChars(jEnv, jPath); - int currentMode; - if(statMode(path, ¤tMode)) { - return currentMode & (S_IRWXU | S_IRWXG | S_IRWXO); - } else { - throwException(jEnv, "Can`t get file current permissions"); - } - - FREE(path); -} - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_isCurrentUserAdmin0 (JNIEnv *jEnv, jobject jObject) { - return (geteuid()==0); -} diff --git a/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.h b/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.h deleted file mode 100644 index 989e05da3446..000000000000 --- a/nbi/engine/native/jnilib/.unix/src/jni_UnixNativeUtils.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -/* Header for class org_netbeans_installer_utils_system_UnixNativeUtils */ - -#ifndef _Included_org_netbeans_installer_utils_system_UnixNativeUtils -#define _Included_org_netbeans_installer_utils_system_UnixNativeUtils -#ifdef __cplusplus -extern "C" { -#endif - - -#define MODE_RU 1L -#define MODE_WU 2L -#define MODE_EU 4L -#define MODE_RG 8L -#define MODE_WG 16L -#define MODE_EG 32L -#define MODE_RO 64L -#define MODE_WO 128L -#define MODE_EO 256L - -#define MODE_CHANGE_SET 1L -#define MODE_CHANGE_ADD 2L -#define MODE_CHANGE_REMOVE 4L - - - -/* - * Class: org_netbeans_installer_utils_system_UnixNativeUtils - * Method: getFreeSpace0 - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_getFreeSpace0 - (JNIEnv *, jobject, jstring); - -/* - * Class: org_netbeans_installer_utils_system_UnixNativeUtils - * Method: setPermission0 - * Signature: (Ljava/lang/String;II)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_setPermissions0 - (JNIEnv *, jobject, jstring, jint, jint); - -/* - * Class: org_netbeans_installer_utils_system_UnixNativeUtils - * Method: getPermissions0 - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_getPermissions0 - (JNIEnv *, jobject, jstring); - -/* - * Class: org_netbeans_installer_utils_system_UnixNativeUtils - * Method: isCurrentUserAdmin0 - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_UnixNativeUtils_isCurrentUserAdmin0 - (JNIEnv *, jobject); - - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/nbi/engine/native/jnilib/linux/Makefile b/nbi/engine/native/jnilib/linux/Makefile deleted file mode 100644 index 516847d04159..000000000000 --- a/nbi/engine/native/jnilib/linux/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/jnilib/linux/nbproject/configurations.xml b/nbi/engine/native/jnilib/linux/nbproject/configurations.xml deleted file mode 100644 index 9e8e8b1c983b..000000000000 --- a/nbi/engine/native/jnilib/linux/nbproject/configurations.xml +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - ../.common/src/CommonUtils.c - ../.unix/src/jni_UnixNativeUtils.c - - - ../.common/src/CommonUtils.h - ../.unix/src/jni_UnixNativeUtils.h - - - - - Makefile - - - Makefile - 0 - - - - GNU - true - true - false - 2 - - - - 0 - true - - /usr/java/include - /usr/java/include/linux - - -shared -m32 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - - /usr/java/include - /usr/java/include/linux - - -shared -m32 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/linux.so - true - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 2 - - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 2 - - - - 0 - true - true - - /usr/java/include - /usr/java/include/linux - - -shared -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - true - - /usr/java/include - /usr/java/include/linux - - -shared -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/linux-amd64.so - true - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - diff --git a/nbi/engine/native/jnilib/linux/nbproject/project.properties b/nbi/engine/native/jnilib/linux/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/jnilib/linux/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/jnilib/linux/nbproject/project.xml b/nbi/engine/native/jnilib/linux/nbproject/project.xml deleted file mode 100644 index 4e61d3b4e2b5..000000000000 --- a/nbi/engine/native/jnilib/linux/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Library: Linux - 0 - - - diff --git a/nbi/engine/native/jnilib/macosx/Makefile b/nbi/engine/native/jnilib/macosx/Makefile deleted file mode 100644 index 516847d04159..000000000000 --- a/nbi/engine/native/jnilib/macosx/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/jnilib/macosx/nbproject/configurations.xml b/nbi/engine/native/jnilib/macosx/nbproject/configurations.xml deleted file mode 100644 index 50ab41e33df8..000000000000 --- a/nbi/engine/native/jnilib/macosx/nbproject/configurations.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - ../.common/src/CommonUtils.h - ../.unix/src/jni_UnixNativeUtils.h - - - - - ../.common/src/CommonUtils.c - ../.unix/src/jni_UnixNativeUtils.c - - - Makefile - - - UTF-8 - Makefile - - - - GNU|GNU - 4 - - - - 0 - true - - /Library/Java/Home/include - - -arch i386 -arch ppc -arch ppc64 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -dynamiclib - - - 0 - true - - /Library/Java/Home/include - - -arch i386 -arch ppc -arch ppc64 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -dynamiclib - - - dist/macosx.dylib - - - -Wl,-syslibroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -arch ppc64 -arch x86_64 - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU|GNU - 4 - - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - diff --git a/nbi/engine/native/jnilib/macosx/nbproject/project.properties b/nbi/engine/native/jnilib/macosx/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/jnilib/macosx/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/jnilib/macosx/nbproject/project.xml b/nbi/engine/native/jnilib/macosx/nbproject/project.xml deleted file mode 100644 index 1825876f3cfd..000000000000 --- a/nbi/engine/native/jnilib/macosx/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Library: MacOS X - 0 - - - - diff --git a/nbi/engine/native/jnilib/solaris-sparc/Makefile b/nbi/engine/native/jnilib/solaris-sparc/Makefile deleted file mode 100644 index 516847d04159..000000000000 --- a/nbi/engine/native/jnilib/solaris-sparc/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/jnilib/solaris-sparc/nbproject/configurations.xml b/nbi/engine/native/jnilib/solaris-sparc/nbproject/configurations.xml deleted file mode 100644 index 98c3b5ce6c33..000000000000 --- a/nbi/engine/native/jnilib/solaris-sparc/nbproject/configurations.xml +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - ../.common/src/CommonUtils.c - ../.unix/src/jni_UnixNativeUtils.c - - - ../.common/src/CommonUtils.h - ../.unix/src/jni_UnixNativeUtils.h - - - - - Makefile - - - Makefile - 0 - - - - Sun12 - true - true - false - 0 - - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - dist/solaris-sparc.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 0 - - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - Sun12 - true - true - false - 0 - - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - dist/solaris-sparcv9.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 0 - - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -shared -static-libgcc -mimpure-text -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -shared -static-libgcc -mimpure-text -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/solaris-sparc.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 0 - - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -shared -static-libgcc -mimpure-text -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -shared -static-libgcc -mimpure-text -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/solaris-sparcv9.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - diff --git a/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.properties b/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.xml b/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.xml deleted file mode 100644 index c6febe0b0561..000000000000 --- a/nbi/engine/native/jnilib/solaris-sparc/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Library: Solaris Sparc - 0 - - - diff --git a/nbi/engine/native/jnilib/solaris-x86/Makefile b/nbi/engine/native/jnilib/solaris-x86/Makefile deleted file mode 100644 index 516847d04159..000000000000 --- a/nbi/engine/native/jnilib/solaris-x86/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/jnilib/solaris-x86/nbproject/configurations.xml b/nbi/engine/native/jnilib/solaris-x86/nbproject/configurations.xml deleted file mode 100644 index 18c1468d911f..000000000000 --- a/nbi/engine/native/jnilib/solaris-x86/nbproject/configurations.xml +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - ../.common/src/CommonUtils.c - ../.unix/src/jni_UnixNativeUtils.c - - - ../.common/src/CommonUtils.h - ../.unix/src/jni_UnixNativeUtils.h - - - - - Makefile - - - Makefile - 0 - - - - Sun12 - true - true - false - 1 - - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - dist/solaris-x86.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 0 - - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - Sun12 - true - true - false - 1 - - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -KPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -KPIC -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -xO2 -Xa - - - dist/solaris-amd64.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 1 - - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -static-libgcc -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - - /usr/java/include - /usr/java/include/solaris - - -m32 -fPIC -static-libgcc -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/solaris-x86.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - - GNU - true - true - false - 1 - - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -static-libgcc -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - 0 - true - true - - /usr/java/include - /usr/java/include/solaris - - -fPIC -static-libgcc -shared -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - - dist/solaris-amd64.so - true - false - - - - - - 0 - - - 3 - - - 0 - - - 3 - - - - diff --git a/nbi/engine/native/jnilib/solaris-x86/nbproject/project.properties b/nbi/engine/native/jnilib/solaris-x86/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/jnilib/solaris-x86/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/jnilib/solaris-x86/nbproject/project.xml b/nbi/engine/native/jnilib/solaris-x86/nbproject/project.xml deleted file mode 100644 index fdb447727778..000000000000 --- a/nbi/engine/native/jnilib/solaris-x86/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Library: Solaris X86 - 0 - - - diff --git a/nbi/engine/native/jnilib/windows/Makefile b/nbi/engine/native/jnilib/windows/Makefile deleted file mode 100644 index 516847d04159..000000000000 --- a/nbi/engine/native/jnilib/windows/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: -# Add your pre 'clean' code here... - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/jnilib/windows/Makefile-vc b/nbi/engine/native/jnilib/windows/Makefile-vc deleted file mode 100644 index 131aee1f0e10..000000000000 --- a/nbi/engine/native/jnilib/windows/Makefile-vc +++ /dev/null @@ -1,76 +0,0 @@ -# -# - - -!include <$(PLATFORM_SDK)/include/win32.mak> - -# define the compiler and linker for all the platforms -CC32="$(VC_2005)\Bin\cl.exe" -L32="$(VC_2005)\Bin\link.exe" - -CC32_OPTS=/O1 /Os /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_STATIC_CPPLIB" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MT /Fo".\build\32bit\\" /W3 /WX /c /Wp64 /Gd /TC -L32_OPTS=/OUT:".\dist\windows-x86.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib - - -CC64="$(PLATFORM_SDK)\Bin\win64\x86\AMD64\cl.exe" -L64="$(PLATFORM_SDK)\Bin\win64\x86\AMD64\link.exe" - -CC64_OPTS=/O1 /Os /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(PLATFORM_SDK)\Include\win64\crt\amd64" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_STATIC_CPPLIB" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MT /Fo".\build\64bit\\" /W3 /c /Wp64 /Gd /TC -L64_OPTS=/OUT:".\dist\windows-x64.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib\amd64" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:AMD64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib - -CCIA64="$(PLATFORM_SDK)\Bin\win64\cl.exe" -LIA64="$(PLATFORM_SDK)\Bin\win64\link.exe" - -CCIA64_OPTS=/O1 /Os /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(PLATFORM_SDK)\Include\win64\crt\amd64" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_STATIC_CPPLIB" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MT /Fo".\build\ia64\\" /W3 /c /Wp64 /Gd /TC -LIA64_OPTS=/OUT:".\dist\windows-ia64.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib\ia64" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:IA64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib bufferoverflowU.lib - - -all: init build-32 build-64 build-ia64 - -init: - - md .\build\32bit - - md .\build\64bit - - md .\build\ia64 - - md .\dist - - del /Q /S build - - del /Q .\dist\windows-x86.* - del /Q .\dist\windows-x64.* - del /Q .\dist\windows-ia64.* - -build-32: - Set CPU=i386 - Set Lib=%PLATFORM_SDK%\Lib;%Lib% - Set Include=%PLATFORM_SDK%\Include;%Include% - Set Path=%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%VC_2005_PATH%;%path% - Set APPVER=5.01 - Set TARGETOS=WINNT - - $(CC32) $(CC32_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(L32) $(L32_OPTS) ".\build\32bit\WindowsUtils.obj" ".\build\32bit\jni_WindowsRegistry.obj" ".\build\32bit\jni_WindowsNativeUtils.obj" ".\build\32bit\CommonUtils.obj" - - -build-64: - Set CPU=AMD64 - Set Lib=%PLATFORM_SDK%\Lib\AMD64;%PLATFORM_SDK%\Lib\AMD64\atlmfc; - Set Include=%PLATFORM_SDK%\Include;%PLATFORM_SDK%\Include\crt;%PLATFORM_SDK%\Include\crt\sys;%PLATFORM_SDK%\Include\mfc;%PLATFORM_SDK%\Include\atl - Set Path=%PLATFORM_SDK%\Bin\Win64\x86\AMD64;%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%path% - Set APPVER=5.02 - Set TARGETOS=WINNT - - $(CC64) $(CC64_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(L64) $(L64_OPTS) ".\build\64bit\WindowsUtils.obj" ".\build\64bit\jni_WindowsRegistry.obj" ".\build\64bit\jni_WindowsNativeUtils.obj" ".\build\64bit\CommonUtils.obj" - - -build-ia64: - Set CPU=IA64 - Set Lib=%PLATFORM_SDK%\Lib\IA64;%PLATFORM_SDK%\Lib\IA64\atlmfc; - Set Include=%PLATFORM_SDK%\Include;%PLATFORM_SDK%\Include\crt;%PLATFORM_SDK%\Include\crt\sys;%PLATFORM_SDK%\Include\mfc;%PLATFORM_SDK%\Include\atl - Set Path=%PLATFORM_SDK%\Bin\Win64;%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%path% - Set APPVER=5.02 - Set TARGETOS=WINNT - - $(CCIA64) $(CCIA64_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(LIA64) $(LIA64_OPTS) ".\build\ia64\WindowsUtils.obj" ".\build\ia64\jni_WindowsRegistry.obj" ".\build\ia64\jni_WindowsNativeUtils.obj" ".\build\ia64\CommonUtils.obj" - diff --git a/nbi/engine/native/jnilib/windows/Makefile-vc-wo-crt b/nbi/engine/native/jnilib/windows/Makefile-vc-wo-crt deleted file mode 100644 index e344b286fbdb..000000000000 --- a/nbi/engine/native/jnilib/windows/Makefile-vc-wo-crt +++ /dev/null @@ -1,79 +0,0 @@ -# -# - - -!include <$(PLATFORM_SDK)/include/win32.mak> - -# define the compiler and linker for all the platforms -CC32="$(VC_2005)\Bin\cl.exe" -L32="$(VC_2005)\Bin\link.exe" - -L32_LIBS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib -CC32_OPTS=/GS- /O1 /Os /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MD /Fo".\build\32bit\\" /W3 /WX /c /Wp64 /Gd /TC -L32_OPTS=/NOENTRY /NODEFAULTLIB /OUT:".\dist\windows-x86.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:X86 $(L32_LIBS) - - -CC64="$(PLATFORM_SDK)\Bin\win64\x86\AMD64\cl.exe" -L64="$(PLATFORM_SDK)\Bin\win64\x86\AMD64\link.exe" - -L64_LIBS=$(L32_LIBS) -CC64_OPTS=/O1 /Os /GS- /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(PLATFORM_SDK)\Include\win64\crt\amd64" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MD /Fo".\build\64bit\\" /W3 /c /Wp64 /Gd /TC -L64_OPTS=/NOENTRY /NODEFAULTLIB /OUT:".\dist\windows-x64.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib\amd64" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:AMD64 $(L64_LIBS) - -CCIA64="$(PLATFORM_SDK)\Bin\win64\cl.exe" -LIA64="$(PLATFORM_SDK)\Bin\win64\link.exe" - -LIA64_LIBS=$(L32_LIBS) -CCIA64_OPTS=/O1 /Os /GS- /I "$(VC_2005)\include" /I "$(PLATFORM_SDK)\Include" /I "$(PLATFORM_SDK)\Include\win64\crt\amd64" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "NBIJNILIBRARY_EXPORTS" /D "_CRT_SECURE_NO_DEPRECATE" /D "_LITTLE_ENDIAN" /D "_WINDLL" /FD /MD /Fo".\build\ia64\\" /W3 /c /Wp64 /Gd /TC -LIA64_OPTS=/NOENTRY /NODEFAULTLIB /OUT:".\dist\windows-ia64.dll" /INCREMENTAL:NO /LIBPATH:"$(PLATFORM_SDK)\Lib\ia64" /LIBPATH:"$(VC_2005)\lib" /DLL /MANIFEST:NO /IGNOREIDL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:IA64 $(LIA64_LIBS) - - -all: init build-32 build-64 build-ia64 - -init: - - md .\build\32bit - - md .\build\64bit - - md .\build\ia64 - - md .\dist - - del /Q /S build - - del /Q .\dist\windows-x86.* - del /Q .\dist\windows-x64.* - del /Q .\dist\windows-ia64.* - -build-32: - Set CPU=i386 - Set Lib=%PLATFORM_SDK%\Lib;%Lib% - Set Include=%PLATFORM_SDK%\Include;%Include% - Set Path=%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%VC_2005_PATH%;%path% - Set APPVER=5.01 - Set TARGETOS=WINNT - - $(CC32) $(CC32_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(L32) $(L32_OPTS) ".\build\32bit\WindowsUtils.obj" ".\build\32bit\jni_WindowsRegistry.obj" ".\build\32bit\jni_WindowsNativeUtils.obj" ".\build\32bit\CommonUtils.obj" - - -build-64: - Set CPU=AMD64 - Set Lib=%PLATFORM_SDK%\Lib\AMD64;%PLATFORM_SDK%\Lib\AMD64\atlmfc; - Set Include=%PLATFORM_SDK%\Include;%PLATFORM_SDK%\Include\crt;%PLATFORM_SDK%\Include\crt\sys;%PLATFORM_SDK%\Include\mfc;%PLATFORM_SDK%\Include\atl - Set Path=%PLATFORM_SDK%\Bin\Win64\x86\AMD64;%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%path% - Set APPVER=5.02 - Set TARGETOS=WINNT - - $(CC64) $(CC64_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(L64) $(L64_OPTS) ".\build\64bit\WindowsUtils.obj" ".\build\64bit\jni_WindowsRegistry.obj" ".\build\64bit\jni_WindowsNativeUtils.obj" ".\build\64bit\CommonUtils.obj" - - -build-ia64: - Set CPU=IA64 - Set Lib=%PLATFORM_SDK%\Lib\IA64;%PLATFORM_SDK%\Lib\IA64\atlmfc; - Set Include=%PLATFORM_SDK%\Include;%PLATFORM_SDK%\Include\crt;%PLATFORM_SDK%\Include\crt\sys;%PLATFORM_SDK%\Include\mfc;%PLATFORM_SDK%\Include\atl - Set Path=%PLATFORM_SDK%\Bin\Win64;%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%path% - Set APPVER=5.02 - Set TARGETOS=WINNT - - $(CCIA64) $(CCIA64_OPTS) .\src\WindowsUtils.c .\src\jni_WindowsRegistry.c .\src\jni_WindowsNativeUtils.c .\..\.common\src\CommonUtils.c - $(LIA64) $(LIA64_OPTS) ".\build\ia64\WindowsUtils.obj" ".\build\ia64\jni_WindowsRegistry.obj" ".\build\ia64\jni_WindowsNativeUtils.obj" ".\build\ia64\CommonUtils.obj" - diff --git a/nbi/engine/native/jnilib/windows/nbproject/configurations.xml b/nbi/engine/native/jnilib/windows/nbproject/configurations.xml deleted file mode 100644 index b7731b5f037a..000000000000 --- a/nbi/engine/native/jnilib/windows/nbproject/configurations.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - ../.common/src/CommonUtils.c - src/jni_WindowsNativeUtils.c - src/jni_WindowsRegistry.c - src/WindowsUtils.c - - - ../.common/src/CommonUtils.h - src/jni_WindowsNativeUtils.h - src/jni_WindowsRegistry.h - src/WindowsUtils.h - - - - - Makefile - - - Makefile - 0 - - - - Cygwin - true - true - false - 3 - - - - 0 - true - - /usr/java/include - /usr/java/include/win32 - - -mno-cygwin - - - 0 - true - - /usr/java/include - /usr/java/include\win32 - - -mno-cygwin - - - dist/windows.dll - true - - -lole32 - -luuid - - -Wl,--add-stdcall-alias - - - - 0 - - - 3 - - - 0 - - - 3 - - - 0 - - - 3 - - - 0 - - - 3 - - - - - Cygwin - true - true - false - 3 - - - - 0 - true - - /usr/java/include - /usr/java/include/win32 - - -mno-cygwin - - - 0 - true - - /usr/java/include - /usr/java/include\win32 - - -mno-cygwin - - - dist/windows.dll - true - - -lole32 - -luuid - - -Wl,--add-stdcall-alias - - - - 0 - - - 3 - - - 0 - - - 3 - - - 0 - - - 3 - - - 0 - - - 3 - - - - diff --git a/nbi/engine/native/jnilib/windows/nbproject/project.properties b/nbi/engine/native/jnilib/windows/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/jnilib/windows/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/jnilib/windows/nbproject/project.xml b/nbi/engine/native/jnilib/windows/nbproject/project.xml deleted file mode 100644 index 1aa64eba18a3..000000000000 --- a/nbi/engine/native/jnilib/windows/nbproject/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Library: Windows - 0 - - - diff --git a/nbi/engine/native/jnilib/windows/src/WindowsUtils.c b/nbi/engine/native/jnilib/windows/src/WindowsUtils.c deleted file mode 100644 index fe4972d35648..000000000000 --- a/nbi/engine/native/jnilib/windows/src/WindowsUtils.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../.common/src/CommonUtils.h" -#include "WindowsUtils.h" -#include "jni_WindowsRegistry.h" - -HKEY getHKEY(jint jSection) { - switch (jSection) { - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CLASSES_ROOT: - return HKEY_CLASSES_ROOT; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_USER: - return HKEY_CURRENT_USER; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_LOCAL_MACHINE: - return HKEY_LOCAL_MACHINE; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_USERS: - return HKEY_USERS; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_CONFIG: - return HKEY_CURRENT_CONFIG; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_DYN_DATA: - return HKEY_DYN_DATA; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_DATA: - return HKEY_PERFORMANCE_DATA; - default: - return NULL; - } -} - -LONG getMode(jint jmode) { - switch (jmode) { - case org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_DEFAULT: - return 0L; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_32BIT: - return KEY_WOW64_32KEY; - case org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_64BIT: - return KEY_WOW64_64KEY; - default: - return 0L; - } -} - - -int queryValue(int mode, HKEY section, const unsigned short* key, const unsigned short* name, DWORD* type, DWORD* size, byte** value, int expand) { - int result = 1; - - HKEY hkey = 0; - int tempType = 0; - int tempSize = 0; - byte* tempValue = NULL; - - if (RegOpenKeyExW(section, key, 0, KEY_QUERY_VALUE | mode, &hkey) == ERROR_SUCCESS) { - if (RegQueryValueExW(hkey, name, NULL, (LPDWORD) &tempType, NULL, (LPDWORD) &tempSize) == ERROR_SUCCESS) { - tempValue = (byte*) MALLOC(tempSize + 8); - - if (tempValue != NULL) { - ZERO(tempValue, tempSize + 8); - - if (RegQueryValueExW(hkey, name, NULL, (LPDWORD) &tempType, tempValue, (LPDWORD) &tempSize) == ERROR_SUCCESS) { - if (expand && (tempType == REG_EXPAND_SZ)) { - int expandedSize = (int) WCSLEN((unsigned short*) tempValue) + 2; - byte* expandedValue = (byte*) MALLOC(expandedSize * sizeof(wchar_t)); - int expandedCharsNumber = 0; - ZERO(expandedValue, expandedSize); - expandedCharsNumber = ExpandEnvironmentStringsW((unsigned short*) tempValue, (unsigned short*) expandedValue, tempSize); - if (expandedCharsNumber > tempSize) { - FREE(expandedValue); - expandedValue = (byte*) MALLOC(expandedCharsNumber * sizeof(wchar_t)); - expandedCharsNumber = ExpandEnvironmentStringsW((unsigned short*) tempValue, (unsigned short*) expandedValue, expandedCharsNumber); - } - - FREE(tempValue); - tempValue = expandedValue; - } - } else { - FREE(tempValue); - result = 0; - } - } - } else { - result = 0; - } - } else { - result = 0; - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - if (type != NULL) { - *type = tempType; - } - if (size != NULL) { - *size = tempSize; - } - if ((value != NULL) && (tempValue != NULL)) { - *value = tempValue; - } - - return result; -} - -int setValue(int mode, HKEY section, const unsigned short* key, const unsigned short* name, DWORD type, const byte* data, int size, int expand) { - int result = 1; - - HKEY hkey = 0; - - if (RegOpenKeyExW(section, key, 0, KEY_SET_VALUE | mode, &hkey) == ERROR_SUCCESS) { - if (!(RegSetValueExW(hkey, name, 0, type, data, size) == ERROR_SUCCESS)) { - result = 0; - } - } else { - result = 0; - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - return result; -} diff --git a/nbi/engine/native/jnilib/windows/src/WindowsUtils.h b/nbi/engine/native/jnilib/windows/src/WindowsUtils.h deleted file mode 100644 index 947c63e7482a..000000000000 --- a/nbi/engine/native/jnilib/windows/src/WindowsUtils.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../.common/src/CommonUtils.h" - -#ifndef _WindowsUtils_H -#define _WindowsUtils_H - -#ifdef __cplusplus -extern "C" { -#endif - -HKEY getHKEY(jint jSection); - -int queryValue(int mode, HKEY section, const unsigned short * key, const unsigned short * name, DWORD* type, DWORD* size, byte** value, int expand); - -int setValue(int mode, HKEY section, const unsigned short * key, const unsigned short * name, DWORD type, const byte* data, int size, int expand); - -LONG getMode(jint jmode); -#ifdef __cplusplus -} -#endif -#endif // _WindowsUtils_H diff --git a/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.c b/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.c deleted file mode 100644 index 6d7c60baa118..000000000000 --- a/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include - -#include "../../.common/src/CommonUtils.h" -#include "WindowsUtils.h" -#include "jni_WindowsNativeUtils.h" - -//////////////////////////////////////////////////////////////////////////////// -// Functions - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_isCurrentUserAdmin0(JNIEnv* jEnv, jobject jObject) { - BOOL result = FALSE; - - PACL pACL = NULL; - PSID psidAdmin = NULL; - HANDLE token = NULL; - HANDLE duplToken = NULL; - PSECURITY_DESCRIPTOR adminDescriptor = NULL; - - SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; - DWORD aclSize; - - const DWORD ACCESS_READ = 1; - const DWORD ACCESS_WRITE = 2; - - GENERIC_MAPPING mapping; - - PRIVILEGE_SET ps; - DWORD status; - DWORD structSize = sizeof(PRIVILEGE_SET); - - // MS KB 118626 - while (TRUE) { - if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, TRUE, &token)) { - if (GetLastError() != ERROR_NO_TOKEN) { - throwException(jEnv, "Native error"); - break; - } - - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_QUERY, &token)) { - throwException(jEnv, "Native error"); - break; - } - } - - if (!DuplicateToken(token, SecurityImpersonation, &duplToken)) { - throwException(jEnv, "Native error"); - break; - } - - if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin)) { - throwException(jEnv, "Native error"); - break; - } - - adminDescriptor = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); - if (adminDescriptor == NULL) { - throwException(jEnv, "Native error"); - break; - } - if (!InitializeSecurityDescriptor(adminDescriptor, SECURITY_DESCRIPTOR_REVISION)) { - throwException(jEnv, "Native error"); - break; - } - - aclSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD); - - pACL = (PACL) LocalAlloc(LPTR, aclSize); - if (pACL == NULL) { - throwException(jEnv, "Native error"); - break; - } - if (!InitializeAcl(pACL, aclSize, ACL_REVISION2)) { - throwException(jEnv, "Native error"); - break; - } - - if (!AddAccessAllowedAce(pACL, ACL_REVISION2, ACCESS_READ | ACCESS_WRITE , psidAdmin)) { - throwException(jEnv, "Native error"); - break; - } - if (!SetSecurityDescriptorDacl(adminDescriptor, TRUE, pACL, FALSE)) { - throwException(jEnv, "Native error"); - break; - } - - SetSecurityDescriptorGroup(adminDescriptor, psidAdmin, FALSE); - SetSecurityDescriptorOwner(adminDescriptor, psidAdmin, FALSE); - - if (!IsValidSecurityDescriptor(adminDescriptor)) { - throwException(jEnv, "Native error"); - break; - } - - mapping.GenericRead = ACCESS_READ; - mapping.GenericWrite = ACCESS_WRITE; - mapping.GenericExecute = 0; - mapping.GenericAll = ACCESS_READ | ACCESS_WRITE; - - if (!AccessCheck(adminDescriptor, duplToken, ACCESS_READ, &mapping, &ps, &structSize, &status, &result)) { - throwException(jEnv, "Native error"); - break; - } - - break; - } - - if (pACL) { - LocalFree(pACL); - } - if (adminDescriptor) { - LocalFree(adminDescriptor); - } - if (psidAdmin) { - FreeSid(psidAdmin); - } - if (duplToken) { - CloseHandle(duplToken); - } - if (token) { - CloseHandle(token); - } - - return result; -} - -JNIEXPORT jlong JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_getFreeSpace0(JNIEnv* jEnv, jobject jObject, jstring jPath) { - WCHAR* path = getWideChars(jEnv, jPath); - jlong size = 0; - typedef struct int64s { unsigned long Low, High; } int64t; - int64t bytes; - if (GetDiskFreeSpaceExW(path, (PULARGE_INTEGER) &bytes, NULL, NULL)) { - unsigned long h = bytes.High; - // workaround of using missing _allmul function - // replace multiplication by sum - // (2^32 * high + low) = 2^32 + 2^32 + ... (bytes.High times total) + bytes.Low - // can be relatively expensive on big sizes (peta bytes and more) - while(h > 0) { - h--; - size+=4294967296L; - } - size+= bytes.Low; - } else { - throwException(jEnv, "Native error"); - } - - FREE(path); - - return size; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_createShortcut0(JNIEnv* jEnv, jobject jObject, jobject jShortcut) { - unsigned short *shortcutPath = getWideStringFromMethod(jEnv, jShortcut, "getPath"); - unsigned short *targetPath = getWideStringFromMethod(jEnv, jShortcut, "getTargetPath"); - unsigned short *description = getWideStringFromMethod(jEnv, jShortcut, "getDescription"); - unsigned short *iconPath = getWideStringFromMethod(jEnv, jShortcut, "getIconPath"); - jint iconIndex = getIntFromMethod (jEnv, jShortcut, "getIconIndex"); - unsigned short *workingDirectory = getWideStringFromMethod(jEnv, jShortcut, "getWorkingDirectoryPath"); - unsigned short *arguments = getWideStringFromMethod(jEnv, jShortcut, "getArgumentsString"); - - HRESULT tempResult; - IShellLinkW* shell; - - HRESULT comStart = CoInitialize(NULL); - int errorCode = 0; - - tempResult = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (void **) &shell); - - if (SUCCEEDED(tempResult)) { - IPersistFile *persistFile; - // we will save the shell link in persistent storage - tempResult = shell->lpVtbl->QueryInterface(shell, &IID_IPersistFile, (void **) &persistFile); - - if (SUCCEEDED(tempResult)) { - tempResult = shell->lpVtbl->SetPath(shell, targetPath); - if (!SUCCEEDED(tempResult)) { - throwException(jEnv, "Native error (-2)"); - errorCode = -2; - } - // make sure description length is less than MAX_PATH - if ((errorCode == 0) && (description != NULL)) { - if (WCSLEN(description) < MAX_PATH) { - if (!SUCCEEDED(shell->lpVtbl->SetDescription(shell, description))) { - throwException(jEnv, "Native error (-3)"); - errorCode = -3; - } - } else { - unsigned short *desc = (unsigned short *) MALLOC(sizeof(unsigned short) * MAX_PATH); - ZERO(desc, sizeof(unsigned short) * MAX_PATH); - desc = WCSNCPY(desc, description, MAX_PATH); - if (!SUCCEEDED(shell->lpVtbl->SetDescription(shell, desc))) { - throwException(jEnv, "Native error (-4)"); - errorCode = -4; - } - FREE(desc); - } - } - if ((errorCode == 0) && (arguments != NULL)) { - if (!SUCCEEDED(shell->lpVtbl->SetArguments(shell, arguments))) { - throwException(jEnv, "Native error (-5)"); - errorCode = -5; - } - } - if ((errorCode == 0) && (workingDirectory != NULL)) { - if (!SUCCEEDED(shell->lpVtbl->SetWorkingDirectory(shell, workingDirectory))) { - throwException(jEnv, "Native error (-6)"); - errorCode = -6; - } - } - if ((errorCode == 0) && (iconPath != NULL)) { - if (!SUCCEEDED(shell->lpVtbl->SetIconLocation(shell, iconPath, iconIndex))) { - throwException(jEnv, "Native error (-7)"); - errorCode = -7; - } - } - // use normal window. - if (errorCode == 0) { - if (!SUCCEEDED(shell->lpVtbl->SetShowCmd(shell, SW_NORMAL))) { - throwException(jEnv, "Native error (-8)"); - errorCode = -8; - } - } - if (errorCode == 0) { - if (mkdirsW(jEnv, shortcutPath)) { - if (!SUCCEEDED(persistFile->lpVtbl->Save(persistFile, shortcutPath, TRUE))) { - throwException(jEnv, "Native error (-9)"); - errorCode = -9; - } - } else { - throwException(jEnv, "Native error (-10)"); - errorCode = -10; - } - } - - if (errorCode == 0) { - persistFile->lpVtbl->Release(persistFile); - } - } else { - throwException(jEnv, "Native error (-11)"); - errorCode = -11; - } - shell->lpVtbl->Release(shell); - } else { - throwException(jEnv, "Native error (-12)"); - errorCode = -12; - } - - if (comStart == S_OK) { - CoUninitialize(); - } - - FREE(shortcutPath); - FREE(targetPath); - FREE(description); - FREE(iconPath); - FREE(workingDirectory); - FREE(arguments); -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_deleteFileOnReboot0(JNIEnv* jEnv, jobject jObject, jstring jPath) { - unsigned short * path = getWideChars(jEnv, jPath); - - if (!MoveFileExW(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { - throwException(jEnv, "Native error"); - } - - FREE(path); -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_createProcessWithoutHandles0(JNIEnv* jEnv, jobject jObject, jstring jCommand) { - unsigned short * command = getWideChars(jEnv, jCommand); - STARTUPINFOW si; - PROCESS_INFORMATION pi; - - ZERO(&si, sizeof(si)); - si.cb = sizeof(si); - ZERO(&pi, sizeof(pi)); - if(!CreateProcessW(NULL, // executable name - use command line - command, // command line - NULL, // process security attribute - NULL, // thread security attribute - FALSE, // inherits system handles - 0, // no creation flags - NULL, // use parent's environment block - NULL, // use parent's starting directory - &si, // (in) startup information - &pi)) { // (out) process information - throwException(jEnv, "Cannot create process.\n"); - } - - - FREE(command); -} -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_notifyAssociationChanged0(JNIEnv *jEnv, jobject jObj) { - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0); -} - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_notifyEnvironmentChanged0(JNIEnv *jEnv, jobject jObj) { - /* maximum 1 sec timeout for each window in the system */ - DWORD dwReturnValue = 0; - LRESULT result = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR) &dwReturnValue); - return (result!=0); -} - - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_checkAccessTokenAccessLevel0(JNIEnv *jEnv, jobject jObj, jstring jPath, jint jLevel) { - unsigned short * path = getWideChars(jEnv, jPath); - PSECURITY_DESCRIPTOR pSD; - DWORD nLength; - - PRIVILEGE_SET PrivilegeSet; - DWORD PrivSetSize = sizeof (PRIVILEGE_SET); - - HANDLE hToken; - - GENERIC_MAPPING GenericMapping; - DWORD DesiredAccess = (DWORD) jLevel ; - - BOOL bAccessGranted; - DWORD GrantedAccess; - - // create memory for storing user's security descriptor - GetFileSecurityW(path, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, NULL, 0, &nLength); - - pSD = (PSECURITY_DESCRIPTOR) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength); - - if (pSD == NULL) { - throwException(jEnv, "Unable to allocate memory to store security descriptor.\n"); - return -1; - } - // Get the security descriptor - if (!GetFileSecurityW(path, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, pSD, nLength, &nLength)) { - throwException(jEnv, "Unable to obtain security descriptor.\n"); - FREE(path); - return (-3); - } - FREE(path); - - /* Perform security impersonation of the user and open */ - /* the resulting thread token. */ - if (!ImpersonateSelf(SecurityImpersonation)) { - throwException(jEnv, "Unable to perform security impersonation.\n"); - HeapFree(GetProcessHeap(), 0, pSD); - return (-4); - } - - if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken)) { - throwException(jEnv, "Unable to get current thread's token.\n"); - HeapFree(GetProcessHeap(), 0, pSD); - return (-5); - } - RevertToSelf(); - - ZERO(&GenericMapping, sizeof (GENERIC_MAPPING)); - - DesiredAccess = DesiredAccess | STANDARD_RIGHTS_READ; - GenericMapping.GenericRead = FILE_GENERIC_READ; - - if(jLevel & FILE_WRITE_DATA) { - GenericMapping.GenericWrite = FILE_GENERIC_WRITE; - } - - MapGenericMask(&DesiredAccess, &GenericMapping); - - /* Perform access check using the token. */ - if (!AccessCheck(pSD, hToken, DesiredAccess, &GenericMapping, &PrivilegeSet, &PrivSetSize, &GrantedAccess, &bAccessGranted)) { - throwException(jEnv, "Unable to perform access check.\n"); - CloseHandle(hToken); - HeapFree(GetProcessHeap(), 0, pSD); - return (-6); - } - /* Clean up. */ - HeapFree(GetProcessHeap(), 0, pSD); - CloseHandle(hToken); - return (bAccessGranted); -} - - diff --git a/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.h b/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.h deleted file mode 100644 index 9ea87e707e2b..000000000000 --- a/nbi/engine/native/jnilib/windows/src/jni_WindowsNativeUtils.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -/* Header for class org_netbeans_installer_utils_system_WindowsNativeUtils */ - -#ifndef _Included_org_netbeans_installer_utils_system_WindowsNativeUtils -#define _Included_org_netbeans_installer_utils_system_WindowsNativeUtils - -#ifdef __cplusplus -extern "C" { -#endif - -#undef org_netbeans_installer_utils_system_WindowsNativeUtils_MIN_UID_INDEX -#define org_netbeans_installer_utils_system_WindowsNativeUtils_MIN_UID_INDEX 1L - -#undef org_netbeans_installer_utils_system_WindowsNativeUtils_MAX_UID_INDEX -#define org_netbeans_installer_utils_system_WindowsNativeUtils_MAX_UID_INDEX 100L - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: isCurrentUserAdmin0 - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_isCurrentUserAdmin0 - (JNIEnv *, jobject); - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: getFreeSpace0 - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_getFreeSpace0 - (JNIEnv *, jobject, jstring); - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: createShortcut0 - * Signature: (Lorg/netbeans/installer/utils/system/shortcut/FileShortcut;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_createShortcut0 - (JNIEnv *, jobject, jobject); - - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: deleteFileOnReboot0 - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_deleteFileOnReboot0 - (JNIEnv *, jobject, jstring); - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: createProcessWithoutHandles0 - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_createProcessWithoutHandles0 - (JNIEnv *, jobject, jstring); - - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: notifyAssociationChanged0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_notifyAssociationChanged0 - (JNIEnv *, jobject); - - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: checkAccessTokenAccessLevel0 - * Signature: (Ljava/lang/String;I)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_checkAccessTokenAccessLevel0 - (JNIEnv *, jobject, jstring, jint); - - -/* - * Class: org_netbeans_installer_utils_system_WindowsNativeUtils - * Method: notifyEnvironmentChanged0 - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_WindowsNativeUtils_notifyEnvironmentChanged0 - (JNIEnv *, jobject); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.c b/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.c deleted file mode 100644 index 3608bf029add..000000000000 --- a/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../.common/src/CommonUtils.h" -#include "WindowsUtils.h" -#include "jni_WindowsRegistry.h" - -//////////////////////////////////////////////////////////////////////////////// -// Globals - -// maximum length of a registry value -const DWORD MAX_LEN_VALUE_NAME = 16383; - -//////////////////////////////////////////////////////////////////////////////// -// Functions - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_checkKeyAccess0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jint jLevel) { - HKEY hkey = 0; - unsigned short * key = getWideChars(jEnv, jKey); - - jboolean result = FALSE; - REGSAM access = (jLevel==0) ? KEY_READ : KEY_ALL_ACCESS; - result = (RegOpenKeyExW(getHKEY(jSection), key, 0, access | getMode(jMode), &hkey) == ERROR_SUCCESS); - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - - return result; -} - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_valueExists0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey = 0; - unsigned short * key = getWideChars(jEnv, jKey); - unsigned short * value = getWideChars(jEnv, jName); - jboolean result = FALSE; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - result = (RegQueryValueExW(hkey, value, NULL, NULL, NULL, NULL) == ERROR_SUCCESS); - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - FREE(key); - FREE(value); - - return result; -} - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_keyEmpty0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - - DWORD subkeys = 1; - DWORD values = 1; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_READ | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, &subkeys, NULL, NULL, &values, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - - return (values + subkeys == 0); -} - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_countSubKeys0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - - DWORD count = 0; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_READ | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if(RegQueryInfoKeyW(hkey, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - - return count; -} - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_countValues0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - - DWORD count = 0; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_READ | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - - return count; -} - -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getSubkeyNames0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - DWORD number = 0; - int err = 0; - int index = 0 ; - - unsigned short* buffer = (unsigned short*) MALLOC(sizeof(char) * MAX_LEN_VALUE_NAME); - - jobjectArray result = NULL; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_READ | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, &number, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - jclass stringClazz = (*jEnv)->FindClass(jEnv, "java/lang/String"); - result = (*jEnv)->NewObjectArray(jEnv, number, stringClazz, NULL); - - do { - DWORD size = MAX_LEN_VALUE_NAME; - buffer[0] = 0; - - err = RegEnumKeyExW(hkey, index, buffer, &size, NULL, NULL, NULL, NULL); - if (err == ERROR_SUCCESS) { - (*jEnv)->SetObjectArrayElement(jEnv, result, index, getStringW(jEnv, buffer)); - } else { - if (err != ERROR_NO_MORE_ITEMS) { - throwException(jEnv, "Cannot get key names"); - } - } - - index++; - } while (err == ERROR_SUCCESS); - } else { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(buffer); - - return result; -} - -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getValueNames0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - DWORD valuesCount = 0; - int err = 0; - int index = 0; - - unsigned short* buffer = (unsigned short*) MALLOC(sizeof(char) * MAX_LEN_VALUE_NAME); - - jobjectArray result = NULL; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &valuesCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - jclass stringClazz = (*jEnv)->FindClass(jEnv, "java/lang/String"); - result = (*jEnv)->NewObjectArray(jEnv, valuesCount, stringClazz, NULL); - - do { - DWORD size = MAX_LEN_VALUE_NAME; - buffer[0] = 0; - - err = RegEnumValueW(hkey, index, buffer, &size, NULL, NULL, NULL, NULL); - if (err == ERROR_SUCCESS) { - (*jEnv)->SetObjectArrayElement(jEnv, result, index, getStringW(jEnv, buffer)); - } else { - if (err != ERROR_NO_MORE_ITEMS) { - throwException(jEnv, "Cannot get value names"); - } - } - - index++; - } while (err == ERROR_SUCCESS); - } else { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(buffer); - - return result; -} - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getValueType0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey =0; - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* value = getWideChars(jEnv, jName); - - DWORD type = REG_NONE; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryValueExW(hkey, value, NULL, &type, NULL, NULL) != ERROR_SUCCESS) { - throwException(jEnv, "Cannot read value"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(value); - - return type; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_createKey0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jParent, jstring jChild) { - HKEY hkey = 0; - HKEY newKey = 0; - unsigned short* parent = getWideChars(jEnv, jParent); - unsigned short* child = getWideChars(jEnv, jChild); - - if (RegOpenKeyExW(getHKEY(jSection), parent, 0, KEY_CREATE_SUB_KEY | getMode(jMode), &hkey) == ERROR_SUCCESS) { - LONG result = RegCreateKeyExW(hkey, child, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE | getMode(jMode), NULL, &newKey, NULL); - if (result == ERROR_SUCCESS) { - if (newKey != 0) { - RegCloseKey(newKey); - } - } else if (result == ERROR_ACCESS_DENIED) { - throwException(jEnv, "Could not create a new key (access denied)"); - } else { - throwException(jEnv, "Could not create a new key"); - } - } else { - throwException(jEnv, "Could not open the parent key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(parent); - FREE(child); -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_deleteKey0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jParent, jstring jChild) { - HKEY hkey = 0; - unsigned short* jParentS = getWideChars(jEnv, jParent); - unsigned short* jChildS = getWideChars(jEnv, jChild); - - - if (RegOpenKeyExW(getHKEY(jSection), jParentS, 0, KEY_READ | KEY_WRITE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - LONG mode = getMode(jMode); - if(mode==0) { - if (RegDeleteKeyW(hkey, jChildS) != ERROR_SUCCESS) { - throwException(jEnv, "Could not delete key"); - } - } else { - typedef LONG (WINAPI *LPFN_REGDELETEKEYEXW) (HKEY, LPCWSTR, REGSAM, DWORD); - LPFN_REGDELETEKEYEXW regDeleteKeyExW; - HMODULE hModule = GetModuleHandle(TEXT("advapi32.dll")); - if(hModule == NULL) { - hModule = LoadLibraryA("advapi32.dll"); - } - regDeleteKeyExW = (LPFN_REGDELETEKEYEXW) GetProcAddress(hModule,"RegDeleteKeyExW"); - if (NULL != regDeleteKeyExW) { - if (regDeleteKeyExW(hkey, jChildS, mode, 0) != ERROR_SUCCESS) { - throwException(jEnv, "Could not delete key"); - } - } else { - throwException(jEnv, "Cannot load function RegDeleteKeyExW"); - } - } - } else { - throwException(jEnv, "Could not open the parent key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(jParentS); - FREE(jChildS); -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_deleteValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* value = getWideChars(jEnv, jName); - - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_SET_VALUE | getMode(jMode) , &hkey) == ERROR_SUCCESS) { - if (RegDeleteValueW(hkey, value) != ERROR_SUCCESS) { - throwException(jEnv, "Cannot delete value"); - } - } else { - throwException(jEnv, "Canont open key"); - } - - if(hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(value); -} - -JNIEXPORT jstring JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getStringValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jboolean jExpand) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - DWORD type = REG_NONE; - byte* value = NULL; - - jstring result = NULL; - - if (queryValue(getMode(jMode), getHKEY(jSection), key, name, &type, NULL, &value, jExpand)) { - if (type == REG_SZ || type == REG_EXPAND_SZ) { - result = getStringW(jEnv, (unsigned short*) value); - } else { - throwException(jEnv, "Value has wrong type"); - } - } else { - throwException(jEnv, "Cannot read value"); - } - - FREE(key); - FREE(name); - FREE(value); - - return result; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setStringValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jstring jValue, jboolean jExpand) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - unsigned short* value = getWideChars(jEnv, jValue); - - if (!setValue(getMode(jMode), getHKEY(jSection), key, name, jExpand ? REG_EXPAND_SZ : REG_SZ, (byte*) value, ((int) WCSLEN(value)) * sizeof(unsigned short), 0)) { - throwException(jEnv, "Could not set value"); - } - - FREE(key); - FREE(name); - FREE(value); -} - -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_get32BitValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* value = getWideChars(jEnv, jName); - - jint result = -1; - if(RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - DWORD dwType = 0; - DWORD dwValue = 0; - DWORD dwBufSize = sizeof(dwValue); - - if (RegQueryValueExW(hkey, value, NULL, &dwType, (LPBYTE) &dwValue, &dwBufSize) == ERROR_SUCCESS) { - if ((dwType == REG_DWORD) || (dwType == REG_DWORD_BIG_ENDIAN)) { - result = dwValue; - } else { - throwException(jEnv, "Value is of wrong type"); - } - } else { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Could not open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(value); - - return result; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_set32BitValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jint jValue) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - DWORD dword = (DWORD) jValue; - LPBYTE byteValue = (LPBYTE) &dword; - - if (!setValue(getMode(jMode),getHKEY(jSection), key, name, REG_DWORD, byteValue, sizeof(dword), 0)) { - throwException(jEnv, "Cannot set value"); - } - - FREE(key); - FREE(name); -} - -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getMultiStringValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* value = getWideChars(jEnv, jName); - - int i, start, count, cnt; - LONG regErr = 0; - unsigned short* data = 0; - jstring string; - jclass strClass; - DWORD dwType; - DWORD size = 0; - - jarray result = 0; - if(RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - if (RegQueryValueExW(hkey, value, NULL, &dwType, NULL, &size) == ERROR_SUCCESS) { - if (dwType == REG_MULTI_SZ) { - data = (unsigned short*) LocalAlloc(LPTR, size + 8); - - if (data != NULL) { - if (RegQueryValueExW(hkey, value, NULL, &dwType, (byte*) data, &size) == ERROR_SUCCESS) { - for (count = 0, i = 0; i < (int) size; i++) { - if (data[i] == '\0') { // \0 - end of a single string - count++; - if (data[i + 1] == '\0') { // two \0 's in a row - end of all strings - break; - } - } - } - - strClass = (*jEnv)->FindClass(jEnv, "java/lang/String"); - if (strClass != NULL) { - result = (*jEnv)->NewObjectArray(jEnv, (jsize) count, strClass, NULL); - if (result != NULL) { - for (cnt = 0, start = 0, i = 0; (i < (int) size) && (cnt < count); i++) { - if (data[i] == '\0') { - string = getStringWithLengthW(jEnv, &data[start], i - start); - - if (string != NULL) { - (*jEnv)->SetObjectArrayElement(jEnv, (jobjectArray) result, (jsize) cnt++, string); - - start = i + 1; - if (data[start] == '\0') { - break; - } - } else { - throwException(jEnv, "Cannot create an array element"); - break; - } - } - } - } else { - throwException(jEnv, "Cannot create resulting array"); - } - } else { - throwException(jEnv, "Cannot find java.lang.String"); - } - } else { - throwException(jEnv, "Cannot read value data"); - } - FREE(data); - } else { - throwException(jEnv, "Cannot allocate memory for value"); - } - } else { - throwException(jEnv, "Value is of wrong type"); - } - } else { - throwException(jEnv, "Cannot read key data"); - } - } else { - throwException(jEnv, "Cannot open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(value); - - return (jobjectArray) result; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setMultiStringValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jobjectArray jValue) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - DWORD size = 0; - BYTE* data = getByteFromMultiString(jEnv, jValue, &size); - - if (!setValue(getMode(jMode),getHKEY(jSection), key, name, REG_MULTI_SZ, data, size, 0)) { - throwException(jEnv, "Cannot set value"); - } - - FREE(key); - FREE(name); - FREE(data); -} - -JNIEXPORT jbyteArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getBinaryValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName) { - HKEY hkey = 0; - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* value = getWideChars(jEnv, jName); - - jbyteArray result = NULL; - if (RegOpenKeyExW(getHKEY(jSection), key, 0, KEY_QUERY_VALUE | getMode(jMode), &hkey) == ERROR_SUCCESS) { - DWORD dwType = 0; - DWORD dwValue = 0; - DWORD size = 0; - BYTE* data = NULL; - - if (RegQueryValueExW(hkey, value, NULL, &dwType, NULL, &size) == ERROR_SUCCESS) { - if (dwType == REG_BINARY || dwType == REG_NONE) { - data = (BYTE*) LocalAlloc(LPTR, size + 8); - if (RegQueryValueExW(hkey, value, NULL, &dwType, (BYTE*) data, &size) == ERROR_SUCCESS) { - if (data != NULL) { - result = (*jEnv)->NewByteArray(jEnv, (jsize) size); - (*jEnv)->SetByteArrayRegion(jEnv, result, 0, (jsize) size, (jbyte*) data); - } - } else { - throwException(jEnv, "Could not read key data"); - } - FREE(data); - } else { - throwException(jEnv, "Value is of wrong type"); - } - } else { - throwException(jEnv, "Could not read key data"); - } - } else { - throwException(jEnv, "Could not open key"); - } - - if (hkey != 0) { - RegCloseKey(hkey); - } - - FREE(key); - FREE(value); - - return result; -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setBinaryValue0(JNIEnv *jEnv, jobject jObject, jint jMode, jint jSection, jstring jKey, jstring jName, jbyteArray jValue) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - BYTE* data = (BYTE*) (*jEnv)->GetByteArrayElements(jEnv, jValue, 0); - DWORD length = (*jEnv)->GetArrayLength(jEnv, jValue); - - if (!setValue(getMode(jMode),getHKEY(jSection), key, name, REG_BINARY, data, length, 0)) { - throwException(jEnv, "Cannot set value"); - } - - FREE(key); - FREE(name); - if (data != NULL) { - (*jEnv)->ReleaseByteArrayElements(jEnv, jValue, (jbyte*) data, JNI_ABORT); - } -} - -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setNoneValue0(JNIEnv *jEnv, jobject jobj, jint jMode, jint jSection, jstring jKey, jstring jName, jbyteArray jValue) { - unsigned short* key = getWideChars(jEnv, jKey); - unsigned short* name = getWideChars(jEnv, jName); - BYTE* data = (BYTE*) (*jEnv)->GetByteArrayElements(jEnv, jValue, 0); - DWORD length = (*jEnv)->GetArrayLength(jEnv, jValue); - - if (!setValue(getMode(jMode),getHKEY(jSection), key, name, REG_NONE, data, length, 0)) { - throwException(jEnv, "Cannot set value"); - } - - FREE(key); - FREE(name); - if (data != NULL) { - (*jEnv)->ReleaseByteArrayElements(jEnv, jValue, (jbyte*) data, JNI_ABORT); - } -} - -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_IsWow64Process0(JNIEnv *jEnv, jobject jObject) { - typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); - LPFN_ISWOW64PROCESS fnIsWow64Process; - BOOL IsWow64 = FALSE; - - fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); - - if (NULL != fnIsWow64Process) - { - if (!fnIsWow64Process(GetCurrentProcess(),&IsWow64)) - { - } - } - return IsWow64; -} diff --git a/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.h b/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.h deleted file mode 100644 index 1bf9addca013..000000000000 --- a/nbi/engine/native/jnilib/windows/src/jni_WindowsRegistry.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -/* Header for class org_netbeans_installer_utils_system_windows_WindowsRegistry */ - -#ifndef _Included_org_netbeans_installer_utils_system_windows_WindowsRegistry -#define _Included_org_netbeans_installer_utils_system_windows_WindowsRegistry -#ifdef __cplusplus -extern "C" { -#endif -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CLASSES_ROOT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CLASSES_ROOT 0L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_USER -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_USER 1L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_LOCAL_MACHINE -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_LOCAL_MACHINE 2L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_USERS -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_USERS 3L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_CONFIG -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_CURRENT_CONFIG 4L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_DYN_DATA -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_DYN_DATA 5L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_DATA -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_DATA 6L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_NLSTEXT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_NLSTEXT 7L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_TEXT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKEY_PERFORMANCE_TEXT 8L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKCR -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKCR 0L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKCU -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKCU 1L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_HKLM -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_HKLM 2L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_NONE -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_NONE 0L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_SZ -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_SZ 1L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_EXPAND_SZ -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_EXPAND_SZ 2L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_BINARY -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_BINARY 3L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD_LITTLE_ENDIAN -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD_LITTLE_ENDIAN 4L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD 4L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD_BIG_ENDIAN -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_DWORD_BIG_ENDIAN 5L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_LINK -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_LINK 6L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_MULTI_SZ -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_MULTI_SZ 7L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_RESOURCE_LIST -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_RESOURCE_LIST 8L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_FULL_RESOURCE_DESCRIPTOR -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_FULL_RESOURCE_DESCRIPTOR 9L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_RESOURCE_REQUIREMENTS_LIST -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_RESOURCE_REQUIREMENTS_LIST 10L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_QWORD_LITTLE_ENDIAN -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_QWORD_LITTLE_ENDIAN 11L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_QWORD -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_REG_QWORD 11L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_DEFAULT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_DEFAULT 0L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_32BIT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_32BIT 1L -#undef org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_64BIT -#define org_netbeans_installer_utils_system_windows_WindowsRegistry_MODE_64BIT 2L -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: checkKeyAccess0 - * Signature: (IILjava/lang/String;I;)Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_checkKeyAccess0 - (JNIEnv *, jobject, jint, jint, jstring, jint); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: valueExists0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_valueExists0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: keyEmpty0 - * Signature: (IILjava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_keyEmpty0 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: countSubKeys0 - * Signature: (IILjava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_countSubKeys0 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: countValues0 - * Signature: (IILjava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_countValues0 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getSubkeyNames0 - * Signature: (IILjava/lang/String;)[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getSubkeyNames0 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getValueNames0 - * Signature: (IILjava/lang/String;)[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getValueNames0 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getValueType0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getValueType0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: createKey0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_createKey0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: deleteKey0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_deleteKey0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: deleteValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_deleteValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getStringValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getStringValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jboolean); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: setStringValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setStringValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jstring, jboolean); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: get32BitValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_get32BitValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: set32BitValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_set32BitValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jint); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getMultiStringValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getMultiStringValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: setMultiStringValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setMultiStringValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jobjectArray); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: getBinaryValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;)[B - */ -JNIEXPORT jbyteArray JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_getBinaryValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: setBinaryValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;[B)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setBinaryValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jbyteArray); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: setNoneValue0 - * Signature: (IILjava/lang/String;Ljava/lang/String;[B)V - */ -JNIEXPORT void JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_setNoneValue0 - (JNIEnv *, jobject, jint, jint, jstring, jstring, jbyteArray); - -/* - * Class: org_netbeans_installer_utils_system_windows_WindowsRegistry - * Method: IsWow64Process0 - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_IsWow64Process0 - (JNIEnv *, jobject); - - -#ifndef KEY_WOW64_32KEY -#define KEY_WOW64_32KEY 0x0200 -#endif -#ifndef KEY_WOW64_64KEY -#define KEY_WOW64_64KEY 0x0100 -#endif - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.ncb b/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.ncb deleted file mode 100644 index 9057ebacbf8c..000000000000 --- a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.ncb +++ /dev/null @@ -1 +0,0 @@ -Microsoft C/C++ MSF 7.00 diff --git a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.sln b/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.sln deleted file mode 100644 index 4410e6f719f0..000000000000 --- a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NBI JNI Library", "NBI JNI Library.vcproj", "{AF9FBB45-6887-41CE-8DC2-915C5FB2AD45}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Default-32bit|Windows = Default-32bit|Windows - Default-64bit|Windows = Default-64bit|Windows - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF9FBB45-6887-41CE-8DC2-915C5FB2AD45}.Default-32bit|Windows.ActiveCfg = Default-32bit|Win32 - {AF9FBB45-6887-41CE-8DC2-915C5FB2AD45}.Default-32bit|Windows.Build.0 = Default-32bit|Win32 - {AF9FBB45-6887-41CE-8DC2-915C5FB2AD45}.Default-64bit|Windows.ActiveCfg = Default-32bit|Win32 - {AF9FBB45-6887-41CE-8DC2-915C5FB2AD45}.Default-64bit|Windows.Build.0 = Default-32bit|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.suo b/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.suo deleted file mode 100644 index 8a450573de0c..000000000000 Binary files a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.suo and /dev/null differ diff --git a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj b/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj deleted file mode 100644 index 4cbd1b736b43..000000000000 --- a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj.user b/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj.user deleted file mode 100644 index a5ca4f998dec..000000000000 --- a/nbi/engine/native/jnilib/windows/vcproject/NBI JNI Library.vcproj.user +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/nbi/engine/native/jnilib/windows/vcproject/vc80.idb b/nbi/engine/native/jnilib/windows/vcproject/vc80.idb deleted file mode 100644 index 3169052dc2e3..000000000000 Binary files a/nbi/engine/native/jnilib/windows/vcproject/vc80.idb and /dev/null differ diff --git a/nbi/engine/native/launcher/unix/i18n/launcher.properties b/nbi/engine/native/launcher/unix/i18n/launcher.properties deleted file mode 100644 index 73e6c6e14319..000000000000 --- a/nbi/engine/native/launcher/unix/i18n/launcher.properties +++ /dev/null @@ -1,51 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -nlu.jvm.notfoundmessage=Java SE Development Kit (JDK) was not found on this computer\nJDK 8 is required for installing the NetBeans IDE. Make sure that the JDK is properly installed and run installer again.\nYou can specify valid JDK location using {0} installer argument.\n\nTo download the JDK, visit http://www.oracle.com/technetwork/java/javase/downloads -nlu.jvm.usererror=Java Runtime Environment (JRE) was not found at the specified location {0} -nlu.jvm.uncompatible=Unsupported JVM version at {0}.\nTry to specify another JVM location using parameter {1} -nlu.freespace=There is not enough free disk space to extract installation data\n{0} MB of free disk space is required in a temporary folder.\nClean up the disk space and run installer again. You can specify a temporary folder with sufficient disk space using {1} installer argument -nlu.integrity=\nInstaller file {0} seems to be corrupted -nlu.missing.external.resource=Can`t run NetBeans Installer.\nAn external file with necessary data is required but missing:\n{0} -nlu.cannot.create.tmpdir=Cannot create temporary directory {0} -nlu.cannot.extract.bundled.jvm=Cannot prepare bundled JVM to run the installer.\nMost probably the bundled JVM is not compatible with the current platform.\nSee FAQ at http://wiki.netbeans.org/FaqUnableToPrepareBundledJdk for more information. -nlu.cannot.unpack.jvm.file=Cannot unpack file {0} -nlu.error.verify.bundled.jvm=Cannot verify bundled JVM, try to search JVM on the system - -nlu.running=Running the installer wizard... -nlu.starting=Configuring the installer... -nlu.extracting=Extracting installation data... -nlu.prepare.jvm=Preparing bundled JVM ... -nlu.jvm.search=Searching for JVM on the system... - -nlu.msg.usage=\nUsage: -nlu.arg.javahome=\t{0}\t\tUsing java from for running application -nlu.arg.verbose=\t{0}\t\tUse verbose output -nlu.arg.output=\t{0}\t\tRedirect all output to file -nlu.arg.disable.space.check=\t{0}\t\tDisable free space check -nlu.arg.extract=\t{0}\t[dir]\tExtract all bundled data to .\n\t\t\t\tIf is not specified then extract to the current directory -nlu.arg.tempdir=\t{0}\t\tUse for extracting temporary data -nlu.arg.cpa=\t{0} \tAppend classpath with -nlu.arg.cpp=\t{0} \tPrepend classpath with -nlu.arg.locale=\t{0}\t\tOverride default locale with specified -nlu.arg.silent=\t{0}\t\tRun installer silently -nlu.arg.help=\t{0}\t\tShow this help - - -nlu.java.application.name.macosx=NetBeans IDE Installer diff --git a/nbi/engine/native/launcher/unix/src/launcher.sh b/nbi/engine/native/launcher/unix/src/launcher.sh deleted file mode 100644 index 5a6fc1323807..000000000000 --- a/nbi/engine/native/launcher/unix/src/launcher.sh +++ /dev/null @@ -1,1665 +0,0 @@ -#!/bin/sh -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -ARG_JAVAHOME="--javahome" -ARG_VERBOSE="--verbose" -ARG_OUTPUT="--output" -ARG_EXTRACT="--extract" -ARG_JAVA_ARG_PREFIX="-J" -ARG_TEMPDIR="--tempdir" -ARG_CLASSPATHA="--classpath-append" -ARG_CLASSPATHP="--classpath-prepend" -ARG_HELP="--help" -ARG_SILENT="--silent" -ARG_NOSPACECHECK="--nospacecheck" -ARG_LOCALE="--locale" - -USE_DEBUG_OUTPUT=0 -PERFORM_FREE_SPACE_CHECK=1 -SILENT_MODE=0 -EXTRACT_ONLY=0 -SHOW_HELP_ONLY=0 -LOCAL_OVERRIDDEN=0 -APPEND_CP= -PREPEND_CP= -LAUNCHER_APP_ARGUMENTS= -LAUNCHER_JVM_ARGUMENTS= -ERROR_OK=0 -ERROR_TEMP_DIRECTORY=2 -ERROR_TEST_JVM_FILE=3 -ERROR_JVM_NOT_FOUND=4 -ERROR_JVM_UNCOMPATIBLE=5 -ERROR_EXTRACT_ONLY=6 -ERROR_INPUTOUPUT=7 -ERROR_FREESPACE=8 -ERROR_INTEGRITY=9 -ERROR_MISSING_RESOURCES=10 -ERROR_JVM_EXTRACTION=11 -ERROR_JVM_UNPACKING=12 -ERROR_VERIFY_BUNDLED_JVM=13 - -VERIFY_OK=1 -VERIFY_NOJAVA=2 -VERIFY_UNCOMPATIBLE=3 - -MSG_ERROR_JVM_NOT_FOUND="nlu.jvm.notfoundmessage" -MSG_ERROR_USER_ERROR="nlu.jvm.usererror" -MSG_ERROR_JVM_UNCOMPATIBLE="nlu.jvm.uncompatible" -MSG_ERROR_INTEGRITY="nlu.integrity" -MSG_ERROR_FREESPACE="nlu.freespace" -MSG_ERROP_MISSING_RESOURCE="nlu.missing.external.resource" -MSG_ERROR_TMPDIR="nlu.cannot.create.tmpdir" - -MSG_ERROR_EXTRACT_JVM="nlu.cannot.extract.bundled.jvm" -MSG_ERROR_UNPACK_JVM_FILE="nlu.cannot.unpack.jvm.file" -MSG_ERROR_VERIFY_BUNDLED_JVM="nlu.error.verify.bundled.jvm" - -MSG_RUNNING="nlu.running" -MSG_STARTING="nlu.starting" -MSG_EXTRACTING="nlu.extracting" -MSG_PREPARE_JVM="nlu.prepare.jvm" -MSG_JVM_SEARCH="nlu.jvm.search" -MSG_ARG_JAVAHOME="nlu.arg.javahome" -MSG_ARG_VERBOSE="nlu.arg.verbose" -MSG_ARG_OUTPUT="nlu.arg.output" -MSG_ARG_EXTRACT="nlu.arg.extract" -MSG_ARG_TEMPDIR="nlu.arg.tempdir" -MSG_ARG_CPA="nlu.arg.cpa" -MSG_ARG_CPP="nlu.arg.cpp" -MSG_ARG_DISABLE_FREE_SPACE_CHECK="nlu.arg.disable.space.check" -MSG_ARG_LOCALE="nlu.arg.locale" -MSG_ARG_SILENT="nlu.arg.silent" -MSG_ARG_HELP="nlu.arg.help" -MSG_USAGE="nlu.msg.usage" - -isSymlink= - -entryPoint() { - initSymlinkArgument - CURRENT_DIRECTORY=`pwd` - LAUNCHER_NAME=`echo $0` - parseCommandLineArguments "$@" - initializeVariables - setLauncherLocale - debugLauncherArguments "$@" - if [ 1 -eq $SHOW_HELP_ONLY ] ; then - showHelp - fi - - message "$MSG_STARTING" - createTempDirectory - checkFreeSpace "$TOTAL_BUNDLED_FILES_SIZE" "$LAUNCHER_EXTRACT_DIR" - - extractJVMData - if [ 0 -eq $EXTRACT_ONLY ] ; then - searchJava - fi - - extractBundledData - verifyIntegrity - - if [ 0 -eq $EXTRACT_ONLY ] ; then - executeMainClass - else - exitProgram $ERROR_OK - fi -} - -initSymlinkArgument() { - testSymlinkErr=`test -L / 2>&1 > /dev/null` - if [ -z "$testSymlinkErr" ] ; then - isSymlink=-L - else - isSymlink=-h - fi -} - -debugLauncherArguments() { - debug "Launcher Command : $0" - argCounter=1 - while [ $# != 0 ] ; do - debug "... argument [$argCounter] = $1" - argCounter=`expr "$argCounter" + 1` - shift - done -} -isLauncherCommandArgument() { - case "$1" in - $ARG_VERBOSE | $ARG_NOSPACECHECK | $ARG_OUTPUT | $ARG_HELP | $ARG_JAVAHOME | $ARG_TEMPDIR | $ARG_EXTRACT | $ARG_SILENT | $ARG_LOCALE | $ARG_CLASSPATHP | $ARG_CLASSPATHA) - echo 1 - ;; - *) - echo 0 - ;; - esac -} - -parseCommandLineArguments() { - while [ $# != 0 ] - do - case "$1" in - $ARG_VERBOSE) - USE_DEBUG_OUTPUT=1;; - $ARG_NOSPACECHECK) - PERFORM_FREE_SPACE_CHECK=0 - parseJvmAppArgument "$1" - ;; - $ARG_OUTPUT) - if [ -n "$2" ] ; then - OUTPUT_FILE="$2" - if [ -f "$OUTPUT_FILE" ] ; then - # clear output file first - rm -f "$OUTPUT_FILE" > /dev/null 2>&1 - touch "$OUTPUT_FILE" - fi - shift - fi - ;; - $ARG_HELP) - SHOW_HELP_ONLY=1 - ;; - $ARG_JAVAHOME) - if [ -n "$2" ] ; then - LAUNCHER_JAVA="$2" - shift - fi - ;; - $ARG_TEMPDIR) - if [ -n "$2" ] ; then - LAUNCHER_JVM_TEMP_DIR="$2" - shift - fi - ;; - $ARG_EXTRACT) - EXTRACT_ONLY=1 - if [ -n "$2" ] && [ `isLauncherCommandArgument "$2"` -eq 0 ] ; then - LAUNCHER_EXTRACT_DIR="$2" - shift - else - LAUNCHER_EXTRACT_DIR="$CURRENT_DIRECTORY" - fi - ;; - $ARG_SILENT) - SILENT_MODE=1 - parseJvmAppArgument "$1" - ;; - $ARG_LOCALE) - SYSTEM_LOCALE="$2" - LOCAL_OVERRIDDEN=1 - parseJvmAppArgument "$1" - ;; - $ARG_CLASSPATHP) - if [ -n "$2" ] ; then - if [ -z "$PREPEND_CP" ] ; then - PREPEND_CP="$2" - else - PREPEND_CP="$2":"$PREPEND_CP" - fi - shift - fi - ;; - $ARG_CLASSPATHA) - if [ -n "$2" ] ; then - if [ -z "$APPEND_CP" ] ; then - APPEND_CP="$2" - else - APPEND_CP="$APPEND_CP":"$2" - fi - shift - fi - ;; - - *) - parseJvmAppArgument "$1" - esac - shift - done -} - -setLauncherLocale() { - if [ 0 -eq $LOCAL_OVERRIDDEN ] ; then - SYSTEM_LOCALE="$LANG" - debug "Setting initial launcher locale from the system : $SYSTEM_LOCALE" - else - debug "Setting initial launcher locale using command-line argument : $SYSTEM_LOCALE" - fi - - LAUNCHER_LOCALE="$SYSTEM_LOCALE" - - if [ -n "$LAUNCHER_LOCALE" ] ; then - # check if $LAUNCHER_LOCALE is in UTF-8 - if [ 0 -eq $LOCAL_OVERRIDDEN ] ; then - removeUTFsuffix=`echo "$LAUNCHER_LOCALE" | sed "s/\.UTF-8//"` - isUTF=`ifEquals "$removeUTFsuffix" "$LAUNCHER_LOCALE"` - if [ 1 -eq $isUTF ] ; then - #set launcher locale to the default if the system locale name doesn`t containt UTF-8 - LAUNCHER_LOCALE="" - fi - fi - - localeChanged=0 - localeCounter=0 - while [ $localeCounter -lt $LAUNCHER_LOCALES_NUMBER ] ; do - localeVar="$""LAUNCHER_LOCALE_NAME_$localeCounter" - arg=`eval "echo \"$localeVar\""` - if [ -n "$arg" ] ; then - # if not a default locale - # $comp length shows the difference between $SYSTEM_LOCALE and $arg - # the less the length the less the difference and more coincedence - - comp=`echo "$SYSTEM_LOCALE" | sed -e "s/^${arg}//"` - length1=`getStringLength "$comp"` - length2=`getStringLength "$LAUNCHER_LOCALE"` - if [ $length1 -lt $length2 ] ; then - # more coincidence between $SYSTEM_LOCALE and $arg than between $SYSTEM_LOCALE and $arg - compare=`ifLess "$comp" "$LAUNCHER_LOCALE"` - - if [ 1 -eq $compare ] ; then - LAUNCHER_LOCALE="$arg" - localeChanged=1 - debug "... setting locale to $arg" - fi - if [ -z "$comp" ] ; then - # means that $SYSTEM_LOCALE equals to $arg - break - fi - fi - else - comp="$SYSTEM_LOCALE" - fi - localeCounter=`expr "$localeCounter" + 1` - done - if [ $localeChanged -eq 0 ] ; then - #set default - LAUNCHER_LOCALE="" - fi - fi - - - debug "Final Launcher Locale : $LAUNCHER_LOCALE" -} - -escapeBackslash() { - echo "$1" | sed "s/\\\/\\\\\\\/g" -} - -ifLess() { - arg1=`escapeBackslash "$1"` - arg2=`escapeBackslash "$2"` - compare=`awk 'END { if ( a < b ) { print 1 } else { print 0 } }' a="$arg1" b="$arg2" < /dev/null` - echo $compare -} - -formatVersion() { - formatted=`echo "$1" | sed "s/-ea//g;s/-rc[0-9]*//g;s/-beta[0-9]*//g;s/-preview[0-9]*//g;s/-dp[0-9]*//g;s/-alpha[0-9]*//g;s/-fcs//g;s/_/./g;s/-/\./g"` - formatted=`echo "$formatted" | sed "s/^\(\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)\)\.b\([0-9][0-9]*\)/\1\.0\.\5/g"` - formatted=`echo "$formatted" | sed "s/\.b\([0-9][0-9]*\)/\.\1/g"` - echo "$formatted" - -} - -compareVersions() { - current1=`formatVersion "$1"` - current2=`formatVersion "$2"` - compresult= - #0 - equals - #-1 - less - #1 - more - - while [ -z "$compresult" ] ; do - value1=`echo "$current1" | sed "s/\..*//g"` - value2=`echo "$current2" | sed "s/\..*//g"` - - - removeDots1=`echo "$current1" | sed "s/\.//g"` - removeDots2=`echo "$current2" | sed "s/\.//g"` - - if [ 1 -eq `ifEquals "$current1" "$removeDots1"` ] ; then - remainder1="" - else - remainder1=`echo "$current1" | sed "s/^$value1\.//g"` - fi - if [ 1 -eq `ifEquals "$current2" "$removeDots2"` ] ; then - remainder2="" - else - remainder2=`echo "$current2" | sed "s/^$value2\.//g"` - fi - - current1="$remainder1" - current2="$remainder2" - - if [ -z "$value1" ] || [ 0 -eq `ifNumber "$value1"` ] ; then - value1=0 - fi - if [ -z "$value2" ] || [ 0 -eq `ifNumber "$value2"` ] ; then - value2=0 - fi - if [ "$value1" -gt "$value2" ] ; then - compresult=1 - break - elif [ "$value2" -gt "$value1" ] ; then - compresult=-1 - break - fi - - if [ -z "$current1" ] && [ -z "$current2" ] ; then - compresult=0 - break - fi - done - echo $compresult -} - -ifVersionLess() { - compareResult=`compareVersions "$1" "$2"` - if [ -1 -eq $compareResult ] ; then - echo 1 - else - echo 0 - fi -} - -ifVersionGreater() { - compareResult=`compareVersions "$1" "$2"` - if [ 1 -eq $compareResult ] ; then - echo 1 - else - echo 0 - fi -} - -ifGreater() { - arg1=`escapeBackslash "$1"` - arg2=`escapeBackslash "$2"` - - compare=`awk 'END { if ( a > b ) { print 1 } else { print 0 } }' a="$arg1" b="$arg2" < /dev/null` - echo $compare -} - -ifEquals() { - arg1=`escapeBackslash "$1"` - arg2=`escapeBackslash "$2"` - - compare=`awk 'END { if ( a == b ) { print 1 } else { print 0 } }' a="$arg1" b="$arg2" < /dev/null` - echo $compare -} - -ifNumber() -{ - result=0 - if [ -n "$1" ] ; then - num=`echo "$1" | sed 's/[0-9]*//g' 2>/dev/null` - if [ -z "$num" ] ; then - result=1 - fi - fi - echo $result -} -getStringLength() { - strlength=`awk 'END{ print length(a) }' a="$1" < /dev/null` - echo $strlength -} - -resolveRelativity() { - if [ 1 -eq `ifPathRelative "$1"` ] ; then - echo "$CURRENT_DIRECTORY"/"$1" | sed 's/\"//g' 2>/dev/null - else - echo "$1" - fi -} - -ifPathRelative() { - param="$1" - removeRoot=`echo "$param" | sed "s/^\\\///" 2>/dev/null` - echo `ifEquals "$param" "$removeRoot"` 2>/dev/null -} - - -initializeVariables() { - debug "Launcher name is $LAUNCHER_NAME" - systemName=`uname` - debug "System name is $systemName" - isMacOSX=`ifEquals "$systemName" "Darwin"` - isSolaris=`ifEquals "$systemName" "SunOS"` - if [ 1 -eq $isSolaris ] ; then - POSSIBLE_JAVA_EXE_SUFFIX="$POSSIBLE_JAVA_EXE_SUFFIX_SOLARIS" - else - POSSIBLE_JAVA_EXE_SUFFIX="$POSSIBLE_JAVA_EXE_SUFFIX_COMMON" - fi - if [ 1 -eq $isMacOSX ] ; then - # set default userdir and cachedir on MacOS - DEFAULT_USERDIR_ROOT="${HOME}/Library/Application Support/NetBeans" - DEFAULT_CACHEDIR_ROOT="${HOME}/Library/Caches/NetBeans" - else - # set default userdir and cachedir on unix systems - DEFAULT_USERDIR_ROOT=${HOME}/.netbeans - DEFAULT_CACHEDIR_ROOT=${HOME}/.cache/netbeans - fi - systemInfo=`uname -a 2>/dev/null` - debug "System Information:" - debug "$systemInfo" - debug "" - DEFAULT_DISK_BLOCK_SIZE=512 - LAUNCHER_TRACKING_SIZE=$LAUNCHER_STUB_SIZE - LAUNCHER_TRACKING_SIZE_BYTES=`expr "$LAUNCHER_STUB_SIZE" \* "$FILE_BLOCK_SIZE"` - getLauncherLocation -} - -parseJvmAppArgument() { - param="$1" - arg=`echo "$param" | sed "s/^-J//"` - argEscaped=`escapeString "$arg"` - - if [ "$param" = "$arg" ] ; then - LAUNCHER_APP_ARGUMENTS="$LAUNCHER_APP_ARGUMENTS $argEscaped" - else - LAUNCHER_JVM_ARGUMENTS="$LAUNCHER_JVM_ARGUMENTS $argEscaped" - fi -} - -getLauncherLocation() { - # if file path is relative then prepend it with current directory - LAUNCHER_FULL_PATH=`resolveRelativity "$LAUNCHER_NAME"` - debug "... normalizing full path" - LAUNCHER_FULL_PATH=`normalizePath "$LAUNCHER_FULL_PATH"` - debug "... getting dirname" - LAUNCHER_DIR=`dirname "$LAUNCHER_FULL_PATH"` - debug "Full launcher path = $LAUNCHER_FULL_PATH" - debug "Launcher directory = $LAUNCHER_DIR" -} - -getLauncherSize() { - lsOutput=`ls -l --block-size=1 "$LAUNCHER_FULL_PATH" 2>/dev/null` - if [ $? -ne 0 ] ; then - #default block size - lsOutput=`ls -l "$LAUNCHER_FULL_PATH" 2>/dev/null` - fi - echo "$lsOutput" | awk ' { print $5 }' 2>/dev/null -} - -verifyIntegrity() { - size=`getLauncherSize` - extractedSize=$LAUNCHER_TRACKING_SIZE_BYTES - if [ 1 -eq `ifNumber "$size"` ] ; then - debug "... check integrity" - debug "... minimal size : $extractedSize" - debug "... real size : $size" - - if [ $size -lt $extractedSize ] ; then - debug "... integration check FAILED" - message "$MSG_ERROR_INTEGRITY" `normalizePath "$LAUNCHER_FULL_PATH"` - exitProgram $ERROR_INTEGRITY - fi - debug "... integration check OK" - fi -} -showHelp() { - msg0=`message "$MSG_USAGE"` - msg1=`message "$MSG_ARG_JAVAHOME $ARG_JAVAHOME"` - msg2=`message "$MSG_ARG_TEMPDIR $ARG_TEMPDIR"` - msg3=`message "$MSG_ARG_EXTRACT $ARG_EXTRACT"` - msg4=`message "$MSG_ARG_OUTPUT $ARG_OUTPUT"` - msg5=`message "$MSG_ARG_VERBOSE $ARG_VERBOSE"` - msg6=`message "$MSG_ARG_CPA $ARG_CLASSPATHA"` - msg7=`message "$MSG_ARG_CPP $ARG_CLASSPATHP"` - msg8=`message "$MSG_ARG_DISABLE_FREE_SPACE_CHECK $ARG_NOSPACECHECK"` - msg9=`message "$MSG_ARG_LOCALE $ARG_LOCALE"` - msg10=`message "$MSG_ARG_SILENT $ARG_SILENT"` - msg11=`message "$MSG_ARG_HELP $ARG_HELP"` - out "$msg0" - out "$msg1" - out "$msg2" - out "$msg3" - out "$msg4" - out "$msg5" - out "$msg6" - out "$msg7" - out "$msg8" - out "$msg9" - out "$msg10" - out "$msg11" - exitProgram $ERROR_OK -} - -exitProgram() { - if [ 0 -eq $EXTRACT_ONLY ] ; then - if [ -n "$LAUNCHER_EXTRACT_DIR" ] && [ -d "$LAUNCHER_EXTRACT_DIR" ]; then - debug "Removing directory $LAUNCHER_EXTRACT_DIR" - rm -rf "$LAUNCHER_EXTRACT_DIR" > /dev/null 2>&1 - fi - fi - debug "exitCode = $1" - exit $1 -} - -debug() { - if [ $USE_DEBUG_OUTPUT -eq 1 ] ; then - timestamp=`date '+%Y-%m-%d %H:%M:%S'` - out "[$timestamp]> $1" - fi -} - -out() { - - if [ -n "$OUTPUT_FILE" ] ; then - printf "%s\n" "$@" >> "$OUTPUT_FILE" - elif [ 0 -eq $SILENT_MODE ] ; then - printf "%s\n" "$@" - fi -} - -message() { - msg=`getMessage "$@"` - out "$msg" -} - - -createTempDirectory() { - if [ 0 -eq $EXTRACT_ONLY ] ; then - if [ -z "$LAUNCHER_JVM_TEMP_DIR" ] ; then - if [ 0 -eq $EXTRACT_ONLY ] ; then - if [ -n "$TEMP" ] && [ -d "$TEMP" ] ; then - debug "TEMP var is used : $TEMP" - LAUNCHER_JVM_TEMP_DIR="$TEMP" - elif [ -n "$TMP" ] && [ -d "$TMP" ] ; then - debug "TMP var is used : $TMP" - LAUNCHER_JVM_TEMP_DIR="$TMP" - elif [ -n "$TEMPDIR" ] && [ -d "$TEMPDIR" ] ; then - debug "TEMPDIR var is used : $TEMPDIR" - LAUNCHER_JVM_TEMP_DIR="$TEMPDIR" - elif [ -d "/tmp" ] ; then - debug "Using /tmp for temp" - LAUNCHER_JVM_TEMP_DIR="/tmp" - else - debug "Using home dir for temp" - LAUNCHER_JVM_TEMP_DIR="$HOME" - fi - else - #extract only : to the curdir - LAUNCHER_JVM_TEMP_DIR="$CURRENT_DIRECTORY" - fi - fi - # if temp dir does not exist then try to create it - if [ ! -d "$LAUNCHER_JVM_TEMP_DIR" ] ; then - mkdir -p "$LAUNCHER_JVM_TEMP_DIR" > /dev/null 2>&1 - if [ $? -ne 0 ] ; then - message "$MSG_ERROR_TMPDIR" "$LAUNCHER_JVM_TEMP_DIR" - exitProgram $ERROR_TEMP_DIRECTORY - fi - fi - debug "Launcher TEMP ROOT = $LAUNCHER_JVM_TEMP_DIR" - subDir=`date '+%u%m%M%S'` - subDir=`echo ".nbi-$subDir.tmp"` - LAUNCHER_EXTRACT_DIR="$LAUNCHER_JVM_TEMP_DIR/$subDir" - else - #extracting to the $LAUNCHER_EXTRACT_DIR - debug "Launcher Extracting ROOT = $LAUNCHER_EXTRACT_DIR" - fi - - if [ ! -d "$LAUNCHER_EXTRACT_DIR" ] ; then - mkdir -p "$LAUNCHER_EXTRACT_DIR" > /dev/null 2>&1 - if [ $? -ne 0 ] ; then - message "$MSG_ERROR_TMPDIR" "$LAUNCHER_EXTRACT_DIR" - exitProgram $ERROR_TEMP_DIRECTORY - fi - else - debug "$LAUNCHER_EXTRACT_DIR is directory and exist" - fi - debug "Using directory $LAUNCHER_EXTRACT_DIR for extracting data" -} -extractJVMData() { - debug "Extracting testJVM file data..." - extractTestJVMFile - debug "Extracting bundled JVMs ..." - extractJVMFiles - debug "Extracting JVM data done" -} -extractBundledData() { - message "$MSG_EXTRACTING" - debug "Extracting bundled jars data..." - extractJars - debug "Extracting other data..." - extractOtherData - debug "Extracting bundled data finished..." -} - -setTestJVMClasspath() { - testjvmname=`basename "$TEST_JVM_PATH"` - removeClassSuffix=`echo "$testjvmname" | sed 's/\.class$//'` - notClassFile=`ifEquals "$testjvmname" "$removeClassSuffix"` - - if [ -d "$TEST_JVM_PATH" ] ; then - TEST_JVM_CLASSPATH="$TEST_JVM_PATH" - debug "... testJVM path is a directory" - elif [ $isSymlink "$TEST_JVM_PATH" ] && [ $notClassFile -eq 1 ] ; then - TEST_JVM_CLASSPATH="$TEST_JVM_PATH" - debug "... testJVM path is a link but not a .class file" - else - if [ $notClassFile -eq 1 ] ; then - debug "... testJVM path is a jar/zip file" - TEST_JVM_CLASSPATH="$TEST_JVM_PATH" - else - debug "... testJVM path is a .class file" - TEST_JVM_CLASSPATH=`dirname "$TEST_JVM_PATH"` - fi - fi - debug "... testJVM classpath is : $TEST_JVM_CLASSPATH" -} - -extractTestJVMFile() { - TEST_JVM_PATH=`resolveResourcePath "TEST_JVM_FILE"` - extractResource "TEST_JVM_FILE" - setTestJVMClasspath - -} - -installJVM() { - message "$MSG_PREPARE_JVM" - jvmFile=`resolveRelativity "$1"` - jvmDir=`dirname "$jvmFile"`/_jvm - debug "JVM Directory : $jvmDir" - mkdir "$jvmDir" > /dev/null 2>&1 - if [ $? != 0 ] ; then - message "$MSG_ERROR_EXTRACT_JVM" - exitProgram $ERROR_JVM_EXTRACTION - fi - chmod +x "$jvmFile" > /dev/null 2>&1 - jvmFileEscaped=`escapeString "$jvmFile"` - jvmDirEscaped=`escapeString "$jvmDir"` - cd "$jvmDir" - runCommand "$jvmFileEscaped" - ERROR_CODE=$? - - cd "$CURRENT_DIRECTORY" - - if [ $ERROR_CODE != 0 ] ; then - message "$MSG_ERROR_EXTRACT_JVM" - exitProgram $ERROR_JVM_EXTRACTION - fi - - files=`find "$jvmDir" -name "*.jar.pack.gz" -print` - debug "Packed files : $files" - f="$files" - fileCounter=1; - while [ -n "$f" ] ; do - f=`echo "$files" | sed -n "${fileCounter}p" 2>/dev/null` - debug "... next file is $f" - if [ -n "$f" ] ; then - debug "... packed file = $f" - unpacked=`echo "$f" | sed s/\.pack\.gz//` - debug "... unpacked file = $unpacked" - fEsc=`escapeString "$f"` - uEsc=`escapeString "$unpacked"` - cmd="$jvmDirEscaped/bin/unpack200 -r $fEsc $uEsc" - runCommand "$cmd" - if [ $? != 0 ] ; then - message "$MSG_ERROR_UNPACK_JVM_FILE" "$f" - exitProgram $ERROR_JVM_UNPACKING - fi - fi - fileCounter=`expr "$fileCounter" + 1` - done - - verifyJVM "$jvmDir" - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - message "$MSG_ERROR_VERIFY_BUNDLED_JVM" - exitProgram $ERROR_VERIFY_BUNDLED_JVM - fi -} - -resolveResourcePath() { - resourcePrefix="$1" - resourceVar="$""$resourcePrefix""_PATH" - resourceName=`eval "echo \"$resourceVar\""` - resourcePath=`resolveString "$resourceName"` - echo "$resourcePath" - -} - -resolveResourceSize() { - resourcePrefix="$1" - resourceVar="$""$resourcePrefix""_SIZE" - resourceSize=`eval "echo \"$resourceVar\""` - echo "$resourceSize" -} - -resolveResourceMd5() { - resourcePrefix="$1" - resourceVar="$""$resourcePrefix""_MD5" - resourceMd5=`eval "echo \"$resourceVar\""` - echo "$resourceMd5" -} - -resolveResourceType() { - resourcePrefix="$1" - resourceVar="$""$resourcePrefix""_TYPE" - resourceType=`eval "echo \"$resourceVar\""` - echo "$resourceType" -} - -extractResource() { - debug "... extracting resource" - resourcePrefix="$1" - debug "... resource prefix id=$resourcePrefix" - resourceType=`resolveResourceType "$resourcePrefix"` - debug "... resource type=$resourceType" - if [ $resourceType -eq 0 ] ; then - resourceSize=`resolveResourceSize "$resourcePrefix"` - debug "... resource size=$resourceSize" - resourcePath=`resolveResourcePath "$resourcePrefix"` - debug "... resource path=$resourcePath" - extractFile "$resourceSize" "$resourcePath" - resourceMd5=`resolveResourceMd5 "$resourcePrefix"` - debug "... resource md5=$resourceMd5" - checkMd5 "$resourcePath" "$resourceMd5" - debug "... done" - fi - debug "... extracting resource finished" - -} - -extractJars() { - counter=0 - while [ $counter -lt $JARS_NUMBER ] ; do - extractResource "JAR_$counter" - counter=`expr "$counter" + 1` - done -} - -extractOtherData() { - counter=0 - while [ $counter -lt $OTHER_RESOURCES_NUMBER ] ; do - extractResource "OTHER_RESOURCE_$counter" - counter=`expr "$counter" + 1` - done -} - -extractJVMFiles() { - javaCounter=0 - debug "... total number of JVM files : $JAVA_LOCATION_NUMBER" - while [ $javaCounter -lt $JAVA_LOCATION_NUMBER ] ; do - extractResource "JAVA_LOCATION_$javaCounter" - javaCounter=`expr "$javaCounter" + 1` - done -} - - -processJarsClasspath() { - JARS_CLASSPATH="" - jarsCounter=0 - while [ $jarsCounter -lt $JARS_NUMBER ] ; do - resolvedFile=`resolveResourcePath "JAR_$jarsCounter"` - debug "... adding jar to classpath : $resolvedFile" - if [ ! -f "$resolvedFile" ] && [ ! -d "$resolvedFile" ] && [ ! $isSymlink "$resolvedFile" ] ; then - message "$MSG_ERROP_MISSING_RESOURCE" "$resolvedFile" - exitProgram $ERROR_MISSING_RESOURCES - else - if [ -z "$JARS_CLASSPATH" ] ; then - JARS_CLASSPATH="$resolvedFile" - else - JARS_CLASSPATH="$JARS_CLASSPATH":"$resolvedFile" - fi - fi - - jarsCounter=`expr "$jarsCounter" + 1` - done - debug "Jars classpath : $JARS_CLASSPATH" -} - -extractFile() { - start=$LAUNCHER_TRACKING_SIZE - size=$1 #absolute size - name="$2" #relative part - fullBlocks=`expr $size / $FILE_BLOCK_SIZE` - fullBlocksSize=`expr "$FILE_BLOCK_SIZE" \* "$fullBlocks"` - oneBlocks=`expr $size - $fullBlocksSize` - oneBlocksStart=`expr "$start" + "$fullBlocks"` - - checkFreeSpace $size "$name" - LAUNCHER_TRACKING_SIZE_BYTES=`expr "$LAUNCHER_TRACKING_SIZE" \* "$FILE_BLOCK_SIZE"` - - if [ 0 -eq $diskSpaceCheck ] ; then - dir=`dirname "$name"` - message "$MSG_ERROR_FREESPACE" "$size" "$ARG_TEMPDIR" - exitProgram $ERROR_FREESPACE - fi - - if [ 0 -lt "$fullBlocks" ] ; then - # file is larger than FILE_BLOCK_SIZE - dd if="$LAUNCHER_FULL_PATH" of="$name" \ - bs="$FILE_BLOCK_SIZE" count="$fullBlocks" skip="$start"\ - > /dev/null 2>&1 - LAUNCHER_TRACKING_SIZE=`expr "$LAUNCHER_TRACKING_SIZE" + "$fullBlocks"` - LAUNCHER_TRACKING_SIZE_BYTES=`expr "$LAUNCHER_TRACKING_SIZE" \* "$FILE_BLOCK_SIZE"` - fi - if [ 0 -lt "$oneBlocks" ] ; then - dd if="$LAUNCHER_FULL_PATH" of="$name.tmp.tmp" bs="$FILE_BLOCK_SIZE" count=1\ - skip="$oneBlocksStart"\ - > /dev/null 2>&1 - - dd if="$name.tmp.tmp" of="$name" bs=1 count="$oneBlocks" seek="$fullBlocksSize"\ - > /dev/null 2>&1 - - rm -f "$name.tmp.tmp" - LAUNCHER_TRACKING_SIZE=`expr "$LAUNCHER_TRACKING_SIZE" + 1` - - LAUNCHER_TRACKING_SIZE_BYTES=`expr "$LAUNCHER_TRACKING_SIZE_BYTES" + "$oneBlocks"` - fi -} - -md5_program="" -no_md5_program_id="no_md5_program" - -initMD5program() { - if [ -z "$md5_program" ] ; then - type digest >> /dev/null 2>&1 - if [ 0 -eq $? ] ; then - md5_program="digest -a md5" - else - type md5sum >> /dev/null 2>&1 - if [ 0 -eq $? ] ; then - md5_program="md5sum" - else - type gmd5sum >> /dev/null 2>&1 - if [ 0 -eq $? ] ; then - md5_program="gmd5sum" - else - type md5 >> /dev/null 2>&1 - if [ 0 -eq $? ] ; then - md5_program="md5 -q" - else - md5_program="$no_md5_program_id" - fi - fi - fi - fi - debug "... program to check: $md5_program" - fi -} - -checkMd5() { - name="$1" - md5="$2" - if [ 32 -eq `getStringLength "$md5"` ] ; then - #do MD5 check - initMD5program - if [ 0 -eq `ifEquals "$md5_program" "$no_md5_program_id"` ] ; then - debug "... check MD5 of file : $name" - debug "... expected md5: $md5" - realmd5=`$md5_program "$name" 2>/dev/null | sed "s/ .*//g"` - debug "... real md5 : $realmd5" - if [ 32 -eq `getStringLength "$realmd5"` ] ; then - if [ 0 -eq `ifEquals "$md5" "$realmd5"` ] ; then - debug "... integration check FAILED" - message "$MSG_ERROR_INTEGRITY" `normalizePath "$LAUNCHER_FULL_PATH"` - exitProgram $ERROR_INTEGRITY - fi - else - debug "... looks like not the MD5 sum" - fi - fi - fi -} -searchJavaEnvironment() { - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - # search java in the environment - - ptr="$POSSIBLE_JAVA_ENV" - while [ -n "$ptr" ] && [ -z "$LAUNCHER_JAVA_EXE" ] ; do - argJavaHome=`echo "$ptr" | sed "s/:.*//"` - back=`echo "$argJavaHome" | sed "s/\\\//\\\\\\\\\//g"` - end=`echo "$ptr" | sed "s/${back}://"` - argJavaHome=`echo "$back" | sed "s/\\\\\\\\\//\\\//g"` - ptr="$end" - eval evaluated=`echo \\$$argJavaHome` > /dev/null - if [ -n "$evaluated" ] ; then - debug "EnvVar $argJavaHome=$evaluated" - verifyJVM "$evaluated" - fi - done - fi -} - -installBundledJVMs() { - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - # search bundled java in the common list - javaCounter=0 - while [ $javaCounter -lt $JAVA_LOCATION_NUMBER ] && [ -z "$LAUNCHER_JAVA_EXE" ] ; do - fileType=`resolveResourceType "JAVA_LOCATION_$javaCounter"` - - if [ $fileType -eq 0 ] ; then # bundled->install - argJavaHome=`resolveResourcePath "JAVA_LOCATION_$javaCounter"` - installJVM "$argJavaHome" - fi - javaCounter=`expr "$javaCounter" + 1` - done - fi -} - -searchJavaOnMacOs() { - if [ -x "/usr/libexec/java_home" ]; then - javaOnMacHome=`/usr/libexec/java_home --failfast` - fi - - if [ ! -x "$javaOnMacHome/bin/java" -a -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" ] ; then - javaOnMacHome=`echo "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"` - fi - - verifyJVM "$javaOnMacHome" -} - -searchJavaSystemDefault() { - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - debug "... check default java in the path" - java_bin=`which java 2>&1` - if [ $? -eq 0 ] && [ -n "$java_bin" ] ; then - remove_no_java_in=`echo "$java_bin" | sed "s/no java in//g"` - if [ 1 -eq `ifEquals "$remove_no_java_in" "$java_bin"` ] && [ -f "$java_bin" ] ; then - debug "... java in path found: $java_bin" - # java is in path - java_bin=`resolveSymlink "$java_bin"` - debug "... java real path: $java_bin" - parentDir=`dirname "$java_bin"` - if [ -n "$parentDir" ] ; then - parentDir=`dirname "$parentDir"` - if [ -n "$parentDir" ] ; then - debug "... java home path: $parentDir" - parentDir=`resolveSymlink "$parentDir"` - debug "... java home real path: $parentDir" - verifyJVM "$parentDir" - fi - fi - fi - fi - fi -} - -searchJavaSystemPaths() { - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - # search java in the common system paths - javaCounter=0 - while [ $javaCounter -lt $JAVA_LOCATION_NUMBER ] && [ -z "$LAUNCHER_JAVA_EXE" ] ; do - fileType=`resolveResourceType "JAVA_LOCATION_$javaCounter"` - argJavaHome=`resolveResourcePath "JAVA_LOCATION_$javaCounter"` - - debug "... next location $argJavaHome" - - if [ $fileType -ne 0 ] ; then # bundled JVMs have already been proceeded - argJavaHome=`escapeString "$argJavaHome"` - locations=`ls -d -1 $argJavaHome 2>/dev/null` - nextItem="$locations" - itemCounter=1 - while [ -n "$nextItem" ] && [ -z "$LAUNCHER_JAVA_EXE" ] ; do - nextItem=`echo "$locations" | sed -n "${itemCounter}p" 2>/dev/null` - debug "... next item is $nextItem" - nextItem=`removeEndSlashes "$nextItem"` - if [ -n "$nextItem" ] ; then - if [ -d "$nextItem" ] || [ $isSymlink "$nextItem" ] ; then - debug "... checking item : $nextItem" - verifyJVM "$nextItem" - fi - fi - itemCounter=`expr "$itemCounter" + 1` - done - fi - javaCounter=`expr "$javaCounter" + 1` - done - fi -} - -searchJavaUserDefined() { - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - if [ -n "$LAUNCHER_JAVA" ] ; then - verifyJVM "$LAUNCHER_JAVA" - - if [ $VERIFY_UNCOMPATIBLE -eq $verifyResult ] ; then - message "$MSG_ERROR_JVM_UNCOMPATIBLE" "$LAUNCHER_JAVA" "$ARG_JAVAHOME" - exitProgram $ERROR_JVM_UNCOMPATIBLE - elif [ $VERIFY_NOJAVA -eq $verifyResult ] ; then - message "$MSG_ERROR_USER_ERROR" "$LAUNCHER_JAVA" - exitProgram $ERROR_JVM_NOT_FOUND - fi - fi - fi -} - -searchJavaInstallFolder() { - installFolder="`dirname \"$0\"`" - installFolder="`( cd \"$installFolder\" && pwd )`" - installFolder="$installFolder/bin/jre" - tempJreFolder="$TEST_JVM_CLASSPATH/_jvm" - - if [ -d "$installFolder" ] ; then - #copy nested JRE to temp folder - cp -r "$installFolder" "$tempJreFolder" - - verifyJVM "$tempJreFolder" - fi -} - -searchJava() { - message "$MSG_JVM_SEARCH" - if [ ! -f "$TEST_JVM_CLASSPATH" ] && [ ! $isSymlink "$TEST_JVM_CLASSPATH" ] && [ ! -d "$TEST_JVM_CLASSPATH" ]; then - debug "Cannot find file for testing JVM at $TEST_JVM_CLASSPATH" - message "$MSG_ERROR_JVM_NOT_FOUND" "$ARG_JAVAHOME" - exitProgram $ERROR_TEST_JVM_FILE - else - searchJavaInstallFolder - searchJavaUserDefined - installBundledJVMs - searchJavaEnvironment - searchJavaSystemDefault - searchJavaSystemPaths - if [ 1 -eq $isMacOSX ] ; then - searchJavaOnMacOs - fi - fi - - if [ -z "$LAUNCHER_JAVA_EXE" ] ; then - message "$MSG_ERROR_JVM_NOT_FOUND" "$ARG_JAVAHOME" - exitProgram $ERROR_JVM_NOT_FOUND - fi -} - -normalizePath() { - argument="$1" - - # replace all /./ to / - while [ 0 -eq 0 ] ; do - testArgument=`echo "$argument" | sed 's/\/\.\//\//g' 2> /dev/null` - if [ -n "$testArgument" ] && [ 0 -eq `ifEquals "$argument" "$testArgument"` ] ; then - # something changed - argument="$testArgument" - else - break - fi - done - - # replace XXX/../YYY to 'dirname XXX'/YYY - while [ 0 -eq 0 ] ; do - beforeDotDot=`echo "$argument" | sed "s/\/\.\.\/.*//g" 2> /dev/null` - if [ 0 -eq `ifEquals "$beforeDotDot" "$argument"` ] && [ 0 -eq `ifEquals "$beforeDotDot" "."` ] && [ 0 -eq `ifEquals "$beforeDotDot" ".."` ] ; then - esc=`echo "$beforeDotDot" | sed "s/\\\//\\\\\\\\\//g"` - afterDotDot=`echo "$argument" | sed "s/^$esc\/\.\.//g" 2> /dev/null` - parent=`dirname "$beforeDotDot"` - argument=`echo "$parent""$afterDotDot"` - else - break - fi - done - - # replace XXX/.. to 'dirname XXX' - while [ 0 -eq 0 ] ; do - beforeDotDot=`echo "$argument" | sed "s/\/\.\.$//g" 2> /dev/null` - if [ 0 -eq `ifEquals "$beforeDotDot" "$argument"` ] && [ 0 -eq `ifEquals "$beforeDotDot" "."` ] && [ 0 -eq `ifEquals "$beforeDotDot" ".."` ] ; then - argument=`dirname "$beforeDotDot"` - else - break - fi - done - - # remove /. a the end (if the resulting string is not zero) - testArgument=`echo "$argument" | sed 's/\/\.$//' 2> /dev/null` - if [ -n "$testArgument" ] ; then - argument="$testArgument" - fi - - # replace more than 2 separators to 1 - testArgument=`echo "$argument" | sed 's/\/\/*/\//g' 2> /dev/null` - if [ -n "$testArgument" ] ; then - argument="$testArgument" - fi - - echo "$argument" -} - -resolveSymlink() { - pathArg="$1" - while [ $isSymlink "$pathArg" ] ; do - ls=`ls -ld "$pathArg"` - link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null` - - if expr "$link" : '^/' 2> /dev/null >/dev/null; then - pathArg="$link" - else - pathArg="`dirname "$pathArg"`"/"$link" - fi - pathArg=`normalizePath "$pathArg"` - done - echo "$pathArg" -} - -verifyJVM() { - javaTryPath=`normalizePath "$1"` - verifyJavaHome "$javaTryPath" - if [ $VERIFY_OK -ne $verifyResult ] ; then - savedResult=$verifyResult - - if [ 0 -eq $isMacOSX ] ; then - #check private jre - javaTryPath="$javaTryPath""/jre" - verifyJavaHome "$javaTryPath" - else - #check MacOSX Home dir - javaTryPath="$javaTryPath""/Home" - verifyJavaHome "$javaTryPath" - fi - - if [ $VERIFY_NOJAVA -eq $verifyResult ] ; then - verifyResult=$savedResult - fi - fi -} - -removeEndSlashes() { - arg="$1" - tryRemove=`echo "$arg" | sed 's/\/\/*$//' 2>/dev/null` - if [ -n "$tryRemove" ] ; then - arg="$tryRemove" - fi - echo "$arg" -} - -checkJavaHierarchy() { - # return 0 on no java - # return 1 on jre - # return 2 on jdk - - tryJava="$1" - javaHierarchy=0 - if [ -n "$tryJava" ] ; then - if [ -d "$tryJava" ] || [ $isSymlink "$tryJava" ] ; then # existing directory or a isSymlink - javaBin="$tryJava"/"bin" - - if [ -d "$javaBin" ] || [ $isSymlink "$javaBin" ] ; then - javaBinJavac="$javaBin"/"javac" - if [ -f "$javaBinJavac" ] || [ $isSymlink "$javaBinJavac" ] ; then - #definitely JDK as the JRE doesn`t contain javac - javaHierarchy=2 - else - #check if we inside JRE - javaBinJava="$javaBin"/"java" - if [ -f "$javaBinJava" ] || [ $isSymlink "$javaBinJava" ] ; then - javaHierarchy=1 - fi - fi - fi - fi - fi - if [ 0 -eq $javaHierarchy ] ; then - debug "... no java there" - elif [ 1 -eq $javaHierarchy ] ; then - debug "... JRE there" - elif [ 2 -eq $javaHierarchy ] ; then - debug "... JDK there" - fi -} - -verifyJavaHome() { - verifyResult=$VERIFY_NOJAVA - java=`removeEndSlashes "$1"` - debug "... verify : $java" - - java=`resolveSymlink "$java"` - debug "... real path : $java" - - checkJavaHierarchy "$java" - - if [ 0 -ne $javaHierarchy ] ; then - testJVMclasspath=`escapeString "$TEST_JVM_CLASSPATH"` - testJVMclass=`escapeString "$TEST_JVM_CLASS"` - - pointer="$POSSIBLE_JAVA_EXE_SUFFIX" - while [ -n "$pointer" ] && [ -z "$LAUNCHER_JAVA_EXE" ]; do - arg=`echo "$pointer" | sed "s/:.*//"` - back=`echo "$arg" | sed "s/\\\//\\\\\\\\\//g"` - end=`echo "$pointer" | sed "s/${back}://"` - arg=`echo "$back" | sed "s/\\\\\\\\\//\\\//g"` - pointer="$end" - javaExe="$java/$arg" - - if [ -x "$javaExe" ] ; then - javaExeEscaped=`escapeString "$javaExe"` - command="$javaExeEscaped -classpath $testJVMclasspath $testJVMclass" - - debug "Executing java verification command..." - debug "$command" - output=`eval "$command" 2>/dev/null` - javaVersion=`echo "$output" | sed "2d;3d;4d;5d"` - javaVmVersion=`echo "$output" | sed "1d;3d;4d;5d"` - vendor=`echo "$output" | sed "1d;2d;4d;5d"` - osname=`echo "$output" | sed "1d;2d;3d;5d"` - osarch=`echo "$output" | sed "1d;2d;3d;4d"` - - debug "Java :" - debug " executable = {$javaExe}" - debug " javaVersion = {$javaVersion}" - debug " javaVmVersion = {$javaVmVersion}" - debug " vendor = {$vendor}" - debug " osname = {$osname}" - debug " osarch = {$osarch}" - comp=0 - - if [ -n "$javaVersion" ] && [ -n "$javaVmVersion" ] && [ -n "$vendor" ] && [ -n "$osname" ] && [ -n "$osarch" ] ; then - debug "... seems to be java indeed" - javaVersionEsc=`escapeBackslash "$javaVersion"` - javaVmVersionEsc=`escapeBackslash "$javaVmVersion"` - javaVersion=`awk 'END { idx = index(b,a); if(idx!=0) { print substr(b,idx,length(b)) } else { print a } }' a="$javaVersionEsc" b="$javaVmVersionEsc" < /dev/null` - - #remove build number - javaVersion=`echo "$javaVersion" | sed 's/-.*$//;s/\ .*//'` - verifyResult=$VERIFY_UNCOMPATIBLE - - if [ -n "$javaVersion" ] ; then - debug " checking java version = {$javaVersion}" - javaCompCounter=0 - - while [ $javaCompCounter -lt $JAVA_COMPATIBLE_PROPERTIES_NUMBER ] && [ -z "$LAUNCHER_JAVA_EXE" ] ; do - comp=1 - setJavaCompatibilityProperties_$javaCompCounter - debug "Min Java Version : $JAVA_COMP_VERSION_MIN" - debug "Max Java Version : $JAVA_COMP_VERSION_MAX" - debug "Java Vendor : $JAVA_COMP_VENDOR" - debug "Java OS Name : $JAVA_COMP_OSNAME" - debug "Java OS Arch : $JAVA_COMP_OSARCH" - - if [ -n "$JAVA_COMP_VERSION_MIN" ] ; then - compMin=`ifVersionLess "$javaVersion" "$JAVA_COMP_VERSION_MIN"` - if [ 1 -eq $compMin ] ; then - comp=0 - fi - fi - - if [ -n "$JAVA_COMP_VERSION_MAX" ] ; then - compMax=`ifVersionGreater "$javaVersion" "$JAVA_COMP_VERSION_MAX"` - if [ 1 -eq $compMax ] ; then - comp=0 - fi - fi - if [ -n "$JAVA_COMP_VENDOR" ] ; then - debug " checking vendor = {$vendor}, {$JAVA_COMP_VENDOR}" - subs=`echo "$vendor" | sed "s/${JAVA_COMP_VENDOR}//"` - if [ `ifEquals "$subs" "$vendor"` -eq 1 ] ; then - comp=0 - debug "... vendor incompatible" - fi - fi - - if [ -n "$JAVA_COMP_OSNAME" ] ; then - debug " checking osname = {$osname}, {$JAVA_COMP_OSNAME}" - subs=`echo "$osname" | sed "s/${JAVA_COMP_OSNAME}//"` - - if [ `ifEquals "$subs" "$osname"` -eq 1 ] ; then - comp=0 - debug "... osname incompatible" - fi - fi - if [ -n "$JAVA_COMP_OSARCH" ] ; then - debug " checking osarch = {$osarch}, {$JAVA_COMP_OSARCH}" - subs=`echo "$osarch" | sed "s/${JAVA_COMP_OSARCH}//"` - - if [ `ifEquals "$subs" "$osarch"` -eq 1 ] ; then - comp=0 - debug "... osarch incompatible" - fi - fi - if [ $comp -eq 1 ] ; then - LAUNCHER_JAVA_EXE="$javaExe" - LAUNCHER_JAVA="$java" - verifyResult=$VERIFY_OK - fi - debug " compatible = [$comp]" - javaCompCounter=`expr "$javaCompCounter" + 1` - done - fi - fi - fi - done - fi -} - -checkFreeSpace() { - size="$1" - path="$2" - - if [ ! -d "$path" ] && [ ! $isSymlink "$path" ] ; then - # if checking path is not an existing directory - check its parent dir - path=`dirname "$path"` - fi - - diskSpaceCheck=0 - - if [ 0 -eq $PERFORM_FREE_SPACE_CHECK ] ; then - diskSpaceCheck=1 - else - # get size of the atomic entry (directory) - freeSpaceDirCheck="$path"/freeSpaceCheckDir - debug "Checking space in $path (size = $size)" - mkdir -p "$freeSpaceDirCheck" - # POSIX compatible du return size in 1024 blocks - du --block-size=$DEFAULT_DISK_BLOCK_SIZE "$freeSpaceDirCheck" 1>/dev/null 2>&1 - - if [ $? -eq 0 ] ; then - debug " getting POSIX du with 512 bytes blocks" - atomicBlock=`du --block-size=$DEFAULT_DISK_BLOCK_SIZE "$freeSpaceDirCheck" | awk ' { print $A }' A=1 2>/dev/null` - else - debug " getting du with default-size blocks" - atomicBlock=`du "$freeSpaceDirCheck" | awk ' { print $A }' A=1 2>/dev/null` - fi - rm -rf "$freeSpaceDirCheck" - debug " atomic block size : [$atomicBlock]" - - isBlockNumber=`ifNumber "$atomicBlock"` - if [ 0 -eq $isBlockNumber ] ; then - out "Can\`t get disk block size" - exitProgram $ERROR_INPUTOUPUT - fi - requiredBlocks=`expr \( "$1" / $DEFAULT_DISK_BLOCK_SIZE \) + $atomicBlock` 1>/dev/null 2>&1 - if [ `ifNumber $1` -eq 0 ] ; then - out "Can\`t calculate required blocks size" - exitProgram $ERROR_INPUTOUPUT - fi - # get free block size - column=4 - df -P --block-size="$DEFAULT_DISK_BLOCK_SIZE" "$path" 1>/dev/null 2>&1 - if [ $? -eq 0 ] ; then - # gnu df, use POSIX output - debug " getting GNU POSIX df with specified block size $DEFAULT_DISK_BLOCK_SIZE" - availableBlocks=`df -P --block-size="$DEFAULT_DISK_BLOCK_SIZE" "$path" | sed "1d" | awk ' { print $A }' A=$column 2>/dev/null` - else - # try POSIX output - df -P "$path" 1>/dev/null 2>&1 - if [ $? -eq 0 ] ; then - debug " getting POSIX df with 512 bytes blocks" - availableBlocks=`df -P "$path" | sed "1d" | awk ' { print $A }' A=$column 2>/dev/null` - # try Solaris df from xpg4 - elif [ -x /usr/xpg4/bin/df ] ; then - debug " getting xpg4 df with default-size blocks" - availableBlocks=`/usr/xpg4/bin/df -P "$path" | sed "1d" | awk ' { print $A }' A=$column 2>/dev/null` - # last chance to get free space - else - debug " getting df with default-size blocks" - availableBlocks=`df "$path" | sed "1d" | awk ' { print $A }' A=$column 2>/dev/null` - fi - fi - debug " available blocks : [$availableBlocks]" - if [ `ifNumber "$availableBlocks"` -eq 0 ] ; then - out "Can\`t get the number of the available blocks on the system" - exitProgram $ERROR_INPUTOUTPUT - fi - - # compare - debug " required blocks : [$requiredBlocks]" - - if [ $availableBlocks -gt $requiredBlocks ] ; then - debug "... disk space check OK" - diskSpaceCheck=1 - else - debug "... disk space check FAILED" - fi - fi - if [ 0 -eq $diskSpaceCheck ] ; then - mbDownSize=`expr "$size" / 1024 / 1024` - mbUpSize=`expr "$size" / 1024 / 1024 + 1` - mbSize=`expr "$mbDownSize" \* 1024 \* 1024` - if [ $size -ne $mbSize ] ; then - mbSize="$mbUpSize" - else - mbSize="$mbDownSize" - fi - - message "$MSG_ERROR_FREESPACE" "$mbSize" "$ARG_TEMPDIR" - exitProgram $ERROR_FREESPACE - fi -} - -prepareClasspath() { - debug "Processing external jars ..." - processJarsClasspath - - LAUNCHER_CLASSPATH="" - if [ -n "$JARS_CLASSPATH" ] ; then - if [ -z "$LAUNCHER_CLASSPATH" ] ; then - LAUNCHER_CLASSPATH="$JARS_CLASSPATH" - else - LAUNCHER_CLASSPATH="$LAUNCHER_CLASSPATH":"$JARS_CLASSPATH" - fi - fi - - if [ -n "$PREPEND_CP" ] ; then - debug "Appending classpath with [$PREPEND_CP]" - PREPEND_CP=`resolveString "$PREPEND_CP"` - - if [ -z "$LAUNCHER_CLASSPATH" ] ; then - LAUNCHER_CLASSPATH="$PREPEND_CP" - else - LAUNCHER_CLASSPATH="$PREPEND_CP":"$LAUNCHER_CLASSPATH" - fi - fi - if [ -n "$APPEND_CP" ] ; then - debug "Appending classpath with [$APPEND_CP]" - APPEND_CP=`resolveString "$APPEND_CP"` - if [ -z "$LAUNCHER_CLASSPATH" ] ; then - LAUNCHER_CLASSPATH="$APPEND_CP" - else - LAUNCHER_CLASSPATH="$LAUNCHER_CLASSPATH":"$APPEND_CP" - fi - fi - debug "Launcher Classpath : $LAUNCHER_CLASSPATH" -} - -resolvePropertyStrings() { - args="$1" - escapeReplacedString="$2" - propertyStart=`echo "$args" | sed "s/^.*\\$P{//"` - propertyValue="" - propertyName="" - - #Resolve i18n strings and properties - if [ 0 -eq `ifEquals "$propertyStart" "$args"` ] ; then - propertyName=`echo "$propertyStart" | sed "s/}.*//" 2>/dev/null` - if [ -n "$propertyName" ] ; then - propertyValue=`getMessage "$propertyName"` - - if [ 0 -eq `ifEquals "$propertyValue" "$propertyName"` ] ; then - propertyName="\$P{$propertyName}" - args=`replaceString "$args" "$propertyName" "$propertyValue" "$escapeReplacedString"` - fi - fi - fi - - echo "$args" -} - - -resolveLauncherSpecialProperties() { - args="$1" - escapeReplacedString="$2" - propertyValue="" - propertyName="" - propertyStart=`echo "$args" | sed "s/^.*\\$L{//"` - - - if [ 0 -eq `ifEquals "$propertyStart" "$args"` ] ; then - propertyName=`echo "$propertyStart" | sed "s/}.*//" 2>/dev/null` - - - if [ -n "$propertyName" ] ; then - case "$propertyName" in - "nbi.launcher.tmp.dir") - propertyValue="$LAUNCHER_EXTRACT_DIR" - ;; - "nbi.launcher.java.home") - propertyValue="$LAUNCHER_JAVA" - ;; - "nbi.launcher.user.home") - propertyValue="$HOME" - ;; - "nbi.launcher.parent.dir") - propertyValue="$LAUNCHER_DIR" - ;; - *) - propertyValue="$propertyName" - ;; - esac - if [ 0 -eq `ifEquals "$propertyValue" "$propertyName"` ] ; then - propertyName="\$L{$propertyName}" - args=`replaceString "$args" "$propertyName" "$propertyValue" "$escapeReplacedString"` - fi - fi - fi - echo "$args" -} - -resolveString() { - args="$1" - escapeReplacedString="$2" - last="$args" - repeat=1 - - while [ 1 -eq $repeat ] ; do - repeat=1 - args=`resolvePropertyStrings "$args" "$escapeReplacedString"` - args=`resolveLauncherSpecialProperties "$args" "$escapeReplacedString"` - if [ 1 -eq `ifEquals "$last" "$args"` ] ; then - repeat=0 - fi - last="$args" - done - echo "$args" -} - -replaceString() { - initialString="$1" - fromString="$2" - toString="$3" - if [ -n "$4" ] && [ 0 -eq `ifEquals "$4" "false"` ] ; then - toString=`escapeString "$toString"` - fi - fromString=`echo "$fromString" | sed "s/\\\//\\\\\\\\\//g" 2>/dev/null` - toString=`echo "$toString" | sed "s/\\\//\\\\\\\\\//g" 2>/dev/null` - replacedString=`echo "$initialString" | sed "s/${fromString}/${toString}/g" 2>/dev/null` - echo "$replacedString" -} - -prepareJVMArguments() { - debug "Prepare JVM arguments... " - - jvmArgCounter=0 - debug "... resolving string : $LAUNCHER_JVM_ARGUMENTS" - LAUNCHER_JVM_ARGUMENTS=`resolveString "$LAUNCHER_JVM_ARGUMENTS" true` - debug "... resolved string : $LAUNCHER_JVM_ARGUMENTS" - while [ $jvmArgCounter -lt $JVM_ARGUMENTS_NUMBER ] ; do - argumentVar="$""JVM_ARGUMENT_$jvmArgCounter" - arg=`eval "echo \"$argumentVar\""` - debug "... jvm argument [$jvmArgCounter] [initial] : $arg" - arg=`resolveString "$arg"` - debug "... jvm argument [$jvmArgCounter] [resolved] : $arg" - arg=`escapeString "$arg"` - debug "... jvm argument [$jvmArgCounter] [escaped] : $arg" - LAUNCHER_JVM_ARGUMENTS="$LAUNCHER_JVM_ARGUMENTS $arg" - jvmArgCounter=`expr "$jvmArgCounter" + 1` - done - if [ ! -z "${DEFAULT_USERDIR_ROOT}" ] ; then - debug "DEFAULT_USERDIR_ROOT: $DEFAULT_USERDIR_ROOT" - LAUNCHER_JVM_ARGUMENTS="$LAUNCHER_JVM_ARGUMENTS -Dnetbeans.default_userdir_root=\"${DEFAULT_USERDIR_ROOT}\"" - fi - if [ ! -z "${DEFAULT_CACHEDIR_ROOT}" ] ; then - debug "DEFAULT_CACHEDIR_ROOT: $DEFAULT_CACHEDIR_ROOT" - LAUNCHER_JVM_ARGUMENTS="$LAUNCHER_JVM_ARGUMENTS -Dnetbeans.default_cachedir_root=\"${DEFAULT_CACHEDIR_ROOT}\"" - fi - - debug "Final JVM arguments : $LAUNCHER_JVM_ARGUMENTS" -} - -prepareAppArguments() { - debug "Prepare Application arguments... " - - appArgCounter=0 - debug "... resolving string : $LAUNCHER_APP_ARGUMENTS" - LAUNCHER_APP_ARGUMENTS=`resolveString "$LAUNCHER_APP_ARGUMENTS" true` - debug "... resolved string : $LAUNCHER_APP_ARGUMENTS" - while [ $appArgCounter -lt $APP_ARGUMENTS_NUMBER ] ; do - argumentVar="$""APP_ARGUMENT_$appArgCounter" - arg=`eval "echo \"$argumentVar\""` - debug "... app argument [$appArgCounter] [initial] : $arg" - arg=`resolveString "$arg"` - debug "... app argument [$appArgCounter] [resolved] : $arg" - arg=`escapeString "$arg"` - debug "... app argument [$appArgCounter] [escaped] : $arg" - LAUNCHER_APP_ARGUMENTS="$LAUNCHER_APP_ARGUMENTS $arg" - appArgCounter=`expr "$appArgCounter" + 1` - done - debug "Final application arguments : $LAUNCHER_APP_ARGUMENTS" -} - - -runCommand() { - cmd="$1" - debug "Running command : $cmd" - if [ -n "$OUTPUT_FILE" ] ; then - #redirect all stdout and stderr from the running application to the file - eval "$cmd" >> "$OUTPUT_FILE" 2>&1 - elif [ 1 -eq $SILENT_MODE ] ; then - # on silent mode redirect all out/err to null - eval "$cmd" > /dev/null 2>&1 - elif [ 0 -eq $USE_DEBUG_OUTPUT ] ; then - # redirect all output to null - # do not redirect errors there but show them in the shell output - eval "$cmd" > /dev/null - else - # using debug output to the shell - # not a silent mode but a verbose one - eval "$cmd" - fi - return $? -} - -executeMainClass() { - prepareClasspath - prepareJVMArguments - prepareAppArguments - debug "Running main jar..." - message "$MSG_RUNNING" - classpathEscaped=`escapeString "$LAUNCHER_CLASSPATH"` - mainClassEscaped=`escapeString "$MAIN_CLASS"` - launcherJavaExeEscaped=`escapeString "$LAUNCHER_JAVA_EXE"` - tmpdirEscaped=`escapeString "$LAUNCHER_JVM_TEMP_DIR"` - - command="$launcherJavaExeEscaped $LAUNCHER_JVM_ARGUMENTS -Djava.io.tmpdir=$tmpdirEscaped -classpath $classpathEscaped $mainClassEscaped $LAUNCHER_APP_ARGUMENTS" - - debug "Running command : $command" - runCommand "$command" - exitCode=$? - debug "... java process finished with code $exitCode" - exitProgram $exitCode -} - -escapeString() { - echo "$1" | sed "s/\\\/\\\\\\\/g;s/\ /\\\\ /g;s/\"/\\\\\"/g;s/(/\\\\\(/g;s/)/\\\\\)/g;" # escape spaces, commas and parentheses -} - -getMessage() { - getLocalizedMessage_$LAUNCHER_LOCALE $@ -} - -POSSIBLE_JAVA_ENV="JAVA:JAVA_HOME:JAVAHOME:JAVA_PATH:JAVAPATH:JDK:JDK_HOME:JDKHOME:ANT_JAVA:" -POSSIBLE_JAVA_EXE_SUFFIX_SOLARIS="bin/java:bin/sparcv9/java:" -POSSIBLE_JAVA_EXE_SUFFIX_COMMON="bin/java:" diff --git a/nbi/engine/native/launcher/windows/.dep.inc b/nbi/engine/native/launcher/windows/.dep.inc deleted file mode 100644 index 4560e55af987..000000000000 --- a/nbi/engine/native/launcher/windows/.dep.inc +++ /dev/null @@ -1,5 +0,0 @@ -# This code depends on make tool being used -DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES})) -ifneq (${DEPFILES},) -include ${DEPFILES} -endif diff --git a/nbi/engine/native/launcher/windows/Makefile b/nbi/engine/native/launcher/windows/Makefile deleted file mode 100644 index 1debec653ff1..000000000000 --- a/nbi/engine/native/launcher/windows/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib -RESCOMP=windres - - -# build -build: .build-pre .build-impl .build-post - -.build-pre: - mkdir -p build - windres -I resources -o build/icon.o -i resources/res.rc - -.build-post: -# Add your post 'build' code here... - - -# clean -clean: .clean-pre .clean-impl .clean-post - -.clean-pre: - rm -rf build/icon.o - -.clean-post: -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-pre .clobber-impl .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: -# Add your post 'clobber' code here... - - -# all -all: .all-pre .all-impl .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: -# Add your post 'all' code here... - - -# help -help: .help-pre .help-impl .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: -# Add your post 'help' code here... - -# include project implementation makefile -include nbproject/Makefile-impl.mk diff --git a/nbi/engine/native/launcher/windows/Makefile-vc b/nbi/engine/native/launcher/windows/Makefile-vc deleted file mode 100644 index 78bc6316edd1..000000000000 --- a/nbi/engine/native/launcher/windows/Makefile-vc +++ /dev/null @@ -1,92 +0,0 @@ -# -# - - -!include <$(PLATFORM_SDK)/include/win32.mak> - -# define the compiler and linker for all the platforms -CC32="$(VC_2005)\Bin\cl.exe" -L32="$(VC_2005)\Bin\link.exe" -MT32="$(PLATFORM_SDK)\Bin\mt.exe" -RC32="$(VC_2005)\Bin\rc.exe" - -BUILD_DIR32=.\build\32bit -OUTPUT_FILE32=.\dist\nlw.exe -MANIFEST_FILE32=.\resources\nlw.exe.manifest -#Alternative manifest file - read more in resources\res.rc -#MANIFEST_FILE32=.\resources\nlw-alt.exe.manifest - -SOURCE_FILES=\ - .\src\ExtractUtils.c \ - .\src\FileUtils.c \ - .\src\JavaUtils.c \ - .\src\Launcher.c \ - .\src\Main.c \ - .\src\ProcessUtils.c \ - .\src\RegistryUtils.c \ - .\src\StringUtils.c \ - .\src\SystemUtils.c - - -CC32_OPTS=/O1 /Os \ - /I "$(VC_2005)\include" \ - /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" \ - /FD /EHsc /MT \ - /Fo"$(BUILD_DIR32)\\" /Fd"$(BUILD_DIR32)\vc80.pdb" \ - /W3 /nologo /c /Wp64 /TC /errorReport:prompt - -LINKING_LIBRARIES=\ - user32.lib\ - gdi32.lib \ - comdlg32.lib \ - comctl32.lib \ - advapi32.lib\ - shell32.lib \ - ole32.lib \ - oleaut32.lib \ - userenv.lib \ - libcmt.lib \ - kernel32.lib - -L32_OPTS=\ - /OUT:$(OUTPUT_FILE32) \ - /INCREMENTAL:NO \ - /LIBPATH:"$(PLATFORM_SDK)\Lib" \ - /MANIFEST \ - /MANIFESTFILE:"$(BUILD_DIR32)\nlw.exe.intermediate.manifest" \ - /NODEFAULTLIB \ - /SUBSYSTEM:WINDOWS \ - /OPT:REF /OPT:ICF \ - /MACHINE:X86 \ - /ERRORREPORT:PROMPT \ - $(LINKING_LIBRARIES) - - -RC32_OPTS=\ - /I ".\resources" /fo $(BUILD_DIR32)\resources.obj - - -all: init build-32 - -clean: - - -init: - - md $(BUILD_DIR32) - - md .\dist - - del /Q /S $(BUILD_DIR32) - del /Q $(OUTPUT_FILE32) - -build-32: - Set CPU=i386 - Set Lib=%VC_2005%\Lib;%PLATFORM_SDK%\Lib;%Lib% - Set Include=%PLATFORM_SDK%\Include;%Include% - Set Path=%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%VC_2005_PATH%;%path% - Set APPVER=5.01 - Set TARGETOS=WINNT - - $(CC32) $(CC32_OPTS) $(SOURCE_FILES) - $(RC32) $(RC32_OPTS) resources/res.rc - $(L32) $(L32_OPTS) $(BUILD_DIR32)\ExtractUtils.obj $(BUILD_DIR32)\FileUtils.obj $(BUILD_DIR32)\JavaUtils.obj $(BUILD_DIR32)\Launcher.obj $(BUILD_DIR32)\Main.obj $(BUILD_DIR32)\ProcessUtils.obj $(BUILD_DIR32)\RegistryUtils.obj $(BUILD_DIR32)\StringUtils.obj $(BUILD_DIR32)\SystemUtils.obj $(BUILD_DIR32)\resources.obj - $(MT32) /outputresource:"$(OUTPUT_FILE32);#1" -manifest $(MANIFEST_FILE32) $(BUILD_DIR32)\nlw.exe.intermediate.manifest diff --git a/nbi/engine/native/launcher/windows/Makefile-vc-wo-crt b/nbi/engine/native/launcher/windows/Makefile-vc-wo-crt deleted file mode 100644 index 6a693f5cc19a..000000000000 --- a/nbi/engine/native/launcher/windows/Makefile-vc-wo-crt +++ /dev/null @@ -1,92 +0,0 @@ -# -# - - -!include <$(PLATFORM_SDK)/include/win32.mak> - -# define the compiler and linker for all the platforms -CC32="$(VC_2005)\Bin\cl.exe" -L32="$(VC_2005)\Bin\link.exe" -MT32="$(PLATFORM_SDK)\Bin\mt.exe" -RC32="$(VC_2005)\Bin\rc.exe" - -BUILD_DIR32=.\build\32bit -OUTPUT_FILE32=.\dist\nlw.exe -MANIFEST_FILE32=.\resources\nlw.exe.manifest -#Alternative manifest file - read more in resources\res.rc -#MANIFEST_FILE32=.\resources\nlw-alt.exe.manifest - -SOURCE_FILES=\ - .\src\ExtractUtils.c \ - .\src\FileUtils.c \ - .\src\JavaUtils.c \ - .\src\Launcher.c \ - .\src\Main.c \ - .\src\ProcessUtils.c \ - .\src\RegistryUtils.c \ - .\src\StringUtils.c \ - .\src\SystemUtils.c - - -CC32_OPTS=/O1 /Os \ - /I "$(VC_2005)\include" \ - /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" \ - /FD /EHsc /GS- \ - /Fo"$(BUILD_DIR32)\\" /Fd"$(BUILD_DIR32)\vc80.pdb" \ - /W3 /nologo /c /Wp64 /TC /errorReport:prompt - -LINKING_LIBRARIES=\ - user32.lib\ - gdi32.lib \ - comdlg32.lib \ - comctl32.lib \ - advapi32.lib\ - shell32.lib \ - ole32.lib \ - oleaut32.lib \ - userenv.lib \ - kernel32.lib \ - -L32_OPTS=\ - /OUT:$(OUTPUT_FILE32) \ - /INCREMENTAL:NO \ - /LIBPATH:"$(PLATFORM_SDK)\Lib" \ - /MANIFEST \ - /MANIFESTFILE:"$(BUILD_DIR32)\nlw.exe.intermediate.manifest" \ - /NODEFAULTLIB \ - /SUBSYSTEM:WINDOWS \ - /OPT:REF /OPT:ICF \ - /MACHINE:X86 \ - /ERRORREPORT:PROMPT \ - /ENTRY:MyMain \ - $(LINKING_LIBRARIES) - - -RC32_OPTS=\ - /I ".\resources" /fo $(BUILD_DIR32)\resources.obj - - -all: init build-32 - -clean: - - -init: - - md $(BUILD_DIR32) - - md .\dist - - del /Q /S $(BUILD_DIR32) - del /Q $(OUTPUT_FILE32) - -build-32: - Set CPU=i386 - Set Lib=%VC_2005%\Lib;%PLATFORM_SDK%\Lib;%Lib% - Set Include=%PLATFORM_SDK%\Include;%Include% - Set Path=%PLATFORM_SDK%\Bin;%PLATFORM_SDK%\Bin\WinNT;%VC_2005_PATH%;%path% - Set APPVER=5.01 - Set TARGETOS=WINNT - - $(CC32) $(CC32_OPTS) $(SOURCE_FILES) - $(RC32) $(RC32_OPTS) resources/res.rc - $(L32) $(L32_OPTS) $(BUILD_DIR32)\ExtractUtils.obj $(BUILD_DIR32)\FileUtils.obj $(BUILD_DIR32)\JavaUtils.obj $(BUILD_DIR32)\Launcher.obj $(BUILD_DIR32)\Main.obj $(BUILD_DIR32)\ProcessUtils.obj $(BUILD_DIR32)\RegistryUtils.obj $(BUILD_DIR32)\StringUtils.obj $(BUILD_DIR32)\SystemUtils.obj $(BUILD_DIR32)\resources.obj - $(MT32) /outputresource:"$(OUTPUT_FILE32);#1" -manifest $(MANIFEST_FILE32) $(BUILD_DIR32)\nlw.exe.intermediate.manifest diff --git a/nbi/engine/native/launcher/windows/i18n/launcher.properties b/nbi/engine/native/launcher/windows/i18n/launcher.properties deleted file mode 100644 index 70f24c5bcca7..000000000000 --- a/nbi/engine/native/launcher/windows/i18n/launcher.properties +++ /dev/null @@ -1,54 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -nlw.jvm.notfoundmessage=Java SE Development Kit (JDK) was not found on this computer\nJDK 8 or newer is required for installing the NetBeans IDE. Make sure that the JDK is properly installed and run installer again. You can specify valid JDK location using {0} installer argument.\n\nTo download the JDK, visit http://www.oracle.com/technetwork/java/javase/downloads -nlw.jvm.usererror=Java Runtime Environment (JRE) was not found\nThere is no JRE at the specified location {0} -nlw.jvm.unsupportedversion=Unsupported Java VM version\nThe Java VM at {0} has the unsupported version -nlw.freespace=There is not enough free disk space to extract installation data\n{0} MB of free disk space is required in a temporary folder. Clean up the disk space and run installer again. You can specify a temporary folder with sufficient disk space using {1} installer argument -nlw.tmpdir=Can't create temporary directory\nThe temporary directory for extracting data {0} was not created -nlw.integrity=Installer file is corrupted\nInstaller file {0} seems to be corrupted -nlw.output.error=Data extraction error\nCan't create file {0}!\nThe following error occured :\n{1} -nlw.java.process.error=An error occured while running java process\n{0} -nlw.missing.external.resource=Can`t run NetBeans Installer.\nAn external file with necessary data is required but missing:\n{0} -nlw.bundled.jvm.extract.error=Cannot prepare bundled JVM to run the installer.\nMost probably the bundled JVM is not compatible with the current platform. -nlw.bundled.jvm.verify.error=An error occured while verifying bundled JVM.\nMost probably the bundled JVM is not compatible with the current platform. - -nlw.arg.output={0} \n\tRedirect output to file -nlw.arg.javahome={0} \n\tRun jar file using JVM from -nlw.arg.verbose={0}\n\tUse verbose output -nlw.arg.tempdir={0} \n\tUse for extracting data -nlw.arg.extract={0} [directory]\n\tExtract all bundled data to the specific directory.\n\tIf directory is not specified then extract to the current directory -nlw.arg.classpatha={0} \n\tAppend classpath with -nlw.arg.classpathp={0} \n\tPrepend classpath with -nlw.arg.disable.space.check={0}\n\tDisable free space check -nlw.arg.locale={0} \n\tOverride system default locale with -nlw.arg.silent={0} \n\tRun installer silently -nlw.arg.help={0}\n\tShow help message - - -nlw.msg.create.tmpdir=Creating temporary directory ... -nlw.msg.extract=Extracting data ... -nlw.msg.jvmsearch=Finding JVM on your system ... -nlw.msg.setoptions=Setting command options ... -nlw.msg.running=Running JVM ... -nlw.msg.title=Please wait while the launcher prepares data to run the installer ... -nlw.msg.messagebox.title=Apache NetBeans IDE Installer -nlw.msg.progress.title=Configuring the installer ... -nlw.msg.button.error=Exit Installer -nlw.msg.main.title=Apache NetBeans IDE Installer diff --git a/nbi/engine/native/launcher/windows/nbproject/configurations.xml b/nbi/engine/native/launcher/windows/nbproject/configurations.xml deleted file mode 100644 index 095caed51c8e..000000000000 --- a/nbi/engine/native/launcher/windows/nbproject/configurations.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - src/Errors.h - src/ExtractUtils.h - src/FileUtils.h - src/JavaUtils.h - src/Launcher.h - src/Main.h - src/ProcessUtils.h - src/RegistryUtils.h - src/StringUtils.h - src/SystemUtils.h - src/Types.h - - - resources/res.rc - - - src/ExtractUtils.c - src/FileUtils.c - src/JavaUtils.c - src/Launcher.c - src/Main.c - src/ProcessUtils.c - src/RegistryUtils.c - src/StringUtils.c - src/SystemUtils.c - - - Makefile - - - Makefile - - - - LOCAL_SOURCES - Cygwin|Cygwin - - - - true - -mno-cygwin - 3 - - - true - - - dist/nlw - true - - -lole32 -luuid -lkernel32 -lcomctl32 -luserenv - - -mwindows -mno-cygwin build/icon.o - - - - - - LOCAL_SOURCES - Cygwin|Cygwin - - - - 5 - - - 5 - - - 5 - - - - - diff --git a/nbi/engine/native/launcher/windows/nbproject/project.properties b/nbi/engine/native/launcher/windows/nbproject/project.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/native/launcher/windows/nbproject/project.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/native/launcher/windows/nbproject/project.xml b/nbi/engine/native/launcher/windows/nbproject/project.xml deleted file mode 100644 index 017b77b3f98e..000000000000 --- a/nbi/engine/native/launcher/windows/nbproject/project.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - org.netbeans.modules.cnd.makeproject - - - NBI Native Launcher : Windows - 0 - c - - h - UTF-8 - - - - - Debug - 1 - - - Release - 1 - - - - - diff --git a/nbi/engine/native/launcher/windows/resources/icon.ico b/nbi/engine/native/launcher/windows/resources/icon.ico deleted file mode 100644 index ec123c065723..000000000000 Binary files a/nbi/engine/native/launcher/windows/resources/icon.ico and /dev/null differ diff --git a/nbi/engine/native/launcher/windows/resources/nlw-alt.exe.manifest b/nbi/engine/native/launcher/windows/resources/nlw-alt.exe.manifest deleted file mode 100644 index 62fb856801cf..000000000000 --- a/nbi/engine/native/launcher/windows/resources/nlw-alt.exe.manifest +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/nbi/engine/native/launcher/windows/resources/nlw.exe.manifest b/nbi/engine/native/launcher/windows/resources/nlw.exe.manifest deleted file mode 100644 index a22dcb9983d2..000000000000 --- a/nbi/engine/native/launcher/windows/resources/nlw.exe.manifest +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/nbi/engine/native/launcher/windows/resources/res.rc b/nbi/engine/native/launcher/windows/resources/res.rc deleted file mode 100644 index 012c85ea01f1..000000000000 --- a/nbi/engine/native/launcher/windows/resources/res.rc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -// Uncomment the following lines to add special "Vista" manifest under Cygwin using GCC and WINDRES -// Seems that tools from MS Platform SDK/MS VS C++ 2005 EE (C compiler, resource compiler and manifest tool) ignore that -// (so you can leave that uncommented for both tools at once) but I haven`t check that much. -// PS. Currently uncommented - seems to be working with GCC compiler (checked by Martin Sladecek) -#define RT_MANIFEST 24 -#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 - - -// Using of nlw.exe.manifest means that on Vista every installer/uninstaller (launcher, in general) invocation would require admin privileges which user would be asked for (evaluation dialog). -// In that case the executable icon would have "shield" mark. -// Using of nlw-alt.exe.manifest means that on Vista evaluation dialog is not displayed. To run it with admin right user have to execute "Run as Administrator" explicitely. -// Without the build-it manifest the following issue can occur (reported Martin Sladecek): -// When launcher would have "instal" in its name (uninstall.exe for instance), then - due to UAC and it`s method of checking "installer-like" names and code stamps - it would be executed with Administrator`s environment - it is would be different from the user that performed the installation. -// Only one of the following lines should be commented, the other one should be uncommented. -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "nlw.exe.manifest" -//CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "nlw-alt.exe.manifest" - -100 ICON DISCARDABLE "icon.ico" - diff --git a/nbi/engine/native/launcher/windows/src/Errors.h b/nbi/engine/native/launcher/windows/src/Errors.h deleted file mode 100644 index 7955823d06b3..000000000000 --- a/nbi/engine/native/launcher/windows/src/Errors.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _Errors_H -#define _Errors_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#define ERROR_OK 0 -#define ERROR_INTEGRITY 1000 -#define ERROR_FREESPACE 1001 -#define ERROR_INPUTOUPUT 1002 -#define ERROR_JVM_UNCOMPATIBLE 1003 -#define ERROR_JVM_NOT_FOUND 1004 -#define ERROR_ON_EXECUTE_PROCESS 1005 -#define ERROR_PROCESS_TIMEOUT 1006 -#define ERROR_USER_TERMINATED 1007 -#define EXTERNAL_RESOURCE_MISSING 1008 -#define ERROR_BUNDLED_JVM_EXTRACTION 1009 -#define ERROR_BUNDLED_JVM_VERIFICATION 1010 - -#define EXIT_CODE_EVENTS_INITIALIZATION_ERROR 1022 -#define EXIT_CODE_GUI_INITIALIZATION_ERROR 1023 -#define EXIT_CODE_STUB 1024 -#define EXIT_CODE_SYSTEM_ERROR 1025 - - -#ifdef __cplusplus -} -#endif - -#endif /* _Errors_H */ - diff --git a/nbi/engine/native/launcher/windows/src/ExtractUtils.c b/nbi/engine/native/launcher/windows/src/ExtractUtils.c deleted file mode 100644 index edbfa5543ace..000000000000 --- a/nbi/engine/native/launcher/windows/src/ExtractUtils.c +++ /dev/null @@ -1,761 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include "FileUtils.h" -#include "StringUtils.h" -#include "SystemUtils.h" -#include "JavaUtils.h" -#include "RegistryUtils.h" -#include "ExtractUtils.h" -#include "Launcher.h" -#include "Main.h" - -const DWORD STUB_FILL_SIZE = 450000; - -void skipLauncherStub(LauncherProperties * props, DWORD stubSize) { - HANDLE hFileRead = props->handler; - - if(hFileRead!=INVALID_HANDLE_VALUE) { - // just read stub data.. no need to write it anywhere - DWORD read = 0; - char * offsetbuf = newpChar(stubSize); - DWORD sizeLeft = stubSize; - while(ReadFile(hFileRead, offsetbuf, sizeLeft, &read, 0) && sizeLeft && read) { - sizeLeft-=read; - addProgressPosition(props, read); - if(sizeLeft==0) break; - if(read==0) { // we need some more bytes to read but we can`t to read - props->status = ERROR_INTEGRITY; - break; - } - } - FREE(offsetbuf); - } -} - - -void skipStub(LauncherProperties * props) { - if(props->isOnlyStub) { - WCHAR * os; - props->status = EXIT_CODE_STUB; - os = appendStringW(NULL, L"It`s only the launcher stub.\nOS: "); - if(is9x()) os = appendStringW(os, L"Windows 9x"); - if(isNT()) os = appendStringW(os, L"Windows NT"); - if(is2k()) os = appendStringW(os, L"Windows 2000"); - if(isXP()) os = appendStringW(os, L"Windows XP"); - if(is2003()) os = appendStringW(os, L"Windows 2003"); - if(isVista()) os = appendStringW(os, L"Windows Vista"); - if(is2008()) os = appendStringW(os, L"Windows 2008"); - if(is7()) os = appendStringW(os, L"Windows 7"); - if(IsWow64) os = appendStringW(os, L" x64"); - showMessageW(props, os , 0); - FREE(os); - } else { - skipLauncherStub(props, STUB_FILL_SIZE); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, - "Error! Can`t process launcher stub", 1); - showErrorW(props, INTEGRITY_ERROR_PROP, 1, props->exeName); - } - } -} - -void modifyRestBytes(SizedString* rest, DWORD start) { - - DWORD len = rest->length - start; - char * restBytesNew = NULL; - - if(len>0) { - DWORD i; - restBytesNew = newpChar(len); - for(i=start;ilength;i++) { - restBytesNew[i-start] = (rest->bytes) [i]; - } - } - FREE(rest->bytes); - rest->bytes = restBytesNew; - rest->length = len; -} - -DWORD readStringFromBuf(SizedString *rest, SizedString * result, DWORD isUnicode) { - if((rest->length)!=0) { - // we have smth in the restBytes that we have read but haven`t yet proceeded - DWORD i=0; - for(i=0;ilength;i++) { - DWORD check = ((rest->bytes)[i]==0); - if(isUnicode) { - if ( (i/2)*2==i) {// i is even - check = check && (i < rest->length-1 && ((rest->bytes)[i+1]==0)); - } else { - check = 0; - } - } - if( check ) { // we have found null character in the rest bytes - result->bytes = appendStringN(NULL, 0, rest->bytes, i); - result->length = i; - modifyRestBytes(rest, i + 1 + isUnicode); - return ERROR_OK; - } - } - //here we have found no \0 character in the rest of bytes... - } - return ERROR_INPUTOUPUT; -} - -void readString(LauncherProperties * props, SizedString * result, DWORD isUnicode) { - DWORD * status = & props->status; - HANDLE hFileRead = props->handler; - SizedString * rest = props->restOfBytes; - DWORD bufferSize = props->bufsize; - DWORD read=0; - char * buf = NULL; - - if(*status != ERROR_OK ) return; - - if(readStringFromBuf(rest, result, isUnicode)==ERROR_OK) { - return; - } - - //we need to read file for more data to find \0 character... - - buf = newpChar(bufferSize); - - while (ReadFile(hFileRead, buf, bufferSize, &read, 0) && read) { - addProgressPosition(props, read); - rest->bytes = appendStringN(rest->bytes, rest->length, buf, read); - rest->length = rest->length + read; - if(readStringFromBuf(rest, result, isUnicode)==ERROR_OK) { - //if(result->bytes!=NULL) { - //we have find \0 character - break; - } - ZERO(buf, sizeof(char) * bufferSize); - if(read==0) { // we have nothing to read.. smth wrong - *status = ERROR_INTEGRITY; - break; - } - } - FREE(buf); - return; -} - - - -void readNumber(LauncherProperties * props, DWORD * result) { - if(isOK(props)) { - - SizedString * numberString = createSizedString(); - DWORD i =0; - DWORD number = 0; - - readString(props, numberString, 0); - if(!isOK(props)) { - freeSizedString(&numberString); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, - "Error!! Can`t read number string. Most probably integrity error.", 1); - return; - } - - if(numberString->bytes==NULL) { - freeSizedString(&numberString); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, - "Error!! Can`t read number string (it can`t be NULL). Most probably integrity error.", 1); - props->status = ERROR_INTEGRITY; - return; - } - - - for(;ilength;i++) { - char c = numberString->bytes[i]; - if(c>='0' && c<='9') { - number = number * 10 + (c - '0'); - } else if(c==0) { - // we have reached the end of number section - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, - "Can`t read number from string (it contains zero character):", 1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, numberString->bytes, 1); - props->status = ERROR_INTEGRITY; - break; - } else { - // unexpected... - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, - "Can`t read number from string (unexpected error):", 1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, numberString->bytes, 1); - props->status = ERROR_INTEGRITY; - break; - } - } - freeSizedString(&numberString); - *result = number; - } -} - -void readStringWithDebugW(LauncherProperties * props, WCHAR ** dest, char * paramName) { - SizedString *sizedStr = createSizedString(); - if(paramName!=NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Reading ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, paramName, 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " : ", 0); - } - readString(props, sizedStr, 1); - if(!isOK(props)) { - freeSizedString(&sizedStr); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, - "[ERROR] Can`t read string !! Seems to be integrity error", 1); - return; - } - *dest = createWCHAR(sizedStr); - freeSizedString(&sizedStr); - if(paramName!=NULL) { - if((*dest)!=NULL) { - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *dest, 1); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "NULL", 1); - } - } - return; -} - -void readStringWithDebugA(LauncherProperties * props, char ** dest, char * paramName) { - SizedString *sizedStr = createSizedString(); - - if(paramName!=NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Reading ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, paramName, 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " : ", 0); - } - readString( props, sizedStr, 0); - if(!isOK(props)) { - freeSizedString(&sizedStr); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, - "[ERROR] Can`t read string!!! Seems to be integritiy error", 1); - return; - } - *dest = appendString(NULL, sizedStr->bytes); - if(paramName!=NULL) { - if((*dest)==NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "NULL", 1); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, *dest, 1); - } - } - freeSizedString(&sizedStr); - return; -} - - -void readNumberWithDebug(LauncherProperties * props, DWORD * dest, char * paramName) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Reading ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, paramName, 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " : ", 0); - readNumber(props, dest); - - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, - "[ERROR] Can`t read number !!! Seems to be integrity error", 1); - return; - } - writeDWORD(props, OUTPUT_LEVEL_DEBUG, 0, NULL, *dest, 1); - return; -} -void readBigNumberWithDebug(LauncherProperties * props, int64t * dest, char * paramName) { - DWORD low = 0; - DWORD high = 0; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Reading ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, paramName, 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " : ", 0); - - readNumber(props, &low); - if(isOK(props)) { - readNumber(props, &high); - } - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, - "[ERROR] Can`t read number !!! Seems to be integrity error", 1); - return; - } - dest->High = high; - dest->Low = low; - writeint64t(props, OUTPUT_LEVEL_DEBUG, 0, "", dest, 1); -} - -// returns: ERROR_OK, ERROR_INPUTOUPUT, ERROR_INTEGRITY -void extractDataToFile(LauncherProperties * props, WCHAR *output, int64t * fileSize, DWORD expectedCRC ) { - if(isOK(props)) { - DWORD * status = & props->status; - HANDLE hFileRead = props->handler; - int64t * size = fileSize; - DWORD counter = 0; - DWORD crc32 = -1L; - HANDLE hFileWrite = CreateFileW(output, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, hFileRead); - - if (hFileWrite == INVALID_HANDLE_VALUE) { - WCHAR * err; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "[ERROR] Can`t create file ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, output, 1); - - err = getErrorDescription(GetLastError()); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Error description : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, err, 1); - - showErrorW(props, OUTPUT_ERROR_PROP, 2, output, err); - FREE(err); - *status = ERROR_INPUTOUPUT; - return; - } - if(props->restOfBytes->length!=0 && props->restOfBytes->bytes!=NULL) { - //check if the data stored in restBytes is more than we neen - // rest bytes contains much less than int64t so we operate here only bith low bits of size - DWORD restBytesToWrite = (compare(size, props->restOfBytes->length)> 0 ) ? props->restOfBytes->length : size->Low; - DWORD usedBytes = restBytesToWrite; - - char *ptr = props->restOfBytes->bytes; - - DWORD write = 0; - while (restBytesToWrite >0) { - WriteFile(hFileWrite, ptr, restBytesToWrite, &write, 0); - update_crc32(&crc32, ptr, write); - restBytesToWrite -= write; - ptr +=write; - } - modifyRestBytes(props->restOfBytes, usedBytes); - minus(size, usedBytes); - - } - - - if(compare(size, 0) > 0 ) { - DWORD bufferSize = props->bufsize; - char * buf = newpChar(bufferSize); - DWORD bufsize = (compare(size, bufferSize) > 0) ? bufferSize : size->Low; - DWORD read = 0 ; - // printf("Using buffer size: %u/%u\n", bufsize, bufferSize); - while (ReadFile(hFileRead, buf, bufsize, &read, 0) && read && compare(size, 0) > 0) { - addProgressPosition(props, read); - WriteFile(hFileWrite, buf, read, &read, 0); - update_crc32(&crc32, buf, read); - - minus(size, read); - - if((compare(size, bufsize)<0) && (compare(size, 0)>0) ) { - bufsize = size->Low; - } - ZERO(buf, sizeof(char) * bufferSize); - if(compare(size, 0)==0) { - break; - } - if((counter ++) % 20 == 0) { - if(isTerminated(props)) break; - } - - } - if((compare(size, 0)>0 || read==0) && !isTerminated(props)) { - // we could not read requested size - * status = ERROR_INTEGRITY; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, - "Can`t read data from file : not enought data", 1); - } - FREE(buf); - } - CloseHandle(hFileWrite); - crc32=~crc32; - if(isOK(props) && crc32!=expectedCRC) { - writeDWORD(props, OUTPUT_LEVEL_DEBUG, 0, "expected CRC : ", expectedCRC, 1); - writeDWORD(props, OUTPUT_LEVEL_DEBUG, 0, "real CRC : ", crc32, 1); - * status = ERROR_INTEGRITY; - - } - } -} - -//returns : ERROR_OK, ERROR_INTEGRITY, ERROR_FREE_SPACE -void extractFileToDir(LauncherProperties * props, WCHAR ** resultFile) { - WCHAR * fileName = NULL; - int64t * fileLength = NULL; - DWORD crc = 0; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Extracting file ...", 1); - readStringWithDebugW( props, & fileName, "file name"); - - fileLength = newint64_t(0, 0); - readBigNumberWithDebug( props, fileLength, "file length "); - - readNumberWithDebug( props, &crc, "CRC32"); - - if(!isOK(props)) return; - - if(fileName!=NULL) { - DWORD i=0; - WCHAR * dir; - resolveString(props, &fileName); - - for(i=0;i status = ERROR_INTEGRITY; - } - FREE(fileLength); - return; -} - - -void loadI18NStrings(LauncherProperties * props) { - DWORD i=0; - DWORD j=0; - //read number of locales - - DWORD numberOfLocales = 0; - DWORD numberOfProperties = 0; - - readNumberWithDebug(props, &numberOfLocales, "number of locales"); - if(!isOK(props)) return; - if(numberOfLocales==0) { - props->status = ERROR_INTEGRITY; - return ; - } - - - readNumberWithDebug( props, &numberOfProperties, "i18n properties"); - if(!isOK(props)) return; - if(numberOfProperties==0) { - props->status = ERROR_INTEGRITY; - return ; - } - - props->i18nMessages = (I18NStrings * ) LocalAlloc(LPTR, sizeof(I18NStrings) * numberOfProperties); - - props->I18N_PROPERTIES_NUMBER = numberOfProperties; - props->i18nMessages->properties = newppChar(props->I18N_PROPERTIES_NUMBER); - props->i18nMessages->strings = newppWCHAR(props->I18N_PROPERTIES_NUMBER); - - for(i=0; isOK(props) && ii18nMessages->properties[i] = NULL; - props->i18nMessages->strings[i] = NULL; - propName = appendString(NULL, "property name "); - - propName = appendString(propName, number); - FREE(number); - - readStringWithDebugA(props, & (props->i18nMessages->properties[i]), propName); - FREE(propName); - } - if(isOK(props)) { - - DWORD isLocaleMatches; - WCHAR * localeName; - WCHAR * currentLocale = getLocaleName(); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Current System Locale : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, currentLocale, 1); - - if(props->userDefinedLocale!=NULL) { // using user-defined locale via command-line parameter - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[CMD Argument] Try to use locale ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, props->userDefinedLocale, 1); - FREE(currentLocale); - currentLocale = appendStringW(NULL, props->userDefinedLocale); - } - - for(j=0;ji18nMessages->strings[i]); - props->i18nMessages->strings[i] = appendStringW(NULL, value); - } - FREE(value); - } - FREE(localeName); - } - FREE(currentLocale); - } -} - -LauncherResource * newLauncherResource() { - LauncherResource * file = (LauncherResource *) LocalAlloc(LPTR, sizeof(LauncherResource)); - file->path=NULL; - file->resolved=NULL; - file->type=0; - return file; -} -WCHARList * newWCHARList(DWORD number) { - WCHARList * list = (WCHARList*) LocalAlloc(LPTR, sizeof(WCHARList)); - list->size = number; - if(number>0) { - DWORD i=0; - list->items = newppWCHAR(number); - for(i=0;iitems[i] = NULL; - } - } else { - list->items = NULL; - } - return list; -} - -void freeWCHARList(WCHARList ** plist) { - WCHARList * list; - list = * plist; - if(list!=NULL) { - DWORD i=0; - if(list->items!=NULL) { - for(i=0;isize;i++) { - FREE(list->items[i]); - } - FREE(list->items); - } - FREE(*plist); - } -} - -LauncherResourceList * newLauncherResourceList(DWORD number) { - LauncherResourceList * list = (LauncherResourceList*) LocalAlloc(LPTR, sizeof(LauncherResourceList)); - list->size = number; - if(number > 0) { - DWORD i=0; - - list->items = (LauncherResource**) LocalAlloc(LPTR, sizeof(LauncherResource*) * number); - for(i=0;iitems[i] = NULL; - } - } else { - list->items = NULL; - } - return list; -} - -void freeLauncherResource(LauncherResource ** file) { - if(*file!=NULL) { - FREE((*file)->path); - FREE((*file)->resolved); - FREE(*file); - - } -} - - -void extractLauncherResource(LauncherProperties * props, LauncherResource ** file, char * name) { - char * typeStr = appendString(appendString(NULL, name), " type"); - * file = newLauncherResource(); - - readNumberWithDebug( props, & ((*file)->type) , typeStr); - - if(isOK(props)) { - FREE(typeStr); - - if((*file)->type==0) { //bundled - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... file is bundled", 1); - extractFileToDir(props, & ((*file)->path)); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error extracting file!", 1); - return; - } else { - (*file)->resolved = appendStringW(NULL, (*file)->path); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "file was succesfully extracted to ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, (*file)->path, 1); - } - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... file is external", 1); - readStringWithDebugW(props, & ((*file)->path), name); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error reading ", 1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, name, 1); - } - } - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error reading ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, typeStr, 0); - FREE(typeStr); - } -} - -void readWCHARList(LauncherProperties * props, WCHARList ** list, char * name) { - DWORD number = 0; - DWORD i =0; - char * numberStr = appendString(appendString(NULL, "number of "), name); - - * list = NULL; - readNumberWithDebug(props, &number, numberStr); - FREE(numberStr); - - if(!isOK(props)) return; - - * list = newWCHARList(number); - for(i=0;i < (*list)->size ;i++) { - char * nextStr = appendString(appendString(NULL, "next item in "), name); - readStringWithDebugW(props, &((*list)->items[i]), nextStr); - FREE(nextStr); - if(!isOK(props)) return; - } -} -void readLauncherResourceList(LauncherProperties * props, LauncherResourceList ** list, char * name) { - DWORD num = 0; - DWORD i=0; - char * numberStr = appendString(appendString(NULL, "number of "), name); - readNumberWithDebug(props, &num, numberStr); - FREE(numberStr); - if(!isOK(props)) return; - - * list = newLauncherResourceList(num); - for(i=0;i<(*list)->size;i++) { - extractLauncherResource(props, & ((*list)->items[i]), "launcher resource"); - if(!isOK(props)) { - char * str = appendString(appendString(NULL, "Error processing "), name); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, str, 1); - FREE(str); - break; - } - } -} - -void readLauncherProperties(LauncherProperties * props) { - DWORD i=0; - char * str = NULL; - - readWCHARList(props, &(props->jvmArguments), "jvm arguments"); - if(!isOK(props)) return; - - readWCHARList(props, &(props->appArguments), "app arguments"); - if(!isOK(props)) return; - - readStringWithDebugW(props, &(props->mainClass), "Main Class"); - if(!isOK(props)) return; - - readStringWithDebugW(props, &(props->testJVMClass), "TestJVM Class"); - if(!isOK(props)) return; - - readNumberWithDebug( props, &(props->compatibleJavaNumber), - "compatible java"); - if(!isOK(props)) return; - - - - if ( props->compatibleJavaNumber > 0 ) { - props->compatibleJava = (JavaCompatible **) LocalAlloc(LPTR, sizeof(JavaCompatible *) * props->compatibleJavaNumber); - for(i=0;icompatibleJavaNumber;i++) { - - props->compatibleJava [i] = newJavaCompatible() ; - - readStringWithDebugA(props, &str, "min java version"); - if(!isOK(props)) return; - props->compatibleJava[i]->minVersion = getJavaVersionFromString(str, &props->status); - FREE(str); - if(!isOK(props)) return; - - str = NULL; - readStringWithDebugA(props, &str, "max java version"); - if(!isOK(props)) return; - props->compatibleJava[i]->maxVersion = getJavaVersionFromString(str, &props->status); - FREE(str); - if(!isOK(props)) return; - - readStringWithDebugA(props, &(props->compatibleJava[i]->vendor) , - "vendor"); - if(!isOK(props)) return; - - readStringWithDebugA(props, &(props->compatibleJava[i]->osName) , - "os name"); - if(!isOK(props)) return; - - readStringWithDebugA(props, &(props->compatibleJava[i]->osArch) , - "os arch"); - if(!isOK(props)) return; - - } - } - readNumberWithDebug( props, &props->bundledNumber, "bundled files"); - readBigNumberWithDebug(props, props->bundledSize, "bundled size"); -} - -void extractJVMData(LauncherProperties * props) { - if(isOK(props)) { - - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Extracting JVM data... ", 1); - extractLauncherResource(props, &(props->testJVMFile), "testJVM file"); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error extracting testJVM file!", 1); - return ; - } - - readLauncherResourceList(props, &(props->jvms), "JVMs"); - } -} - -void extractData(LauncherProperties *props) { - if(isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Extracting Bundled data... ", 1); - readLauncherResourceList(props, &(props->jars), "bundled and external files"); - if(isOK(props)) { - readLauncherResourceList(props, &(props->other), "other data"); - } - } -} diff --git a/nbi/engine/native/launcher/windows/src/ExtractUtils.h b/nbi/engine/native/launcher/windows/src/ExtractUtils.h deleted file mode 100644 index f816df879514..000000000000 --- a/nbi/engine/native/launcher/windows/src/ExtractUtils.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _ExtractUtils_H -#define _ExtractUtils_H - -#include -#include "StringUtils.h" -#include "JavaUtils.h" -#include "Errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - - extern const DWORD STUB_FILL_SIZE; - - void skipStub(LauncherProperties * props); - - void loadI18NStrings(LauncherProperties * props); - - WCHARList * newWCHARList(DWORD number) ; - void readLauncherProperties(LauncherProperties * props); - void freeWCHARList(WCHARList ** plist); - void freeLauncherResource(LauncherResource ** file); - - void extractJVMData(LauncherProperties * props); - void extractData(LauncherProperties *props); - -#ifdef __cplusplus -} -#endif - -#endif /* _ExtractUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/FileUtils.c b/nbi/engine/native/launcher/windows/src/FileUtils.c deleted file mode 100644 index 6c36fd63f01e..000000000000 --- a/nbi/engine/native/launcher/windows/src/FileUtils.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include "FileUtils.h" -#include "StringUtils.h" - -HANDLE stdoutHandle = INVALID_HANDLE_VALUE; -HANDLE stderrHandle = INVALID_HANDLE_VALUE; - -DWORD newLine = 1; -const WCHAR * FILE_SEP = L"\\"; - -const long CRC32_TABLE[256] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, - 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, - 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, - 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, - 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, - 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, - 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, - 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, - 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, - 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, - 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, - 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, - 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, - 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, - 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, - 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, - 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, - 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, - 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, - 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, - 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, - 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -void writeTimeStamp(HANDLE hd, DWORD need) { - DWORD written; - if(need==1) { - SYSTEMTIME t; - char * yearStr; - char * monthStr; - char * dayStr; - char * hourStr; - char * minuteStr; - char * secondStr; - char * msStr; - char * result = NULL; - GetLocalTime(&t); - yearStr = word2charN(t.wYear,2); - monthStr = word2charN(t.wMonth,2); - dayStr = word2charN(t.wDay,2); - hourStr = word2charN(t.wHour,2); - minuteStr = word2charN(t.wMinute,2); - secondStr = word2charN(t.wSecond,2); - msStr = word2charN(t.wMilliseconds,3); - - result = appendString(NULL, "["); - result = appendString(result, yearStr); - result = appendString(result, "-"); - result = appendString(result, monthStr); - result = appendString(result, "-"); - result = appendString(result, dayStr); - result = appendString(result, " "); - result = appendString(result, hourStr); - result = appendString(result, ":"); - result = appendString(result, minuteStr); - result = appendString(result, ":"); - result = appendString(result, secondStr); - result = appendString(result, "."); - result = appendString(result, msStr); - result = appendString(result, "]> "); - - WriteFile(hd, result, sizeof(char) * getLengthA(result), & written, NULL); - FREE(result); - FREE(yearStr); - FREE(monthStr); - FREE(dayStr); - - FREE(hourStr); - FREE(minuteStr); - FREE(secondStr); - FREE(msStr); - } -} - -void writeMessageA(LauncherProperties * props, DWORD level, DWORD isErr, const char * message, DWORD needEndOfLine) { - if(level>=props->outputLevel) { - HANDLE hd = (isErr) ? props->stderrHandle : props->stdoutHandle; - DWORD written; - writeTimeStamp(hd, newLine); - WriteFile(hd, message, sizeof(char) * getLengthA(message), & written, NULL); - if(needEndOfLine>0) { - newLine = 0; - while((needEndOfLine--)>0) { - writeMessageA(props, level, isErr, "\r\n", 0); - newLine = 1; - } - flushHandle(hd); - } else { - newLine = 0; - } - } -} - -void writeMessageW(LauncherProperties * props, DWORD level, DWORD isErr, const WCHAR * message, DWORD needEndOfLine) { - if ( level >= props->outputLevel ) { - char * msg = toChar(message); - writeMessageA(props, level, isErr, msg, needEndOfLine); - FREE(msg); - } -} -void writeDWORD(LauncherProperties * props, DWORD level, DWORD isErr, const char * message, DWORD value, DWORD needEndOfLine) { - char * dwordStr = DWORDtoCHAR(value); - writeMessageA(props, level, isErr, message, 0); - writeMessageA(props, level, isErr, dwordStr, needEndOfLine); - FREE(dwordStr); -} - -void writeint64t(LauncherProperties * props, DWORD level, DWORD isErr, const char * message, int64t * value, DWORD needEndOfLine) { - char * str = int64ttoCHAR(value); - writeMessageA(props, level, isErr, message, 0); - writeMessageA(props, level, isErr, str, needEndOfLine); - FREE(str); -} -void writeErrorA(LauncherProperties * props, DWORD level, DWORD isErr, const char * message, const WCHAR * param, DWORD errorCode) { - WCHAR * err = getErrorDescription(errorCode); - writeMessageA(props, level, isErr, message, 0); - writeMessageW(props, level, isErr, param, 1); - writeMessageW(props, level, isErr, err, 1); - FREE(err); -} - -void flushHandle(HANDLE hd) { - FlushFileBuffers(hd); -} - -int64t * getFreeSpace(WCHAR *path) { - int64t bytes; - int64t * result = newint64_t(0, 0); - WCHAR * dst = appendStringW(NULL, path); - - while(!fileExists(dst)) { - WCHAR * parent = getParentDirectory(dst); - FREE(dst); - dst = parent; - if(dst==NULL) break; - } - if(dst==NULL) return result; // no parent ? strange - if (GetDiskFreeSpaceExW(dst, (PULARGE_INTEGER) &bytes, NULL, NULL)) { - result->High = bytes.High; - result->Low = bytes.Low; - } - FREE(dst); - return result; -} - -void checkFreeSpace(LauncherProperties * props, WCHAR * tmpDir, int64t * size) { - if(props->checkForFreeSpace) { - int64t * space = getFreeSpace(tmpDir); - DWORD result = 0; - result = ((space->High > size->High) || - (space->High == size->High && space->Low >= size->Low)); - - if(!result) { - WCHAR * available = NULL; - WCHAR * str = NULL; - WCHAR * required = NULL; - available = int64ttoWCHAR(space); - required = int64ttoWCHAR(size); - str = appendStringW(str, L"Not enough free space in "); - str = appendStringW(str, tmpDir); - str = appendStringW(str, L", available="); - str = appendStringW(str, available); - str = appendStringW(str, L", required="); - str = appendStringW(str, required); - - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, str, 1); - FREE(str); - FREE(available); - FREE(required); - props->status = ERROR_FREESPACE; - } - FREE(space); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... free space checking is disabled", 1); - } -} - -DWORD fileExists(WCHAR *path) { - WIN32_FILE_ATTRIBUTE_DATA attrs; - return GetFileAttributesExW(path, GetFileExInfoStandard, &attrs); -} - -DWORD isDirectory(WCHAR *path) { - WIN32_FILE_ATTRIBUTE_DATA attrs; - if(GetFileAttributesExW(path, GetFileExInfoStandard, &attrs)) { - return (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - } - else { - return 0; - } -} -WCHAR * getParentDirectory(WCHAR * dir) { - WCHAR * ptr = dir; - WCHAR * res = NULL; - while(1) { - if(searchW(ptr, FILE_SEP)==NULL) { - break; - } - ptr = searchW(ptr, FILE_SEP) + 1; - } - res = appendStringNW(NULL, 0, dir, getLengthW(dir) - getLengthW(ptr) - 1); - return res; -} -WCHAR * normalizePath(WCHAR * dir) { - WCHAR * directory = NULL; - WCHAR * ptr1, *ptr2, *ptr3; - DWORD i=0; - DWORD len; - ptr1 = searchW(dir, L":\\"); - ptr2 = searchW(dir, L":/"); - ptr3 = searchW(dir, L"\\\\"); - if(ptr1==NULL && ptr2==NULL && dir!=ptr3) { //relative path - directory = appendStringW(getCurrentDirectory(), FILE_SEP); - directory = appendStringW(directory, dir); - } else { - directory = appendStringW(NULL, dir); - } - len = getLengthW(directory); - - for(i=0;i status = ERROR_INPUTOUPUT; - } else { - SECURITY_ATTRIBUTES secattr; - int64t * minSize = newint64_t(0, 0); - - secattr.nLength = sizeof(SECURITY_ATTRIBUTES); - secattr.lpSecurityDescriptor = 0; - secattr.bInheritHandle = 1; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... creating directory itself... ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, directory, 1); - - checkFreeSpace(props, parent, minSize); - FREE(minSize); - - if(isOK(props)) { - props->status = (CreateDirectoryExW(parent, directory, &secattr)) ? ERROR_OK : ERROR_INPUTOUPUT; - if(!isOK(props)) { - props->status = (CreateDirectoryW(directory, &secattr)) ? ERROR_OK : ERROR_INPUTOUPUT; - } - props->status = (fileExists(directory)) ? ERROR_OK : ERROR_INPUTOUPUT; - - if(isOK(props)) { - SetFileAttributesW(directory, parentAttrs); - } else { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t create directory : ", directory, GetLastError()); - } - } - } - } - FREE(parent); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " parent is NULL ", 1); - props-> status = ERROR_INPUTOUPUT; - } -} - -#define a 16807 /* multiplier */ -#define m 2147483647L /* 2**31 - 1 */ -#define q 127773L /* m div a */ -#define r 2836 /* m mod a */ - -long nextRandDigit(long seed) -{ - unsigned long lo, hi; - - lo = a * (long)(seed & 0xFFFF); - hi = a * (long)((unsigned long)seed >> 16); - lo += (hi & 0x7FFF) << 16; - if (lo > m) - { - lo &= m; - ++lo; - } - lo += hi >> 15; - if (lo > m) - { - lo &= m; - ++lo; - } - return (long)lo; -} - -void createTempDirectory(LauncherProperties * props, WCHAR * argTempDir, DWORD createRndSubDir) { - WCHAR * t = (argTempDir!=NULL) ? appendStringW(NULL, argTempDir) : getSystemTemporaryDirectory(); - - WCHAR * nbiTmp = normalizePath(t); - FREE(t); - if(createRndSubDir) { - WCHAR * randString = newpWCHAR(6); - DWORD i=0; - DWORD initValue = GetTickCount() & 0x7FFFFFFF; - long value = (long) initValue; - nbiTmp = appendStringW(nbiTmp, L"\\NBI"); - - for(i=0;i<5;i++) { - value = nextRandDigit(value); - randString[i] = '0' + (WCHAR) (value% 10); - } - nbiTmp = appendStringW(appendStringW(nbiTmp, randString), L".tmp"); - FREE(randString); - } - - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Using temp directory for extracting data : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, nbiTmp, 1); - - if(fileExists(nbiTmp) ) { - if(!isDirectory(nbiTmp)) { - props->status = ERROR_INPUTOUPUT; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, ".. exists but not a directory", 1); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Output directory already exist so don`t create it", 1); - } - } - else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "creating directory...", 1); - createDirectory(props, nbiTmp); - if(isOK(props)) { - props->tmpDirCreated = 1; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Directory created : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, nbiTmp, 1); - // set hidden attribute - if(createRndSubDir) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Setting hidden attributes to ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, nbiTmp, 1); - - SetFileAttributesW(nbiTmp, GetFileAttributesW(nbiTmp) | FILE_ATTRIBUTE_HIDDEN); - } - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t create nbi temp directory : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, nbiTmp, 1); - } - } - props->tmpDir = nbiTmp; - return; -} - - -void deleteDirectory(LauncherProperties * props, WCHAR * dir) { - DWORD attrs = GetFileAttributesW(dir); - DWORD dwError; - DWORD count = 0 ; - if(attrs==INVALID_FILE_ATTRIBUTES) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t get attributes of the dir : ", dir, GetLastError()); - return; - } - if(!SetFileAttributesW(dir, attrs & FILE_ATTRIBUTE_NORMAL)) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t set attributes of the dir : ", dir, GetLastError()); - } - - - if(attrs & FILE_ATTRIBUTE_DIRECTORY) { - WIN32_FIND_DATAW FindFileData; - HANDLE hFind = INVALID_HANDLE_VALUE; - - WCHAR * DirSpec = appendStringW(appendStringW(NULL, dir), L"\\*" ); - - // Find the first file in the directory. - hFind = FindFirstFileW(DirSpec, &FindFileData); - - if (hFind == INVALID_HANDLE_VALUE) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t file with pattern ", DirSpec, GetLastError()); - } - else { - // List all the other files in the directory. - while (FindNextFileW(hFind, &FindFileData) != 0) { - if(lstrcmpW(FindFileData.cFileName, L".")!=0 && - lstrcmpW(FindFileData.cFileName, L"..")!=0 ) { - WCHAR * child = appendStringW(appendStringW(appendStringW(NULL, dir), FILE_SEP), FindFileData.cFileName); - deleteDirectory(props, child); - FREE(child); - } - } - - dwError = GetLastError(); - FindClose(hFind); - if (dwError != ERROR_NO_MORE_FILES) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t find file with pattern : ", DirSpec, dwError); - } - } - - // 20 tries in 2 seconds to delete the directory - while(!RemoveDirectoryW(dir) && count++ < 20) Sleep(100); - FREE(DirSpec); - } - else { - // 20 tries in 2 seconds to delete the file - while(!DeleteFileW(dir) && count++ < 20) Sleep(100); - } -} - - - - -WCHAR * getSystemTemporaryDirectory() { - WCHAR * expanded = newpWCHAR(MAX_PATH); - DWORD result; - if(GetTempPathW(MAX_PATH, expanded)!=0) { - return expanded; - } - - result = GetEnvironmentVariableW(L"TEMP", expanded, MAX_PATH); - if(result<=0 || result>MAX_PATH) { - //writeOutputLn("Can`t find variable TEMP"); - result = GetEnvironmentVariableW(L"TMP", expanded, MAX_PATH); - if(result<=0 || result>MAX_PATH) { - //writeOutputLn("Can`t find variable TMP"); - result = GetEnvironmentVariableW(L"USERPROFILE", expanded, MAX_PATH); - if(result>0 && result<=MAX_PATH) { - expanded = appendStringW(expanded, L"\\Local Settings\\Temp"); - } else{ - WCHAR * curdir = getCurrentDirectory(); - ZERO(expanded, sizeof(WCHAR) * MAX_PATH); - lstrcpynW(expanded, curdir, MAX_PATH); - FREE(curdir); - } - } - } - return expanded; -} - -WCHAR * getExePath() { - WCHAR * szPath = newpWCHAR(MAX_PATH); - - if( !GetModuleFileNameW( NULL, szPath, MAX_PATH ) ) { - FREE(szPath); - return NULL; - } else { - return szPath;//appendStringNW(NULL, 0, szPath, getLengthW(szPath)); - } -} - - -WCHAR * getExeName() { - WCHAR * szPath = newpWCHAR(MAX_PATH); - WCHAR * result = NULL; - if(GetModuleFileNameW( NULL, szPath, MAX_PATH )) { - WCHAR * lastSlash = szPath; - while(searchW(lastSlash, FILE_SEP)!=NULL) { - lastSlash = searchW(lastSlash, FILE_SEP) + 1; - } - result = appendStringW(NULL, lastSlash); - } - FREE(szPath); - return result; -} - -WCHAR * getExeDirectory() { - WCHAR * szPath = newpWCHAR(MAX_PATH); - WCHAR * result = NULL; - if(GetModuleFileNameW( NULL, szPath, MAX_PATH )) { - WCHAR * lastSlash = szPath; - while(searchW(lastSlash, FILE_SEP)!=NULL) { - lastSlash = searchW(lastSlash, FILE_SEP) + 1; - } - result = appendStringNW(NULL, 0 , szPath, - getLengthW(szPath) - getLengthW(lastSlash) - 1); - } - FREE(szPath); - return result; -} - -WCHAR * getCurrentDirectory() { - WCHAR * buf = newpWCHAR(MAX_PATH); - - if(GetCurrentDirectoryW(MAX_PATH, buf)!=0) { - return buf; - } else { - FREE(buf); - return NULL; - } -} -WCHAR * getCurrentUserHome() { - HANDLE hUser; - WCHAR * buf = NULL; - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hUser)) { - DWORD size = MAX_PATH; - buf = newpWCHAR(MAX_PATH); - GetUserProfileDirectoryW(hUser, buf, &size); - if (size > MAX_PATH) { - FREE(buf); - buf = newpWCHAR(size + 1); - if(!GetUserProfileDirectoryW(hUser, buf, &size)) { - FREE(buf); - } - } - CloseHandle(hUser); - } - if(buf==NULL) { - DWORD size = MAX_PATH; - buf = newpWCHAR(size); - size = GetEnvironmentVariableW(L"USERPROFILE", buf, MAX_PATH); - if( size > MAX_PATH) { - FREE(buf); - buf = newpWCHAR(size + 1); - GetEnvironmentVariableW(L"USERPROFILE", buf, size); - } else if (size==0) { - FREE(buf); - } - } - return buf; -} -int64t * getFileSize(WCHAR * path) { - WIN32_FILE_ATTRIBUTE_DATA wfad; - int64t * res = newint64_t(0, 0); - if (GetFileAttributesExW(path, - GetFileExInfoStandard, - &wfad)) { - res->Low = wfad.nFileSizeLow; - res->High = wfad.nFileSizeHigh ; - } - return res; -} - -void update_crc32(DWORD * crc, char *ptr, DWORD size) { - while( size-- ) *crc = CRC32_TABLE[(unsigned char) (*crc^*ptr++)] ^ (*crc>>8); -} diff --git a/nbi/engine/native/launcher/windows/src/FileUtils.h b/nbi/engine/native/launcher/windows/src/FileUtils.h deleted file mode 100644 index 0b01ace4585a..000000000000 --- a/nbi/engine/native/launcher/windows/src/FileUtils.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _FileUtils_H -#define _FileUtils_H - -#include -#include "Errors.h" -#include "Types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define OUTPUT_LEVEL_DEBUG 0 -#define OUTPUT_LEVEL_NORMAL 1 - - - extern const WCHAR * FILE_SEP; - extern const long CRC32_TABLE[256]; - void update_crc32(DWORD * crc32, char * buf, DWORD size); - int64t * getFreeSpace(WCHAR *path); - int64t * getFileSize(WCHAR * path); - void checkFreeSpace(LauncherProperties * props, WCHAR * tmpDir, int64t * size); - WCHAR * getParentDirectory(WCHAR * dir); - void createDirectory(LauncherProperties * props, WCHAR * directory); - void createTempDirectory(LauncherProperties * props, WCHAR * argTempDir, DWORD createRndSubDir); - void deleteDirectory(LauncherProperties * props,WCHAR * dir); - WCHAR * getExePath(); - WCHAR * getExeName(); - WCHAR * getExeDirectory(); - - WCHAR * getSystemTemporaryDirectory(); - DWORD isDirectory(WCHAR *path); - WCHAR * getCurrentDirectory(); - WCHAR * getCurrentUserHome(); - - - void writeMessageW(LauncherProperties * props, DWORD level,DWORD isErr, const WCHAR * message, DWORD needEndOfLine); - void writeMessageA(LauncherProperties * props,DWORD level, DWORD isErr, const char * message, DWORD needEndOfLine); - void writeErrorA(LauncherProperties * props,DWORD level, DWORD isErr, const char * message, const WCHAR * param, DWORD errorCode); - void writeDWORD(LauncherProperties * props,DWORD level, DWORD isErr, const char * message, DWORD value, DWORD needEndOfLine); - void writeint64t(LauncherProperties * props,DWORD level, DWORD isErr, const char * message, int64t * value, DWORD needEndOfLine); - - void flushHandle(HANDLE hd); - DWORD fileExists(WCHAR * path); - - #ifdef __cplusplus -} -#endif - -#endif /* _FileUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/JavaUtils.c b/nbi/engine/native/launcher/windows/src/JavaUtils.c deleted file mode 100644 index 9e4245e018d8..000000000000 --- a/nbi/engine/native/launcher/windows/src/JavaUtils.c +++ /dev/null @@ -1,796 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include "JavaUtils.h" -#include "RegistryUtils.h" -#include "StringUtils.h" -#include "SystemUtils.h" -#include "FileUtils.h" -#include "ProcessUtils.h" -#include "Launcher.h" -#include "Main.h" - -const DWORD JAVA_VERIFICATION_PROCESS_TIMEOUT = 10000; // 10sec -const DWORD UNPACK200_EXTRACTION_TIMEOUT = 60000; //60 seconds on each file -const DWORD JAVA_VERIFICATION_PROCESS_PRIORITY = NORMAL_PRIORITY_CLASS; -const WCHAR * JAVA_EXE_SUFFIX = L"\\bin\\java.exe"; -const WCHAR * UNPACK200_EXE_SUFFIX = L"\\bin\\unpack200.exe"; -const WCHAR * JAVA_LIB_SUFFIX = L"\\lib"; -const WCHAR * PACK_GZ_SUFFIX = L".pack.gz"; -const WCHAR * JAR_PACK_GZ_SUFFIX = L".jar.pack.gz"; - -const DWORD JVM_EXTRACTION_TIMEOUT = 180000; //180sec - -WCHAR * JAVA_REGISTRY_KEYS [] = { - L"SOFTWARE\\JavaSoft\\Java Runtime Environment", - L"SOFTWARE\\JavaSoft\\Java Development Kit", - L"SOFTWARE\\JavaSoft\\JDK", - L"SOFTWARE\\JRockit\\Java Runtime Environment", - L"SOFTWARE\\JRockit\\Java Development Kit", - L"SOFTWARE\\IBM\\Java Runtime Environment", - L"SOFTWARE\\IBM\\Java2 Runtime Environment", - L"SOFTWARE\\IBM\\Java Development Kit", -}; -WCHAR * JAVA_HOME = L"JavaHome"; -WCHAR * CURRENT_VERSION = L"CurrentVersion"; - -WCHAR * getJavaHomeValue(WCHAR *parentkey, WCHAR *subkey, BOOL access64key) { - return getStringValuePC(HKEY_LOCAL_MACHINE, parentkey, subkey, JAVA_HOME, access64key); -} - - -WCHAR * getTestJVMFileName(WCHAR * testJVMFile) { - WCHAR * filePtr = testJVMFile; - WCHAR * testJavaClass = NULL; - - if(filePtr!=NULL) { - WCHAR * dotClass = NULL; - while(searchW(filePtr, L"\\")!=NULL) { - filePtr = searchW(filePtr, L"\\"); - filePtr++; - } - dotClass = searchW(filePtr, L".class"); - - if(dotClass!=NULL) { - testJavaClass = appendStringNW(NULL, 0, filePtr, getLengthW(filePtr) - getLengthW(dotClass)); - } - } - return testJavaClass; -} - - -//returns 0 if equals, 1 if first > second, -1 if first < second -char compareJavaVersion(JavaVersion * first, JavaVersion * second) { - if(first==NULL) return (second==NULL) ? 0 : -1; - if(second==NULL) return -1; - if(first->major == second->major) { - if(first->minor == second->minor) { - if(first->micro == second->micro) { - if(first->update == second->update) return 0; - return (first->update > second->update) ? 1 : -1; - } - return (first->micro > second->micro) ? 1 : -1; - } - return (first->minor > second->minor) ? 1 : -1; - } else { - return (first->major > second->major) ? 1 : -1; - } -} -DWORD isJavaCompatible(JavaProperties *currentJava, JavaCompatible ** compatibleJava, DWORD number) { - JavaVersion * current = currentJava->version; - DWORD i = 0 ; - - for(i=0;iminVersion) >= 0 && - compareJavaVersion(current, compatibleJava[i]->maxVersion) <= 0) ? check : 0; - - if (check) { - if(compatibleJava[i]->vendor!=NULL) { - check = (searchA(currentJava->vendor, compatibleJava[i]->vendor) != NULL) ? check : 0; - } - if (compatibleJava[i]->osName!=NULL) { - check = (searchA(currentJava->osName, compatibleJava[i]->osName)!=NULL) ? check : 0; - } - - if (compatibleJava[i]->osArch!=NULL) { - check = (searchA(currentJava->osArch, compatibleJava[i]->osArch)!=NULL) ? check : 0; - } - if(check) { - return 1; - } - } - } - return 0; -} - -JavaVersion * getJavaVersionFromString(char * string, DWORD * result) { - JavaVersion *vers = NULL; - if(getLengthA(string)<3) { - return vers; - } - - const char *p = string; - - // get major - long major = 0; - while(*p!=0) { - char c = *p++; - if(c>='0' && c<='9') { - major = (major) * 10 + c - '0'; - if (major > 999) return vers; - continue; - } else if(c=='.' || c=='+'){ - break; - } else{ - return vers; - } - } - - // get minor - long minor = 0; - while(*p!=0) { - char c = *p; - if(c>='0' && c<='9') { - minor = (minor) * 10 + c - '0'; - p++; - continue; - } - break; - } - - *result = ERROR_OK; - vers = (JavaVersion*) LocalAlloc(LPTR, sizeof(JavaVersion)); - vers->major = major; - vers->minor = minor; - vers->micro = 0; - vers->update = 0; - ZERO(vers->build, 128); - - if(p[0]=='.') { // micro... - p++; - while(*p!=0) { - char c = *p; - if(c>='0' && c<='9') { - vers->micro = (vers->micro) * 10 + c - '0'; - p++; - continue; - } else if(c=='_') {//update - p++; - while((c = *p) != 0) { - p++; - if(c>='0' && c<='9') { - vers->update = (vers->update) * 10 + c - '0'; - continue; - } else { - break; - } - } - } else { - if(*p!=0) p++; - } - if(c=='-' && *p!=0) { // build number - lstrcpyn(vers->build, p, min(127, getLengthA(p)+1)); - } - break; - } - } - return vers; -} - -DWORD getJavaPropertiesFromOutput(LauncherProperties * props, char *str, JavaProperties ** javaProps) { - DWORD separators = getLineSeparatorNumber(str); - DWORD result = ERROR_INPUTOUPUT; - * javaProps = NULL; - if(separators == TEST_JAVA_PARAMETERS) { - char * start; - char * end; - char * javaVersion; - char * javaVmVersion; - char * javaVendor; - char * osName; - char * osArch; - char * string; - JavaVersion * vers; - - start = str; - end = searchA(start, "\n"); - - javaVersion = appendStringN(NULL, 0, start, getLengthA(start) - getLengthA(end)-1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " java.version = ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, javaVersion, 1); - start = end + 1; - end = searchA(start, "\n"); - - - javaVmVersion = appendStringN(NULL, 0, start, getLengthA(start) - getLengthA(end)-1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " java.vm.version = ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, javaVmVersion, 1); - start = end + 1; - end = searchA(start, "\n"); - - javaVendor = appendStringN(NULL, 0, start, getLengthA(start) - getLengthA(end)-1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " java.vendor = ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, javaVendor, 1); - start = end + 1; - end = searchA(start, "\n"); - - osName = appendStringN(NULL, 0, start, getLengthA(start) - getLengthA(end)-1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " os.name = ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, osName, 1); - start = end + 1; - end = searchA(start, "\n"); - - osArch = appendStringN(NULL, 0, start, getLengthA(start) - getLengthA(end)-1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " os.arch = ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, osArch, 2); - - string = javaVersion; - - - if(javaVmVersion!=NULL) { - string = searchA(javaVmVersion, javaVersion); - if(string==NULL) { - string = javaVersion; - } - } - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... getting java version from string : ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, string, 1); - - vers = getJavaVersionFromString(string, & result); - if(javaProps != NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... some java there", 1); - * javaProps = (JavaProperties *) LocalAlloc(LPTR, sizeof(JavaProperties)); - (*javaProps)->version = vers; - (*javaProps)->vendor = javaVendor; - (*javaProps)->osName = osName; - (*javaProps)->osArch = osArch; - (*javaProps)->javaHome = NULL; - (*javaProps)->javaExe = NULL; - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... no java there", 1); - FREE(javaVendor); - FREE(osName); - FREE(osArch); - } - FREE(javaVmVersion); - FREE(javaVersion); - } - return result; -} - - -void getJavaProperties(WCHAR * location, LauncherProperties * props, JavaProperties ** javaProps) { - WCHAR *testJavaClass = props->testJVMClass; - WCHAR *javaExecutable = getJavaResource(location, JAVA_EXE_SUFFIX); - WCHAR *libDirectory = getJavaResource(location, JAVA_LIB_SUFFIX); - - if(fileExists(javaExecutable) && testJavaClass!=NULL && isDirectory(libDirectory)) { - WCHAR * command = NULL; - HANDLE hRead; - HANDLE hWrite; - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... java hierarchy there", 1); - // \bin\java.exe exists - - - appendCommandLineArgument(&command, javaExecutable); - appendCommandLineArgument(&command, L"-classpath"); - appendCommandLineArgument(&command, props->testJVMFile->resolved); - appendCommandLineArgument(&command, testJavaClass); - - - CreatePipe(&hRead, &hWrite, NULL, 0); - // Start the child process. - executeCommand(props, command, NULL, JAVA_VERIFICATION_PROCESS_TIMEOUT, hWrite, INVALID_HANDLE_VALUE, JAVA_VERIFICATION_PROCESS_PRIORITY); - if(props->status!= ERROR_ON_EXECUTE_PROCESS && props->status!= ERROR_PROCESS_TIMEOUT) { - char * output = readHandle(hRead); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, " output :\n", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, output, 1); - - props->status = getJavaPropertiesFromOutput(props, output, javaProps); - if(props->status == ERROR_OK) { - (*javaProps)->javaHome = appendStringW(NULL, location); - (*javaProps)->javaExe = appendStringW(NULL, javaExecutable); - } - FREE(output); - } else if(props->status == ERROR_PROCESS_TIMEOUT) { - // java verification process finished by time out - props->status = ERROR_INPUTOUPUT; - } - FREE(command); - CloseHandle(hWrite); - CloseHandle(hRead); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... not a java hierarchy", 1); - props->status = ERROR_INPUTOUPUT; - } - FREE(libDirectory); - FREE(javaExecutable); -} - - - -char * getJavaVersionFormatted(const JavaProperties * javaProps) { - char *result = NULL; - if(javaProps!=NULL) { - JavaVersion * version = javaProps->version; - if(version!=NULL) { - char * majorStr = long2char(version->major); - char * minorStr = long2char(version->minor); - char * microStr = long2char(version->micro); - result = appendString(result, majorStr); - result = appendString(result, "."); - result = appendString(result, minorStr); - result = appendString(result, "."); - result = appendString(result, microStr); - FREE(majorStr); - FREE(minorStr); - FREE(microStr); - - if(version->update!=0) { - char * updateStr = long2charN(version->update, 2); - result = appendString(result, "_"); - result = appendString(result, updateStr); - FREE(updateStr); - } - if(getLengthA(version->build) > 0) { - result = appendString(result, "-"); - result = appendString(result, version->build); - } - } - } - return result; -} - - -JavaCompatible * newJavaCompatible() { - JavaCompatible * props = (JavaCompatible *) LocalAlloc(LPTR, sizeof(JavaCompatible)); - props->minVersion = NULL; - props->maxVersion = NULL; - props->vendor = NULL; - props->osName = NULL; - return props; -} - -void freeJavaProperties(JavaProperties ** props) { - if(*props!=NULL) { - FREE((*props)->version); - FREE((*props)->javaHome); - FREE((*props)->javaExe); - FREE((*props)->vendor); - FREE(*props); - } -} - -WCHAR * getJavaResource(WCHAR * location, const WCHAR * suffix) { - return appendStringW(appendStringW(NULL, location), suffix); -} - - -void searchCurrentJavaRegistry(LauncherProperties * props, BOOL access64key) { - DWORD i=0; - WCHAR ** keys = JAVA_REGISTRY_KEYS; - DWORD k=0; - WCHAR * buffer = newpWCHAR(MAX_LEN_VALUE_NAME); - HKEY rootKeys [2] = {HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER}; - DWORD rootKeysNumber = sizeof(rootKeys)/sizeof(HKEY); - DWORD keysNumber = sizeof(JAVA_REGISTRY_KEYS)/sizeof(WCHAR*); - DWORD status = ERROR_OK; - - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in CurrentVersion values...", 1); - - - for ( k = 0; k < rootKeysNumber; k++) { - for(i=0; i < keysNumber;i++) { - if(isTerminated(props)) { - return; - } - else { - - WCHAR * value = getStringValue(rootKeys[k], keys[i], CURRENT_VERSION, access64key); - if(value!=NULL) { - WCHAR *javaHome = getStringValuePC(rootKeys[k], keys[i], value, JAVA_HOME, access64key); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... ", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, (rootKeys[k]==HKEY_LOCAL_MACHINE) ? "HKEY_LOCAL_MACHINE" : "HKEY_CURRENT_USER", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "\\", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, keys[i], 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "\\", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, CURRENT_VERSION, 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "->", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, value, 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, JAVA_HOME, 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "] = ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, javaHome, 1); - - FREE(value); - trySetCompatibleJava(javaHome, props); - FREE(javaHome); - if(props->java!=NULL) { - FREE(buffer); - return; - } - } - } - } - } - - - // we found no CurrentVersion java... just search for other possible keys - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in other values...", 1); - - - for(k=0;k 0 && ret <= MAX_PATH) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " <", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, ENVS[i], 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "> = ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, buffer, 1); - trySetCompatibleJava(buffer, props); - if(props->java!=NULL) { - break; - } - } - } -} - - - - -void unpackJars(LauncherProperties * props, WCHAR * jvmDir, WCHAR * startDir, WCHAR * unpack200exe) { - DWORD attrs; - DWORD dwError; - DWORD count = 0 ; - - if(!isOK(props)) return; - attrs = GetFileAttributesW(startDir); - if(attrs==INVALID_FILE_ATTRIBUTES) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t get attributes of the file : ", startDir, GetLastError()); - return; - } - if(attrs & FILE_ATTRIBUTE_DIRECTORY) { // is directory - WIN32_FIND_DATAW FindFileData; - HANDLE hFind = INVALID_HANDLE_VALUE; - - WCHAR * DirSpec = appendStringW(appendStringW(NULL, startDir), L"\\*" ); - - // Find the first file in the directory. - hFind = FindFirstFileW(DirSpec, &FindFileData); - - if (hFind == INVALID_HANDLE_VALUE) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t file with pattern ", DirSpec, GetLastError()); - } - else { - // List all the other files in the directory. - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... listing directory ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, startDir, 1); - - while (FindNextFileW(hFind, &FindFileData) != 0 && isOK(props)) { - if(lstrcmpW(FindFileData.cFileName, L".")!=0 && - lstrcmpW(FindFileData.cFileName, L"..")!=0) { - WCHAR * child = NULL; - - child = appendStringW(appendStringW(appendStringW(NULL, startDir), FILE_SEP), FindFileData.cFileName); - if(isDirectory(child)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... directory : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, child, 1); - unpackJars(props, jvmDir, child, unpack200exe); - } else if(searchW(FindFileData.cFileName, JAR_PACK_GZ_SUFFIX)!=NULL) { - WCHAR * jarName = appendStringW(appendStringW( - appendStringW(NULL, startDir), FILE_SEP), - appendStringNW(NULL, 0, FindFileData.cFileName, - getLengthW(FindFileData.cFileName) - getLengthW(PACK_GZ_SUFFIX))); - WCHAR * unpackCommand = NULL; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... packed jar : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, child, 1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... jar name : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, jarName, 1); - - - appendCommandLineArgument(&unpackCommand, unpack200exe); - appendCommandLineArgument(&unpackCommand, L"-r"); // remove input file - appendCommandLineArgument(&unpackCommand, child); - appendCommandLineArgument(&unpackCommand, jarName); - - executeCommand(props, unpackCommand, NULL, UNPACK200_EXTRACTION_TIMEOUT, props->stdoutHandle, props->stderrHandle, NORMAL_PRIORITY_CLASS); - FREE(unpackCommand); - if(!isOK(props)) { - if(props->status==ERROR_PROCESS_TIMEOUT) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... could not unpack file : timeout", 1); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... an error occured unpacking the file", 1); - } - props->exitCode = props->status; - } - FREE(jarName); - } - FREE(child); - } - } - - dwError = GetLastError(); - FindClose(hFind); - if (dwError != ERROR_NO_MORE_FILES) { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t find file with pattern : ", DirSpec, dwError); - } - } - FREE(DirSpec); - } - -} -void installJVM(LauncherProperties * props, LauncherResource *jvm) { - WCHAR * command = NULL; - WCHAR * jvmDir = getParentDirectory(jvm->resolved); - - jvmDir = appendStringW(jvmDir, L"\\_jvm"); - createDirectory(props, jvmDir); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... cannot create dir for JVM extraction :", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, jvmDir, 1); - FREE(jvmDir); - return; - } - - appendCommandLineArgument(&command, jvm->resolved); - appendCommandLineArgument(&command, L"-d"); - appendCommandLineArgument(&command, jvmDir); - - executeCommand(props, command, jvmDir, JVM_EXTRACTION_TIMEOUT, props->stdoutHandle, props->stderrHandle, NORMAL_PRIORITY_CLASS); - FREE(command); - if(!isOK(props)) { - if(props->status==ERROR_PROCESS_TIMEOUT) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... could not extract JVM : timeout", 1); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... an error occured during running JVM extraction file", 1); - } - props->exitCode = props->status; - } else { - WCHAR * unpack200exe = appendStringW(appendStringW(NULL, jvmDir), UNPACK200_EXE_SUFFIX); - if(fileExists(unpack200exe)) { - unpackJars(props, jvmDir, jvmDir, unpack200exe); - } else { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... no unpack200 command", 1); - props->status = ERROR_BUNDLED_JVM_EXTRACTION; - } - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Could not unpack200 the JVM jars", 1); - } - FREE(unpack200exe); - } - FREE(jvm->resolved); - jvm->resolved = jvmDir; -} - -void installBundledJVMs(LauncherProperties * props) { - if ( props->jvms->size > 0 ) { - DWORD i=0; - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... search for bundled JVMs", 1); - for(i=0;ijvms->size; i++) { - if(props->jvms->items[i]->type==0 && !isTerminated(props)) { - resolvePath(props, props->jvms->items[i]); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... install bundled JVM ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, props->jvms->items[i]->resolved, 1); - installJVM(props, props->jvms->items[i]); - if(isTerminated(props)) return; - if(isOK(props)) { - trySetCompatibleJava(props->jvms->items[i]->resolved, props); - if(props->java!=NULL) { - break; - } else { - props->status = ERROR_BUNDLED_JVM_VERIFICATION; - return; - } - } - else { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... error occured during JVM extraction", 1); - props->status = ERROR_BUNDLED_JVM_EXTRACTION; - return; - } - } - } - } -} -void searchJavaInstallationFolder(LauncherProperties * props) { - char executablePath [MAX_PATH]; - GetModuleFileName(0, executablePath, MAX_PATH); - char * pch = strrchr(executablePath, '\\'); - char installationFolder [MAX_PATH]= ""; - int i = 0; - int end = (int) (pch - executablePath); - printf("%i", end); - for(i; i < end; i++) { - installationFolder[i] = executablePath[i]; - } - strcat(installationFolder, "\\bin\\jre"); - - // check if JRE is in installation folder - WCHAR * nestedJreFolder = toWCHAR(installationFolder); - if (!fileExists(nestedJreFolder)) { - // if not exists - return - return; - } - - // if exists - copy to temp folder to run uninstaller on that jvm - // to be able to delete jvm in installation folder - WCHAR * tempJreFolder = NULL; - tempJreFolder = appendStringW(tempJreFolder, props->testJVMFile->resolved); - tempJreFolder = appendStringW(tempJreFolder, L"\\_jvm\\"); - - WCHAR * command = NULL; - appendCommandLineArgument(&command, L"xcopy"); - appendCommandLineArgument(&command, nestedJreFolder); - appendCommandLineArgument(&command, tempJreFolder); - appendCommandLineArgument(&command, L"/e"); - appendCommandLineArgument(&command, L"/y"); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Copying nested JRE to temp folder", 0); - - executeCommand(props, command, NULL, JVM_EXTRACTION_TIMEOUT, props->stdoutHandle, props->stderrHandle, NORMAL_PRIORITY_CLASS); - - if (fileExists(tempJreFolder)) { - trySetCompatibleJava(tempJreFolder, props); - } -} -void searchJavaSystemLocations(LauncherProperties * props) { - if ( props->jvms->size > 0 ) { - DWORD i=0; - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search jvm using some predefined locations", 1); - for(i=0;ijvms->size && !isTerminated(props);i++) { - resolvePath(props, props->jvms->items[i]); - if(props->jvms->items[i]->type!=0) { // bundled JVMs are already checked - trySetCompatibleJava(props->jvms->items[i]->resolved, props); - if(props->java!=NULL) { - break; - } - } - } - } -} -void findSystemJava(LauncherProperties *props) { - // install bundled JVMs if any - if(isTerminated(props)) return; - installBundledJVMs(props); - - if(!isOK(props) || isTerminated(props)) return; - // search in /bin/jre - if(props->java==NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in installation folder", 1); - searchJavaInstallationFolder(props); - } - // search JVM in the system paths - if(props->java==NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in the system paths", 1); - searchJavaSystemLocations(props); - } - - if(isTerminated(props)) return; - if(props->java==NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in environment variables", 1); - searchJavaFromEnvVariables(props); - } - - // search JVM in the registry - if(isTerminated(props)) return; - if(props->java==NULL) { - if(IsWow64) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in 64-bit registry", 1); - searchCurrentJavaRegistry(props, 1); - } - if(props->java==NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search java in 32-bit registry", 1); - searchCurrentJavaRegistry(props, 0); - } - } -} - - -void printJavaProperties(LauncherProperties * props, JavaProperties * javaProps) { - if(javaProps!=NULL) { - char * jv = getJavaVersionFormatted(javaProps); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Current Java:", 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " javaHome: ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->javaHome, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " javaExe: ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->javaExe, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " version: ", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, jv, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " vendor: ", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->vendor, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " os.name: ", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->osName, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " os.arch: ", 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->osArch, 1); - FREE(jv); - } -} diff --git a/nbi/engine/native/launcher/windows/src/JavaUtils.h b/nbi/engine/native/launcher/windows/src/JavaUtils.h deleted file mode 100644 index fa9109d068c7..000000000000 --- a/nbi/engine/native/launcher/windows/src/JavaUtils.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _JavaUtils_H -#define _JavaUtils_H - -#include -#include "Launcher.h" -#include "Types.h" -#include "Errors.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// java.version -// java.vm.version -// java.vendor -// os.name -// os.arch -#define TEST_JAVA_PARAMETERS 5 -#define MAX_LEN_VALUE_NAME 16383 - -WCHAR * getJavaResource(WCHAR * location, const WCHAR * suffix); - -void getJavaProperties(WCHAR * location, LauncherProperties * props, JavaProperties ** javaProps); - -void findSystemJava(LauncherProperties * props); - -JavaVersion * getJavaVersionFromString(char * string, DWORD * result); - -char compareJavaVersion(JavaVersion * first, JavaVersion * second); - -DWORD isJavaCompatible(JavaProperties *currentJava, JavaCompatible ** compatibleJava, DWORD number); - -void printJavaProperties(LauncherProperties * props, JavaProperties * javaProps); - -void freeJavaProperties(JavaProperties ** props); - -void installJVM(LauncherProperties * props, LauncherResource *jvm); - -JavaCompatible * newJavaCompatible(); - -#ifdef __cplusplus -} -#endif - -#endif /* _JavaUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/Launcher.c b/nbi/engine/native/launcher/windows/src/Launcher.c deleted file mode 100644 index 95bdcbd45630..000000000000 --- a/nbi/engine/native/launcher/windows/src/Launcher.c +++ /dev/null @@ -1,1009 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include "FileUtils.h" -#include "StringUtils.h" -#include "JavaUtils.h" -#include "RegistryUtils.h" -#include "Launcher.h" -#include "ProcessUtils.h" -#include "StringUtils.h" -#include "ExtractUtils.h" -#include "Main.h" -#include "shlobj.h" - -const DWORD NUMBER_OF_HELP_ARGUMENTS = 11; -const DWORD READ_WRITE_BUFSIZE = 65536; -const WCHAR * outputFileArg = L"--output"; -const WCHAR * javaArg = L"--javahome"; -const WCHAR * debugArg = L"--verbose"; -const WCHAR * tempdirArg = L"--tempdir"; -const WCHAR * classPathPrepend = L"--classpath-prepend"; -const WCHAR * classPathAppend = L"--classpath-append"; -const WCHAR * extractArg = L"--extract"; -const WCHAR * helpArg = L"--help"; -const WCHAR * helpOtherArg = L"/?"; -const WCHAR * silentArg = L"--silent"; -const WCHAR * nospaceCheckArg = L"--nospacecheck"; -const WCHAR * localeArg = L"--locale"; - -const WCHAR * javaParameterPrefix = L"-J"; - -const WCHAR * NEW_LINE = L"\n"; - -const WCHAR * CLASSPATH_SEPARATOR = L";"; -const WCHAR * CLASS_SUFFIX = L".class"; - - -DWORD isLauncherArgument(LauncherProperties * props, WCHAR * value) { - DWORD i=0; - for(i=0;ilauncherCommandArguments->size;i++) { - if(lstrcmpW(props->launcherCommandArguments->items[i], value)==0) { - return 1; - } - } - return 0; -} - -DWORD getArgumentIndex(LauncherProperties * props, const WCHAR *arg, DWORD removeArgument) { - WCHARList *cmd = props->commandLine; - DWORD i=0; - for(i=0;isize;i++) { - if(cmd->items[i]!=NULL) { // argument has not been cleaned yet - if(lstrcmpW(arg, cmd->items[i])==0) { //argument is the same as the desired - if(removeArgument) FREE(cmd->items[i]); // free it .. we don`t need it anymore - return i; - } - } - } - return cmd->size; -} - -DWORD argumentExists(LauncherProperties * props, const WCHAR *arg, DWORD removeArgument) { - DWORD index = getArgumentIndex(props, arg, removeArgument); - return (index < props->commandLine->size); - -} -WCHAR * getArgumentValue(LauncherProperties * props, const WCHAR *arg, DWORD removeArgument, DWORD mandatory) { - WCHARList *cmd = props->commandLine; - WCHAR * result = NULL; - DWORD i = getArgumentIndex(props, arg, removeArgument); - if((i+1) < cmd->size) { - //we have at least one more argument - if(mandatory || !isLauncherArgument(props, cmd->items[i+1])) { - result = appendStringW(NULL, cmd->items[i+1]); - if(removeArgument) FREE(cmd->items[i+1]); - } - } - return result; -} - - -void setOutputFile(LauncherProperties * props, WCHAR *path) { - HANDLE out = INVALID_HANDLE_VALUE ; - - out = CreateFileW(path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0); - if(out!=INVALID_HANDLE_VALUE) { - SetStdHandle(STD_OUTPUT_HANDLE, out); - SetStdHandle(STD_ERROR_HANDLE, out); - props->stdoutHandle = out; - props->stderrHandle = out; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "[CMD Argument] Redirect output to file : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, path, 1); - } else { - WCHAR * err = NULL; - DWORD code = GetLastError(); - props->status = ERROR_INPUTOUPUT; - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "[CMD Argument] Can`t create file: ", path, code); - err = getErrorDescription(code); - showMessageW(props, L"Can`t redirect output to file!\n\nRequested file : %s\n%s", 2, path, err); - FREE(err); - } -} - -void setOutput(LauncherProperties * props) { - WCHAR * file = props->userDefinedOutput; - if(file!=NULL) { - DWORD exists = fileExists(file); - if((exists && !isDirectory(file) )|| !exists) { - setOutputFile(props, file); - } - } - - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, - (props->outputLevel == OUTPUT_LEVEL_DEBUG) ? - "[CMD Argument] Using debug output." : - "Using normal output." , 1); - -} - - -void loadLocalizationStrings(LauncherProperties *props) { - - // load localized messages - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Loading I18N Strings.", 1); - loadI18NStrings(props); - - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Error! Can`t load i18n strings!!", 1); - showErrorW(props, INTEGRITY_ERROR_PROP, 1, props->exeName); - } -} - -void readDefaultRoots(LauncherProperties *props) { - TCHAR appDataValueTChar[MAX_PATH]; - TCHAR localAppDataValueTChar[MAX_PATH]; - SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appDataValueTChar); - SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, localAppDataValueTChar); - WCHAR* appDataValue = toWCHAR(appDataValueTChar); - WCHAR* localAppDataValue = toWCHAR(localAppDataValueTChar); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Reading Default Userdir and Cachedir roots...", 1); - - props->defaultUserDirRoot = appendStringW(appDataValue, toWCHAR("\\NetBeans")); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "defaultUserDirRoot: ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->defaultUserDirRoot, 1); - - props->defaultCacheDirRoot = appendStringW(localAppDataValue, toWCHAR("\\NetBeans\\Cache")); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "defaultCacheDirRoot: ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->defaultCacheDirRoot, 1); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "End of Reading Default Roots.", 1); -} - -void createTMPDir(LauncherProperties * props) { - WCHAR * argTempDir = NULL; - DWORD createRndSubDir = 1; - - if((argTempDir = props->userDefinedExtractDir) !=NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "[CMD Argument] Extract data to directory: ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 1, argTempDir, 1); - createRndSubDir = 0; - } else if((argTempDir = props->userDefinedTempDir) !=NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[CMD Argument] Using tmp directory: ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, argTempDir, 1); - } - - createTempDirectory(props, argTempDir, createRndSubDir); - if(!isOK(props)) { - showErrorW(props, CANT_CREATE_TEMP_DIR_PROP, 1, props->tmpDir); - } -} - -void checkExtractionStatus(LauncherProperties *props) { - if(props->status == ERROR_FREESPACE) { - DWORD hiMB = props->bundledSize->High; - DWORD lowMB = props->bundledSize->Low; - DWORD hiMult = (hiMB!=0) ? ((MAXDWORD / 1024) + 1) / 1024 : 0; - DWORD dw = hiMult * hiMB + lowMB / (1024 * 1024) + 1; - WCHAR * size = DWORDtoWCHAR(dw); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Not enought free space !", 1); - showErrorW(props, NOT_ENOUGH_FREE_SPACE_PROP, 2, size, tempdirArg); - FREE(size); - } - else if(props->status == ERROR_INTEGRITY) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "Error! Can`t extract data from bundle. Seems to be integrirty error!", 1); - showErrorW(props, INTEGRITY_ERROR_PROP, 1, props->exeName); - } -} - - -void trySetCompatibleJava(WCHAR * location, LauncherProperties * props) { - if(isTerminated(props)) return; - if(location!=NULL) { - JavaProperties * javaProps = NULL; - - if(inList(props->alreadyCheckedJava, location)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... already checked location ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, location, 1); - // return here and don`t proceed with private jre checking since it`s already checked as well - return; - } else { - props->alreadyCheckedJava = addStringToList(props->alreadyCheckedJava, location); - } - - getJavaProperties(location, props, &javaProps); - - if(isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... some java at ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, location, 1); - // some java there, check compatibility - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... checking compatibility of java : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->javaHome, 1); - if(isJavaCompatible(javaProps, props->compatibleJava, props->compatibleJavaNumber)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... compatible", 1); - props->java = javaProps; - } else { - props->status = ERROR_JVM_UNCOMPATIBLE; - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... uncompatible", 1); - freeJavaProperties(&javaProps); - } - } else { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... no java at ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, location, 1); - if (props->status==ERROR_INPUTOUPUT) { - props->status = ERROR_JVM_NOT_FOUND; - } - } - - if(props->status == ERROR_JVM_NOT_FOUND) { // check private JRE - //DWORD privateJreStatus = props->status; - WCHAR * privateJre = appendStringW(NULL, location); - privateJre = appendStringW(privateJre, L"\\jre"); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... check private jre at ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, privateJre, 1); - - if(inList(props->alreadyCheckedJava, privateJre)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... already checked location ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, privateJre, 1); - } else { - props->alreadyCheckedJava = addStringToList(props->alreadyCheckedJava, privateJre); - - getJavaProperties(privateJre, props, &javaProps); - if(isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "... checking compatibility of private jre : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, javaProps->javaHome, 1); - if(isJavaCompatible(javaProps, props->compatibleJava, props->compatibleJavaNumber)) { - props->java = javaProps; - props->status = ERROR_OK; - } else { - freeJavaProperties(&javaProps); - props->status = ERROR_JVM_UNCOMPATIBLE; - } - } else if (props->status==ERROR_INPUTOUPUT) { - props->status = ERROR_JVM_NOT_FOUND; - } - } - FREE(privateJre); - } - } else { - props->status = ERROR_JVM_NOT_FOUND; - } -} - -void resolveTestJVM(LauncherProperties * props) { - WCHAR * testJVMFile = NULL; - WCHAR * testJVMClassPath = NULL; - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Resolving testJVM classpath...", 1); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... first step : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->path, 1); - resolvePath(props, props->testJVMFile); - testJVMFile = props->testJVMFile->resolved; - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... second : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->resolved, 1); - - - if(isDirectory(testJVMFile)) { // the directory of the class file is set - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : directory ", 1); - testJVMClassPath = appendStringW(NULL, testJVMFile); - } else { // testJVMFile is either .class file or .jar/.zip file with the neccessary class file - WCHAR * dir = getParentDirectory(testJVMFile); - WCHAR * ptr = testJVMFile; - do { - ptr = searchW(ptr, CLASS_SUFFIX); // check if ptr contains .class - if(ptr==NULL) { // .jar or .zip file - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : ZIP/JAR file", 1); - testJVMClassPath = appendStringW(NULL, testJVMFile); - break; - } - ptr += getLengthW(CLASS_SUFFIX); // shift to the right after the ".class" - - if(ptr==NULL || getLengthW(ptr)==0) { // .class was at the end of the ptr - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... testJVM is : .class file ", 1); - testJVMClassPath = appendStringW(NULL, dir); - break; - } - } while(1); - FREE(dir); - } - - FREE(props->testJVMFile->resolved); - props->testJVMFile->resolved = testJVMClassPath; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... resolved : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, props->testJVMFile->resolved, 1); -} - -void findSuitableJava(LauncherProperties * props) { - if(!isOK(props)) return; - - //resolve testJVM file - resolveTestJVM(props); - - if(!fileExists(props->testJVMFile->resolved)) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Can`t find TestJVM classpath : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 1, props->testJVMFile->resolved, 1); - showErrorW(props, JVM_NOT_FOUND_PROP, 1, javaArg); - props->status = ERROR_JVM_NOT_FOUND; - return; - } else if(!isTerminated(props)) { - - // try to get java location from command line arguments - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "", 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Finding JAVA...", 1); - - //WCHAR * java = NULL; - - if(props->userDefinedJavaHome!=NULL) { // using user-defined JVM via command-line parameter - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "[CMD Argument] Try to use java from ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, props->userDefinedJavaHome, 1); - - trySetCompatibleJava(props->userDefinedJavaHome, props); - if( props->status == ERROR_JVM_NOT_FOUND || props->status == ERROR_JVM_UNCOMPATIBLE) { - const char * prop = (props->status == ERROR_JVM_NOT_FOUND) ? - JVM_USER_DEFINED_ERROR_PROP : - JVM_UNSUPPORTED_VERSION_PROP; - showErrorW(props, prop, 1, props->userDefinedJavaHome); - } - } else { // no user-specified java argument - findSystemJava(props); - if( props->java ==NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... no java was found", 1); - if(props->status == ERROR_BUNDLED_JVM_EXTRACTION) { - showErrorW(props, BUNDLED_JVM_EXTRACT_ERROR_PROP, 1, javaArg); - } else if(props->status == ERROR_BUNDLED_JVM_VERIFICATION) { - showErrorW(props, BUNDLED_JVM_VERIFY_ERROR_PROP, 1, javaArg); - } else { - showErrorW(props, JVM_NOT_FOUND_PROP, 1, javaArg); - props->status = ERROR_JVM_NOT_FOUND; - } - } - } - - if(props->java!=NULL) { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Compatible jvm was found on the system", 1); - printJavaProperties(props, props->java); - } else { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "No compatible jvm was found on the system", 1); - } - } - return; -} - - - -void resolveLauncherStringProperty(LauncherProperties * props, WCHAR ** result) { - if(*result!=NULL) { - WCHAR * propStart = searchW(*result, L"$P{"); - if(propStart!=NULL) { - WCHAR * propEnd = searchW(propStart + 3, L"}"); - if(propEnd!=NULL) { - WCHAR * propName; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... resolving string property", 1); - propName = appendStringNW(NULL, 0, propStart + 3 , - getLengthW(propStart + 3) - getLengthW(propEnd)); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... property name is : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, propName, 1); - - if(propName!=NULL) { - char * name = toChar(propName); - const WCHAR * propValue = getI18nProperty(props, name); - if(propValue!=NULL) { - WCHAR * tmp = appendStringNW(NULL, 0, *result, getLengthW(*result) - getLengthW(propStart)); - tmp = appendStringW(tmp, propValue); - tmp = appendStringW(tmp, propEnd + 1); - FREE(*result); - *result = tmp; - } - FREE(name); - FREE(propName); - } - } - } - } -} - -void resolveLauncherProperties(LauncherProperties * props, WCHAR **result) { - if(*result != NULL) { - WCHAR * propStart = searchW(*result, L"$L{"); - if(propStart!=NULL) { - WCHAR * propEnd = searchW(propStart + 3, L"}"); - if(propEnd!=NULL) { - WCHAR * propName = appendStringNW(NULL, 0, propStart + 3 , getLengthW(propStart + 3) - getLengthW(propEnd)); - if(propName!=NULL) { - WCHAR * propValue = NULL; - - if(lstrcmpW(propName, L"nbi.launcher.tmp.dir")==0) { - propValue = appendStringW(NULL, props->tmpDir); // launcher tmpdir - } else if(lstrcmpW(propName, L"nbi.launcher.java.home")==0) { - if(props->java!=NULL) { - propValue = appendStringW(NULL, props->java->javaHome); // relative to javahome - } - } else if(lstrcmpW(propName, L"nbi.launcher.user.home")==0) { - propValue = getCurrentUserHome(); - } else if(lstrcmpW(propName, L"nbi.launcher.parent.dir")==0) { - propValue = appendStringW(NULL, props->exeDir); // launcher parent - } - - - if(propValue!=NULL) { - WCHAR * tmp = appendStringNW(NULL, 0, *result, getLengthW(*result) - getLengthW(propStart)); - tmp = appendStringW(tmp, propValue); - tmp = appendStringW(tmp, propEnd + 1); - FREE(*result); - FREE(propValue); - *result = tmp; - } - } - } - } - } - -} - -void resolveString(LauncherProperties * props, WCHAR ** result) { - WCHAR * tmp = NULL; - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Resolving string : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *result, 1); - do { - FREE(tmp); - tmp = appendStringW(NULL, *result); - //writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... step 1 : ", 0); - //writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *result, 1); - resolveLauncherProperties(props, result); - //writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... step 2 : ", 0); - //writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *result, 1); - resolveLauncherStringProperty(props, result); - //writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... step 3 : ", 0); - //writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *result, 1); - } while(lstrcmpW(tmp, *result)!=0); - - FREE(tmp); - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, ".... resolved : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, *result, 1); -} - -void resolvePath(LauncherProperties * props, LauncherResource * file) { - WCHAR * result = NULL; - DWORD i=0; - - if(file==NULL) return; - if(file->resolved!=NULL) return; - - file->resolved = appendStringW(NULL, file->path); - resolveString(props, & (file->resolved)); - - for(i=0;iresolved);i++) { - if(file->resolved[i]==L'/') { - file->resolved[i]=L'\\'; - } - } -} - -void setClasspathElements(LauncherProperties * props) { - if(isOK(props)) { - WCHAR * preCP = NULL; - WCHAR * appCP = NULL; - WCHAR *tmp = NULL; - DWORD i = 0 ; - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Modifying classpath ...", 1); - // add some libraries to the beginning of the classpath - while((preCP = getArgumentValue(props, classPathPrepend, 1, 1))!=NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding entry to the beginning of classpath : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, preCP, 1); - if (props->classpath != NULL) { - preCP = appendStringW(preCP, CLASSPATH_SEPARATOR); - } - //WCHAR *last = props->classpath; - resolveString(props, &preCP); - tmp = appendStringW(preCP, props->classpath); - FREE(props->classpath); - props->classpath = tmp; - } - - - for(i=0;ijars->size;i++) { - WCHAR * resolvedCpEntry = NULL; - resolvePath(props, props->jars->items[i]); - resolvedCpEntry = props->jars->items[i]->resolved; - if(!fileExists(resolvedCpEntry)) { - props->status = EXTERNAL_RESOURCE_MISSING; - showErrorW(props, EXTERNAL_RESOURE_LACK_PROP, 1, resolvedCpEntry); - return; - } - if (props->classpath != NULL) { - props->classpath = appendStringW(props->classpath, CLASSPATH_SEPARATOR); - } - props->classpath = appendStringW(props->classpath, resolvedCpEntry); - } - - // add some libraries to the end of the classpath - while((appCP = getArgumentValue(props, classPathAppend, 1, 1))!=NULL) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding entry to the end of classpath : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, appCP, 1); - if (props->classpath != NULL) { - props->classpath = appendStringW(props->classpath, CLASSPATH_SEPARATOR); - } - resolveString(props, &appCP); - props->classpath = appendStringW(props->classpath, appCP); - FREE(appCP); - } - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... finished", 1); - } -} - -void setAdditionalArguments(LauncherProperties * props) { - if(isOK(props)) { - WCHARList * cmd = props->commandLine; - WCHAR ** javaArgs; - WCHAR ** appArgs; - DWORD i=0; - DWORD jArg = 0; // java arguments number - DWORD aArg = 0; // app arguments number - - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, - "Parsing rest of command line arguments to add them to java or application parameters... ", 1); - - // get number for array creation - for(i=0;isize;i++) { - if(cmd->items[i]!=NULL) { - if(searchW(cmd->items[i], javaParameterPrefix)!=NULL) { - jArg++; - } else { - aArg++; - } - } - } - - // handle DefaultUserDirRoot, DefaultCacheDirRoot - increasing array size - jArg = jArg + 2; - - //fill the array - if(jArg>0) { - int size = jArg + props->jvmArguments->size; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, DWORDtoCHAR(size), 1); - javaArgs = newppWCHAR(jArg + props->jvmArguments->size); - for (i=0;ijvmArguments->size;i++) { - javaArgs[i] = props->jvmArguments->items[i]; - } - FREE(props->jvmArguments->items); - - // cont. handle DefaultUserDirRoot, DefaultCacheDirRoot - // * add -Dnetbeans.default_userdir_root - // * add -Dnetbeans.default_cachedir_root - javaArgs[i-2] = appendStringW(toWCHAR("-Dnetbeans.default_userdir_root="), props->defaultUserDirRoot); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Added an JVM argument: ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, javaArgs[i-2], 1); - - javaArgs[i-1] = appendStringW(toWCHAR("-Dnetbeans.default_cachedir_root="), props->defaultCacheDirRoot); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Added an JVM argument: ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, javaArgs[i-1], 1); - } else { - javaArgs = NULL; - } - - if(aArg>0) { - appArgs = newppWCHAR(aArg + props->appArguments->size); - for (i=0; i < props->appArguments->size; i++) { - appArgs [i]= props->appArguments->items[i]; - } - FREE(props->appArguments->items); - } else { - appArgs = NULL; - } - jArg = aArg = 0; - - for(i=0;isize;i++) { - if(cmd->items[i]!=NULL) { - if(searchW(cmd->items[i], javaParameterPrefix)!=NULL) { - javaArgs [ props->jvmArguments->size + jArg] = appendStringW(NULL, cmd->items[i] + getLengthW(javaParameterPrefix)); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding JVM argument : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, javaArgs [ props->jvmArguments->size + jArg], 1); - jArg ++ ; - } else { - appArgs [ props->appArguments->size + aArg] = appendStringW(NULL, cmd->items[i]); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... adding APP argument : ", 0); - writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, appArgs [ props->appArguments->size + aArg], 1); - aArg++; - } - FREE(cmd->items[i]); - } - } - props->appArguments->size = props->appArguments->size + aArg; - props->jvmArguments->size = props->jvmArguments->size + jArg; - if(props->jvmArguments->items==NULL) props->jvmArguments->items = javaArgs; - if(props->appArguments->items==NULL) props->appArguments->items = appArgs; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... resolving jvm arguments", 1); - for(i=0;ijvmArguments->size;i++) { - resolveString(props, &props->jvmArguments->items[i]); - } - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... resolving app arguments", 1); - for(i=0;iappArguments->size;i++) { - resolveString(props, &props->appArguments->items[i]); - } - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... finished parsing parameters", 1); - } -} -void appendCommandLineArgument( WCHAR ** command, const WCHAR * arg) { - WCHAR * escapedString = escapeString(arg); - *command = appendStringW(*command, escapedString); - FREE(escapedString); - *command = appendStringW(*command, L" "); -} - -void setLauncherCommand(LauncherProperties *props) { - if(!isOK(props)) return; - - if(props->java==NULL) { - props->status = ERROR_JVM_NOT_FOUND; - return; - } else { - WCHAR * command = NULL; - WCHAR * javaIOTmpdir = NULL; - DWORD i = 0; - - appendCommandLineArgument(&command, props->java->javaExe); - command = appendStringW(command, L"-Djava.io.tmpdir="); - javaIOTmpdir = getParentDirectory(props->tmpDir); - appendCommandLineArgument(&command, javaIOTmpdir); - FREE(javaIOTmpdir); - - - for(i=0;ijvmArguments->size;i++) { - appendCommandLineArgument(&command, props->jvmArguments->items[i]); - } - - appendCommandLineArgument(&command, L"-classpath"); - appendCommandLineArgument(&command, props->classpath); - appendCommandLineArgument(&command, props->mainClass); - - for(i=0;iappArguments->size; i++) { - appendCommandLineArgument(&command, props->appArguments->items[i]); - } - props->command = command; - } -} - -void executeMainClass(LauncherProperties * props) { - if(isOK(props) && !isTerminated(props)) { - int64t * minSize = newint64_t(0, 0); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Executing main class", 1); - checkFreeSpace(props, props->tmpDir, minSize); - if(isOK(props)) { - HANDLE hErrorRead; - HANDLE hErrorWrite; - char * error = NULL; - - CreatePipe(&hErrorRead, &hErrorWrite, NULL, 0); - hideLauncherWindows(props); - executeCommand(props, props->command, NULL, INFINITE, props->stdoutHandle, hErrorWrite, NORMAL_PRIORITY_CLASS); - if(!isOK(props)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... an error occured during JVM running main class", 1); - props->exitCode = props->status; - } else { - char * s = DWORDtoCHAR(props->exitCode); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... main class has finished its work. Exit code is ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, s, 1); - FREE(s); - } - - error = readHandle(hErrorRead); - if(getLengthA(error)>1) { - DWORD showMessage = 0; - char * ptr = error; - while(ptr!=NULL) { - //Bug #105165 and #194242 - if((searchA(ptr, "Picked up ") == NULL && searchA(ptr, "fatal: Not a git repository") == NULL) && getLengthA(ptr) > 1) { - showMessage = 1; - break; - } - ptr = searchA(ptr, "\n"); - if(ptr!=NULL) ptr++; - } - - if(showMessage && props->exitCode != 0) { - WCHAR * errorW = toWCHAR(error); - showMessageW(props, getI18nProperty(props, JAVA_PROCESS_ERROR_PROP), 1, errorW); - FREE(errorW); - } else { - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, error, 1); - } - } - CloseHandle(hErrorWrite); - CloseHandle(hErrorRead); - FREE(error); - Sleep(1); - } else { - props->status = ERROR_FREESPACE; - props->exitCode = props->status; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... there is not enough space in tmp dir to execute main jar", 1); - } - FREE(minSize); - } -} - -DWORD isOnlyHelp(LauncherProperties * props) { - if(argumentExists(props, helpArg, 1) || argumentExists(props, helpOtherArg, 1)) { - - WCHARList * help = newWCHARList(NUMBER_OF_HELP_ARGUMENTS); - DWORD counter = 0; - WCHAR * helpString = NULL; - - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_JAVA_PROP), 1, javaArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_TMP_PROP), 1, tempdirArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_EXTRACT_PROP), 1, extractArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_OUTPUT_PROPERTY), 1, outputFileArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_DEBUG_PROP), 1, debugArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_CPA_PROP), 1, classPathAppend); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_CPP_PROP), 1, classPathPrepend); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_DISABLE_SPACE_CHECK), 1, nospaceCheckArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_LOCALE_PROP), 1, localeArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_SILENT_PROP), 1, silentArg); - help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_HELP_PROP), 1, helpArg); - - - for(counter=0;counteritems[counter]), NEW_LINE); - } - freeWCHARList(&help); - showMessageW(props, helpString, 0); - FREE(helpString); - return 1; - } - return 0; -} - -DWORD isSilent(LauncherProperties * props) { - return props->silentMode; -} - -WCHARList * getCommandlineArguments() { - int argumentsNumber = 0; - int i=0; - WCHAR ** commandLine = CommandLineToArgvW(GetCommandLineW(), &argumentsNumber); - // the first is always the running program.. we don`t need it - // it is that same as GetModuleFileNameW says - WCHARList * commandsList = newWCHARList((DWORD) (argumentsNumber - 1) ); - for(i=0;iitems[i] = appendStringW(NULL, commandLine[i + 1]); - } - - LocalFree(commandLine); - return commandsList; -} - - -LauncherProperties * createLauncherProperties() { - LauncherProperties *props = (LauncherProperties*)LocalAlloc(LPTR, sizeof(LauncherProperties)); - DWORD c = 0; - props->launcherCommandArguments = newWCHARList(11); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, outputFileArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, javaArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, debugArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, tempdirArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, classPathPrepend); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, classPathAppend); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, extractArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, helpArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, helpOtherArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, silentArg); - props->launcherCommandArguments->items[c++] = appendStringW(NULL, nospaceCheckArg); - - props->jvmArguments = NULL; - props->appArguments = NULL; - props->extractOnly = 0; - props->mainClass = NULL; - props->testJVMClass = NULL; - props->classpath = NULL; - props->jars = NULL; - props->testJVMFile = NULL; - props->tmpDir = NULL; - props->tmpDirCreated = 0; - props->compatibleJava=NULL; - props->compatibleJavaNumber=0; - props->java = NULL; - props->command = NULL; - props->jvms = NULL; - props->other = NULL; - props->alreadyCheckedJava = NULL; - props->exePath = getExePath(); - props->exeName = getExeName(); - props->exeDir = getExeDirectory(); - props->handler = CreateFileW(props->exePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - props->bundledSize = newint64_t(0, 0); - props->bundledNumber = 0; - props->commandLine = getCommandlineArguments(); - props->status = ERROR_OK; - props->exitCode = 0; - props->outputLevel = argumentExists(props, debugArg, 1) ? OUTPUT_LEVEL_DEBUG : OUTPUT_LEVEL_NORMAL; - props->stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); - props->stderrHandle = GetStdHandle(STD_ERROR_HANDLE); - props->bufsize = READ_WRITE_BUFSIZE; - props->restOfBytes = createSizedString(); - props->I18N_PROPERTIES_NUMBER = 0; - props->i18nMessages = NULL; - props->userDefinedJavaHome = getArgumentValue(props, javaArg, 1, 1); - props->userDefinedTempDir = getArgumentValue(props, tempdirArg, 1, 1); - props->userDefinedLocale = getArgumentValue(props, localeArg, 0, 1); - props->userDefinedExtractDir = NULL; - props->extractOnly = 0; - - if(argumentExists(props, extractArg, 0)) { - props->userDefinedExtractDir = getArgumentValue(props, extractArg, 1, 0); - if(props->userDefinedExtractDir==NULL) {// next argument is null or another launcher argument - props->userDefinedExtractDir = getCurrentDirectory(); - } - props->extractOnly = 1; - } - props->userDefinedOutput = getArgumentValue(props, outputFileArg, 1, 1); - props->checkForFreeSpace = !argumentExists(props, nospaceCheckArg, 0); - props->silentMode = argumentExists(props, silentArg, 0); - props->launcherSize = getFileSize(props->exePath); - props->isOnlyStub = (compare(props->launcherSize, STUB_FILL_SIZE) < 0); - return props; -} -void freeLauncherResourceList(LauncherResourceList ** list) { - if(*list!=NULL) { - if((*list)->items!=NULL) { - DWORD i=0; - for(i=0;i<(*list)->size;i++) { - freeLauncherResource(&((*list)->items[i])); - } - FREE((*list)->items); - } - FREE((*list)); - } -} - - -void freeLauncherProperties(LauncherProperties **props) { - if((*props)!=NULL) { - DWORD i=0; - writeMessageA(*props, OUTPUT_LEVEL_DEBUG, 0, "Closing launcher properties", 1); - freeWCHARList(& ( (*props)->appArguments)); - freeWCHARList(& ( (*props)->jvmArguments)); - - FREE((*props)->mainClass); - FREE((*props)->testJVMClass); - FREE((*props)->classpath); - freeLauncherResourceList(&((*props)->jars)); - - freeLauncherResourceList(&((*props)->jvms)); - - freeLauncherResourceList(&((*props)->other)); - - freeLauncherResource(&((*props)->testJVMFile)); - - FREE((*props)->tmpDir); - for(i=0;i<(*props)->compatibleJavaNumber;i++) { - JavaCompatible * jc = (*props)->compatibleJava[i]; - if(jc!=NULL) { - FREE(jc->minVersion); - FREE(jc->maxVersion); - FREE(jc->vendor); - FREE(jc->osName); - FREE(jc->osArch); - FREE((*props)->compatibleJava[i]); - } - } - freeStringList(&((*props)->alreadyCheckedJava)); - FREE((*props)->compatibleJava); - freeJavaProperties(&((*props)->java)); - FREE((*props)->userDefinedJavaHome); - FREE((*props)->userDefinedTempDir); - FREE((*props)->userDefinedExtractDir); - FREE((*props)->userDefinedOutput); - FREE((*props)->userDefinedLocale); - FREE((*props)->command); - FREE((*props)->exePath); - FREE((*props)->exeDir); - FREE((*props)->exeName); - FREE((*props)->bundledSize); - FREE((*props)->launcherSize); - freeSizedString(&((*props)->restOfBytes)); - - flushHandle((*props)->stdoutHandle); - flushHandle((*props)->stderrHandle); - CloseHandle((*props)->stdoutHandle); - CloseHandle((*props)->stderrHandle); - - freeI18NMessages((*props)); - freeWCHARList(& ((*props)->launcherCommandArguments)); - freeWCHARList(& ((*props)->commandLine)); - CloseHandle((*props)->handler); - - FREE((*props)); - } - return; -} -void printStatus(LauncherProperties * props) { - char * s = DWORDtoCHAR(props->status); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... EXIT status : ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, s, 1); - FREE(s); - s = DWORDtoCHAR(props->exitCode); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... EXIT code : ", 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, s, 1); - FREE(s); -} - -void processLauncher(LauncherProperties * props) { - setOutput(props); - if(!isOK(props) || isTerminated(props)) return; - - setProgressRange(props, props->launcherSize); - if(!isOK(props) || isTerminated(props)) return; - - skipStub(props); - if(!isOK(props) || isTerminated(props)) return; - - readDefaultRoots(props); - if(!isOK(props) || isTerminated(props)) return; - - loadLocalizationStrings(props); - if(!isOK(props) || isTerminated(props)) return; - - if(isOnlyHelp(props)) return; - - setProgressTitleString(props, getI18nProperty(props, MSG_PROGRESS_TITLE)); - setMainWindowTitle(props, getI18nProperty(props, MAIN_WINDOW_TITLE)); - showLauncherWindows(props); - if(!isOK(props) || isTerminated(props)) return; - - readLauncherProperties(props); - checkExtractionStatus(props); - if(!isOK(props) || isTerminated(props)) return; - - if(props->bundledNumber > 0) { - createTMPDir(props); - if(isOK(props)) { - checkFreeSpace(props, props->tmpDir, props->bundledSize); - checkExtractionStatus(props); - } - } - - if (isOK(props) ){ - extractJVMData(props); - checkExtractionStatus(props); - if (isOK(props) && !props->extractOnly && !isTerminated(props)) { - findSuitableJava(props); - } - - if (isOK(props) && !isTerminated(props)) { - extractData(props); - checkExtractionStatus(props); - if (isOK(props) && (props->java!=NULL) && !isTerminated(props)) { - setClasspathElements(props); - if(isOK(props) && (props->java!=NULL) && !isTerminated(props)) { - setAdditionalArguments(props); - setLauncherCommand(props); - Sleep(500); - executeMainClass(props); - } - } - } - } - - if(!props->extractOnly && props->tmpDirCreated) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... deleting temporary directory ", 1); - deleteDirectory(props, props->tmpDir); - } - -} diff --git a/nbi/engine/native/launcher/windows/src/Launcher.h b/nbi/engine/native/launcher/windows/src/Launcher.h deleted file mode 100644 index d06279553802..000000000000 --- a/nbi/engine/native/launcher/windows/src/Launcher.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _Launcher_H -#define _Launcher_H - -#include -#include "Errors.h" -#include "JavaUtils.h" -#include "Types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - extern const WCHAR * NEW_LINE; - - LauncherProperties * createLauncherProperties(); - void freeLauncherProperties(LauncherProperties ** props); - - void printStatus(LauncherProperties * props); - void trySetCompatibleJava(WCHAR * location, LauncherProperties * props); - DWORD isSilent(LauncherProperties * props); - DWORD isLauncherArgument(LauncherProperties * props, WCHAR * value); - void processLauncher(LauncherProperties * props); - - void resolvePath(LauncherProperties * props, LauncherResource * file); - void resolveString(LauncherProperties * props, WCHAR ** result); - void resolveLauncherProperties(LauncherProperties * props, WCHAR **result); - void appendCommandLineArgument( WCHAR ** command, const WCHAR * arg); - -#ifdef __cplusplus -} -#endif - -#endif /* _Launcher_H */ diff --git a/nbi/engine/native/launcher/windows/src/Main.c b/nbi/engine/native/launcher/windows/src/Main.c deleted file mode 100644 index 5a819eed0580..000000000000 --- a/nbi/engine/native/launcher/windows/src/Main.c +++ /dev/null @@ -1,672 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include "Launcher.h" -#include "FileUtils.h" -#include "StringUtils.h" -#include "SystemUtils.h" -#include "ExtractUtils.h" -#include "Main.h" - -#define HAVE_WCHAR_H 1 - -char mainClassName[80] = "Main NBI Window Class"; -char mainTitle [80] = "NBI Launcher"; -char showMessageTitle [] = "\n\n"; -HWND hwndPB = NULL; -HWND hwndMain = NULL; -HWND hwndErrorDetail = NULL; -HWND hwndErrorTitle = NULL; -HWND hwndButton = NULL; -HWND hwndProgressTitle = NULL; - -HINSTANCE globalInstance = NULL; -int64t * totalProgressSize = NULL; -int64t * currentProgressSize = NULL; -long steps = 1000; -long lastCheckedStep = 0; -int iCmdShowGlobal = 0; - -HANDLE initializationSuccess = NULL; -HANDLE initializationFailed = NULL; -HANDLE closingWindowsRequired = NULL; -HANDLE closingWindowsConfirmed = NULL; -HANDLE buttonPressed = NULL; - -#define BTN_EXIT 254 - -LRESULT CALLBACK WndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { - switch (umsg) { - case WM_CLOSE: - SetEvent(closingWindowsRequired); - DestroyWindow(hwndPB); - DestroyWindow(hwndProgressTitle); - DestroyWindow(hwndErrorDetail); - DestroyWindow(hwndErrorTitle); - DestroyWindow(hwndButton); - DestroyWindow(hwnd); - return 0; - - case WM_DESTROY: - UnregisterClass(mainClassName, globalInstance); - PostQuitMessage(0); - return 0; - case WM_COMMAND: - if(LOWORD(wParam)==BTN_EXIT) { - SetEvent(buttonPressed); - return 0; - } - } - return DefWindowProc(hwnd, umsg, wParam, lParam); -} - -void initMainWindow(LauncherProperties * props, HINSTANCE hInstance) { - if(!isSilent(props)) { - int systemWidth = GetSystemMetrics(SM_CXSCREEN); - int systemHeight = GetSystemMetrics(SM_CYSCREEN); - - int w = 460; - int h = 200; - int x = (systemWidth - w)/2; - int y = (systemHeight - h)/2; - - InitCommonControls(); - - hwndMain = CreateWindow(mainClassName, mainTitle, - //WS_OVERLAPPED | WS_EX_TOOLWINDOW, - WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_MINIMIZEBOX /* | WS_THICKFRAME | WS_MAXIMIZEBOX*/ - , - x, y, w, h, NULL, NULL, hInstance, NULL); - } -} - -void initErrorTitleWindow(LauncherProperties *props, HINSTANCE hInstance) { - if(!isSilent(props)) { - RECT rcClient; - int cyVScroll; - cyVScroll = GetSystemMetrics(SM_CYVSCROLL); - GetClientRect(hwndMain, &rcClient); - hwndErrorTitle = CreateWindowExW(0, WC_STATICW, WC_STATICW, WS_CHILD, - rcClient.left + 10, 15, rcClient.right - 20, 20, hwndMain, NULL, hInstance, NULL); - if (hwndErrorTitle) { - HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); - LOGFONT lfTitle; - HFONT titleFont; - - GetObject(hFont, sizeof(lfTitle), &lfTitle); - lfTitle.lfWeight = FW_ULTRABOLD;//OLD; - lfTitle.lfHeight = lfTitle.lfHeight + 2 ; - lfTitle.lfWidth = 0; - titleFont = CreateFontIndirect(&lfTitle); - SendMessage(hwndErrorTitle, WM_SETFONT, (WPARAM) titleFont , FALSE); - //DeleteObject(titleFont ); - setErrorTitleString(props, NULL); - } - } -} - -void initErrorDetailWindow(LauncherProperties *props, HINSTANCE hInstance) { - if(!isSilent(props)) { - RECT rcClient; - int cyVScroll; - cyVScroll = GetSystemMetrics(SM_CYVSCROLL); - GetClientRect(hwndMain, &rcClient); - hwndErrorDetail = CreateWindowExW(0, WC_STATICW, WC_STATICW, WS_CHILD , - rcClient.left + 10, 40, rcClient.right - 20, 80, - hwndMain, NULL, hInstance, NULL); - if (hwndErrorDetail) { - LOGFONT lfDetail; - HFONT detailFont; - HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFont, sizeof(lfDetail), &lfDetail); - lfDetail.lfHeight = lfDetail.lfHeight + 2; - lfDetail.lfWidth = 0; - detailFont = CreateFontIndirect(&lfDetail); - SendMessage(hwndErrorDetail, WM_SETFONT, (WPARAM) detailFont, FALSE); - //DeleteObject(detailFont); - setErrorDetailString(props, NULL); - } - } -} - -void initProgressTitleWindow(LauncherProperties *props, HINSTANCE hInstance) { - if(!isSilent(props)) { - RECT rcClient; - int cyVScroll; - int height = 20; - cyVScroll = GetSystemMetrics(SM_CYVSCROLL); - GetClientRect(hwndMain, &rcClient); - hwndProgressTitle = CreateWindowExW(0, WC_STATICW, WC_STATICW, WS_CHILD | WS_VISIBLE , - rcClient.left + 10, (rcClient.bottom - cyVScroll)/2 - height, rcClient.right - 20, height, - hwndMain, NULL, hInstance, NULL); - if (hwndProgressTitle) { - LOGFONT lfTitle; - HFONT progressTitleFont; - HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFont, sizeof(lfTitle), &lfTitle); - lfTitle.lfHeight = lfTitle.lfHeight + 2; - lfTitle.lfWidth = 0; - progressTitleFont = CreateFontIndirect(&lfTitle); - SendMessage(hwndProgressTitle, WM_SETFONT, (WPARAM) progressTitleFont, FALSE); - //DeleteObject(detailFont); - setProgressTitleString(props, NULL); - } - } -} - -void initProgressWindow(LauncherProperties * props, HINSTANCE hInstance) { - if(!isSilent(props)) { - RECT rcClient; - int cyVScroll; - cyVScroll = GetSystemMetrics(SM_CYVSCROLL); - GetClientRect(hwndMain, &rcClient); - hwndPB = CreateWindowExW(0, PROGRESS_CLASSW, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, - rcClient.left + 10, (rcClient.bottom - cyVScroll)/2 , rcClient.right - 20, cyVScroll, - hwndMain, NULL, hInstance, NULL); - totalProgressSize->Low = 100; - totalProgressSize->High = 0; - } -} - -void initExitButton(LauncherProperties * props, HINSTANCE hInstance) { - if(!isSilent(props)) { - RECT rcClient; - //int cyVScroll = GetSystemMetrics(SM_CYVSCROLL); - int buttonWidth = 180; - int buttonHeight = 25; - - GetClientRect(hwndMain, &rcClient); - hwndButton = CreateWindowExW(0, WC_BUTTONW, NULL, - WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP | BS_PUSHBUTTON , - rcClient.right - 20 - buttonWidth, rcClient.bottom - 10 - buttonHeight, buttonWidth, buttonHeight, - hwndMain, (HMENU)BTN_EXIT, hInstance, 0); - if (hwndButton) { - LOGFONT lfButton; - HFONT buttonFont; - HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); - GetObject(hFont, sizeof(lfButton), &lfButton); - lfButton.lfHeight = lfButton.lfHeight + 2; - lfButton.lfWidth = 0; - buttonFont = CreateFontIndirect(&lfButton); - SendMessage(hwndButton, WM_SETFONT, (WPARAM) buttonFont, FALSE); - SetFocus(hwndButton); - //DeleteObject(detailFont); - setButtonString(props, NULL); - UpdateWindow(hwndButton); - } - } -} - -void showErrorW(LauncherProperties * props, const char * error, const DWORD varArgsNumber, ...) { - - WCHAR * errorTitle = NULL; - WCHAR * errorMessage = NULL; - DWORD totalLength = 0; - DWORD counter=0; - WCHAR * result = NULL; - va_list ap; - - getI18nPropertyTitleDetail(props, error, & errorTitle, &errorMessage); - totalLength=getLengthW(errorMessage); - - va_start(ap, varArgsNumber); - - while((counter++) 0) { - if(!IsDialogMessage(hwndMain, & message)) { - TranslateMessage(&message); - DispatchMessage(&message); - } - } - } -} - -BOOL InitApplication(LauncherProperties * props, HINSTANCE hInstance) { - if(isSilent(props)) { - return TRUE; - } - else { - - WNDCLASSEX wndclass; - wndclass.style = CS_HREDRAW | CS_VREDRAW; - wndclass.lpfnWndProc = (WNDPROC)WndProc; - wndclass.cbSize = sizeof(WNDCLASSEX); - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(100)); - wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(100), - IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - wndclass.hInstance = hInstance; - wndclass.hCursor = LoadCursor( 0, IDC_ARROW ); - wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = mainClassName; - return RegisterClassEx(&wndclass); - } -} - - -DWORD isTerminated(LauncherProperties * props) { - if(props->status == ERROR_USER_TERMINATED) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... already terminated", 1); - return 1; - } - if (WAIT_OBJECT_0 == WaitForSingleObject(closingWindowsRequired, 0)) { - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... terminate signal!", 1); - props->status = ERROR_USER_TERMINATED; - return 1; - } - return 0; -} - -void addProgressPosition(LauncherProperties * props, DWORD add) { - if(isSilent(props)) return; - if ( add > 0 ) { - int64t *mult1 = NULL; - int64t *mult2 = NULL; - int64t *currMult = NULL; - int comp1 = 0; - int comp2 = 0; - int goout = 0; - - plus(currentProgressSize, add); - do { - multiply(mult1 = newint64_t(totalProgressSize->Low, totalProgressSize->High), lastCheckedStep); - multiply(mult2 = newint64_t(totalProgressSize->Low, totalProgressSize->High), lastCheckedStep + 1); - multiply(currMult = newint64_t(currentProgressSize->Low, currentProgressSize->High), steps); - comp1 = compareInt64t(currMult, mult1); - - if (comp1 == 0) { - goout = 1; - } else { - comp2 = compareInt64t(currMult, mult2); - if (comp2 == 0) { - lastCheckedStep++; - goout = 1; - } else if (comp1 > 0 && comp2 < 0) { - goout = 1; - } else { - lastCheckedStep++; - } - } - FREE(mult1); - FREE(mult2); - FREE(currMult); - if(lastCheckedStep >= steps) { - lastCheckedStep = steps; - goout = 1; - } - } while (!goout); - SendMessage(hwndPB, PBM_SETPOS, lastCheckedStep, 0); - } -} - -void setProgressRange(LauncherProperties * props, int64t * range) { - if(isSilent(props)) return; - totalProgressSize->Low = range->Low; - totalProgressSize->High = range->High; - currentProgressSize->Low = 0; - currentProgressSize->High = 0; - lastCheckedStep = 0; - SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, steps)); - SendMessage(hwndPB, PBM_SETSTEP, 1, 0); -} - -void hide(LauncherProperties * props, HWND hwnd) { - if(!isSilent(props) && hwndMain != NULL && hwnd!=NULL ) { - ShowWindow(hwnd, SW_HIDE); - UpdateWindow(hwnd); - } -} -void show(LauncherProperties * props, HWND hwnd) { - if(!isSilent(props) && hwndMain != NULL && hwnd!=NULL ) { - ShowWindow(hwnd, iCmdShowGlobal); - UpdateWindow(hwnd); - } -} - -void setProgressTitleString(LauncherProperties * props, const WCHAR * message) { - if(isSilent(props)) return; - SetWindowTextW(hwndProgressTitle, message); - UpdateWindow(hwndProgressTitle); - UpdateWindow(hwndMain); -} - -void setErrorTitleString(LauncherProperties * props, const WCHAR * message) { - if(isSilent(props)) return; - SetWindowTextW(hwndErrorTitle, message); - UpdateWindow(hwndErrorTitle); - UpdateWindow(hwndMain); -} - -void setErrorDetailString(LauncherProperties * props, const WCHAR * message) { - if(isSilent(props)) return; - SetWindowTextW(hwndErrorDetail, message); - UpdateWindow(hwndErrorDetail); - UpdateWindow(hwndMain); -} - -void setButtonString(LauncherProperties * props, const WCHAR * message) { - if(isSilent(props)) return; - SetWindowTextW(hwndButton, message); - UpdateWindow(hwndButton); - UpdateWindow(hwndMain); -} - -void setMainWindowTitle(LauncherProperties * props, const WCHAR * message) { - if(isSilent(props)) return; - SetWindowTextW(hwndMain, message); - UpdateWindow(hwndMain); -} - -void closeLauncherWindows(LauncherProperties * props) { - if(isSilent(props)) return; - SendMessage(hwndMain, WM_CLOSE, 0, 0); -} - - -void hideLauncherWindows(LauncherProperties * props) { - if(isSilent(props)) return; - if(hwndMain != NULL) { - ShowWindow(hwndMain, HIDE_WINDOW); - UpdateWindow(hwndMain); - } -} - - -void showLauncherWindows(LauncherProperties * props) { - if(isSilent(props)) return; - ShowWindow(hwndMain, iCmdShowGlobal); - SetForegroundWindow(hwndMain); - UpdateWindow(hwndMain); -} - -void showMessageW(LauncherProperties * props, const WCHAR* message, const DWORD varArgsNumber, ...) { - DWORD totalLength = getLengthW(message); - va_list ap; - DWORD counter=0; - WCHAR * result = NULL; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, showMessageTitle, 0); - - va_start(ap, varArgsNumber); - - while((counter++)status; - exitCode = props->exitCode; - printStatus(props); - freeLauncherProperties(&props); - } - } - FREE(currentProgressSize); - FREE(totalProgressSize); - return (status==ERROR_OK) ? exitCode : status; -} - -int WINAPI MyMain(void) { - int exitCode; - STARTUPINFO StartupInfo; - StartupInfo.dwFlags = 0; - GetStartupInfo( &StartupInfo ); - exitCode = WinMain(GetModuleHandle(NULL), NULL, NULL, StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT); - ExitProcess(exitCode); - return exitCode; -} diff --git a/nbi/engine/native/launcher/windows/src/Main.h b/nbi/engine/native/launcher/windows/src/Main.h deleted file mode 100644 index 57c81ef8107d..000000000000 --- a/nbi/engine/native/launcher/windows/src/Main.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _Main_H -#define _Main_H - -#include -#include "Errors.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -void addProgressPosition(LauncherProperties *props,DWORD add); -void setProgressRange(LauncherProperties *props, int64t * size); -void setErrorDetailString(LauncherProperties *props,const WCHAR * message); -void setErrorTitleString(LauncherProperties *props,const WCHAR * message); -void setButtonString(LauncherProperties *props,const WCHAR * message); -void setProgressTitleString(LauncherProperties *props,const WCHAR * message); -void setMainWindowTitle(LauncherProperties * props, const WCHAR * message); - -void showLauncherWindows(LauncherProperties *props); -void closeLauncherWindows(LauncherProperties *props); -void hideLauncherWindows(LauncherProperties *props); - -void hide(LauncherProperties *props,HWND hwnd); -void show(LauncherProperties *props,HWND hwnd); - -DWORD isTerminated(LauncherProperties * props); - -void showErrorW(LauncherProperties *props, const char * error, const DWORD varArgsNumber, ...); - -void showMessageW(LauncherProperties *props,const WCHAR* message, const DWORD number, ...); -//void showMessageA(LauncherProperties *props,const char * message, const DWORD varArgsNumber, ...); - -#ifdef __cplusplus -} -#endif - -#endif /* _Main_H */ - diff --git a/nbi/engine/native/launcher/windows/src/ProcessUtils.c b/nbi/engine/native/launcher/windows/src/ProcessUtils.c deleted file mode 100644 index 0fcd9dd44e9f..000000000000 --- a/nbi/engine/native/launcher/windows/src/ProcessUtils.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "ProcessUtils.h" -#include "StringUtils.h" -#include "FileUtils.h" - - -const DWORD DEFAULT_PROCESS_TIMEOUT = 30000; //30 sec - -DWORD readBuf(HANDLE hRead, WCHAR * buf, DWORD * bytesRead, HANDLE hWrite) { - ReadFile(hRead, buf, STREAM_BUF_LENGTH - 1, bytesRead, NULL); - - if((*bytesRead)>0 && hWrite!=INVALID_HANDLE_VALUE) { - DWORD bytesWritten = 0; - WriteFile(hWrite, buf, (*bytesRead), &bytesWritten, 0); - } - ZERO(buf, sizeof(buf)); - return 0; -} - -DWORD readNextData(HANDLE hRead, WCHAR * buf, HANDLE hWrite) { - DWORD bytesRead; - DWORD bytesAvailable; - ZERO(buf, sizeof(buf)); - - PeekNamedPipe(hRead, buf, STREAM_BUF_LENGTH - 1, &bytesRead, &bytesAvailable, NULL); - if (bytesRead != 0) { - ZERO(buf, sizeof(buf)); - if (bytesAvailable >= STREAM_BUF_LENGTH) { - while (bytesRead >= STREAM_BUF_LENGTH-1) { - readBuf(hRead, buf, &bytesRead, hWrite); - } - } - else { - readBuf(hRead, buf, &bytesRead, hWrite); - } - return bytesRead; - } - return 0; -} - -// get already running process stdout -DWORD readProcessStream(PROCESS_INFORMATION pi, HANDLE currentProcessStdin, HANDLE currentProcessStdout, HANDLE currentProcessStderr, DWORD timeOut, HANDLE hWriteInput, HANDLE hWriteOutput, HANDLE hWriteError) { - DWORD started = GetTickCount(); - WCHAR buf[STREAM_BUF_LENGTH]; - DWORD exitCode=0; - DWORD outRead =0; - DWORD errRead =0; - DWORD inRead =0; - while(1) { - outRead = readNextData(currentProcessStdout, buf, hWriteOutput); - errRead = readNextData(currentProcessStderr, buf, hWriteError); - inRead = readNextData(hWriteInput, buf, currentProcessStdin); - GetExitCodeProcess(pi.hProcess, &exitCode); - if (exitCode != STILL_ACTIVE) break; - - if(outRead == 0 && errRead==0 && inRead==0 && timeOut!=INFINITE) { - if((GetTickCount() - started) > timeOut) break; - } - //avoid extra using of CPU resources - Sleep(1); - } - return exitCode; -} -char * readHandle(HANDLE hRead) { - char * output = NULL; - char * buf = newpChar(STREAM_BUF_LENGTH); - DWORD total = 0; - DWORD read; - DWORD bytesRead; - DWORD bytesAvailable; - - while(1) { - PeekNamedPipe(hRead, buf, STREAM_BUF_LENGTH - 1, &bytesRead, &bytesAvailable, NULL); - if(bytesAvailable==0) break; - ReadFile(hRead, buf, STREAM_BUF_LENGTH - 1, &read, NULL); - if(read==0) break; - output = appendStringN(output, total, buf, read); - total+=read; - } - FREE(buf); - return output; -} - - - - -// run process and get its standart output -// command - executing command -// timeLimitMillis - timeout of the process running without any output -// dir - working directory -// return ERROR_ON_EXECUTE_PROCESS for serios error -// return ERROR_PROCESS_TIMEOUT for timeout - -void executeCommand(LauncherProperties * props, WCHAR * command, WCHAR * dir, DWORD timeLimitMillis, HANDLE hWriteOutput, HANDLE hWriteError, DWORD priority) { - STARTUPINFOW si; - SECURITY_ATTRIBUTES sa; - SECURITY_DESCRIPTOR sd; - PROCESS_INFORMATION pi; - - HANDLE newProcessInput; - HANDLE newProcessOutput; - HANDLE newProcessError; - - HANDLE currentProcessStdout; - HANDLE currentProcessStdin; - HANDLE currentProcessStderr; - - WCHAR * directory; - - InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE); - sa.lpSecurityDescriptor = &sd; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.bInheritHandle = TRUE; - - - if (!CreatePipe(&newProcessInput, ¤tProcessStdin, &sa, 0)) { - writeErrorA(props, OUTPUT_LEVEL_NORMAL, 1, "Can`t create pipe for input. ", NULL , GetLastError()); - props->status = ERROR_ON_EXECUTE_PROCESS; - return; - } - - if (!CreatePipe(¤tProcessStdout, &newProcessOutput, &sa, 0)) { - writeErrorA(props, OUTPUT_LEVEL_NORMAL, 1, "Can`t create pipe for output. ", NULL , GetLastError()); - CloseHandle(newProcessInput); - CloseHandle(currentProcessStdin); - props->status = ERROR_ON_EXECUTE_PROCESS; - return; - } - - if (!CreatePipe(¤tProcessStderr, &newProcessError, &sa, 0)) { - writeErrorA(props, OUTPUT_LEVEL_NORMAL, 1, "Can`t create pipe for error. ", NULL , GetLastError()); - CloseHandle(newProcessInput); - CloseHandle(currentProcessStdin); - CloseHandle(newProcessOutput); - CloseHandle(currentProcessStdout); - props->status = ERROR_ON_EXECUTE_PROCESS; - return; - } - - - GetStartupInfoW(&si); - - si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - si.hStdOutput = newProcessOutput; - si.hStdError = newProcessError; - si.hStdInput = newProcessInput; - - directory = (dir!=NULL) ? dir : getCurrentDirectory(); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Create new process: ", 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " command : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, command, 1); - writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, " directory : ", 0); - writeMessageW(props, OUTPUT_LEVEL_NORMAL, 0, directory, 1); - - props->exitCode = ERROR_OK; - if (CreateProcessW(NULL, command, NULL, NULL, TRUE, - CREATE_NEW_CONSOLE | CREATE_NO_WINDOW | CREATE_DEFAULT_ERROR_MODE | priority, - NULL, directory, &si, &pi)) { - // TODO - // Check whether volder virtualization can brake things and provide method to disable it if necessary - // I am not sure whether we need it off or on. - // http://www.netbeans.org/issues/show_bug.cgi?id=122186 - DWORD timeOut = ((timeLimitMillis<=0) ? DEFAULT_PROCESS_TIMEOUT: timeLimitMillis); - props->status = ERROR_OK; - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... process created", 1); - - props->exitCode = readProcessStream(pi, currentProcessStdin, currentProcessStdout, currentProcessStderr, timeOut, newProcessInput, hWriteOutput, hWriteError); - - if(props->exitCode==STILL_ACTIVE) { - //actually we have reached the timeout of the process and need to terminate it - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... process is timeouted", 1); - GetExitCodeProcess(pi.hProcess, & (props->exitCode)); - - if(props->exitCode==STILL_ACTIVE) { - TerminateProcess(pi.hProcess, 0); - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... terminate process", 1); - //Terminating process...It worked too much without any stdout/stdin/stderr - props->status = ERROR_PROCESS_TIMEOUT;//terminated by timeout - } - } else { - //application finished its work... succesfully or not - it doesn`t matter - writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... process finished his work", 1); - } - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - } else { - writeErrorA(props, OUTPUT_LEVEL_DEBUG, 1, "... can`t create process.", NULL, GetLastError()); - props->status = ERROR_ON_EXECUTE_PROCESS; - } - - - CloseHandle(newProcessInput); - CloseHandle(newProcessOutput); - CloseHandle(newProcessError); - CloseHandle(currentProcessStdin); - CloseHandle(currentProcessStdout); - CloseHandle(currentProcessStderr); -} - - - diff --git a/nbi/engine/native/launcher/windows/src/ProcessUtils.h b/nbi/engine/native/launcher/windows/src/ProcessUtils.h deleted file mode 100644 index f553b207ee2d..000000000000 --- a/nbi/engine/native/launcher/windows/src/ProcessUtils.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _ProcessUtils_H -#define _ProcessUtils_H - -#include -#include -#include "Errors.h" -#include "Types.h" -#include "ExtractUtils.h" -#include "FileUtils.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - - #define STREAM_BUF_LENGTH 1024 - - extern const DWORD DEFAULT_PROCESS_TIMEOUT; - - char * readHandle(HANDLE hRead); - - void executeCommand(LauncherProperties * props, WCHAR * command, WCHAR * dir, DWORD timeLimitMillis, HANDLE hWriteOutput, HANDLE hWriteError, DWORD priority); - -#ifdef __cplusplus -} -#endif - -#endif /* _ProcessUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/RegistryUtils.c b/nbi/engine/native/launcher/windows/src/RegistryUtils.c deleted file mode 100644 index e60bd60ea39a..000000000000 --- a/nbi/engine/native/launcher/windows/src/RegistryUtils.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "RegistryUtils.h" -#include "StringUtils.h" -#include "SystemUtils.h" -#include "FileUtils.h" - -WCHAR * getStringValue(HKEY root, WCHAR *key, WCHAR *valueName, BOOL access64key) { - - HKEY hkey = 0 ; - WCHAR *result = NULL; - DWORD type = 0; - DWORD size = 0; - byte* value = NULL; - - if(RegOpenKeyExW(root, key, 0, KEY_READ | ((access64key && IsWow64) ? KEY_WOW64_64KEY : 0), &hkey) == ERROR_SUCCESS) { - - if (RegQueryValueExW(hkey, valueName, NULL, &type, NULL, &size) == ERROR_SUCCESS) { - - value = (byte*) LocalAlloc(LPTR,(size + 1) * sizeof(WCHAR)); - ZERO(value, sizeof(WCHAR) * (size + 1)); - if (RegQueryValueExW(hkey, valueName, NULL, &type, value, &size) == ERROR_SUCCESS) { - if(type == REG_SZ) { - result = (WCHAR *)value; - } - } - if(result==NULL) { - FREE(value); - } - } - } - - if(hkey!=0) { - RegCloseKey(hkey); - } - return result; -} -WCHAR * getStringValuePC(HKEY root, WCHAR *parentkey, WCHAR *childkey, WCHAR *valueName, BOOL access64key) { - WCHAR * key = appendStringW(appendStringW(appendStringW(NULL, parentkey), L"\\"), childkey); - WCHAR *value = getStringValue(root, key, valueName, access64key); - FREE(key); - return value; -} diff --git a/nbi/engine/native/launcher/windows/src/RegistryUtils.h b/nbi/engine/native/launcher/windows/src/RegistryUtils.h deleted file mode 100644 index c9851b053e1c..000000000000 --- a/nbi/engine/native/launcher/windows/src/RegistryUtils.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _RegistryUtils_H -#define _RegistryUtils_H - -#include -#ifdef __cplusplus -extern "C" { -#endif - - -WCHAR * getStringValue(HKEY root, WCHAR *key, WCHAR *valueName, BOOL access64key); -WCHAR * getStringValuePC(HKEY root, WCHAR *parentkey, WCHAR *childkey, WCHAR *valueName, BOOL access64key); - -#ifndef KEY_WOW64_32KEY -#define KEY_WOW64_32KEY 0x0200 -#endif -#ifndef KEY_WOW64_64KEY -#define KEY_WOW64_64KEY 0x0100 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _RegistryUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/StringUtils.c b/nbi/engine/native/launcher/windows/src/StringUtils.c deleted file mode 100644 index cf0423bb9094..000000000000 --- a/nbi/engine/native/launcher/windows/src/StringUtils.c +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include -#include "StringUtils.h" - - - -const char * JVM_NOT_FOUND_PROP = "nlw.jvm.notfoundmessage"; -const char * JVM_USER_DEFINED_ERROR_PROP = "nlw.jvm.usererror"; - -const char * JVM_UNSUPPORTED_VERSION_PROP = "nlw.jvm.unsupportedversion"; -const char * NOT_ENOUGH_FREE_SPACE_PROP = "nlw.freespace"; -const char * CANT_CREATE_TEMP_DIR_PROP = "nlw.tmpdir"; -const char * INTEGRITY_ERROR_PROP = "nlw.integrity"; -const char * OUTPUT_ERROR_PROP = "nlw.output.error"; -const char * JAVA_PROCESS_ERROR_PROP = "nlw.java.process.error"; -const char * EXTERNAL_RESOURE_LACK_PROP = "nlw.missing.external.resource"; -const char * BUNDLED_JVM_EXTRACT_ERROR_PROP = "nlw.bundled.jvm.extract.error"; -const char * BUNDLED_JVM_VERIFY_ERROR_PROP = "nlw.bundled.jvm.verify.error"; - -const char * ARG_OUTPUT_PROPERTY = "nlw.arg.output"; -const char * ARG_JAVA_PROP = "nlw.arg.javahome"; -const char * ARG_DEBUG_PROP = "nlw.arg.verbose"; -const char * ARG_TMP_PROP = "nlw.arg.tempdir"; -const char * ARG_CPA_PROP = "nlw.arg.classpatha"; -const char * ARG_CPP_PROP = "nlw.arg.classpathp"; -const char * ARG_EXTRACT_PROP = "nlw.arg.extract"; -const char * ARG_DISABLE_SPACE_CHECK = "nlw.arg.disable.space.check"; -const char * ARG_LOCALE_PROP = "nlw.arg.locale"; -const char * ARG_SILENT_PROP = "nlw.arg.silent"; -const char * ARG_HELP_PROP = "nlw.arg.help"; - -const char * MSG_CREATE_TMPDIR = "nlw.msg.create.tmpdir"; -const char * MSG_EXTRACT_DATA = "nlw.msg.extract"; -const char * MSG_JVM_SEARCH = "nlw.msg.jvmsearch"; -const char * MSG_SET_OPTIONS = "nlw.msg.setoptions"; -const char * MSG_RUNNING = "nlw.msg.running"; -const char * MSG_TITLE = "nlw.msg.title"; -const char * MSG_MESSAGEBOX_TITLE = "nlw.msg.messagebox.title"; -const char * MSG_PROGRESS_TITLE = "nlw.msg.progress.title"; - -const char * EXIT_BUTTON_PROP = "nlw.msg.button.error" ; -const char * MAIN_WINDOW_TITLE = "nlw.msg.main.title" ; - - - - -//adds string the the initial string and modifies totalWCHARs and capacity -// initial - the beginning of the string -// size - pointer to the value that contains the length of the initial string -// It is modified to store returning string length -// addString - additional string -// - - -void freeI18NMessages(LauncherProperties * props) { - if(props->i18nMessages!=NULL) { - DWORD i=0; - - for(i=0;iI18N_PROPERTIES_NUMBER;i++) { - FREE(props->i18nMessages->properties[i]); - FREE(props->i18nMessages->strings[i]); - } - FREE(props->i18nMessages->properties); - FREE(props->i18nMessages->strings); - FREE(props->i18nMessages); - } -} - -char * searchA(const char * wcs1, const char * wcs2) { - char *cp = (char *) wcs1; - char *s1, *s2; - - if ( !*wcs2) { - return (char *)wcs1; - } - - while (*cp) { - s1 = cp; - s2 = (char *) wcs2; - - while ( *s1 && *s2 && !(*s1-*s2) ) { - s1++, s2++; - } - if (!*s2) { - return(cp); - } - cp++; - } - return(NULL); -} - -WCHAR * searchW(const WCHAR * wcs1, const WCHAR * wcs2) { - WCHAR *cp = (WCHAR *) wcs1; - WCHAR *s1, *s2; - - if ( !*wcs2) { - return (WCHAR *)wcs1; - } - - while (*cp) { - s1 = cp; - s2 = (WCHAR *) wcs2; - - while ( *s1 && *s2 && !(*s1-*s2) ) { - s1++, s2++; - } - if (!*s2) { - return(cp); - } - cp++; - } - return(NULL); -} - -void getI18nPropertyTitleDetail(LauncherProperties * props, const char * name, WCHAR ** title, WCHAR ** detail) { - const WCHAR * prop = getI18nProperty(props,name); - WCHAR * detailStringSep = searchW(prop, L"\n"); - - if(detailStringSep == NULL) { - *title = appendStringW(NULL, prop); - *detail = NULL; - } else { - DWORD dif = getLengthW(prop) - getLengthW(detailStringSep); - *title = appendStringNW(NULL, 0, prop, dif); - *detail = appendStringW(NULL, prop + (dif + 1)); - } -} -const WCHAR * getI18nProperty(LauncherProperties * props, const char * name) { - if(name==NULL) return NULL; - if(name!=NULL && props->i18nMessages!=NULL) { - DWORD i; - for(i=0;iI18N_PROPERTIES_NUMBER;i++) { - char * pr = props->i18nMessages->properties[i]; - if(pr!=NULL) { // hope so it`s true - if(lstrcmpA(name, pr)==0) { - return props->i18nMessages->strings[i]; - } - } - } - } - return getDefaultString(name); -} - -WCHAR * getDefaultString(const char *name) { - if(lstrcmpA(name, JVM_NOT_FOUND_PROP)==0) { - return L"Can`t find suitable JVM. Specify it with %s argument"; - } else if(lstrcmpA(name, NOT_ENOUGH_FREE_SPACE_PROP)==0) { - return L"Not enought free space at %s"; - } else if(lstrcmpA(name, CANT_CREATE_TEMP_DIR_PROP)==0) { - return L"Can`t create temp directory %s"; - } else if(lstrcmpA(name, INTEGRITY_ERROR_PROP)==0) { - return L"Integrity error. File %s is corrupted"; - } else if(lstrcmpA(name, JVM_USER_DEFINED_ERROR_PROP)==0) { - return L"Can`t find JVM at %s"; - } else if(lstrcmpA(name, JVM_UNSUPPORTED_VERSION_PROP)==0) { - return L"Unsupported JVM at %s"; - } else if(lstrcmpA(name, OUTPUT_ERROR_PROP)==0) { - return L"Can`t create file %s.\nError: %s"; - } else if(lstrcmpA(name, JAVA_PROCESS_ERROR_PROP)==0) { - return L"Java error:\n%s"; - } else if(lstrcmpA(name, ARG_JAVA_PROP)==0) { - return L"%s Using specified JVM"; - } else if(lstrcmpA(name, ARG_OUTPUT_PROPERTY)==0) { - return L"%s Output all stdout/stderr to the file"; - } else if(lstrcmpA(name, ARG_DEBUG_PROP)==0) { - return L"%s Use verbose output"; - } else if(lstrcmpA(name, ARG_TMP_PROP)==0) { - return L"%s Use specified temporary dir for extracting data"; - } else if(lstrcmpA(name, ARG_CPA_PROP)==0) { - return L"%s Append classpath"; - } else if(lstrcmpA(name, ARG_CPP_PROP)==0) { - return L"%s Prepend classpath"; - } else if(lstrcmpA(name, ARG_EXTRACT_PROP)==0) { - return L"%s Extract all data"; - } else if(lstrcmpA(name, ARG_HELP_PROP)==0) { - return L"%s Using this help"; - } else if(lstrcmpA(name, ARG_DISABLE_SPACE_CHECK)==0) { - return L"%s Disable free space check"; - } else if(lstrcmpA(name, ARG_LOCALE_PROP )==0) { - return L"%s Use specified locale for messagess"; - } else if(lstrcmpA(name, ARG_SILENT_PROP )==0) { - return L"%s Run silently"; - } else if(lstrcmpA(name, MSG_CREATE_TMPDIR)==0) { - return L"Creating tmp directory..."; - } else if(lstrcmpA(name, MSG_EXTRACT_DATA)==0) { - return L"Extracting data..."; - } else if(lstrcmpA(name, MSG_JVM_SEARCH)==0) { - return L"Finding JVM..."; - } else if(lstrcmpA(name, MSG_RUNNING)==0) { - return L"Running JVM..."; - } else if(lstrcmpA(name, MSG_SET_OPTIONS)==0) { - return L"Setting command options..."; - } else if(lstrcmpA(name, MSG_MESSAGEBOX_TITLE)==0) { - return L"Message"; - } else if(lstrcmpA(name, MSG_PROGRESS_TITLE)==0) { - return L"Running"; - } else if(lstrcmpA(name, EXIT_BUTTON_PROP)==0) { - return L"Exit"; - } else if(lstrcmpA(name, MAIN_WINDOW_TITLE)==0) { - return L"NBI Launcher"; - } else if(lstrcmpA(name, EXTERNAL_RESOURE_LACK_PROP)==0) { - return L"Can`t run launcher\nThe following file is missing : %s"; - } else if(lstrcmpA(name, BUNDLED_JVM_EXTRACT_ERROR_PROP)==0) { - return L"Can`t run prepare bundled JVM"; - } else if(lstrcmpA(name, BUNDLED_JVM_VERIFY_ERROR_PROP)==0) { - return L"Can`t run verify bundled JVM"; - } - return NULL; -} - -DWORD getLengthA(const char * message) { - return (message!=NULL) ? lstrlenA(message) : 0; -} - -DWORD getLengthW(const WCHAR * message) { - return (message!=NULL) ? lstrlenW(message) : 0; -} - -//adds string the the initial string -char * appendStringN(char * initial, DWORD initialLength, const char * addString, DWORD addStringLength) { - DWORD length = initialLength + addStringLength + 1; - if (length > 1) { - char * tmp = newpChar(length+1); - DWORD i=0; - if(initialLength!=0) { - for(i=0;i1) { - - WCHAR * tmp = newpWCHAR(length+1); - DWORD i=0; - - if(initialLength!=0) { - for(i=0;i0); - default: - bsCounter = 0; - break; - } - result[r++] = c; - } - if(quoting) { - while(bsCounter>0) { - result[r++] = '\\'; - bsCounter--; - } - result[r++] = '\"'; - } - result[r] = '\0'; - return result; -} - -char * DWORDtoCHARN(DWORD value, int fillZeros) { - int digits = 0; - DWORD tmpValue = value; - int i = 0; - char * str; - - do { - digits++; - tmpValue = tmpValue / 10; - } while(tmpValue!=0); - tmpValue = value; - if(digits < fillZeros) { - digits = fillZeros; - } - str = (char*) LocalAlloc(LPTR, sizeof(char)*(digits +1)); - str[digits] = '\0'; - for(i=0;iHigh==0) { - return DWORDtoCHAR(value->Low); - } else { - char * high = DWORDtoCHAR(value->High); - char * low = DWORDtoCHAR(value->Low); - DWORD highLength = getLengthA(high); - DWORD lowLength = getLengthA(low); - - char * str = newpChar(highLength + lowLength + 9); - DWORD i = 0; - str[0] = '['; - str[1] = 'H'; - str[2] = ']'; - str[3] = '['; - str[4] = 'L'; - str[5] = ']'; - str[6] = '='; - - for(i = 0; i < highLength; i++) { - str [7 + i] = high[i]; - } - str [7 + highLength] =L','; - for(i = 0; i < lowLength;i++) { - str [8 + highLength + i] = low[i]; - } - str [8 + highLength + lowLength] = '\0'; - FREE(high); - FREE(low); - return str; - } -} -WCHAR * int64ttoWCHAR(int64t*value) { - if(value->High==0) { - return DWORDtoWCHAR(value->Low); - } else { - WCHAR * high = DWORDtoWCHAR(value->High); - WCHAR * low = DWORDtoWCHAR(value->Low); - DWORD highLength = getLengthW(high); - DWORD lowLength = getLengthW(low); - - WCHAR * str = newpWCHAR(highLength + lowLength + 9); - DWORD i = 0; - str[0] = L'['; - str[1] = L'H'; - str[2] = L']'; - str[3] = L'['; - str[4] = L'L'; - str[5] = L']'; - str[6] = L'='; - - for(i = 0; i < highLength;i++) { - str [7 + i] = high[i]; - } - str [7 + highLength] = L','; - for(i = 0; i < lowLength;i++) { - str [8 + highLength + i] = low[i]; - } - str [8 + highLength + lowLength] = L'\0'; - FREE(high); - FREE(low); - return str; - } -} - -void freeStringList(StringListEntry **ss) { - while ( (*ss) !=NULL) { - StringListEntry * tmp = (*ss)->next; - FREE((*ss)->string); - FREE((*ss)); - * ss = tmp; - } -} - -DWORD inList(StringListEntry * top, WCHAR * str) { - StringListEntry * tmp = top; - while(tmp!=NULL) { - if(lstrcmpW(tmp->string, str)==0) { - return 1; - } - tmp = tmp->next; - } - return 0; -} - -StringListEntry * addStringToList(StringListEntry * top, WCHAR * str) { - StringListEntry * ss = (StringListEntry*) LocalAlloc(LPTR,sizeof(StringListEntry)); - ss->string = appendStringW(NULL, str); - ss->next = top; - return ss; -} - - -DWORD getLineSeparatorNumber(char *str) { - DWORD result = 0; - char *ptr = str; - if(ptr!=NULL) { - while((ptr = searchA(ptr, "\n"))!=NULL) { - ptr++; - result++; - if(ptr==NULL) break; - } - } - return result; -} - -char *toCharN(const WCHAR * string, DWORD n) { - DWORD len = 0; - DWORD length = 0; - char * str = NULL; - if(string==NULL) return NULL; - //static DWORD excludeCodepages [] = { 50220, 50221, 50222, 50225, 50227, 50229, 52936, 54936, 57002, 57003, 57004, 57005, 57006, 57007, 57008, 57009, 57010, 57011, 65000, 42}; - //int symbols = 0; - len = getLengthW(string); - if(nbytes; - DWORD len = sz->length; - int unicodeFlags; - DWORD i; - char * string = NULL; - char * ptr = NULL; - WCHAR * wstr = NULL; - if(str==NULL) return NULL; - //static DWORD excludeCodepages [] = { 50220, 50221, 50222, 50225, 50227, 50229, 52936, 54936, 57002, 57003, 57004, 57005, 57006, 57007, 57008, 57009, 57010, 57011, 65000, 42}; - - string = appendStringN(NULL, 0 , str, len); - ptr = string; - unicodeFlags = -1 ; - if(len>=2) { - BOOL hasBOM = (*ptr == '\xFF' && *(ptr+1) == '\xFE'); - BOOL hasReverseBOM = (*ptr == '\xFE' && *(ptr+1) == '\xFF'); - - if (IsTextUnicode(string, len, &unicodeFlags) || hasBOM || hasReverseBOM) { - //text is unicode - len-= 2; - ptr+= 2; - if (unicodeFlags & IS_TEXT_UNICODE_REVERSE_SIGNATURE || hasReverseBOM) { - //we need to change bytes order - char c; - for (i = 0 ; i < len/2 ; i++) { - c = ptr [2 * i] ; - ptr [2 * i] = ptr [2 * i + 1] ; - ptr [2 * i + 1] = c; - } - } - } - - } - wstr = newpWCHAR(len/2+1); - - for(i=0;ibytes = NULL; - s->length = 0; - return s; -} - -void freeSizedString(SizedString ** s) { - if(*s!=NULL) { - FREE((*s)->bytes); - FREE((*s)); - *s = NULL; - } -} - - -WCHAR * getLocaleName() { - LANGID langID = LANGIDFROMLCID(GetUserDefaultLCID()); - LCID localeID = MAKELCID(langID, SORT_DEFAULT); - const DWORD MAX_LENGTH = 512; - WCHAR * lang = newpWCHAR(MAX_LENGTH); - WCHAR * country = newpWCHAR(MAX_LENGTH); - WCHAR * locale = NULL; - GetLocaleInfoW(localeID, LOCALE_SISO639LANGNAME, lang, MAX_LENGTH); - GetLocaleInfoW(localeID, LOCALE_SISO3166CTRYNAME, country, MAX_LENGTH); - locale = appendStringW(appendStringW(appendStringW(NULL, lang), L"_"), country); - FREE(country); - FREE(lang); - return locale; -} - -WCHAR * newpWCHAR(DWORD length) { - WCHAR * res = (WCHAR*) LocalAlloc(LPTR,sizeof(WCHAR) * length); - ZERO(res, length * sizeof(WCHAR)); - return res; -} -WCHAR ** newppWCHAR(DWORD length) { - return (WCHAR**) LocalAlloc(LPTR,sizeof(WCHAR *) * length); -} - - -char * newpChar(DWORD length) { - char * res = (char*) LocalAlloc(LPTR,sizeof(char) * length); - ZERO(res, length * sizeof(char)); - return res; -} - -char ** newppChar(DWORD length) { - return (char**) LocalAlloc(LPTR,sizeof(char*) * length); -} - -int compare(int64t * size, DWORD value) { - if (size->High > 0) return 1; - - if (size->Low > value) - return 1; - else if(size->Low == value) - return 0; - else //if(size->Low < value) - return -1; -} -int compareInt64t(int64t * a1, int64t * a2) { - if (a1->High > a2->High) { - return 1; - } else if(a1->High == a2->High) { - if (a1->Low > a2->Low) { - return 1; - } else if(a1->Low == a2->Low) { - return 0; - } - } - return -1; -} - -void plus(int64t * size, DWORD value) { - if(value!=0) { - if((MAXDWORD - size->Low) >= (value - 1)) { - size->Low = size->Low + value; - } else { - size->High = size->High + 1; - size->Low = value - (MAXDWORD - size->Low) - 1; - } - } -} -void multiply(int64t * size, DWORD value) { - if(value==0) { - size->Low = 0; - size->High = 0; - } else { - DWORD i = 0; - DWORD low = size->Low; - DWORD high = size->High; - size->High = 0; - for(; i < value - 1 ; i++) { - plus(size, low); - } - size->High += high * value; - } -} - -void minus(int64t * size, DWORD value) { - if(value!=0) { - if(size->Low < value) { - size->High = size->High -1; - size->Low = size->Low + (MAXDWORD - value) + 1; - } else { - size->Low = size->Low - value; - }} -} -int64t * newint64_t(DWORD low, DWORD high) { - int64t * res = (int64t *) LocalAlloc(LPTR,sizeof(int64t)); - res->Low = low; - res->High = high; - return res; -} -WCHAR * getErrorDescription(DWORD dw) { - WCHAR * lpMsgBuf; - WCHAR * lpDisplayBuf = NULL; - WCHAR * res = DWORDtoWCHAR(dw); - - FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR) &lpMsgBuf, 0, NULL ); - - lpDisplayBuf = appendStringW(lpDisplayBuf, L"Error code ("); - lpDisplayBuf = appendStringW(lpDisplayBuf, res); - lpDisplayBuf = appendStringW(lpDisplayBuf, L"): "); - lpDisplayBuf = appendStringW(lpDisplayBuf, lpMsgBuf); - - FREE(lpMsgBuf); - FREE(res); - - return lpDisplayBuf; - -} - -WCHAR * formatMessageW(const WCHAR* message, const DWORD varArgsNumber, ...) { - DWORD totalLength=getLengthW(message); - DWORD counter=0; - WCHAR * result = NULL; - - va_list ap; - va_start(ap, varArgsNumber); - - while((counter++)status == ERROR_OK); -} diff --git a/nbi/engine/native/launcher/windows/src/StringUtils.h b/nbi/engine/native/launcher/windows/src/StringUtils.h deleted file mode 100644 index 9cf775ca4703..000000000000 --- a/nbi/engine/native/launcher/windows/src/StringUtils.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _StringUtils_H -#define _StringUtils_H - -#include -#include -#include "Types.h" -#include "Errors.h" -#ifdef __cplusplus -extern "C" { -#endif - -extern const char * JVM_NOT_FOUND_PROP; -extern const char * JVM_USER_DEFINED_ERROR_PROP; -extern const char * JVM_UNSUPPORTED_VERSION_PROP; -extern const char * NOT_ENOUGH_FREE_SPACE_PROP; -extern const char * CANT_CREATE_TEMP_DIR_PROP; -extern const char * INTEGRITY_ERROR_PROP; -extern const char * OUTPUT_ERROR_PROP; -extern const char * JAVA_PROCESS_ERROR_PROP; -extern const char * EXTERNAL_RESOURE_LACK_PROP; -extern const char * BUNDLED_JVM_EXTRACT_ERROR_PROP; -extern const char * BUNDLED_JVM_VERIFY_ERROR_PROP; -extern const char * ARG_OUTPUT_PROPERTY; -extern const char * ARG_JAVA_PROP; -extern const char * ARG_DEBUG_PROP; -extern const char * ARG_TMP_PROP; -extern const char * ARG_CPA_PROP; -extern const char * ARG_CPP_PROP; -extern const char * ARG_EXTRACT_PROP; -extern const char * ARG_DISABLE_SPACE_CHECK; -extern const char * ARG_LOCALE_PROP; -extern const char * ARG_SILENT_PROP; -extern const char * ARG_HELP_PROP; -extern const char * MSG_CREATE_TMPDIR; -extern const char * MSG_EXTRACT_DATA; -extern const char * MSG_JVM_SEARCH; -extern const char * MSG_SET_OPTIONS; -extern const char * MSG_RUNNING; -extern const char * MSG_TITLE; -extern const char * MSG_MESSAGEBOX_TITLE; -extern const char * MSG_PROGRESS_TITLE; -extern const char * EXIT_BUTTON_PROP; -extern const char * MAIN_WINDOW_TITLE; - -#define FREE(x) { \ - if((x)!=NULL) {\ - LocalFree(x); \ - (x)=NULL;\ - }\ -} - - -#ifdef _MSC_VER -#define ZERO(x,y) SecureZeroMemory((x),(y)); -#else -#define ZERO(x,y) ZeroMemory((x),(y)); -#endif - - - - - - void freeI18NMessages(LauncherProperties * props); - - void getI18nPropertyTitleDetail(LauncherProperties * props, const char * name, WCHAR ** title, WCHAR ** detail); - const WCHAR * getI18nProperty(LauncherProperties * props, const char * name); - WCHAR * getDefaultString(const char *name); - - WCHAR * addString(WCHAR * initial, WCHAR *addString, long number, WCHAR * totalWCHARs, WCHAR * capacity); - char * appendStringN(char * initial, DWORD initialLength, const char * addString, DWORD addStringLength); - WCHAR * appendStringNW(WCHAR * initial, DWORD initialLength, const WCHAR * addString, DWORD addStringLength); - char * appendString(char * initial, const char * addString); - WCHAR * appendStringW(WCHAR * initial, const WCHAR * addString); - WCHAR * escapeString(const WCHAR * string); - - void freeStringList(StringListEntry **s); - StringListEntry * addStringToList(StringListEntry * top, WCHAR * str); - DWORD inList(StringListEntry * top, WCHAR * str); - - char *toChar(const WCHAR * string); - char *toCharN(const WCHAR * string, DWORD length); - WCHAR * toWCHAR(char * string); - WCHAR * toWCHARn(char * string, DWORD length); - - WCHAR *createWCHAR(SizedString * sz); - - SizedString * createSizedString(); - char * int64ttoCHAR(int64t*); - WCHAR * int64ttoWCHAR(int64t*); - char * DWORDtoCHAR(DWORD); - char * DWORDtoCHARN(DWORD,int); - - WCHAR * DWORDtoWCHAR(DWORD); - WCHAR * DWORDtoWCHARN(DWORD,int); - - char * long2char(long value); - char * long2charN(long value,int fillZeros); - - char * word2char(WORD value); - char * word2charN(WORD value,int fillZeros); - - void freeSizedString(SizedString ** s); - - WCHAR * getLocaleName(); - - WCHAR * newpWCHAR(DWORD length); - char * newpChar(DWORD length); - WCHAR * searchW( const WCHAR * wcs1, const WCHAR * wcs2); - char * searchA(const char* str1, const char * str2); - - WCHAR ** newppWCHAR(DWORD length); - char ** newppChar(DWORD length); - int64t * newint64_t(DWORD low, DWORD high); - int compare(int64t * size, DWORD value); - int compareInt64t(int64t * a1, int64t * a2); - void plus(int64t * size, DWORD value); - void multiply(int64t * size, DWORD value); - void minus(int64t * size, DWORD value); - DWORD getLineSeparatorNumber(char *str); - DWORD getLengthA(const char * message); - DWORD getLengthW(const WCHAR * message); - - WCHAR * getErrorDescription(DWORD dw); - WCHAR * formatMessageW(const WCHAR* message, const DWORD varArgsNumber, ...); - DWORD isOK(LauncherProperties * props); -#ifdef __cplusplus -} -#endif - -#endif /* _StringUtils_H */ diff --git a/nbi/engine/native/launcher/windows/src/SystemUtils.c b/nbi/engine/native/launcher/windows/src/SystemUtils.c deleted file mode 100644 index c8b423ec7916..000000000000 --- a/nbi/engine/native/launcher/windows/src/SystemUtils.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include - -#include "SystemUtils.h" - -BOOL IsWow64 = FALSE; - -void getOSVersion(DWORD *id, DWORD *major, DWORD *minor, DWORD *productType) { - OSVERSIONINFOEX ver; - ver.dwOSVersionInfoSize = sizeof(ver); - GetVersionEx((OSVERSIONINFO *) &ver); - *id = ver.dwPlatformId; - *major = ver.dwMajorVersion; - *minor = ver.dwMinorVersion; - *productType = ver.wProductType; - return; -} - -DWORD is9x() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_WINDOWS) ? 1 : 0; -} -DWORD isNT() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 4 && minor == 0) ? 1 : 0; -} -DWORD is2k() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 5 && minor == 0) ? 1 : 0; -} - -DWORD isXP() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 5 && minor == 1) ? 1 : 0; -} - -DWORD is2003() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 5 && minor == 2) ? 1 : 0; -} -DWORD isVista() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 6 && minor == 0 && type == VER_NT_WORKSTATION) ? 1 : 0; -} - -DWORD is2008() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 6 && (minor == 0 || minor == 1) && type != VER_NT_WORKSTATION) ? 1 : 0; -} - -DWORD is7() { - DWORD id, major, minor, type; - getOSVersion(& id, & major, & minor, & type); - return (id == VER_PLATFORM_WIN32_NT && major == 6 && minor == 1 && type == VER_NT_WORKSTATION) ? 1 : 0; -} - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -LPFN_ISWOW64PROCESS fnIsWow64Process; - -void initWow64() -{ - IsWow64 = FALSE; - - fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); - - if (NULL != fnIsWow64Process) - { - if (!fnIsWow64Process(GetCurrentProcess(),&IsWow64)) - { - // handle error - } - } -} diff --git a/nbi/engine/native/launcher/windows/src/SystemUtils.h b/nbi/engine/native/launcher/windows/src/SystemUtils.h deleted file mode 100644 index 69437f83fbad..000000000000 --- a/nbi/engine/native/launcher/windows/src/SystemUtils.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _SystemUtils_H -#define _SystemUtils_H - -#ifdef __cplusplus -extern "C" { -#endif - -DWORD is9x(); -DWORD isNT(); -DWORD isXP(); -DWORD is2k(); -DWORD is2003(); -DWORD is2008(); -DWORD is7(); -DWORD isVista(); -void initWow64(); - -extern BOOL IsWow64; - -#ifdef __cplusplus -} -#endif - -#endif /* _SystemUtils_H */ - diff --git a/nbi/engine/native/launcher/windows/src/Types.h b/nbi/engine/native/launcher/windows/src/Types.h deleted file mode 100644 index 9fea21c18e3b..000000000000 --- a/nbi/engine/native/launcher/windows/src/Types.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef _Types_H -#define _Types_H - -#include -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct int64s { - DWORD Low; - DWORD High; - } int64t; - - - typedef struct { - long major; - long minor; - long micro; - long update; - char build [128]; - } JavaVersion; - - typedef struct _javaProps { - WCHAR * javaHome; - WCHAR * javaExe; - char * vendor; - char * osName; - char * osArch; - JavaVersion *version; - } JavaProperties; - - typedef struct _javaCompatible { - JavaVersion * minVersion; - JavaVersion * maxVersion; - char * vendor; - char * osName; - char * osArch; - } JavaCompatible; - - typedef struct _launcherResource { - WCHAR * path; - WCHAR * resolved; - DWORD type; - } LauncherResource; - - typedef struct _launcherResourceList { - LauncherResource ** items; - DWORD size; - } LauncherResourceList; - - typedef struct _WCHARList { - WCHAR ** items; - DWORD size; - } WCHARList; - - typedef struct _string { - char * bytes; - DWORD length; - } SizedString ; - - typedef struct _i18nstrings { - char ** properties; //property name as ASCII - WCHAR ** strings; //value as UNICODE - } I18NStrings; - - - - typedef struct _stringListEntry { - WCHAR * string; - struct _stringListEntry * next; - } StringListEntry; - - typedef struct _launchProps { - - LauncherResourceList * jars; - LauncherResourceList * jvms; - LauncherResourceList * other; - - LauncherResource * testJVMFile; - - WCHAR * testJVMClass; - WCHAR * tmpDir; - DWORD tmpDirCreated; - int64t * bundledSize; - DWORD bundledNumber; - JavaCompatible ** compatibleJava; - DWORD compatibleJavaNumber; - - DWORD checkForFreeSpace; - DWORD silent; - WCHARList * jvmArguments; - WCHARList * appArguments; - - DWORD extractOnly; - WCHAR * classpath; - WCHAR * mainClass; - - JavaProperties * java; - WCHAR * command; - WCHAR * exePath; - WCHAR * exeDir; - WCHAR * exeName; - DWORD status; - DWORD exitCode; - DWORD silentMode; - HANDLE handler; - DWORD outputLevel; - WCHARList * commandLine; - HANDLE stdoutHandle; - HANDLE stderrHandle; - DWORD bufsize; - int64t * launcherSize; - DWORD isOnlyStub; - WCHAR * userDefinedJavaHome; - WCHAR * userDefinedTempDir; - WCHAR * userDefinedExtractDir; - WCHAR * userDefinedOutput; - WCHAR * userDefinedLocale; - SizedString * restOfBytes; - I18NStrings * i18nMessages; - DWORD I18N_PROPERTIES_NUMBER; - StringListEntry * alreadyCheckedJava; - WCHARList * launcherCommandArguments; - WCHAR * defaultUserDirRoot; - WCHAR * defaultCacheDirRoot; - - } LauncherProperties ; - - - -#ifdef __cplusplus -} -#endif - -#endif /* _Types_H */ - diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.ncb b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.ncb deleted file mode 100644 index 9057ebacbf8c..000000000000 --- a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.ncb +++ /dev/null @@ -1 +0,0 @@ -Microsoft C/C++ MSF 7.00 diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.sln b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.sln deleted file mode 100644 index cad338e99ae5..000000000000 --- a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NBI Native Launcher", "NBI Native Launcher.vcproj", "{BC558D87-D517-4F10-BFCA-0371AC724252}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC558D87-D517-4F10-BFCA-0371AC724252}.Release|Win32.ActiveCfg = Release|Win32 - {BC558D87-D517-4F10-BFCA-0371AC724252}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.suo b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.suo deleted file mode 100644 index 6a0abfa93215..000000000000 Binary files a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.suo and /dev/null differ diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj deleted file mode 100644 index 44a49a47e435..000000000000 --- a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj +++ /dev/null @@ -1,304 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.SARD.dlm198383.user b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.SARD.dlm198383.user deleted file mode 100644 index ab27aa58ceef..000000000000 --- a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.SARD.dlm198383.user +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - diff --git a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.user b/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.user deleted file mode 100644 index a5ca4f998dec..000000000000 --- a/nbi/engine/native/launcher/windows/vcproject/NBI Native Launcher.vcproj.user +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/nbi/engine/nbproject/build-impl.xml b/nbi/engine/nbproject/build-impl.xml deleted file mode 100644 index 359e59289223..000000000000 --- a/nbi/engine/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.tests.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/nbproject/genfiles.properties b/nbi/engine/nbproject/genfiles.properties deleted file mode 100644 index d2ea465d46e3..000000000000 --- a/nbi/engine/nbproject/genfiles.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -build.xml.data.CRC32=779659b8 -build.xml.jax-ws.CRC32=749ccaa7 -build.xml.script.CRC32=8045bb5e -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=d65b1cba -nbproject/build-impl.xml.jax-ws.CRC32=749ccaa7 -nbproject/build-impl.xml.script.CRC32=094d2ba0 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 -nbproject/profiler-build-impl.xml.data.CRC32=779659b8 -nbproject/profiler-build-impl.xml.script.CRC32=abda56ed -nbproject/profiler-build-impl.xml.stylesheet.CRC32=a5b6598e diff --git a/nbi/engine/nbproject/profiler-build-impl.xml b/nbi/engine/nbproject/profiler-build-impl.xml deleted file mode 100644 index 7c8995daf1d3..000000000000 --- a/nbi/engine/nbproject/profiler-build-impl.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/nbproject/project.properties b/nbi/engine/nbproject/project.properties deleted file mode 100644 index 4c6b0e3a2757..000000000000 --- a/nbi/engine/nbproject/project.properties +++ /dev/null @@ -1,117 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -application.args= -application.title=NetBeans Installer Engine -application.vendor=Kirill Sorokin -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/nbi-engine.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jetty-6.0.2.jar=lib/jetty-6.0.2.jar -file.reference.jetty-util-6.0.2.jar=lib/jetty-util-6.0.2.jar -file.reference.junit-4.13.2.jar=../../libs.junit4/external/junit-4.13.2.jar -file.reference.servlet-api-2.5-6.0.2.jar=lib/servlet-api-2.5-6.0.2.jar -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=true -jar.index=${jnlp.enabled} -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs=-Xlint:unchecked -javac.deprecation=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${file.reference.jetty-6.0.2.jar}:\ - ${file.reference.jetty-util-6.0.2.jar}:\ - ${file.reference.servlet-api-2.5-6.0.2.jar}:\ - ${file.reference.junit-4.13.2.jar} -javac.test.modulepath=\ - ${javac.modulepath} -javadoc.additionalparam=-header "NBI Engine API" -javadoc.author=true -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=true -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -# Property libs.swing-layout.classpath is set here just to make sharing of project simpler. -# The library definition has always preference over this property. -libs.swing-layout.classpath=../../../../../applications/NetBeans 6.0 Dev/platform/modules/ext/swing-layout-1.0.1.jar -main.class=org.netbeans.installer.Installer -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=true -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -src.dir=src -test.tests.dir=tests diff --git a/nbi/engine/nbproject/project.xml b/nbi/engine/nbproject/project.xml deleted file mode 100644 index d3054d7354f5..000000000000 --- a/nbi/engine/nbproject/project.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - org.netbeans.modules.java.j2seproject - - - NBI Engine - 1.6.5 - - - - - - - - - diff --git a/nbi/engine/probesrc/TestJDK.java b/nbi/engine/probesrc/TestJDK.java deleted file mode 100644 index b108314e1ea7..000000000000 --- a/nbi/engine/probesrc/TestJDK.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public class TestJDK { - public static void main(String[] args) { - String[] props = new String[] {"java.version", "java.vm.version", "java.vendor", "os.name", "os.arch"}; - for (int i = 0; i < props.length; i++) { - System.out.println(System.getProperty(props[i])); - } - } -} diff --git a/nbi/engine/src/com/apple/eawt/Application.java b/nbi/engine/src/com/apple/eawt/Application.java deleted file mode 100644 index efa7068e18bf..000000000000 --- a/nbi/engine/src/com/apple/eawt/Application.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. - */ - -package com.apple.eawt; - -import java.awt.Point; - -public class Application { - public void addAboutMenuItem() { - // does nothing - } - - public void addApplicationListener(final ApplicationListener listener) { - // does nothing - } - - public void addPreferencesMenuItem() { - // does nothing - } - - public static Application getApplication() { - return null; - } - - public boolean getEnabledAboutMenu() { - return false; - } - - public boolean getEnabledPreferencesMenu() { - return false; - } - - public static Point getMouseLocationOnScreen() { - return null; - } - - public boolean isAboutMenuItemPresent() { - return false; - } - - public boolean isPreferencesMenuItemPresent() { - return false; - } - - public void removeAboutMenuItem() { - // does nothing - } - - public void removeApplicationListener(final ApplicationListener listener) { - // does nothing - } - - public void removePreferencesMenuItem() { - // does nothing - } - - public void setEnabledAboutMenu(final boolean enable) { - // does nothing - } - - public void setEnabledPreferencesMenu(final boolean enable) { - // does nothing - } -} diff --git a/nbi/engine/src/com/apple/eawt/ApplicationAdapter.java b/nbi/engine/src/com/apple/eawt/ApplicationAdapter.java deleted file mode 100644 index 771f7c3499e5..000000000000 --- a/nbi/engine/src/com/apple/eawt/ApplicationAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. The compiled stub classes should never be - * included in the final product. - */ - -package com.apple.eawt; - -public class ApplicationAdapter implements ApplicationListener { - public void handleAbout(final ApplicationEvent event) { - // does nothing - } - - public void handleOpenApplication(final ApplicationEvent event) { - // does nothing - } - - public void handleOpenFile(final ApplicationEvent event) { - // does nothing - } - - public void handlePreferences(final ApplicationEvent event) { - // does nothing - } - - public void handlePrintFile(final ApplicationEvent event) { - // does nothing - } - - public void handleQuit(final ApplicationEvent event) { - // does nothing - } - - public void handleReOpenApplication(final ApplicationEvent event) { - // does nothing - } -} - - diff --git a/nbi/engine/src/com/apple/eawt/ApplicationBeanInfo.java b/nbi/engine/src/com/apple/eawt/ApplicationBeanInfo.java deleted file mode 100644 index 3e98d9482d0a..000000000000 --- a/nbi/engine/src/com/apple/eawt/ApplicationBeanInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. The compiled stub classes should never be - * included in the final product. - */ - -package com.apple.eawt; - -import java.awt.Image; -import java.beans.SimpleBeanInfo; - -public class ApplicationBeanInfo extends SimpleBeanInfo { - @Override - public Image getIcon(final int iconKind) { - return null; - } -} - - diff --git a/nbi/engine/src/com/apple/eawt/ApplicationEvent.java b/nbi/engine/src/com/apple/eawt/ApplicationEvent.java deleted file mode 100644 index dd4e030b8331..000000000000 --- a/nbi/engine/src/com/apple/eawt/ApplicationEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. The compiled stub classes should never be - * included in the final product. - */ - -package com.apple.eawt; - -import java.io.Serializable; -import java.util.EventObject; - -public class ApplicationEvent extends EventObject implements Serializable { - public ApplicationEvent(final Object source) { - super(source); - } - - public String getFilename() { - return null; - } - - public boolean isHandled() { - return false; - } - - public void setHandled(final boolean state) { - // does nothing - } -} - diff --git a/nbi/engine/src/com/apple/eawt/ApplicationListener.java b/nbi/engine/src/com/apple/eawt/ApplicationListener.java deleted file mode 100644 index fe295ab1a748..000000000000 --- a/nbi/engine/src/com/apple/eawt/ApplicationListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. The compiled stub classes should never be - * included in the final product. - */ - -package com.apple.eawt; - -import java.util.EventListener; - -public interface ApplicationListener extends EventListener { - void handleAbout(final ApplicationEvent event); - - void handleOpenApplication(final ApplicationEvent event); - - void handleOpenFile(final ApplicationEvent event); - - void handlePreferences(final ApplicationEvent event); - - void handlePrintFile(final ApplicationEvent event); - - void handleQuit(final ApplicationEvent event); - - void handleReOpenApplication(final ApplicationEvent event); -} diff --git a/nbi/engine/src/com/apple/eawt/CocoaComponent.java b/nbi/engine/src/com/apple/eawt/CocoaComponent.java deleted file mode 100644 index 5f9a2abc8b7c..000000000000 --- a/nbi/engine/src/com/apple/eawt/CocoaComponent.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* this is stub code written based on Apple EAWT package javadoc published at - * http://developer.apple.com. It makes compiling code which uses Apple EAWT - * on non-Mac platforms possible. The compiled stub classes should never be - * included in the final product. - */ - -package com.apple.eawt; - -import java.awt.Canvas; -import java.awt.Dimension; - -public abstract class CocoaComponent extends Canvas { - public abstract int createNSView(); - - public long createNSViewLong() { - return 0; - } - - @Override - public abstract Dimension getMaximumSize(); - - @Override - public abstract Dimension getMinimumSize(); - - @Override - public abstract Dimension getPreferredSize(); - - public void sendMessage(final int messageID, final Object message) { - // does nothing - } -} diff --git a/nbi/engine/src/data/engine.properties b/nbi/engine/src/data/engine.properties deleted file mode 100644 index 3807b675d79a..000000000000 --- a/nbi/engine/src/data/engine.properties +++ /dev/null @@ -1,20 +0,0 @@ - -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - diff --git a/nbi/engine/src/data/registry.xml b/nbi/engine/src/data/registry.xml deleted file mode 100644 index c4ac65d37fda..000000000000 --- a/nbi/engine/src/data/registry.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/Bundle.properties b/nbi/engine/src/org/netbeans/installer/Bundle.properties deleted file mode 100644 index 5340a15523d5..000000000000 --- a/nbi/engine/src/org/netbeans/installer/Bundle.properties +++ /dev/null @@ -1,39 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# Installer.java -I.error.unsupported.platform=The current platform is not supported. -I.error.load.engine.properties=Could not load the engine properties file - -I.warning.silent.without.state="{1}" option is required when using "{0}". "{0}" will be ignored. - -I.error.cannot.create.local.dir=Cannot create local directory: {0} -I.error.local.dir.is.file=Local directory exists and is a file: {0} -I.error.no.read.permissions.for.local.dir=Cannot read local directory {0} - not enough permissions -I.error.no.write.permissions.for.local.dir=Cannot write to local directory {0} - not enough permissions - -I.lock.file.exists.dialog.title=NetBeans Installer lock file exists -I.lock.file.exists.dialog.text=\ - The installer lock file exists at {0}\n\n\ - It means that either another instance of the installer is already running or the previous installation was not finished correctly.\n\ - It is not recommended that you run multiple instances at the same time since it can result in installer data corruption.\n\n\ - If you are sure that no other instance is running at the moment, click "Yes" to proceed otherwise click "No" to exit the installer.\n - -I.error.cannot.create.lock.file=Can't create lock for the local registry file diff --git a/nbi/engine/src/org/netbeans/installer/Installer.java b/nbi/engine/src/org/netbeans/installer/Installer.java deleted file mode 100644 index 8a984936b281..000000000000 --- a/nbi/engine/src/org/netbeans/installer/Installer.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer; - -import java.io.File; -import java.io.IOException; -import java.util.Enumeration; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.TreeSet; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.DateUtils; -import org.netbeans.installer.utils.EngineUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.cli.options.*; -import org.netbeans.installer.utils.cli.CLIHandler; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.helper.FinishHandler; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.Wizard; - -/** - * The main class of the NBI engine. It represents the installer and provides - * methods to start the installation/maintenance process as well as to - * finish/cancel/break the installation. - * - * @author Kirill Sorokin - */ -public class Installer implements FinishHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Main - /** - * The main method. It creates an instance of {@link Installer} and calls - * the {@link #start()} method, passing in the command line arguments. - * - * @param arguments The command line arguments - */ - public static void main(String[] arguments) { - new Installer(arguments).start(); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static Installer instance; - - /** - * Returns an instance of Installer. If the instance does not - * exist - it is created. - * - * @return An instance of Installer - */ - public static synchronized Installer getInstance() { - if (instance == null) { - instance = new Installer(new String[0]); - } - - return instance; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private File localDirectory = null; - - // Constructor ////////////////////////////////////////////////////////////////// - /** - * The only private constructor - we need to hide the default one as - * Installer is a singleton. - * - * @param arguments Command-line parameters. - */ - private Installer(String[] arguments) { - LogManager.logEntry("initializing the installer engine"); // NOI18N - - initializeErrorHandler(); - dumpSystemInfo(); - EngineUtils.checkEngine(); - initializePlatform(); - - instance = this; - parseArguments(arguments); - loadEngineProperties(); - initializeLocalDirectory(); - - // once we have set the local directory (and therefore devised the log - // file path) we can start logging safely - initializeLogManager(); - initializeRegistry(); - initializeWizard(); - createLockFile(); - - LogManager.logExit("... finished initializing the engine"); // NOI18N - } - - // Life cycle control methods /////////////////////////////////////////////////// - /** - * Starts the installer. - */ - public void start() { - LogManager.logEntry("starting the installer"); // NOI18N - - Wizard.getInstance().open(); - - LogManager.logExit("... finished starting the installer"); // NOI18N - } - - /** - * Cancels the installation. This method cancels the changes that were possibly - * made to the components registry and exits with the cancel error code. - * - * This method is not logged. - * - * @see #finish() - * @see #criticalExit() - */ - public void cancel() { - exitNormally(CANCEL_ERRORCODE); - } - - /** - * Finishes the installation. This method finalizes the changes made to the - * components registry and exits with a normal error code. - * - * This method is not logged. - * - * @see #cancel() - * @see #criticalExit() - */ - public void finish() { - int exitCode = NORMAL_ERRORCODE; - final Object prop = System.getProperties().get(EXIT_CODE_PROPERTY); - if (prop instanceof Integer) { - try { - exitCode = ((Integer)prop).intValue(); - } catch (NumberFormatException e) { - LogManager.log("... cannot parse exit code : " + prop, e); - } - } - exitNormally(exitCode); - } - - /** - * Critically exists. No changes will be made to the components registry - it - * will remain at the same state it was at the moment this method was called. - * - * This method is not logged. - * - * @see #cancel() - * @see #finish() - */ - public void criticalExit() { - LogManager.stop(); - // exit immediately, as the system is apparently in a crashed state - exitImmediately(CRITICAL_ERRORCODE); - } - - public File getLocalDirectory() { - if(localDirectory==null) { - initializeLocalDirectory(); - } - return localDirectory; - } - - private void initializeErrorHandler() { - // initialize the error manager - LogManager.logEntry("... initializing ErrorHandler"); - ErrorManager.setFinishHandler(this); - ErrorManager.setExceptionHandler(new ErrorManager.ExceptionHandler()); - - // attach a handler for uncaught exceptions in the main thread - Thread.currentThread().setUncaughtExceptionHandler( - ErrorManager.getExceptionHandler()); - LogManager.logExit("... end of ErrorHandler initialization"); // NOI18N - } - - private void initializePlatform() { - // check whether we can safely execute on the current platform, exit in panic otherwise - if (SystemUtils.getCurrentPlatform() == null) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_UNSUPPORTED_PLATFORM_KEY)); - } - } - - private void initializeLogManager() { - final String logFileProp = System.getProperty(LogManager.LOG_FILE_PROPERTY); - final File logFile = logFileProp == null ? - new File(getLocalDirectory(), LOG_FILE_NAME) : - new File(logFileProp).getAbsoluteFile(); - LogManager.setLogFile(logFile); - LogManager.start(); - } - - private void initializeRegistry() { - LogManager.logEntry("... initializing Registry"); - final Registry registry = Registry.getInstance(); - registry.setLocalDirectory(getLocalDirectory()); - registry.setFinishHandler(this); - LogManager.logExit("... end of initializing ErrorHandler"); - } - - private void initializeWizard() { - LogManager.logEntry("... initializing Wizard"); - final Wizard wizard = Wizard.getInstance(); - wizard.setFinishHandler(this); - wizard.getContext().put(Registry.getInstance()); - LogManager.logExit("... end of initializing Wizard"); - } - - // private ////////////////////////////////////////////////////////////////////// - private void exitNormally(int errorCode) { - Wizard.getInstance().close(); - LogManager.stop(); - - exitImmediately(errorCode); - } - - private void exitImmediately(int errorCode) { - if (Boolean.getBoolean(DONT_USE_SYSTEM_EXIT_PROPERTY) && - (errorCode != CRITICAL_ERRORCODE)) { - System.getProperties().put( - EXIT_CODE_PROPERTY, - Integer.valueOf(errorCode)); - } else { - System.exit(errorCode); - } - } - - private void dumpSystemInfo() { - // output all the possible target system information -- this may help to - // devise the configuration differences in case of errors - LogManager.logEntry("dumping target system information"); // NOI18N - - LogManager.logIndent("system properties:"); // NOI18N - - for (Object key: new TreeSet(System.getProperties().keySet())) { - LogManager.log(key.toString() + " => " + // NOI18N - System.getProperties().get(key).toString()); - } - - LogManager.unindent(); - - LogManager.logExit("... end of target system information"); // NOI18N - } - - private void loadEngineProperties() { - LogManager.logEntry("loading engine properties"); // NOI18N - - try { - LogManager.logIndent("loading engine properties"); - - ResourceBundle bundle = ResourceBundle.getBundle( - EngineResources.ENGINE_PROPERTIES_BUNDLE); - Enumeration keys = bundle.getKeys(); - - while (keys.hasMoreElements()) { - final String key = keys.nextElement(); - final String value = bundle.getString(key); - LogManager.log("loading " + key + " => " + value); // NOI18N - final String currentValue = System.getProperty(key); - if(currentValue!=null) { - LogManager.log("... already defined, using existing value: " + currentValue); // NOI18N - } else { - System.setProperty(key,value); - } - - } - } catch (MissingResourceException e) { - LogManager.log("... no engine properties file, skip loading engine properties"); - } - - LogManager.unindent(); - - LogManager.logExit("... finished loading engine properties"); // NOI18N - } - - /** - * Parses the command line arguments passed to the installer. All unknown - * arguments are ignored. - * - * @param arguments The command line arguments - */ - private void parseArguments(String[] arguments) { - LogManager.logEntry("parsing command-line arguments"); // NOI18N - - new CLIHandler(arguments).proceed(); - - // validate arguments /////////////////////////////////////////////////////// - /* - Disabled since 28.02.2008 by Dmitry Lipin: - I don`t see any reason for having that restiction at this moment: - I can succesfully install/create bundle just with empty state file similar to - Registry.DEFAULT_STATE_FILE_STUB_URI or even just have as the file contents - */ - /* - if (UiMode.getCurrentUiMode() != UiMode.DEFAULT_MODE) { - if (System.getProperty( - Registry.SOURCE_STATE_FILE_PATH_PROPERTY) == null) { - UiMode.setCurrentUiMode(UiMode.DEFAULT_MODE); - ErrorManager.notifyWarning(ResourceUtils.getString( - Installer.class, - WARNING_SILENT_WITHOUT_STATE_KEY, - SilentOption.SILENT_ARG, - StateOption.STATE_ARG)); - } - } - */ - LogManager.logExit( - "... finished parsing command line arguments"); // NOI18N - } - - private void initializeLocalDirectory() { - if(localDirectory!=null) { - return; - } - LogManager.logIndent("initializing the local directory"); // NOI18N - - if (System.getProperty(LOCAL_DIRECTORY_PATH_PROPERTY) != null) { - String path = System.getProperty(LOCAL_DIRECTORY_PATH_PROPERTY); - LogManager.log("... local directory path (initial) : " + path); - path = SystemUtils.resolveString(path); - LogManager.log("... local directory path (resolved): " + path); - localDirectory = new File(path).getAbsoluteFile(); - } else { - LogManager.log("... custom local directory was " + // NOI18N - "not specified, using the default"); // NOI18N - - localDirectory = - new File(DEFAULT_LOCAL_DIRECTORY_PATH).getAbsoluteFile(); - System.setProperty( - LOCAL_DIRECTORY_PATH_PROPERTY, - localDirectory.getAbsolutePath()); - - } - - - LogManager.log("... local directory: " + localDirectory); // NOI18N - - if (!localDirectory.exists()) { - if (!localDirectory.mkdirs()) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_CANNOT_CREATE_LOCAL_DIR_KEY, - localDirectory)); - } - } else if (localDirectory.isFile()) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_LOCAL_DIR_IS_FILE_KEY, - localDirectory)); - } else if (!localDirectory.canRead()) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_NO_READ_PERMISSIONS_FOR_LOCAL_DIR_KEY, - localDirectory)); - } else if (!localDirectory.canWrite()) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_NO_WRITE_PERMISSIONS_FOR_LOCAL_DIR_KEY, - localDirectory)); - } - - LogManager.logUnindent( - "... finished initializing local directory"); // NOI18N - } - - private void createLockFile() { - LogManager.logIndent("creating lock file"); // NOI18N - - if (System.getProperty(IGNORE_LOCK_FILE_PROPERTY) == null) { - final File lock = new File(getLocalDirectory(), LOCK_FILE_NAME); - - if (lock.exists()) { - LogManager.log("... lock file already exists at " + lock); // NOI18N - LogManager.log("... to skip lock file check run installer with " + IgnoreLockOption.IGNORE_LOCK_ARG + " argument"); // NOI18N - - final String dialogTitle = ResourceUtils.getString( - Installer.class, - LOCK_FILE_EXISTS_DIALOG_TITLE_KEY); - final String dialogText = ResourceUtils.getString( - Installer.class, - LOCK_FILE_EXISTS_DIALOG_TEXT_KEY, - lock.getAbsolutePath()); - if(!UiUtils.showYesNoDialog(dialogTitle, dialogText)) { - cancel(); - } - } else { - try { - lock.createNewFile(); - } catch (IOException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Installer.class, - ERROR_CANNOT_CREATE_LOCK_FILE_KEY), e); - } - - LogManager.log("... created lock file: " + lock); // NOI18N - } - - lock.deleteOnExit(); - } else { - LogManager.log("... running with " + // NOI18N - IgnoreLockOption.IGNORE_LOCK_ARG + ", skipping this step"); // NOI18N - } - - LogManager.logUnindent("finished creating lock file"); // NOI18N - } - - @Deprecated - public File cacheInstallerEngine(Progress progress) throws IOException { - return EngineUtils.cacheEngine(progress); - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - - // errorcodes /////////////////////////////////////////////////////////////////// - /** Errorcode to be used at normal exit */ - public static final int NORMAL_ERRORCODE = - 0; - - /** Errorcode to be used when the installer is canceled */ - public static final int CANCEL_ERRORCODE = - 1; - - /** Errorcode to be used when the installer exits because of a critical error */ - public static final int CRITICAL_ERRORCODE = - 255; - - // lock file //////////////////////////////////////////////////////////////////// - public static final String LOCK_FILE_NAME = - ".nbilock"; // NOI18N - - public static final String IGNORE_LOCK_FILE_PROPERTY = - "nbi.ignore.lock.file"; // NOI18N - - // local working directory ////////////////////////////////////////////////////// - public static final String DEFAULT_LOCAL_DIRECTORY_PATH = - System.getProperty("user.home") + File.separator + ".nbi"; - - public static final String LOCAL_DIRECTORY_PATH_PROPERTY = - "nbi.local.directory.path"; // NOI18N - - // miscellaneous //////////////////////////////////////////////////////////////// - public static final String DONT_USE_SYSTEM_EXIT_PROPERTY = - "nbi.dont.use.system.exit"; // NOI18N - - public static final String EXIT_CODE_PROPERTY = - "nbi.exit.code"; // NOI18N - - public static final String BUNDLE_PROPERTIES_FILE_PROPERTY = - "nbi.bundle.properties.file";//NOI18N - - public static final String LOG_FILE_NAME = - "log/" + DateUtils.getTimestamp() + ".log"; - - // resource bundle keys ///////////////////////////////////////////////////////// - private static final String ERROR_UNSUPPORTED_PLATFORM_KEY = - "I.error.unsupported.platform"; // NOI18N - - private static final String WARNING_SILENT_WITHOUT_STATE_KEY = - "I.warning.silent.without.state"; // NOI18N - - private static final String ERROR_CANNOT_CREATE_LOCAL_DIR_KEY = - "I.error.cannot.create.local.dir"; // NOI18N - - private static final String ERROR_LOCAL_DIR_IS_FILE_KEY = - "I.error.local.dir.is.file"; // NOI18N - - private static final String ERROR_NO_READ_PERMISSIONS_FOR_LOCAL_DIR_KEY = - "I.error.no.read.permissions.for.local.dir"; // NOI18N - - private static final String ERROR_NO_WRITE_PERMISSIONS_FOR_LOCAL_DIR_KEY = - "I.error.no.write.permissions.for.local.dir"; // NOI18N - - private static final String LOCK_FILE_EXISTS_DIALOG_TITLE_KEY = - "I.lock.file.exists.dialog.title"; // NOI18N - - private static final String LOCK_FILE_EXISTS_DIALOG_TEXT_KEY = - "I.lock.file.exists.dialog.text"; // NOI18N - - private static final String ERROR_CANNOT_CREATE_LOCK_FILE_KEY = - "I.error.cannot.create.lock.file"; // NOI18N - -} diff --git a/nbi/engine/src/org/netbeans/installer/product/Bundle.properties b/nbi/engine/src/org/netbeans/installer/product/Bundle.properties deleted file mode 100644 index fea513da29e1..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/Bundle.properties +++ /dev/null @@ -1,67 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -R.loading.local.registry=Loading local registry [{0}] -R.error.loading.local.registry.failed.title=Failed to load the local registry -R.error.loading.local.registry.failed.msg=The local registry ({0}) could not be loaded, or was loaded partially.\nThe installer can continue to work normally, but doing so may result in a corrupted global registry.\n\nChoose Yes to continue, No to exit the installer. - -R.loading.bundled.registry=Loading bundled registry [{0}] -R.error.loading.bundled.registry.failed.title=Failed to load the bundled registry -R.error.loading.bundled.registry.failed.msg=The bundled registry ({0}) could not be loaded, or was loaded partially.\nThe installer can continue to work normally, but doing so may result in a corrupted global registry.\n\nChoose Yes to continue, No to exit the installer. - -R.loading.remote.registry=Loading remote registry [{0}] -R.error.loading.remote.registry.failed.title=Failed to load the remote registry -R.error.loading.remote.registry.failed.msg=The remote registry ({0}) could not be loaded, or was loaded partially.\nThe installer can continue to work normally, but doing so may result in a corrupted global registry.\n\nChoose Yes to continue, No to exit the installer. - -R.error.cannot.delete.data=Cannot delete the cached installation data -R.save.local.registry.title=Saving local registry -R.save.local.registry.detail=Saving to {0} - -R.error.missing.target.component.title=Missing target component -R.error.missing.target.component.msg=The specified target component - {0}/{1}\nwas not found in the registry. The installer\n can continue as if the target component was not specified.\nClick Yes to continue, No to exit the installer. - -R.error.validation.title=Validation Problem -R.error.validation.msg=It seems that the installation of {0} is corrupted.\nThe validation procedure issued the following warning:\n\n{1}\n\nWould you like to mark this product as not installed and continue?\nIf you click No the installer will exit.\n\nNote that these products that depend on {2} will also be disabled:\n{3} - -R.error.matching.requirement=No components matching the requirement: {0} requires {1} -R.error.cyclic.dependency=Cyclic dependency: {0}, {1} - -R.loading.registry.properties=Loading registry properties -R.loading.component=Loading component: uid={0}, version={1} -R.error.loading.components=Could not load components -R.error.registry.finalization=Could not finalize registry -R.error.registry.document.loading=Could not load registry document - -R.error.cannot.create.cache.directory=Cannot create local product cache directory {0} -R.error.cache.is.file=Local product cache directory exists and is a file : {0} -R.error.cannot.read.cache=Cannot read local product cache directory {0} - not enough permissions -R.error.cannot.write.cache=Cannot write to local product cache directory {0} - not enough permissions -R.error.cannot.create.registry=Cannot create local registry - -R.error.registry.is.dir=Local registry {0} is a directory -R.error.cannot.read.registry=Cannot read local registry {0} - not enough permissions -R.error.cannot.write.registry=Cannot write local registry {0} - not enough permissions - -R.error.cannot.parse.platform=Cannot parse platform from "{0}" -R.error.cannot.load.registry=Cannot load registry -R.error.parser.not.support.schemas=The current parser - {0} - does not support schemas. - -R.error.unknown.dependency=Unknown dependency type {0} - -R.registry.initialization.failed=Cannot initialize registry diff --git a/nbi/engine/src/org/netbeans/installer/product/Registry.java b/nbi/engine/src/org/netbeans/installer/product/Registry.java deleted file mode 100644 index 73d530c57462..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/Registry.java +++ /dev/null @@ -1,1928 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.Queue; -import java.util.Set; -import java.util.Map; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.components.ProductConfigurationLogic; -import org.netbeans.installer.product.dependencies.Conflict; -import org.netbeans.installer.product.dependencies.InstallAfter; -import org.netbeans.installer.product.dependencies.Requirement; -import org.netbeans.installer.product.filters.OrFilter; -import org.netbeans.installer.product.filters.ProductFilter; -import org.netbeans.installer.product.filters.GroupFilter; -import org.netbeans.installer.product.filters.RegistryFilter; -import org.netbeans.installer.product.filters.TrueFilter; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.helper.DetailedStatus; -import org.netbeans.installer.utils.helper.ExtendedUri; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.helper.ExecutionMode; -import org.netbeans.installer.utils.helper.Feature; -import org.netbeans.installer.utils.helper.FinishHandler; -import org.netbeans.installer.utils.helper.NbiProperties; -import org.netbeans.installer.utils.helper.PropertyContainer; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -/** - * - * @author Kirill Sorokin - */ -public class Registry implements PropertyContainer { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static Registry instance; - - public static synchronized Registry getInstance() { - if (instance == null) { - instance = new Registry(); - } - - return instance; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private File localDirectory; - private File localRegistryFile; - private File localProductCache; - - private String localRegistryStubUri; - private String bundledRegistryUri; - private List remoteRegistryUris; - private String registrySchemaUri; - - private String stateFileSchemaUri; - private String stateFileStubUri; - - private List features; - - private List includes; - - private RegistryNode registryRoot; - private NbiProperties properties; - private Platform targetPlatform; - - private FinishHandler finishHandler; - - // constructors ///////////////////////////////////////////////////////////////// - public Registry() { - localRegistryStubUri = DEFAULT_LOCAL_PRODUCT_REGISTRY_STUB_URI; - bundledRegistryUri = DEFAULT_BUNDLED_PRODUCT_REGISTRY_URI; - remoteRegistryUris = new ArrayList(); - registrySchemaUri = DEFAULT_PRODUCT_REGISTRY_SCHEMA_URI; - - stateFileSchemaUri = DEFAULT_STATE_FILE_SCHEMA_URI; - stateFileStubUri = DEFAULT_STATE_FILE_STUB_URI; - - features = new LinkedList(); - - includes = new LinkedList(); - - registryRoot = new Group(); - registryRoot.setRegistryType(RegistryType.LOCAL); - - properties = new NbiProperties(); - targetPlatform = SystemUtils.getCurrentPlatform(); - } - - // initialization/finalization ////////////////////////////////////////////////// - public void setLocalDirectory( - final File localDirectory) { - this.localDirectory = localDirectory; - - localProductCache = new File( - localDirectory, - DEFAULT_LOCAL_PRODUCT_CACHE_DIRECTORY_NAME); - localRegistryFile = new File( - localDirectory, - DEFAULT_LOCAL_REGISTRY_FILE_NAME); - } - - public void setFinishHandler( - final FinishHandler finishHandler) { - this.finishHandler = finishHandler; - } - - public void setTargetPlatform( - final Platform targetPlatform) { - this.targetPlatform = targetPlatform; - } - - public void initializeRegistry( - final Progress progress) throws InitializationException { - LogManager.logEntry("initializing product registry"); - - setRegistryProperties(); - - loadAllRegistries(progress); - - validateDependencies(); - - if (System.getProperty(SOURCE_STATE_FILE_PATH_PROPERTY) != null) { - loadStateFile( - new File(System.getProperty(SOURCE_STATE_FILE_PATH_PROPERTY)), - new Progress()); - } - - applyRegistryFilters(); - if (System.getProperty(SOURCE_STATE_FILE_PATH_PROPERTY) == null) { - changeStatuses(); - } - - LogManager.logExit("... product registry initialization complete"); - } - - private void loadAllRegistries (Progress progress) { - final CompositeProgress compositeProgress = new CompositeProgress(); - int percentageChunk = Progress.COMPLETE / (remoteRegistryUris.size() + 2); - int percentageLeak = Progress.COMPLETE % (remoteRegistryUris.size() + 2); - - compositeProgress.synchronizeTo(progress); - compositeProgress.synchronizeDetails(true); - compositeProgress.setPercentage(percentageLeak); - - loadProductRegistry(compositeProgress, localRegistryFile, RegistryType.LOCAL, percentageChunk, false); - loadProductRegistry(compositeProgress, bundledRegistryUri, RegistryType.BUNDLED, percentageChunk, true); - - for (String remoteRegistryURI: remoteRegistryUris) { - loadProductRegistry(compositeProgress, remoteRegistryURI, RegistryType.REMOTE, percentageChunk, true); - } - } - - private String getLoadingRegistryMessageKey (RegistryType type) { - switch (type) { - case BUNDLED : return LOADING_BUNDLED_REGISTRY_KEY; - case LOCAL : return LOADING_LOCAL_REGISTRY_KEY; - case REMOTE : return LOADING_REMOTE_REGISTRY_KEY; - default: return null; - } - } - - private String getErrorLoadingRegistryTitleKey (RegistryType type) { - switch (type) { - case BUNDLED : return ERROR_LOADING_BUNDLED_REGISTRY_TITLE_KEY; - case LOCAL : return ERROR_LOADING_LOCAL_REGISTRY_TITLE_KEY; - case REMOTE : return ERROR_LOADING_REMOTE_REGISTRY_TITLE_KEY; - default: return null; - } - } - private String getErrorLoadingRegistryMessageKey (RegistryType type) { - switch (type) { - case BUNDLED : return ERROR_LOADING_BUNDLED_REGISTRY_MESSAGE_KEY; - case LOCAL : return ERROR_LOADING_LOCAL_REGISTRY_MESSAGE_KEY; - case REMOTE : return ERROR_LOADING_REMOTE_REGISTRY_MESSAGE_KEY; - default: return null; - } - } - - private void loadProductRegistry ( - CompositeProgress compositeProgress, - File registryFile, - RegistryType type, - int percentageChunk, - boolean includes) { - - loadProductRegistry (compositeProgress, - registryFile.toURI().toString(), - registryFile, - type, - percentageChunk, - includes); - } - - private void loadProductRegistry ( - CompositeProgress compositeProgress, - String registryUri, - RegistryType type, - int percentageChunk, - boolean includes) { - - loadProductRegistry (compositeProgress, - registryUri, - registryUri, - type, - percentageChunk, - includes); - } - - private void loadProductRegistry( - CompositeProgress compositeProgress, - String registryUri, - Object registryDisplayName, - RegistryType type, - int percentageChunk, - boolean includes) { - - Progress childProgress = new Progress(); - compositeProgress.addChild(childProgress, percentageChunk); - compositeProgress.setTitle(ResourceUtils.getString(Registry.class, - getLoadingRegistryMessageKey(type), - registryDisplayName)); - - try { - loadProductRegistry( - registryUri, - childProgress, - type, - includes); - } catch (InitializationException e) { - if (!UiUtils.showYesNoDialog( - ResourceUtils.getString( - Registry.class, getErrorLoadingRegistryTitleKey(type)), - ResourceUtils.getString(Registry.class, - getErrorLoadingRegistryMessageKey(type), registryDisplayName))) { - finishHandler.criticalExit(); - } else { - LogManager.log(ErrorLevel.ERROR, e); - } - } - } - - public void finalizeRegistry( - final Progress progress) throws FinalizationException { - LogManager.logEntry("finalizing product registry"); - - progress.setPercentage(Progress.START); - - // remove installation data for all the products, if it still exists (should - // be removed right upon installation); we only remove the files if the - // local uri is different from the remote one and is not contained in the - // list of alternate uris -- as we could be useing a locally located remote - // registry - LogManager.log("... removing remaining installation data for all the products"); - for (Product product: getProducts()) { - for (ExtendedUri uri: product.getDataUris()) { - try { - FileProxy.getInstance().deleteFile(uri); - } catch (IOException e) { - ErrorManager.notifyWarning( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_DELETE_DATA_KEY), - e); - } - } - } - LogManager.log("... save local registry if necessary"); - // save the local registry if we're executing in normal mode (i.e. not - // creating a bundle) - if (ExecutionMode.getCurrentExecutionMode() == ExecutionMode.NORMAL) { - progress.setTitle(ResourceUtils.getString(Registry.class, - SAVE_LOCAL_REGISTRY_TITLE_KEY)); - progress.setDetail(ResourceUtils.getString(Registry.class, - SAVE_LOCAL_REGISTRY_DETAIL_KEY, localRegistryFile)); - LogManager.log("... save registry to file " + localRegistryFile); - saveProductRegistry( - localRegistryFile, - new ProductFilter(Status.INSTALLED), - false, // we don't need any includes in the local registry, - true, // but the registry's properties would be nice, - false); // and the features list is not required either - } - - // save the state file if it is required (i.e. --record command line option - // was specified) - LogManager.log("... save state file if necessary"); - if (System.getProperty(TARGET_STATE_FILE_PATH_PROPERTY) != null) { - File stateFile = - new File(System.getProperty(TARGET_STATE_FILE_PATH_PROPERTY)); - LogManager.log("... save state file to " + stateFile); - saveStateFile(stateFile, new Progress()); - } - - progress.setPercentage(Progress.COMPLETE); - - LogManager.logExit("finalizing product registry"); - } - - private void setRegistryProperties( - ) throws InitializationException { - LogManager.logEntry("initializing product registry properties"); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.logIndent("initializing local product cache directory"); - if (System.getProperty(LOCAL_PRODUCT_CACHE_DIRECTORY_PROPERTY) != null) { - localProductCache = new File( - localDirectory, - System.getProperty(LOCAL_PRODUCT_CACHE_DIRECTORY_PROPERTY)); - } - if (!localProductCache.exists()) { - if (!localProductCache.mkdirs()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_CREATE_CACHE_DIR_KEY, - localProductCache )); - } - } else if (localProductCache.isFile()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CACHE_IS_FILE_KEY, - localProductCache )); - } else if (!localProductCache.canRead()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_READ_CACHE_KEY, - localProductCache )); - } else if (!localProductCache.canWrite()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_WRITE_CACHE_KEY, - localProductCache )); - } - LogManager.logUnindent("... " + localProductCache); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log("initializing local product registry file"); - if (System.getProperty(LOCAL_PRODUCT_REGISTRY_PROPERTY) != null) { - localRegistryFile = new File( - localDirectory, - System.getProperty(LOCAL_PRODUCT_REGISTRY_PROPERTY)); - } - - if (!localRegistryFile.exists()) { - try { - FileUtils.copyFile( - FileProxy.getInstance().getFile(localRegistryStubUri,true), - localRegistryFile); - } catch (DownloadException e) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_CREATE_REGISTRY_KEY), e); - } catch (IOException e) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_CREATE_REGISTRY_KEY), e); - } - } else if (localRegistryFile.isDirectory()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_REGISTRY_IS_DIRECTORY_KEY, localRegistryFile)); - } else if (!localRegistryFile.canRead()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_READ_CACHE_KEY, - localRegistryFile )); - } else if (!localRegistryFile.canWrite()) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_WRITE_REGISTRY_KEY, - localRegistryFile )); - } - LogManager.log(" ... " + localRegistryFile); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing local product registry stub uri"); - if (System.getProperty(LOCAL_PRODUCT_REGISTRY_STUB_PROPERTY) != null) { - localRegistryStubUri = - System.getProperty(LOCAL_PRODUCT_REGISTRY_STUB_PROPERTY); - } - LogManager.log(" ... " + localRegistryStubUri); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing bundled product registry uri"); - if (System.getProperty(BUNDLED_PRODUCT_REGISTRY_URI_PROPERTY) != null) { - bundledRegistryUri = - System.getProperty(BUNDLED_PRODUCT_REGISTRY_URI_PROPERTY); - } - LogManager.log(" ... " + bundledRegistryUri); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing product registry schema uri"); - if (System.getProperty(PRODUCT_REGISTRY_SCHEMA_URI_PROPERTY) != null) { - registrySchemaUri = System.getProperty(PRODUCT_REGISTRY_SCHEMA_URI_PROPERTY); - } - LogManager.log(" ... " + registrySchemaUri); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing remote product registries uris"); - if (System.getProperty(REMOTE_PRODUCT_REGISTRIES_PROPERTY) != null) { - for (String remoteRegistryURI: System.getProperty(REMOTE_PRODUCT_REGISTRIES_PROPERTY).split(StringUtils.LF)) { - remoteRegistryUris.add(remoteRegistryURI); - } - } - for (String string: remoteRegistryUris) { - LogManager.log(" ... " + string); - } - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing state file schema uri"); - if (System.getProperty(STATE_FILE_SCHEMA_URI_PROPERTY) != null) { - stateFileSchemaUri = System.getProperty(STATE_FILE_SCHEMA_URI_PROPERTY); - } - LogManager.log(" ... " + stateFileSchemaUri); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing default state file uri"); - if (System.getProperty(STATE_FILE_STUB_PROPERTY) != null) { - stateFileStubUri = System.getProperty(STATE_FILE_STUB_PROPERTY); - } - LogManager.log(" ... " + stateFileStubUri); - - ///////////////////////////////////////////////////////////////////////////// - LogManager.log(" initializing target platform"); - if (System.getProperty(TARGET_PLATFORM_PROPERTY) != null) { - final String platformString = System.getProperty(TARGET_PLATFORM_PROPERTY); - try { - targetPlatform = StringUtils.parsePlatform(platformString); - } catch (ParseException e) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_PARSE_PLATFORM_KEY, - platformString), e); - - } - } - LogManager.log(" ... " + targetPlatform); - LogManager.logExit("initializing product registry properties"); - } - - private void validateDependencies() throws InitializationException { - for (Product product: getProducts()) { - validateDependencies(product); - } - } - - private void validateDependencies(final Product product) throws InitializationException { - validateRequirements(product); - validateConflicts(product); - validateInstallAfters(product); - } - - private void applyRegistryFilters() { - // if a target component was specified, hide everything except: - // * the target itself - // * products, whose requirement(s) the target satisfies - // * ancestors of any of the above - if ((System.getProperty(TARGET_COMPONENT_UID_PROPERTY) != null) && - (System.getProperty(TARGET_COMPONENT_VERSION_PROPERTY) != null)) { - final String uid = System.getProperty(TARGET_COMPONENT_UID_PROPERTY); - final Version version = Version.getVersion( - System.getProperty(TARGET_COMPONENT_VERSION_PROPERTY)); - - final Product target = getProduct(uid, version); - - if (target != null) { - final List dependents = getInavoidableDependents(target); - - for (Product product: getProducts()) { - if (!target.equals(product) && - !dependents.contains(product) && - !product.isAncestor(target) && - !product.isAncestor(dependents)) { - product.setVisible(false); - } - } - } else { - if (!UiUtils.showYesNoDialog( - ResourceUtils.getString(Registry.class, - ERROR_MISSING_TARGET_COMPONENT_TITLE_KEY), - ResourceUtils.getString(Registry.class, - ERROR_MISSING_TARGET_COMPONENT_MSG_KEY, - uid, version ))) { - finishHandler.cancel(); - } else { - for (Product product: getProducts()) { - product.setVisible(false); - } - } - } - } - - // hide products that do not support the current platform - for (Product product: getProducts()) { - boolean compatible = false; - - for (Platform productPlatform: product.getPlatforms()) { - if (targetPlatform.isCompatibleWith(productPlatform)) { - compatible = true; - break; - } - } - - if (!compatible) { - product.setVisible(false); - } - } - - // hide empty groups - for (Group group: getGroups()) { - if (group.isEmpty()) { - group.setVisible(false); - } - } - } - - private void changeStatuses() { - if (Boolean.getBoolean(SUGGEST_INSTALL_PROPERTY) || - Boolean.getBoolean(FORCE_INSTALL_PROPERTY)) { - for (Product product: getProducts(Status.NOT_INSTALLED)) { - // we should not change the status of components that are not - // visible (were filtered out either at build time or runtime), as - // this may cause unexpected results - these components are not - // expected to be dealt with - if (product.isVisible()) { - product.setStatus(Status.TO_BE_INSTALLED); - } - } - } - - if (Boolean.getBoolean(SUGGEST_UNINSTALL_PROPERTY) || - Boolean.getBoolean(FORCE_UNINSTALL_PROPERTY)) { - Version version = null; - for (Product product: getProducts(Status.INSTALLED)) { - // we should not change the status of components that are not - // visible (were filtered out either at build time or runtime), as - // this may cause unexpected results - these components are not - // expected to be dealt with - if (product.isVisible()) { - product.setStatus(Status.TO_BE_UNINSTALLED); - if (product.getUid().equals(BASE_IDE_UID)) { - version = product.getVersion(); - } - } - } - for (Product product : getProducts(JRE_NESTED_UID)) { - // mark for uninstall only proper nested JRE - if (product.getVersion().equals(version)) { - product.setStatus(Status.TO_BE_UNINSTALLED); - } - } - } - } - - // validation /////////////////////////////////////////////////////////////////// - private void validateRequirements( - final Product product) throws InitializationException { - validateRequirements(product, new LinkedList()); - } - - private void validateRequirements( - final Product product, - final List prohibitedList) throws InitializationException { - for (Dependency requirement: product.getDependencies(Requirement.class)) { - // get the list of products that satisfy the requirement - final List requirees = queryProducts(new ProductFilter( - requirement.getUid(), - requirement.getVersionLower(), - requirement.getVersionUpper(), - targetPlatform)); - - // if there are no products that satisfy the requirement, the registry - // is inconsistent - if (requirees.size() == 0) { - String sourceId = - product.getUid() + "/" + - product.getVersion(); - String requirementId = - requirement.getUid() + "/" + - requirement.getVersionLower() + " - " + - requirement.getVersionUpper() + - (requirement.getVersionResolved() != null ? - " [" + requirement.getVersionResolved() + "]" : ""); - - // don't throw exception here, just ask user whether continue or not - InitializationException e = new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_REQUIREMENT_KEY, sourceId, requirementId)); - - ErrorManager.notifyError(StringUtils.format( - ResourceUtils.getString(Registry.class, REGISTRY_INITIALIZATION_FAILED_PROPERTY)), e); - } - - // iterate over the list of satisfying products, and check whether they - // define a dependency that is satisfied wither by the current product - // or by any product in the prohibited list; if it is, we have a cyclic - // dependency which is faulty - throw an exception - for (Product requiree: requirees) { - for (Dependency dependency: requiree.getDependencies()) { - if (product.satisfies(dependency)) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CYCLIC_DEPENDENCY_KEY, - product.getUid(), dependency.getUid())); - - } - - for (Product prohibited: prohibitedList) { - if (prohibited.satisfies(dependency)) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CYCLIC_DEPENDENCY_KEY, - prohibited.getUid(), dependency.getUid())); - } - } - } - - // if the requiree's dependencies are ok, we need to check whether, - // the products that satisfy its requirements are ok as well - final List newProhibitedList = new LinkedList(); - newProhibitedList.addAll(prohibitedList); - newProhibitedList.add(product); - - validateRequirements(requiree, newProhibitedList); - } - } - } - - private void validateConflicts( - final Product product) throws InitializationException { - for (Dependency requirement: product.getDependencies(Requirement.class)) { - // get the list of products that satisfy the requirement - final List requirees = queryProducts(new ProductFilter( - requirement.getUid(), - requirement.getVersionLower(), - requirement.getVersionUpper(), - targetPlatform)); - - for (Dependency conflict: product.getDependencies(Conflict.class)) { - // get the list of products that satisfy the conflict - final List conflictees = queryProducts(new ProductFilter( - conflict.getUid(), - conflict.getVersionLower(), - conflict.getVersionUpper(), - targetPlatform)); - - if (SystemUtils.intersects(requirees, conflictees)) { - throw new InitializationException( - "A requiree is also a conflictee."); - } - } - } - } - - private void validateInstallAfters( - final Product product) throws InitializationException { - validateInstallAfters(product, new LinkedList()); - } - - private void validateInstallAfters( - final Product product, - final List prohibitedList) throws InitializationException { - for (Dependency installafter: product.getDependencies(InstallAfter.class)) { - // get the list of products that satisfy the install-after dependency - final List dependees = queryProducts(new ProductFilter( - installafter.getUid(), - targetPlatform)); - - // iterate over the list of satisfying products, and check whether they - // define a requirement or install-efter dependency that is satisfied - // either by the current product or by any product in the prohibited - // list; if it is, we have a cyclic dependency which is faulty - throw - // an exception - for (Product requiree: dependees) { - for (Dependency dependency: requiree.getDependencies( - Requirement.class, - InstallAfter.class)) { - if (product.satisfies(dependency)) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CYCLIC_DEPENDENCY_KEY, - product.getUid(), dependency.getUid())); - } - - for (Product prohibited: prohibitedList) { - if (prohibited.satisfies(dependency)) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CYCLIC_DEPENDENCY_KEY, - prohibited.getUid(), dependency.getUid())); - } - } - } - - // if the requiree's dependencies are ok, we need to check whether - // the products that satisfy its requirements are ok as well - final List newProhibitedList = new LinkedList(); - newProhibitedList.addAll(prohibitedList); - newProhibitedList.add(product); - - validateRequirements(requiree, newProhibitedList); - } - - } - } - - /** - * Returns the list of products for which the given product is the only one, - * that satisfies the requirement. In other words the returned products define - * at least one requirement that is directly or indirectly satisfied by this - * particular product and not by any other products. - * - *

- * Product's status is also taken into account, i.e. if the dependent product - * is installed, a not installed product cannot be considered as satisfying the - * requirement. - * - * @param product Product for which the dependents chain should be constructed. - * @return The list of products for which the given product is the only one - * satisfying their requirements. - */ - public List getInavoidableDependents(final Product product) { - final Set dependents = new HashSet(); - - for (Product candidate: getProducts()) { - for (Dependency requirement: candidate.getDependencies(Requirement.class)) { - final List requirees = getProducts(requirement); - - // if the candidate product is installed, then not installed - // products cannot be counted as satisfying the requirement - if (candidate.getStatus() == Status.INSTALLED) { - for (int i = 0; i < requirees.size(); i++) { - if (requirees.get(i).getStatus() != Status.INSTALLED) { - requirees.remove(i); - } - } - } - - // if the requirees size is 0 then we're in trouble, but this method - // should not be concerned about this stuff -- it's the - // reponsibility of the requirement validating methods - - // if the list of requirees contains only one element and this - // element equals to the given product -- the candidate should be - // included in the list of inavoidable dependents; additionally we - // need to checks for indirect requirements, i.e. run this method - // recursively on the dependent - if ((requirees.size() == 1) && requirees.get(0).equals(product)) { - dependents.add(candidate); - dependents.addAll(getInavoidableDependents(candidate)); - } - } - } - - return new ArrayList(dependents); - } - - private void validateInstallations() throws InitializationException { - LogManager.logEntry("validating previous installations"); - - final String LIST_ONE_PRODUCT_MESSAGE = "-> {0} ({1}/{2})";//NOI18N - final String CANNOT_GET_LOGIC_MAKE_INVISIBLE_MESSAGE = - "Cannot load configuration logic for {0} ({1}/{2}), marking it as invisible";//NOI18N - final String INSTALLATION_VALIDATION_MESSAGE = - "Installation validation of {0} ({1}/{2}):";//NOI18N - - for (Product product: getProducts()) { - if (product.getStatus() == Status.INSTALLED && product.isVisible()) { - ProductConfigurationLogic logic = null; - try { - logic = product.getLogic(); - } catch (InitializationException e) { - LogManager.log(ErrorLevel.WARNING, - StringUtils.format(CANNOT_GET_LOGIC_MAKE_INVISIBLE_MESSAGE, - product.getDisplayName(), product.getUid(), product.getVersion())); - - LogManager.log(ErrorLevel.WARNING, e); - product.setVisible(false); - - final List inavoidableDependents = - getInavoidableDependents(product); - if (!inavoidableDependents.isEmpty()) { - LogManager.indent(); - LogManager.log(ErrorLevel.WARNING, - "Also make the dependent products invisible: ");//NOI18N - - for (Product p : inavoidableDependents) { - LogManager.log(ErrorLevel.WARNING, - StringUtils.format(LIST_ONE_PRODUCT_MESSAGE, - p.getDisplayName(), p.getUid(), p.getVersion())); - p.setVisible(false); - } - LogManager.unindent(); - } - continue; - } - - final String message = logic.validateInstallation(); - - if (message != null) { - final List inavoidableDependents = - getInavoidableDependents(product); - LogManager.logIndent( - StringUtils.format(INSTALLATION_VALIDATION_MESSAGE, - product.getDisplayName(), product.getUid(), product.getVersion())); - - LogManager.log(message); - if(!inavoidableDependents.isEmpty()) { - LogManager.logIndent("Dependent Products: "); - for(Product p : inavoidableDependents) { - LogManager.log(StringUtils.format(LIST_ONE_PRODUCT_MESSAGE, - p.getDisplayName(), p.getUid(), p.getVersion())); - } - LogManager.unindent(); - } - LogManager.unindent(); - - - boolean result = Boolean.getBoolean(REMOVE_CORRUPTED_PRODUCTS_SILENTLY_PROPERTY) || - UiUtils.showYesNoDialog( - ResourceUtils.getString(Registry.class, - ERROR_VALIDATION_TITLE_KEY), - ResourceUtils.getString(Registry.class, - ERROR_VALIDATION_MSG_KEY, - product.getDisplayName(), - message , - product.getDisplayName(), - StringUtils.asString(inavoidableDependents)), - true); - - if (result) { - product.setStatus(Status.NOT_INSTALLED); - product.getParent().removeChild(product); - for (Product dependent: inavoidableDependents) { - dependent.setStatus(Status.NOT_INSTALLED); - dependent.getParent().removeChild(dependent); - } - } else { - finishHandler.criticalExit(); - } - } - } - } - LogManager.logExit("... validating installations finished"); - } - - // registry <-> dom <-> xml operations ////////////////////////////////////////// - public void loadProductRegistry( - final File file) throws InitializationException { - loadProductRegistry(file.toURI().toString()); - } - - public void loadProductRegistry( - final String uri) throws InitializationException { - loadProductRegistry(uri, new Progress(), RegistryType.REMOTE, false); - } - - public void loadProductRegistry( - final String uri, - final Progress progress, - final RegistryType registryType, - final boolean loadIncludes) throws InitializationException { - try { - LogManager.log("... loading registry from " + uri); - final Element registryElement = - loadRegistryDocument(uri).getDocumentElement(); - - // load the includes - final Element includesElement = - XMLUtils.getChild(registryElement, "includes"); - - if (includesElement != null) { - includes.addAll( - XMLUtils.parseExtendedUrisList(includesElement)); - - if (loadIncludes) { - for (ExtendedUri includeUri: includes) { - loadProductRegistry( - includeUri.getRemote().toString(), - new Progress(), - RegistryType.REMOTE, - true); - } - } - } - - // load the properties - final Element propertiesElement = - XMLUtils.getChild(registryElement, "properties"); - - if (propertiesElement != null) { - final NbiProperties map = - XMLUtils.parseNbiProperties(propertiesElement); - for (Map.Entry entry : map.entrySet()) { - if (!properties.containsKey(entry.getKey())) { - properties.put(entry.getKey(), entry.getValue()); - } - } - } - - // load the features list - final Element featuresElement = - XMLUtils.getChild(registryElement, "features"); - - if (featuresElement != null) { - for (Feature feature: XMLUtils.parseFeaturesList(featuresElement)) { - boolean shouldAdd = true; - - int i; - for (i = 0; i < features.size(); i++) { - if (features.get(i).getId().equals(feature.getId())) { - shouldAdd = false; - break; - } - if (features.get(i).getOffset() > feature.getOffset()) { - break; - } - } - - if (shouldAdd) { - features.add(i, feature); - } - } - } - - // load the components - loadRegistryComponents(registryRoot, registryElement, registryType); - - validateInstallations(); - - progress.setPercentage(Progress.COMPLETE); - } catch (ParseException e) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_LOAD_REGISTRY_KEY), e); - } catch (XMLException e) { - throw new InitializationException( - ResourceUtils.getString(Registry.class, - ERROR_CANNOT_LOAD_REGISTRY_KEY), e); - } - } - - public void saveProductRegistry( - final File file, - final RegistryFilter filter, - final boolean saveIncludes, - final boolean saveProperties, - final boolean saveFeatures) throws FinalizationException { - try { - LogManager.logEntry("saving product registry file"); - LogManager.log("... getting registry document"); - Document document = getRegistryDocument( - filter, saveIncludes, saveProperties, saveFeatures); - LogManager.log("... saving registry document to file " + file); - XMLUtils.saveXMLDocument(document, file); - LogManager.log("... saving XML file succesfully finished"); - } catch (XMLException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } finally { - LogManager.logExit("... saving product registry done"); - } - } - - public Document getEmptyRegistryDocument() throws XMLException { - return loadRegistryDocument(localRegistryStubUri); - } - - public Document getRegistryDocument( - final RegistryFilter filter, - final boolean saveIncludes, - final boolean saveProperties, - final boolean saveFeatures) throws XMLException, FinalizationException { - final Document document = getEmptyRegistryDocument(); - final Element documentElement = document.getDocumentElement(); - - if ((includes.size() > 0) && saveIncludes) { - documentElement.appendChild(XMLUtils.saveExtendedUrisList( - includes, document.createElement("includes"))); - } - - if ((properties.size() > 0) && saveProperties) { - documentElement.appendChild(XMLUtils.saveNbiProperties( - properties, document.createElement("properties"))); - } - - if ((features.size() > 0) && saveFeatures) { - documentElement.appendChild(XMLUtils.saveFeaturesList( - features, document.createElement("features"))); - } - - final Element componentsElement = - registryRoot.saveChildrenToDom(document, filter); - if (componentsElement != null) { - documentElement.appendChild(componentsElement); - } - - return document; - } - - public Document loadRegistryDocument( - final String uri) throws XMLException { - try { - final File schemaFile = - FileProxy.getInstance().getFile(registrySchemaUri,true); - final File registryFile = - FileProxy.getInstance().getFile(uri, true); - - final Schema schema = SchemaFactory.newInstance( - XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaFile); - - final DocumentBuilderFactory factory = - DocumentBuilderFactory.newInstance(); - try { - factory.setSchema(schema); - } catch (UnsupportedOperationException e) { - // if the parser does not support schemas, let it be -- we can do - // without it anyway -- just log it and proceed - ErrorManager.notifyDebug( - ResourceUtils.getString(Registry.class, - ERROR_PARSER_DO_NOT_CUPPORT_SCHEMAS_KEY, - factory.getClass()), e); - } - factory.setNamespaceAware(true); - - final DocumentBuilder builder = factory.newDocumentBuilder(); - - return builder.parse(registryFile); - } catch (DownloadException e) { - throw new XMLException(ResourceUtils.getString(Registry.class, - ERROR_REGISTRY_DOCUMENT_LOADING), e); - } catch (ParserConfigurationException e) { - throw new XMLException(ResourceUtils.getString(Registry.class, - ERROR_REGISTRY_DOCUMENT_LOADING), e); - } catch (SAXException e) { - throw new XMLException(ResourceUtils.getString(Registry.class, - ERROR_REGISTRY_DOCUMENT_LOADING), e); - } catch (IOException e) { - throw new XMLException(ResourceUtils.getString(Registry.class, - ERROR_REGISTRY_DOCUMENT_LOADING), e); - } - } - - private void loadRegistryComponents( - final RegistryNode parentNode, - final Element parentElement, - final RegistryType registryType) throws InitializationException { - final Element element = XMLUtils.getChild(parentElement, "components"); - - if (element != null) { - for (Element child: XMLUtils.getChildren(element)) { - if (child.getNodeName().equals("product")) { - final Product product = new Product().loadFromDom(child); - - // find the existing products which have the same uid/version - // and whose platforms itersect with the platforms of the - // currently loaded component (i.e. at least one of the platforms - // in the existing product is compatible a platform in the - // currept product's set and vice versa) - final List existing = getProducts( - product.getUid(), - product.getVersion(), - product.getPlatforms()); - - product.setRegistryType(registryType); - - if (existing.size() == 0) { - parentNode.addChild(product); - loadRegistryComponents(product, child, registryType); - } else { - final RegistryNode existingNode = existing.get(0); - if(!existingNode.getParent().getUid().equals(parentNode.getUid())){ - existingNode.getParent().removeChild(existingNode); - parentNode.addChild(existingNode); - } - loadRegistryComponents(existingNode, child, registryType); - } - } - - if (child.getNodeName().equals("group")) { - final Group group = new Group().loadFromDom(child); - final Group existing = getGroup(group.getUid()); - - group.setRegistryType(registryType); - - if (existing == null) { - parentNode.addChild(group); - loadRegistryComponents(group, child, registryType); - } else { - loadRegistryComponents(existing, child, registryType); - } - } - } - } - } - - // basic queries //////////////////////////////////////////////////////////////// - public List query(final RegistryFilter filter) { - List matches = new LinkedList(); - Queue queue = new LinkedList(); - - queue.offer(registryRoot); - while (queue.peek() != null) { - final RegistryNode node = queue.poll(); - - if (filter.accept(node)) { - matches.add(node); - } - - for (RegistryNode child: node.getChildren()) { - queue.offer(child); - } - } - - return matches; - } - - public List queryProducts(final RegistryFilter filter) { - List components = new ArrayList(); - - for (RegistryNode node: query(filter)) { - if (node instanceof Product) { - components.add((Product) node); - } - } - - return components; - } - - public List queryGroups(final RegistryFilter filter) { - List groups = new ArrayList(); - - for (RegistryNode node: query(filter)) { - if (node instanceof Group) { - groups.add((Group) node); - } - } - - return groups; - } - - public List getNodes() { - return query(TrueFilter.INSTANCE); - } - - public List getNodes(final RegistryType registryType) { - final List filtered = new LinkedList(); - - for (RegistryNode node: getNodes()) { - if (node.getRegistryType() == registryType) { - filtered.add(node); - } - } - - return filtered; - } - - // products queries ///////////////////////////////////////////////////////////// - public List getProducts() { - return queryProducts(TrueFilter.INSTANCE); - } - - public List getProducts(final Platform platform) { - return queryProducts(new ProductFilter(platform)); - } - - public List getProducts(final String uid) { - return queryProducts(new ProductFilter(uid, targetPlatform)); - } - - public List getProducts(final String uid, final Version lower, final Version upper) { - return queryProducts(new ProductFilter(uid, lower, upper, targetPlatform)); - } - - public List getProducts(final String uid, final Version version, final Platform platform) { - return queryProducts(new ProductFilter(uid, version, platform)); - } - - public List getProducts(final String uid, final Version version, final List platforms) { - return queryProducts(new ProductFilter(uid, version, platforms)); - } - - public List getProducts(final Dependency dependency) { - if(dependency instanceof Requirement) { - if (dependency.getVersionResolved() != null) { - return queryProducts(new ProductFilter( - dependency.getUid(), - dependency.getVersionResolved(), - dependency.getVersionResolved(), - targetPlatform)); - } - } - if(dependency instanceof Requirement || dependency instanceof Conflict) { - return queryProducts(new ProductFilter( - dependency.getUid(), - dependency.getVersionLower(), - dependency.getVersionUpper(), - targetPlatform)); - } - if(dependency instanceof InstallAfter) { - return queryProducts(new ProductFilter( - dependency.getUid(), - targetPlatform)); - } - ErrorManager.notifyCritical(ResourceUtils.getString(Registry.class, - ERROR_UNKNOWN_DEPENDENCY_KEY, dependency.getClass().toString())); - - // the only way for us to reach this spot is to get to 'default:' in the - // switch, but ErrorManager.notifyCritical() will cause a System.exit(), - // so the below line is present only for successful compilation - return null; - } - - public List getProducts(final Status status) { - return queryProducts(new ProductFilter(status, targetPlatform)); - } - - public List getProducts(final DetailedStatus detailedStatus) { - return queryProducts(new ProductFilter(detailedStatus, targetPlatform)); - } - - public List getProducts(final Feature feature) { - return queryProducts(new ProductFilter(feature, targetPlatform)); - } - - public Product getProduct(final String uid, final Version version) { - final List candidates = getProducts( - uid, - version, - targetPlatform); - - return (candidates.size() > 0) ? candidates.get(0) : null; - } - - // groups queries /////////////////////////////////////////////////////////////// - public List getGroups() { - return queryGroups(TrueFilter.INSTANCE); - } - - public Group getGroup(final String uid) { - List candidates = queryGroups(new GroupFilter(uid)); - - return (candidates.size() > 0) ? candidates.get(0) : null; - } - - // installation order related queries /////////////////////////////////////////// - public List getProductsToInstall() { - final List products = new LinkedList(); - - Product product; - while ((product = getNextComponentToInstall(products)) != null) { - products.add(product); - } - - return products; - } - - public List getProductsToUninstall() { - final List products = new ArrayList(); - - Product product; - while ((product = getNextComponentToUninstall(products)) != null) { - products.add(product); - } - - return products; - } - - private Product getNextComponentToInstall(final List currentList) { - for (Product product: getProducts()) { - if ((product.getStatus() == Status.TO_BE_INSTALLED) && - !currentList.contains(product) && - checkDependenciesForInstall(product)) { - boolean productIsGood = true; - - // all products satisfying the requirement and install-after - // dependencies which are planned for installation should be already - // present in the list - for (Dependency dependency: product.getDependencies( - Requirement.class, - InstallAfter.class)) { - for (Product dependee: getProducts(dependency)) { - if ((dependee.getStatus() == Status.TO_BE_INSTALLED) && - !currentList.contains(dependee)) { - productIsGood = false; - } - } - } - - if (productIsGood) { - return product; - } - } - } - - return null; - } - - private Product getNextComponentToUninstall(final List currentList) { - for (Product product: getProducts()) { - if ((product.getStatus() == Status.TO_BE_UNINSTALLED) && - !currentList.contains(product) && - checkDependenciesForUninstall()) { - boolean productIsGood = true; - - for (Product dependent: getProducts()) { - if (dependent.getStatus() != Status.NOT_INSTALLED && - dependent.getStatus() != Status.TO_BE_INSTALLED && - !currentList.contains(dependent) && - satisfiesRequirement(product, dependent)) { - productIsGood = false; - break; - } - } - - if (productIsGood) { - return product; - } - - } - } - return null; - } - - // products ///////////////////////////////////////////////////////////////////// - public boolean satisfiesRequirement(final Product candidate, final Product product) { - for (Dependency requirement: product.getDependencies(Requirement.class)) { - final List requirees = getProducts(requirement); - - for (Product requiree: requirees) { - if (candidate.equals(requiree) || - satisfiesRequirement(candidate, requiree)) { - return true; - } - } - } - - return false; - } - - public boolean checkDependenciesForInstall(final Product product) { - for (Dependency requirement: product.getDependencies(Requirement.class)) { - final List requirees = getProducts(requirement); - boolean satisfied = false; - - for (Product requiree: requirees) { - if ((requiree.getStatus() == Status.INSTALLED) || - (requiree.getStatus() == Status.TO_BE_INSTALLED)) { - satisfied = true; - break; - } - } - - if (!satisfied) return false; - } - - for (Dependency conflict: product.getDependencies(Conflict.class)) { - final List conflictees = getProducts(conflict); - boolean satisfied = true; - - for (Product conflictee: conflictees) { - if ((conflictee.getStatus() == Status.INSTALLED) || - (conflictee.getStatus() == Status.TO_BE_INSTALLED)) { - satisfied = false; - break; - } - } - - if (!satisfied) return false; - } - - return true; - } - - public boolean checkDependenciesForUninstall() { - for (Product product: getProducts()) { - if ((product.getStatus() == Status.INSTALLED) || - (product.getStatus() == Status.TO_BE_INSTALLED)) { - for (Dependency requirement: product.getDependencies(Requirement.class)) { - final List requirees = getProducts(requirement); - - for (Product requiree: requirees) { - if (requiree.getStatus() == Status.INSTALLED) { - return true; - } - } - } - } - } - - return true; - } - - // properties /////////////////////////////////////////////////////////////////// - public Properties getProperties() { - return properties; - } - - public String getProperty(final String name) { - return properties.getProperty(name); - } - - public void setProperty(final String name, final String value) { - properties.setProperty(name, value); - } - - // state file methods /////////////////////////////////////////////////////////// - public void loadStateFile(final File stateFile, final Progress progress) throws InitializationException { - try { - LogManager.log("loading state file from " + stateFile.getAbsolutePath()); - - LogManager.log("parsing xml file..."); - final File schemaFile = - FileProxy.getInstance().getFile(stateFileSchemaUri,true); - - final Schema schema = SchemaFactory. - newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI). - newSchema(schemaFile); - - final DocumentBuilderFactory factory = - DocumentBuilderFactory.newInstance(); - try { - factory.setSchema(schema); - } catch (UnsupportedOperationException e) { - // if the parser does not support schemas, let it be -- we can do - // without it anyway -- just log it and proceed - ErrorManager.notifyDebug( - ResourceUtils.getString(Registry.class, - ERROR_PARSER_DO_NOT_CUPPORT_SCHEMAS_KEY, - factory.getClass()), e); - } - factory.setNamespaceAware(true); - - final Document document = factory. - newDocumentBuilder(). - parse(stateFile); - LogManager.log("...complete"); - - final Element element = document.getDocumentElement(); - - // get the total number of components in this state file, we need this to - // be able to properly update the progress - int productsNumber = XMLUtils.countDescendants(element, "product"); - - // we should get the percentage per component and we reserce one area for - // registry-wide properties - int percentageChunk = Progress.COMPLETE / (productsNumber + 1); - int percentageLeak = Progress.COMPLETE % (productsNumber + 1); - - LogManager.log(" parsing registry properties..."); - - final Element propertiesElement = - XMLUtils.getChild(element, "properties"); - if (propertiesElement != null) { - progress.setDetail(ResourceUtils.getString(Registry.class, - LOADING_REGISTRY_PROPERTIES_KEY)); - properties.putAll(XMLUtils.parseNbiProperties(propertiesElement)); - } - - LogManager.log(" ...complete"); - progress.addPercentage(percentageChunk + percentageLeak); - - LogManager.log(ErrorLevel.DEBUG, " parsing components..."); - - final Element productsElement = - XMLUtils.getChild(element, "components"); - if (productsElement != null) { - for (Element productElement: XMLUtils.getChildren(productsElement)) { - final String uid = - productElement.getAttribute("uid"); - final Version version = - Version.getVersion(productElement.getAttribute("version")); - final List platforms = - StringUtils.parsePlatforms(productElement.getAttribute("platform")); - - LogManager.log(" parsing component uid=" + uid + ", version=" + version); - progress.setDetail(ResourceUtils.getString(Registry.class, - LOADING_COMPONENT_KEY, uid, version)); - - boolean compatible = false; - - for (Platform productPlatform: platforms) { - if (targetPlatform.isCompatibleWith(productPlatform)) { - compatible = true; - break; - } - } - - if (compatible) { - final Product product = getProduct(uid, version); - - if (product != null) { - final Status status = StringUtils.parseStatus(productElement.getAttribute("status")); - switch (status) { - case NOT_INSTALLED: - continue; - case TO_BE_INSTALLED: - if (product.getStatus() != Status.INSTALLED) { - product.setStatus(status); - } else { - continue; - } - break; - case INSTALLED: - continue; - case TO_BE_UNINSTALLED: - if (product.getStatus() != Status.NOT_INSTALLED) { - product.setStatus(status); - } else { - continue; - } - break; - } - - final Element productPropertiesElement = XMLUtils.getChild(productElement, "properties"); - if (productPropertiesElement != null) { - product.getProperties().putAll( - XMLUtils.parseNbiProperties(productPropertiesElement)); - } - } - } - } - } - LogManager.log(ErrorLevel.DEBUG, " ...complete"); - } catch (DownloadException e) { - throw new InitializationException(ResourceUtils.getString( - Registry.class, ERROR_LOADING_COMPONENTS), e); - } catch (ParserConfigurationException e) { - throw new InitializationException(ResourceUtils.getString( - Registry.class, ERROR_LOADING_COMPONENTS), e); - } catch (SAXException e) { - throw new InitializationException(ResourceUtils.getString( - Registry.class, ERROR_LOADING_COMPONENTS), e); - } catch (IOException e) { - throw new InitializationException(ResourceUtils.getString( - Registry.class, ERROR_LOADING_COMPONENTS), e); - } catch (ParseException e) { - throw new InitializationException(ResourceUtils.getString( - Registry.class, ERROR_LOADING_COMPONENTS), e); - } - } - - public void saveStateFile(final File stateFile, final Progress progress) throws FinalizationException { - try { - final File schemaFile = - FileProxy.getInstance().getFile(stateFileSchemaUri,true); - final File stubFile = - FileProxy.getInstance().getFile(stateFileStubUri,true); - - final Schema schema = SchemaFactory. - newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI). - newSchema(schemaFile); - - final DocumentBuilderFactory factory = - DocumentBuilderFactory.newInstance(); - try { - factory.setSchema(schema); - } catch (UnsupportedOperationException e) { - // if the parser does not support schemas, let it be -- we can do - // without it anyway -- just log it and proceed - ErrorManager.notifyDebug( - ResourceUtils.getString(Registry.class, - ERROR_PARSER_DO_NOT_CUPPORT_SCHEMAS_KEY, - factory.getClass()), e); - } - factory.setNamespaceAware(true); - - final Document document = factory. - newDocumentBuilder(). - parse(stubFile); - - final Element documentElement = document.getDocumentElement(); - - if (properties.size() > 0) { - Element propertiesNode = document.createElement("properties"); - - for (Object key: properties.keySet()) { - String name = (String) key; - - Element propertyNode = document.createElement("property"); - - propertyNode.setAttribute("name", name); - propertyNode.setTextContent(properties.getProperty(name)); - - propertiesNode.appendChild(propertyNode); - } - - documentElement.appendChild(propertiesNode); - } - - List products = queryProducts(new OrFilter( - new ProductFilter(Status.INSTALLED, targetPlatform), - new ProductFilter(Status.NOT_INSTALLED, targetPlatform))); - if (products.size() > 0) { - final Element productsNode = document.createElement("components"); - - for (Product component: products) { - final Element productNode = document.createElement("product"); - - productNode.setAttribute( - "uid", - component.getUid()); - productNode.setAttribute( - "version", - component.getVersion().toString()); - productNode.setAttribute( - "platform", - StringUtils.asString(component.getPlatforms(), " ")); - - switch (component.getStatus()) { - case INSTALLED: - productNode.setAttribute( - "status", - Status.TO_BE_INSTALLED.toString()); - break; - case NOT_INSTALLED: - productNode.setAttribute( - "status", - Status.TO_BE_UNINSTALLED.toString()); - break; - default: - continue; - } - - if (component.getProperties().size() > 0) { - Element propertiesNode = document.createElement("properties"); - Properties props = new Properties(); - props.putAll(component.getProperties()); - for (Object key: props.keySet()) { - String name = (String) key; - - Element propertyNode = document.createElement("property"); - - propertyNode.setAttribute("name", name); - propertyNode.setTextContent(props.getProperty(name)); - - propertiesNode.appendChild(propertyNode); - } - productNode.appendChild(propertiesNode); - } - - productsNode.appendChild(productNode); - } - - documentElement.appendChild(productsNode); - } - FileUtils.mkdirs(stateFile.getParentFile()); - XMLUtils.saveXMLDocument(document, stateFile); - } catch (DownloadException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } catch (ParserConfigurationException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } catch (SAXException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } catch (IOException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } catch (XMLException e) { - throw new FinalizationException(ResourceUtils.getString( - Registry.class, ERROR_REGISTRY_FINALIZATION), e); - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public File getLocalProductCache() { - return localProductCache; - } - - public RegistryNode getRegistryRoot() { - return registryRoot; - } - - public boolean hasInstalledChildren(final RegistryNode parentNode) { - for (RegistryNode child: parentNode.getChildren()) { - if (child instanceof Product) { - Product component = (Product) child; - if (component.getStatus() == Status.INSTALLED) { - return true; - } - } - - if (hasInstalledChildren(child)) { - return true; - } - } - - return false; - } - - public Platform getTargetPlatform() { - return targetPlatform; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - - public static final String BASE_IDE_UID = - "nb-base"; // NOI18N - - public static final String JRE_NESTED_UID = - "jre-nested"; // NOI18N - - public static final String DEFAULT_LOCAL_PRODUCT_CACHE_DIRECTORY_NAME = - "product-cache"; - - public static final String LOCAL_PRODUCT_CACHE_DIRECTORY_PROPERTY = - "nbi.product.local.cache.directory.name"; - - public static final String DEFAULT_LOCAL_REGISTRY_FILE_NAME = - "registry.xml"; - public static final String DEFAULT_BUNDLED_REGISTRY_FILE_NAME = - "registry.xml"; - - public static final String LOCAL_PRODUCT_REGISTRY_PROPERTY = - "nbi.product.local.registry.file.name"; - - public static final String DEFAULT_LOCAL_PRODUCT_REGISTRY_STUB_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/product/default-registry.xml"; - - public static final String LOCAL_PRODUCT_REGISTRY_STUB_PROPERTY = - "nbi.product.local.registry.stub"; - - public static final String DEFAULT_BUNDLED_PRODUCT_REGISTRY_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - EngineResources.DATA_DIRECTORY + StringUtils.FORWARD_SLASH + - DEFAULT_BUNDLED_REGISTRY_FILE_NAME; - - public static final String BUNDLED_PRODUCT_REGISTRY_URI_PROPERTY = - "nbi.product.bundled.registry.uri"; - - public static final String DEFAULT_PRODUCT_REGISTRY_SCHEMA_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/product/registry.xsd"; - - public static final String PRODUCT_REGISTRY_SCHEMA_URI_PROPERTY = - "nbi.product.registry.schema.uri"; - - public static final String REMOTE_PRODUCT_REGISTRIES_PROPERTY = - "nbi.product.remote.registries"; - - public static final String TARGET_COMPONENT_UID_PROPERTY = - "nbi.product.target.component.uid"; - - public static final String TARGET_COMPONENT_VERSION_PROPERTY = - "nbi.product.target.component.version"; - - public static final String SOURCE_STATE_FILE_PATH_PROPERTY = - "nbi.product.source.state.file.path"; - - public static final String TARGET_STATE_FILE_PATH_PROPERTY = - "nbi.product.target.state.file.path"; - - public static final String STATE_FILE_SCHEMA_URI_PROPERTY = - "nbi.state.file.schema.uri"; - - public static final String DEFAULT_STATE_FILE_SCHEMA_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/product/state-file.xsd"; - - public static final String DEFAULT_STATE_FILE_STUB_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/product/default-state-file.xml"; - - public static final String STATE_FILE_STUB_PROPERTY = - "nbi.state.file.stub"; - - public static final String TARGET_PLATFORM_PROPERTY = - "nbi.target.platform"; - - public static final String SUGGEST_INSTALL_PROPERTY = - "nbi.product.suggest.install"; - - public static final String SUGGEST_UNINSTALL_PROPERTY = - "nbi.product.suggest.uninstall"; - - public static final String FORCE_INSTALL_PROPERTY = - "nbi.product.force.install"; - - public static final String FORCE_UNINSTALL_PROPERTY = - "nbi.product.force.uninstall"; - - public static final String CREATE_BUNDLE_PATH_PROPERTY = - "nbi.create.bundle.path"; - public static final String CREATE_BUNDLE_SKIP_NATIVE_LAUNCHER_PROPERTY = - "nbi.create.bundle.skip.native.launcher"; - - public static final String LAZY_LOAD_ICONS_PROPERTY = - "nbi.product.lazy.load.icons"; - /** - * If this property is set to true then all products which - * ProductConfigurationLogic.validateInstallation() invokation returned not-null message - * will be removed (together with all dependent products) silently from the registry. - * Such removal do nothing with the product uninstallation. - * - */ - public static final String REMOVE_CORRUPTED_PRODUCTS_SILENTLY_PROPERTY = - "nbi.product.remove.corrupted.products.silently";//NOI18N - - private static final String LOADING_LOCAL_REGISTRY_KEY = - "R.loading.local.registry"; //NOI18N - private static final String ERROR_LOADING_LOCAL_REGISTRY_TITLE_KEY = - "R.error.loading.local.registry.failed.title";//NOI18N - private static final String ERROR_LOADING_LOCAL_REGISTRY_MESSAGE_KEY = - "R.error.loading.local.registry.failed.msg";//NOI18N - - private static final String LOADING_BUNDLED_REGISTRY_KEY = - "R.loading.bundled.registry"; //NOI18N - private static final String ERROR_LOADING_BUNDLED_REGISTRY_TITLE_KEY = - "R.error.loading.bundled.registry.failed.title";//NOI18N - private static final String ERROR_LOADING_BUNDLED_REGISTRY_MESSAGE_KEY = - "R.error.loading.bundled.registry.failed.msg";//NOI18N - - private static final String LOADING_REMOTE_REGISTRY_KEY = - "R.loading.remote.registry"; //NOI18N - private static final String ERROR_LOADING_REMOTE_REGISTRY_TITLE_KEY = - "R.error.loading.remote.registry.failed.title";//NOI18N - private static final String ERROR_LOADING_REMOTE_REGISTRY_MESSAGE_KEY = - "R.error.loading.remote.registry.failed.msg"; //NOI18N - private static final String ERROR_CANNOT_DELETE_DATA_KEY = - "R.error.cannot.delete.data"; //NOI18N - private static final String SAVE_LOCAL_REGISTRY_TITLE_KEY = - "R.save.local.registry.title";//NOI18N - private static final String SAVE_LOCAL_REGISTRY_DETAIL_KEY = - "R.save.local.registry.detail"; //NOI18N - private static final String ERROR_MISSING_TARGET_COMPONENT_TITLE_KEY = - "R.error.missing.target.component.title"; //NOI18N - private static final String ERROR_MISSING_TARGET_COMPONENT_MSG_KEY = - "R.error.missing.target.component.msg"; //NOI18N - private static final String ERROR_VALIDATION_TITLE_KEY = - "R.error.validation.title";//NOI18N - private static final String ERROR_VALIDATION_MSG_KEY = - "R.error.validation.msg";//NOI18N - private static final String ERROR_REQUIREMENT_KEY = - "R.error.matching.requirement";//NOI18N - private static final String ERROR_CYCLIC_DEPENDENCY_KEY = - "R.error.cyclic.dependency";//NOI18N - private static final String LOADING_REGISTRY_PROPERTIES_KEY = - "R.loading.registry.properties";//NOI18N - private static final String LOADING_COMPONENT_KEY = - "R.loading.component";//NOI18N - private static final String ERROR_LOADING_COMPONENTS = - "R.error.loading.components";//NOI18N - private static final String ERROR_REGISTRY_FINALIZATION = - "R.error.registry.finalization";//NOI18N - private static final String ERROR_REGISTRY_DOCUMENT_LOADING = - "R.error.registry.document.loading";//NOI18N - private static final String ERROR_CANNOT_CREATE_CACHE_DIR_KEY = - "R.error.cannot.create.cache.directory";//NOI18N - private static final String ERROR_CACHE_IS_FILE_KEY = - "R.error.cache.is.file";//NOI18N - private static final String ERROR_CANNOT_READ_CACHE_KEY = - "R.error.cannot.read.cache";//NOI18N - private static final String ERROR_CANNOT_WRITE_CACHE_KEY = - "R.error.cannot.write.cache";//NOI18N - private static final String ERROR_CANNOT_CREATE_REGISTRY_KEY = - "R.error.cannot.create.registry";//NOI18N - private static final String ERROR_REGISTRY_IS_DIRECTORY_KEY = - "R.error.registry.is.dir";//NOI18N - private static final String ERROR_CANNOT_WRITE_REGISTRY_KEY = - "R.error.cannot.write.registry";//NOI18N - private static final String ERROR_CANNOT_PARSE_PLATFORM_KEY = - "R.error.cannot.parse.platform";//NOI18N - private static final String ERROR_CANNOT_LOAD_REGISTRY_KEY = - "R.error.cannot.load.registry";//NOI18N - private static final String ERROR_PARSER_DO_NOT_CUPPORT_SCHEMAS_KEY = - "R.error.parser.not.support.schemas";//NOI18N - private static final String ERROR_UNKNOWN_DEPENDENCY_KEY = - "R.error.unknown.dependency";//NOI18N - private static final String REGISTRY_INITIALIZATION_FAILED_PROPERTY = - "R.registry.initialization.failed"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/product/RegistryNode.java b/nbi/engine/src/org/netbeans/installer/product/RegistryNode.java deleted file mode 100644 index b47e43cd8399..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/RegistryNode.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product; - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.tree.TreePath; -import org.netbeans.installer.product.filters.RegistryFilter; -import org.netbeans.installer.product.filters.TrueFilter; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.ExtendedUri; -import org.netbeans.installer.utils.helper.NbiProperties; -import org.netbeans.installer.utils.helper.PropertyContainer; -import org.netbeans.installer.utils.helper.UiMode; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * - * @author Kirill Sorokin - */ -public abstract class RegistryNode implements PropertyContainer { - protected RegistryNode parent; - - protected RegistryType registryType; - - protected String uid; - - protected ExtendedUri iconUri; - protected Icon icon; - - protected long offset; - protected boolean expand; - protected boolean initialVisible; - protected boolean currentVisible; - - protected Date built; - - protected Map displayNames; - protected Map descriptions; - - protected List children; - - protected NbiProperties properties; - - protected RegistryNode() { - initialVisible = true; - currentVisible = true; - built = new Date(); - - displayNames = new HashMap(); - descriptions = new HashMap(); - - children = new ArrayList(); - - properties = new NbiProperties(); - } - - public String getUid() { - return uid; - } - - public String getDisplayName() { - return getDisplayName(Locale.getDefault()); - } - - public String getDisplayName(final Locale locale) { - return StringUtils.getLocalizedString(displayNames,locale); - } - - public Map getDisplayNames() { - return displayNames; - } - - public void setDisplayName(final String displayName) { - setDisplayName(Locale.getDefault(), displayName); - } - - public void setDisplayName(final Locale locale, final String displayName) { - displayNames.put(locale, displayName); - } - - public String getDescription() { - return getDescription(Locale.getDefault()); - } - - public String getDescription(final Locale locale) { - return StringUtils.getLocalizedString(descriptions,locale); - } - - public Map getDescriptions() { - return descriptions; - } - - public void setDescription(final String description) { - setDescription(Locale.getDefault(), description); - } - - public void setDescription(final Locale locale, final String description) { - descriptions.put(locale, description); - } - - public ExtendedUri getIconUri() { - return iconUri; - } - - public Icon getIcon() { - if (icon==null && UiMode.getCurrentUiMode() != UiMode.SILENT) { - if(getIconUri()!=null && getIconUri().getLocal()!=null) { - icon = new ImageIcon(getIconUri().getLocal().getPath()); - } - } - return icon; - } - - public long getOffset() { - return offset; - } - - public boolean isVisible() { - return currentVisible; - } - - public void setVisible(final boolean visible) { - this.currentVisible = visible; - } - - public boolean getExpand() { - return expand; - } - - public Date getBuildDate() { - return built; - } - - public RegistryType getRegistryType() { - return registryType; - } - - public void setRegistryType(final RegistryType registryType) { - this.registryType = registryType; - } - - // tree ///////////////////////////////////////////////////////////////////////// - public RegistryNode getParent() { - return parent; - } - - public void setParent(final RegistryNode parent) { - this.parent = parent; - } - - public List getChildren() { - return children; - } - - public List getVisibleChildren() { - List visibleChildren = new LinkedList(); - - for (RegistryNode child: children) { - if (child.isVisible()) { - visibleChildren.add(child); - } - } - - return visibleChildren; - } - - public void addChild(final RegistryNode child) { - child.setParent(this); - - int i; - for (i = 0; i < children.size(); i++) { - if (children.get(i).getOffset() > child.getOffset()) { - break; - } - } - children.add(i, child); - } - - public void removeChild(final RegistryNode child) { - children.remove(child); - } - - public void attachRegistry(Registry registry) { - for (RegistryNode node: registry.getRegistryRoot().getChildren()) { - addChild(node); - } - } - - public boolean isAncestor(final RegistryNode candidate) { - for (RegistryNode node: getChildren()) { - if ((node == candidate) || node.isAncestor(candidate)) { - return true; - } - } - - return false; - } - - public boolean isAncestor(final List candidates) { - for (RegistryNode node: candidates) { - if (isAncestor(node)) { - return true; - } - } - - return false; - } - - public boolean hasChildren() { - return hasChildren(new TrueFilter()); - } - - public boolean hasChildren(RegistryFilter filter) { - for (RegistryNode child: children) { - if (filter.accept(child)) { - return true; - } - - if (child.hasChildren(filter)) { - return true; - } - } - - return false; - } - - public TreePath getTreePath() { - List nodes = new LinkedList(); - - RegistryNode node = this; - while (node != null) { - nodes.add(0, node); - node = node.getParent(); - } - - return new TreePath(nodes.toArray()); - } - - // properties /////////////////////////////////////////////////////////////////// - public Properties getProperties() { - return properties; - } - - public String getProperty(final String name) { - return properties.getProperty(name); - } - - public void setProperty(final String name, final String value) { - properties.setProperty(name, value); - } - - // node <-> dom ///////////////////////////////////////////////////////////////// - public Element saveToDom(Document document, RegistryFilter filter) throws FinalizationException { - final boolean hasChilren = hasChildren(filter); - - if (filter.accept(this) || hasChilren) { - Element element = saveToDom(document.createElement(getTagName())); - - if (hasChilren) { - element.appendChild(saveChildrenToDom(document, filter)); - } - - return element; - } else { - return null; - } - } - - public Element saveChildrenToDom(Document document, RegistryFilter filter) throws FinalizationException { - Element components = null; - - if (hasChildren(filter)) { - components = document.createElement("components"); - - for (RegistryNode child: children) { - if (filter.accept(child) || child.hasChildren(filter)) { - components.appendChild(child.saveToDom(document, filter)); - } - } - } - - return components; - } - - protected String getTagName() { - return "node"; - } - - protected Element saveToDom( - final Element element) throws FinalizationException { - Document document = element.getOwnerDocument(); - - element.setAttribute("uid", uid); - element.setAttribute("offset", Long.toString(offset)); - element.setAttribute("expand", Boolean.toString(expand)); - element.setAttribute("visible", Boolean.toString(initialVisible)); - - element.setAttribute("built", Long.toString(built.getTime())); - - element.appendChild(XMLUtils.saveLocalizedString( - displayNames, - document.createElement("display-name"))); - - element.appendChild(XMLUtils.saveLocalizedString( - descriptions, - document.createElement("description"))); - - element.appendChild(XMLUtils.saveExtendedUri( - iconUri, - document.createElement("icon"))); - - if (properties.size() > 0) { - element.appendChild(XMLUtils.saveNbiProperties( - properties, - document.createElement("properties"))); - } - - return element; - } - - public RegistryNode loadFromDom( - final Element element) throws InitializationException { - try { - uid = element.getAttribute("uid"); - - iconUri = XMLUtils.parseExtendedUri( - XMLUtils.getChild(element, "icon")); - - if (!Boolean.getBoolean(Registry.LAZY_LOAD_ICONS_PROPERTY)) { - final File iconFile = - FileProxy.getInstance().getFile(iconUri.getRemote()); - iconUri.setLocal(iconFile.toURI()); - } - - offset = Long.parseLong(element.getAttribute("offset")); - currentVisible = - initialVisible = - Boolean.parseBoolean(element.getAttribute("visible")); - expand = Boolean.parseBoolean(element.getAttribute("expand")); - - built = new Date(Long.parseLong(element.getAttribute("built"))); - - displayNames = XMLUtils.parseLocalizedString( - XMLUtils.getChild(element, "display-name")); - - descriptions = XMLUtils.parseLocalizedString( - XMLUtils.getChild(element, "description")); - - properties = XMLUtils.parseNbiProperties( - XMLUtils.getChild(element, "properties")); - } catch (ParseException e) { - throw new InitializationException("Cannot deserialize product tree node", e); - } catch (DownloadException e) { - throw new InitializationException("Cannot deserialize product tree node", e); - } catch (NumberFormatException e) { - throw new InitializationException("Cannot deserialize product tree node", e); - } - - return this; - } - - // node -> string /////////////////////////////////////////////////////////////// - @Override - public String toString() { - return getDisplayName(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/RegistryType.java b/nbi/engine/src/org/netbeans/installer/product/RegistryType.java deleted file mode 100644 index 05c25b3a88b2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/RegistryType.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product; - -/** - * - * @author Kirill Sorokin - */ -public enum RegistryType { - LOCAL, - REMOTE, - BUNDLED; -} diff --git a/nbi/engine/src/org/netbeans/installer/product/components/Bundle.properties b/nbi/engine/src/org/netbeans/installer/product/components/Bundle.properties deleted file mode 100644 index 7ba906a0a6dc..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/components/Bundle.properties +++ /dev/null @@ -1,58 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -################################################################################ -# ProductConfigurationLogic.java -PCL.validation.directory.missing=The installation directory {0} is missing.\nMost likely it was deleted manually. -PCL.validation.directory.file=The installation directory {0} is in fact a file.\nMost likely it was previously deleted manually and overwritten with a file. -PCL.validation.directory.empty=The installation directory {0} is empty.\nMost likely its contents were deleted manually. -PCL.validation.directory.null=The installation directory cannot be detected. - -################################################################################ -# Product.java -P.error.cannot.initialize.product=Cannot initialize data for {0} -P.error.cannot.load.logic=Cannot load configuration logic for {0} -P.error.installdir.not.set=Installation location is not set for {0} -P.error.installdir.set.empty=Installation location is set to empty string for {0} -P.error.cannot.create.cache.dir=Cannot create the local cache directory {0} for {1} -P.error.local.cache.not.dir=The local cache directory {0} for {1} is not a directory -P.error.cannot.load.product=Could not load product {0} -P.error.logic.not.yet.downloaded=Configuration logic for {0} is not yet downloaded -P.error.installation.data.not.cached=Installation data is not cached for {0} -P.error.cannot.extract.data=Cannot extract installation data for {0} -P.error.cannot.save.files.list=Cannot save installed files list -P.error.cannot.get.wizard.components=Cannot get component's wizard components -P.error.cannot.wrap.for.macos=Cannot create directory hierarchy for MacOS Application -P.error.cannot.get.files.list=Cannot get the installation files list -P.error.cannot.delete.files.list=Cannot delete installed files list -P.error.cannot.delete.file=Cannot delete the file -P.error.cannot.remove.from.system=Cannot remove {0} from the system install manager -P.error.not.enough.space=Cannot extract installation data -- not enough disk space in the target directory. -P.error.cannot.clear.cache=Cannot clear installation data cache file {0} -P.error.system.integartion.failed=Integration of {0} with the system package manager failed - -P.message.installation=Installing {0} -P.message.uninstallation=Uninstalling {0} -P.message.configuration=Configuring {0} -P.message.unconfiguration=Unconfiguring {0} -P.message.legal.artifacts=Creating legal artifacts -P.message.run.logic=Running custom configuration logic -P.message.system.registration=Registering in the system package manager -P.message.save.installation.files.list=Saving installed files list -P.message.delete=Deleting {0} diff --git a/nbi/engine/src/org/netbeans/installer/product/components/Group.java b/nbi/engine/src/org/netbeans/installer/product/components/Group.java deleted file mode 100644 index 263c6d5f2710..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/components/Group.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.components; - -import java.util.Locale; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.StringUtils; -import org.w3c.dom.Element; -import org.netbeans.installer.utils.helper.Status; - -/** - * - * @author Kirill Sorokin - * @author Yulia Novozhilova - */ -public class Group extends RegistryNode implements StatusInterface { - private Status currentStatus; - - public Group() { - uid = StringUtils.EMPTY_STRING; - displayNames.put(new Locale(StringUtils.EMPTY_STRING), "Product Tree Root"); - descriptions.put(new Locale(StringUtils.EMPTY_STRING), StringUtils.EMPTY_STRING); - } - - public boolean isEmpty() { - for (RegistryNode node: getVisibleChildren()) { - if (node instanceof Group) { - if (!((Group) node).isEmpty()) { - return false; - } - } else { - return false; - } - } - - return true; - } - - // node <-> dom ///////////////////////////////////////////////////////////////// - protected String getTagName() { - return "group"; - } - - public Group loadFromDom(Element element) throws InitializationException { - super.loadFromDom(element); - - return this; - } - - public Status getStatus() { - if(currentStatus == null && !isEmpty()) { - final List statuses = new ArrayList(); - for (RegistryNode node: getVisibleChildren()) { - if (node instanceof Group) { - statuses.add(((Group)node).getStatus()); - } - if (node instanceof Product) { - statuses.add(((Product)node).getStatus()); - } - } - //todo - currentStatus = statuses.contains(Status.TO_BE_INSTALLED) || - statuses.contains(Status.NOT_INSTALLED)? - Status.TO_BE_INSTALLED : Status.INSTALLED; - } - return currentStatus; - } - - public void setStatus(final Status status) { - currentStatus = status; - - for (RegistryNode node: getVisibleChildren()) { - if(node instanceof StatusInterface && - ((StatusInterface)node).getStatus()!= Status.INSTALLED) { - ((StatusInterface)node).setStatus(status); - } - } - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/product/components/Product.java b/nbi/engine/src/org/netbeans/installer/product/components/Product.java deleted file mode 100644 index 28663dcc08f8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/components/Product.java +++ /dev/null @@ -1,1276 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.components; - -import org.netbeans.installer.utils.cli.options.ForceUninstallOption; -import org.netbeans.installer.utils.cli.options.TargetOption; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.dependencies.Conflict; -import org.netbeans.installer.product.dependencies.InstallAfter; -import org.netbeans.installer.product.dependencies.Requirement; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.helper.DependencyType; -import org.netbeans.installer.utils.helper.DetailedStatus; -import org.netbeans.installer.utils.helper.RemovalMode; -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.FileEntry; -import org.netbeans.installer.utils.helper.FilesList; -import org.netbeans.installer.utils.helper.NbiClassLoader; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.exceptions.UninstallationException; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.ApplicationDescriptor; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.helper.ExtendedUri; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Text; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.UnixNativeUtils; -import org.netbeans.installer.wizard.components.WizardComponent; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * - * @author Kirill Sorokin - */ -public final class Product extends RegistryNode implements StatusInterface { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private Version version; - private List supportedPlatforms; - - private Status initialStatus; - private Status currentStatus; - private boolean reinstallationForced; - - private List logicUris; - private List dataUris; - - private List features; - - private long requiredDiskSpace; - - private List dependencies; - - private NbiClassLoader classLoader; - private ProductConfigurationLogic configurationLogic; - - private Throwable installationError; - private List installationWarnings; - - private Throwable uninstallationError; - private List uninstallationWarnings; - - private FilesList installedFiles; - - private InstallationPhase installationPhase; - - // constructor ////////////////////////////////////////////////////////////////// - public Product() { - supportedPlatforms = new ArrayList(); - logicUris = new ArrayList(); - dataUris = new ArrayList(); - dependencies = new ArrayList(); - } - - // essential functionality ////////////////////////////////////////////////////// - public void install(final Progress progress) throws InstallationException { - LogManager.logIndent("Start installation of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - final CompositeProgress totalProgress = new CompositeProgress(); - final CompositeProgress unjarProgress = new CompositeProgress(); - final Progress logicProgress = new Progress(); - - // initialization phase //////////////////////////////////////////////// - installationPhase = InstallationPhase.INITIALIZATION; - - // load the component's configuration logic (it should be already - // there, but we need to be sure) - try { - getLogic(); - } catch (InitializationException e) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_INITIALIZE_PRODUCT_KEY, getDisplayName()), e); - } - - totalProgress.addChild( - unjarProgress, - Progress.COMPLETE - configurationLogic.getLogicPercentage()); - totalProgress.addChild( - logicProgress, - configurationLogic.getLogicPercentage()); - totalProgress.synchronizeTo(progress); - totalProgress.synchronizeDetails(true); - - // check whether the installation location was set, if it's not we - // cannot continue - if (getInstallationLocation() == null) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_INSTALLATION_LOCATION_NOT_SET_KEY, - getDisplayName())); - } else if (getInstallationLocation().equals( - new File(StringUtils.EMPTY_STRING))) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_INSTALLATION_LOCATION_SET_EMPTY_KEY, - getDisplayName())); - } - - // initialize the local cache directory - final File cache = getLocalCache(); - if (!cache.exists()) { - if (!cache.mkdirs()) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_CREATE_PRODUCT_CACHE_DIR_KEY, cache, getDisplayName())); - } - } else if (!cache.isDirectory()) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CACHE_NOT_DIRECTORY_KEY, cache, getDisplayName())); - } - - // initialize the files list - installedFiles = new FilesList(); - - // check for cancel status - if (progress.isCanceled()) return; - - // extraction phase ///////////////////////////////////////////////////////// - installationPhase = InstallationPhase.EXTRACTION; - - totalProgress.setTitle(StringUtils.format( - MESSAGE_INSTALLATION_STRING, getDisplayName())); - - final File contentsDir = new File(getInstallationLocation(), "Contents"); - final File macosDir = new File(contentsDir, "MacOS"); - final File resourcesDir = new File(contentsDir, "Resources"); - final File infoplist = new File(contentsDir, "Info.plist"); - final File ds_store = new File(getInstallationLocation().getParentFile(), ".DS_Store"); - - // if we're running on macos x and the configuraion logic tells us that the - // product should be automatically wrapped, we first create the required - // directories structure and then extract the product - if (SystemUtils.isMacOS() && configurationLogic.wrapForMacOs()) { - setProperty(APPLICATION_LOCATION_PROPERTY, - getInstallationLocation().getAbsolutePath()); - setInstallationLocation(new File(resourcesDir, - getInstallationLocation().getName().replaceAll("\\.app$", - StringUtils.EMPTY_STRING))); - - final UnixNativeUtils utils = - (UnixNativeUtils) SystemUtils.getNativeUtils(); - - try { - installedFiles.add(FileUtils.mkdirs(contentsDir)); - installedFiles.add(FileUtils.mkdirs(resourcesDir)); - installedFiles.add(FileUtils.mkdirs(macosDir)); - - final String executableName = "executable"; //NOI18N - - installedFiles.add(utils.createSymLink( - new File(macosDir, executableName), - new File(getInstallationLocation(), configurationLogic.getExecutable()))); - - final String iconName = "icon.icns"; //NOI18N - - if(configurationLogic.getIcon() != null) { - installedFiles.add(utils.createSymLink( - new File(resourcesDir, iconName), - new File(getInstallationLocation(), configurationLogic.getIcon()))); - } - - installedFiles.add(FileUtils.writeFile(infoplist, StringUtils.format( - INFO_PLIST_STUB, - getDisplayName(), - getVersion().toString(), - getVersion().toMinor(), - executableName, - iconName))); - - //Fix #172000: NetBeans folder stay at Applications after uninstallation - //installedFiles.add(ds_store); - - } catch (IOException e) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_WRAP_FOR_MACOS_KEY), e); - } - } - - // check for cancel status - if (progress.isCanceled()) return; - - if(dataUris.size()>0) { - LogManager.log("... extracting files from the data archives"); - // extract each of the defined installation data files - unjarProgress.setPercentage(Progress.COMPLETE % dataUris.size()); - unjarProgress.synchronizeDetails(true); - for (ExtendedUri uri: dataUris) { - final Progress currentProgress = new Progress(); - unjarProgress.addChild( - currentProgress, - Progress.COMPLETE / dataUris.size()); - - // get the uri of the current data file - final URI dataUri = uri.getLocal(); - if (dataUri == null) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_DATA_NOT_CACHED_KEY, getDisplayName())); - } - - // convert it to a file and do some additional checks - final File dataFile = new File(uri.getLocal()); - if (!dataFile.exists()) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_DATA_NOT_CACHED_KEY, getDisplayName())); - } - - // exract it and add the files to the installed files list - try { - installedFiles.add(FileUtils.unjar( - dataFile, - getInstallationLocation(), - currentProgress)); - } catch (IOException e) { - if (e.getMessage().equals("Not enough space")) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_NOT_ENOUGH_SPACE_KEY), e); - } - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_EXTRACT_DATA_KEY, - getDisplayName()), - e); - } catch (XMLException e) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_EXTRACT_DATA_KEY, - getDisplayName()), - e); - } - - // finally remove the data file - try { - FileProxy.getInstance().deleteFile(uri); - } catch (IOException e) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_CLEAR_DATA_CACHE_KEY, - dataFile), - e); - } - // check for cancel status - if (progress.isCanceled()) break; - } - } else { - LogManager.log("... no data archives assigned to this product"); - unjarProgress.setPercentage(Progress.COMPLETE); - } - - LogManager.log("... saving legal artifacts if required"); - // create legal/docs artifacts - progress.setDetail(StringUtils.format(MESSAGE_LEGAL_ARTIFACTS_STRING)); - try { - saveLegalArtifacts(); - } catch (IOException e) { - addInstallationWarning(e); - } - - // check for cancel status - if (progress.isCanceled()) return; - - // custom configuration phase /////////////////////////////////////////////// - installationPhase = InstallationPhase.CUSTOM_LOGIC; - - totalProgress.setTitle(StringUtils.format( - MESSAGE_CONFIGURATION_STRING, getDisplayName())); - - // run custom configuration logic - progress.setDetail(StringUtils.format(MESSAGE_RUN_LOGIC_STRING)); - - LogManager.log("... running installation logic"); - configurationLogic.install(logicProgress); - logicProgress.setPercentage(Progress.COMPLETE); - progress.setDetail(StringUtils.EMPTY_STRING); - - // check for cancel status - if (progress.isCanceled()) return; - - // finalization phase /////////////////////////////////////////////////////// - installationPhase = InstallationPhase.FINALIZATION; - LogManager.log("... register in system, create uninstaller, etc"); - // register the component in the system install manager - if (configurationLogic.registerInSystem()) { - try { - progress.setDetail(StringUtils.format(MESSAGE_SYSTEM_REGISTRATION_STRING)); - installedFiles.add(SystemUtils.addComponentToSystemInstallManager(getApplicationDescriptor())); - } catch (NativeException e) { - throw new InstallationException(ResourceUtils.getString(Product.class, - ERROR_SYSTEM_INTEGRATION_FAILER_KEY, - getDisplayName()),e); - } catch (IOException e) { - throw new InstallationException(ResourceUtils.getString(Product.class, - ERROR_SYSTEM_INTEGRATION_FAILER_KEY, - getDisplayName()),e); - } - } - LogManager.log("... save installation files list"); - // save the installed files list - progress.setDetail(StringUtils.format(MESSAGE_SAVE_INSTALL_FILES_LIST_STRING)); - try { - installedFiles.saveXmlGz(getInstalledFilesList()); - } catch (XMLException e) { - throw new InstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_SAVE_FILES_LIST_KEY), e); - } - - installationPhase = InstallationPhase.COMPLETE; - progress.setPercentage(Progress.COMPLETE); - progress.setDetail(StringUtils.EMPTY_STRING); - setStatus(Status.INSTALLED); - LogManager.logUnindent("... finished installation of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - } - - public void rollback(final Progress progress) throws UninstallationException { - final CompositeProgress totalProgress = new CompositeProgress(); - final Progress logicProgress = new Progress(); - final Progress eraseProgress = new Progress(); - LogManager.logIndent("Start rollback of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - // initialization /////////////////////////////////////////////////////////// - - // load the component's configuration logic (it should be already - // there, but we need to be sure) - try { - getLogic(); - } catch (InitializationException e) { - throw new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_INITIALIZE_PRODUCT_KEY, getDisplayName()), e); - } - - int logicChunk = (int) (progress.getPercentage() * ( - (float) configurationLogic.getLogicPercentage() / - (float) Progress.COMPLETE)); - int eraseChunk = (int) (progress.getPercentage() * (1. - ( - (float) configurationLogic.getLogicPercentage() / - (float) Progress.COMPLETE))); - - totalProgress.setPercentage(Progress.COMPLETE - logicChunk - eraseChunk); - totalProgress.addChild(logicProgress, logicChunk); - totalProgress.addChild(eraseProgress, eraseChunk); - totalProgress.synchronizeDetails(true); - totalProgress.reverseSynchronizeTo(progress); - - // rollback ///////////////////////////////////////////////////////////////// - - // the starting point is chosen depending on the stage at which the - // installation process was canceled, or failed; note that we intentionally - // fall through all these cases, as they should be executed exactly in this - // order and the only unclear point is where to start - switch (installationPhase) { - case COMPLETE: - case FINALIZATION: - LogManager.log("... deleting installed files files"); - try { - FileUtils.deleteFile(getInstalledFilesList()); - } catch (IOException e) { - ErrorManager.notifyWarning(ResourceUtils.getString(Product.class, - ERROR_CANNOT_DELETE_FILES_LIST_KEY), e); - } - - if (configurationLogic.registerInSystem()) { - LogManager.log("... removing system integration"); - try { - SystemUtils.removeComponentFromSystemInstallManager(getApplicationDescriptor()); - } catch (NativeException e) { - ErrorManager.notifyWarning( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_REMOVE_FROM_SYSTEM_KEY, getDisplayName()), e); - } - } - - case CUSTOM_LOGIC: - LogManager.log("... running uninstallation logic"); - configurationLogic.uninstall(logicProgress); - - case EXTRACTION: - logicProgress.setPercentage(Progress.COMPLETE); - LogManager.log("... deleting installed files"); - // remove installation files - int total = installedFiles.getSize(); - int current = 0; - - for (FileEntry entry: installedFiles) { - current++; - - File file = entry.getFile(); - - eraseProgress.setDetail(StringUtils.format(MESSAGE_DELETE_STRING, file)); - eraseProgress.setPercentage(Progress.COMPLETE * current / total); - - try { - FileUtils.deleteFile(file); - } catch (IOException e) { - ErrorManager.notifyWarning( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_DELETE_FILE_KEY), e); - } - } - - case INITIALIZATION: - eraseProgress.setPercentage(Progress.COMPLETE); - // for initialization we don't need to do anything - - default: - // default, nothing should be done here - } - setStatus(Status.NOT_INSTALLED); - LogManager.logUnindent("... finished rollbacking of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - } - - public void uninstall(final Progress progress) throws UninstallationException { - LogManager.logIndent("Start uninstallation of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - final CompositeProgress totalProgress = new CompositeProgress(); - final Progress logicProgress = new Progress(); - final Progress eraseProgress = new Progress(); - - // initialization phase ///////////////////////////////////////////////////// - - // load the component's configuration logic (it should be already - // there, but we need to be sure) - try { - getLogic(); - } catch (InitializationException e) { - throw new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_INITIALIZE_PRODUCT_KEY, getDisplayName()), e); - } - - totalProgress.addChild( - logicProgress, - configurationLogic.getLogicPercentage()); - totalProgress.addChild( - eraseProgress, - Progress.COMPLETE - configurationLogic.getLogicPercentage()); - totalProgress.synchronizeTo(progress); - totalProgress.synchronizeDetails(true); - - // load the installed files list - try { - installedFiles = new FilesList().loadXmlGz(getInstalledFilesList()); - } catch (XMLException e) { - throw new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_GET_FILES_LIST_KEY), e); - } - - // custom logic phase /////////////////////////////////////////////////////// - progress.setTitle(StringUtils.format( - MESSAGE_UNCONFIGURATION_STRING, getDisplayName())); - - // run custom unconfiguration logic - LogManager.log("... running uninstallation logic"); - configurationLogic.uninstall(logicProgress); - logicProgress.setPercentage(Progress.COMPLETE); - progress.setDetail(StringUtils.EMPTY_STRING); - - // files deletion phase ///////////////////////////////////////////////////// - progress.setTitle(StringUtils.format( - MESSAGE_UNINSTALLATION_STRING, getDisplayName())); - - // remove installation files - LogManager.log("... removing installation files"); - if (configurationLogic.getRemovalMode() == RemovalMode.ALL) { - try { - File startPoint = getInstallationLocation(); - if(SystemUtils.isMacOS() && configurationLogic.wrapForMacOs()) { - startPoint = startPoint. - getParentFile(). - getParentFile(). - getParentFile(); - } - FileUtils.deleteFile(startPoint, true, eraseProgress); - } catch (IOException e) { - addUninstallationWarning(new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_DELETE_FILE_KEY), - e)); - } - } else { - try { - FileUtils.deleteFiles(installedFiles, eraseProgress); - } catch (IOException e) { - addUninstallationWarning(new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_DELETE_FILE_KEY), - e)); - } - } - LogManager.log("... removing the system integration"); - // remove the component from the native install manager - if (configurationLogic.registerInSystem()) { - try { - SystemUtils.removeComponentFromSystemInstallManager(getApplicationDescriptor()); - } catch (NativeException e) { - addUninstallationWarning(new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_REMOVE_FROM_SYSTEM_KEY, - getDisplayName()), e)); - } - } - LogManager.log("... removing installation files list"); - progress.setDetail(StringUtils.EMPTY_STRING); - // remove the files list - try { - FileUtils.deleteFile(getInstalledFilesList()); - } catch (IOException e) { - addUninstallationWarning(new UninstallationException( - ResourceUtils.getString(Product.class, - ERROR_CANNOT_DELETE_FILES_LIST_KEY), e)); - } - - progress.setPercentage(Progress.COMPLETE); - setStatus(Status.NOT_INSTALLED); - LogManager.logUnindent("...finished uninstallation of " + getDisplayName() + "(" + getUid() + "/" + getVersion()+")"); - } - - // configuration logic ////////////////////////////////////////////////////////// - public List getLogicUris() { - return logicUris; - } - - public void downloadLogic(final Progress progress) throws DownloadException { - final CompositeProgress overallProgress = new CompositeProgress(); - - final int percentageChunk = Progress.COMPLETE / logicUris.size(); - final int percentageLeak = Progress.COMPLETE % logicUris.size(); - - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeTo(progress); - overallProgress.synchronizeDetails(true); - - for (ExtendedUri uri: logicUris) { - final Progress currentProgress = new Progress(); - overallProgress.addChild(currentProgress, percentageChunk); - - final File cache = FileProxy.getInstance().getFile( - uri.getRemote(), - currentProgress); - uri.setLocal(cache.toURI()); - } - } - - public boolean isLogicDownloaded() { - for (ExtendedUri uri: logicUris) { - if (uri.getLocal() == null) { - return false; - } - } - - return true; - } - - public ProductConfigurationLogic getLogic() throws InitializationException { - if (configurationLogic != null) { - return configurationLogic; - } - - if (!isLogicDownloaded()) { - throw new InitializationException( - ResourceUtils.getString(Product.class, - ERROR_LOGIC_NOT_YET_DOWNLOADED_KEY, getDisplayName())); - } - - try { - String classname = null; - for (ExtendedUri uri: logicUris) { - classname = FileUtils.getJarAttribute( - new File(uri.getLocal()), - MANIFEST_LOGIC_CLASS); - - if (classname != null) { - break; - } - } - - classLoader = new NbiClassLoader(logicUris); - - configurationLogic = (ProductConfigurationLogic) classLoader. - loadClass(classname).newInstance(); - configurationLogic.setProduct(this); - - return configurationLogic; - } catch (IOException e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } catch (ClassNotFoundException e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } catch (InstantiationException e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } catch (IllegalAccessException e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } catch (NoClassDefFoundError e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } catch (UnsupportedClassVersionError e) { - throw new InitializationException(ResourceUtils.getString(Product.class, - ERROR_CANNOT_LOAD_LOGIC_KEY, getDisplayName()), e); - } - } - - // installation data //////////////////////////////////////////////////////////// - public List getDataUris() { - return dataUris; - } - - public void downloadData(final Progress progress) throws DownloadException { - final CompositeProgress overallProgress = new CompositeProgress(); - if (dataUris.size() > 0) { - final int percentageChunk = Progress.COMPLETE / dataUris.size(); - final int percentageLeak = Progress.COMPLETE % dataUris.size(); - - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeTo(progress); - overallProgress.synchronizeDetails(true); - - for (ExtendedUri uri : dataUris) { - final Progress currentProgress = new Progress(); - overallProgress.addChild(currentProgress, percentageChunk); - - final File cache = FileProxy.getInstance().getFile( - uri.getRemote(), - currentProgress); - uri.setLocal(cache.toURI()); - if (progress.isCanceled()) return; - } - } else { - overallProgress.setPercentage(Progress.COMPLETE); - overallProgress.synchronizeTo(progress); - } - } - - public boolean isDataDownloaded() { - for (ExtendedUri uri: dataUris) { - if (uri.getLocal() == null) { - return false; - } - } - - return true; - } - - // wizard /////////////////////////////////////////////////////////////////////// - public List getWizardComponents() { - try { - return getLogic().getWizardComponents(); - } catch (InitializationException e) { - ErrorManager.notifyError(ResourceUtils.getString( - Product.class, ERROR_CANNOT_GET_WIZARD_COMPONENTS_KEY), e); - } - - return null; - } - - // status /////////////////////////////////////////////////////////////////////// - public Status getStatus() { - return currentStatus; - } - - public void setStatus(final Status status) { - if (initialStatus == null) { - initialStatus = status; - } - - currentStatus = status; - - if (initialStatus == Status.INSTALLED && - currentStatus == Status.TO_BE_INSTALLED) { - reinstallationForced = true; - } - - } - - public boolean hasStatusChanged() { - return currentStatus != initialStatus; - } - - public DetailedStatus getDetailedStatus() { - if (getStatus() == Status.INSTALLED) { - if (getUninstallationError() != null) { - return DetailedStatus.FAILED_TO_UNINSTALL; - } - if ((hasStatusChanged() || reinstallationForced) - && (getInstallationWarnings() != null)) { - return DetailedStatus.INSTALLED_WITH_WARNINGS; - } - if (hasStatusChanged() || reinstallationForced) { - return DetailedStatus.INSTALLED_SUCCESSFULLY; - } - } - - if (getStatus() == Status.NOT_INSTALLED) { - if (getInstallationError() != null) { - return DetailedStatus.FAILED_TO_INSTALL; - } - if (hasStatusChanged() && (getUninstallationWarnings() != null)) { - return DetailedStatus.UNINSTALLED_WITH_WARNINGS; - } - if (hasStatusChanged()) { - return DetailedStatus.UNINSTALLED_SUCCESSFULLY; - } - } - - return null; - } - - // dependencies ///////////////////////////////////////////////////////////////// - public List getDependencies() { - return dependencies; - } - @Deprecated - public List getDependencies(final DependencyType ... types) { - Class [] classes = new Class[types.length]; - for(int i=0;i toDependencyClass(DependencyType type) { - switch (type) { - case REQUIREMENT: - return Requirement.class; - case CONFLICT : - return Conflict.class; - case INSTALL_AFTER: - return InstallAfter.class; - default : - return null; - } - } - - public List getDependencies(Class ... dependencyClasses) { - final List filtered = new ArrayList(); - - for (Dependency dependency: dependencies) { - for (Class clazz: dependencyClasses) { - //if (clazz.isInstance(dependency)) { - if (clazz.isInstance(dependency)) { - filtered.add(dependency); - break; - } - } - } - - return filtered; - } - - public boolean satisfies(final Dependency dependency) { - return dependency.satisfies(this); - } - - public List getDependencyByUid(String dependentUid) { - final List filtered = new ArrayList(); - - for (Dependency dependency: dependencies) { - if (dependency.getUid().equals(dependentUid)) { - filtered.add(dependency); - } - } - - return filtered; - } - - // system requirements ////////////////////////////////////////////////////////// - public long getRequiredDiskSpace() { - return requiredDiskSpace; - } - - // install-time error/warnings ////////////////////////////////////////////////// - public Throwable getInstallationError() { - return installationError; - } - - public void setInstallationError(final Throwable error) { - installationError = error; - } - - public List getInstallationWarnings() { - return installationWarnings; - } - - public void addInstallationWarning(final Throwable warning) { - if (installationWarnings == null) { - installationWarnings = new ArrayList(); - } - - installationWarnings.add(warning); - } - - // uninstall-time error/warnings //////////////////////////////////////////////// - public Throwable getUninstallationError() { - return uninstallationError; - } - - public void setUninstallationError(final Throwable error) { - uninstallationError = error; - } - - public List getUninstallationWarnings() { - return uninstallationWarnings; - } - - public void addUninstallationWarning(final Throwable warning) { - if (uninstallationWarnings == null) { - uninstallationWarnings = new ArrayList(); - } - - uninstallationWarnings.add(warning); - } - - // node <-> dom ///////////////////////////////////////////////////////////////// - protected String getTagName() { - return PRODUCT_TAG_NAME; - } - - protected Element saveToDom(final Element element) throws FinalizationException { - super.saveToDom(element); - - final Document document = element.getOwnerDocument(); - - element.setAttribute(VERSION_TAG_NAME, version.toString()); - element.setAttribute(PLATFORMS_TAG_NAME, - StringUtils.asString(supportedPlatforms, StringUtils.SPACE)); - element.setAttribute(STATUS_TAG_NAME, currentStatus.toString()); - element.setAttribute(FEATURES_TAG_NAME, - StringUtils.asString(features, StringUtils.SPACE)); - - element.appendChild(XMLUtils.saveExtendedUrisList( - logicUris, - document.createElement(CONFIGURATION_LOGIC_TAG_NAME)));//NOI18N - - element.appendChild(XMLUtils.saveExtendedUrisList( - dataUris, - document.createElement(INSTALLATION_DATA_TAG_NAME)));//NOI18N - - final Element systemRequirementsElement = - document.createElement(SYSTEM_REQUIREMENTS_TAG_NAME);//NOI18N - - final Element diskSpaceElement = - document.createElement(DISK_SPACE_TAG_NAME);//NOI18N - diskSpaceElement.setTextContent(Long.toString(requiredDiskSpace)); - systemRequirementsElement.appendChild(diskSpaceElement); - - element.appendChild(systemRequirementsElement); - - if (dependencies.size() > 0) { - element.appendChild(XMLUtils.saveDependencies( - dependencies, - document.createElement(DEPENDENCIES_TAG_NAME)));//NOI18N - } - - return element; - } - - public Product loadFromDom(final Element element) throws InitializationException { - - super.loadFromDom(element); - - Element child; - - try { - version = - Version.getVersion(element.getAttribute(VERSION_TAG_NAME)); - supportedPlatforms = - StringUtils.parsePlatforms(element.getAttribute(PLATFORMS_TAG_NAME)); - - initialStatus = - StringUtils.parseStatus(element.getAttribute(STATUS_TAG_NAME)); - currentStatus = - initialStatus; - - features = StringUtils.asList(element.getAttribute(FEATURES_TAG_NAME), - StringUtils.SPACE); - - logicUris.addAll(XMLUtils.parseExtendedUrisList(XMLUtils.getChild( - element, CONFIGURATION_LOGIC_TAG_NAME))); - - dataUris.addAll(XMLUtils.parseExtendedUrisList(XMLUtils.getChild( - element, INSTALLATION_DATA_TAG_NAME))); - - requiredDiskSpace = Long.parseLong(XMLUtils.getChild( - element, - SYSTEM_REQUIREMENTS_TAG_NAME + "/" + DISK_SPACE_TAG_NAME). - getTextContent()); - - child = XMLUtils.getChild(element, DEPENDENCIES_TAG_NAME); - if (child != null) { - dependencies.addAll(XMLUtils.parseDependencies(child)); - } - } catch (ParseException e) { - throw new InitializationException(ResourceUtils.getString( - Product.class, - ERROR_CANNOT_LOAD_PRODUCT_KEY, - getDisplayName()), - e); - } - - return this; - } - - // essential getters/setters //////////////////////////////////////////////////// - public Version getVersion() { - return version; - } - - public List getPlatforms() { - return supportedPlatforms; - } - - public List getFeatures() { - return features; - } - - public File getInstallationLocation() { - final String path = SystemUtils.resolveString( - getProperty(INSTALLATION_LOCATION_PROPERTY), - getClassLoader()); - - return path == null ? null : new File(path); - } - - public void setInstallationLocation(final File location) { - setProperty(INSTALLATION_LOCATION_PROPERTY, location.getAbsolutePath()); - } - - public File getLocalCache() { - return new File( - Registry.getInstance().getLocalProductCache(), - uid + File.separator + version); - } - - public FilesList getInstalledFiles() { - return installedFiles; - } - - public File getInstalledFilesList() { - return new File( - getLocalCache(), - INSTALLED_FILES_LIST_FILE_NAME); - } - - public ClassLoader getClassLoader() { - return classLoader; - } - - public long getDownloadSize() { - long downloadSize = 0; - - for (ExtendedUri uri: logicUris) { - downloadSize += uri.getSize(); - } - for (ExtendedUri uri: dataUris) { - downloadSize += uri.getSize(); - } - - return downloadSize; - } - - private ApplicationDescriptor getApplicationDescriptor() { - final String key = "nbi-" + uid + "-" + version; - final String displayName = configurationLogic.getSystemDisplayName(); - final String icon; - if (configurationLogic.getIcon() != null) { - icon = new File( - getInstallationLocation(), - configurationLogic.getIcon()).getAbsolutePath(); - } else { - icon = null; - } - - String installLocation = getInstallationLocation().getAbsolutePath(); - if (SystemUtils.isMacOS() && configurationLogic.wrapForMacOs()) { - final String applicationLocation = getProperty(APPLICATION_LOCATION_PROPERTY); - - if (applicationLocation != null) { - installLocation = applicationLocation; - } - } - - final String[] modifyCommand = new String[] { - TargetOption.TARGET_ARG, uid, version.toString()}; - - final String[] uninstallCommand = new String[] { - TargetOption.TARGET_ARG, uid, version.toString(), ForceUninstallOption.FORCE_UNINSTALL_ARG}; - - if (configurationLogic.allowModifyMode()) { - return new ApplicationDescriptor( - key, - displayName, - icon, - installLocation, - uninstallCommand, - modifyCommand, - configurationLogic.getAdditionalSystemIntegrationInfo()); - } else { - return new ApplicationDescriptor( - key, - displayName, - icon, - installLocation, - uninstallCommand, - null, - configurationLogic.getAdditionalSystemIntegrationInfo()); - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public boolean isCompatibleWith(final Platform platform) { - for (Platform compatiblePlatform: supportedPlatforms) { - if (compatiblePlatform.isCompatibleWith(platform)) { - return true; - } - } - - return false; - } - - private void saveLegalArtifacts() throws IOException { - if (!configurationLogic.requireLegalArtifactSaving()) { - return; - } - - final Text license = configurationLogic.getLicense(); - if (license != null) { - final File file = new File( - getInstallationLocation(), - "LICENSE-" + uid + license.getContentType().getExtension()); - - FileUtils.writeFile(file, license.getText()); - installedFiles.add(file); - } - - final Map thirdPartyLicenses = configurationLogic.getThirdPartyLicenses(); - if (thirdPartyLicenses != null) { - final File file = new File( - getInstallationLocation(), - "THIRDPARTYLICENSES-" + uid + ".txt"); - - for (Map.Entry entry : thirdPartyLicenses.entrySet()) { - FileUtils.appendFile(file, - "%% The following software may be included in this product: " + entry.getKey() + ";\n" + - "Use of any of this software is governed by the terms of the license below:\n\n"); - FileUtils.appendFile(file, entry.getValue().getText() + "\n\n"); - } - - installedFiles.add(file); - } - - final Text thirdPartyLicense = configurationLogic.getThirdPartyLicense(); - if (thirdPartyLicense != null) { - final File file = new File( - getInstallationLocation(), - "THIRDPARTYLICENSE-" + uid + thirdPartyLicense.getContentType().getExtension()); - - FileUtils.writeFile(file, thirdPartyLicense.getText()); - installedFiles.add(file); - } - - final Text releaseNotes = configurationLogic.getReleaseNotes(); - if (releaseNotes != null) { - final File file = new File( - getInstallationLocation(), - "RELEASENOTES-" + uid + releaseNotes.getContentType().getExtension()); - - FileUtils.writeFile(file, releaseNotes.getText()); - installedFiles.add(file); - } - - final Text readme = configurationLogic.getReadme(); - if (readme != null) { - final File file = new File( - getInstallationLocation(), - "README-" + uid + readme.getContentType().getExtension()); - - FileUtils.writeFile(file, readme.getText()); - installedFiles.add(file); - } - - final Text distributionReadme = configurationLogic.getDistributionReadme(); - if (distributionReadme != null) { - final File file = new File( - getInstallationLocation(), - "DISTRIBUTION-" + uid + distributionReadme.getContentType().getExtension()); - - FileUtils.writeFile(file, distributionReadme.getText()); - installedFiles.add(file); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - private static enum InstallationPhase { - INITIALIZATION, - EXTRACTION, - CUSTOM_LOGIC, - FINALIZATION, - COMPLETE; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String INSTALLATION_LOCATION_PROPERTY = - "installation.location"; // NOI18N - - public static final String INSTALLED_FILES_LIST_FILE_NAME = - "installed-files.xml.gz"; // NOI18N - - public static final String MANIFEST_LOGIC_CLASS = - "Configuration-Logic-Class"; // NOI18N - - public static final String INFO_PLIST_STUB = FileUtils.INFO_PLIST_STUB; - - private static final String APPLICATION_LOCATION_PROPERTY = - "application.location"; - - private static final String VERSION_TAG_NAME = - "version";//NOI18N - private static final String PLATFORMS_TAG_NAME = - "platforms";//NOI18N - private static final String STATUS_TAG_NAME = - "status";//NOI18N - private static final String FEATURES_TAG_NAME = - "features";//NOI18N - private static final String CONFIGURATION_LOGIC_TAG_NAME = - "configuration-logic";//NOI18N - private static final String INSTALLATION_DATA_TAG_NAME = - "installation-data";//NOI18N - private static final String DEPENDENCIES_TAG_NAME = - "dependencies";//NOI18N - private static final String PRODUCT_TAG_NAME = - "product";//NOI18N - private static final String SYSTEM_REQUIREMENTS_TAG_NAME = - "system-requirements";//NOI18N - private static final String DISK_SPACE_TAG_NAME = - "disk-space";//NOI18N - - private static final String ERROR_CANNOT_INITIALIZE_PRODUCT_KEY = - "P.error.cannot.initialize.product";//NOI18N - private static final String ERROR_CANNOT_LOAD_LOGIC_KEY = - "P.error.cannot.load.logic";//NOI18N - private static final String ERROR_INSTALLATION_LOCATION_NOT_SET_KEY = - "P.error.installdir.not.set";//NOI18N - private static final String ERROR_INSTALLATION_LOCATION_SET_EMPTY_KEY = - "P.error.installdir.set.empty";//NOI18N - private static final String ERROR_CANNOT_CREATE_PRODUCT_CACHE_DIR_KEY = - "P.error.cannot.create.cache.dir";//NOI18N - private static final String ERROR_CACHE_NOT_DIRECTORY_KEY = - "P.error.local.cache.not.dir";//NOI18N - private static final String ERROR_CANNOT_LOAD_PRODUCT_KEY = - "P.error.cannot.load.product";//NOI18N - private static final String ERROR_LOGIC_NOT_YET_DOWNLOADED_KEY = - "P.error.logic.not.yet.downloaded";//NOI18N - private static final String ERROR_DATA_NOT_CACHED_KEY = - "P.error.installation.data.not.cached";//NOI18N - private static final String ERROR_CANNOT_EXTRACT_DATA_KEY = - "P.error.cannot.extract.data";//NOI18N - private static final String ERROR_CANNOT_SAVE_FILES_LIST_KEY = - "P.error.cannot.save.files.list";//NOI18N - private static final String ERROR_CANNOT_GET_WIZARD_COMPONENTS_KEY = - "P.error.cannot.get.wizard.components";//NOI18N - private static final String ERROR_CANNOT_WRAP_FOR_MACOS_KEY = - "P.error.cannot.wrap.for.macos";//NOI18N - private static final String ERROR_CANNOT_GET_FILES_LIST_KEY = - "P.error.cannot.get.files.list";//NOI18N - private static final String ERROR_CANNOT_DELETE_FILES_LIST_KEY = - "P.error.cannot.delete.files.list";//NOI18N - private static final String ERROR_CANNOT_DELETE_FILE_KEY = - "P.error.cannot.delete.file";//NOI18N - private static final String ERROR_CANNOT_REMOVE_FROM_SYSTEM_KEY = - "P.error.cannot.remove.from.system";//NOI18N - private static final String ERROR_NOT_ENOUGH_SPACE_KEY = - "P.error.not.enough.space";//NOI18N - private static final String ERROR_CANNOT_CLEAR_DATA_CACHE_KEY = - "P.error.cannot.clear.cache";//NOI18N - private static final String ERROR_SYSTEM_INTEGRATION_FAILER_KEY = - "P.error.system.integartion.failed";//NOI18N - - private static final String MESSAGE_INSTALLATION_STRING = - ResourceUtils.getString(Product.class, - "P.message.installation");//NOI18N - private static final String MESSAGE_UNINSTALLATION_STRING = - ResourceUtils.getString(Product.class, - "P.message.uninstallation");//NOI18N - private static final String MESSAGE_CONFIGURATION_STRING = - ResourceUtils.getString(Product.class, - "P.message.configuration");//NOI18N - private static final String MESSAGE_UNCONFIGURATION_STRING = - ResourceUtils.getString(Product.class, - "P.message.unconfiguration");//NOI18N - private static final String MESSAGE_LEGAL_ARTIFACTS_STRING = - ResourceUtils.getString(Product.class, - "P.message.legal.artifacts");//NOI18N - private static final String MESSAGE_RUN_LOGIC_STRING = - ResourceUtils.getString(Product.class, - "P.message.run.logic");//NOI18N - private static final String MESSAGE_SYSTEM_REGISTRATION_STRING = - ResourceUtils.getString(Product.class, - "P.message.system.registration");//NOI18N - private static final String MESSAGE_SAVE_INSTALL_FILES_LIST_STRING = - ResourceUtils.getString(Product.class, - "P.message.save.installation.files.list");//NOI18N - private static final String MESSAGE_DELETE_STRING = - ResourceUtils.getString(Product.class, - "P.message.delete");//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/product/components/ProductConfigurationLogic.java b/nbi/engine/src/org/netbeans/installer/product/components/ProductConfigurationLogic.java deleted file mode 100644 index e03e69f4701f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/components/ProductConfigurationLogic.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.components; - -import java.io.File; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.exceptions.UninstallationException; -import org.netbeans.installer.utils.helper.RemovalMode; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Text; -import org.netbeans.installer.utils.helper.Text.ContentType; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardComponent; - -public abstract class ProductConfigurationLogic { - private Product product; - - // abstract ///////////////////////////////////////////////////////////////////// - public abstract void install( - final Progress progress) throws InstallationException; - - public abstract void uninstall( - final Progress progress) throws UninstallationException; - - public abstract List getWizardComponents(); - - // product getter/setter //////////////////////////////////////////////////////// - protected final Product getProduct() { - return product; - } - - final void setProduct(final Product product) { - this.product = product; - } - - // validation /////////////////////////////////////////////////////////////////// - public String validateInstallation() { - if (getProduct().getStatus() == Status.INSTALLED) { - final File installLocation = getProduct().getInstallationLocation(); - if (installLocation == null) { - return ResourceUtils.getString( - ProductConfigurationLogic.class, - "PCL.validation.directory.null"); - } - if (!installLocation.exists()) { - return ResourceUtils.getString( - ProductConfigurationLogic.class, - "PCL.validation.directory.missing", - installLocation); - } - if (!installLocation.isDirectory()) { - return ResourceUtils.getString( - ProductConfigurationLogic.class, - "PCL.validation.directory.file", - installLocation); - } - if (FileUtils.isEmpty(installLocation)) { - return ResourceUtils.getString( - ProductConfigurationLogic.class, - "PCL.validation.directory.empty", - installLocation); - } - } - - return null; - } - - // product properties /////////////////////////////////////////////////////////// - protected final String getProperty(String name) { - return getProperty(name, true); - } - - protected final String getProperty(String name, boolean parse) { - final String value = product.getProperty(name); - - if (parse) { - return value != null ? parseString(value) : null; - } else { - return value; - } - } - - protected final void setProperty(final String name, final String value) { - product.setProperty(name, value); - } - - // various documentation/legal getters ////////////////////////////////////////// - public Text getLicense() { - final String text = parseString( - "$R{" + StringUtils.asPath(getClass()) + "/license.txt;" + - StringUtils.ENCODING_UTF8 + "}"); - return text == null ? null : new Text(text, ContentType.PLAIN_TEXT); - } - - public Map getThirdPartyLicenses() { - return null; - } - - public boolean requireLegalArtifactSaving() { - return true; - } - - public Text getThirdPartyLicense() { - return null; - } - - public Text getReleaseNotes() { - return null; - } - - public Text getReadme() { - return null; - } - - public Text getDistributionReadme() { - return null; - } - - public Text getInstallationInstructions() { - return null; - } - - // various informational probes ///////////////////////////////////////////////// - public boolean registerInSystem() { - return true; - } - - public String getSystemDisplayName() { - return product.getDisplayName(); - } - - public boolean allowModifyMode() { - return true; - } - - /** - * Specifies whether some special handling should be applied to the product's - * files when placing them on disk. If this method returns true, - * then the files of the product will be "wrapped" in the standard MacOS - * application directories structure. Also the {@link #getExecutable()} and - * {@link #getIcon()} methods will be called and will be expected to return - * proper values for the product's executable and icon so that they are - * symlinked from appropriate locations. - * - * @return Whether the product's files should be wrapped with the standard - * Mac OS application directories structure. - */ - public boolean wrapForMacOs() { - return false; - } - - /** - * Specifies whether the the installation directory for the product should end - * with Mac OS's specific extension - .app. - * - * @return true - if the installation directory must end with - * .app, false - otherwise. - */ - public boolean requireDotAppForMacOs() { - return false; - } - - /** - * @deprecated Use getProhibitedInstallationPathParts instead. - */ - @Deprecated - public boolean prohibitExclamation() { - return true; - } - /** - * Get the array of strings with each element deprecating the specific paths.

- * One char length elements are treated as the single deprecated char.
String.contains() is used for the check.

- * Two and more chars length elements are treated as the regexp patterns.
String.matches() is used for the check

- * @return Array of prohibited path parts. - */ - public String [] getProhibitedInstallationPathParts() { - return new String [] {"!", File.pathSeparator}; - } - - public String getExecutable() { - return null; - } - - public String getIcon() { - return null; - } - - public int getLogicPercentage() { - return 10; - } - /** - * Get additonal information about the product that is used during system integration - */ - public Map getAdditionalSystemIntegrationInfo() { - return new HashMap(); - } - // installation behavior //////////////////////////////////////////////////////// - public RemovalMode getRemovalMode() { - return RemovalMode.ALL; - } - - // helper methods for system utils and resource utils /////////////////////////// - protected final String parseString(String string) { - return SystemUtils.resolveString(string, product.getClassLoader()); - } - - protected final File parsePath(String path) { - return SystemUtils.resolvePath(path, product.getClassLoader()); - } - - protected final String getString(String key) { - return ResourceUtils.getString(getClass(), key); - } - - protected final Map getStrings(String key) { - return ResourceUtils.getStrings(getClass(), key); - } - protected final Map getStrings(String key, Object... arguments) { - return ResourceUtils.getStrings(getClass(), key, arguments); - } - - protected final String getString(String key, Object... arguments) { - return ResourceUtils.getString(getClass(), key, arguments); - } - - protected final InputStream getResource(String path) { - return ResourceUtils.getResource(path, product.getClassLoader()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/components/StatusInterface.java b/nbi/engine/src/org/netbeans/installer/product/components/StatusInterface.java deleted file mode 100644 index b46d33f74727..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/components/StatusInterface.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.components; - -import org.netbeans.installer.utils.helper.Status; - -/** - * - * @author Yulia Novozhilova - */ -public interface StatusInterface { - - public Status getStatus(); - - public void setStatus(Status status); -} diff --git a/nbi/engine/src/org/netbeans/installer/product/default-registry.xml b/nbi/engine/src/org/netbeans/installer/product/default-registry.xml deleted file mode 100644 index c4ac65d37fda..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/default-registry.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/product/default-state-file.xml b/nbi/engine/src/org/netbeans/installer/product/default-state-file.xml deleted file mode 100644 index f1899ef1891a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/default-state-file.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/product/dependencies/Conflict.java b/nbi/engine/src/org/netbeans/installer/product/dependencies/Conflict.java deleted file mode 100644 index 8e84f9251c9a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/dependencies/Conflict.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.dependencies; - -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Version; - -/** - * - * @author Dmitry Lipin - */ -public class Conflict extends Dependency { - public static final String NAME = "conflict"; //NOI18N - public Conflict( - final String uid, - final Version versionLower, - final Version versionUpper, - final Version versionResolved) { - super(uid,versionLower,versionUpper,versionResolved); - } - public String getName() { - return NAME; - } - - public boolean satisfies(Product product) { - return product.getUid().equals(getUid()) && - product.getVersion().newerOrEquals(getVersionLower()) && - product.getVersion().olderOrEquals(getVersionUpper()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/dependencies/InstallAfter.java b/nbi/engine/src/org/netbeans/installer/product/dependencies/InstallAfter.java deleted file mode 100644 index 6fe869bb1ba1..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/dependencies/InstallAfter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.dependencies; - -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Version; - -/** - * - * @author Dmitry Lipin - */ -public class InstallAfter extends Dependency { - public static final String NAME = "install-after"; //NOI18N - public InstallAfter( - final String uid, - final Version versionLower, - final Version versionUpper, - final Version versionResolved) { - super(uid,versionLower,versionUpper,versionResolved); - } - public String getName() { - return NAME; - } - public boolean satisfies(Product product) { - return product.getUid().equals(getUid()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/dependencies/Requirement.java b/nbi/engine/src/org/netbeans/installer/product/dependencies/Requirement.java deleted file mode 100644 index 7ff94b6af2ce..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/dependencies/Requirement.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.dependencies; - -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Version; - -/** - * - * @author Dmitry Lipin - */ -public class Requirement extends Dependency { - public static final String NAME = "requirement"; //NOI18N - private List > alternatives ; - - public Requirement( - final String uid, - final Version versionLower, - final Version versionUpper, - final Version versionResolved) { - this(uid,versionLower,versionUpper,versionResolved, - new ArrayList >()); - } - public Requirement( - final String uid, - final Version versionLower, - final Version versionUpper, - final Version versionResolved, - final List > altRequirements) { - super(uid,versionLower,versionUpper,versionResolved); - alternatives = new ArrayList > (altRequirements); - } - - - public String getName() { - return NAME; - } - - public boolean satisfies(Product product) { - if (getVersionResolved() != null) { - return product.getUid().equals(getUid()) && - product.getVersion().equals(getVersionResolved()); - - } - - // if the requirement is not resolved, we check uid equality and - // upper/lower version compatibility - return product.getUid().equals(getUid()) && - product.getVersion().newerOrEquals(getVersionLower()) && - product.getVersion().olderOrEquals(getVersionUpper()); - } - - public List> getAlternatives() { - return alternatives; - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/AndFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/AndFilter.java deleted file mode 100644 index 8c4b41387d2e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/AndFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public class AndFilter implements RegistryFilter { - private RegistryFilter[] filters; - - public AndFilter(final RegistryFilter... filters) { - this.filters = filters; - } - - public boolean accept(final RegistryNode node) { - for (RegistryFilter filter: filters) { - if (!filter.accept(node)) { - return false; - } - } - - return true; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/GroupFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/GroupFilter.java deleted file mode 100644 index a3ca447e7895..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/GroupFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public class GroupFilter implements RegistryFilter { - private String uid; - - public GroupFilter() { - // does nothing - } - - public GroupFilter(final String uid) { - this.uid = uid; - } - - public boolean accept(final RegistryNode node) { - if (node instanceof Group) { - Group group = (Group) node; - if (uid != null) { - if (!group.getUid().equals(uid)) { - return false; - } - } - - return true; - } - - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/OrFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/OrFilter.java deleted file mode 100644 index d153ae4e17f9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/OrFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public class OrFilter implements RegistryFilter { - private RegistryFilter[] filters; - - public OrFilter(final RegistryFilter... filters) { - this.filters = filters; - } - - public boolean accept(final RegistryNode node) { - for (RegistryFilter filter: filters) { - if (filter.accept(node)) { - return true; - } - } - - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/ProductFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/ProductFilter.java deleted file mode 100644 index a03191c83003..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/ProductFilter.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.utils.helper.DetailedStatus; -import org.netbeans.installer.utils.helper.Feature; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.helper.Version; - -/** - * - * @author Kirill Sorokin - */ -public class ProductFilter implements RegistryFilter { - private String uid; - - private List platforms; - - private Version versionLower; - private Version versionUpper; - - private Status status; - private DetailedStatus detailedStatus; - - private Feature feature; - - private Boolean visible; - - public ProductFilter() { - this.platforms = new LinkedList(); - } - - public ProductFilter(final boolean visible) { - this(); - - this.visible = visible; - } - - public ProductFilter(final Platform platform) { - this(); - - this.platforms.add(platform); - } - - public ProductFilter(final String uid, final Platform platform) { - this(); - - this.uid = uid; - this.platforms.add(platform); - } - - public ProductFilter(final String uid, final Version version, final Platform platform) { - this(); - - this.uid = uid; - this.versionLower = version; - this.versionUpper = version; - this.platforms.add(platform); - } - - public ProductFilter(final String uid, final Version version, final List platforms) { - this(); - - this.uid = uid; - this.versionLower = version; - this.versionUpper = version; - this.platforms.addAll(platforms); - } - - public ProductFilter(final String uid, final Version versionLower, final Version versionUpper, final Platform platform) { - this(); - - this.uid = uid; - this.versionLower = versionLower; - this.versionUpper = versionUpper; - this.platforms.add(platform); - } - - public ProductFilter(final Status status) { - this(status, Registry.getInstance().getTargetPlatform()); - } - - public ProductFilter(final Status status, final Platform platform) { - this(); - - this.status = status; - this.platforms.add(platform); - } - - public ProductFilter(final DetailedStatus detailedStatus) { - this(detailedStatus, Registry.getInstance().getTargetPlatform()); - } - - public ProductFilter(final DetailedStatus detailedStatus, final Platform platform) { - this(); - - this.detailedStatus = detailedStatus; - this.platforms.add(platform); - } - - public ProductFilter(final Feature feature, final Platform platform) { - this(); - - this.feature = feature; - this.platforms.add(platform); - } - - public boolean accept(final RegistryNode node) { - if (node instanceof Product) { - final Product product = (Product) node; - - if (uid != null) { - if (!product.getUid().equals(uid)) { - return false; - } - } - - if ((versionLower != null) && (versionUpper != null)) { - if (!product.getVersion().newerOrEquals(versionLower) || - !product.getVersion().olderOrEquals(versionUpper)) { - return false; - } - } - - if (platforms.size() > 0) { - boolean intersects = false; - - for (Platform platform: platforms) { - for (Platform productPlatform: product.getPlatforms()) { - if (platform.isCompatibleWith(productPlatform) || - productPlatform.isCompatibleWith(platform)) { - intersects = true; - } - } - - if (intersects) break; - } - - if (!intersects) return false; - } - - if (status != null) { - if (product.getStatus() != status) { - return false; - } - } - - if (detailedStatus != null) { - if (product.getDetailedStatus() != detailedStatus) { - return false; - } - } - - if (feature != null) { - for (String id: product.getFeatures()) { - if (feature.getId().equals(id)) { - return false; - } - } - } - - if (visible != null) { - if (product.isVisible() != visible.booleanValue()) { - return false; - } - } - - return true; - } - - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/RegistryFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/RegistryFilter.java deleted file mode 100644 index 2a06f6830a00..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/RegistryFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public interface RegistryFilter { - - public abstract boolean accept(final RegistryNode node); - -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/SubTreeFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/SubTreeFilter.java deleted file mode 100644 index fddad9bb2f55..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/SubTreeFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public class SubTreeFilter implements RegistryFilter { - private List leaves; - - public SubTreeFilter(List nodes) { - this.leaves = new LinkedList(); - this.leaves.addAll(nodes); - } - - public boolean accept(final RegistryNode node) { - if (leaves.contains(node)) { - return true; - } - - for (RegistryNode leaf: leaves) { - if (node.isAncestor(leaf)) { - return true; - } - } - - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/filters/TrueFilter.java b/nbi/engine/src/org/netbeans/installer/product/filters/TrueFilter.java deleted file mode 100644 index 5722ed5d2ee2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/filters/TrueFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.product.filters; - -import org.netbeans.installer.product.RegistryNode; - -/** - * - * @author Kirill Sorokin - */ -public class TrueFilter implements RegistryFilter { - public static final TrueFilter INSTANCE = new TrueFilter(); - - public boolean accept(final RegistryNode node) { - return true; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/product/registry.xsd b/nbi/engine/src/org/netbeans/installer/product/registry.xsd deleted file mode 100644 index edb2c8412922..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/registry.xsd +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/product/state-file.xsd b/nbi/engine/src/org/netbeans/installer/product/state-file.xsd deleted file mode 100644 index ba9443c8f3ca..000000000000 --- a/nbi/engine/src/org/netbeans/installer/product/state-file.xsd +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/utils/BrowserUtils.java b/nbi/engine/src/org/netbeans/installer/utils/BrowserUtils.java deleted file mode 100644 index 254684cf6888..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/BrowserUtils.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; - -/** - * - * @author Dmitry Lipin - */ -public class BrowserUtils { - - private static final boolean isBrowseSupported; - private static final Method browseMethod; - private static final Object desktop; - - - static { - LogManager.log("Checking if java.awt.Desktop.getDesktop().browse() functionality is supported"); - boolean supported = false; - Method browseM = null; - Object desktopObj = null; - try { - // Determine if java.awt.Desktop is supported - Class desktopCls = Class.forName("java.awt.Desktop", true, null); - Method getDesktopM = desktopCls.getMethod("getDesktop"); - browseM = desktopCls.getMethod("browse", URI.class); - - Class actionCls = Class.forName("java.awt.Desktop$Action", true, null); - Method isDesktopSupportedMethod = desktopCls.getMethod("isDesktopSupported"); - Method isSupportedMethod = desktopCls.getMethod("isSupported", actionCls); - Field browseField = actionCls.getField("BROWSE"); - - // support only if Desktop.isDesktopSupported() and - // Desktop.isSupported(Desktop.Action.BROWSE) return true. - Boolean result = (Boolean) isDesktopSupportedMethod.invoke(null); - if (result.booleanValue()) { - desktopObj = getDesktopM.invoke(null); - result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null)); - supported = result.booleanValue(); - } - } catch (ClassNotFoundException e) { - LogManager.log("... browser not supported", e); - } catch (NoSuchMethodException e) { - LogManager.log("... browser not supported", e); - } catch (NoSuchFieldException e) { - LogManager.log("... browser not supported", e); - } catch (IllegalAccessException e) { - // should never reach here - InternalError x = - new InternalError("Desktop.getDesktop() method not found"); - x.initCause(e); - LogManager.log("... browser not supported", e); - } catch (InvocationTargetException e) { - LogManager.log("... browser not supported", e); - } - isBrowseSupported = supported; - browseMethod = browseM; - desktop = desktopObj; - } - - public static boolean openBrowser(URI uri) { - LogManager.log("... opening in the browser: " + uri); - boolean result = false; - try { - if (isBrowseSupported) { - LogManager.log("... browse (bs): " + uri); - result = browse(uri); - } else if (SystemUtils.getNativeUtils().isBrowseSupported()) { - LogManager.log("... browse (fb): " + uri); - result = SystemUtils.getNativeUtils().openBrowser(uri); - } else { - LogManager.log("... browser is not supported"); - } - } catch (Exception ex) { - LogManager.log("Cannot open browser", ex); - } - return result; - } - - public static boolean isBrowseSupported() { - return isBrowseSupported || SystemUtils.getNativeUtils().isBrowseSupported(); - } - - private static boolean browse(URI uri) throws IOException { - if (uri == null) { - throw new NullPointerException("null uri"); - } - if (!isBrowseSupported) { - throw new UnsupportedOperationException("Browse operation is not supported"); - } - - // Call Desktop.browse() method - try { - browseMethod.invoke(desktop, uri); - return true; - } catch (IllegalAccessException e) { - // should never reach here - InternalError x = - new InternalError("Desktop.getDesktop() method not found"); - x.initCause(e); - throw x; - } catch (InvocationTargetException e) { - Throwable x = e.getCause(); - if (x != null) { - if (x instanceof UnsupportedOperationException) { - throw (UnsupportedOperationException) x; - } else if (x instanceof IllegalArgumentException) { - throw (IllegalArgumentException) x; - } else if (x instanceof IOException) { - throw (IOException) x; - } else if (x instanceof SecurityException) { - throw (SecurityException) x; - } else { - // ignore - } - } - } - return false; - } - - public static HyperlinkListener createHyperlinkListener() { - return new HyperlinkListener() { - - public void hyperlinkUpdate(HyperlinkEvent hlevt) { - if (HyperlinkEvent.EventType.ACTIVATED == hlevt.getEventType()) { - final URL url = hlevt.getURL(); - if (url != null) { - try { - openBrowser(url.toURI()); - } catch (URISyntaxException e) { - LogManager.log(e); - } - } - } - } - }; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/Bundle.properties deleted file mode 100644 index f9aa2c2545cb..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/Bundle.properties +++ /dev/null @@ -1,72 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -LM.error.cannot.write=Error writing to the log file. Logging disabled. - -EM.ununexpected.exception=An unexpected exception happened in thread {0} -EM.errortype.critical=Critical Error -EM.errortype.error=Error -EM.errortype.warning=Warning -EM.errortype.message=Message -EM.unexpected.error=An unknown error occured. -EM.exception.message=\n\nException:\n {0}:\n {1} -EM.exception.logfile.info=\n\nYou can get more details about the issue in the installer log file:\n {0} -EM.exception.continue.question=\n\nContinue installation? - -FU.error.output.file.entry=An file entry {0} exists and is not a file -FU.error.output.dir.entry=An directory entry {0} exists and is not a directory -FU.message.extracting=Extracting {0} -FU.error.load.xml.file.list=Could not load xml files list for extraction -FU.error.unjar.todir=Directory {0} is an existing file, cannot unjar -FU.message.copy.dir=Copying directory: {0} to: {1} -FU.message.copy.file=Copying file: {0} to: {1} -FU.error.close.stream=Cannot close stream -FU.error.source.not.readable=Source {0} is not readable -FU.error.dest.not.file=Destination {0} is not a file -FU.error.dest.creation=Destination {0} cannot be created -FU.error.dest.not.writable=Destination {0} is not writable -FU.message.moving=Moving {0} to {1} -FU.error.freespace=Cannot get free disk space amount at {0} -FU.error.cannot.close.jar=Cannot close jar {0} -FU.error.cannot.create.dir.exist.file=Cannot create directory {0}, it is an existing file -FU.error.cannot.create.dir=Cannot create directory {0} -FU.error.not.jar.file=The supplied file {0} is not a jar archive -FU.error.sha1.not.supported=Holy crap, this jvm does not support SHA1 -FU.error.md5.not.supported=Holy crap, this jvm does not support MD5 -FU.error.file.security.exception=Something very unexpected - a security exception during accessing file {0} -FU.message.delete.file=Deleting file {0} -FU.message.delete.dir=Deleting directory {0} -FU.error.pack200.failed=Pack200 finished with error\nError code: {0}\nStdout: {1}\nStderr: {2} -FU.error.unpack200.failed=Unpack200 finished with error\nError code: {0}\nStdout: {1}\nStderr: {2} - -UU.error.failed.to.parse.property=Cannot parse property - {0}, its value - {1}. -UI.error.failed.to.activate.crossplatform.laf=Could not activate the cross-platform look and feel - proceeding with whatever look and feel was the default. -UI.error.failed.to.activate.defined.laf=Could not activate the defined look and feel - falling back to the default cross-platform one. -UI.error.failed.to.init.ui=Can`t initialize UI -UI.error.failed.to.init.ui.headless=Running in headless mode -UI.error.failed.to.force.gtk=Cannot force the use of GTK look and feel -UI.silent.default.yes=Going with Yes (default) option... -UI.silent.default.no=Going with No (default) option... -UI.silent.default.cancel=Going with Cancel (default) option... -UI.error.failed.to.initialize.ui.linkerr=An error occured while initializing the NetBeans IDE installer UI.\n\ -Most probably the running JVM is not compatible with the current platform.\n\ -See FAQ at http://wiki.netbeans.org/FaqUnableToPrepareBundledJdk for more information.\n{0} - -StrU.error.cannot.parse.status=Cannot parse status: {0} -StrU.error.unknown.platform=Platform "{0}" is not recognized. diff --git a/nbi/engine/src/org/netbeans/installer/utils/DateUtils.java b/nbi/engine/src/org/netbeans/installer/utils/DateUtils.java deleted file mode 100644 index 765608838b99..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/DateUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * - * @author Kirill Sorokin - */ -public final class DateUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static String getTimestamp() { - return COMPACT_TIMESTAMP.format(new Date()); - } - - public static String getFormattedTimestamp() { - return DETAILED_TIMESTAMP.format(new Date()); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private DateUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final DateFormat COMPACT_TIMESTAMP = - new SimpleDateFormat("yyyyMMddHHmmss"); // NOI18N - - public static final DateFormat DETAILED_TIMESTAMP = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/EngineUtils.java b/nbi/engine/src/org/netbeans/installer/utils/EngineUtils.java deleted file mode 100644 index 7a51774606e5..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/EngineUtils.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLDecoder; -import java.util.HashSet; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.cli.CLIHandler; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.progress.Progress; - -/** - * - * @author Dmitry Lipin - */ -public final class EngineUtils { - - /** - * Cache installer at NBI`s home directory. - */ - public static File cacheEngine(Progress progress) throws IOException { - File cachedEngine = getEngineLocation(); - - if (!FileUtils.exists(cachedEngine)) { - cacheEngine(cachedEngine, progress); - } - - return cachedEngine; - } - public static Class getEngineMainClass() { - return Installer.class; - } - - public static void cacheEngine(File dest, Progress progress) throws IOException { - LogManager.logIndent("cache engine data locally to run uninstall in the future"); - - String filePrefix = "file:"; - String httpPrefix = "http://"; - String jarSep = "!/"; - - String installerResource = ResourceUtils.getResourceClassName(getEngineMainClass()); - URL url = getEngineMainClass().getClassLoader().getResource(installerResource); - if (url == null) { - throw new IOException("No main Installer class in the engine"); - } - - LogManager.log(ErrorLevel.DEBUG, "NBI Engine URL for Installer.Class = " + url); - LogManager.log(ErrorLevel.DEBUG, "URL Path = " + url.getPath()); - - boolean needCache = true; - - if ("jar".equals(url.getProtocol())) { - LogManager.log("... running engine as a .jar file"); - // we run engine from jar, not from .class - String path = url.getPath(); - String jarLocation; - - if (path.startsWith(filePrefix)) { - LogManager.log("... classloader says that jar file is on the disk"); - if (path.indexOf(jarSep) != -1) { - jarLocation = path.substring(filePrefix.length(), - path.indexOf(jarSep + installerResource)); - jarLocation = URLDecoder.decode(jarLocation, StringUtils.ENCODING_UTF8); - File jarfile = new File(jarLocation); - LogManager.log("... checking if it runs from cached engine"); - if (jarfile.getAbsolutePath().equals( - dest.getAbsolutePath())) { - needCache = false; // we already run cached version - } - LogManager.log("... " + !needCache); - } else { - throw new IOException("JAR path " + path + - " doesn`t contaion jar-separator " + jarSep); - } - } else if (path.startsWith(httpPrefix)) { - LogManager.log("... classloader says that jar file is on remote server"); - } - } else { - // a quick hack to allow caching engine when run from the IDE (i.e. - // as a .class) - probably to be removed later. Or maybe not... - LogManager.log("... running engine as a .class file"); - } - - if (needCache) { - cacheEngineJar(dest, progress); - } - - LogManager.logUnindent("... finished caching engine data"); - } - - - public static void checkEngine() { - Class mainClass = getEngineMainClass(); - String thisClassResource = ResourceUtils.getResourceClassName(mainClass); - InputStream is = mainClass.getClassLoader().getResourceAsStream(thisClassResource); - ClassLoader cl = mainClass.getClassLoader(); - boolean exclamationMarkInURL = false; - if (cl instanceof URLClassLoader) { - URLClassLoader ucl = (URLClassLoader) cl; - for (URL url : ucl.getURLs()) { - exclamationMarkInURL = exclamationMarkInURL || url.getPath().contains("!"); - } - } - if (is == null) { - if (exclamationMarkInURL) { - String message; - if (SystemUtils.getDefaultUserdirRoot().toString().contains("!")) { - //Issue #156011 - //Note: don`t use ResourceUtils for getting string here. - message = - "Looks like the name of current user profile directory contains an exclamation mark (!):\n" + - SystemUtils.getDefaultUserdirRoot() + "\n\n" + - "It is not recommended to use such profile names due to JDK bugs:\n" + - "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4730642" + "\n" + - "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4523159" + "\n" + "\n" + - "That bugs affects the installer work as well.\n" + - "The workaround is to run installer with different temporary and working installer directory.\n" + - "For example, try run installer with the following arguments:\n" + - "--tempdir " + new File(System.getenv("SystemDrive"), "Temp") + " " + - "--userdir " + new File(System.getenv("SystemDrive"), "NBI") + "\n"; - - } else { - // some generic message - message = - "Cannot load the main class " + mainClass.getName() + " from the jar file due to JDK bugs:\n" + - "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4730642" + "\n" + - "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4523159" + "\n" + "\n" + - "Use other directory for the jar file.\n"; - } - - ErrorManager.notifyCritical(message); - } - } else { - try { - is.close(); - } catch (IOException e) { - } - } - } - - private static File getEngineLocation() { - final String propName = EngineResources.LOCAL_ENGINE_PATH_PROPERTY; - - if (System.getProperty(propName) == null) { - File cachedEngine = new File(Installer.getInstance().getLocalDirectory(), - DEFAULT_ENGINE_JAR_NAME); - System.setProperty(propName, cachedEngine.getAbsolutePath()); - } - return new File(System.getProperty(propName)); - } - - private static void cacheEngineJar(File dest, Progress progress) throws IOException { - LogManager.log("... starting copying engine content to the new jar file"); - String[] entries = StringUtils.splitByLines( - StreamUtils.readStream( - ResourceUtils.getResource(EngineResources.ENGINE_CONTENTS_LIST))); - - JarOutputStream jos = null; - Set jarEntries = new HashSet (); - - try { - Manifest mf = new Manifest(); - mf.getMainAttributes().put(Attributes.Name.MAIN_CLASS, getEngineMainClass().getName()); - mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); - mf.getMainAttributes().put(Attributes.Name.CLASS_PATH, StringUtils.EMPTY_STRING); - - dest.getParentFile().mkdirs(); - jos = new JarOutputStream(new FileOutputStream(dest), mf); - LogManager.log("... total entries : " + entries.length); - for (int i = 0; i < entries.length; i++) { - progress.setPercentage((i * 100) / entries.length); - String name = entries[i]; - if (name.length() > 0) { - String dataDir = EngineResources.DATA_DIRECTORY + - StringUtils.FORWARD_SLASH; - if (!name.startsWith(dataDir) || // all except "data/"" - name.equals(dataDir) || // "data/" - name.matches(EngineResources.ENGINE_PROPERTIES_PATTERN) || // engine properties - name.equals(CLIHandler.OPTIONS_LIST)) { // additional CLI commands list - addJarEntry(jos, name, jarEntries); - if (!name.endsWith(StringUtils.FORWARD_SLASH)) { - StreamUtils.transferData(ResourceUtils.getResource(name), jos); - } - } - } - } - LogManager.log("... adding content list and some other stuff"); - addJarEntry(jos, EngineResources.DATA_DIRECTORY + StringUtils.FORWARD_SLASH + - Registry.DEFAULT_BUNDLED_REGISTRY_FILE_NAME, jarEntries); - - XMLUtils.saveXMLDocument( - Registry.getInstance().getEmptyRegistryDocument(), - jos); - - addJarEntry(jos, EngineResources.ENGINE_CONTENTS_LIST, jarEntries); - jos.write(StringUtils.asString(entries, SystemUtils.getLineSeparator()).getBytes()); - } catch (XMLException e) { - throw new IOException(e); - } finally { - if (jos != null) { - try { - jos.close(); - } catch (IOException ex) { - LogManager.log(ex); - } - - } - } - - LogManager.log("Installer Engine has been cached to " + dest); - } - - private static void addJarEntry(JarOutputStream jos, String name, Set entries) throws IOException { - String parent; - int index; - if(!name.endsWith(StringUtils.FORWARD_SLASH)) { - //file entry - index = name.lastIndexOf(StringUtils.FORWARD_SLASH); - } else { - index = name.substring(0, name.length() - 1).lastIndexOf(StringUtils.FORWARD_SLASH); - } - if(index != -1) { - parent = name.substring(0, index + 1); - addJarEntry(jos, parent, entries); - } - if(entries.add(name)) { - jos.putNextEntry(new JarEntry(name)); - } - } - - public static final String DEFAULT_ENGINE_JAR_NAME = "nbi-engine.jar";//NOI18N - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/ErrorManager.java b/nbi/engine/src/org/netbeans/installer/utils/ErrorManager.java deleted file mode 100644 index 5fcfc3b2cada..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/ErrorManager.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.lang.Thread.UncaughtExceptionHandler; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.helper.FinishHandler; - -/** - * - * @author Kirill Sorokin - */ -public final class ErrorManager { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static UncaughtExceptionHandler exceptionHandler; - private static FinishHandler finishHandler; - - public static synchronized void notifyDebug(String message) { - notify(ErrorLevel.DEBUG, message); - } - - public static synchronized void notifyDebug(String message, Throwable e) { - notify(ErrorLevel.DEBUG, message, e); - } - - public static synchronized void notify(String message) { - notify(ErrorLevel.MESSAGE, message); - } - - public static synchronized void notify(String message, Throwable e) { - notify(ErrorLevel.MESSAGE, message, e); - } - - public static synchronized void notifyWarning(String message) { - notify(ErrorLevel.WARNING, message); - } - - public static synchronized void notifyWarning(String message, Throwable e) { - notify(ErrorLevel.WARNING, message, e); - } - - public static synchronized void notifyError(String message) { - notify(ErrorLevel.ERROR, message); - } - - public static synchronized void notifyError(String message, Throwable e) { - notify(ErrorLevel.ERROR, message, e); - } - - public static synchronized void notifyCritical(String message) { - notify(ErrorLevel.CRITICAL, message); - } - - public static synchronized void notifyCritical(String message, Throwable e) { - notify(ErrorLevel.CRITICAL, message, e); - } - - public static synchronized void notify(int level, String message) { - notify(level, message, null); - } - - public static synchronized void notify(int level, Throwable exception) { - notify(level, null, exception); - } - - public static synchronized void notify(int level, String message, Throwable exception) { - // parameters validation - assert (message != null) || (exception != null); - - String dialogText = StringUtils.EMPTY_STRING; - - if (message != null) { - LogManager.log(level, message); - dialogText = message; - } else { - dialogText = ResourceUtils.getString(ErrorManager.class, - ERROR_UNEXPECTED_ERROR_KEY); - } - if (exception != null) { - LogManager.log(level, exception); - dialogText += ResourceUtils.getString(ErrorManager.class, - ERROR_EXCEPTION_MESSAGE_KEY, - exception.getClass().getName(), - exception.getMessage()); - } - if(LogManager.getLogFile()!=null) { - dialogText += ResourceUtils.getString(ErrorManager.class, - ERROR_LOGFILE_INFO_KEY, - LogManager.getLogFile().getAbsolutePath()); - } - String titleKey = null; - UiUtils.MessageType type; - - switch (level) { - case ErrorLevel.MESSAGE: - titleKey = ERROR_MESSAGE_KEY; - type = UiUtils.MessageType.INFORMATION; - break; - case ErrorLevel.WARNING: - titleKey = ERROR_WARNING_KEY; - type = UiUtils.MessageType.WARNING; - break; - case ErrorLevel.ERROR: - dialogText += ResourceUtils.getString(ErrorManager.class, ERROR_EXCEPTION_CONTINUE_QUESTION_KEY); - titleKey = ERROR_ERROR_KEY; - type = UiUtils.MessageType.ERROR; - break; - case ErrorLevel.CRITICAL: - titleKey = ERROR_CRITICAL_KEY; - type = UiUtils.MessageType.CRITICAL; - break; - default: - return; - } - String title = ResourceUtils.getString(ErrorManager.class, titleKey); - if(title == null) { - title = type.toString(); - } - - boolean exitInstaller = UiUtils.showMessageDialog(dialogText, title, type); - - if(exitInstaller || type.equals(UiUtils.MessageType.CRITICAL)) { - finishHandler.criticalExit(); - } - } - - public static UncaughtExceptionHandler getExceptionHandler() { - return exceptionHandler; - } - - public static void setExceptionHandler(final UncaughtExceptionHandler exceptionHandler) { - ErrorManager.exceptionHandler = exceptionHandler; - } - - public static FinishHandler getFinishHandler() { - return finishHandler; - } - - public static void setFinishHandler(final FinishHandler finishHandler) { - ErrorManager.finishHandler = finishHandler; - } - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private ErrorManager() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class ExceptionHandler implements UncaughtExceptionHandler { - public void uncaughtException( - final Thread thread, - final Throwable exception) { - ErrorManager.notifyCritical( - ResourceUtils.getString(ErrorManager.class, - ERROR_UNEXPECTED_EXCEPTION_KEY,thread.getName()), - exception); - } - } - private static final String ERROR_UNEXPECTED_EXCEPTION_KEY = - "EM.ununexpected.exception";//NOI18N - private static final String ERROR_CRITICAL_KEY = - "EM.errortype.critical";//NOI18N - private static final String ERROR_WARNING_KEY = - "EM.errortype.warning";//NOI18N - private static final String ERROR_ERROR_KEY = - "EM.errortype.error";//NOI18N - private static final String ERROR_MESSAGE_KEY = - "EM.errortype.message";//NOI18N - private static final String ERROR_UNEXPECTED_ERROR_KEY = - "EM.unexpected.error";//NOI18N - private static final String ERROR_EXCEPTION_MESSAGE_KEY = - "EM.exception.message";//NOI18N - private static final String ERROR_LOGFILE_INFO_KEY = - "EM.exception.logfile.info";//NOI18N - private static final String ERROR_EXCEPTION_CONTINUE_QUESTION_KEY = - "EM.exception.continue.question";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/FileProxy.java b/nbi/engine/src/org/netbeans/installer/utils/FileProxy.java deleted file mode 100644 index 535715d7ae5d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/FileProxy.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.util.HashMap; -import java.util.Map; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.helper.ExtendedUri; - -/** - * - * @author Danila_Dugurov - */ -//todo: This class already ready to die. -public class FileProxy { - private static final String RESOURCE_SCHEME = "resource"; - public static final String RESOURCE_SCHEME_PREFIX = RESOURCE_SCHEME + ":"; - - private final File tmpDir; - private final Map cache = new HashMap(); - { - try { - tmpDir = Files.createTempDirectory("nbi").toFile(); - } catch (IOException ex) { - throw new IllegalStateException("can not write to temp folder", ex); - } - tmpDir.mkdirs(); - tmpDir.deleteOnExit(); - } - - public static final FileProxy proxy = new FileProxy(); - - public static FileProxy getInstance() { - return proxy; - } - - public void deleteFile(String uri) throws IOException { - final File file = cache.get(uri); - if (uri != null && uri.startsWith("file")) return; - if (file != null) FileUtils.deleteFile(file); - cache.remove(uri); - } - - public void deleteFile(ExtendedUri uri) throws IOException { - if ((uri.getLocal() != null) && - !uri.getLocal().equals(uri.getRemote()) && - !uri.getAlternates().contains(uri.getLocal())) { - deleteFile(uri.getRemote()); - uri.setLocal(null); - } - } - public void deleteFile(URI uri) throws IOException { - deleteFile(uri.toString()); - } - - public void deleteFile(URL url) throws IOException { - deleteFile(url.toString()); - } - - public File getFile(String uri) throws DownloadException { - return getFile(uri, null, null); - } - - public File getFile(String uri, boolean deleteOnExit) throws DownloadException { - return getFile(uri, null, null, deleteOnExit); - } - - public File getFile(ExtendedUri uri, Progress progress) throws DownloadException { - return getFile(uri.getRemote(), progress, null, false); - } - - public File getFile(String uri, ClassLoader loader) throws DownloadException { - return getFile(uri, null, loader); - } - public File getFile(String uri, ClassLoader loader, boolean deleteOnExit) throws DownloadException { - return getFile(uri, null, loader, deleteOnExit); - } - public File getFile(URI uri, Progress progress) throws DownloadException { - return getFile(uri, progress, null, false); - } - - public File getFile(String uri, Progress progress, ClassLoader loader) throws DownloadException{ - return getFile(uri, progress, loader, false); - } - - public File getFile(String uri, Progress progress, ClassLoader loader, boolean deleteOnExit) throws DownloadException { - final URI myUri; - try { - myUri = new URI(uri); - } catch (URISyntaxException ex) { - throw new DownloadException("uri:" + uri, ex); - } - return getFile(myUri, progress, loader, deleteOnExit); - } - - public File getFile(URI uri, boolean deleteOnExit) throws DownloadException { - return getFile(uri, null, null, deleteOnExit); - } - - public File getFile(URI uri) throws DownloadException { - return getFile(uri, null, null, false); - } - - public File getFile(URI uri, Progress progress, ClassLoader loader, boolean deleteOnExit) throws DownloadException { - final String cacheKey = uri.toString() + - (loader != null ? "#" + loader.toString() : ""); - - if (cache.containsKey(cacheKey) && cache.get(cacheKey).exists()) { - return cache.get(cacheKey); - } - if (uri.getScheme().equals("file")) { - File file = new File(uri); - if (!file.exists()) throw new DownloadException("file not exist: " + uri); - return file; - } else if (uri.getScheme().equals(RESOURCE_SCHEME)) { - OutputStream out = null; - try { - String path = uri.getSchemeSpecificPart(); - File file = new File(tmpDir, path.substring(path.lastIndexOf('/'))); - String fileName = file.getName(); - File parent = file.getParentFile(); - for (int i = 0; file.exists(); i++) { - file = new File(parent, fileName + "." + i); - } - file.createNewFile(); - if (deleteOnExit) { - file.deleteOnExit(); - } - final InputStream resource = (loader != null ? loader: getClass().getClassLoader()).getResourceAsStream(uri.getSchemeSpecificPart()); - out = new FileOutputStream(file); - if (resource == null) throw new DownloadException(RESOURCE_SCHEME_PREFIX + uri.getSchemeSpecificPart() + " not found"); - StreamUtils.transferData(resource, out); - cache.put(cacheKey, file); - return file; - } catch(IOException ex) { - throw new DownloadException("I/O error has occures", ex); - } finally { - if (out != null) - try { - out.close(); - } catch (IOException ignord) {} - } - } - throw new DownloadException("unsupported sheme: " + uri.getScheme()); - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/FileUtils.java b/nbi/engine/src/org/netbeans/installer/utils/FileUtils.java deleted file mode 100644 index 694606635204..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/FileUtils.java +++ /dev/null @@ -1,1931 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.nio.charset.Charset; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.InvalidPathException; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.CRC32; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipOutputStream; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.ExecutionResults; -import org.netbeans.installer.utils.helper.FilesList; -import org.netbeans.installer.utils.helper.FileEntry; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.NativeUtils; -import org.netbeans.installer.utils.system.WindowsNativeUtils; - -/** - * - * @author Kirill Sorokin - */ -public final class FileUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - - // file/stream read/write /////////////////////////////////////////////////////// - public static String readFile( - final File file, String charset) throws IOException { - FileInputStream fis = new FileInputStream(file); - InputStreamReader isr = new InputStreamReader(fis, charset); - final Reader reader = new BufferedReader(isr); - try { - final char[] buffer = new char[BUFFER_SIZE]; - final StringBuilder stringBuilder = new StringBuilder(); - int readLength; - while ((readLength = reader.read(buffer)) != -1) { - stringBuilder.append(buffer, 0, readLength); - } - return stringBuilder.toString(); - } finally { - try { - reader.close(); - isr.close(); - fis.close(); - } catch(IOException ignord) { - } - } - } - public static String readFile( - final File file) throws IOException { - final Reader reader = new BufferedReader(new FileReader(file)); - try { - final char[] buffer = new char[BUFFER_SIZE]; - final StringBuilder stringBuilder = new StringBuilder(); - int readLength; - while ((readLength = reader.read(buffer)) != -1) { - stringBuilder.append(buffer, 0, readLength); - } - return stringBuilder.toString(); - } finally { - try { - reader.close(); - } catch(IOException ignord) {} - } - } - - public static FilesList writeFile( - final File file, - final CharSequence string) throws IOException { - return writeFile(file, string, Charset.defaultCharset().name(), false); - } - - public static FilesList writeFile( - final File file, - final CharSequence string, - final String charset) throws IOException { - return writeFile(file, string, charset, false); - } - - public static FilesList appendFile( - final File file, - final CharSequence string) throws IOException { - return writeFile(file, string, Charset.defaultCharset().name(), true); - } - - public static FilesList appendFile( - final File file, - final CharSequence string, - final String charset) throws IOException { - return writeFile(file, string, charset, true); - } - - public static FilesList writeFile( - final File file, - final CharSequence string, - final boolean append) throws IOException { - return writeFile( - file, - string, - Charset.defaultCharset().name(), - append); - } - - public static FilesList writeFile( - final File file, - final CharSequence string, - final String charset, - final boolean append) throws IOException { - return writeFile( - file, - new ByteArrayInputStream(string.toString().getBytes(charset)), - append); - } - - public static FilesList writeFile( - final File file, - final InputStream input) throws IOException { - return writeFile(file, input, false); - } - - public static FilesList appendFile( - final File file, - final InputStream input) throws IOException { - return writeFile(file, input, true); - } - - public static FilesList writeFile( - final File file, - final InputStream input, - final boolean append) throws IOException { - final FilesList list = new FilesList(); - - if (!exists(file)) { - if (!exists(file.getParentFile())) { - list.add(mkdirs(file.getParentFile())); - } - - file.createNewFile(); - list.add(file); - } - - FileOutputStream output = null; - try { - output = new FileOutputStream(file, append); - StreamUtils.transferData(input, output); - } finally { - if (output != null) { - try { - output.close(); - } catch (IOException e) { - ErrorManager.notifyDebug(ResourceUtils.getString( - FileUtils.class, ERROR_CLOSE_STREAM_KEY), - e); - } - } - } - - return list; - } - - public static String readFirstLine( - final File file) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - try { - return reader.readLine(); - } finally { - try { - reader.close(); - } catch (IOException ignord) {} - } - } - public static List readStringList( - final File file, String charset) throws IOException { - final List list = new ArrayList(); - for (String line: StringUtils.splitByLines((readFile(file,charset)))) { - list.add(line); - } - return list; - } - public static List readStringList( - final File file) throws IOException { - final List list = new ArrayList(); - for (String line: StringUtils.splitByLines((readFile(file)))) { - list.add(line); - } - return list; - } - - public static FilesList writeStringList( - final File file, - final List list) throws IOException { - return writeStringList(file, list, Charset.defaultCharset().name(), false); - } - - public static FilesList writeStringList( - final File file, - final List list, - final String charset) throws IOException { - return writeStringList(file, list, charset, false); - } - - public static FilesList writeStringList( - final File file, - final List list, - final boolean append) throws IOException { - return writeStringList(file, list, Charset.defaultCharset().name(), append); - } - - public static FilesList writeStringList( - final File file, - final List list, - final String charset, - final boolean append) throws IOException { - StringBuilder builder = new StringBuilder(); - - for(int i=0;i getRecursiveFileSet( - final File file) throws IOException { - Set fileSet = new HashSet<>(); - - if (file != null && exists(file)) { - computeRecursiveFileSet(file,fileSet); - } - - return fileSet; - } - - static void computeRecursiveFileSet(final File file, Set fileSet) throws IOException { - try { - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (files != null) { - if (files.length > 0) { - fileSet.add(file); - } - for (File f : files) { - computeRecursiveFileSet(f,fileSet); - } - } - } else { - fileSet.add(file); - } - } catch (SecurityException e) { - ErrorManager.notifyError( - ResourceUtils.getString(FileUtils.class, - ERROR_FILE_SECURITY_EXCEPTION_KEY, file), - e); - } - } - - public static FilesList listFiles( - final File file) throws IOException { - final FilesList list = new FilesList(); - - if (file != null && exists(file)) { - try { - list.add(file); - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (files != null) { - for (File f : files) { - list.add(listFiles(f)); - } - } - } - } catch (SecurityException e) { - ErrorManager.notifyError( - ResourceUtils.getString(FileUtils.class, - ERROR_FILE_SECURITY_EXCEPTION_KEY, file), - e); - } - } - - return list; - } - - public static long getFreeSpace( - final File file) { - long freeSpace = 0; - - try { - freeSpace = SystemUtils.getNativeUtils().getFreeSpace(file); - } catch (NativeException e) { - ErrorManager.notifyError(ResourceUtils.getString( - FileUtils.class, ERROR_CANT_GET_FREE_SPACE_KEY, file), - e); - } - - return freeSpace; - } - - public static long getCrc32(final File file) throws IOException { - InputStream input = null; - try { - input = new FileInputStream(file); - return getCrc32(input); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException ignord) {} - } - } - } - public static long getCrc32(final InputStream input) throws IOException { - CRC32 crc = new CRC32(); - final byte[] buffer = new byte[BUFFER_SIZE]; - int readLength; - while ((readLength = input.read(buffer)) != -1) { - crc.update(buffer, 0, readLength); - } - return crc.getValue(); - } - - public static String getMd5( - final File file) throws IOException { - return StringUtils.asHexString(getMd5Bytes(file)); - } - public static String getMd5( - final InputStream input) throws IOException { - return StringUtils.asHexString(getMd5Bytes(input)); - } - - public static byte[] getMd5Bytes( - final File file) throws IOException { - try { - return getDigestBytes(file, MD5_DIGEST_NAME); - } catch (NoSuchAlgorithmException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - FileUtils.class, ERROR_MD5_NOT_SUPPORTED_KEY), e); - } - - return null; - } - public static byte[] getMd5Bytes( - final InputStream input) throws IOException { - try { - return getDigestBytes(input, MD5_DIGEST_NAME); - } catch (NoSuchAlgorithmException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - FileUtils.class, ERROR_MD5_NOT_SUPPORTED_KEY), e); - } - - return null; - } - public static String getSha1( - final File file) throws IOException { - return StringUtils.asHexString(getSha1Bytes(file)); - } - - public static byte[] getSha1Bytes( - final File file) throws IOException { - try { - return getDigestBytes(file, SHA1_DIGEST_NAME); - } catch (NoSuchAlgorithmException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - FileUtils.class, ERROR_SHA1_NOT_SUPPORTED_KEY), e); - } - - return null; - } - - public static byte[] getDigestBytes( - final File file, - final String algorithm) throws IOException, NoSuchAlgorithmException { - InputStream input = null; - try { - input = new FileInputStream(file); - return getDigestBytes(input, algorithm); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException ex) { - LogManager.log(ex); - } - } - } - } - - public static byte[] getDigestBytes( - final InputStream input, - final String algorithm) throws IOException, NoSuchAlgorithmException { - MessageDigest md = MessageDigest.getInstance(algorithm); - md.reset(); - - final byte[] buffer = new byte[BUFFER_SIZE];//todo: here was 10240?? discus - int readLength; - while ((readLength = input.read(buffer)) != -1) { - md.update(buffer, 0, readLength); - } - - return md.digest(); - } - - public static boolean isEmpty( - final File file) { - if (!exists(file)) { - return true; - } - - if (file.isDirectory()) { - File [] list = file.listFiles(); - if (list != null) { - for(File child : list) { - if (!isEmpty(child)) { - return false; - } - } - } - return true; - } else { - return false; - } - } - - public static boolean canRead( - final File file) { - return canAccessFile(file,true); - } - - public static boolean canWrite( - final File file) { - return canAccessFile(file,false); - } - - public static boolean isJarFile( - final File file) { - if (file.getName().endsWith(JAR_EXTENSION)) { - JarFile jar = null; - try { - jar = new JarFile(file); - return true; - } catch (IOException e) { - ErrorManager.notifyDebug( - ResourceUtils.getString(FileUtils.class, - ERROR_NOT_JAR_FILE_KEY, file), - e); - return false; - } finally { - if (jar != null) { - try { - jar.close(); - } catch (IOException e) { - ErrorManager.notifyDebug( - ResourceUtils.getString( - FileUtils.class, ERROR_CANT_CLOSE_JAR_KEY, - jar.getName()), - e); - } - } - } - } else { - return false; - } - } - - public static boolean isSigned( - final File file) throws IOException { - JarFile jar = new JarFile(file); - - try { - Enumeration entries = jar.entries(); - boolean signatureInfoPresent = false; - boolean signatureFilePresent = false; - while (entries.hasMoreElements()) { - String entryName = entries.nextElement().getName(); - if (entryName.startsWith("META-INF/")) { - if (entryName.endsWith(".RSA") || entryName.endsWith(".DSA")) { - signatureFilePresent = true; - if(signatureInfoPresent) { - break; - } - } else if (entryName.endsWith(".SF")) { - signatureInfoPresent = true; - if(signatureFilePresent) { - break; - } - } - } - } - return signatureFilePresent && signatureInfoPresent; - } finally { - jar.close(); - } - } - - public static boolean exists( - final File file) { - if (file.exists()) { - return true; - } else if (!file.isFile() && !file.isDirectory()) { - final File parent = file.getParentFile(); - if ((parent == null) || !parent.exists()) { - return false; - } - - final File[] children = parent.listFiles(); - if (children == null) { - return false; - } - - for (File child: children) { - if (child.equals(file)) { - return true; - } - } - } - - return false; - } - - public static boolean isParent( - final File candidate, - final File file) { - File parent = file.getParentFile(); - - while ((parent != null) && !candidate.equals(parent)) { - parent = parent.getParentFile(); - } - - return (parent != null) && candidate.equals(parent); - } - - public static File getRoot( - final File fileRequested, - final List roots) { - File result = null; - File file = fileRequested; - try { - file = file.getCanonicalFile(); - } catch (IOException e) { - LogManager.log("... cannot get canonical file for " + file); - } - for (File root: roots) { - if (isParent(root, file) || root.equals(file)) { - if(result == null || - (result.getAbsolutePath().length() < - root.getAbsolutePath().length())) { - result = root; - } - } - } - if(result == null) { - if(SystemUtils.isWindows() && FileUtils.isUNCPath(file.getPath())) { - return getRoot(file); - } - } - return result; - } - - public static long countChildren( - final File file) { - long count = 0; - - if (!file.exists()) { - return 0; - } else { - count++; - } - - final File[] children = file.listFiles(); - if (children != null) { - for (File child: children) { - count += countChildren(child); - } - } - - return count; - } - - // in-file string replacement /////////////////////////////////////////////////// - public static void modifyFile( - final File file, - final String token, - final Object replacement) throws IOException { - modifyFile(file, token, replacement, false, Charset.defaultCharset().name()); - } - public static void modifyFile( - final File file, - final String token, - final Object replacement, - final String charset) throws IOException { - modifyFile(file, token, replacement, false, charset); - } - - public static void modifyFile( - final File file, - final String token, - final Object replacement, - final boolean regexp) throws IOException { - modifyFile(file, token, replacement, regexp, Charset.defaultCharset().name()); - } - - public static void modifyFile( - final File file, - final String token, - final Object replacement, - final boolean regexp, - final String charset) throws IOException { - final Map replacementMap = new HashMap(); - - replacementMap.put(token, replacement); - - modifyFile(file, replacementMap, regexp, charset); - } - - public static void modifyFile( - final File file, - final Map map) throws IOException { - modifyFile(file, map, false); - } - - public static void modifyFile( - final File file, - final Map map, - final boolean regexp) throws IOException { - modifyFile(file, map,regexp, Charset.defaultCharset().name()); - } - public static void modifyFile( - final File file, - final Map map, - final boolean regexp, - final String charset) throws IOException { - if (!exists(file)) { - return; - } - - if (file.isDirectory()) { - for (File child: file.listFiles()) { - modifyFile(child, map, regexp, charset); - } - } else { - // if the file is larger than 100 Kb - skip it - if (file.length() > 1024*100) { - return; - } - - final String original = readFile(file, charset); - - String modified = new String(original); - for(Map.Entry entry : map.entrySet()) { - final Object object = entry.getValue(); - String token = entry.getKey(); - - final String replacement; - if (object instanceof File) { - replacement = ((File) object).getAbsolutePath(); - } else { - replacement = object.toString(); - } - - if (regexp) { - modified = Pattern. - compile(token, Pattern.MULTILINE). - matcher(modified). - replaceAll(replacement); - } else { - modified = modified.replace(token, replacement); - } - } - - if (!modified.equals(original)) { - LogManager.log("modifying file: " + file.getAbsolutePath()); - - writeFile(file, modified, charset); - } - } - } - - public static void modifyFiles( - final List files, - final Map map, - final boolean regexp) throws IOException { - modifyFiles(files, map, regexp, new Progress()); - } - - public static void modifyFiles( - final List files, - final Map map, - final boolean regexp, - final Progress progress) throws IOException { - progress.setPercentage(Progress.START); - - for (int i = 0; i < files.size(); i++) { - modifyFile(files.get(i), map, regexp); - - progress.setPercentage(Progress.COMPLETE * i / files.size()); - } - - progress.setPercentage(Progress.COMPLETE); - } - - // file operations ////////////////////////////////////////////////////////////// - public static void deleteFile( - final File file) throws IOException { - deleteFile(file, false); - } - - public static void deleteFile( - final File file, - final Progress progress) throws IOException { - deleteFile(file, false, progress); - } - - public static void deleteFile( - final File file, - final boolean recurse) throws IOException { - deleteFile(file, recurse, new Progress()); - } - - public static void deleteFile( - final File file, - final boolean recurse, - final Progress progress) throws IOException { - final long childrenCount; - if (recurse) { - childrenCount = countChildren(file); - } else { - childrenCount = 1; - } - - deleteFile( - file, - recurse, - progress, - 0, - childrenCount == 0 ? 1 : childrenCount); - progress.setPercentage(Progress.COMPLETE); - } - - public static void deleteFiles( - final List files) throws IOException { - deleteFiles(files, new Progress()); - } - - public static void deleteFiles( - final List files, - final Progress progress) throws IOException { - long count = 0; - - for (File file: files) { - count = deleteFile(file, false, progress, count, files.size()); - } - progress.setPercentage(Progress.COMPLETE); - } - - public static void deleteFiles( - final File... files) throws IOException { - deleteFiles(new Progress(), files); - } - - public static void deleteFiles( - final Progress progress, - final File... files) throws IOException { - deleteFiles(Arrays.asList(files), progress); - } - - public static void deleteFiles( - final FilesList files) throws IOException { - deleteFiles(files, new Progress()); - } - - public static void deleteFiles( - final FilesList files, - final Progress progress) throws IOException { - long count = 0; - - for (FileEntry entry: files) { - count = deleteFile( - entry.getFile(), false, progress, count, files.getSize()); - } - progress.setPercentage(Progress.COMPLETE); - } - - public static void deleteEmptyParents( - final File file) throws IOException { - if (!exists(file)) { - final File parent = file.getParentFile(); - - if (isEmpty(parent)) { - deleteWithEmptyParents(parent); - } - } - } - - public static void deleteWithEmptyParents( - final File file) throws IOException { - if (file == null) { - return; - } - - File probe = file; - do { - deleteFile(probe); - probe = probe.getParentFile(); - } while ((probe != null) && isEmpty(probe)); - } - - public static void deleteOnExit( - final File file) { - SystemUtils.getNativeUtils().addDeleteOnExitFile(file); - } - - public static File createTempFile( - ) throws IOException { - return createTempFile(SystemUtils.getTempDirectory()); - } - - public static File createTempFile( - final File parent) throws IOException { - return createTempFile(parent, true); - } - - public static File createTempFile( - final File parent, - final boolean create) throws IOException { - return createTempFile(parent, create, false); - } - - public static File createTempFile( - final File parent, - final boolean create, - final boolean directory) throws IOException { - final File file = File.createTempFile("nbi-", ".tmp", parent); - - if (!create || directory) { - file.delete(); - } - if (create && directory) { - mkdirs(file); - } - - file.deleteOnExit(); - - return file; - } - - public static FilesList copyFile( - final File source, - final File target) throws IOException { - return copyFile(source, target, false); - } - - public static FilesList copyFile( - final File source, - final File target, - final Progress progress) throws IOException { - return copyFile(source, target, false, progress); - } - - public static FilesList copyFile( - final File source, - final File target, - final boolean recurse) throws IOException { - return copyFile(source, target, recurse, new Progress()); - } - - public static FilesList copyFile( - final File source, - final File target, - final boolean recurse, - final Progress progress) throws IOException { - final FilesList list = new FilesList(); - - final long childrenCount; - if (recurse) { - childrenCount = countChildren(source); - } else { - childrenCount = 1; - } - - copyFile( - source, - target, - recurse, - list, - progress, - 0, - childrenCount == 0 ? 1 : childrenCount, - false); - progress.setPercentage(Progress.COMPLETE); - - return list; - } - - /** - * Special method for copying nested JRE - #256122 - 8.1 RC2 IDE will not start unless run as admin - * - * @param source Source JRE folder - * @param target Targer folder (in \bin\jre\) - * @param progress - * @return - * @throws IOException - */ - public static FilesList copyNestedJRE(final File source, final File target, final Progress progress) throws IOException { - final FilesList list = new FilesList(); - - copyFile(source, target, true, list, progress, 0, countChildren(source), true); - progress.setPercentage(Progress.COMPLETE); - - return list; - } - - public static FilesList moveFile( - final File source, - final File target) throws IOException { - return moveFile(source, target, new Progress()); - } - - public static FilesList moveFile( - final File source, - final File target, - final Progress progress) throws IOException { - final FilesList list = new FilesList(); - - progress.setDetail(StringUtils.format( - MESSAGE_MOVING, source, target)); - if (!source.renameTo(target)) { - final CompositeProgress composite = new CompositeProgress(); - final Progress copyProgress = new Progress(); - final Progress deleteProgress = new Progress(); - - composite.synchronizeTo(progress); - composite.addChild(copyProgress, 80); - composite.addChild(deleteProgress, 20); - - list.add(copyFile( - source, - target, - true, - copyProgress)); - - deleteFile( - source, - true, - deleteProgress); - } else { - list.add(target); - } - progress.setPercentage(Progress.COMPLETE); - - return list; - } - - // archive operations /////////////////////////////////////////////////////////// - public static void zip( - final File file, - final ZipOutputStream output, - final File root, - final List excludes) throws IOException { - if (excludes.contains(file)) { - return; - } - - final String entryName = file.getAbsolutePath().substring( - root.getAbsolutePath().length() + 1); - - if (file.isDirectory()) { - output.putNextEntry(new ZipEntry(entryName + SLASH)); - - final File[] children = file.listFiles(); - if (children != null) { - for (File child: children) { - zip(child, output, root, excludes); - } - } - } else { - output.putNextEntry(new ZipEntry(entryName)); - StreamUtils.transferFile(file, output); - } - } - - public static FilesList unzip( - final File source, - final File target) throws IOException { - return extractAll(source, target, null, new Progress()); - } - - public static FilesList unzip( - final File source, - final File target, - final Progress progress) throws IOException { - return extractAll(source, target, null, progress); - } - - public static FilesList unjar( - final File source, - final File target) throws IOException, XMLException { - return unjar(source, target, new Progress()); - } - - public static FilesList unjar( - final File source, - final File target, - final Progress progress) throws IOException, XMLException { - return extractAll(source, target, METAINF_MASK, progress); - } - - public static boolean zipEntryExists( - final File file, - final String entry) throws IOException { - ZipFile zip = new ZipFile(file); - - try { - return zip.getEntry(entry) != null; - } finally { - zip.close(); - } - } - - public static boolean jarEntryExists( - final File file, - final String entry) throws IOException { - JarFile jar = new JarFile(file); - - try { - return jar.getEntry(entry) != null; - } finally { - jar.close(); - } - } - - public static File extractJarEntry( - final String entry, - final File source) throws IOException { - return extractJarEntry(entry, source, FileUtils.createTempFile()); - } - - public static File extractJarEntry( - final String entry, - final File source, - final File target) throws IOException { - JarFile jar = new JarFile(source); - FileOutputStream out = new FileOutputStream(target); - - try { - StreamUtils.transferData(jar.getInputStream(jar.getEntry(entry)), out); - - return target; - } finally { - jar.close(); - out.close(); - } - } - - public static String getJarAttribute( - final File file, - final String name) throws IOException { - JarFile jar = new JarFile(file); - - try { - return jar.getManifest().getMainAttributes().getValue(name); - } finally { - try { - jar.close(); - } catch (IOException e) { - ErrorManager.notifyDebug(ResourceUtils.getString( - FileUtils.class, ERROR_CANT_CLOSE_JAR_KEY, jar.getName()), e); - } - } - } - - // miscellaneous //////////////////////////////////////////////////////////////// - public static FilesList mkdirs( - final File file) throws IOException { - FilesList list = new FilesList(); - - if (exists(file)) { - if (file.isFile()) { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_CANT_CREATE_DIR_EXIST_FILE_KEY, file)); - } - } else { - final File parent = file.getParentFile(); - if (parent != null && !exists(parent)) { - list.add(mkdirs(parent)); - } - - if (file.mkdir()) { - list.add(file); - } else { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_CANT_CREATE_DIR_KEY, file)); - } - } - - return list; - } - - public static String getRelativePath( - final File source, - final File target) { - String path; - - if (source.equals(target)) { // simplest - source equals target - path = source.isDirectory() ? CURRENT : target.getName(); - } else if (isParent(source, target)) { // simple - source is target's parent - final String sourcePath = - source.getAbsolutePath().replace(BACKSLASH, SLASH); - final String targetPath = - target.getAbsolutePath().replace(BACKSLASH, SLASH); - - if (sourcePath.endsWith(SLASH)) { - path = targetPath.substring(sourcePath.length()); - } else { - path = targetPath.substring(sourcePath.length() + 1); - } - } else if (isParent(target, source)) { // simple - target is source's parent - path = source.isDirectory() ? PARENT : CURRENT; - - File parent = source.getParentFile(); - while (!parent.equals(target)) { - path += SLASH + PARENT; - parent = parent.getParentFile(); - } - } else { // tricky - the files are unrelated - // first we need to find a common parent for the files - File parent = source.getParentFile(); - while ((parent != null) && !isParent(parent, target)) { - parent = parent.getParentFile(); - } - - // if there is no common parent, we cannot deduct a relative path - if (parent == null) { - return null; - } - - path = getRelativePath(source, parent) + - SLASH + - getRelativePath(parent, target); - } - - // some final beautification - if (path.startsWith(CURRENT + SLASH)) { - if (path.length() > 2) { - path = path.substring(2); - } else { - path = path.substring(0, 1); - } - } - path = path.replace(SLASH + CURRENT + SLASH, SLASH); - - return path; - } - - public static File getNormalizedPathFile(File file) { - if (file != null && !file.getPath().isEmpty()) { - try { - Path path = FileSystems.getDefault().getPath(file.getPath()); - - if (path != null) { - return path.normalize().toFile(); - } - } catch(InvalidPathException ex) { - LogManager.log("Trying to normalize invalid path", ex); - } - } - - return file; - } - - public static boolean isUNCPath(String path) { - return SystemUtils.getNativeUtils().isUNCPath(path); - } - - public static File eliminateRelativity( - final String path) { - String corrected = path; - - if(SystemUtils.isWindows() && isUNCPath(corrected)) { - // don`t correct UNC paths that starts with \\ - corrected = corrected.substring(0,2) + - corrected.substring(2).replace(BACKSLASH, SLASH); - } else { - corrected = corrected.replace(BACKSLASH, SLASH); - } - - while (corrected.indexOf(SLASH + SLASH) != -1) { - corrected = corrected.replace(SLASH + SLASH, SLASH); - } - - while (corrected.indexOf(SLASH + CURRENT + SLASH) != -1) { - corrected = corrected.replace(SLASH + CURRENT + SLASH, SLASH); - } - - final Pattern pattern = Pattern.compile("(\\/([^\\/]+)\\/\\.\\.\\/)"); - - Matcher matcher = pattern.matcher(corrected); - while (matcher.find()) { - if (matcher.group(2).equals(PARENT)) { - continue; - } else { - corrected = corrected.replace(matcher.group(), SLASH); - matcher = pattern.matcher(corrected); - } - } - - if (corrected.endsWith(SLASH + CURRENT)) { - corrected = corrected.substring( - 0, - corrected.length() - SLASH.length() - CURRENT.length()); - } - - if (corrected.endsWith(SLASH + PARENT)) { - int index = corrected.lastIndexOf( - SLASH, - corrected.length() - SLASH.length() - PARENT.length() - 1); - if (index != -1) { - corrected = corrected.substring(0, index); - } - } - - return new File(corrected); - } - - public static File getRoot( - final File file) { - return SystemUtils.getNativeUtils().getRoot(file); - } - - public static File findFile( - final File directory, - final String filename) { - if (directory.getName().equals(filename)) { - return directory; - } - - final File[] children = directory.listFiles(); - if (children != null) { - for (File child: children) { - final File match = findFile(child, filename); - - if (match != null) { - return match; - } - } - } - - return null; - } - - // private ////////////////////////////////////////////////////////////////////// - private static long deleteFile( - final File file, - final boolean recurse, - final Progress progress, - final long start, - final long total) throws IOException { - long count = start; - - if (SystemUtils.isDeletingAllowed(file)) { - final boolean isDir = file.isDirectory(); - final String type = (isDir) ? "directory" : "file"; - if (isDir && recurse) { - final File[] children = file.listFiles(); - if (children != null) { - for (File child: children) { - count = deleteFile(child, true, progress, count, total); - } - } - } - - LogManager.log("deleting " + type + ": " + file); - - progress.setDetail(StringUtils.format( - isDir ? MESSAGE_DELETE_DIR : MESSAGE_DELETE_FILE, file)); - - if (!exists(file)) { - LogManager.log(" ... " + type + " does not exist"); - SystemUtils.getNativeUtils().removeDeleteOnExitFile(file); - } else { - if (!file.delete()) { - deleteOnExit(file); - } - } - - count++; - progress.setPercentage(Progress.COMPLETE * count / total); - } - - return count; - } - - private static long copyFile( - final File source, - final File target, - final boolean recurse, - final FilesList list, - final Progress progress, - final long start, - final long total, - final boolean copyNesteJre) throws IOException { - long count = start; - - if (!exists(source)) { - LogManager.log(" ... " + source + " does not exist"); - return count; - } - - if (source.isFile()) { - LogManager.log("copying file: " + source + " to: " + target); - progress.setDetail(StringUtils.format(MESSAGE_COPY_FILE, source,target)); - - if (!source.canRead()) { - throw new IOException(ResourceUtils.getString( - FileUtils.class, ERROR_SOURCE_NOT_READABLE_KEY, source)); - } - - if (exists(target) && !target.isFile()) { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_DEST_NOT_FILE_KEY, target)); - } - - File parent = target.getParentFile(); - if (!exists(parent)) { - list.add(mkdirs(parent)); - } - - if (!exists(target) && !target.createNewFile()) { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_DEST_CREATION_KEY, target)); - } - - if (!target.canWrite()) { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_DEST_NOT_WRITABLE_KEY, target)); - } - - if (copyNesteJre && SystemUtils.isWindows()) { - InputStream is = null; - OutputStream os = null; - try { - is = new FileInputStream(source); - os = new FileOutputStream(target); - byte[] buffer = new byte[1024]; - int length; - while ((length = is.read(buffer)) > 0) { - os.write(buffer, 0, length); - } - } finally { - is.close(); - os.close(); - } - } else { - Files.copy(source.toPath(), target.toPath(), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS); - } - list.add(target); - } else { - LogManager.log("copying directory: " + source + " to: " + target + (recurse ? " with recursion" : "")); - progress.setDetail(StringUtils.format(MESSAGE_COPY_DIRECTORY, source, target)); - - list.add(mkdirs(target)); - if (recurse) { - for (File file : source.listFiles()) { - count = copyFile(file, new File(target, file.getName()), recurse, list, progress, count, total, copyNesteJre); - } - } - } - - count++; - progress.setPercentage(Progress.COMPLETE * count / total); - - return count; - } - - private static boolean canAccessDirectoryReal( - final File file, - final boolean isReadNotWrite) { - if (isReadNotWrite) { - boolean result = (file.listFiles()!=null); - // LogManager.indent(); - // LogManager.log(ErrorLevel.DEBUG, "READ: Real Level Access DIR: " + ((result) ? "TRUE" : "FALSE")); - // LogManager.unindent(); - return result; - } else { - try { - FileUtils.createTempFile(file).delete(); - // LogManager.indent(); - // LogManager.log(ErrorLevel.DEBUG, "WRITE: Real Level Access DIR: TRUE"); - // LogManager.unindent(); - return true; - } catch (IOException e) { - // LogManager.indent(); - // LogManager.log(ErrorLevel.DEBUG, "WRITE: Real Level Access DIR: FALSE"); - // LogManager.unindent(); - return false; - } - } - } - - private static boolean canAccessFileReal( - final File file, - final boolean isReadNotWrite) { - Closeable stream = null; - LogManager.indent(); - try { - stream = (isReadNotWrite) ? new FileInputStream(file) : - new FileOutputStream(file) ; - //LogManager.log(ErrorLevel.DEBUG, - // ((isReadNotWrite) ? "READ:" : "WRITE:") + "Real Level Access File: TRUE"); - return true; - } catch (IOException ex) { - //LogManager.log(ErrorLevel.DEBUG, - // ((isReadNotWrite) ? "READ:" : "WRITE:") + "Real Level Access File: FALSE"); - return false; - } finally { - LogManager.unindent(); - if (stream!=null) { - try { - stream.close(); - } catch (IOException ex) { - LogManager.log(ex); - } - } - } - } - - private static boolean canAccessFile( - final File fileToCheck, - final boolean isReadNotWrite) { - File file = fileToCheck; - - // if file doesn`t exist then get it existing parent - if (!exists(file)) { - File parent = file; - do { - parent = parent.getParentFile(); - } while ((parent != null) && !exists(parent)); - - if ((parent == null) || !parent.isDirectory()) { - return false; - } else { - file = parent; - } - } - - //first of all check java implementation - boolean javaAccessCheck = (isReadNotWrite) ? file.canRead() : file.canWrite(); - - // don`t treat read-only attributes for directories as "can`t write" on windows - if (SystemUtils.isWindows() && !isReadNotWrite && file.isDirectory()) { - javaAccessCheck = true; - } - - if (javaAccessCheck) { - boolean result = true; - boolean needCheckDirectory = true; - - try { - // Native checking - result = SystemUtils.getNativeUtils().checkFileAccess(file, isReadNotWrite); - - if (!isReadNotWrite) { - // we don`t want to check for writing if OS says smth specific - needCheckDirectory = false; - } - } catch (NativeException ex) { - // most probably there is smth wrong with OS - LogManager.log(ex); - } - - if (!result) { // some limitations by OS - return false; - } - - if (file.isFile()) { - return canAccessFileReal(file, isReadNotWrite); - } else if (file.isDirectory() && (needCheckDirectory)) { - return canAccessDirectoryReal(file, isReadNotWrite); - } else { // file is directory, access==read || (access==write & OSCheck==true) - return true; - } - } else { - return false; - } - } - - private static FilesList extractAll( - final File file, - final File target, - final String excludes, - final Progress progress) throws IOException { - final FilesList list = new FilesList(); - - // first some basic validation of the destination directory - if (exists(target) && target.isFile()) { - throw new IOException(ResourceUtils.getString(FileUtils.class, - ERROR_UNJAR_TODIR_KEY, target)); - } else if (!exists(target)) { - list.add(mkdirs(target)); - } - - final ZipFile zip = new ZipFile(file); - - try { - FilesList extracted = null; - boolean extractedWithList = false; - - // first we try to extract with the given list - if (zipEntryExists(file, FILES_LIST_ENTRY)) { - try { - final File initialList = - extractJarEntry(FILES_LIST_ENTRY, file); - final FilesList toExtract = - new FilesList().loadXml(initialList, target); - - deleteFile(initialList); - extracted = extractByList(zip, target, toExtract, progress); - toExtract.clear(); - - extractedWithList = true; - } catch (XMLException e) { - ErrorManager.notifyDebug( - ResourceUtils.getString(FileUtils.class, - ERROR_LOAD_XML_FILE_LIST_KEY), - e); - } - } - - if (!extractedWithList) { - extracted = extractNormal(zip, target, excludes, progress); - } - - list.add(extracted); - extracted.clear(); - } finally { - zip.close(); - } - - return list; - } - - private static FilesList extractByList( - final ZipFile zip, - final File target, - final FilesList list, - final Progress progress) throws IOException { - final FilesList newList = new FilesList(); - final String targetPath = target.getAbsolutePath(); - - final int total = list.getSize(); - - int extracted = 0; - for (FileEntry listEntry: list) { - // check for cancel status - if (progress.isCanceled()) return newList; - - final String listEntryName = listEntry.getName(); - final File listEntryFile = listEntry.getFile(); - - final String zipEntryName = - listEntryName.substring(targetPath.length() + 1); - - // increase the extracted files count and update the progress percentage - extracted++; - progress.setPercentage(Progress.COMPLETE * extracted / total); - - // set the progress detail and add a log entry - progress.setDetail(StringUtils.format(MESSAGE_EXTRACTING, listEntryFile)); - LogManager.log("extracting " + listEntryFile); - - if (listEntry.isDirectory()) { - newList.add(mkdirs(listEntryFile)); - } else { - final ZipEntry zipEntry = zip.getEntry(zipEntryName); - - newList.add(mkdirs(listEntryFile.getParentFile())); - - // actual data transfer - InputStream in = null; - OutputStream out = null; - try { - in = zip.getInputStream(zipEntry); - out = new FileOutputStream(listEntryFile); - - StreamUtils.transferData(in, out); - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } - - listEntryFile.setLastModified(listEntry.getLastModified()); - - SystemUtils.setPermissions( - listEntry.getFile(), - listEntry.getPermissions(), - NativeUtils.FA_MODE_SET); - } - - newList.add(listEntry); - } - - return newList; - } - - private static FilesList extractNormal( - final ZipFile zip, - final File target, - final String excludes, - final Progress progress) throws IOException { - final FilesList list = new FilesList(); - - Enumeration entries; - - int total = 0; - int extracted = 0; - - // then we count the entries, to correctly display progress - entries = (Enumeration) zip.entries(); - while (entries.hasMoreElements()) { - total++; - entries.nextElement(); - } - - // and only after that we actually extract them - entries = (Enumeration) zip.entries(); - while (entries.hasMoreElements()) { - // check for cancel status - if (progress.isCanceled()) return list; - - final ZipEntry entry = entries.nextElement(); - - // increase the extracted files count and update the progress percentage - extracted++; - progress.setPercentage(Progress.COMPLETE * extracted / total); - - // if the entry name matches the excludes pattern, we skip it - if ((excludes != null) && entry.getName().matches(excludes)) { - continue; - } - - // create the target file for this entry - final File file = new File(target, entry.getName()).getAbsoluteFile(); - - // set the progress detail and add a log entry - progress.setDetail(StringUtils.format(MESSAGE_EXTRACTING, file)); - LogManager.log("extracting " + file); - - if (entry.getName().endsWith(SLASH)) { - // some validation (this is a directory entry and thus an existing - // file will definitely break things) - if (exists(file) && !file.isDirectory()) { - throw new IOException(ResourceUtils.getString( - FileUtils.class, ERROR_OUTPUT_DIR_ENTRY_KEY, file)); - } - - // if the directory does not exist, it will be created and added to - // the extracted files list (if it exists already, it will not - // appear in the list) - if (!exists(file)) { - list.add(mkdirs(file)); - } - } else { - // some validation of the file's parent directory - final File parent = file.getParentFile(); - if (!exists(parent)) { - list.add(mkdirs(parent)); - } - - // some validation of the file itself - if (exists(file) && !file.isFile()) { - throw new IOException(ResourceUtils.getString( - FileUtils.class, ERROR_OUTPUT_FILE_ENTRY_KEY, file)); - } - - // actual data transfer - InputStream in = null; - OutputStream out = null; - try { - in = zip.getInputStream(entry); - out = new FileOutputStream(file); - - StreamUtils.transferData(in, out); - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } - - // as opposed to directories, we always add files to the list, as - // even if they exist, they will be overwritten - list.add(file); - } - - // correct the entry's modification time, so it corresponds to the real - // time of the file in archive - file.setLastModified(entry.getTime()); - } - - return list; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private FileUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final int BUFFER_SIZE = - 65536; // NOMAGI - - public static final String SLASH = - "/"; // NOI18N - public static final String BACKSLASH = - "\\"; // NOI18N - public static final String METAINF_MASK = - "META-INF.*"; // NOI18N - - public static final String JAR_EXTENSION = - ".jar"; // NOI18N - public static final String PROPERTIES_EXTENSION = - ".properties"; // NOI18N - public static final String PACK_GZ_SUFFIX = - ".pack.gz"; // NOI18N - public static final String SUN_MICR_RSA = - "META-INF/SUN_MICR.RSA"; // NOI18N - public static final String SUN_MICR_SF = - "META-INF/SUN_MICR.SF"; // NOI18N - public static final String FILES_LIST_ENTRY = - "META-INF/files.list";//NOI18N - public static final String CURRENT = - "."; // NOI18N - public static final String PARENT = - ".."; // NOI18N - public static final String SHA1_DIGEST_NAME = - "SHA1";//NOI18N - public static final String MD5_DIGEST_NAME = - "MD5";//NOI18N - public static final String INFO_PLIST_STUB = - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " CFBundleName\n" + - " {0}\n" + - " \n" + - " CFBundleVersion\n" + - " {1}\n" + - " \n" + - " CFBundleExecutable\n" + - " {3}\n" + - " \n" + - " CFBundlePackageType\n" + - " APPL\n" + - " \n" + - " CFBundleShortVersionString\n" + - " {2}\n" + - " \n" + - " CFBundleSignature\n" + - " ????\n" + - " \n" + - " CFBundleInfoDictionaryVersion\n" + - " 6.0\n" + - " \n" + - " CFBundleIconFile\n" + - " {4}\n" + - " \n" + - "\n"; - - - - public static final String ERROR_OUTPUT_FILE_ENTRY_KEY = - "FU.error.output.file.entry";// NOI18N - - public static final String ERROR_OUTPUT_DIR_ENTRY_KEY = - "FU.error.output.dir.entry";// NOI18N - public static final String MESSAGE_MOVING = - ResourceUtils.getString(FileUtils.class, - "FU.message.moving");//NOI18N - public static final String MESSAGE_EXTRACTING = - ResourceUtils.getString(FileUtils.class, - "FU.message.extracting");//NOI18N - public static final String ERROR_LOAD_XML_FILE_LIST_KEY = - "FU.error.load.xml.file.list";//NOI18N - public static final String ERROR_UNJAR_TODIR_KEY = - "FU.error.unjar.todir";//NOI18N - public static final String MESSAGE_COPY_DIRECTORY = - ResourceUtils.getString(FileUtils.class, - "FU.message.copy.dir");//NOI18N - public static final String MESSAGE_COPY_FILE = - ResourceUtils.getString(FileUtils.class, - "FU.message.copy.file");//NOI18N - public static final String ERROR_CLOSE_STREAM_KEY = - "FU.error.close.stream";//NOI18N - public static final String ERROR_SOURCE_NOT_READABLE_KEY = - "FU.error.source.not.readable";//NOI18N - public static final String ERROR_DEST_NOT_FILE_KEY = - "FU.error.dest.not.file";//NOI18N - public static final String ERROR_DEST_CREATION_KEY = - "FU.error.dest.creation";//NOI18N - public static final String ERROR_DEST_NOT_WRITABLE_KEY = - "FU.error.dest.not.writable";//NOI18N - public static final String ERROR_CANT_GET_FREE_SPACE_KEY = - "FU.error.freespace";//NOI18N - public static final String ERROR_CANT_CLOSE_JAR_KEY = - "FU.error.cannot.close.jar";//NOI18N - public static final String ERROR_CANT_CREATE_DIR_EXIST_FILE_KEY= - "FU.error.cannot.create.dir.exist.file";//NOI18N - public static final String ERROR_CANT_CREATE_DIR_KEY= - "FU.error.cannot.create.dir";//NOI18N - public static final String ERROR_NOT_JAR_FILE_KEY= - "FU.error.not.jar.file";//NOI18N - public static final String ERROR_SHA1_NOT_SUPPORTED_KEY = - "FU.error.sha1.not.supported";//NOI18N - public static final String ERROR_MD5_NOT_SUPPORTED_KEY = - "FU.error.md5.not.supported";//NOI18N - public static final String ERROR_FILE_SECURITY_EXCEPTION_KEY = - "FU.error.file.security.exception";//NOI18N - public static final String MESSAGE_DELETE_FILE = - ResourceUtils.getString(FileUtils.class, - "FU.message.delete.file");//NOI18N - public static final String MESSAGE_DELETE_DIR = - ResourceUtils.getString(FileUtils.class, - "FU.message.delete.dir");//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/LogManager.java b/nbi/engine/src/org/netbeans/installer/utils/LogManager.java deleted file mode 100644 index eee0283d6365..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/LogManager.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringReader; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.utils.helper.ErrorLevel; - -/** - * - * @author Kirill Sorokin - */ -public final class LogManager { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static final int DEFAULT_LOG_LEVEL = - ErrorLevel.DEBUG; - public static final boolean DEFAULT_LOG_TO_CONSOLE = - true; - - private static File logFile; - private static PrintWriter logWriter; - private static int logLevel = DEFAULT_LOG_LEVEL; - private static boolean logToConsole = DEFAULT_LOG_TO_CONSOLE; - - private static int indent; - - private static boolean started = false; - - private static List logCache = new LinkedList(); - - public static synchronized void start() { - // check for custom log level - if (System.getProperty(LOG_LEVEL_PROPERTY) != null) { - try { - logLevel = Integer.parseInt(System.getProperty(LOG_LEVEL_PROPERTY)); - } catch (NumberFormatException e) { - logLevel = DEFAULT_LOG_LEVEL; - } - } else { - logLevel = DEFAULT_LOG_LEVEL; - } - - initializeConsoleLogging(); - - // init the log file and streams - try { - if(logFile!=null) { - logFile.getParentFile().mkdirs(); - if(logFile.exists()) { - logFile.delete(); - } - logFile.createNewFile(); - logWriter = new PrintWriter(new FileWriter(logFile)); - System.setProperty(LOG_FILE_PROPERTY, logFile.getAbsolutePath()); - } - - // here is a small assumption that there will be no calls to log*(*) - // during the cache dumping. Otherwise we'll get a concurrent - // modification exception - for (String string: logCache) { - write(string); - } - logCache.clear(); - } catch (IOException e) { - e.printStackTrace(System.err); - logWriter = null; - } - - started = true; - } - private static void initializeConsoleLogging () { - // check whether we should log to console as well - if (System.getProperty(LOG_TO_CONSOLE_PROPERTY) != null) { - logToConsole = Boolean.parseBoolean(System.getProperty(LOG_TO_CONSOLE_PROPERTY)); - } else { - logToConsole = DEFAULT_LOG_TO_CONSOLE; - } - } - - public static synchronized void stop() { - started = false; - stopFileLog(); - stopConsoleLog(); - } - - private static final void stopConsoleLog() { - // can happen if log manager haven`t started yet - dump to console everything cached - if (!logCache.isEmpty()) { - initializeConsoleLogging(); - if (logToConsole) { - for (String string : logCache) { - try { - write(string); - } catch (IOException e) { - e.printStackTrace(); - } - } - logCache.clear(); - } - } - } - - private static synchronized void stopFileLog() { - if (logWriter != null) { - logWriter.close(); - logWriter = null; - } - } - - public static synchronized void indent() { - indent++; - } - - public static synchronized void unindent() { - indent--; - } - - public static synchronized void log(int level, String message) { - if (level <= logLevel) { - BufferedReader reader = new BufferedReader(new StringReader(message)); - - try { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - String string = - "[" + DateUtils.getFormattedTimestamp() + "]: " + - StringUtils.pad(INDENT, indent) + line; - - if (started) { - write(string); - } else { - logCache.add(string); - } - //System.out.println(message); - } - } catch (IOException e) { - logWriter = null; - ErrorManager.notifyWarning( - ResourceUtils.getString(LogManager.class, - ERROR_CANNOT_WRITE_KEY)); - } - } - } - - public static synchronized void log(int level, Throwable exception) { - log(level, StringUtils.asString(exception)); - } - - public static synchronized void log(int level, Object object) { - log(level, object.toString()); - } - - public static synchronized void log(String message) { - log(ErrorLevel.MESSAGE, message); - } - - public static synchronized void log(Throwable exception) { - log(ErrorLevel.MESSAGE, exception); - } - - public static synchronized void log(Object object) { - log(ErrorLevel.MESSAGE, object); - } - - public static synchronized void log(String message, Throwable exception) { - log(message); - log(exception); - } - - public static synchronized void logEntry(String message) { - final StackTraceElement traceElement = - Thread.currentThread().getStackTrace()[3]; - - log(ErrorLevel.DEBUG, - "entering -- " + - (traceElement.isNativeMethod() ? "[native] " : "") + - traceElement.getClassName() + "." + - traceElement.getMethodName() + "():" + - traceElement.getLineNumber()); - log(ErrorLevel.MESSAGE, message); - indent(); - } - - public static synchronized void logExit(String message) { - StackTraceElement traceElement = Thread.currentThread().getStackTrace()[3]; - - unindent(); - log(message); - log(ErrorLevel.DEBUG, "exiting -- " + - (traceElement.isNativeMethod() ? "[native] " : "") + - traceElement.getClassName() + "." + - traceElement.getMethodName() + "():" + - traceElement.getLineNumber()); - } - - public static synchronized void logIndent(String message) { - log(message); - indent(); - } - - public static synchronized void logUnindent(String message) { - unindent(); - log(message); - } - - public static File getLogFile() { - return logFile; - } - - public static void setLogFile(final File logFile) { - LogManager.logFile = logFile; - } - - // private ////////////////////////////////////////////////////////////////////// - private static void write(String string) throws IOException { - if (logWriter != null) { - logWriter.println(string); - logWriter.flush(); - } - - if (logToConsole) { - System.out.println(string); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private LogManager() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String LOG_LEVEL_PROPERTY = - "nbi.utils.log.level"; // NOI18N - public static final String LOG_TO_CONSOLE_PROPERTY = - "nbi.utils.log.to.console"; // NOI18N - public static final String LOG_FILE_PROPERTY = - "nbi.utils.log.file"; // NOI18N - - public static final String INDENT = - " "; // NOI18N - public static final String ERROR_CANNOT_WRITE_KEY = - "LM.error.cannot.write";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/NetworkUtils.java b/nbi/engine/src/org/netbeans/installer/utils/NetworkUtils.java deleted file mode 100644 index 931b1501eee3..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/NetworkUtils.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.UnknownHostException; -import org.netbeans.installer.utils.helper.ErrorLevel; - -/** - * @author Kirill Sorokin - * @author Dmitry Lipin - */ -class NetworkUtils { - public static String getHostName() { - try { - String hostName = InetAddress.getLocalHost().getHostName(); - if (hostName != null) { - return hostName; - } - } catch (UnknownHostException e) { - LogManager.log(ErrorLevel.MESSAGE, e); - } - - return "localhost"; //NOI18N - } - public static boolean isPortAvailable(int port, int... forbiddenPorts) { - // check whether the port is in the restricted list, if it is, there is no - // sense to check whether it is physically available - for (int forbidden: forbiddenPorts) { - if (port == forbidden) { - return false; - } - } - - // if the port is not in the allowed range - return false - if ((port < 0) && (port > 65535)) { - return false; - } - - // if the port is not in the restricted list, we'll try to open a server - // socket on it, if we fail, then someone is already listening on this port - // and it is occupied - synchronized (Integer.toString(port).intern()) { - ServerSocket socket = null; - try { - socket = new ServerSocket(port); - return true; - } catch (IOException e) { - return false; - } finally { - if (socket != null) { - try { - socket.close(); - } catch (IOException e) { - ErrorManager.notifyError( - "Could not close server socket on port " + port, - e); - } - } - } - } - } - - public static int getAvailablePort(int basePort, int... forbiddenPorts) { - // increment the port value until we find an available port or stumble into - // the upper bound - int port = basePort; - while ((port < 65535) && !isPortAvailable(port, forbiddenPorts)) { - port++; - } - - if (port == 65535) { - port = 0; - while ((port < basePort) && !isPortAvailable(port, forbiddenPorts)) { - port++; - } - - if (port == basePort) { - return -1; - } else { - return port; - } - } else { - return port; - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/ResourceUtils.java b/nbi/engine/src/org/netbeans/installer/utils/ResourceUtils.java deleted file mode 100644 index eed6a3f428d0..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/ResourceUtils.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * - * @author Kirill Sorokin - * @author Dmitry Lipin - */ -public final class ResourceUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - - private static HashMap loadedBundles = - new HashMap(); - - - // strings ////////////////////////////////////////////////////////////////////// - public static String getString(final String baseName, final String key) { - return getString(baseName, key, ResourceUtils.class.getClassLoader()); - } - - public static String getString(final String baseName, final String key, final ClassLoader loader) { - return getBundleMessage(baseName, Locale.getDefault(), loader, key); - } - - public static String getString(final Class clazz, final String key) { - return getBundleMessage(getBundleResource(clazz), Locale.getDefault(), clazz.getClassLoader(), key); - } - - public static String getString( - final String baseName, - final String key, - final Object... arguments) { - return getString(baseName, key, ResourceUtils.class.getClassLoader(), arguments); - } - - public static String getString( - final String baseName, - final String key, - final ClassLoader loader, - final Object... arguments) { - return format(getString(baseName, key, loader), arguments); - } - - public static String getString( - final Class clazz, - final String key, - final Object... arguments) { - return format(getString(clazz, key), arguments); - } - - public static Map getStrings( - final String baseName, - final String key, - final ClassLoader loader, - final Object... arguments) { - Map map = getBundleMessagesMapForKey(baseName, key, loader); - if(arguments.length == 0) { - return map; - } else { - Map result = new HashMap<>(); - map.forEach((locale, name) -> result.put(locale, format(name, arguments))); - return result; - } - } - - public static Map getStrings( - final String baseName, - final String key, - final Object... arguments) { - return getStrings(baseName, key, ResourceUtils.class.getClassLoader(), arguments); - } - - public static Map getStrings( - final Class clazz, - final String key, - final Object... arguments) { - return getStrings(getBundleResource(clazz), key, clazz.getClassLoader(), arguments); - } - - private static String format( - final String message, - final Object... arguments) { - return message == null ? null : StringUtils.format(message, arguments); - } - - // resources //////////////////////////////////////////////////////////////////// - public static InputStream getResource( - final String name) { - return getResource(name, ResourceUtils.class.getClassLoader()); - } - - public static InputStream getResource( - final String path, - final ClassLoader loader) { - return loader.getResourceAsStream(path); - } - - /** - * Returns the size of the resource file. - * @param resource Resource name - * @return size of the resource or - * -1 if the resource was not found or any other error occured - */ - public static long getResourceSize( - final String resource) { - InputStream is = null; - long size = 0; - try { - is = getResource(resource); - if(is==null) { // resource was not found - return -1; - } - byte [] buf = new byte [BUFFER_SIZE]; - while(is.available()>0) { - size += is.read(buf); - } - } catch (IOException ex) { - size = -1; - } finally { - try { - if(is!=null) { - is.close(); - } - } catch (IOException e){ - } - } - return size; - } - - public static String getResourceFileName( - final String resource) { - return resource.substring(resource.lastIndexOf("/")+1); - } - public static String getResourceClassName(Class c) { - return getResourceClassName(c.getName()); - } - public static String getResourceClassName(String className) { - return (className.replace(".", "/") + ".class"); - } - // private ////////////////////////////////////////////////////////////////////// - private static ResourceBundle loadBundle( - final String baseName, - final Locale locale, - final ClassLoader loader) { - final String bundleId = loader.toString() + baseName + - (locale.toString().equals(StringUtils.EMPTY_STRING) ? StringUtils.EMPTY_STRING : ("_" + locale)); - - ResourceBundle bundle = (ResourceBundle) loadedBundles.get(bundleId); - - if (bundle == null && !loadedBundles.containsKey(bundleId)) { - try { - bundle = ResourceBundle.getBundle(baseName, locale, loader); - } catch (MissingResourceException e) { - LogManager.log("Can`t find bundle " + baseName + - " using [" + locale + "] locale" + - " and [" + loader + "] classloader", - e); - //throw e; - } - loadedBundles.put(bundleId, bundle); - } - - return bundle; - } - - private static String getBundleMessage( - final String baseName, - final Locale locale, - final ClassLoader loader, - final String key) { - ResourceBundle bundle = loadBundle(baseName, locale, loader); - String message = null; - if (bundle != null) { - try { - message = bundle.getString(key); - } catch (MissingResourceException e) { - if(locale.toString().length() > 0) { - String [] parts = locale.toString().split(StringUtils.UNDERSCORE); - String upLocale = StringUtils.asString(parts, 0, parts.length - 1, StringUtils.UNDERSCORE); - return getBundleMessage(baseName, StringUtils.parseLocale(upLocale), loader, key); - } else { - LogManager.log("Can`t load message in bundle " + baseName + - " for key " + key + - " using [" + loader + "] classloader"); - } - } - } - return message; - } - - private static Map getBundleMessagesMapForKey( - final String baseName, - final String key, - final ClassLoader loader) { - Map map = new HashMap (); - List list = new ArrayList (); - list.add(new Locale(StringUtils.EMPTY_STRING)); - list.addAll(Arrays.asList(Locale.getAvailableLocales())); - for(Locale locale : list) { - ResourceBundle bundle = loadBundle(baseName, locale, loader); - if(bundle!=null && locale.equals(bundle.getLocale()) && !map.containsKey(bundle.getLocale())) { - map.put(locale, getBundleMessage(baseName, locale, loader, key)); - } - } - return map; - } - - private static String getBundleResource(final Class clazz) { - return clazz.getPackage().getName() + BUNDLE_FILE_SUFFIX; - } - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private ResourceUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final int BUFFER_SIZE = - 40960; // NOMAGI - public static final String BUNDLE_FILE_SUFFIX = - ".Bundle"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/SecurityUtils.java b/nbi/engine/src/org/netbeans/installer/utils/SecurityUtils.java deleted file mode 100644 index 87d46b4bc072..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/SecurityUtils.java +++ /dev/null @@ -1,449 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.CodeSigner; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.Principal; -import java.security.cert.CertificateException; -import java.security.cert.Certificate; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.X509Certificate; -import java.text.DateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.Random; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import javax.swing.JOptionPane; - -/** - * - * @author Kirill Sorokin - * @author Dmitry Lipin - */ -final class SecurityUtils { - - private static KeyStore caStore; - private static KeyStore permanentTrustedStore; - private static KeyStore sessionTrustedStore; - private static KeyStore deniedStore; - private static String CACERTS_FILE_PATH = "lib/security/cacerts";//NOI18N - private static final int BUFFER_SIZE = 4096; - - public static boolean isJarSignatureVeryfied( - final File file, - final String description) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { - if (caStore == null) { - caStore = KeyStore.getInstance(KeyStore.getDefaultType()); - final File cacertsFile = new File(SystemUtils.getCurrentJavaHome(), CACERTS_FILE_PATH); - caStore.load(new FileInputStream(cacertsFile), null); - - permanentTrustedStore = KeyStore.getInstance(KeyStore.getDefaultType()); - permanentTrustedStore.load(null, null); - - sessionTrustedStore = KeyStore.getInstance(KeyStore.getDefaultType()); - sessionTrustedStore.load(null, null); - - deniedStore = KeyStore.getInstance(KeyStore.getDefaultType()); - deniedStore.load(null, null); - } - - final JarFile jar = new JarFile(file); - try { - // first we should fetch all certificates that are present in the jar - // file skipping duplicates - Certificate[] certificates = null; - CodeSigner[] codeSigners = null; - for (JarEntry entry : Collections.list(jar.entries())) { - readFully(jar.getInputStream(entry)); - - certificates = entry.getCertificates(); - codeSigners = entry.getCodeSigners(); - - if (certificates != null) { - break; - } - } - - // if there are no certificates -- we should pop up the dialog warning - // that the jar is not signed and ask the user whether he wants to - // accept this - if (certificates == null) { - // todo - } - - // check the permanent and session trusted stores - int chainStart = 0; - int chainEnd = 0; - int chainNum = 0; - - // iterate over the certificate chains that are present in the - // certificate arrays - while (chainEnd < certificates.length) { - // determine the start and end of the current certificates chain - int i = chainStart; - while (i < certificates.length - 1) { - final boolean isIssuer = isIssuerOf( - (X509Certificate) certificates[i], - (X509Certificate) certificates[i + 1]); - - if ((certificates[i] instanceof X509Certificate) && (certificates[i + 1] instanceof X509Certificate) && isIssuer) { - i++; - } else { - break; - } - } - chainEnd = i + 1; - - // if the denied certificates store contains the - if (containsCertificate(deniedStore, certificates[chainStart])) { - return false; - } else if (containsCertificate(permanentTrustedStore, certificates[chainStart]) || - containsCertificate(sessionTrustedStore, certificates[chainStart])) { - return true; - } - - chainStart = chainEnd; - chainNum++; - } - - // If we get here, no cert in chain has been stored in Session or Permanent store. - // If they are not in Deny store either, we have to pop up security dialog box - // for each signer's certificate one by one. - boolean rootCANotValid = false; - boolean timeNotValid = false; - - chainStart = 0; - chainEnd = 0; - chainNum = 0; - while (chainEnd < certificates.length) { - int i = chainStart; - - for (i = chainStart; i < certificates.length; i++) { - X509Certificate currentCert = null; - X509Certificate issuerCert = null; - - if (certificates[i] instanceof X509Certificate) { - currentCert = (X509Certificate) certificates[i]; - } - if ((i < certificates.length - 1) && - (certificates[i + 1] instanceof X509Certificate)) { - issuerCert = (X509Certificate) certificates[i + 1]; - } else { - issuerCert = currentCert; - } - - // check if the certificate is valid and has not expired - try { - currentCert.checkValidity(); - } catch (CertificateExpiredException e1) { - timeNotValid = true; - } catch (CertificateNotYetValidException e2) { - timeNotValid = true; - } - - if (isIssuerOf(currentCert, issuerCert)) { - // check the current certificate's signature -- verify that - // this issuer did indeed sign the certificate. - try { - currentCert.verify(issuerCert.getPublicKey()); - } catch (GeneralSecurityException e) { - return false; - } - } else { - break; - } - } - chainEnd = (i < certificates.length) ? (i + 1) : i; - - // we need to verify if the certificate chain is signed by a CA - rootCANotValid = !verifyCertificate(caStore, certificates[chainEnd - 1]); - - Date timestamp = null; - if (codeSigners[chainNum].getTimestamp() != null) { - timestamp = codeSigners[chainNum].getTimestamp().getTimestamp(); - } - - CertificateAcceptanceStatus status = showCertificateAcceptanceDialog( - certificates, - chainStart, - chainEnd, - rootCANotValid, - timeNotValid, - timestamp, - description); - - - // If user Grant permission, just pass all security checks. - // If user Deny first signer, pop up security box for second signer certs - if (status == CertificateAcceptanceStatus.ACCEPT_PERMANENTLY) { - addCertificate(permanentTrustedStore, certificates[chainStart]); - return true; - } else if (status == CertificateAcceptanceStatus.ACCEPT_FOR_THIS_SESSION) { - addCertificate(sessionTrustedStore, certificates[chainStart]); - return true; - } else { - addCertificate(deniedStore, certificates[chainStart]); - } - - chainStart = chainEnd; - chainNum++; - } - - return false; - } finally { - jar.close(); - } - } - - private static void readFully( - final InputStream stream) throws IOException { - final byte[] buffer = new byte[BUFFER_SIZE]; - while (stream.read(buffer) != -1) { - ; // do this! - } - } - - private static boolean isIssuerOf( - final X509Certificate certificate1, - final X509Certificate certificate2) { - return certificate1.getIssuerDN().equals(certificate2.getSubjectDN()); - } - - private static boolean containsCertificate( - final KeyStore store, - final Certificate certificate) throws KeyStoreException { - return store.getCertificateAlias(certificate) != null; - } - - private static void addCertificate( - final KeyStore store, - final Certificate certificate) throws KeyStoreException { - if (store.getCertificateAlias(certificate) == null) { - store.setCertificateEntry( - "alias" + new Random().nextLong(), - certificate); - } - } - - private static boolean verifyCertificate( - final KeyStore store, - final Certificate certificate) throws KeyStoreException { - for (String alias : Collections.list(store.aliases())) { - try { - certificate.verify(store.getCertificate(alias).getPublicKey()); - return true; - } catch (GeneralSecurityException e) { - // we must ignore this exception as it is VERY expected -- will - // happen N-1 times at least - } - } - - return false; - } - - private static CertificateAcceptanceStatus showCertificateAcceptanceDialog( - final Certificate[] certificates, - final int chainStart, - final int chainEnd, - final boolean rootCaIsNotValid, - final boolean timeIsNotValid, - final Date timestamp, - final String description) { - if (certificates[chainStart] instanceof X509Certificate && certificates[chainEnd - 1] instanceof X509Certificate) { - final X509Certificate firstCert = - (X509Certificate) certificates[chainStart]; - final X509Certificate lastCert = - (X509Certificate) certificates[chainEnd - 1]; - - final Principal subject = firstCert.getSubjectDN(); - final Principal issuer = lastCert.getIssuerDN(); - - // extract subject & issuer's name - final String subjectName = extractName( - subject.getName(), - "CN=", - "Unknown Subject"); - final String issuerName = extractName( - issuer.getName(), - "O=", - "Unknown Issuer"); - - // dialog caption - String caption = null; - String body = ""; - - // check if this is the case when both - the root CA and time of - // signing is valid: - if ((!rootCaIsNotValid) && (!timeIsNotValid)) { - caption = StringUtils.format( - "The digital signature of {0} has been verified.", - description); - - body += - "The digital signature has been validated by a trusted source. " + - "The security certificate was issued by a company that is trusted"; - - // for timestamp info, add a message saying that certificate was - // valid at the time of signing. And display date of signing. - if (timestamp != null) { - // get the right date format for timestamp - final DateFormat df = DateFormat.getDateTimeInstance( - DateFormat.LONG, - DateFormat.LONG); - body += StringUtils.format( - " and was valid at the time of signing on {0}.", - df.format(timestamp)); - } else { - // add message about valid time of signing: - body += - ", has not expired and is still valid."; - } - - // we should add one more message here - disclaimer we used - // to have. This is to be displayed in the "All trusted" - // case in the More Information dialog. - body += StringUtils.format( - "Caution: \"{0}\" asserts that this content is safe. " + - "You should only accept this content if you trust \"{1}\" to make that assertion.", - subjectName, - subjectName); - } else { - // this is the case when either publisher or time of signing - // is invalid - check and add corresponding messages to - // appropriate message arrays. - - // If root CA is not valid, add a caption and a message to the - // securityAlerts array. - if (rootCaIsNotValid) { - // Use different caption text for https and signed content - caption = StringUtils.format( - "The digital signature of {0} cannot be verified.", - description); - - body += "The digital signature cannot be verified by a trusted source. " + - "Only continue if you trust the origin of the file. " + - "The security certificate was issued by a company that is not trusted."; - } else { - caption = StringUtils.format( - "The digital signature of {0} has been verified.", - description); - - // Same details for both - body += "The security certificate was issued by a company that is trusted."; - } - - // now check if time of signing is valid. - if (timeIsNotValid) { - // if no warnings yet, add the one that will show with the - // bullet in security warning dialog: - body += "The digital signature was generated with a trusted certificate but has expired or is not yet valid"; - } else { - // for timestamp info, add a message saying that certificate - // was valid at the time of signing - if (timestamp != null) { - // get the right date format for timestamp - final DateFormat df = DateFormat.getDateTimeInstance( - DateFormat.LONG, - DateFormat.LONG); - body += StringUtils.format( - "The security certificate was valid at the time of signing on {0}.", - df.format(timestamp)); - } else { - body += "The security certificate has not expired and is still valid."; - } - } - } - - String message = StringUtils.format("{0}
" + - "Subject: {1}
" + - "Issuer: {2}

" + - "{3}

" + - "Click OK to accept the certificate permanently, " + - "No to accept it temporary for this session, " + - "Cancel to reject the certificate.", - caption, subjectName, issuerName, body); - - int option = UiUtils.showYesNoCancelDialog(null, message, JOptionPane.NO_OPTION); - if (option == JOptionPane.OK_OPTION) { - return CertificateAcceptanceStatus.ACCEPT_PERMANENTLY; - } else if (option == JOptionPane.NO_OPTION) { - return CertificateAcceptanceStatus.ACCEPT_FOR_THIS_SESSION; - } else { - return CertificateAcceptanceStatus.DENY; - } - } - - return CertificateAcceptanceStatus.DENY; - } - - private static String extractName( - final String nameString, - final String prefix, - final String defaultValue) { - int i = nameString.indexOf(prefix); - int j = 0; - - if (i < 0) { - return defaultValue; - } else { - try { - // shift to the beginning of the prefix text - i = i + prefix.length(); - - // check if it begins with a quote - if (nameString.charAt(i) == '\"') { - // skip the quote - i = i + 1; - - // search for another quote - j = nameString.indexOf('\"', i); - } else { - - // no quote, so search for comma - j = nameString.indexOf(',', i); - } - - if (j < 0) { - return nameString.substring(i); - } else { - return nameString.substring(i, j); - } - } catch (IndexOutOfBoundsException e) { - return defaultValue; - } - } - } - - public static enum CertificateAcceptanceStatus { - - ACCEPT_PERMANENTLY, - ACCEPT_FOR_THIS_SESSION, - DENY - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/StreamUtils.java b/nbi/engine/src/org/netbeans/installer/utils/StreamUtils.java deleted file mode 100644 index 1fbeadf1364f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/StreamUtils.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.RandomAccessFile; -import java.io.Reader; -import java.nio.charset.Charset; -import org.netbeans.installer.utils.progress.Progress; - -/** - * @author Danila Dugurov - * @author Kirill Sorokin - */ -public class StreamUtils { - public static void transferData( - final InputStream in, - final OutputStream out) throws IOException { - final byte[] buffer = new byte[FileUtils.BUFFER_SIZE]; - int length = 0; - while ((length = in.read(buffer)) != -1) { - out.write(buffer, 0, length); - } - out.flush(); - } - - public static void transferData( - final RandomAccessFile in, - final OutputStream out) throws IOException { - transferData(in, out, in.length()); - } - - public static void transferData( - final RandomAccessFile in, - final OutputStream out, - final Progress progress) throws IOException { - transferData(in, out, in.length(), progress); - } - - public static void transferData( - final RandomAccessFile in, - final OutputStream out, - final long max) throws IOException { - transferData(in, out, max, new Progress()); - } - - public static void transferData( - final RandomAccessFile in, - final OutputStream out, - final long max, - final Progress progress) throws IOException { - final byte[] buffer = new byte[FileUtils.BUFFER_SIZE]; - - long total = 0; - int length = 0; - - progress.setPercentage(Progress.START); - while (((length = in.read(buffer)) != -1) && (total < max)) { - total += length; - out.write( - buffer, - 0, - (int) (total < max ? length : length - (total - max))); - - if (total < max) { - progress.setPercentage(Progress.COMPLETE * total / max); - } - } - progress.setPercentage(Progress.COMPLETE); - - out.flush(); - } - - public static void transferFile( - final File file, - final OutputStream out) throws IOException { - transferFile(file, out, new Progress()); - } - - public static void transferFile( - final File file, - final OutputStream out, - final Progress progress) throws IOException { - RandomAccessFile in = null; - - try { - transferData(in = new RandomAccessFile(file, "r"), out, progress); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - ErrorManager.notifyDebug("Cannot close raf", e); - } - } - } - } - - public static CharSequence readStream( - final InputStream input) throws IOException { - return readStream(input, Charset.forName(StringUtils.ENCODING_UTF8)); - } - - public static CharSequence readStream( - final InputStream input, - final Charset charset) throws IOException { - final Reader reader = new BufferedReader(new InputStreamReader(input, charset)); - return readReader(reader); - } - - public static CharSequence readReader( - final Reader reader) throws IOException { - final char[] buffer = new char[FileUtils.BUFFER_SIZE]; - final StringBuilder stringBuilder = new StringBuilder(); - int readLength; - while ((readLength = reader.read(buffer)) != -1) { - stringBuilder.append(buffer, 0, readLength); - } - return stringBuilder; - } - - public static CharSequence readFile( - final File file) throws IOException { - return readFile(file, Charset.forName(StringUtils.ENCODING_UTF8)); - } - - public static CharSequence readFile( - final File file, - final Charset charset) throws IOException { - final InputStream in = new BufferedInputStream(new FileInputStream(file)); - try { - return readReader(new InputStreamReader(in, charset)); - } finally { - try { - in.close(); - } catch(IOException ignord) {} - } - } - - public static void writeChars( - final OutputStream out, - final CharSequence chars) throws IOException { - writeChars(out, chars, Charset.forName(StringUtils.ENCODING_UTF8)); - } - - public static void writeChars( - final OutputStream out, - final CharSequence chars, - final Charset charset) throws IOException { - out.write(chars.toString().getBytes(charset.name())); - } - - public static void writeChars( - final File file, - final CharSequence chars) throws IOException { - writeChars(file, chars, Charset.forName(StringUtils.ENCODING_UTF8)); - } - - public static void writeChars( - final File file, - final CharSequence chars, - final Charset charset) throws IOException { - final OutputStream out = - new BufferedOutputStream(new FileOutputStream(file)); - - try { - writeChars(out, chars, charset); - } finally { - try { - out.close(); - } catch(IOException ignord) {} - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/StringUtils.java b/nbi/engine/src/org/netbeans/installer/utils/StringUtils.java deleted file mode 100644 index 0d0aaab4879e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/StringUtils.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.MessageFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.Platform; - -/** - * - * @author Kirill Sorokin - */ -public abstract class StringUtils { - //////////////////////////////////////////////////////////////////////////// - // Static - public static String format( - final String message, - final Object... arguments) { - return MessageFormat.format(message, arguments); - } - - public static String leftTrim( - final String string) { - return string.replaceFirst(LEFT_WHITESPACE, EMPTY_STRING); - } - - public static String rightTrim( - final String string) { - return string.replaceFirst(RIGHT_WHITESPACE, EMPTY_STRING); - } - - public static char fetchMnemonic( - final String string) { - // source is org.openide.awt.Mnemonics - int i = findMnemonicAmpersand(string); - return (i >= 0) ? string.charAt(i+1) : NO_MNEMONIC; - } - - public static String stripMnemonic( - final String string) { - int i = findMnemonicAmpersand(string); - String s = string; - if( i>=0 ) { - if (string.startsWith("")) { // NOI18N - // Workaround for JDK bug #6510775 - s = string.substring(0, i) + - "" + string.charAt(i + 1) + "" + // NOI18N - string.substring(i + 2); - } else { - s = string.substring(0, i) + string.substring(i + 1); - } - } - return s; - } - - // source - org.openide.awt.Mnenonics; - public static int findMnemonicAmpersand(String text) { - int i = -1; - boolean isHTML = text.startsWith(""); - - do { - // searching for the next ampersand - i = text.indexOf(MNEMONIC_CHAR, i + 1); - - if ((i >= 0) && ((i + 1) < text.length())) { - if (isHTML) { - boolean startsEntity = false; - for (int j = i + 1; j < text.length(); j++) { - char c = text.charAt(j); - if (c == ';') { - startsEntity = true; - break; - } - if (!Character.isLetterOrDigit(c)) { - break; - } - } - if (!startsEntity) { - return i; - } - } else { - // before ' ' - if (text.charAt(i + 1) == ' ') { - continue; - - // before ', and after ' - } else if ((text.charAt(i + 1) == '\'') && (i > 0) && (text.charAt(i - 1) == '\'')) { - continue; - } - - // ampersand is marking mnemonics - return i; - } - } - } while (i >= 0); - - return -1; - } - - public static String capitalizeFirst( - final String string) { - return EMPTY_STRING + Character.toUpperCase(string.charAt(0)) + string.substring(1); - } - - public static String getGetterName( - final String propertyName) { - return "get" + capitalizeFirst(propertyName); - } - - public static String getBooleanGetterName( - final String propertyName) { - return "is" + capitalizeFirst(propertyName); - } - - public static String getSetterName( - final String propertyName) { - return "set" + capitalizeFirst(propertyName); - } - - public static String getFilenameFromUrl( - final String string) { - String url = string.trim(); - - int index = Math.max( - url.lastIndexOf(FORWARD_SLASH), - url.lastIndexOf(BACK_SLASH)); - int length = url.length(); - return (index > 0 && (index < length - 1)) ? - url.substring(index + 1, length) : null; - } - - public static String formatSize( - final long longBytes) { - double bytes = (double) longBytes; - - // try as GB - double gigabytes = bytes / 1024. / 1024. / 1024.; - if (gigabytes > 1.) { - return String.format("%.1f GB", gigabytes); - } - - // try as MB - double megabytes = bytes / 1024. / 1024.; - if (megabytes > 1.) { - return String.format("%.1f MB", megabytes); - } - - // try as KB - double kilobytes = bytes / 1024.; - if (kilobytes > .5) { - return String.format("%.1f KB", kilobytes); - } - - // return as bytes - return EMPTY_STRING + longBytes + " B"; - } - - public static String asHexString( - final byte[] bytes) { - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < bytes.length; i++) { - byte b = bytes[i]; - - String byteHex = Integer.toHexString(b); - if (byteHex.length() == 1) { - byteHex = "0" + byteHex; - } - if (byteHex.length() > 2) { - byteHex = byteHex.substring(byteHex.length() - 2); - } - - builder.append(byteHex); - } - - return builder.toString(); - } - - public static String pad( - final String string, - final int number) { - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < number; i++) { - builder.append(string); - } - - return builder.toString(); - } - - public static String escapeRegExp( - final String string) { - return string.replace(BACK_SLASH, BACK_SLASH + BACK_SLASH).replace("$", "\\$"); - } - public static String [] splitByLines(CharSequence cs) { - return splitByLines(cs.toString()); - } - public static String [] splitByLines(String s) { - return s.split(NEW_LINE_PATTERN, -1); - } - public static String readStream( - final InputStream stream) throws IOException { - return readStream(stream, null); - } - public static String readStream( - final InputStream stream, String charset) throws IOException { - StringBuilder builder = new StringBuilder(); - - byte[] buffer = new byte[1024]; - while (stream.available() > 0) { - int read = stream.read(buffer); - - String readString = (charset==null) ? - new String(buffer, 0, read) : - new String(buffer, 0, read, charset); - String[] strings = splitByLines(readString); - for(int i=0;i -1) { - if (SystemUtils.isWindows()) { - localPath = QUOTE + localPath + QUOTE; - } else { - localPath = localPath.replace(SPACE, - BACK_SLASH + SPACE); //NOI18N - } - } - - return localPath; - } - - /** - * Joins a command string and its arguments into a single string using the - * platform-specific rules. - * - * @param commandArray The command and its arguments. - * @return The joined string. - */ - public static String joinCommand( - final String... commandArray) { - StringBuffer command = new StringBuffer(); - - for (int i = 0; i < commandArray.length; i++) { - command.append(escapePath(commandArray[i])); - if (i != commandArray.length - 1) { - command.append(SPACE); //NOI18N - } - } - - return command.toString(); - } - - // object -> string .//////////////////////////////////////////////////////////// - public static String asString( - final Throwable throwable) { - final StringWriter writer = new StringWriter(); - - throwable.printStackTrace(new PrintWriter(writer)); - return writer.toString(); - } - - public static String asString( - final List objects) { - return asString(objects.toArray(), 0, objects.size(), ", "); - } - - public static String asString( - final List objects, - final String separator) { - return asString(objects.toArray(), 0, objects.size(), separator); - } - - public static String asString( - final List objects, - final int offset, - final int length, - final String separator) { - return asString(objects.toArray(), offset, length, separator); - } - - public static String asString( - final Object[] objects) { - return asString(objects, 0, objects.length, ", "); - } - - public static String asString( - final Object[] objects, - final String separator) { - return asString(objects, 0, objects.length, separator); - } - - public static String asString( - final Object[] objects, - final int offset, - final int length, - final String separator) { - final StringBuilder result = new StringBuilder(); - - for (int i = offset; i < offset + length; i++) { - result.append(EMPTY_STRING + objects[i]); - - if (i != offset + length - 1) { - result.append(separator); - } - } - - return result.toString(); - } - - // base64 /////////////////////////////////////////////////////////////////////// - public static String base64Encode( - final String string) throws UnsupportedEncodingException { - return base64Encode(string, ENCODING_UTF8); - } - - public static String base64Encode( - final String string, - final String charset) throws UnsupportedEncodingException { - final StringBuilder builder = new StringBuilder(); - final byte[] bytes = string.getBytes(charset); - - int i; - for (i = 0; i < bytes.length - 2; i += 3) { - int byte1 = bytes[i] & BIN_11111111; - int byte2 = bytes[i + 1] & BIN_11111111; - int byte3 = bytes[i + 2] & BIN_11111111; - - builder.append( - BASE64_TABLE[byte1 >> 2]); - builder.append( - BASE64_TABLE[((byte1 << 4) & BIN_00110000) | (byte2 >> 4)]); - builder.append( - BASE64_TABLE[((byte2 << 2) & BIN_00111100) | (byte3 >> 6)]); - builder.append( - BASE64_TABLE[byte3 & BIN_00111111]); - } - - if (i == bytes.length - 2) { - int byte1 = bytes[i] & BIN_11111111; - int byte2 = bytes[i + 1] & BIN_11111111; - - builder.append( - BASE64_TABLE[byte1 >> 2]); - builder.append( - BASE64_TABLE[((byte1 << 4) & BIN_00110000) | (byte2 >> 4)]); - builder.append( - BASE64_TABLE[(byte2 << 2) & BIN_00111100]); - builder.append( - BASE64_PAD); - } - - if (i == bytes.length - 1) { - int byte1 = bytes[i] & BIN_11111111; - - builder.append( - BASE64_TABLE[byte1 >> 2]); - builder.append( - BASE64_TABLE[(byte1 << 4) & BIN_00110000]); - builder.append( - BASE64_PAD); - builder.append( - BASE64_PAD); - } - - return builder.toString(); - } - - public static String base64Decode( - final String string) throws UnsupportedEncodingException { - return base64Decode(string, ENCODING_UTF8); - } - - public static String base64Decode( - final String string, - final String charset) throws UnsupportedEncodingException { - int completeBlocksNumber = string.length() / 4; - int missingBytesNumber = 0; - - if (string.endsWith("=")) { - completeBlocksNumber--; - missingBytesNumber++; - } - if (string.endsWith("==")) { - missingBytesNumber++; - } - - int decodedLength = (completeBlocksNumber * 3) + (3 - missingBytesNumber) % 3; - byte[] decodedBytes = new byte[decodedLength]; - - int encodedCounter = 0; - int decodedCounter = 0; - for (int i = 0; i < completeBlocksNumber; i++) { - int byte1 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte2 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte3 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte4 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - - decodedBytes[decodedCounter++] = (byte) ((byte1 << 2) | (byte2 >> 4)); - decodedBytes[decodedCounter++] = (byte) ((byte2 << 4) | (byte3 >> 2)); - decodedBytes[decodedCounter++] = (byte) ((byte3 << 6) | byte4); - } - - if (missingBytesNumber == 1) { - int byte1 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte2 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte3 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - - decodedBytes[decodedCounter++] = (byte) ((byte1 << 2) | (byte2 >> 4)); - decodedBytes[decodedCounter++] = (byte) ((byte2 << 4) | (byte3 >> 2)); - } - - if (missingBytesNumber == 2) { - int byte1 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - int byte2 = BASE64_REVERSE_TABLE[string.charAt(encodedCounter++)]; - - decodedBytes[decodedCounter++] = (byte) ((byte1 << 2) | (byte2 >> 4)); - } - - return new String(decodedBytes, charset); - } - - // normal <-> ascii only //////////////////////////////////////////////////////// - public static String parseAscii(final String string) { - final Properties properties = new Properties(); - - // we don't really care about enconding here, as the input string is - // expected to be ASCII-only, which means it's the same for any encoding - try { - properties.load(new ByteArrayInputStream(("key=" + string).getBytes())); - } catch (IOException e) { - ErrorManager.notifyWarning( - "Cannot parse string", - e); - return string; - } - - return (String) properties.get("key"); - } - - public static String convertToAscii(final String string) { - final Properties properties = new Properties(); - - properties.put("uberkey", string); - - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - properties.store(baos, EMPTY_STRING); - } catch (IOException e) { - ErrorManager.notifyWarning( - "Cannot convert string", - e); - return string; - } - - final Matcher matcher = Pattern. - compile("uberkey=(.*)$", Pattern.MULTILINE). - matcher(baos.toString()); - - if (matcher.find()) { - return matcher.group(1); - } else { - return string; - } - } - - // string -> object ///////////////////////////////////////////////////////////// - public static List asList( - final String string) { - return asList(string, ", "); - } - - public static List asList( - final String string, final String separator) { - return Arrays.asList(string.split(separator)); - } - - public static Locale parseLocale( - final String string) { - final String[] parts = string.split("_"); - - switch (parts.length) { - case 1: - return new Locale(parts[0]); - case 2: - return new Locale(parts[0], parts[1]); - default: - return new Locale(parts[0], parts[1], parts[2]); - } - } - public static String getLocalizedString(final Map stringsMap, final Locale inLocale) { - final String message = stringsMap.get(inLocale); - if(message==null && !inLocale.equals(new Locale(EMPTY_STRING))) { - final Locale upLocale; - if(!inLocale.getVariant().equals(EMPTY_STRING)) { - upLocale = new Locale(inLocale.getLanguage(), inLocale.getCountry()); - } else if(!inLocale.getCountry().equals(EMPTY_STRING)) { - upLocale = new Locale(inLocale.getLanguage()); - } else { - upLocale = new Locale(EMPTY_STRING); - } - return getLocalizedString(stringsMap, upLocale); - } else { - return message; - } - } - public static URL parseUrl( - final String string) throws ParseException { - try { - return new URL(string); - } catch (MalformedURLException e) { - throw new ParseException("Cannot parse URL", e); - } - } - - public static Platform parsePlatform( - final String string) throws ParseException { - for (Platform platform: Platform.values()) { - if (platform.getCodeName().equals(string)) { - return platform; - } - } - - throw new ParseException(ResourceUtils.getString(StringUtils.class, - StringUtils.ERROR_UNKNOWN_PLATFORM, string)); - } - - public static List parsePlatforms( - final String string) throws ParseException { - final List platforms = new ArrayList(); - - for (String name: asList(string, " ")) { - final Platform platform = parsePlatform(name); - - if (!platforms.contains(platform)) { - platforms.add(platform); - } - } - - return platforms; - } - - public static Status parseStatus( - final String string) throws ParseException { - for (Status status: Status.values()) { - if (status.getName().equals(string)) { - return status; - } - } - - throw new ParseException(ResourceUtils.getString(StringUtils.class, - StringUtils.ERROR_CANNOT_PARSE_STATUS, string)); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String BACK_SLASH = - "\\"; // NOI18N - public static final String FORWARD_SLASH = - "/"; // NOI18N - public static final String DOUBLE_BACK_SLASH = - "\\\\"; // NOI18N - - public static final String ENCODING_UTF8 = - "UTF-8"; // NOI18N - - public static final String CR = "\r"; // NOI18N - public static final String LF = "\n"; // NOI18N - public static final String DOT = "."; // NOI18N - public static final String EMPTY_STRING = ""; // NOI18N - public static final String CRLF = CR + LF; - public static final String CRLFCRLF = CRLF + CRLF; - public static final String SPACE = " "; // NOI18N - public static final String QUOTE = "\""; // NOI18N - public static final String EQUAL = "="; // NOI18N - public static final String UNDERSCORE = "_"; // NOI18N - - public static final String NEW_LINE_PATTERN = "(?:\r\n|\n|\r)"; // NOI18N - - private static final String LEFT_WHITESPACE = "^\\s+"; // NOI18N - private static final String RIGHT_WHITESPACE = "\\s+$"; // NOI18N - - - private static final char MNEMONIC_CHAR = '&'; - private static final String MNEMONIC = "&"; // NOI18N - private static final char NO_MNEMONIC = '\u0000'; - - private static final char[] BASE64_TABLE = new char[] { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', '+', '/' - }; - - private static final byte[] BASE64_REVERSE_TABLE = new byte[] { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, - -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51 - }; - - private static final char BASE64_PAD = '='; - - private static final int BIN_11111111 = 0xff; - private static final int BIN_00110000 = 0x30; - private static final int BIN_00111100 = 0x3c; - private static final int BIN_00111111 = 0x3f; - - public static final String ERROR_CANNOT_PARSE_STATUS = - "StrU.error.cannot.parse.status";//NOI18N - public static final String ERROR_UNKNOWN_PLATFORM = - "StrU.error.unknown.platform";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/SystemUtils.java b/nbi/engine/src/org/netbeans/installer/utils/SystemUtils.java deleted file mode 100644 index 22c1f74a9024..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/SystemUtils.java +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.*; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.NativeUtils; -import org.netbeans.installer.utils.system.NativeUtilsFactory; -import org.netbeans.installer.utils.system.launchers.Launcher; -import org.netbeans.installer.utils.system.launchers.LauncherFactory; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.resolver.StringResolverUtil; -import org.netbeans.installer.utils.system.shortcut.FileShortcut; -import org.netbeans.installer.utils.system.shortcut.LocationType; -import org.netbeans.installer.utils.system.shortcut.Shortcut; - -/** - * - * @author Kirill Sorokin - */ -public final class SystemUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static Map environment = - new ProcessBuilder().environment(); - - private static NativeUtils nativeUtils; - - // string resolution //////////////////////////////////////////////////////////// - public static String resolveString(String string) { - return resolveString(string, SystemUtils.class.getClassLoader()); - } - - public static String resolveString(String string, ClassLoader loader) { - return StringResolverUtil.resolve(string, loader); - } - - public static File resolvePath(String string) { - return resolvePath(string, SystemUtils.class.getClassLoader()); - } - - public static File resolvePath(String path, ClassLoader loader) { - final String separator = getFileSeparator(); - - String parsed = resolveString(path, loader); - - parsed = parsed.replace("\\", separator); - parsed = parsed.replace("/", separator); - - if (parsed.contains(separator + ".." + separator) || - parsed.contains(separator + "." + separator) || - parsed.endsWith(separator + "..") || - parsed.endsWith(separator + ".")) { - return FileUtils.getNormalizedPathFile(new File(parsed)); - } - - return new File(parsed).getAbsoluteFile(); - } - - // system info ////////////////////////////////////////////////////////////////// - @Deprecated - public static File getUserHomeDirectory() { - return new File(USER_HOME); - } - - public static File getDefaultUserdirRoot() { - String root = System.getProperty("netbeans.default_userdir_root", null); - if (root != null && root.isEmpty()) { - return new File(root); - } - return null; - } - - public static String getUserName() { - return System.getProperty("user.name"); - } - - public static boolean isCurrentUserAdmin() throws NativeException { - return getNativeUtils().isCurrentUserAdmin(); - } - - public static File getCurrentDirectory() { - return new File("."); - } - - public static File getTempDirectory() { - return new File(System.getProperty("java.io.tmpdir")); - } - - public static File getDefaultApplicationsLocation() throws NativeException { - return getNativeUtils().getDefaultApplicationsLocation(); - } - - public static File getCurrentJavaHome() { - return new File(JAVA_HOME); - } - - public static boolean isCurrentJava64Bit() { - final String osArch = System.getProperty("os.arch"); - return "64".equals(System.getProperty("sun.arch.data.model")) || - "64".equals(System.getProperty("com.ibm.vm.bitmode")) || //IBM`s JDK - osArch.equals("ia64") || //Windows/Linux/? on Intel Itanium - osArch.toLowerCase(Locale.ENGLISH).equals("ia64w") || //HP-UX on Intel Itanium - osArch.equals("PA_RISC2.0W") || //HP-UX on PA-RISC 2.0 - osArch.equals("amd64") || - osArch.equals("sparcv9") || - osArch.equals("x86_64") || - osArch.equals("ppc64"); - } - - public static String getLineSeparator() { - return LINE_SEPARATOR; - } - - public static String getFileSeparator() { - return FILE_SEPARATOR; - } - - public static String getPathSeparator() { - return PATH_SEPARATOR; - } - - public static long getFreeSpace(File file) throws NativeException { - //LogManager.log("[SystemUtils] getFreeSpace"); - //LogManager.indent(); - //LogManager.log(ErrorLevel.DEBUG, - // "... getting free space [requested path] : " + file.getPath()); - File directory = file; - while (directory!=null && (!directory.exists() || !directory.isDirectory())) { - directory = directory.getParentFile(); - } - //LogManager.log(ErrorLevel.DEBUG, - // "... getting free space [existing parent] : " + directory.getPath()); - long space = getNativeUtils().getFreeSpace(directory); - //LogManager.unindent(); - //LogManager.log(ErrorLevel.DEBUG, "... free space is : " + space); - return space; - } - - public static ExecutionResults executeCommand(String... command) throws IOException { - return executeCommand(null, null, null, command); - } - - public static ExecutionResults executeCommand(File workingDirectory, String... command) throws IOException { - return executeCommand(null, null, workingDirectory, command); - } - - @SuppressWarnings({"SleepWhileInLoop", "empty-statement"}) - public static ExecutionResults executeCommand(Progress progress, String[] supportedPrefixes, File workingDirectory, String... command) throws IOException { - // construct the initial log message - String commandString = StringUtils.asString(command, StringUtils.SPACE); - - if (supportedPrefixes == null) { - supportedPrefixes = new String[0]; - } - - if (workingDirectory == null) { - workingDirectory = getCurrentDirectory(); - } - - LogManager.log(ErrorLevel.MESSAGE, - "executing command: " + commandString + - ", in directory: " + workingDirectory); - LogManager.indent(); - - StringBuilder processStdOut = new StringBuilder(); - StringBuilder processStdErr = new StringBuilder(); - int errorLevel = ExecutionResults.TIMEOUT_ERRORCODE; - - ProcessBuilder builder= new ProcessBuilder(command).directory(workingDirectory); - - builder.environment().clear(); - builder.environment().putAll(environment); - setDefaultEnvironment(); - - Process process = builder.start(); - - long startTime = System.currentTimeMillis(); - long endTime = startTime + MAX_EXECUTION_TIME; - boolean doRun = true; - long delay = INITIAL_DELAY; - while (doRun && (System.currentTimeMillis() < endTime)) { - try { - Thread.sleep(delay); - if(delay < MAX_DELAY) { - delay += DELTA_DELAY; - } - } catch (InterruptedException e) { - ErrorManager.notifyDebug("Interrupted", e); - } - try { - errorLevel = process.exitValue(); - doRun = false; - } catch (IllegalThreadStateException e) { - ; // do nothing - the process is still running - } - String string; - - string = StringUtils.readStream(process.getInputStream()); - if (string.length() > 0) { - BufferedReader reader = new BufferedReader(new StringReader(string)); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (progress != null) { - if (! line.trim().isEmpty()) { - progress.setDetail(line); - } - } - LogManager.log(ErrorLevel.MESSAGE, "[stdout]: " + line); - endTime = System.currentTimeMillis() + MAX_EXECUTION_TIME; - } - - processStdOut.append(string); - } - - string = StringUtils.readStream(process.getErrorStream()); - if (string.length() > 0) { - BufferedReader reader = new BufferedReader(new StringReader(string)); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (progress != null) { - line = line.trim(); - if (! line.isEmpty()) { - for (String prefix : supportedPrefixes) { - if (line.startsWith(prefix)) { - progress.setDetail(line.substring(prefix.length())); - } - } - } - } - LogManager.log(ErrorLevel.MESSAGE, "[stderr]: " + line); - endTime = System.currentTimeMillis() + MAX_EXECUTION_TIME; - } - - processStdErr.append(string); - } - } - - LogManager.log(ErrorLevel.MESSAGE, - (doRun) ? - "[return]: killed by timeout" : - "[return]: " + errorLevel); - process.destroy(); - LogManager.unindent(); - LogManager.log(ErrorLevel.MESSAGE, "... command execution finished"); - - return new ExecutionResults(errorLevel, processStdOut.toString(), processStdErr.toString()); - } - - public static boolean isPathValid(String path) { - return getNativeUtils().isPathValid(path); - } - - public static boolean isPortAvailable(int port, int... forbiddenPorts) { - return NetworkUtils.isPortAvailable(port, forbiddenPorts); - } - - public static int getAvailablePort(int basePort, int... forbiddenPorts) { - return NetworkUtils.getAvailablePort(basePort, forbiddenPorts); - } - - public static boolean isDeletingAllowed(File file) { - return getNativeUtils().isDeletingAllowed(file); - } - - @Deprecated - private static LocationType toLocationType(ShortcutLocationType type) { - LocationType tp = null; - switch(type) { - case CURRENT_USER_DESKTOP : - tp = LocationType.CURRENT_USER_DESKTOP; - break; - case CURRENT_USER_START_MENU : - tp = LocationType.CURRENT_USER_START_MENU; - break; - case ALL_USERS_DESKTOP : - tp = LocationType.ALL_USERS_DESKTOP; - break; - case ALL_USERS_START_MENU : - tp = LocationType.ALL_USERS_START_MENU; - break; - } - return tp; - } - - @Deprecated - public static File getShortcutLocation(org.netbeans.installer.utils.helper.Shortcut shortcut, ShortcutLocationType locationType) throws NativeException { - return getNativeUtils().getShortcutLocation((FileShortcut)shortcut, toLocationType(locationType)); - } - - @Deprecated - public static File createShortcut(org.netbeans.installer.utils.helper.Shortcut shortcut, ShortcutLocationType locationType) throws NativeException { - return getNativeUtils().createShortcut((FileShortcut)shortcut, toLocationType(locationType)); - } - - @Deprecated - public static void removeShortcut(org.netbeans.installer.utils.helper.Shortcut shortcut, ShortcutLocationType locationType, boolean deleteEmptyParents) throws NativeException { - getNativeUtils().removeShortcut((FileShortcut)shortcut, toLocationType(locationType), deleteEmptyParents); - } - - public static File getShortcutLocation(Shortcut shortcut, LocationType locationType) throws NativeException { - return getNativeUtils().getShortcutLocation(shortcut, locationType); - } - - /** - * Create shortcut at the specified location that is set using locationType. - *
For the current moment the following logic is implemented: - *

    - *
  • For Windows FileShortcut is created as an .lnk file.
    - * InternetShortcut is created as a standard .url file.
  • - *
  • For Linux/Solaris FileShortcut is created as a .desktop entry with - * type Application if the target is normal file.
    - * If the file is actually a directory then a symlink is created
    - * InternetShortcut is created as a .desktop entry with type - * Link.
  • - *
  • For MacOS FileShortcut on desktop is created as a symlink - * (with, possibly, moving up-parents to the first .app).
    - * InternetShortcut on desktop is created as a standard .url file.
    - * "Start Menu" file shortcuts for MacOS are created at Dock.
    - * InternetShortcut creation in Dock actually does nothing since it - * seems that there is no way add an internet shortcut ot the Dock - * at all.
  • - *
- * - * - */ - public static File createShortcut( - final Shortcut shortcut, - final LocationType locationType) throws NativeException { - return getNativeUtils().createShortcut(shortcut, locationType); - } - - public static void removeShortcut(Shortcut shortcut, LocationType locationType, boolean deleteEmptyParents) throws NativeException { - getNativeUtils().removeShortcut(shortcut, locationType, deleteEmptyParents); - } - - public static FilesList addComponentToSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException { - return getNativeUtils().addComponentToSystemInstallManager(descriptor); - } - - public static void removeComponentFromSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException { - getNativeUtils().removeComponentFromSystemInstallManager(descriptor); - } - - public static String getEnvironmentVariable(String name) throws NativeException { - return getEnvironmentVariable(name, EnvironmentScope.PROCESS, true); - } - - public static String getEnvironmentVariable(String name, EnvironmentScope scope, boolean expand) throws NativeException { - return getNativeUtils().getEnvironmentVariable(name, scope, expand); - } - - public static void setEnvironmentVariable(String name, String value) throws NativeException { - setEnvironmentVariable(name, value, EnvironmentScope.PROCESS, true); - } - - public static void setEnvironmentVariable(String name, String value, EnvironmentScope scope, boolean expand) throws NativeException { - getNativeUtils().setEnvironmentVariable(name, value, scope, expand); - } - - public static List findIrrelevantFiles(File parent) throws IOException { - return getNativeUtils().findIrrelevantFiles(parent); - } - - public static List findIrrelevantFiles(File... parents) throws IOException { - List list = new LinkedList(); - - for (File parent: parents) { - list.addAll(findIrrelevantFiles(parent)); - } - - return list; - } - - public static void removeIrrelevantFiles(File parent) throws IOException { - FileUtils.deleteFiles(findIrrelevantFiles(parent)); - } - - public static void removeIrrelevantFiles(File... parents) throws IOException { - for (File file: parents) { - removeIrrelevantFiles(file); - } - } - - public static List findExecutableFiles(File parent) throws IOException { - return getNativeUtils().findExecutableFiles(parent); - } - - public static List findExecutableFiles(File... parents) throws IOException { - List list = new LinkedList(); - - for (File parent: parents) { - list.addAll(findExecutableFiles(parent)); - } - - return list; - } - - public static void correctFilesPermissions(File parent) throws IOException { - getNativeUtils().correctFilesPermissions(parent); - } - - public static void correctFilesPermissions(File... parents) throws IOException { - for (File file: parents) { - correctFilesPermissions(file); - } - } - - public static void setPermissions(final File file, final int mode, final int change) throws IOException { - getNativeUtils().setPermissions(file, mode, change); - } - - public static int getPermissions(final File file) throws IOException { - return getNativeUtils().getPermissions(file); - } - - public static Launcher createLauncher(LauncherProperties props, Progress progress) throws IOException { - return createLauncher(props, getCurrentPlatform(), progress); - } - - public static Launcher createLauncher(LauncherProperties props, Platform platform, Progress progress) throws IOException { - Progress prg = (progress == null) ? new Progress() : progress; - LogManager.log("Create native launcher for " + platform.toString()); - Launcher launcher =null; - try { - LogManager.indent(); - launcher = LauncherFactory.newLauncher(props, platform); - long start = System.currentTimeMillis(); - launcher.initialize(); - launcher.create(prg); - long seconds = System.currentTimeMillis() - start ; - LogManager.unindent(); - LogManager.log("[launcher] Time : " + (seconds/1000) + "."+ (seconds%1000)+ " seconds"); - } catch (IOException e) { - LogManager.unindent(); - LogManager.log("[launcher] Build failed with the following exception :"); - LogManager.log(e); - throw e; - } - return launcher; - } - - public static void sleep(long millis) { - try { - Thread.sleep(millis); - } catch (InterruptedException e) { - ErrorManager.notify(ErrorLevel.DEBUG, - "Interrupted while sleeping", e); - } - } - - public static void setDefaultEnvironment() { - environment = new ProcessBuilder().environment(); - } - - public static Map getEnvironment() { - return environment; - } - - public static Platform getCurrentPlatform() { - return getNativeUtils().getCurrentPlatform(); - } - - public static String getHostName() { - return NetworkUtils.getHostName(); - } - - public static List getFileSystemRoots(String... files) throws IOException { - return getNativeUtils().getFileSystemRoots(files); - } - - // platforms probes ///////////////////////////////////////////////////////////// - public static boolean isWindows() { - return getCurrentPlatform().isCompatibleWith(Platform.WINDOWS); - } - - public static boolean isMacOS() { - return getCurrentPlatform().isCompatibleWith(Platform.MACOSX); - } - - public static boolean isLinux() { - return getCurrentPlatform().isCompatibleWith(Platform.LINUX); - } - - public static boolean isSolaris() { - return getCurrentPlatform().isCompatibleWith(Platform.SOLARIS); - } - public static boolean isUnix() { - return getCurrentPlatform().isCompatibleWith(Platform.UNIX); - } - // miscellanea ////////////////////////////////////////////////////////////////// - public static boolean intersects( - final List list1, - final List list2) { - for (int i = 0; i < list1.size(); i++) { - for (int j = 0; j < list2.size(); j++) { - if (list1.get(i).equals(list2.get(j))) { - return true; - } - } - } - - return false; - } - - public static List intersect( - final List list1, - final List list2) { - final List intersection = new LinkedList(); - - for (T item: list1) { - if (list2.contains(item)) { - intersection.add(item); - } - } - - return intersection; - } - - public static List substract( - final List list1, - final List list2) { - final List result = new LinkedList(); - - for (T item1: list1) { - boolean found = false; - - for (T item2: list2) { - if (item1.equals(item2)) { - found = true; - break; - } - } - - if (!found) { - result.add(item1); - } - } - - return result; - } - - // native accessor ////////////////////////////////////////////////////////////// - public static synchronized NativeUtils getNativeUtils() { - if (nativeUtils == null) { - nativeUtils = NativeUtilsFactory.newNativeUtils(); - } - return nativeUtils; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final long MAX_EXECUTION_TIME = 10 * 60 * 1000; - - public static final int MAX_DELAY = 50; // NOMAGI - public static final int INITIAL_DELAY = 5; // NOMAGI - public static final int DELTA_DELAY = 5; // NOMAGI - public static final String LINE_SEPARATOR = - System.getProperty("line.separator");//NOI18N - public static final String FILE_SEPARATOR = - System.getProperty("file.separator");//NOI18N - public static final String PATH_SEPARATOR = - System.getProperty("path.separator");//NOI18N - public static final String JAVA_HOME = - System.getProperty("java.home");//NOI18N - public static final String USER_HOME = - System.getProperty("user.home");//NOI18N - public static final String NO_SPACE_CHECK_PROPERTY = - "no.space.check";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/UiUtils.java b/nbi/engine/src/org/netbeans/installer/utils/UiUtils.java deleted file mode 100644 index cef760210bdc..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/UiUtils.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.awt.GraphicsEnvironment; -import java.awt.HeadlessException; -import java.awt.Toolkit; -import java.io.File; -import java.io.FileFilter; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JProgressBar; -import javax.swing.LookAndFeel; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import org.netbeans.installer.Installer; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.NbiThread; -import org.netbeans.installer.utils.helper.UiMode; -import static javax.swing.JOptionPane.YES_NO_OPTION; -import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION; -import static javax.swing.JOptionPane.YES_OPTION; -import static javax.swing.JOptionPane.NO_OPTION; -import static javax.swing.JOptionPane.CANCEL_OPTION; -import org.netbeans.installer.utils.helper.ErrorLevel; - - -/** - * - * @author Kirill Sorokin - * @author Dmitry Lipin - */ -public final class UiUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static boolean lookAndFeelInitialized = false; - private static LookAndFeelType lookAndFeelType = null; - private static boolean uiUnavailable; - - public static boolean showMessageDialog( - final String message, - final String title, - final MessageType messageType) { - initLAF(); - - boolean exitInstaller = false; - - switch (UiMode.getCurrentUiMode()) { - case SWING: - int intMessageType = JOptionPane.INFORMATION_MESSAGE; - - LogManager.logIndent("... show message dialog"); - LogManager.log("title: "+ title); - LogManager.log("message: " + message); - - if (messageType == MessageType.WARNING) { - intMessageType = JOptionPane.WARNING_MESSAGE; - } else if (messageType == MessageType.CRITICAL) { - intMessageType = JOptionPane.ERROR_MESSAGE; - exitInstaller = true; - } - - if (messageType == MessageType.ERROR) { - int result = JOptionPane.showOptionDialog(null, - message, - title, - JOptionPane.YES_NO_OPTION, - JOptionPane.ERROR_MESSAGE, - null, - null, - JOptionPane.YES_OPTION); - if (result == JOptionPane.NO_OPTION) { - exitInstaller = true; - LogManager.logUnindent("... user selected: NO"); - } else { - LogManager.logUnindent("... user selected: YES"); - } - } else { - JOptionPane.showMessageDialog(null, - message, - title, - intMessageType); - } - - LogManager.logUnindent("... dialog closed"); - break; - case SILENT: - LogManager.log(message); - System.err.println(message); - break; - } - - return exitInstaller; - } - /** - * - * @param title The title of the dialog - * @param message The message of the dialog - * @return true if user click YES option. - * If installer is running silently then false is returned. - */ - public static boolean showYesNoDialog( - final String title, - final String message) { - return showYesNoDialog(title, message, false); - } - /** - * @param title The title of the dialog - * @param message The message of the dialog - * @param silentDefault The default return value if installer is running silently - * @return true if user click YES option. In silent mode return silentDefault - */ - public static boolean showYesNoDialog( - final String title, - final String message, - final boolean silentDefault) { - initLAF(); - switch (UiMode.getCurrentUiMode()) { - case SWING: - LogManager.logIndent("... showing Yes/No dialog"); - LogManager.log("title: " + title); - LogManager.log("message: " + message); - final int result = JOptionPane.showConfirmDialog( - null, - message, - title, - YES_NO_OPTION); - LogManager.logUnindent("... dialog closed, choice : " + (result == YES_OPTION ? "yes" : (result == NO_OPTION ? "no" : "closed"))); - return result == YES_OPTION; - - case SILENT: - LogManager.log(message); - final String option = StringUtils.format( - ResourceUtils.getString(UiUtils.class, - silentDefault ? - RESOURCE_SILENT_DEFAULT_YES : - RESOURCE_SILENT_DEFAULT_NO)); - System.err.println(message); - System.err.println(option); - LogManager.log(message); - LogManager.log(option); - return silentDefault; - } - //never get this line... - return true; - } - /** - * @param title The title of the dialog - * @param message The message of the dialog - * @param silentDefault The dafault return value if installer is running silently - * @return true if user click YES option. In silent mode return silentDefault - */ - public static int showYesNoCancelDialog( - final String title, - final String message, - final int silentDefault) { - initLAF(); - switch (UiMode.getCurrentUiMode()) { - case SWING: - LogManager.logIndent("... show Yes/No/Cancel dialog"); - LogManager.log("title: " + title); - LogManager.log("message: " + message); - int result = JOptionPane.showConfirmDialog( - null, - message, - title, - YES_NO_CANCEL_OPTION); - LogManager.logUnindent("... dialog closed, choice : " + (result == YES_OPTION ? "yes" : (result == NO_OPTION ? "no" : (result==CANCEL_OPTION ? "cancel" : "closed")))); - return result; - - case SILENT: - LogManager.log(message); - String resource; - switch(silentDefault) { - case YES_OPTION : - resource = RESOURCE_SILENT_DEFAULT_YES; - break; - case NO_OPTION : - resource = RESOURCE_SILENT_DEFAULT_NO; - break; - case CANCEL_OPTION : - resource = RESOURCE_SILENT_DEFAULT_CANCEL; - break; - default: - resource = StringUtils.EMPTY_STRING; - break; - } - - final String option = StringUtils.format( - ResourceUtils.getString(UiUtils.class,resource)); - System.err.println(message); - System.err.println(option); - LogManager.log(message); - LogManager.log(option); - return silentDefault; - } - //never get this line... - return silentDefault; - } - - public static void initializeLookAndFeel() throws InitializationException { - if (lookAndFeelInitialized) { - return; - } - - try { - LogManager.log("... initializing look and feel"); - LogManager.indent(); - switch (UiMode.getCurrentUiMode()) { - case SWING: - uiUnavailable = true; - String className = System.getProperty(LAF_CLASS_NAME_PROPERTY); - if (className == null) { - LogManager.log("... custom look and feel class name was not specified, using system default"); - className = UiUtils.getDefaultLookAndFeelClassName(); - } else if(!className.contains(StringUtils.DOT)) {//short name of the L&F class - className = UiUtils.getLookAndFeelClassNameByShortName(className); - } - - LogManager.log("... class name: " + className); - - if (Boolean.getBoolean(LAF_DECORATED_WINDOWS_PROPERTY)) { - JFrame.setDefaultLookAndFeelDecorated(true); - } - - try { - Thread jdkFileChooserWarningLogThread = null; - try { - // this helps to avoid some GTK L&F bugs for some locales - LogManager.log("... get installed L&Fs"); - UIManager.getInstalledLookAndFeels(); - LogManager.log("... set specified L&F"); - UIManager.setLookAndFeel(className); - LogManager.log("... check headless"); - if (GraphicsEnvironment.isHeadless()) { - HeadlessException e = new HeadlessException(ResourceUtils.getString(UiUtils.class, RESOURCE_FAILED_TO_INIT_UI_HEADLESS)); - System.err.println(ResourceUtils.getString(UiUtils.class, RESOURCE_FAILED_TO_INIT_UI)); - System.err.println(e.getMessage()); - throw new InitializationException( - ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_INIT_UI), e); - } - - if (System.getProperty("os.name").startsWith("Windows")) { - // workaround for the issue with further using JFileChooser - // in case of missing system icons - // Java Issue : - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6210674 - // NBI Issue : - // http://www.netbeans.org/issues/show_bug.cgi?id=105065 - // it also a workaround for two more bugs - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6449933 - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6489447 - LogManager.log("... creating JFileChooser object to check possible issues with UI"); - - if (System.getProperty("java.version").startsWith("1.6")) { - File desktop = new File(SystemUtils.getUserHomeDirectory(), "Desktop"); - File[] zips = null; - final List names = new ArrayList(); - if (FileUtils.exists(desktop)) { - zips = desktop.listFiles(new FileFilter() { - public boolean accept(File pathname) { - boolean result = pathname.getName().endsWith(".zip") && pathname.length() > 1000000L; - if (result) { - names.add(pathname.getName()); - } - return result; - } - }); - } - if (zips != null && zips.length > 0) { - jdkFileChooserWarningLogThread = new NbiThread() { - @Override - public void run() { - try { - sleep(8000); //8 seconds - } catch (InterruptedException e) { - return; - } - final File lock = new File(Installer.getInstance().getLocalDirectory(), Installer.LOCK_FILE_NAME); - LogManager.log("\n... !!! WARNING !!!"); - LogManager.log("... There are some big zip files on your desktop: " + StringUtils.asString(names)); - LogManager.log("... In case installer UI does not appear for a long time:"); - LogManager.log("... 1) kill the installer process"); - LogManager.log("... 2) move those zip files somewhere from the desktop"); - LogManager.log("... 3) delete " + lock); - LogManager.log("... 4) run installer again"); - LogManager.log("... For more details see the following bugs descriptions: "); - LogManager.log("... http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6372808"); - LogManager.log("... http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050516"); - } - }; - jdkFileChooserWarningLogThread.start(); - } - } - - - - if (SwingUtilities.isEventDispatchThread()) { - new JFileChooser(); - } else { - try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - new JFileChooser(); - } - }); - } catch (InvocationTargetException e) { - throw (e.getCause() != null) ? e.getCause() : e; - } - } - - - if(jdkFileChooserWarningLogThread!=null) { - jdkFileChooserWarningLogThread.interrupt(); - jdkFileChooserWarningLogThread = null; - } - - LogManager.log("... getting default Toolkit to check possible issues with UI"); - Toolkit.getDefaultToolkit(); - - // workaround for JDK issue with JProgressBar using StyleXP - // http://www.netbeans.org/issues/show_bug.cgi?id=106876 - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6337517 - LogManager.log("... creating JProgressBar object to check possible issues with UI"); - new JProgressBar().getMaximumSize(); - - LogManager.log("... all UI checks done"); - } - LogManager.log("... L&F is set"); - } catch (Throwable e) { - if(jdkFileChooserWarningLogThread!=null) { - jdkFileChooserWarningLogThread.interrupt(); - jdkFileChooserWarningLogThread = null; - } - // we're catching Throwable here as pretty much anything can happen - // while setting the look and feel and we have no control over it - // if something wrong happens we should fall back to the default - // cross-platform look and feel which is assumed to be working - // correctly - LogManager.log("... could not activate defined L&F, initializing cross-platfrom one", e); - if (e instanceof InternalError) { - System.err.println(e.getMessage()); - } else if (e instanceof ExceptionInInitializerError) { - final Throwable cause = e.getCause(); - - if (cause instanceof HeadlessException) { - System.err.println(cause.getMessage()); - } - } - - className = UIManager.getCrossPlatformLookAndFeelClassName(); - LogManager.log("... cross-platform L&F class-name : " + className); - - UIManager.setLookAndFeel(className); - - if(System.getProperty(LAF_CLASS_NAME_PROPERTY)!=null) { - // Throw exception only if user specified custom L&F, - // otherwise just go to initialization of cross-platfrom L&F - // (Exception e is already logged above) - // See also http://www.netbeans.org/issues/show_bug.cgi?id=122557 - // This exception would be thrown only if cross-platform LAF is successfully installed - throw new InitializationException( - ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_DEFINED_LAF), e); - } - } - } catch (NoClassDefFoundError e) { - throw new InitializationException( - ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF), e); - } catch (ClassNotFoundException e) { - throw new InitializationException(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF), e); - } catch (InstantiationException e) { - throw new InitializationException(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF), e); - } catch (IllegalAccessException e) { - throw new InitializationException(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF), e); - } catch (UnsupportedLookAndFeelException e) { - throw new InitializationException(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF), e); - } - break; - } - } catch (LinkageError err) { - uiUnavailable = true; - LogManager.log(ErrorLevel.ERROR, err); - throw new InitializationException(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_INITIALIZE_UI_LINKERR, err.getLocalizedMessage()), err); - } finally { - LogManager.unindent(); - LogManager.log("... initializing L&F finished"); - - if (Boolean.getBoolean("nbi.look.and.feel.dump.defaults")) { - try { - LogManager.logIndent("... dumping UIManger L&F defaults: "); - Hashtable hash = (Hashtable) UIManager.getLookAndFeelDefaults(); - Enumeration keys = hash.keys(); - while (keys.hasMoreElements()) { - Object key = keys.nextElement(); - LogManager.log("" + key + " = " + hash.get(key)); - } - } catch (Exception e) { - LogManager.log(e); - } finally { - LogManager.unindent(); - } - } - - lookAndFeelInitialized = true; - lookAndFeelType = getLAF(); - } - } - - public static String getDefaultLookAndFeelClassName( - ) { - switch (UiMode.getCurrentUiMode()) { - case SWING: - String className = UIManager.getSystemLookAndFeelClassName(); - - // if the default look and feel is the cross-platform one, we might - // need to correct this choice. E.g. - KDE, where GTK look and feel - // would be much more appropriate - if (className.equals(UIManager.getCrossPlatformLookAndFeelClassName())) { - - // if the current platform is Linux and the desktop manager is - // KDE, then we should try to use the GTK look and feel - try { - if (System.getProperty("os.name").contains("Linux") && - (System.getenv("KDE_FULL_SESSION") != null)) { - // check whether the GTK look and feel class is - // available -- we'll get CNFE if it is not and it will - // not be set - Class.forName(LookAndFeelType.GTK.getClassName()); - - className = LookAndFeelType.GTK.getClassName(); - } - } catch (ClassNotFoundException e) { - ErrorManager.notifyDebug(ResourceUtils.getString(UiUtils.class, - RESOURCE_FAILED_TO_FORCE_GTK), e); - } - } - - return className; - default: - return null; - } - } - - public static final String getLookAndFeelClassNameByShortName(String name) { - if(name == null) { - return null; - } - for(LookAndFeelType lafType : LookAndFeelType.values()) { - if(lafType.getId()!=null && lafType.getClassName()!=null) { - if(name.toLowerCase(Locale.ENGLISH).equals(lafType.getId().toLowerCase(Locale.ENGLISH))) { - return lafType.getClassName(); - } - } - } - return name; - } - - public static final LookAndFeelType getLAF() { - if(lookAndFeelType==null) { - try { - initializeLookAndFeel(); - } catch (InitializationException e) { - LogManager.log(e); - } - lookAndFeelType = LookAndFeelType.DEFAULT; - - if (!uiUnavailable && UiMode.getCurrentUiMode() == UiMode.SWING) { - LookAndFeel laf = UIManager.getLookAndFeel(); - if (laf != null) { - String id = laf.getID(); - for (LookAndFeelType type : LookAndFeelType.values()) { - if (id.equals(LookAndFeelType.WINDOWS_XP.getId()) || - id.equals(LookAndFeelType.WINDOWS_CLASSIC.getId())) { - final Object object = Toolkit.getDefaultToolkit(). - getDesktopProperty(WINDOWS_XP_THEME_MARKER_PROPERTY); - boolean xpThemeActive = false; - if (object != null) { - xpThemeActive = (Boolean) object; - } - lookAndFeelType = (xpThemeActive) ? LookAndFeelType.WINDOWS_XP : LookAndFeelType.WINDOWS_CLASSIC; - break; - } else if (id.equals(type.getId())) { - lookAndFeelType = type; - break; - } - } - } - } - } - return lookAndFeelType; - } - - private static void initLAF() { - try { - initializeLookAndFeel(); - } catch (InitializationException e) { - ErrorManager.notifyWarning(e.getMessage(), e.getCause()); - } - } - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private UiUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - - public static enum MessageType { - INFORMATION, - WARNING, - ERROR, - CRITICAL - } - - public enum LookAndFeelType { - WINDOWS_XP("win.xp", "Windows", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"), - WINDOWS_CLASSIC("win.classic", "Windows", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"), - MOTIF("motif", "Motif", "com.sun.java.swing.plaf.motif.MotifLookAndFeel"), - GTK("gtk", "GTK", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"), - METAL("metal", "Metal", "javax.swing.plaf.metal.MetalLookAndFeel"), - AQUA("aqua", "Aqua", "com.apple.laf.AquaLookAndFeel"), - NIMBUS("nimbus", "Nimbus", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"), - DEFAULT("default", null, null); - - private String name; - private String className; - private String id; - - @Override - public String toString() { - return name; - } - private LookAndFeelType(String name, String id, String className) { - this.name = name; - this.id = id; - this.className = className; - } - public String getId() { - return id; - } - public String getClassName() { - return className; - } - }; - - public static int getDimension(Properties props, final String defaultPropertyName, final int defaultValue) { - int dimension = defaultValue; - String propertyName = defaultPropertyName; - if (props.getProperty(propertyName + "." + UiUtils.getLAF()) != null) { - propertyName = propertyName + "." + UiUtils.getLAF(); - } - - if (props.getProperty(propertyName) != null) { - try { - dimension = Integer.parseInt( - props.getProperty(propertyName).trim()); - } catch (NumberFormatException e) { - final String warning = ResourceUtils.getString( - UiUtils.class, - RESOURCE_FAILED_TO_PARSE_SYSTEM_PROPERTY, - propertyName, - props.getProperty(propertyName)); - - ErrorManager.notifyWarning(warning, e); - } - } - return dimension; - } - ///////////////////////////////////////////////////////////////////////////////// - // Constants - - /** - * Name of the system property, which contains the look and feel class name that - * should be used by the wizard. - */ - public static final String LAF_CLASS_NAME_PROPERTY = - "nbi.look.and.feel"; // NOI18N - - /** - * Name of the system property, which tells the UiUtils whether the wizard - * windows should be decorated by the current look and feel or the system - * window manager. - */ - public static final String LAF_DECORATED_WINDOWS_PROPERTY = - "nbi.look.and.feel.decorate.windows"; // NOI18N - - public static final String WINDOWS_XP_THEME_MARKER_PROPERTY = - "win.xpstyle.themeActive"; // NOI18N - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_PARSE_SYSTEM_PROPERTY = - "UI.error.failed.to.parse.property"; // NOI18N - private static final String RESOURCE_FAILED_TO_ACTIVATE_CROSSPLATFORM_LAF = - "UI.error.failed.to.activate.crossplatform.laf"; // NOI18N - private static final String RESOURCE_FAILED_TO_ACTIVATE_DEFINED_LAF = - "UI.error.failed.to.activate.defined.laf";//NOI18N - private static final String RESOURCE_FAILED_TO_INIT_UI = - "UI.error.failed.to.init.ui";//NOI18N - private static final String RESOURCE_FAILED_TO_INIT_UI_HEADLESS = - "UI.error.failed.to.init.ui.headless";//NOI18N - private static final String RESOURCE_FAILED_TO_FORCE_GTK = - "UI.error.failed.to.force.gtk";//NOI18N - private static final String RESOURCE_SILENT_DEFAULT_YES = - "UI.silent.default.yes";//NOI18N - private static final String RESOURCE_SILENT_DEFAULT_NO = - "UI.silent.default.no";//NOI18N - private static final String RESOURCE_SILENT_DEFAULT_CANCEL = - "UI.silent.default.cancel";//NOI18N - private static final String RESOURCE_FAILED_TO_INITIALIZE_UI_LINKERR = - "UI.error.failed.to.initialize.ui.linkerr"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/UninstallUtils.java b/nbi/engine/src/org/netbeans/installer/utils/UninstallUtils.java deleted file mode 100644 index a43b2d3bb4f7..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/UninstallUtils.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.Version; -import org.w3c.dom.Element; - -/** - * - * @author lfischme - */ -public class UninstallUtils { - - private static final String UPDATE_TRACKING_MODULE_VERSION_ELEMENT = "module_version";//NOI18N - private static final String UPDATE_TRACKING_ORIGIN_ATRIBUTE = "origin";//NOI18N - private static final String UPDATE_TRACKING_NAME_ATRIBUTE = "name";//NOI18N - private static final String UPDATE_TRACKING_ORIGIN_INSTALLER_STRING = "installer";//NOI18N - private static final String UPDATE_TRACKING_LOCATION = "update_tracking";//NOI18N - private static final String UPDATE_BACKUP_LOCATION = "update";//NOI18N - - private static File installationLocation; - private static List emptyFolders; - private static Set updatedFiles; - private static Set clustersRoots; - private static Set filesToDelete; - - /** - * Returns all files that should be deleted, but not listed in registry - * Except empty folders - * - * @return all files that should be deleted, but not listed in registry - */ - public static Set getFilesToDeteleAfterUninstallation() { - if (filesToDelete == null) { - filesToDelete = new HashSet(); - - filesToDelete.addAll(getUpdatedFiles()); - - for (File clusterRoot : getClustersRoots()) { - File updateTrackingFolder = new File(clusterRoot, UPDATE_TRACKING_LOCATION); - filesToDelete.addAll(getAllDescendantsRecursively(updateTrackingFolder)); - - File lastModifiedFile = new File(clusterRoot, ".lastModified"); - if (lastModifiedFile.exists()) { - filesToDelete.add(lastModifiedFile); - } - - File updateBackupFolder = new File(clusterRoot, UPDATE_BACKUP_LOCATION); - filesToDelete.addAll(getAllDescendantsRecursively(updateBackupFolder)); - } - } - - return filesToDelete; - } - - /** - * Returns list of empty folders in specified location - * - * @return list of empty folders in specified location - */ - public static List getEmptyFolders() { - if (emptyFolders == null) { - emptyFolders = new ArrayList(); - for (File clusterRoot : getClustersRoots()) { - isFolderEmpty(clusterRoot); - } - } - - return emptyFolders; - } - - /** - * Returns list of all files installed via IDE - Plugins and updates in - * installation folder - * - * @return list of files installed via IDE - */ - private static Set getUpdatedFiles() { - if (updatedFiles == null) { - Set clustersRootsList = getClustersRoots(); - - if (clustersRootsList == null || clustersRootsList.isEmpty()) { - return Collections.emptySet(); - } - - FileFilter onlyXmlFilter = new FileFilter() { - @Override - public boolean accept(File file) { - return file.getPath().endsWith(".xml"); - } - }; - - updatedFiles = new HashSet(); - - for (File clusterRoot : clustersRootsList) { - File clusterUpdateTrackingFolder = new File(clusterRoot, UPDATE_TRACKING_LOCATION); - File[] updateTrackingFiles = clusterUpdateTrackingFolder.listFiles(onlyXmlFilter); - - if (updateTrackingFiles != null) { - for (File trackingFile : updateTrackingFiles) { - try { - Element root = XMLUtils.getDocumentElement(trackingFile); - for (Element element : XMLUtils.getChildren(root, UPDATE_TRACKING_MODULE_VERSION_ELEMENT)) { - if (!element.getAttribute(UPDATE_TRACKING_ORIGIN_ATRIBUTE).equals(UPDATE_TRACKING_ORIGIN_INSTALLER_STRING)) { - for (Element fileElement : XMLUtils.getChildren(element)) { - String fileName = fileElement.getAttribute(UPDATE_TRACKING_NAME_ATRIBUTE); - File file = new File(clusterRoot, fileName); - updatedFiles.add(file); - } - } - } - } catch (XMLException ex) { - LogManager.log(ex); - } - } - } - } - } - - return updatedFiles; - } - - /** - * Returns list of clusters - * - * @return list of clusters - */ - private static Set getClustersRoots() { - if (clustersRoots == null) { - File installationLoc = getInstallationLocation(); - - if (installationLoc != null && installationLoc.exists()) { - FileFilter onlyDirFilter = new FileFilter() { - @Override - public boolean accept(File file) { - return file.isDirectory(); - } - }; - clustersRoots = new HashSet(Arrays.asList(installationLoc.listFiles(onlyDirFilter))); - } else { - clustersRoots = Collections.emptySet(); - } - } - - return clustersRoots; - } - - /** - * Returns all descendants for specified folder - * - * @param folder - * @return all descendants for specified folder - */ - private static List getAllDescendantsRecursively(File folder) { - if (folder != null && folder.isDirectory()) { - List descendants = new ArrayList(); - for (File actualFile : folder.listFiles()) { - if (actualFile.isDirectory()) { - descendants.addAll(getAllDescendantsRecursively(actualFile)); - } - descendants.add(actualFile); - } - return descendants; - } else { - return Collections.emptyList(); - } - } - - /** - * Returns installation location - * - * @return installation location - */ - private static File getInstallationLocation() { - if (installationLocation == null) { - String target = System.getProperty(Registry.TARGET_COMPONENT_UID_PROPERTY); - Registry registry = Registry.getInstance(); - - for (Product product : registry.getProductsToUninstall()) { - if (product.getUid().equals(target)) { - installationLocation = product.getInstallationLocation(); - } - } - } - - return installationLocation; - } - - /** - * Checks if folder is empty, if checking file, false is returned. Also - * fills emptyFolders list by empty descendant folders. - * - * @param file file - folder to check - * @return if folder is empty, if checking file, false is returned - */ - private static boolean isFolderEmpty(File file) { - boolean result = true; - if (file != null && file.isDirectory()) { - for (File descendant : file.listFiles()) { - result = isFolderEmpty(descendant) & result; - } - if (result) { - emptyFolders.add(file); - } - } else { - result = false; - } - return result; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/XMLUtils.java b/nbi/engine/src/org/netbeans/installer/utils/XMLUtils.java deleted file mode 100644 index 341278f97196..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/XMLUtils.java +++ /dev/null @@ -1,629 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import org.netbeans.installer.product.dependencies.Conflict; -import org.netbeans.installer.product.dependencies.InstallAfter; -import org.netbeans.installer.product.dependencies.Requirement; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.ExtendedUri; -import org.netbeans.installer.utils.helper.Feature; -import org.netbeans.installer.utils.helper.NbiProperties; -import org.netbeans.installer.utils.helper.Version; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * - * @author Dmitry Lipin - */ -public abstract class XMLUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static void saveXMLDocument( - final Document document, - final File file) throws XMLException { - LogManager.logEntry("saving document to xml file : " + file); - FileOutputStream output = null; - - for (int i = 0; i < MAXIMUM_SAVE_ATTEMPTS; i++) { - try { - output = new FileOutputStream(file); - saveXMLDocument(document, output); - // check the size of the resulting file -- sometimes it just happens - // to be empty, we need to resave then; if we fail to save for - // several times (MAXIMUM_SAVE_ATTEMPTS) -- fail with an - // XMLException - } catch (IOException e) { - LogManager.log("... can`t save XML, an exception caught", e); - LogManager.logExit("... document not saved"); - throw new XMLException("Cannot save XML document", e); - } finally { - if (output != null) { - try { - output.close(); - output = null; - } catch (IOException e) { - ErrorManager.notifyDebug("Could not close the stream", e); - } - } - } - if (file.length() > 0) { - LogManager.logExit("... document saved"); - return; - } - } - LogManager.logExit("... throwing XML exception since xml file could not be saved for several attemps"); - throw new XMLException("Cannot save XML document after " + - MAXIMUM_SAVE_ATTEMPTS + " attempts, the resulting " + - "file is empty."); - - } - - public static void saveXMLDocument( - final Document document, - final OutputStream output) throws XMLException { - try { - final Source source = new DOMSource( - document); - final Result result = new StreamResult( - output); - final Source xslt = new StreamSource( - FileProxy.getInstance().getFile(XSLT_REFORMAT_URI,true)); - TransformerFactory tf = TransformerFactory. - newInstance(); - final Transformer transformer = tf. - newTransformer(xslt); - transformer.transform(source, result); - } catch (DownloadException e) { - throw new XMLException("Cannot save XML document", e); - } catch (TransformerConfigurationException e) { - throw new XMLException("Cannot save XML document", e); - } catch (TransformerException e) { - throw new XMLException("Cannot save XML document", e); - } - } - - public static Document loadXMLDocument( - final File file) throws XMLException { - FileInputStream input = null; - - try { - return loadXMLDocument(input = new FileInputStream(file)); - } catch (IOException e) { - throw new XMLException("Cannot open XML file", e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - ErrorManager.notifyDebug("Cannot close the stream", e); - } - } - } - } - - public static Document loadXMLDocument( - final InputStream input) throws XMLException { - try { - return DocumentBuilderFactory. - newInstance(). - newDocumentBuilder(). - parse(input); - } catch (ParserConfigurationException e) { - throw new XMLException("Cannot parse XML", e); - } catch (SAXException e) { - throw new XMLException("Cannot parse XML", e); - } catch (IOException e) { - throw new XMLException("Cannot parse XML", e); - } - } - - public static Element getDocumentElement( - final File file) throws XMLException { - return loadXMLDocument(file).getDocumentElement(); - } - - public static Element getDocumentElement( - final InputStream input) throws XMLException { - return loadXMLDocument(input).getDocumentElement(); - } - - public static List getChildren( - final Element element) { - final List children = new LinkedList(); - - final NodeList list = element.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - final Node node = list.item(i); - - if (node instanceof Element) { - children.add((Element) node); - } - } - - return children; - } - - public static List getChildren( - final Element element, - final String... names) { - final List children = new LinkedList(); - - final NodeList list = element.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - final Node node = list.item(i); - - if (node instanceof Element) { - for (int j = 0; j < names.length; j++) { - if (node.getNodeName().equals(names[j])) { - children.add((Element) node); - break; - } - } - } - } - - return children; - } - - public static Element getChild( - final Element element, - final String path) { - final String[] pathComponents; - - if (path.contains(StringUtils.FORWARD_SLASH)) { - pathComponents = path.split(StringUtils.FORWARD_SLASH); - } else { - pathComponents = new String[] { - path - }; - } - - Element child = element; - - for (String name: pathComponents) { - boolean found = false; - - for (Element subchild: getChildren(child)) { - if (subchild.getNodeName().equals(name)) { - child = subchild; - found = true; - break; - } - } - - if (!found) { - child = null; - break; - } - } - - return child; - } - - public static int countDescendants( - final Element element, - final String... names) { - return countDescendants(element, Arrays.asList(names)); - } - - public static int countDescendants( - final Element element, - final List names) { - int count = 0; - for (Element child: getChildren(element)) { - if (names.contains(child.getNodeName())) { - count++; - } - - count += countDescendants(child, names); - } - - return count; - } - - public static Element appendChild( - final Element element, - final String name, - final String text) { - final Element child = element.getOwnerDocument().createElement(name); - - child.setTextContent(text != null ? text : StringUtils.EMPTY_STRING); - element.appendChild(child); - - return child; - } - - // object <-> dom /////////////////////////////////////////////////////////////// - public static Dependency parseDependency( - final Element element) throws ParseException { - final String type = element.getNodeName(); - final String uid = - element.getAttribute("uid"); - final Version lower = - Version.getVersion(element.getAttribute("version-lower")); - final Version upper = - Version.getVersion(element.getAttribute("version-upper")); - final Version resolved = - Version.getVersion(element.getAttribute("version-resolved")); - Dependency dependency = null; - if(type.equals(Requirement.NAME)) { - List > orList = new ArrayList> (); - for(Element orElement : getChildren(element, "or")) { - List < Requirement> requirements = new ArrayList (); - for(Element el : getChildren(orElement)) { - Dependency dep = parseDependency(el); - if(dep instanceof Requirement) { - requirements.add((Requirement)dep); - } else { - throw new ParseException( - "OR dependencies are not supported for " + - dep.getName()); - } - } - orList.add(requirements); - } - dependency = new Requirement(uid, lower, upper, resolved, orList); - } else if(type.equals(Conflict.NAME)) { - dependency = new Conflict(uid, lower, upper, resolved); - } else if(type.equals(InstallAfter.NAME)) { - dependency = new InstallAfter(uid, lower, upper, resolved); - } else { - throw new ParseException("Unknown dependency : " + type); - } - return dependency; - } - - public static Element saveDependency( - final Dependency dependency, - final Element element) { - element.setAttribute("uid", - dependency.getUid()); - - if (dependency.getVersionLower() != null) { - element.setAttribute("version-lower", - dependency.getVersionLower().toString()); - } - if (dependency.getVersionUpper() != null) { - element.setAttribute("version-upper", - dependency.getVersionUpper().toString()); - } - if (dependency.getVersionResolved() != null) { - element.setAttribute("version-resolved", - dependency.getVersionResolved().toString()); - } - if(dependency instanceof Requirement) { - Requirement requirement = (Requirement)dependency; - List > orList = requirement.getAlternatives(); - for(List requirememntsBlock : orList) { - element.appendChild( - saveDependencies(requirememntsBlock, - element.getOwnerDocument().createElement("or"))); - } - } - - return element; - } - - public static List parseDependencies( - final Element element) throws ParseException { - final List dependencies = new LinkedList(); - - for (Element child: getChildren(element)) { - dependencies.add(parseDependency(child)); - } - - return dependencies; - } - - public static Element saveDependencies( - final List dependencies, - final Element element) { - final Document document = element.getOwnerDocument(); - - for (Dependency dependency: dependencies) { - element.appendChild(saveDependency( - dependency, - document.createElement(dependency.getName()))); - } - - return element; - } - - public static Properties parseProperties( - final Element element) throws ParseException { - final Properties properties = new Properties(); - - if (element != null) { - for (Element child: XMLUtils.getChildren(element, "property")) { - String name = child.getAttribute("name"); - String value = child.getTextContent(); - - properties.setProperty(name, value); - } - } - - return properties; - } - - public static Element saveProperties( - final Properties properties, - final Element element) { - final Document document = element.getOwnerDocument(); - - properties.forEach((name, textObj) -> { - final Element propertyElement = document.createElement("property"); - - propertyElement.setAttribute("name", name.toString()); - propertyElement.setTextContent(textObj.toString()); - - element.appendChild(propertyElement); - }); - - return element; - } - - public static NbiProperties parseNbiProperties( - final Element element) throws ParseException { - return new NbiProperties(parseProperties(element)); - } - - public static Element saveNbiProperties( - final NbiProperties properties, - final Element element) { - return saveProperties(properties, element); - } - - public static ExtendedUri parseExtendedUri( - final Element element) throws ParseException { - try { - final URI uri = - new URI(getChild(element, "default-uri").getTextContent()); - final long size = - Long.parseLong(element.getAttribute("size")); - final String md5 = - element.getAttribute("md5"); - - final List alternates = new LinkedList(); - - for (Element alternateElement: XMLUtils.getChildren( - element, "alternate-uri")) { - alternates.add(new URI(alternateElement.getTextContent())); - } - - if (uri.getScheme().equals("file")) { - return new ExtendedUri(uri, alternates, uri, size, md5); - } else { - return new ExtendedUri(uri, alternates, size, md5); - } - } catch (URISyntaxException e) { - throw new ParseException("Cannot parse extended URI", e); - } catch (NumberFormatException e) { - throw new ParseException("Cannot parse extended URI", e); - } - } - - public static Element saveExtendedUri( - final ExtendedUri uri, - final Element element) { - final Document document = element.getOwnerDocument(); - - element.setAttribute("size", Long.toString(uri.getSize())); - element.setAttribute("md5", uri.getMd5()); - - // the default uri would be either "local" (if it's present) or the - // "remote" one - Element uriElement = document.createElement("default-uri"); - if (uri.getLocal() != null) { - uriElement.setTextContent(uri.getLocal().toString()); - } else { - uriElement.setTextContent(uri.getRemote().toString()); - } - element.appendChild(uriElement); - - // if the "local" uri is not null, we should save the "remote" uri as the - // first alternate, unless it's the same as the local - if ((uri.getLocal() != null) && !uri.getRemote().equals(uri.getLocal())) { - uriElement = document.createElement("alternate-uri"); - - uriElement.setTextContent(uri.getRemote().toString()); - element.appendChild(uriElement); - } - - for (URI alternateUri: uri.getAlternates()) { - if (!alternateUri.equals(uri.getRemote())) { - uriElement = document.createElement("alternate-uri"); - - uriElement.setTextContent(alternateUri.toString()); - element.appendChild(uriElement); - } - } - - return element; - } - - public static List parseExtendedUrisList( - final Element element) throws ParseException { - final List uris = new LinkedList(); - - for (Element uriElement: getChildren(element)) { - uris.add(parseExtendedUri(uriElement)); - } - - return uris; - } - - public static Element saveExtendedUrisList( - final List uris, - final Element element) { - final Document document = element.getOwnerDocument(); - - for (ExtendedUri uri: uris) { - element.appendChild( - saveExtendedUri(uri, document.createElement("file"))); - } - - return element; - } - - public static Map parseLocalizedString( - final Element element) throws ParseException { - final Map map = new HashMap(); - - final Element defaultElement = getChild(element, "default"); - map.put(new Locale(StringUtils.EMPTY_STRING), StringUtils.parseAscii( - defaultElement.getTextContent())); - - for (Element localizedElement: getChildren(element, "localized")) { - final Locale locale = StringUtils.parseLocale( - localizedElement.getAttribute("locale")); - final String localizedString = StringUtils.parseAscii( - localizedElement.getTextContent()); - - map.put(locale, localizedString); - } - - return map; - } - - public static Element saveLocalizedString( - final Map map, - final Element element) { - final Document document = element.getOwnerDocument(); - - String s = map.get(new Locale(StringUtils.EMPTY_STRING)); - - final Element defaultElement = document.createElement("default"); - defaultElement.setTextContent(StringUtils.convertToAscii(s)); - element.appendChild(defaultElement); - - for (Map.Entry entry : map.entrySet()) { - if (!entry.getValue().equals(s)) { - final Element localizedElement = document.createElement("localized"); - - localizedElement.setAttribute("locale", entry.getKey().toString()); - localizedElement.setTextContent(StringUtils.convertToAscii(entry.getValue())); - - element.appendChild(localizedElement); - } - } - - return element; - } - - public static Feature parseFeature( - final Element element) throws ParseException { - final String id = element.getAttribute("id"); - final long offset = Long.parseLong(element.getAttribute("offset")); - final ExtendedUri iconUri = parseExtendedUri(getChild(element, "icon")); - - final Map displayNames = - parseLocalizedString(getChild(element, "display-name")); - final Map descriptions = - parseLocalizedString(getChild(element, "description")); - - return new Feature(id, offset, iconUri, displayNames, descriptions); - } - - public static Element saveFeature( - final Feature feature, - final Element element) { - final Document document = element.getOwnerDocument(); - - element.setAttribute("id", feature.getId()); - element.setAttribute("offset", Long.toString(feature.getOffset())); - - element.appendChild(saveExtendedUri( - feature.getIconUri(), document.createElement("icon"))); - element.appendChild(saveLocalizedString( - feature.getDisplayNames(), document.createElement("display-name"))); - element.appendChild(saveLocalizedString( - feature.getDescriptions(), document.createElement("description"))); - - return element; - } - - public static List parseFeaturesList( - final Element element) throws ParseException { - final List features = new LinkedList(); - - for (Element featureElement: XMLUtils.getChildren(element)) { - features.add(XMLUtils.parseFeature(featureElement)); - } - - return features; - } - - public static Element saveFeaturesList( - final List features, - final Element element) { - final Document document = element.getOwnerDocument(); - - for (Feature feature: features) { - element.appendChild( - saveFeature(feature, document.createElement("feature"))); - } - - return element; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String XSLT_REFORMAT_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/utils/xml/reformat.xslt"; // NOI18N - - private static final int MAXIMUM_SAVE_ATTEMPTS = - 3; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/applications/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/applications/Bundle.properties deleted file mode 100644 index 83a80f2cd04e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/applications/Bundle.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -JU.error.verification=Failed to execute the JDK verification procedure -JU.error.cannot.delete=Cannot delete {0} -JU.error.cannot.download.testjdk=Cannot download TestJDK.class from {0} -JU.error.cannot.canonize=Cannot canonize {0} diff --git a/nbi/engine/src/org/netbeans/installer/utils/applications/JavaUtils.java b/nbi/engine/src/org/netbeans/installer/utils/applications/JavaUtils.java deleted file mode 100644 index 0008b099566d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/applications/JavaUtils.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.applications; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.ExecutionResults; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.system.WindowsNativeUtils; -import org.netbeans.installer.utils.system.windows.WindowsRegistry; -import static org.netbeans.installer.utils.system.windows.WindowsRegistry.HKCU; -import static org.netbeans.installer.utils.system.windows.WindowsRegistry.HKLM; - -/** - * - * @author Kirill Sorokin - */ -public class JavaUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static Map knownJdks = new HashMap<>(); - - public static boolean isJavaHome(File javaHome) { - if (!javaHome.exists() || !javaHome.isDirectory()) { - return false; - } - - File probe = getExecutable(javaHome); - if (!probe.exists() || !probe.isFile()) { - return false; - } - - // check for lib subdir - probe = new File(javaHome, "lib"); - if (!probe.exists() || !probe.isDirectory()) { - return false; - } - - String extension = ""; - if (SystemUtils.isWindows()) { - extension = ".exe"; - } - - probe = new File(javaHome, "bin/javac" + extension); - if (!probe.exists() || !probe.isFile()) { - probe = new File(javaHome, "bin/java" + extension); - if (!probe.exists() || !probe.isFile()) { - return false; - } - } - - return true; - } - - public static boolean isJdk(File javaHome) { - if (!isJavaHome(javaHome)) { - return false; - } - - String extension = ""; - if (SystemUtils.isWindows()) { - extension = ".exe"; - } - - if (!SystemUtils.isMacOS()) { - File javac = new File(javaHome, "bin/javac" + extension); - if (!javac.exists() || !javac.isFile()) { - return false; - } - } - - return true; - } - - public static boolean isRecommended(Version version) { - /*to and from versions - not recommended - all JDK 7 versions older than 7u10 */ - return version.olderThan(criticalLowVersion) || version.newerThan(criticalHighVersion); - } - - public static void addJavaInfo(final File location, final JavaInfo info) { - if(knownJdks.get(location)==null) { - knownJdks.put(location, info); - } - } - - public static void removeJavaInfo(final File location) { - if(knownJdks.get(location)!=null) { - knownJdks.remove(location); - } - } - - public static Version getVersion(File javaHome) { - final JavaInfo info = getInfo(javaHome); - - return (info == null) ? null : info.getVersion(); - } - - public static JavaInfo getInfo(final File javaHome) { - return getInfo(javaHome, false); - } - - public static JavaInfo getInfo(final File javaHome, boolean ignoreKnownJdks) { - File location = FileUtils.getNormalizedPathFile(javaHome); - - if (!ignoreKnownJdks && knownJdks.get(location) != null) { - return knownJdks.get(location); - } - - if (!isJavaHome(location)) { - return null; - } - - final File executable = getExecutable(location); - - final File testJdk; - try { - testJdk = FileProxy.getInstance().getFile(TEST_JDK_URI); - } catch (DownloadException e) { - ErrorManager.notifyError(ResourceUtils.getString( - JavaUtils.class, ERROR_CANNOT_DOWNLOAD_TESTJDK_KEY, TEST_JDK_URI), e); - return null; - } - - JavaInfo jdkInfo = null; - try { - final ExecutionResults results = SystemUtils.executeCommand( - executable.getAbsolutePath(), - "-classpath", - testJdk.getParentFile().getAbsolutePath(), - TEST_JDK_CLASSNAME); - - jdkInfo = JavaInfo.getInfo(results.getStdOut()); - - if (jdkInfo != null) { - LogManager.log("... put jdk info to the Java map"); - knownJdks.put(location, jdkInfo); - } else { - LogManager.log("... can`t get jdkInfo from " + location); - } - } catch (IOException e) { - LogManager.log(ResourceUtils.getString( - JavaUtils.class, ERROR_VERIFICATION_KEY), e); - } - - if (!testJdk.delete()) { - ErrorManager.notifyError(ResourceUtils.getString( - JavaUtils.class, ERROR_CANNOT_DELETE_KEY, testJdk.getAbsolutePath())); - } - - return jdkInfo; - } - - public static File getExecutable(File javaHome) { - if (SystemUtils.isWindows()) { - return new File(javaHome, "bin/java.exe"); - } else { - return new File(javaHome, "bin/java"); - } - } - - public static File getExecutableW(File javaHome) { - if (SystemUtils.isWindows()) { - return new File(javaHome, "bin/javaw.exe"); - } else { - return new File(javaHome, "bin/java"); - } - } - - // windows-only ///////////////////////////////////////////////////////////////// - public static void createJdkKey(Version version, String javaHome) throws NativeException { - if (!SystemUtils.isWindows()) { - return; - } - - final WindowsRegistry registry = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - - String key = registry.constructKey(JDK_KEY, version.toJdkStyle()); - - setJdkData(key, version, javaHome); - updateJdkKey(registry.constructKey(JDK_KEY, version.toMinor())); - updateCurrentVersion(); - } - - public static void deleteJdkKey(Version version, String javaHome) throws NativeException { - if (!SystemUtils.isWindows()) { - return; - } - - final WindowsRegistry registry = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - - String key = registry.constructKey(JDK_KEY, version.toJdkStyle()); - int section = getJDKRegistrySection(registry); - if (registry.keyExists(section, key) && registry.valueExists(section, key, JAVAHOME_VALUE)) { - String currentJavaHome = registry.getStringValue(section, key, JAVAHOME_VALUE); - if (currentJavaHome.equals(javaHome)) { - registry.deleteKey(section, key); - updateJdkKey(registry.constructKey(JDK_KEY, version.toMinor())); - } - } - - updateCurrentVersion(); - } - - public static File findJDKHome(Version jdkVersion) { - return findJavaHome(JDK_KEY, jdkVersion); - } - public static File findJreHome(Version jdkVersion) { - return findJavaHome(JRE_KEY, jdkVersion); - } - - private static File findJavaHome(String javaKey, Version jdkVersion) { - File result = null; - try { - if(SystemUtils.isWindows()) { - final String version = jdkVersion.toJdkStyle(); - LogManager.log("... checking if JDK " + version + " is already installed"); - WindowsRegistry winreg = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - if(winreg.keyExists(HKLM, javaKey, version)) { - final String versKey = javaKey + WindowsRegistry.SEPARATOR + version; - if(winreg.valueExists(HKLM, versKey, JAVAHOME_VALUE)) { - final String javaHome = winreg.getStringValue(HKLM, versKey,JAVAHOME_VALUE); - if(JavaUtils.getInfo(new File(javaHome))!=null) { - result = new File(javaHome); - } else { - LogManager.log("... no Java at " + javaHome); - } - } else { - LogManager.log("... cannot find JavaHome value for this Java"); - } - } else { - LogManager.log("... cannot find key for this Java"); - } - } - } catch (NativeException e) { - LogManager.log(e); - } - return result; - } - - // private ////////////////////////////////////////////////////////////////////// - private static int getJDKRegistrySection(WindowsRegistry registry) throws NativeException { - return (registry.canModifyKey(HKLM,JDK_KEY) ? HKLM : HKCU); - } - - private static void setJdkData(String key, Version version, String javaHome) throws NativeException { - final WindowsRegistry registry = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - int section = getJDKRegistrySection(registry); - registry.createKey(section, key); - registry.setStringValue(section, key, JAVAHOME_VALUE, javaHome); - registry.setStringValue(section, key, MICROVERSION_VALUE, version.getMicro()); - } - - private static void updateJdkKey(String key) throws NativeException { - final WindowsRegistry registry = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - int section = getJDKRegistrySection(registry); - registry.createKey(section, key); - - String javaHome = null; - Version version = null; - for (String subkey: registry.getSubKeys(section, JDK_KEY)) { - if (subkey.startsWith(key) && !subkey.equals(key) && registry.valueExists(section, subkey, JAVAHOME_VALUE)) { - final String tempJavaHome = registry.getStringValue(section, subkey, JAVAHOME_VALUE); - final Version tempVersion = JavaUtils.getVersion(new File(tempJavaHome)); - if ((tempVersion != null) && ((version == null) || version.olderThan(tempVersion))) { - javaHome = tempJavaHome; - version = tempVersion; - } - } - } - - if ((version != null) && (javaHome != null)) { - setJdkData(key, version, javaHome); - } else { - registry.deleteKey(section, key); - } - } - - private static void updateCurrentVersion() throws NativeException { - final WindowsRegistry registry = ((WindowsNativeUtils) SystemUtils.getNativeUtils()).getWindowsRegistry(); - int section = getJDKRegistrySection(registry); - registry.createKey(section, JDK_KEY); - - String name = null; - Version version = null; - - for (String key: registry.getSubKeys(section, JDK_KEY)) { - if (registry.valueExists(section, key, JAVAHOME_VALUE)) { - String tempName = registry.getKeyName(key); - String tempJavaHome = registry.getStringValue(section, key, JAVAHOME_VALUE); - Version tempVersion = JavaUtils.getVersion(new File(tempJavaHome)); - if ((tempVersion != null) && ((version == null) || version.olderThan(tempVersion))) { - name = tempName; - version = tempVersion; - } - } - } - - if ((name != null) && (version != null)) { - registry.setStringValue(section, JDK_KEY, CURRENT_VERSION_VALUE, name); - } else { - registry.deleteKey(section, JDK_KEY); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private JavaUtils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class JavaInfo { - ///////////////////////////////////////////////////////////////////////////// - // Static - public static JavaInfo getInfo(final String string) { - final String[] lines = StringUtils.splitByLines(string); - - Version version = null; - String vendor; - String osName; - String osArch; - - boolean nonFinal = false; - - if (lines.length == (TEST_JDK_OUTPUT_PARAMETERS + 1)) { - final String javaVersion = lines[0]; // java.version - final String javaVmVersion = lines[1]; // java.vm.version - - vendor = lines[2]; // java.vendor - osName = lines[3]; // os.name - osArch = lines[4]; // os.arch - LogManager.log("... java.version = " + javaVersion); - LogManager.log("... java.vm.version = " + javaVmVersion); - LogManager.log("... java.vendor = " + vendor); - LogManager.log("... os.name = " + osName); - LogManager.log("... os.arch = " + osArch); - - String versionString; - - // if java.vm.version contains java.version, then use it, as it - // usually contains more detailed info - if (javaVmVersion.contains(javaVersion)) { - versionString = javaVmVersion.substring( - javaVmVersion.indexOf(javaVersion)); - } else { - versionString = javaVersion; - } - - // check whether this particular jvm is non final - final Matcher nonFinalMatcher = Pattern.compile( - NON_FINAL_JVM_PATTERN).matcher(versionString); - if (nonFinalMatcher.find()) { - versionString = versionString.replaceAll( - NON_FINAL_JVM_PATTERN, - StringUtils.EMPTY_STRING); - - nonFinal = true; - } - - // convert 1.6.0-b105 to 1.6.0.0.105 - if (versionString.matches( - "[0-9]+\\.[0-9]+\\.[0-9]+-b[0-9]+")) { - versionString = versionString.replace("-b", ".0."); - } - - // convert 1.6.0_01-b105 to 1.6.0_01.105 - if (versionString.matches( - "[0-9]+\\.[0-9]+\\.[0-9]+_[0-9]+-b[0-9]+")) { - versionString = versionString.replace("-b", "."); - } - - // hack for BEA: 1.6.0-20061129 -> 1.6.0.0.20061129 - if (vendor.contains("BEA")) { - versionString = versionString.replaceAll( - "([0-9]+\\.[0-9]+\\.[0-9])+-([0-9]+)", - "$1.0.$2"); - } - LogManager.log("... version string : " + versionString); - // and create the version - final Matcher matcher = Pattern. - compile("[0-9][0-9_\\.\\-]+[0-9]"). - matcher(versionString); - - if (matcher.find()) { - version = Version.getVersion(matcher.group()); - } - // For JDK release version like 12, java.vm.version = 12+33 - // which doesn't match above pattern string - // hence use java.version string 12 - if (version == null) { - version = Version.getVersion(javaVersion); - } - - // if the version was created successfully, then we can provide a - // JavaInfo object - if (version != null) { - return new JavaInfo(version, vendor, osArch, nonFinal); - } - } else { - LogManager.log("... different lines number [" + lines.length + "]"); - for(int j=0;j,Iterator { - private String[] arguments ; - private int index ; - - public CLIArgumentsList(String [] args) { - this.arguments = args; - index = -1; - } - - public String next() { - index++; - return arguments[index]; - } - - public boolean hasNext() { - return (index + 1 < arguments.length); - } - public int length() { - return arguments.length; - } - - public int getIndex() { - return index; - } - public Iterator iterator() { - return this; - } - - public void remove() { - //do nothing - } - @Override - public String toString() { - return (arguments.length==0) ? StringUtils.EMPTY_STRING : - "[" + StringUtils.asString(arguments,"], [") + "]";//NOI18N - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java deleted file mode 100644 index 2816f02118e6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.cli.options.*; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.helper.ErrorLevel; - -/** - * - * @author Dmitry Lipin - */ -public class CLIHandler { - public static final String OPTIONS_LIST = - "data/clioptions.list";//NOI18N - private CLIArgumentsList args; - - public CLIHandler(String[] arguments) { - args = new CLIArgumentsList(arguments); - } - - public void proceed() { - if (args.hasNext()) { - LogManager.log("... parsing arguments : " + args.toString()); // NOI18N - List list = getOptions(); - - while (args.hasNext()) { - final String currentArg = args.next(); - for (CLIOption option : list) { - if (option.canExecute(currentArg)) { - try { - option.init(); - option.validateOptions(args); - option.execute(args); - } catch (CLIOptionException e) { - ErrorManager.notifyWarning(e.getMessage()); - } finally { - option.finish(); - break; - } - } - } - } - } else { - LogManager.log("... no command line arguments were specified"); // NOI18N - } - } - - private List getOptions() { - List list = new ArrayList(); - loadDefaultOptions(list); - loadAdditionalOptions(list); - return list; - } - - private void loadDefaultOptions(List list) { - list.add(new BundlePropertiesOption()); - list.add(new CreateBundleOption()); - list.add(new ForceInstallOption()); - list.add(new ForceUninstallOption()); - list.add(new IgnoreLockOption()); - list.add(new LocaleOption()); - list.add(new LookAndFeelOption()); - list.add(new NoSpaceCheckOption()); - list.add(new PlatformOption()); - list.add(new PropertiesOption()); - list.add(new RecordOption()); - list.add(new RegistryOption()); - list.add(new SilentOption()); - list.add(new StateOption()); - list.add(new SuggestInstallOption()); - list.add(new SuggestUninstallOption()); - list.add(new TargetOption()); - list.add(new UserdirOption()); - } - - private void loadAdditionalOptions(List list) { - InputStream is = ResourceUtils.getResource(OPTIONS_LIST); - if (is != null) { - LogManager.log(ErrorLevel.MESSAGE, "... loading additional CLI option classes, if necessary"); - try { - final String str = StringUtils.readStream(is); - final String[] lines = StringUtils.splitByLines(str); - for (String classname : lines) { - if (classname.trim().length() > 0) { - if(classname.trim().startsWith("#")) {//NOI18N - LogManager.log(ErrorLevel.DEBUG, "... skipping line : " + classname); - continue; - } - try { - Class cl = Class.forName(classname); - Object obj = cl.newInstance(); - if (obj instanceof CLIOption) { - LogManager.log(ErrorLevel.MESSAGE, "... adding CLI class : " + obj.getClass().getName()); - list.add((CLIOption) obj); - } else { - LogManager.log(ErrorLevel.WARNING, "... the requested class is not instance of CLIOption:"); - LogManager.log(ErrorLevel.WARNING, "...... classname : " + classname); - LogManager.log(ErrorLevel.WARNING, "...... CLIOption : " + CLIOption.class.getName()); - } - } catch (ClassNotFoundException e) { - LogManager.log(ErrorLevel.WARNING, e); - } catch (IllegalAccessException e) { - LogManager.log(ErrorLevel.WARNING, e); - } catch (InstantiationException e) { - LogManager.log(ErrorLevel.WARNING, e); - } catch (NoClassDefFoundError e) { - LogManager.log(ErrorLevel.WARNING, e); - } catch (UnsupportedClassVersionError e) { - LogManager.log(ErrorLevel.WARNING, e); - } - } - } - } catch (IOException e) { - LogManager.log(ErrorLevel.WARNING, e); - } finally { - try { - is.close(); - } catch (IOException e) { - LogManager.log(ErrorLevel.DEBUG, e); - } - } - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java deleted file mode 100644 index e0d3577c5bf0..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli; - -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public abstract class CLIOption { - - protected static final String PARSING_ARGUMENT_STRING = - "parsing command line parameter \"{0}\"";//NOI18N - protected static final String UNARY_ARG_VALUE = - Boolean.toString(true); // NOI18N - - public void init() { - LogManager.logIndent(StringUtils.format( - PARSING_ARGUMENT_STRING, getName())); // NOI18N - } - public boolean canExecute(String arg) { - return getName().equalsIgnoreCase(arg); - } - public void finish() { - LogManager.unindent(); // NOI18N - } - - public void validateOptions(CLIArgumentsList arguments) throws CLIOptionException { - validateArgumentsNumber(arguments); - } - - private void validateArgumentsNumber(CLIArgumentsList arguments) throws CLIOptionException { - final int number = getNumberOfArguments(); - if (number != 0 && (number + arguments.getIndex()) >= arguments.length()) { - throw new CLIOptionException(getLackOfArgumentsMessage()); - } - } - - protected String getLackOfArgumentsMessage() { - return null; - } - - protected abstract int getNumberOfArguments(); - - public abstract String getName(); - - public abstract void execute(CLIArgumentsList arguments) throws CLIOptionException; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionOneArgument.java b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionOneArgument.java deleted file mode 100644 index 132d79b2a19c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionOneArgument.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli; - -/** - * - * @author Dmitry Lipin - */ -public abstract class CLIOptionOneArgument extends CLIOption{ - - @Override - protected int getNumberOfArguments() { - return 1; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionTwoArguments.java b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionTwoArguments.java deleted file mode 100644 index cfea1b55238b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionTwoArguments.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli; - -/** - * - * @author Dmitry Lipin - */ -public abstract class CLIOptionTwoArguments extends CLIOption { - - @Override - protected int getNumberOfArguments() { - return 2; - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionZeroArguments.java b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionZeroArguments.java deleted file mode 100644 index fe382ee3f955..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOptionZeroArguments.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli; - -/** - * - * @author Dmitry Lipin - */ -public abstract class CLIOptionZeroArguments extends CLIOption { - - @Override - protected int getNumberOfArguments() { - return 0; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties deleted file mode 100644 index ee871a89ad2d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# *Option.java -O.warning.bad.look.and.feel.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.target.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.locale.arg.param=Invalid parameter for command line argument "{0}" -- "{1}".\nShould be "{0} [_[_]]". -O.warning.bad.locale.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} [_[_]]". -O.warning.missing.state.file=The specified state file "{1}", does not exist.\n"{0}" parameter is ignored. -O.warning.bag.state.file.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.target.state.file.exists=The specified state file "{1}", exists.\n"{0}" parameter is ignored. -O.warning.bad.target.state.file.arg=Required parameter missing for command line argument\n"{0}". Should be "{0} ". -O.warning.bundle.file.exists=The specified target file "{1}", exists.\n"{0}" parameter is ignored. -O.warning.bad.create.bundle.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.userdir.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.platform.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.registry.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.properties.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". -O.warning.bad.bundle.properties.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/BundlePropertiesOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/BundlePropertiesOption.java deleted file mode 100644 index badd64889e4a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/BundlePropertiesOption.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.Installer; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.cli.CLIArgumentsList; -import org.netbeans.installer.utils.cli.CLIOptionOneArgument; - -/** - * - * @author Dmitry Lipin - */ -public class BundlePropertiesOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Installer.BUNDLE_PROPERTIES_FILE_PROPERTY, - arguments.next()); - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString(BundlePropertiesOption.class, - WARNING_BAD_BUNDLE_PROPERTIES_ARG_KEY, BUNDLE_PROPERTIES_ARG); - } - - public String getName() { - return BUNDLE_PROPERTIES_ARG; - } - public static final String BUNDLE_PROPERTIES_ARG = - "--bundle-properties"; // NOI18N - private static final String WARNING_BAD_BUNDLE_PROPERTIES_ARG_KEY = - "O.warning.bad.bundle.properties.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/CreateBundleOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/CreateBundleOption.java deleted file mode 100644 index 438edbaae9e8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/CreateBundleOption.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.io.File; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.cli.CLIArgumentsList; -import org.netbeans.installer.utils.helper.ExecutionMode; - -/** - * - * @author Dmitry Lipin - */ -public class CreateBundleOption extends CLIOptionOneArgument { - - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - File targetFile = new File(arguments.next()).getAbsoluteFile(); - if (targetFile.exists()) { - throw new CLIOptionException(ResourceUtils.getString( - CreateBundleOption.class, - WARNING_BUNDLE_FILE_EXISTS_KEY, - CREATE_BUNDLE_ARG, - targetFile)); - } else { - ExecutionMode.setCurrentExecutionMode( - ExecutionMode.CREATE_BUNDLE); - System.setProperty( - Registry.CREATE_BUNDLE_PATH_PROPERTY, - targetFile.getAbsolutePath()); - } - } - - public String getName() { - return CREATE_BUNDLE_ARG; - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - CreateBundleOption.class, - WARNING_BAD_CREATE_BUNDLE_ARG_KEY, - CREATE_BUNDLE_ARG); - } - public static final String CREATE_BUNDLE_ARG = - "--create-bundle";// NOI18N - private static final String WARNING_BUNDLE_FILE_EXISTS_KEY = - "O.warning.bundle.file.exists"; // NOI18N - private static final String WARNING_BAD_CREATE_BUNDLE_ARG_KEY = - "O.warning.bad.create.bundle.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceInstallOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceInstallOption.java deleted file mode 100644 index 292d4e0d4504..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceInstallOption.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.cli.CLIArgumentsList; -import org.netbeans.installer.utils.cli.CLIOptionZeroArguments; - -/** - * - * @author Dmitry Lipin - */ -public class ForceInstallOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Registry.FORCE_INSTALL_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return FORCE_INSTALL_ARG; - } - public static final String FORCE_INSTALL_ARG = - "--force-install";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceUninstallOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceUninstallOption.java deleted file mode 100644 index 4c310e4792d9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/ForceUninstallOption.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class ForceUninstallOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Registry.FORCE_UNINSTALL_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return FORCE_UNINSTALL_ARG; - } - public static final String FORCE_UNINSTALL_ARG = - "--force-uninstall";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/IgnoreLockOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/IgnoreLockOption.java deleted file mode 100644 index e8c8c56edc85..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/IgnoreLockOption.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.Installer; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class IgnoreLockOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Installer.IGNORE_LOCK_FILE_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return IGNORE_LOCK_ARG; - } - public static final String IGNORE_LOCK_ARG = - "--ignore-lock";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/LocaleOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/LocaleOption.java deleted file mode 100644 index 7e559979dcbe..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/LocaleOption.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.util.Locale; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class LocaleOption extends CLIOptionOneArgument { - - private Locale targetLocale; - - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - Locale.setDefault(targetLocale); - LogManager.log( - "... locale set to: " + targetLocale); // NOI18N - - } - - private void initializeLocale(String value) { - final String[] valueParts = value.split(StringUtils.UNDERSCORE); - switch (valueParts.length) { - case 1: - targetLocale = new Locale( - valueParts[0]); - break; - case 2: - targetLocale = new Locale( - valueParts[0], - valueParts[1]); - break; - case 3: - targetLocale = new Locale( - valueParts[0], - valueParts[1], - valueParts[2]); - break; - default: - targetLocale = null; - break; - } - } - - @Override - public void validateOptions(CLIArgumentsList arguments) throws CLIOptionException { - super.validateOptions(arguments); - final String value = arguments.next(); - - initializeLocale(value); - - if (targetLocale == null) { - LogManager.log( - "... locale is not set properly, using " + // NOI18N - "system default: " + Locale.getDefault()); // NOI18N - throw new CLIOptionException(ResourceUtils.getString( - LocaleOption.class, - WARNING_BAD_LOCALE_ARG_PARAM_KEY, - LOCALE_ARG, - value)); - } - - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - LocaleOption.class, - WARNING_BAD_LOCALE_ARG_KEY, - LOCALE_ARG); - } - - public String getName() { - return LOCALE_ARG; - } - public static final String LOCALE_ARG = - "--locale";// NOI18N - private static final String WARNING_BAD_LOCALE_ARG_PARAM_KEY = - "O.warning.bad.locale.arg.param"; // NOI18N - private static final String WARNING_BAD_LOCALE_ARG_KEY = - "O.warning.bad.locale.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/LookAndFeelOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/LookAndFeelOption.java deleted file mode 100644 index 2ace586b9933..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/LookAndFeelOption.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class LookAndFeelOption extends CLIOptionOneArgument { - - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - final String value = arguments.next(); - System.setProperty( - UiUtils.LAF_CLASS_NAME_PROPERTY, - value); - - LogManager.log( - "... class name: " + value); // NOI18N - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - LookAndFeelOption.class, - WARNING_BAD_LOOK_AND_FEEL_ARG_KEY, - LOOK_AND_FEEL_ARG); - } - - public String getName() { - return LOOK_AND_FEEL_ARG; - } - private static final String WARNING_BAD_LOOK_AND_FEEL_ARG_KEY = - "O.warning.bad.look.and.feel.arg"; // NOI18N - public static final String LOOK_AND_FEEL_ARG = - "--look-and-feel";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/NoSpaceCheckOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/NoSpaceCheckOption.java deleted file mode 100644 index 3ecc923c9e35..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/NoSpaceCheckOption.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class NoSpaceCheckOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(SystemUtils.NO_SPACE_CHECK_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return NO_SPACE_CHECK_ARG; - } - public static final String NO_SPACE_CHECK_ARG = - "--nospacecheck"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/PlatformOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/PlatformOption.java deleted file mode 100644 index 7ca4825af174..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/PlatformOption.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class PlatformOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Registry.TARGET_PLATFORM_PROPERTY, arguments.next()); - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - PlatformOption.class, - WARNING_BAD_PLATFORM_ARG_KEY, - PLATFORM_ARG); - } - - public String getName() { - return PLATFORM_ARG; - } - public static final String PLATFORM_ARG = - "--platform";// NOI18N - private static final String WARNING_BAD_PLATFORM_ARG_KEY = - "O.warning.bad.platform.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/PropertiesOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/PropertiesOption.java deleted file mode 100644 index 7e40dcdbc246..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/PropertiesOption.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class PropertiesOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - final File propertiesFile = new File(arguments.next()); - InputStream is = null; - try { - is = new FileInputStream(propertiesFile); - Properties props = new Properties(); - props.load(is); - System.getProperties().putAll(props); - } catch (IOException e) { - LogManager.log(e); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - LogManager.log(e); - } - } - } - - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - PropertiesOption.class, - WARNING_BAD_PROPERTIES_ARG_KEY, - PROPERTIES_ARG); - } - - public String getName() { - return PROPERTIES_ARG; - } - public static final String PROPERTIES_ARG = - "--properties";// NOI18N - private static final String WARNING_BAD_PROPERTIES_ARG_KEY = - "O.warning.bad.properties.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/RecordOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/RecordOption.java deleted file mode 100644 index 8ecbfc728709..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/RecordOption.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.io.File; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class RecordOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - File stateFile = new File(arguments.next()).getAbsoluteFile(); - if (stateFile.exists()) { - throw new CLIOptionException(ResourceUtils.getString( - RecordOption.class, - WARNING_TARGET_STATE_FILE_EXISTS_KEY, - RECORD_ARG, - stateFile)); - } else { - System.setProperty( - Registry.TARGET_STATE_FILE_PATH_PROPERTY, - stateFile.getAbsolutePath()); - } - - - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - RecordOption.class, - WARNING_BAD_TARGET_STATE_FILE_ARG_KEY, - RECORD_ARG); - } - - public String getName() { - return RECORD_ARG; - } - public static final String RECORD_ARG = - "--record";// NOI18N - private static final String WARNING_TARGET_STATE_FILE_EXISTS_KEY = - "O.warning.target.state.file.exists"; // NOI18N - private static final String WARNING_BAD_TARGET_STATE_FILE_ARG_KEY = - "O.warning.bad.target.state.file.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/RegistryOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/RegistryOption.java deleted file mode 100644 index df42941899cf..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/RegistryOption.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.util.Arrays; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class RegistryOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - - final String value = arguments.next(); - - final String existing = System.getProperty( - Registry.REMOTE_PRODUCT_REGISTRIES_PROPERTY); - - if (existing == null) { - System.setProperty( - Registry.REMOTE_PRODUCT_REGISTRIES_PROPERTY, - value); - } else { - if (!Arrays.asList( - existing.split(StringUtils.LF)).contains(value)) { - System.setProperty( - Registry.REMOTE_PRODUCT_REGISTRIES_PROPERTY, - existing + StringUtils.LF + value); - } - } - - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - RecordOption.class, - WARNING_BAD_REGISTRY_ARG_KEY, - REGISTRY_ARG); - } - - public String getName() { - return REGISTRY_ARG; - } - public static final String REGISTRY_ARG = - "--registry";// NOI18N - private static final String WARNING_BAD_REGISTRY_ARG_KEY = - "O.warning.bad.registry.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SilentOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/SilentOption.java deleted file mode 100644 index ac9cb75eefb4..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SilentOption.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.helper.UiMode; - - -/** - * - * @author Dmitry Lipin - */ -public class SilentOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - UiMode.setCurrentUiMode(UiMode.SILENT); - } - - public String getName() { - return SILENT_ARG; - } - public static final String SILENT_ARG = - "--silent";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/StateOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/StateOption.java deleted file mode 100644 index 6205981cfec9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/StateOption.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import java.io.File; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class StateOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - File stateFile = new File(arguments.next()).getAbsoluteFile(); - if (!stateFile.exists()) { - throw new CLIOptionException(ResourceUtils.getString( - StateOption.class, - WARNING_MISSING_STATE_FILE_KEY, - STATE_ARG, - stateFile)); - } else { - System.setProperty( - Registry.SOURCE_STATE_FILE_PATH_PROPERTY, - stateFile.getAbsolutePath()); - } - - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - StateOption.class, - WARNING_BAD_STATE_FILE_ARG_KEY, - STATE_ARG); - } - - public String getName() { - return STATE_ARG; - } - private static final String WARNING_MISSING_STATE_FILE_KEY = - "O.warning.missing.state.file"; // NOI18N - private static final String WARNING_BAD_STATE_FILE_ARG_KEY = - "O.warning.bag.state.file.arg"; // NOI18N - public static final String STATE_ARG = - "--state";// NOI18N -} - diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestInstallOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestInstallOption.java deleted file mode 100644 index e508ae18cb73..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestInstallOption.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class SuggestInstallOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Registry.SUGGEST_INSTALL_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return SUGGEST_INSTALL_ARG; - } - public static final String SUGGEST_INSTALL_ARG = - "--suggest-install";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestUninstallOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestUninstallOption.java deleted file mode 100644 index b5209945fd37..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/SuggestUninstallOption.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.*; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class SuggestUninstallOption extends CLIOptionZeroArguments { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Registry.SUGGEST_UNINSTALL_PROPERTY, UNARY_ARG_VALUE); - } - - public String getName() { - return SUGGEST_UNINSTALL_ARG; - } - public static final String SUGGEST_UNINSTALL_ARG = - "--suggest-uninstall";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/TargetOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/TargetOption.java deleted file mode 100644 index d2aa3107096c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/TargetOption.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.exceptions.CLIOptionException; -import org.netbeans.installer.utils.cli.CLIArgumentsList; -import org.netbeans.installer.utils.cli.CLIOptionTwoArguments; - -/** - * - * @author Dmitry Lipin - */ -public class TargetOption extends CLIOptionTwoArguments { - - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - final String uid = arguments.next(); - final String version = arguments.next(); - - System.setProperty(Registry.TARGET_COMPONENT_UID_PROPERTY, uid); - System.setProperty(Registry.TARGET_COMPONENT_VERSION_PROPERTY, version); - - LogManager.log( - "target component:"); // NOI18N - LogManager.log( - "... uid: " + uid); // NOI18N - LogManager.log( - "... version: " + version); // NOI18N - } - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - TargetOption.class, WARNING_BAD_TARGET_ARG_KEY, - TARGET_ARG); - } - - public String getName() { - return TARGET_ARG; - } - public static final String TARGET_ARG = - "--target";// NOI18N - private static final String WARNING_BAD_TARGET_ARG_KEY = - "O.warning.bad.target.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/cli/options/UserdirOption.java b/nbi/engine/src/org/netbeans/installer/utils/cli/options/UserdirOption.java deleted file mode 100644 index 7583818c75db..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/UserdirOption.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.cli.options; - -import org.netbeans.installer.utils.cli.CLIOptionOneArgument; -import java.io.File; -import org.netbeans.installer.Installer; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.cli.CLIArgumentsList; -import org.netbeans.installer.utils.exceptions.CLIOptionException; - -/** - * - * @author Dmitry Lipin - */ -public class UserdirOption extends CLIOptionOneArgument { - - @Override - public void execute(CLIArgumentsList arguments) throws CLIOptionException { - System.setProperty(Installer.LOCAL_DIRECTORY_PATH_PROPERTY, - new File(arguments.next()).getAbsolutePath()); - } - - public String getName() { - return USERDIR_ARG; - } - - - @Override - protected String getLackOfArgumentsMessage() { - return ResourceUtils.getString( - UserdirOption.class, - WARNING_BAD_USERDIR_ARG_KEY, - USERDIR_ARG); - } - public static final String USERDIR_ARG = - "--userdir";// NOI18N - private static final String WARNING_BAD_USERDIR_ARG_KEY = - "O.warning.bad.userdir.arg"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/CLIOptionException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/CLIOptionException.java deleted file mode 100644 index 2f3e338c0ef8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/CLIOptionException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Dmitry Lipin - */ -public class CLIOptionException extends Exception{ -/** - * - * @param message - */ - public CLIOptionException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public CLIOptionException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/DownloadException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/DownloadException.java deleted file mode 100644 index 275ec8e68856..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/DownloadException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class DownloadException extends Exception { - /** - * - * @param message - */ - public DownloadException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public DownloadException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/FinalizationException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/FinalizationException.java deleted file mode 100644 index 791ebc83134f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/FinalizationException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class FinalizationException extends Exception { - /** - * - * @param message - */ - public FinalizationException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public FinalizationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/HTTPException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/HTTPException.java deleted file mode 100644 index fc1896c68d67..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/HTTPException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -import java.io.IOException; - -/** - * - * @author Kirill Sorokin - */ -public class HTTPException extends IOException { - /** - * - * @param message - */ - public HTTPException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public HTTPException(String message, Throwable cause) { - super(message); - - initCause(cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/IgnoreAttributeException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/IgnoreAttributeException.java deleted file mode 100644 index a55dff078e8d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/IgnoreAttributeException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Dmitry Lipin - */ -public class IgnoreAttributeException extends Exception { - /** Creates a new instance of IgnoreAttributeException - * - * @param message - */ - public IgnoreAttributeException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public IgnoreAttributeException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/InitializationException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/InitializationException.java deleted file mode 100644 index 3f3a03fbba51..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/InitializationException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class InitializationException extends Exception { - /** - * - * @param message - */ - public InitializationException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public InitializationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/InstallationException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/InstallationException.java deleted file mode 100644 index d035f2242f6a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/InstallationException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class InstallationException extends Exception { - /** - * - * @param message - */ - public InstallationException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public InstallationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/NativeException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/NativeException.java deleted file mode 100644 index d4a9c57bb169..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/NativeException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class NativeException extends Exception { - /** - * - * @param message - */ - public NativeException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public NativeException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/NotImplementedException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/NotImplementedException.java deleted file mode 100644 index 37eae2a28202..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/NotImplementedException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Danila_Dugurov - */ -public class NotImplementedException extends RuntimeException { - - public NotImplementedException() { - super("Not implemented yet!"); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/ParseException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/ParseException.java deleted file mode 100644 index 15b688664ac2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/ParseException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class ParseException extends Exception { - /** - * - * @param message - */ - public ParseException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public ParseException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnexpectedExceptionError.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnexpectedExceptionError.java deleted file mode 100644 index 780756c1dcda..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnexpectedExceptionError.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Danila_Dugurov - */ -public class UnexpectedExceptionError extends RuntimeException { - - public UnexpectedExceptionError(Throwable cause) { - super(cause); - } - - public UnexpectedExceptionError(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UninstallationException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/UninstallationException.java deleted file mode 100644 index f4b933516f89..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UninstallationException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class UninstallationException extends Exception { - /** - * - * @param message - */ - public UninstallationException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public UninstallationException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnrecognizedObjectException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnrecognizedObjectException.java deleted file mode 100644 index 3c6f13d95ec8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnrecognizedObjectException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class UnrecognizedObjectException extends Exception { - /** - * - * @param message - */ - public UnrecognizedObjectException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public UnrecognizedObjectException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnresolvedDependencyException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnresolvedDependencyException.java deleted file mode 100644 index a56b6c0418d7..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnresolvedDependencyException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class UnresolvedDependencyException extends Exception { - /** - * - * @param message - */ - public UnresolvedDependencyException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public UnresolvedDependencyException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnsupportedActionException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnsupportedActionException.java deleted file mode 100644 index 2c963eec5c8c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/UnsupportedActionException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class UnsupportedActionException extends Exception { - /** - * - * @param message - */ - public UnsupportedActionException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public UnsupportedActionException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/exceptions/XMLException.java b/nbi/engine/src/org/netbeans/installer/utils/exceptions/XMLException.java deleted file mode 100644 index 158decb1cab2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/exceptions/XMLException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.exceptions; - -/** - * - * @author Kirill Sorokin - */ -public class XMLException extends Exception { - /** - * - * @param message - */ - public XMLException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public XMLException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ApplicationDescriptor.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ApplicationDescriptor.java deleted file mode 100644 index 15aca6a344a8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ApplicationDescriptor.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Kirill Sorokin - */ -public class ApplicationDescriptor { - private String uid; - - private String displayName; - private String icon; - - private String installPath; - - private String [] uninstallCommand; - private String [] modifyCommand; - - private Map parameters; - - public ApplicationDescriptor( - final String uid, - final String displayName, - final String icon, - final String installPath, - final String [] uninstallCommand, - final String [] modifyCommand) { - this.uid = uid; - - this.displayName = displayName; - this.icon = icon; - - this.installPath = installPath; - - this.uninstallCommand = uninstallCommand; - this.modifyCommand = modifyCommand; - - this.parameters = new HashMap(); - } - - public ApplicationDescriptor( - final String uid, - final String displayName, - final String icon, - final String installPath, - final String [] uninstallCommand, - final String [] modifyCommand, - final Map parameters) { - this(uid, - displayName, - icon, - installPath, - uninstallCommand, - modifyCommand); - - this.parameters.putAll(parameters); - } - - public String getUid() { - return uid; - } - - public String getDisplayName() { - return displayName; - } - - public String getIcon() { - return icon; - } - - public String getInstallPath() { - return installPath; - } - - public String [] getUninstallCommand() { - return uninstallCommand; - } - - public String [] getModifyCommand() { - return modifyCommand; - } - - public Map getParameters() { - return parameters; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/helper/Bundle.properties deleted file mode 100644 index 10b679f09c42..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Bundle.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -################################################################################ -# Status.java -Status.not-installed=Not installed -Status.to-be-installed=To be installed -Status.installed=Installed -Status.to-be-uninstalled=To be uninstalled - -################################################################################ -# DetailedStatus.java -DetailedStatus.install.succes=Installed Successfully -DetailedStatus.install.warning=Installed With Warnings -DetailedStatus.install.error=Failed to Install -DetailedStatus.uninstall.success=Uninstalled Successfully -DetailedStatus.uninstall.warning=Uninstalled With Warnings -DetailedStatus.uninstall.error=Failed to Uninstall diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Context.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Context.java deleted file mode 100644 index 47287a446a0b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Context.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.HashSet; -import java.util.Set; - -/** - * - * @author Kirill Sorokin - */ -public class Context { - private Set objects; - - public Context() { - objects = new HashSet(); - } - - public Context(Context context) { - this(); - - for (Object object: context.objects) { - objects.add(object); - } - } - - public synchronized void put(Object object) { - objects.add(object); - } - - public synchronized Object get(Class clazz) { - for (Object object: objects) { - if (clazz.isAssignableFrom((Class) object.getClass())) { - return object; - } - } - - return null; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Dependency.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Dependency.java deleted file mode 100644 index 64df80852644..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Dependency.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import org.netbeans.installer.product.components.Product; - -/** - * - * @author Kirill Sorokin - */ - -public abstract class Dependency { - private String uid; - private Version versionLower; - private Version versionUpper; - private Version versionResolved; - - protected Dependency( - final String uid, - final Version versionLower, - final Version versionUpper, - final Version versionResolved) { - this.uid = uid; - this.versionLower = versionLower; - this.versionUpper = versionUpper; - this.versionResolved = versionResolved; - } - - public String getUid() { - return uid; - } - - public Version getVersionLower() { - return versionLower; - } - - public Version getVersionUpper() { - return versionUpper; - } - - public Version getVersionResolved() { - return versionResolved; - } - - public void setVersionResolved(final Version version) { - this.versionResolved = version; - } - - public abstract String getName(); - - public abstract boolean satisfies(Product product); - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/DependencyType.java b/nbi/engine/src/org/netbeans/installer/utils/helper/DependencyType.java deleted file mode 100644 index aa3c38d80ee6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/DependencyType.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -@Deprecated -public enum DependencyType { - REQUIREMENT("requirement"), - CONFLICT("conflict"), - INSTALL_AFTER("install-after"); - - private String name; - - private DependencyType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public String toString() { - return name; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/DetailedStatus.java b/nbi/engine/src/org/netbeans/installer/utils/helper/DetailedStatus.java deleted file mode 100644 index 949d6a2e80fb..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/DetailedStatus.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import org.netbeans.installer.utils.ResourceUtils; - -public enum DetailedStatus { - INSTALLED_SUCCESSFULLY, - INSTALLED_WITH_WARNINGS, - FAILED_TO_INSTALL, - UNINSTALLED_SUCCESSFULLY, - UNINSTALLED_WITH_WARNINGS, - FAILED_TO_UNINSTALL; - - public String toString() { - switch (this) { - case INSTALLED_SUCCESSFULLY: - return INSTALLED_SUCCESSFULLY_STRING; - case INSTALLED_WITH_WARNINGS: - return INSTALLED_WITH_WARNINGS_STRING; - case FAILED_TO_INSTALL: - return FAILED_TO_INSTALL_STRING; - case UNINSTALLED_SUCCESSFULLY: - return UNINSTALLED_SUCCESSFULLY_STRING; - case UNINSTALLED_WITH_WARNINGS: - return UNINSTALLED_WITH_WARNINGS_STRING; - case FAILED_TO_UNINSTALL: - return FAILED_TO_UNINSTALL_STRING; - default: - return null; - } - } - private static final String INSTALLED_SUCCESSFULLY_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.install.succes");//NOI18N -private static final String INSTALLED_WITH_WARNINGS_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.install.warning");//NOI18N -private static final String FAILED_TO_INSTALL_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.install.error");//NOI18N - -private static final String UNINSTALLED_SUCCESSFULLY_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.uninstall.success");//NOI18N -private static final String UNINSTALLED_WITH_WARNINGS_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.uninstall.warning");//NOI18N -private static final String FAILED_TO_UNINSTALL_STRING = - ResourceUtils.getString(DetailedStatus.class, - "DetailedStatus.uninstall.error");//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/EngineResources.java b/nbi/engine/src/org/netbeans/installer/utils/helper/EngineResources.java deleted file mode 100644 index cdad28ecd71b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/EngineResources.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public final class EngineResources { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private EngineResources() { - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String LOCAL_ENGINE_PATH_PROPERTY = - "nbi.product.local.engine.path"; - - /*public static final String LOCAL_ENGINE_UNINSTALL_COMMAND_PROPERTY = - "nbi.product.local.engine.uninstall.command"; - - public static final String LOCAL_ENGINE_MODIFY_COMMAND_PROPERTY = - "nbi.product.local.engine.modify.command"; - */ - public static final String DATA_DIRECTORY = - "data"; - - public static final String ENGINE_CONTENTS_LIST = - DATA_DIRECTORY + "/engine.list"; - - public static final String ENGINE_PROPERTIES_BUNDLE = - DATA_DIRECTORY + ".engine"; - - @Deprecated - public static final String ENGINE_PROPERTIES = - DATA_DIRECTORY + "/engine.properties"; - - public static final String ENGINE_PROPERTIES_PATTERN = - "^" + DATA_DIRECTORY + "/engine(_[a-zA-Z]+)*.properties$";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/EnvironmentScope.java b/nbi/engine/src/org/netbeans/installer/utils/helper/EnvironmentScope.java deleted file mode 100644 index a513a470df61..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/EnvironmentScope.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -public enum EnvironmentScope { - PROCESS, - CURRENT_USER, - ALL_USERS -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ErrorLevel.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ErrorLevel.java deleted file mode 100644 index 55f292ce1f5b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ErrorLevel.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public final class ErrorLevel { - public static final int DEBUG = 4; - public static final int MESSAGE = 3; - public static final int WARNING = 2; - public static final int ERROR = 1; - public static final int CRITICAL = 0; - - private ErrorLevel() { - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionMode.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionMode.java deleted file mode 100644 index d7e4942ad3f8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionMode.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public enum ExecutionMode { - NORMAL, - CREATE_BUNDLE; - - public static final ExecutionMode DEFAULT_MODE = NORMAL; - - private static ExecutionMode currentMode = DEFAULT_MODE; - - public static ExecutionMode getCurrentExecutionMode() { - return currentMode; - } - - public static void setCurrentExecutionMode(final ExecutionMode mode) { - ExecutionMode.currentMode = mode; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionResults.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionResults.java deleted file mode 100644 index 191638fb91b9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ExecutionResults.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -public class ExecutionResults { - public static final int TIMEOUT_ERRORCODE = Integer.MAX_VALUE; - - private int errorCode = TIMEOUT_ERRORCODE; - private String stdOut = ""; - private String stdErr = ""; - public ExecutionResults() { - // do nothing - } - - public ExecutionResults(final int errorCode, final String stdOut, final String stdErr) { - this.errorCode = errorCode; - this.stdOut = stdOut; - this.stdErr = stdErr; - } - - public int getErrorCode() { - return errorCode; - } - - public String getStdOut() { - return stdOut; - } - - public String getStdErr() { - return stdErr; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ExtendedUri.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ExtendedUri.java deleted file mode 100644 index edbe0d9aae1e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ExtendedUri.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.net.URI; -import java.util.LinkedList; -import java.util.List; - -/** - * - * @author Kirill Sorokin - */ -public class ExtendedUri { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private URI remote; - private List alternates; - private URI local; - private long size; - private String md5; - - public ExtendedUri( - final URI remote, - final long size, - final String md5) { - this.remote = remote; - this.size = size; - this.md5 = md5; - - this.alternates = new LinkedList(); - } - - public ExtendedUri( - final URI remote, - final List alternates, - final long size, - final String md5) { - this(remote, size, md5); - - this.alternates.addAll(alternates); - } - - public ExtendedUri( - final URI remote, - final URI local, - final long size, - final String md5) { - this(remote, size, md5); - - this.local = local; - } - - public ExtendedUri( - final URI remote, - final List alternates, - final URI local, - final long size, - final String md5) { - this(remote, alternates, size, md5); - - this.local = local; - } - - public URI getRemote() { - return remote; - } - - public void setRemote(final URI remote) { - this.remote = remote; - } - - public List getAlternates() { - return new LinkedList(alternates); - } - - public URI getLocal() { - return local; - } - - public void setLocal(final URI local) { - this.local = local; - } - - public long getSize() { - return size; - } - - public String getMd5() { - return md5; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String RESOURCE_SCHEME = - "resource"; // NOI18N - - public static final String HTTP_SCHEME = - "http"; // NOI18N - - public static final String FILE_SCHEME = - "file"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Feature.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Feature.java deleted file mode 100644 index 00c6115b0423..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Feature.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Kirill Sorokin - */ -public class Feature { - private String id; - - private long offset; - - private ExtendedUri iconUri; - - private Map displayNames; - private Map descriptions; - - public Feature( - final String id, - final long offset, - final ExtendedUri iconUri, - final Map displayNames, - final Map descriptions) { - this.id = id; - - this.offset = offset; - - this.iconUri = iconUri; - - this.displayNames = new HashMap(); - this.displayNames.putAll(displayNames); - - this.descriptions = new HashMap(); - this.descriptions.putAll(descriptions); - } - - public String getId() { - return id; - } - - public long getOffset() { - return offset; - } - - public ExtendedUri getIconUri() { - return iconUri; - } - - public String getDisplayName() { - return getDisplayName(Locale.getDefault()); - } - - public String getDisplayName(final Locale locale) { - return StringUtils.getLocalizedString(displayNames,locale); - } - - public Map getDisplayNames() { - return displayNames; - } - - public String getDescription() { - return getDescription(Locale.getDefault()); - } - - public String getDescription(final Locale locale) { - return StringUtils.getLocalizedString(descriptions,locale); - } - - public Map getDescriptions() { - return descriptions; - } - - public boolean equals(final Feature feature) { - return feature != null ? id.equals(feature.getId()) : false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/FileEntry.java b/nbi/engine/src/org/netbeans/installer/utils/helper/FileEntry.java deleted file mode 100644 index 61b1d2fead4f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/FileEntry.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.StringUtils; - -public class FileEntry { - private File file; - private String name; - - private boolean metaDataReady; - - private boolean directory; - private boolean empty; - - private long size; - private String md5; - - private boolean jar; - private boolean packed; - private boolean signed; - - private long modified; - - private int permissions; - - // constructors ///////////////////////////////////////////////////////////////// - public FileEntry( - final File file) { - this.file = file; - this.name = file. - getAbsolutePath(). - replace(FileUtils.BACKSLASH, FileUtils.SLASH); - - this.metaDataReady = false; - } - - public FileEntry( - final File file, - final boolean empty, - final long modified, - final int permissions) { - this(file); - - this.directory = true; - this.empty = empty; - this.modified = modified; - this.permissions = permissions; - - this.metaDataReady = true; - } - - public FileEntry( - final File file, - final long size, - final String md5, - final boolean jar, - final boolean packed, - final boolean signed, - final long modified, - final int permissions) { - this(file); - - this.directory = false; - this.size = size; - this.md5 = md5; - this.jar = jar; - this.packed = packed; - this.signed = signed; - this.modified = modified; - this.permissions = permissions; - - this.metaDataReady = true; - } - - // getters/setters ////////////////////////////////////////////////////////////// - public String getName() { - return name; - } - - public File getFile() { - return file; - } - - public boolean isMetaDataReady() { - return metaDataReady; - } - - public boolean isDirectory() { - return directory; - } - - public boolean isEmpty() { - return empty; - } - - public long getSize() { - return size; - } - - public String getMd5() { - return md5; - } - - public boolean isJarFile() { - return jar; - } - - public boolean isPackedJarFile() { - return packed; - } - - public boolean isSignedJarFile() { - return signed; - } - - public long getLastModified() { - return modified; - } - - public int getPermissions() { - return permissions; - } - - // object -> string ///////////////////////////////////////////////////////////// - public String toString() { - if (directory) { - return - name + StringUtils.LF + - directory + StringUtils.LF + - empty + StringUtils.LF + - modified + StringUtils.LF + - Integer.toString(permissions, 8) + StringUtils.LF; - } else { - return - name + StringUtils.LF + - directory + StringUtils.LF + - size + StringUtils.LF + - md5 + StringUtils.LF + - jar + StringUtils.LF + - packed + StringUtils.LF + - signed + StringUtils.LF + - modified + StringUtils.LF + - Integer.toString(permissions, 8) + StringUtils.LF; - } - } - - private String escapeXmlTags(final String str) { - return (str == null) ? null : str. - replace("&", "&").//NOI18N - replace("\'","'").//NOI18N - replace("\"",""").//NOI18N - replace("<", "<").//NOI18N - replace(">", ">");//NOI18N - } - - public String toXml() { - if (directory) { - return "" + escapeXmlTags(name) + ""; - } else { - return "" + escapeXmlTags(name) + ""; - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public void calculateMetaData() throws IOException { - if (file.exists()) { - directory = file.isDirectory(); - - if (!directory) { - size = file.length(); - md5 = FileUtils.getMd5(file); - jar = FileUtils.isJarFile(file); - - if (jar) { - packed = false; // we cannot determine this - signed = FileUtils.isSigned(file); - } - } else { - empty = FileUtils.isEmpty(file); - } - - modified = file.lastModified(); - - metaDataReady = true; - } else { - throw new FileNotFoundException(file.getAbsolutePath()); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/FilesList.java b/nbi/engine/src/org/netbeans/installer/utils/helper/FilesList.java deleted file mode 100644 index ec184831605b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/FilesList.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.List; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * - * @author Kirill Sorokin - */ -public class FilesList implements Iterable { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private File listFile; - private File tempFile; - - private List entries; - - private int size; - - // constructors ///////////////////////////////////////////////////////////////// - public FilesList() { - entries = new ArrayList(CACHE_SIZE); - } - - public FilesList(final File xml) throws IOException, XMLException { - this(); - - loadXml(xml); - } - - // add/remove /////////////////////////////////////////////////////////////////// - public void add( - final File file) throws IOException { - add(new FileEntry(file)); - } - - public void add( - final FileEntry entry) throws IOException { - final String name = entry.getName(); - - int index = 0; - while (index < entries.size()) { - final String current = entries.get(index).getName(); - - if (current.length() < name.length()) { - break; - } else if (current.equals(name)) { - return; - } - - index++; - } - - entries.add(index, entry); - size++; - - if (entries.size() == CACHE_SIZE) { - save(); - } - } - - public void add( - final List list) throws IOException { - for (File file: list) { - add(file); - } - } - - public void add( - final FilesList list) throws IOException { - for (FileEntry entry: list) { - add(entry); - } - } - - public void clear() throws IOException { - if (listFile != null) { - FileUtils.deleteFiles(listFile, tempFile); - } - entries.clear(); - size = 0; - } - - // getters ////////////////////////////////////////////////////////////////////// - public int getSize() { - return size; - } - - // list <-> xml ///////////////////////////////////////////////////////////////// - public FilesList loadXml(final File xml) throws XMLException { - return loadXml(xml, null); - } - - public FilesList loadXml(final File xml, final File root) throws XMLException { - try { - InputStream in = new FileInputStream(xml); - - loadXml(in, root); - in.close(); - - return this; - } catch (IOException e) { - throw new XMLException("Cannot parse xml file", e); - } - } - - public FilesList loadXmlGz(final File xml) throws XMLException { - return loadXmlGz(xml, null); - } - - public FilesList loadXmlGz(final File xml, final File root) throws XMLException { - try { - InputStream in = new GZIPInputStream(new FileInputStream(xml)); - - loadXml(in, root); - in.close(); - - return this; - } catch (IOException e) { - throw new XMLException("Cannot parse xml file", e); - } - } - - public void saveXml(final File xml) throws XMLException { - try { - OutputStream out = new FileOutputStream(xml); - - saveXml(out); - - out.close(); - } catch (UnsupportedEncodingException e) { - throw new XMLException("Cannot save XML", e); - } catch (IOException e) { - throw new XMLException("Cannot save XML", e); - } - } - - public void saveXmlGz(final File xml) throws XMLException { - try { - OutputStream out = new GZIPOutputStream(new FileOutputStream(xml)); - - saveXml(out); - - out.close(); - } catch (UnsupportedEncodingException e) { - throw new XMLException("Cannot save XML", e); - } catch (IOException e) { - throw new XMLException("Cannot save XML", e); - } - } - - // list <-> list :) ///////////////////////////////////////////////////////////// - public List toList() { - final List files = new ArrayList(size); - - for (FileEntry entry: this) { - files.add(entry.getFile()); - } - - return files; - } - - // iterable ///////////////////////////////////////////////////////////////////// - public Iterator iterator() { - return new FilesListIterator(); - } - - // private ////////////////////////////////////////////////////////////////////// - private void save() throws IOException { - if (entries.size() > 0) { - if (listFile == null) { - listFile = FileUtils.createTempFile(); - tempFile = FileUtils.createTempFile(); - } - - final BufferedReader reader; - if (listFile.length() > 0) { - reader = - new BufferedReader( - new InputStreamReader( - new GZIPInputStream( - new FileInputStream(listFile)))); - } else { - reader = - new BufferedReader( - new FileReader(listFile)); - } - final BufferedWriter writer = - new BufferedWriter( - new OutputStreamWriter( - new GZIPOutputStream( - new FileOutputStream(tempFile)))); - - int index = 0; - FileEntry saved = readEntry(reader); - - while ((index < entries.size()) && (saved != null)) { - final String unsavedName = entries.get(index).getName(); - final String savedName = saved.getName(); - - if (savedName.equals(unsavedName)) { - if ((index < entries.size() - 1) && - entries.get(index + 1).getName().equals(unsavedName)) { - index++; - } else { - saved = readEntry(reader); - } - size--; - } else { - if (unsavedName.length() < savedName.length()) { - writeEntry(saved, writer); - saved = readEntry(reader); - } else { - writeEntry(entries.get(index), writer); - index++; - } - } - } - - while (index < entries.size()) { - writeEntry(entries.get(index), writer); - index++; - } - - while (saved != null) { - writeEntry(saved, writer); - saved = readEntry(reader); - } - - reader.close(); - - writer.flush(); - writer.close(); - - FileUtils.copyFile(tempFile, listFile); - - entries.clear(); - } - } - - private FileEntry readEntry( - final BufferedReader reader) throws IOException { - final String name = reader.readLine(); - - if (name != null) { - final File file = new File(name); - final boolean directory = Boolean.parseBoolean(reader.readLine()); - - if (directory) { - final boolean empty = Boolean.parseBoolean(reader.readLine()); - final long modified = Long.parseLong(reader.readLine()); - final int permissions = Integer.parseInt(reader.readLine(), 8); - - return new FileEntry( - file, - empty, - modified, - permissions); - } else { - final long size = Long.parseLong(reader.readLine()); - final String md5 = reader.readLine(); - final boolean jarFile = Boolean.parseBoolean(reader.readLine()); - final boolean packed = Boolean.parseBoolean(reader.readLine()); - final boolean signed = Boolean.parseBoolean(reader.readLine()); - final long modified = Long.parseLong(reader.readLine()); - final int permissions = Integer.parseInt(reader.readLine(), 8); - - return new FileEntry( - file, - size, - md5, - jarFile, - packed, - signed, - modified, - permissions); - } - } - - return null; - } - - private void writeEntry( - final FileEntry entry, - final Writer writer) throws IOException { - if (entry.getFile().exists() && !entry.isMetaDataReady()) { - entry.calculateMetaData(); - } - - writer.write(entry.toString()); - } - - private void saveXml( - final OutputStream out) throws IOException { - final PrintWriter writer = - new PrintWriter(new OutputStreamWriter(out, ENCODING)); - - writer.println(""); - writer.println(""); - - for (FileEntry entry: this) { - if (entry.getFile().exists() && !entry.isMetaDataReady()) { - entry.calculateMetaData(); - } - - writer.println(" " + entry.toXml()); - } - - writer.println(""); - - writer.flush(); - } - - private void loadXml( - final InputStream in, - final File root) throws IOException, XMLException { - final SAXParserFactory factory = SAXParserFactory.newInstance(); - final SAXParser parser; - - try { - parser = factory.newSAXParser(); - - parser.parse(new InputSource(in), new FilesListHandler(root)); - } catch (SAXException e) { - throw new XMLException("Cannot load files list from xml", e); - } catch (ParserConfigurationException e) { - throw new XMLException("Cannot load files list from xml", e); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - private class FilesListHandler extends DefaultHandler { - private boolean entryElement; - - private File root; - - private String name; - - private boolean directory; - private boolean empty; - - private long size; - private String md5; - private boolean jarFile; - private boolean packed; - private boolean signed; - private long modified; - private int permissions; - - public FilesListHandler(File root) { - this.root = root; - } - - public void startElement( - final String uri, - final String localName, - final String qName, - final Attributes attributes) throws SAXException { - if (qName.equals("entry")) { - entryElement = true; - - String type = attributes.getValue("type"); - if (type.equals("file")) { - directory = false; - - size = Long.parseLong(attributes.getValue("size")); - md5 = attributes.getValue("md5"); - jarFile = Boolean.parseBoolean(attributes.getValue("jar")); - - if (jarFile) { - packed = Boolean.parseBoolean(attributes.getValue("packed")); - signed = Boolean.parseBoolean(attributes.getValue("signed")); - } else { - packed = false; - signed = false; - } - - modified = Long.parseLong(attributes.getValue("modified")); - permissions = Integer.parseInt(attributes.getValue("permissions"), 8); - } else { - directory = true; - empty = Boolean.parseBoolean(attributes.getValue("empty")); - modified = Long.parseLong(attributes.getValue("modified")); - permissions = Integer.parseInt(attributes.getValue("permissions"), 8); - } - } else { - entryElement = false; - } - } - - public void characters( - final char[] characters, - final int start, - final int length) throws SAXException { - if (entryElement) { - final String value = new String(characters, start, length); - - if (name == null) { - name = value; - } else { - name += value; - } - } - } - - public void endElement( - final String uri, - final String localName, - final String qName) throws SAXException { - if (entryElement) { - final File file; - if (root == null) { - file = new File(name); - } else { - file = new File(root, name); - } - - name = null; - - FileEntry entry; - - if (directory) { - entry = new FileEntry( - file, - empty, - modified, - permissions); - } else { - entry = new FileEntry( - file, - size, - md5, - jarFile, - packed, - signed, - modified, - permissions); - } - - entryElement = false; - - try { - FilesList.this.add(entry); - } catch (IOException e) { - throw new SAXException("Could not add an entry", e); - } - } - } - } - - private class FilesListIterator implements Iterator { - private int sizeAtConstruction; - private boolean listInMemory; - - private int index; - private BufferedReader reader; - - private FileEntry next; - - public FilesListIterator() { - // if the list size is already bigger than can be reposited in memory - - // make sure that all entries are present in the cache file; and set the - // iteration mode (over memory or over cache file) - if (FilesList.this.listFile != null) { - try { - FilesList.this.save(); - } catch (IOException e) { - ErrorManager.notifyError("Cannot save list", e); - } - - listInMemory = false; - try { - reader = new BufferedReader( - new InputStreamReader( - new GZIPInputStream( - new FileInputStream(FilesList.this.listFile)))); - - } catch (IOException e) { - ErrorManager.notifyError("Cannot open reader to the list file", e); - } - } else { - listInMemory = true; - index = 0; - } - - sizeAtConstruction = FilesList.this.size; - } - - public boolean hasNext() { - if (sizeAtConstruction != FilesList.this.size) { - throw new ConcurrentModificationException("The list was changed, while iterating"); - } - - if (next == null) { - next = next(); - } - - return next != null; - } - - public FileEntry next() { - if (next != null) { - final FileEntry temp = next; - next = null; - - return temp; - } else { - FileEntry entry = null; - - if (listInMemory) { - if (index < FilesList.this.entries.size()) { - entry = FilesList.this.entries.get(index++); - } - } else { - try { - entry = FilesList.this.readEntry(reader); - - if (entry == null) { - reader.close(); - } - } catch (IOException e) { - ErrorManager.notifyError("Cannot read next entry", e); - } - } - - return entry; - } - } - - public void remove() { - throw new UnsupportedOperationException("Remove is not supported for files list"); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final int CACHE_SIZE = - 2500; - - public static final String ENCODING = - StringUtils.ENCODING_UTF8; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/FinishHandler.java b/nbi/engine/src/org/netbeans/installer/utils/helper/FinishHandler.java deleted file mode 100644 index 3c15e8784766..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/FinishHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public interface FinishHandler { - void cancel(); - - void finish(); - - void criticalExit(); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/JavaCompatibleProperties.java b/nbi/engine/src/org/netbeans/installer/utils/helper/JavaCompatibleProperties.java deleted file mode 100644 index 4f7b99c14daa..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/JavaCompatibleProperties.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Dmitry Lipin - */ -public class JavaCompatibleProperties { - private Version minVersion; - private Version maxVersion; - private String vendor; - private String osName; - private String osArch; - - public JavaCompatibleProperties() { - } - public JavaCompatibleProperties(Version minVersion, Version maxVersion, String vendor, String osName, String osArch) { - setMinVersion(minVersion); - setMaxVersion(maxVersion); - setVendor(vendor); - setOsName(osName); - setOsArch(osArch); - } - public JavaCompatibleProperties(String minVersion, String maxVersion, String vendor, String osName, String osArch) { - this(Version.getVersion(minVersion), Version.getVersion(maxVersion),vendor,osName,osArch); - } - public Version getMinVersion() { - return minVersion; - } - - public void setMinVersion(Version minVersion) { - this.minVersion = minVersion; - } - - public Version getMaxVersion() { - return maxVersion; - } - - public void setMaxVersion(Version maxVersion) { - this.maxVersion = maxVersion; - } - - public String getVendor() { - return vendor; - } - - public void setVendor(String vendor) { - this.vendor = vendor; - } - - public String getOsName() { - return osName; - } - public void setOsName(String osName) { - this.osName = osName; - } - - public String getOsArch() { - return osArch; - } - - public void setOsArch(String osArch) { - this.osArch = osArch; - } - public String toString() { - String all = ""; - if(minVersion!=null) { - all += " "; - } - if(maxVersion!=null) { - all += " "; - } - if(vendor!=null) { - all += " "; - } - if(osArch!=null) { - all += " "; - } - if(osName!=null) { - all += " "; - } - return all.trim(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/MutualHashMap.java b/nbi/engine/src/org/netbeans/installer/utils/helper/MutualHashMap.java deleted file mode 100644 index 6f0c12d97c1d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/MutualHashMap.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.Map; -import java.util.Set; -import java.util.Collection; -import java.util.HashMap; - -/** - * @noinspection ALL - */ -//todo: not tested yet so use arefully -public class MutualHashMap implements MutualMap { - - private Map map = new HashMap(); - private Map reversedMap = new HashMap(); - - public int size() { - return map.size(); - } - - public boolean isEmpty() { - return map.isEmpty(); - } - - public boolean containsKey(Object key) { - return map.containsKey(key); - } - - public boolean containsValue(Object value) { - return map.containsValue(value); - } - - public S get(Object key) { - return map.get(key); - } - - public F reversedGet(S object) { - return reversedMap.get(object); - } - - public S put(F key, S value) { - reversedMap.put(value, key); - return map.put(key, value); - } - - public S remove(Object key) { - final S removed = map.remove(key); - reversedMap.remove(removed); - return removed; - } - - public F reversedRemove(Object value) { - final F removed = reversedMap.remove(value); - map.remove(removed); - return removed; - } - - public void putAll(Map m) { - map.putAll(m); - for (Map.Entry entry : m.entrySet()) { - reversedMap.put(entry.getValue(), entry.getKey()); - } - } - - public void clear() { - map.clear(); - reversedMap.clear(); - } - - public Set keySet() { - return map.keySet(); - } - - public Collection values() { - return map.values(); - } - - public Set> entrySet() { - return map.entrySet(); - } - - public Set> reversedEntrySet() { - return reversedMap.entrySet(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/MutualMap.java b/nbi/engine/src/org/netbeans/installer/utils/helper/MutualMap.java deleted file mode 100644 index 4465db704113..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/MutualMap.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.Map; -import java.util.Set; - -public interface MutualMap extends Map { - - F reversedGet(S object); - - F reversedRemove(Object value); - - Set> reversedEntrySet(); - - //todo: not all reversed method added! -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiClassLoader.java b/nbi/engine/src/org/netbeans/installer/utils/helper/NbiClassLoader.java deleted file mode 100644 index 77d97487d97c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiClassLoader.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.security.CodeSource; -import java.security.PermissionCollection; -import java.util.List; - -public class NbiClassLoader extends URLClassLoader { - public NbiClassLoader(final List uris) throws MalformedURLException { - super(new URL[]{}, NbiClassLoader.class.getClassLoader()); - - for(ExtendedUri uri : uris) { - addURL(uri.getLocal().toURL()); - } - } - - protected PermissionCollection getPermissions(final CodeSource source) { - return getClass().getProtectionDomain().getPermissions(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiProperties.java b/nbi/engine/src/org/netbeans/installer/utils/helper/NbiProperties.java deleted file mode 100644 index dae11f230f1a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiProperties.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.Locale; -import java.util.Properties; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author ks152834 - */ -public class NbiProperties extends Properties { - public NbiProperties( - ) { - super(); - } - - public NbiProperties( - final Properties properties) { - super(); - - putAll(properties); - } - - @Override - public String getProperty( - final String name) { - return getProperty( - name, - SystemUtils.getCurrentPlatform(), - Locale.getDefault()); - } - - public String getProperty( - final String name, - final Platform platform, - final Locale locale) { - final String[] platformParts = getPlatformParts(platform); - final String[] localeParts = getLocaleParts(locale); - - for (int i = platformParts.length; i >= 0; i--) { - for (int j = localeParts.length; j >= 0; j--) { - final String platformString = - StringUtils.asString(platformParts, 0, i, "-"); - final String localeString = - StringUtils.asString(localeParts, 0, j, "_"); - - final String candidateName = - name + - (platformString.equals("") ? "" : "." + platformString) + - (localeString.equals("") ? "" : "." + localeString); - - final String value = super.getProperty(candidateName); - if (value != null) { - return value; - } - } - } - - return null; - } - - @Override - public Object setProperty( - final String name, - final String value) { - return setProperty( - name, - value, - SystemUtils.getCurrentPlatform(), - Locale.getDefault()); - } - - public Object setProperty( - final String name, - final String value, - final Platform platform, - final Locale locale) { - final String[] platformParts = getPlatformParts(platform); - final String[] localeParts = getLocaleParts(locale); - - for (int i = platformParts.length; i >= 0; i--) { - for (int j = localeParts.length; j >= 0; j--) { - final String platformString = - StringUtils.asString(platformParts, 0, i, "-"); - final String localeString = - StringUtils.asString(localeParts, 0, j, "_"); - - final String candidateName = - name + - (platformString.equals("") ? "" : "." + platformString) + - (localeString.equals("") ? "" : "." + localeString); - - if (super.getProperty(candidateName) != null) { - return super.setProperty(candidateName, value); - } - } - } - return super.setProperty(name, value); - } - - // private ////////////////////////////////////////////////////////////////////// - private String[] getPlatformParts( - final Platform platform) { - if (platform == null) { - return new String[0]; - } - - if (platform.getOsFamily() != null) { - if (platform.getHardwareArch() != null) { - if (platform.getOsVersion() != null) { - if (platform.getOsFlavor() != null) { - return new String[] { - platform.getOsFamily(), - platform.getHardwareArch(), - platform.getOsVersion(), - platform.getOsFlavor() - }; - } - - return new String[] { - platform.getOsFamily(), - platform.getHardwareArch(), - platform.getOsVersion() - }; - } - - return new String[] { - platform.getOsFamily(), - platform.getHardwareArch() - }; - } - - return new String[] { - platform.getOsFamily() - }; - } - - return new String[0]; - } - - private String[] getLocaleParts( - final Locale locale) { - if (locale == null) { - return new String[0]; - } - - if (!locale.getLanguage().equals("")) { - if (!locale.getCountry().equals("")) { - if (!locale.getVariant().equals("")) { - return new String[] { - locale.getLanguage(), - locale.getCountry(), - locale.getVariant() - }; - } - - return new String[] { - locale.getLanguage(), - locale.getCountry() - }; - } - - return new String[] { - locale.getLanguage() - }; - } - - return new String[0]; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiThread.java b/nbi/engine/src/org/netbeans/installer/utils/helper/NbiThread.java deleted file mode 100644 index 8d787acd9f46..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/NbiThread.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import org.netbeans.installer.utils.ErrorManager; - -/** - * - * @author Kirill Sorokin - */ -public class NbiThread extends Thread { - public NbiThread() { - super(); - - setUncaughtExceptionHandler(ErrorManager.getExceptionHandler()); - } - - public NbiThread(Runnable runnable) { - super(runnable); - - setUncaughtExceptionHandler(ErrorManager.getExceptionHandler()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Pair.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Pair.java deleted file mode 100644 index 41c990acdd7c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Pair.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Danila_Dugurov - */ -public class Pair { - - private F first; - private S second; - - public Pair(F first, S second) { - this.first = first; - this.second = second; - } - - public static Pair create (F first, S second) { - return new Pair(first, second); - } - - public F getFirst() { - return first; - } - - public S getSecond() { - return second; - } - - public String toString() { - return "(" + first + "," + second + ")"; - } - - public boolean equals(Object other) { - if (other == this) return true; - if (other == null) return false; - if (other instanceof Pair) { - Pair pair = (Pair) other; - if (first != null ? first.equals(pair.first): pair.first == null) - return second != null ? second.equals(pair.second): pair.second == null; - } - return false; - } - - public int hashCode() { - int result; - result = (first != null ? first.hashCode() : 0); - result = 29 * result + (second != null ? second.hashCode() : 0); - return result; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Platform.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Platform.java deleted file mode 100644 index 1307a51aff58..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Platform.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.List; -import static org.netbeans.installer.utils.helper.PlatformConstants.*; - -public enum Platform { - ///////////////////////////////////////////////////////////////////////////////// - // Values - GENERIC(null, null, null, null, "Generic"), - UNIX(OS_FAMILY_UNIX, null, null, null, "Unix"), - - WINDOWS(OS_FAMILY_WINDOWS, null, null, null, "Windows"), - WINDOWS_X86(OS_FAMILY_WINDOWS, HARDWARE_X86, null, null, "Windows X86"), - WINDOWS_X64(OS_FAMILY_WINDOWS, HARDWARE_X64, null, null, "Windows X64"), - WINDOWS_IA64(OS_FAMILY_WINDOWS, HARDWARE_IA64, null, null, "Windows Itanium"), - - LINUX(OS_FAMILY_LINUX, null, null, null, "Linux"), - LINUX_X86(OS_FAMILY_LINUX, HARDWARE_X86, null, null, "Linux X86"), - LINUX_X64(OS_FAMILY_LINUX, HARDWARE_X64, null, null, "Linux X64"), - LINUX_PPC(OS_FAMILY_LINUX, HARDWARE_PPC, null, null, "Linux PowerPC"), - LINUX_PPC64(OS_FAMILY_LINUX, HARDWARE_PPC64, null, null, "Linux PowerPC X64"), - LINUX_SPARC(OS_FAMILY_LINUX, HARDWARE_SPARC, null, null, "Linux SPARC"), - LINUX_IA64(OS_FAMILY_LINUX, HARDWARE_IA64, null, null, "Linux Itanium"), - - SOLARIS(OS_FAMILY_SOLARIS, null, null, null, "Solaris"), - SOLARIS_X86(OS_FAMILY_SOLARIS, HARDWARE_X86, null, null, "Solaris X86"), - SOLARIS_SPARC(OS_FAMILY_SOLARIS, HARDWARE_SPARC, null, null, "Solaris SPARC"), - - MACOSX(OS_FAMILY_MACOSX, null, null, null, "MacOS X"), - MACOSX_X86(OS_FAMILY_MACOSX, HARDWARE_X86, null, null, "Mac OS X Intel"), - MACOSX_X64(OS_FAMILY_MACOSX, HARDWARE_X64, null, null, "Mac OS X Intel X64"), - MACOSX_PPC(OS_FAMILY_MACOSX, HARDWARE_PPC, null, null, "Mac OS X PowerPC"), - MACOSX_PPC64(OS_FAMILY_MACOSX, HARDWARE_PPC64, null, null, "Mac OS X PowerPC X64"), - - BSD(OS_FAMILY_BSD, null, null, null, "BSD"), - BSD_X86(OS_FAMILY_BSD, HARDWARE_X86, null, null, "BSD X86"), - BSD_X64(OS_FAMILY_BSD, HARDWARE_X64, null, null, "BSD X64"), - BSD_PPC(OS_FAMILY_BSD, HARDWARE_PPC, null, null, "BSD PowerPC"), - BSD_PPC64(OS_FAMILY_BSD, HARDWARE_PPC64, null, null, "BSD PowerPC X64"), - BSD_SPARC(OS_FAMILY_BSD, HARDWARE_SPARC, null, null, "BSD SPARC"), - - FREEBSD(OS_FAMILY_FREEBSD, null, null, null, "FreeBSD"), - FREEBSD_X86(OS_FAMILY_FREEBSD, HARDWARE_X86, null, null, "FreeBSD X86"), - FREEBSD_X64(OS_FAMILY_FREEBSD, HARDWARE_X64, null, null, "FreeBSD X64"), - FREEBSD_PPC(OS_FAMILY_FREEBSD, HARDWARE_PPC, null, null, "FreeBSD PowerPC"), - FREEBSD_PPC64(OS_FAMILY_FREEBSD, HARDWARE_PPC64, null, null, "FreeBSD PowerPC X64"), - FREEBSD_SPARC(OS_FAMILY_FREEBSD, HARDWARE_SPARC, null, null, "FreeBSD SPARC"), - - OPENBSD(OS_FAMILY_OPENBSD, null, null, null, "OpenBSD"), - OPENBSD_X86(OS_FAMILY_OPENBSD, HARDWARE_X86, null, null, "OpenBSD X86"), - OPENBSD_X64(OS_FAMILY_OPENBSD, HARDWARE_X64, null, null, "OpenBSD X64"), - OPENBSD_PPC(OS_FAMILY_OPENBSD, HARDWARE_PPC, null, null, "OpenBSD PowerPC"), - OPENBSD_PPC64(OS_FAMILY_OPENBSD, HARDWARE_PPC64, null, null, "OpenBSD PowerPC X64"), - OPENBSD_SPARC(OS_FAMILY_OPENBSD, HARDWARE_SPARC, null, null, "OpenBSD SPARC"), - - AIX(OS_FAMILY_AIX, null, null, null, "AIX"), - AIX_PPC(OS_FAMILY_AIX, HARDWARE_PPC, null, null, "AIX PowerPC"), - AIX_PPC64(OS_FAMILY_AIX, HARDWARE_PPC64, null, null, "AIX PowerPC X64"), - - HPUX(OS_FAMILY_HPUX, null, null, null, "HP-UX"), - HPUX_IA64(OS_FAMILY_HPUX, HARDWARE_IA64, null, null, "HP-UX Itanium"), - HPUX_PA_RISC(OS_FAMILY_HPUX, HARDWARE_PA_RISC, null, null, "HP-UX PA-RISC"), - HPUX_PA_RISC20(OS_FAMILY_HPUX, HARDWARE_PA_RISC20, null, null, "HP-UX PA-RISC2.0"), - ; - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private String osFamily; - private String hardwareArch; - private String osVersion; - private String osFlavor; - - private String codeName; - private String displayName; - - private Platform( - final String osFamily, - final String hardwareArch, - final String osVersion, - final String osFlavor, - final String displayName) { - this.osFamily = osFamily; - this.hardwareArch = hardwareArch; - this.osVersion = osVersion; - this.osFlavor = osFlavor; - - if (osFamily != null) { - this.codeName = osFamily; - - if (hardwareArch != null) { - this.codeName += SEPARATOR + hardwareArch; - - if (osVersion != null) { - this.codeName += SEPARATOR + osVersion; - - if (osFlavor != null) { - this.codeName += SEPARATOR + osFlavor; - } - } - } - } else { - this.codeName = "generic"; - } - - this.displayName = displayName; - } - - public String getOsFamily() { - return osFamily; - } - - public String getHardwareArch() { - return hardwareArch; - } - - public String getOsVersion() { - return osVersion; - } - - public String getOsFlavor() { - return osFlavor; - } - - public String getCodeName() { - return codeName; - } - - public String getDisplayName() { - return displayName; - } - - public boolean isCompatibleWith(final Platform platform) { - if (platform.osFamily!=null && - !platform.osFamily.equals(osFamily)) { - if(platform.osFamily.equals(OS_FAMILY_UNIX) && - !OS_FAMILY_WINDOWS.equals(osFamily)) { - return true; - } - if(platform.osFamily.equals(OS_FAMILY_BSD)) { - boolean osFamilyMatches = OS_FAMILY_FREEBSD.equals(osFamily) || - OS_FAMILY_OPENBSD.equals(osFamily) || - OS_FAMILY_MACOSX.equals(osFamily); - return osFamilyMatches && - (platform.hardwareArch==null || platform.hardwareArch.equals(hardwareArch)); - } - return false; - } - - if ((platform.hardwareArch != null) && - !platform.hardwareArch.equals(hardwareArch)) { - return false; - } - - if ((platform.osVersion != null) && - !platform.osVersion.equals(osVersion)) { - return false; - } - - if ((platform.osFlavor != null) && - !platform.osFlavor.equals(osFlavor)) { - return false; - } - - return true; - } - - public boolean isCompatibleWith(final List platforms) { - for (Platform candidate: platforms) { - if (isCompatibleWith(candidate)) { - return true; - } - } - - return false; - } - - - @Override - public String toString() { - return codeName; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String SEPARATOR = - "-"; -} - diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/PlatformConstants.java b/nbi/engine/src/org/netbeans/installer/utils/helper/PlatformConstants.java deleted file mode 100644 index 4ad98e27ee84..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/PlatformConstants.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -public final class PlatformConstants { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private PlatformConstants() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String OS_FAMILY_WINDOWS = - "windows"; - - public static final String OS_FAMILY_LINUX = - "linux"; - - public static final String OS_FAMILY_SOLARIS = - "solaris"; - - public static final String OS_FAMILY_MACOSX = - "macosx"; - - public static final String OS_FAMILY_UNIX = - "unix"; - - public static final String OS_FAMILY_FREEBSD = - "freebsd"; - - public static final String OS_FAMILY_OPENBSD = - "openbsd"; - - public static final String OS_FAMILY_BSD = - "bsd"; - - public static final String OS_FAMILY_AIX = - "aix"; - - public static final String OS_FAMILY_HPUX = - "hpux"; - - public static final String HARDWARE_X86 = - "x86"; - - public static final String HARDWARE_X64 = - "x64"; - - public static final String HARDWARE_IA64 = - "ia64"; - - //this includes PA_RISC 1.0 and 1.1 - public static final String HARDWARE_PA_RISC = - "pa_risc"; - - public static final String HARDWARE_PA_RISC20 = - "pa_risc2.0"; - - public static final String HARDWARE_SPARC = - "sparc"; - - public static final String HARDWARE_PPC = - "ppc"; - - public static final String HARDWARE_PPC64 = - "ppc64"; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/PropertyContainer.java b/nbi/engine/src/org/netbeans/installer/utils/helper/PropertyContainer.java deleted file mode 100644 index f105e23bca17..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/PropertyContainer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.util.Properties; - -/** - * - * @author Kirill Sorokin - */ -public interface PropertyContainer { - Properties getProperties(); - - String getProperty(final String name); - - void setProperty(final String name, final String value); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/RemovalMode.java b/nbi/engine/src/org/netbeans/installer/utils/helper/RemovalMode.java deleted file mode 100644 index 8ca644356f1c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/RemovalMode.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public enum RemovalMode { - ALL, - LIST; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Shortcut.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Shortcut.java deleted file mode 100644 index bf34bba3febe..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Shortcut.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import java.io.File; -import org.netbeans.installer.utils.system.shortcut.FileShortcut; - -/** - * Class is depricated since NetBeans M9.
- * The new style is to use shortcut implementations in shortcut package : - *
    - *
  • FileShortcut
  • - *
  • InternetShortcut
  • - *
- */ -@Deprecated -public class Shortcut extends FileShortcut { - public Shortcut(String name, File file) { - super(name, file); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/ShortcutLocationType.java b/nbi/engine/src/org/netbeans/installer/utils/helper/ShortcutLocationType.java deleted file mode 100644 index 458b7715b444..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/ShortcutLocationType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * Class is depricated since NetBeans M9.
- * Use org.netbeans.installer.utils.system.shortcut.LocationType instead - */ - -@Deprecated -public enum ShortcutLocationType { - CURRENT_USER_DESKTOP, - ALL_USERS_DESKTOP, - CURRENT_USER_START_MENU, - ALL_USERS_START_MENU -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Status.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Status.java deleted file mode 100644 index 3bde2258330a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Status.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import org.netbeans.installer.utils.ResourceUtils; - -public enum Status { - NOT_INSTALLED("not-installed"), - TO_BE_INSTALLED("to-be-installed"), - INSTALLED("installed"), - INSTALLED_DIFFERENT_BUILD("installed-different-build"), - TO_BE_UNINSTALLED("to-be-uninstalled"); - - private String name; - - private Status(final String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public String getDisplayName() { - switch (this) { - case NOT_INSTALLED: - return NOT_INSTALLED_STRING; - case TO_BE_INSTALLED: - return TO_BE_INSTALLED_STRING; - case INSTALLED: - return INSTALLED_STRING; - case TO_BE_UNINSTALLED: - return TO_BE_UNINSTALLED_STRING; - } - - return null; - } - - @Override - public String toString() { - return name; - } - private static final String NOT_INSTALLED_STRING = - ResourceUtils.getString(Status.class, - "Status.not-installed"); - private static final String TO_BE_INSTALLED_STRING = - ResourceUtils.getString(Status.class, - "Status.to-be-installed"); - private static final String INSTALLED_STRING = - ResourceUtils.getString(Status.class, - "Status.installed"); - private static final String TO_BE_UNINSTALLED_STRING = - ResourceUtils.getString(Status.class, - "Status.to-be-uninstalled"); -} - diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Text.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Text.java deleted file mode 100644 index 106e0d9ad324..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Text.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -import org.netbeans.installer.utils.exceptions.UnrecognizedObjectException; - -/** - * - * @author Kirill Sorokin - */ -public class Text { - private String text = ""; - private ContentType contentType = ContentType.PLAIN_TEXT; - - public Text() { - // does nothing - } - - public Text(final String text, final ContentType contentType) { - this.text = text; - this.contentType = contentType; - } - - public String getText() { - return text; - } - - public ContentType getContentType() { - return contentType; - } - - public static enum ContentType { - PLAIN_TEXT, - HTML; - - public static ContentType parseContentType(final String string) throws UnrecognizedObjectException { - if (string.equals("text/plain")) { - return PLAIN_TEXT; - } - - if (string.equals("text/html")) { - return HTML; - } - - throw new UnrecognizedObjectException("Cannot recognize content type"); - } - - public String getExtension() { - switch (this) { - case PLAIN_TEXT: - return ".txt"; - case HTML: - return ".html"; - default: - return ""; - } - } - - public String toString() { - switch (this) { - case PLAIN_TEXT: - return "text/plain"; - case HTML: - return "text/html"; - default: - return ""; - } - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/UiMode.java b/nbi/engine/src/org/netbeans/installer/utils/helper/UiMode.java deleted file mode 100644 index 2d17d8946b9c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/UiMode.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -public enum UiMode { - SWING, - SILENT; - - public static final UiMode DEFAULT_MODE = SWING; - - private static UiMode currentMode = DEFAULT_MODE; - - public static UiMode getCurrentUiMode() { - return currentMode; - } - - public static void setCurrentUiMode(final UiMode mode) { - UiMode.currentMode = mode; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/Version.java b/nbi/engine/src/org/netbeans/installer/utils/helper/Version.java deleted file mode 100644 index 3bc61277a9bc..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/Version.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper; - -/** - * - * @author Kirill Sorokin - */ -public class Version { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static Version getVersion( - final String string) { - if (string!=null && string.matches("([0-9]+[\\._\\-]+)*[0-9]+")) { - return new Version(string); - } else { - return null; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private long major; - private long minor; - private long micro; - private long update; - private long build; - - private Version(final String string) { - String[] split = string.split("[\\._\\-]+"); //NOI18N - - if (split.length > 0) { - major = Long.parseLong(split[0]); - } - if (split.length > 1) { - minor = Long.parseLong(split[1]); - } - if (split.length > 2) { - micro = Long.parseLong(split[2]); - } - if (split.length > 3) { - update = Long.parseLong(split[3]); - } - if (split.length > 4) { - build = Long.parseLong(split[4]); - } - } - - public boolean equals( - final Version version) { - return ((major == version.major) && - (minor == version.minor) && - (micro == version.micro) && - (update == version.update) && - (build == version.build)); - } - - public boolean newerThan( - final Version version) { - if (major > version.major) { - return true; - } else if (major == version.major) { - if (minor > version.minor) { - return true; - } else if (minor == version.minor) { - if (micro > version.micro) { - return true; - } else if (micro == version.micro) { - if (update > version.update) { - return true; - } else if (update == version.update) { - if (build > version.build) { - return true; - } - } - } - } - } - - return false; - } - - public boolean newerOrEquals( - final Version version) { - return newerThan(version) || equals(version); - } - - public boolean olderThan( - final Version version) { - return !newerOrEquals(version); - } - - public boolean olderOrEquals( - final Version version) { - return !newerThan(version); - } - - public VersionDistance getDistance( - final Version version) { - return new VersionDistance(this, version); - } - - public long getMajor() { - return major; - } - - public long getMinor() { - return minor; - } - - public long getMicro() { - return micro; - } - - public long getUpdate() { - return update; - } - - public long getBuild() { - return build; - } - - @Override - public String toString() { - return "" + major + "." + minor + "." + micro + "." + update + "." + build; - } - - public String toMajor() { - return "" + major; - } - - public String toMinor() { - return "" + major + "." + minor; - } - - public String toMicro() { - return "" + major + "." + minor + "." + micro; - } - - public String toJdkStyle() { - return "" + major + - "." + minor + - "." + micro + - (update != 0 ? "_" + (update < 10 ? "0" + update : update) : ""); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class VersionDistance { - private final long majorDistance; - private final long minorDistance; - private final long microDistance; - private final long updateDistance; - private final long buildDistance; - - private VersionDistance( - final Version version1, - final Version version2) { - majorDistance = Math.abs(version1.getMajor() - version2.getMajor()); - minorDistance = Math.abs(version1.getMinor() - version2.getMinor()); - microDistance = Math.abs(version1.getMicro() - version2.getMicro()); - updateDistance = Math.abs(version1.getUpdate() - version2.getUpdate()); - buildDistance = Math.abs(version1.getBuild() - version2.getBuild()); - } - - public boolean equals( - final VersionDistance distance) { - return ((majorDistance == distance.majorDistance) && - (minorDistance == distance.minorDistance) && - (microDistance == distance.microDistance) && - (updateDistance == distance.updateDistance) && - (buildDistance == distance.buildDistance)); - } - - public boolean greaterThan( - final VersionDistance distance) { - if (majorDistance > distance.majorDistance) { - return true; - } else if (majorDistance == distance.majorDistance) { - if (minorDistance > distance.minorDistance) { - return true; - } else if (minorDistance == distance.minorDistance) { - if (microDistance > distance.microDistance) { - return true; - } else if (microDistance == distance.microDistance) { - if (updateDistance > distance.updateDistance) { - return true; - } else if (updateDistance == distance.updateDistance) { - if (buildDistance > distance.buildDistance) { - return true; - } - } - } - } - } - - return false; - } - - public boolean greaterOrEquals( - final VersionDistance version) { - return greaterThan(version) || equals(version); - } - - public boolean lessThan( - final VersionDistance version) { - return !greaterOrEquals(version); - } - - public boolean lessOrEquals( - final VersionDistance distance) { - return !greaterThan(distance); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/Bundle.properties deleted file mode 100644 index 70fb03fff86a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/Bundle.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# NbiFrame.java -NF.error.failed.to.download.icon=Failed to download frame icon from URI - {0}. -NF.error.failed.to.set.frame.icon=Failed to set the frame icon. - -##################################################################################### -# NbiFileChooser.java -NFC.filechooser.title=Browse -NFC.filechooser.approve.button.text=&OK diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiButton.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiButton.java deleted file mode 100644 index bef11f08356f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiButton.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Toolkit; -import javax.swing.JButton; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiButton extends JButton { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public NbiButton() { - super(); - - if (SystemUtils.isWindows()) { - final Object object = Toolkit. - getDefaultToolkit(). - getDesktopProperty(WINDOWS_XP_THEME_MARKER_PROPERTY); - - if (object != null) { - boolean xpThemeActive = (Boolean) object; - if (xpThemeActive) { - setOpaque(false); - } - } - } - - setText(DEFAULT_TEXT); - setMnemonic(DEFAULT_MNEMONIC); - } - - public void setText(String text) { - super.setText(StringUtils.stripMnemonic(text)); - - if (!SystemUtils.isMacOS()) { - super.setMnemonic(StringUtils.fetchMnemonic(text)); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TEXT = - " "; // NOI18N - - public static final char DEFAULT_MNEMONIC = - '\u0000'; - - private static final String WINDOWS_XP_THEME_MARKER_PROPERTY = - "win.xpstyle.themeActive"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiCheckBox.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiCheckBox.java deleted file mode 100644 index cda3c71cc3ec..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiCheckBox.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JCheckBox; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiCheckBox extends JCheckBox { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public NbiCheckBox() { - super(); - - setText(DEFAULT_TEXT); - setMnemonic(DEFAULT_MNEMONIC); - } - - public void setText(String text) { - super.setText(StringUtils.stripMnemonic(text)); - - if (!SystemUtils.isMacOS()) { - super.setMnemonic(StringUtils.fetchMnemonic(text)); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TEXT = - ""; // NOI18N - - public static final char DEFAULT_MNEMONIC = - '\u0000'; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiComboBox.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiComboBox.java deleted file mode 100644 index 6c894e35b19f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiComboBox.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JComboBox; - -/** - * - * @author Kirill Sorokin - */ -public class NbiComboBox extends JComboBox { - public NbiComboBox() { - super(); - - setPreferredSize(new NbiTextField().getPreferredSize()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDialog.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDialog.java deleted file mode 100644 index 424438b63f1c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDialog.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Composite; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Image; -import java.net.URL; -import javax.swing.JDialog; - -/** - * - * @author Kirill Sorokin - */ -public class NbiDialog extends JDialog { - protected NbiFrame owner; - - protected int dialogWidth; - protected int dialogHeight; - protected URL dialogIcon; - - protected NbiDialogContentPane contentPane; - - public NbiDialog() { - super(); - - initComponents(); - } - - public NbiDialog(NbiFrame owner) { - super(owner); - - this.owner = owner; - - initComponents(); - } - - private void initComponents() { - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - - contentPane = new NbiDialogContentPane(); - setContentPane(contentPane); - - setSize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_HEIGHT); - } - - public void setVisible(boolean visible) { - if (owner == null) { - final GraphicsDevice screen = GraphicsEnvironment. - getLocalGraphicsEnvironment(). - getScreenDevices()[0]; - final GraphicsConfiguration config = screen.getDefaultConfiguration(); - - final int screenWidth = config.getBounds().width; - final int screenHeight = config.getBounds().height; - - setLocation( - (screenWidth - getSize().width) / 2, - (screenHeight - getSize().height) / 2); - } else { - setLocation( - owner.getLocation().x + DIALOG_FRAME_WIDTH_DELTA, - owner.getLocation().y + DIALOG_FRAME_WIDTH_DELTA); - } - - super.setVisible(visible); - } - - public class NbiDialogContentPane extends NbiPanel { - private Image backgroundImage; - - public NbiDialogContentPane() { - super(); - - if (NbiDialog.this.owner != null) { - backgroundImage = NbiDialog.this.owner.getBackgroundImage(); - } - } - - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); - - Graphics2D graphics2d = (Graphics2D) graphics; - - if (backgroundImage != null) { - graphics2d.drawImage(backgroundImage, 0, 0, this); - - Composite oldComposite = graphics2d.getComposite(); - - graphics2d.setComposite( - AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.85f)); - graphics2d.setColor(Color.WHITE); - graphics2d.fillRect(0, 0, this.getWidth(), this.getHeight()); - - graphics2d.setComposite(oldComposite); - } - } - } - - public static final int DIALOG_FRAME_WIDTH_DELTA = 100; - - public static final int DIALOG_FRAME_HEIGHT_DELTA = 100; - - public static final int DEFAULT_DIALOG_WIDTH = - NbiFrame.DEFAULT_FRAME_WIDTH - DIALOG_FRAME_WIDTH_DELTA; - - public static final int DEFAULT_DIALOG_HEIGHT = - NbiFrame.DEFAULT_FRAME_HEIGHT - DIALOG_FRAME_HEIGHT_DELTA; - - public static final URL DEFAULT_DIALOG_ICON = NbiDialog.class. - getClassLoader(). - getResource("org/netbeans/installer/wizard/wizard-icon.png"); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDirectoryChooser.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDirectoryChooser.java deleted file mode 100644 index e1ee4488d51d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiDirectoryChooser.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JFileChooser; - -/** - * - * @author Dmitry Lipin - */ -public class NbiDirectoryChooser extends NbiFileChooser { - - public NbiDirectoryChooser() { - super(); - setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - setMultiSelectionEnabled(false); - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFileChooser.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFileChooser.java deleted file mode 100644 index 41b41090262d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFileChooser.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JFileChooser; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Dmitry Lipin - */ -public class NbiFileChooser extends JFileChooser { - - public NbiFileChooser() { - super(); - String titleProp = System.getProperty(FILECHOOSER_TITLE_PROPERTY); - setDialogTitle((titleProp==null) ? DEFAULT_FILECHOOSER_TITLE : titleProp); - - String approveButtonProp = System.getProperty(FILECHOOSER_APPROVE_BUTTON_TEXT_PROPERTY); - String approveButtonText = (approveButtonProp==null) ? - DEFAULT_FILECHOOSER_APPROVE_BUTTON_TEXT : - approveButtonProp; - - if ((approveButtonText != null) && !approveButtonText.equals("")) { - setApproveButtonText(StringUtils.stripMnemonic(approveButtonText)); - setApproveButtonToolTipText(StringUtils.stripMnemonic(approveButtonText)); - if (!SystemUtils.isMacOS()) { - setApproveButtonMnemonic(StringUtils.fetchMnemonic(approveButtonText)); - } - } - } - public static final String DEFAULT_FILECHOOSER_TITLE = - ResourceUtils.getString(NbiFileChooser.class, - "NFC.filechooser.title"); // NOI18N - public static final String DEFAULT_FILECHOOSER_APPROVE_BUTTON_TEXT = - ResourceUtils.getString(NbiFileChooser.class, - "NFC.filechooser.approve.button.text"); // NOI18N - - public static final String FILECHOOSER_TITLE_PROPERTY = - "filechooser.title"; - public static final String FILECHOOSER_APPROVE_BUTTON_TEXT_PROPERTY = - "filechooser.approve.button"; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFrame.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFrame.java deleted file mode 100644 index c27775104ad7..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiFrame.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Graphics; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Image; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.helper.ExtendedUri; - -/** - * - * @author Kirill Sorokin - */ -public class NbiFrame extends JFrame { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Initial width of the frame. - */ - protected int frameWidth; - - /** - * Minimum width of the frame. - */ - protected int frameMinimumWidth; - - /** - * Maximum width of the frame. - */ - protected int frameMaximumWidth; - - /** - * Initial height of the frame. - */ - protected int frameHeight; - - /** - * Minimum height of the frame. - */ - protected int frameMinimumHeight; - - /** - * Maximum height of the frame. - */ - protected int frameMaximumHeight; - - /** - * Frame's icon. - */ - protected File frameIcon; - - private NbiFrameContentPane contentPane; - - public NbiFrame() { - super(); - - frameWidth = UiUtils.getDimension(System.getProperties(), - FRAME_WIDTH_PROPERTY, - DEFAULT_FRAME_WIDTH); - frameHeight = UiUtils.getDimension(System.getProperties(), - FRAME_HEIGHT_PROPERTY, - DEFAULT_FRAME_HEIGHT); - - frameMinimumWidth = UiUtils.getDimension(System.getProperties(), - FRAME_MINIMUM_WIDTH_PROPERTY, - DEFAULT_FRAME_MINIMUM_WIDTH); - frameMinimumHeight = UiUtils.getDimension(System.getProperties(), - FRAME_MINIMUM_HEIGHT_PROPERTY, - DEFAULT_FRAME_MINIMUM_HEIGHT); - - frameMaximumWidth = UiUtils.getDimension(System.getProperties(), - FRAME_MAXIMUM_WIDTH_PROPERTY, - DEFAULT_FRAME_MAXIMUM_WIDTH); - frameMaximumHeight = UiUtils.getDimension(System.getProperties(), - FRAME_MAXIMUM_HEIGHT_PROPERTY, - DEFAULT_FRAME_MAXIMUM_HEIGHT); - - boolean customIconLoaded = false; - if (System.getProperty(FRAME_ICON_URI_PROPERTY) != null) { - final String frameIconUri = - System.getProperty(FRAME_ICON_URI_PROPERTY); - - try { - frameIcon = FileProxy.getInstance().getFile(frameIconUri,true); - customIconLoaded = true; - } catch (DownloadException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - NbiFrame.class, - RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON, - frameIconUri), e); - } - } - - if (!customIconLoaded) { - final String frameIconUri = DEFAULT_FRAME_ICON_URI; - - try { - frameIcon = FileProxy.getInstance().getFile(frameIconUri,true); - customIconLoaded = true; - } catch (DownloadException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - NbiFrame.class, - RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON, - frameIconUri), e); - } - } - - initComponents(); - } - - - - public void setVisible(boolean visible) { - final GraphicsDevice screen = GraphicsEnvironment. - getLocalGraphicsEnvironment(). - getScreenDevices()[0]; - final GraphicsConfiguration config = screen.getDefaultConfiguration(); - - final int screenWidth = config.getBounds().width; - final int screenHeight = config.getBounds().height; - - setLocation( - (screenWidth - getSize().width) / 2, - (screenHeight - getSize().height) / 2); - - super.setVisible(visible); - } - - public Image getBackgroundImage() { - return contentPane.getBackgroundImage(); - } - - public void setBackgroundImage(URL url) { - contentPane.setBackgroundImage(url); - } - - // protected //////////////////////////////////////////////////////////////////// - private void initComponents() { - // the frame itself - try { - setDefaultCloseOperation(EXIT_ON_CLOSE); - } catch (SecurityException e) { - // we might fail here with a custom security manager (e.g. the netbeans - // one); in this case just log the exception and "let it be" (c) - ErrorManager.notifyDebug( - "Cannot set the default close operation", - e); - } - - setSize(frameWidth, frameHeight); - - try { - setIconImage(new ImageIcon(frameIcon.toURI().toURL()).getImage()); - } catch (MalformedURLException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - NbiFrame.class, - RESOURCE_FAILED_TO_SET_FRAME_ICON), e); - } - - addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent event) { - if ((frameMinimumWidth != -1) && - (getSize().width < frameMinimumWidth)) { - setSize(frameMinimumWidth, getSize().height); - } - if ((frameMinimumHeight != -1) && - (getSize().height < frameMinimumHeight)) { - setSize(getSize().width, frameMinimumHeight); - } - - if ((frameMaximumWidth != -1) && - (getSize().width > frameMaximumWidth)) { - setSize(frameMaximumWidth, getSize().height); - } - if ((frameMaximumHeight != -1) && - (getSize().height > frameMaximumHeight)) { - setSize(getSize().width, frameMaximumHeight); - } - } - }); - - // content pane - contentPane = new NbiFrameContentPane(); - setContentPane(contentPane); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class NbiFrameContentPane extends NbiPanel { - private Image backgroundImage; - - @Override - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); - - if (backgroundImage != null) { - graphics.drawImage(backgroundImage, 0, 0, this); - } - } - - public Image getBackgroundImage() { - return backgroundImage; - } - - public void setBackgroundImage(URL url) { - if (url != null) { - backgroundImage = new ImageIcon(url).getImage(); - } else { - backgroundImage = null; - } - } - - public void setBackgroundImage(Image image) { - if (image != null) { - backgroundImage = image; - } else { - backgroundImage = null; - } - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String FRAME_WIDTH_PROPERTY = - "nbi.ui.swing.frame.width"; - - public static final String FRAME_MINIMUM_WIDTH_PROPERTY = - "nbi.ui.swing.frame.minimum.width"; - - public static final String FRAME_MAXIMUM_WIDTH_PROPERTY = - "nbi.ui.swing.frame.maximum.width"; - - public static final String FRAME_HEIGHT_PROPERTY = - "nbi.ui.swing.frame.height"; - - public static final String FRAME_MINIMUM_HEIGHT_PROPERTY = - "nbi.ui.swing.frame.minimum.height"; - - public static final String FRAME_MAXIMUM_HEIGHT_PROPERTY = - "nbi.ui.swing.frame.maximum.height"; - - public static final String FRAME_ICON_URI_PROPERTY = - "nbi.ui.swing.frame.icon.uri"; - - public static final int DEFAULT_FRAME_WIDTH = - 650; - - public static final int DEFAULT_FRAME_MINIMUM_WIDTH = - 650; - - public static final int DEFAULT_FRAME_MAXIMUM_WIDTH = - -1; - - public static final int DEFAULT_FRAME_HEIGHT = - 600; - - public static final int DEFAULT_FRAME_MINIMUM_HEIGHT = - 600; - - public static final int DEFAULT_FRAME_MAXIMUM_HEIGHT = - -1; - - public static final String DEFAULT_FRAME_ICON_URI = - ExtendedUri.RESOURCE_SCHEME + - ":org/netbeans/installer/utils/helper/swing/frame-icon.png"; - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON = - "NF.error.failed.to.download.icon"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_SET_FRAME_ICON = - "NF.error.failed.to.set.frame.icon"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiLabel.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiLabel.java deleted file mode 100644 index b170b252e7e4..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiLabel.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import javax.swing.JLabel; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiLabel extends JLabel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private boolean collapsePaths; - - private String text; - - public NbiLabel() { - super(); - - setText(null); - collapsePaths = false; - } - - public NbiLabel(final boolean collapsePaths) { - this(); - this.collapsePaths = collapsePaths; - if (collapsePaths) { - addComponentListener(new ComponentAdapter() { - - @Override - public void componentResized(ComponentEvent e) { - String shortenedString = shortenString(text); - NbiLabel.super.setText(shortenedString); - NbiLabel.super.setToolTipText(StringUtils.stripMnemonic(shortenedString)); - } - }); - } - } - - public void clearText() { - setText(null); - } - - @Override - public void setText(final String text) { - if ((text == null) || text.equals("")) { - this.text = DEFAULT_TEXT; - - super.setText(DEFAULT_TEXT); - super.setDisplayedMnemonic(DEFAULT_MNEMONIC); - super.setToolTipText(DEFAULT_TOOLTIP_TEXT); - } else { - this.text = text; - if (collapsePaths) { - String shortenedString = shortenString(text); - super.setText(shortenedString); - super.setToolTipText(StringUtils.stripMnemonic(shortenedString)); - } else { - super.setText(StringUtils.stripMnemonic(text)); - super.setToolTipText(StringUtils.stripMnemonic(text)); - } - - if (!SystemUtils.isMacOS()) { - super.setDisplayedMnemonic(StringUtils.fetchMnemonic(text)); - } - } - } - - private String shortenString(final String text) { - final String string = StringUtils.stripMnemonic(text); - final String separator = SystemUtils.getFileSeparator(); - final int boundsWidth = getBounds().width; - final int lastIndex = string.lastIndexOf(separator); - int stringWidth = getStringBounds(getGraphics(), text).width; - int index = string.lastIndexOf(separator, lastIndex - 1); - // we should continue while there is at least one separator - // (lastIndex > -1), there is a previous separator (index > -1) and - // the rendered string width exceeds the bounds - // (stringWidth > boundsWidth) - // note: if there are no separators in the string, it will not be - // shortened at all and the default shortening procedure will take - // place, also if collapsing a path does not help completely, additional - // shortening will be performed by the default procedure - String shortenedString = string; - while ((lastIndex != -1) && (index != -1) && (stringWidth > boundsWidth)) { - shortenedString = StringUtils.replace(string, "...", index + 1, lastIndex); - stringWidth = getStringBounds(getGraphics(), shortenedString).width; - index = string.lastIndexOf(separator, index - 1); - } - return shortenedString; - } - - private Rectangle getStringBounds(Graphics graphics, String text) { - return getFontMetrics( - getFont()).getStringBounds(text, graphics).getBounds(); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TEXT = - " "; // NOI18N - - public static final String DEFAULT_TOOLTIP_TEXT = - null; - - public static final char DEFAULT_MNEMONIC = - '\u0000'; // NOMAGI -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiList.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiList.java deleted file mode 100644 index 27ce8db5f7e9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiList.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JList; -import javax.swing.ListSelectionModel; -import javax.swing.plaf.basic.BasicBorders; - -/** - * - * @author Kirill Sorokin - */ -public class NbiList extends JList { - public NbiList() { - super(); - - setBorder(BasicBorders.getTextFieldBorder()); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPanel.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPanel.java deleted file mode 100644 index d3cac852d6af..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPanel.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Graphics; -import java.awt.GridBagLayout; -import java.awt.Image; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import javax.swing.ImageIcon; -import javax.swing.JPanel; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.helper.Pair; - -/** - * - * @author Kirill Sorokin - */ -public class NbiPanel extends JPanel { - private List > images ; - public static final int ANCHOR_TOP_LEFT = 1; - public static final int ANCHOR_TOP_RIGHT = 2; - public static final int ANCHOR_BOTTOM_LEFT = 3; - public static final int ANCHOR_BOTTOM_RIGHT = 4; - public static final int ANCHOR_LEFT = 5; - public static final int ANCHOR_RIGHT = 6; - public static final int ANCHOR_BOTTOM = 7; - public static final int ANCHOR_TOP = 8; - public static final int ANCHOR_FULL = 9; - - public NbiPanel() { - super(); - - setLayout(new GridBagLayout()); - images = new ArrayList > (); - } - public void setBackgroundImage(String backgroundImageURI, int anchor) { - if (backgroundImageURI != null) { - try { - File file = FileProxy.getInstance().getFile(backgroundImageURI,true); - ImageIcon backgroundImage = new ImageIcon(file.getAbsolutePath()); - setBackgroundImage(backgroundImage,anchor); - } catch (DownloadException e) { - LogManager.log(e); - } - } - } - public void setBackgroundImage(ImageIcon backgroundImage, int anchor) { - if (backgroundImage != null) { - images.add(new Pair (anchor,backgroundImage)); - } - } - public ImageIcon getBackgroundImage(int anchor) { - for(Pair pair : images) { - if(pair.getFirst().intValue() == anchor) { - return pair.getSecond(); - } - } - return null; - } - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); - - for(Pair pair : images){ - final int anchor = pair.getFirst().intValue(); - Image backgroundImage = pair.getSecond().getImage(); - if (backgroundImage != null) { - switch(anchor) { - case ANCHOR_TOP_LEFT : - graphics.drawImage(backgroundImage, - 0, - 0, - this); - break; - case ANCHOR_TOP_RIGHT: - graphics.drawImage(backgroundImage, - this.getWidth() - backgroundImage.getWidth(this), - 0, - this); - break; - case ANCHOR_BOTTOM_LEFT: - graphics.drawImage(backgroundImage, - 0, - this.getHeight() - backgroundImage.getHeight(this), - this); - break; - case ANCHOR_BOTTOM_RIGHT: - graphics.drawImage(backgroundImage, - this.getWidth() - backgroundImage.getWidth(this), - this.getHeight() - backgroundImage.getHeight(this), - this); - break; - - case ANCHOR_LEFT : - graphics.drawImage(backgroundImage, - 0, - (this.getHeight() - backgroundImage.getHeight(this)) / 2 , - this); - break; - case ANCHOR_RIGHT: - graphics.drawImage(backgroundImage, - this.getWidth() - backgroundImage.getWidth(this), - (this.getHeight() - backgroundImage.getHeight(this)) / 2, - this); - break; - case ANCHOR_BOTTOM: - graphics.drawImage(backgroundImage, - (this.getWidth() - backgroundImage.getWidth(this))/2, - this.getHeight() - backgroundImage.getHeight(this), - this); - break; - case ANCHOR_TOP: - graphics.drawImage(backgroundImage, - this.getWidth() - backgroundImage.getWidth(this), - 0, - this); - break; - case ANCHOR_FULL: - graphics.drawImage( - backgroundImage, - 0, 0, - this.getWidth(), this.getHeight(), - 0, 0, - backgroundImage.getWidth(this), backgroundImage.getHeight(this), - this); - break; - } - } - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPasswordField.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPasswordField.java deleted file mode 100644 index f6bd54272106..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiPasswordField.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JPasswordField; - -/** - * - * @author Kirill Sorokin - */ -public class NbiPasswordField extends JPasswordField { - public NbiPasswordField() { - super(); - - setColumns(15); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiProgressBar.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiProgressBar.java deleted file mode 100644 index 50bf618bfbac..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiProgressBar.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JProgressBar; -import org.netbeans.installer.utils.progress.Progress; - -/** - * - * @author Kirill Sorokin - */ -public class NbiProgressBar extends JProgressBar { - public NbiProgressBar() { - super(Progress.START, Progress.COMPLETE); - - setBorderPainted(true); - setStringPainted(true); - setValue(0); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiRadioButton.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiRadioButton.java deleted file mode 100644 index 8c36a934f39c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiRadioButton.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JRadioButton; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiRadioButton extends JRadioButton { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public NbiRadioButton() { - super(); - - setText(DEFAULT_TEXT); - setMnemonic(DEFAULT_MNEMONIC); - } - - public void setText(String text) { - super.setText(StringUtils.stripMnemonic(text)); - - if (!SystemUtils.isMacOS()) { - super.setMnemonic(StringUtils.fetchMnemonic(text)); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TEXT = - ""; // NOI18N - - public static final char DEFAULT_MNEMONIC = - '\u0000'; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiScrollPane.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiScrollPane.java deleted file mode 100644 index d335bd339573..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiScrollPane.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Insets; -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiScrollPane extends JScrollPane { - public NbiScrollPane(final JComponent component) { - super(component); - - setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - - // l&f-specific tweaks - if (!UIManager.getLookAndFeel().getID().equals("GTK")) { - setViewportBorder(new EmptyBorder(new Insets(0, 0, 0, 0))); - } - - // system-specific tweaks - if (SystemUtils.isMacOS()) { - setOpaque(false); - getViewport().setOpaque(false); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiSeparator.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiSeparator.java deleted file mode 100644 index d40495ade2cd..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiSeparator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JSeparator; -import javax.swing.SwingConstants; - -/** - * - * @author Kirill Sorokin - */ -public class NbiSeparator extends JSeparator { - public NbiSeparator() { - super(SwingConstants.HORIZONTAL); - } - - public NbiSeparator(int orientation) { - super(orientation); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTabbedPane.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTabbedPane.java deleted file mode 100644 index a282828970a8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTabbedPane.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JTabbedPane; -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTabbedPane extends JTabbedPane { - public NbiTabbedPane() { - super(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextDialog.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextDialog.java deleted file mode 100644 index f07f368bb5d4..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextDialog.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import javax.swing.JScrollPane; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.utils.helper.Text; - -public class NbiTextDialog extends NbiDialog { - private NbiTextPane textPane; - private NbiPanel textPanel; - private NbiScrollPane textScrollPane; - - private String title; - private Text text; - - public NbiTextDialog(String title, Text text) { - super(); - - this.title = title; - this.text = text; - - initComponents(); - initialize(); - } - - public NbiTextDialog(NbiFrame owner, String title, Text text) { - super(owner); - - this.title = title; - this.text = text; - - initComponents(); - initialize(); - } - - private void initialize() { - setTitle(title); - - textPane.setText(text); - } - - private void initComponents() { - setLayout(new GridBagLayout()); - - textPane = new NbiTextPane(); - - textPanel = new NbiPanel(); - textPanel.setLayout(new BorderLayout()); - textPanel.add(textPane, BorderLayout.CENTER); - - textScrollPane = new NbiScrollPane(textPanel); - textScrollPane.setViewportBorder(new EmptyBorder(new Insets(5, 5, 5, 5))); - textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - add(textScrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextField.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextField.java deleted file mode 100644 index 7d80797ca8b8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextField.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.event.MouseEvent; -import javax.swing.JTextField; -import org.netbeans.installer.utils.LogManager; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTextField extends JTextField { - public NbiTextField() { - super(); - } - - @Override - protected void processMouseMotionEvent(MouseEvent e) { - try { - super.processMouseMotionEvent(e); - } catch (ArrayIndexOutOfBoundsException ex) { - //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6828938 - LogManager.log(ex); - } - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextPane.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextPane.java deleted file mode 100644 index a11ff884ffe8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextPane.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Color; -import javax.swing.JTextPane; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.utils.helper.Text; -import org.netbeans.installer.utils.helper.Text.ContentType; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTextPane extends JTextPane { - public NbiTextPane() { - super(); - - setOpaque(false); - setEditable(false); - setBorder(new EmptyBorder(0, 0, 0, 0)); - setFocusable(false); - putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true); - - if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { - //#134837 - //http://forums.java.net/jive/thread.jspa?messageID=283882 - setBackground(new Color(0, 0, 0, 0)); - } - } - - @Override - public void setText(String text) { - if ((text == null) || text.equals("")) { - if (getContentType().equals("text/plain")) { - super.setText(" "); - } else if (getContentType().equals("text/html")) { - super.setText(" "); - } - } else { - super.setText(text); - } - } - - public void setText(Text text) { - setContentType(text.getContentType()); - setText(text.getText()); - } - - public void setText(CharSequence chars) { - setText(chars.toString()); - } - - public void clearText() { - setText(""); - } - - public void setContentType(ContentType contentType) { - super.setContentType(contentType.toString()); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextsDialog.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextsDialog.java deleted file mode 100644 index 5f6d51a8888b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTextsDialog.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.Map; -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.utils.helper.Text; - -public class NbiTextsDialog extends NbiDialog { - private NbiTabbedPane textsTabbedPane; - - private String title; - private Map texts; - - public NbiTextsDialog(String title, Map texts) { - super(); - - this.title = title; - this.texts = texts; - - initComponents(); - initialize(); - } - - public NbiTextsDialog(NbiFrame owner, String title, Map texts) { - super(owner); - - this.title = title; - this.texts = texts; - - initComponents(); - initialize(); - } - - private void initialize() { - setTitle(title); - - textsTabbedPane.removeAll(); - - texts.forEach((tabTitle, component) -> textsTabbedPane.addTab(tabTitle, createTab(component))); - } - - private void initComponents() { - setLayout(new GridBagLayout()); - - textsTabbedPane = new NbiTabbedPane(); - - add(textsTabbedPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); - } - - private JComponent createTab(Text text) { - NbiTextPane textPane; - NbiPanel textPanel; - NbiScrollPane textScrollPane; - - textPane = new NbiTextPane(); - textPane.setText(text); - - textPanel = new NbiPanel(); - textPanel.setLayout(new BorderLayout()); - textPanel.add(textPane, BorderLayout.CENTER); - - textScrollPane = new NbiScrollPane(textPanel); - textScrollPane.setViewportBorder(new EmptyBorder(new Insets(5, 5, 5, 5))); - textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - return textScrollPane; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTree.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTree.java deleted file mode 100644 index 00770a0e7da2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTree.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import javax.swing.JTree; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTree extends JTree { - public NbiTree() { - super(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTable.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTable.java deleted file mode 100644 index 565549517853..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTable.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.tree.TreePath; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.LogManager; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTreeTable extends JTable { - private NbiTreeTableModel model; - - private NbiTreeTableColumnRenderer treeRenderer; - - private boolean mousePressedEventConsumed = false; - - public NbiTreeTable(final NbiTreeTableModel model) { - this.model = model; - - setTreeColumnRenderer(new NbiTreeTableColumnRenderer(this)); - model.setTree(treeRenderer); - - super.setModel(model); - - getColumnModel().getColumn(model.getTreeColumnIndex()).setCellRenderer(treeRenderer); - - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } - - public void updateUI() { - super.updateUI(); - - if (treeRenderer != null) { - treeRenderer.updateUI(); - } - } - - public void setRowHeight(int height) { - super.setRowHeight(height); - - if (treeRenderer != null) { - treeRenderer.setRowHeight(height); - } - } - - public NbiTreeTableModel getModel() { - return model; - } - - public NbiTreeTableColumnRenderer getTreeColumnRenderer() { - return treeRenderer; - } - - public void setTreeColumnRenderer(NbiTreeTableColumnRenderer renderer) { - treeRenderer = renderer; - - model.setTree(renderer); - model.setTreeModel(renderer.getModel()); - - treeRenderer.setRowHeight(getRowHeight()); - } - - public NbiTreeTableColumnCellRenderer getTreeColumnCellRenderer() { - return treeRenderer.getTreeColumnCellRenderer(); - } - - public void setTreeColumnCellRenderer(NbiTreeTableColumnCellRenderer renderer) { - treeRenderer.setTreeColumnCellRenderer(renderer); - } - - protected void processMouseEvent(MouseEvent event) { - int column = columnAtPoint(event.getPoint()); - int row = rowAtPoint(event.getPoint()); - - if ((event.getID() == MouseEvent.MOUSE_RELEASED) && mousePressedEventConsumed) { - mousePressedEventConsumed = false; - event.consume(); - return; - } - - if (mouseEventHitTreeHandle(event)) { - mousePressedEventConsumed = true; - event.consume(); - sendTreeHandleEvents(event); - return; - } - - mousePressedEventConsumed = false; - super.processMouseEvent(event); - } - - protected void processKeyEvent(KeyEvent event) { - if (event.getID() == KeyEvent.KEY_RELEASED) { - int row = getSelectedRow(); - - if (row != -1) { - if (event.getKeyCode() == KeyEvent.VK_LEFT) { - if (treeRenderer.isExpanded(row)) { - treeRenderer.collapseRow(row); - } else { - int parentRow = treeRenderer.getRowForPath(treeRenderer.getPathForRow(row).getParentPath()); - - treeRenderer.collapseRow(parentRow); - getSelectionModel().setSelectionInterval(parentRow, parentRow); - } - event.consume(); - return; - } - if (event.getKeyCode() == KeyEvent.VK_RIGHT) { - if (treeRenderer.isCollapsed(row)) { - treeRenderer.expandRow(row); - } - event.consume(); - return; - } - } - } - - super.processKeyEvent(event); - } - - private boolean mouseEventHitTreeHandle(MouseEvent event) { - if ((event.getID() != MouseEvent.MOUSE_PRESSED)) { - return false; - } - - int column = columnAtPoint(event.getPoint()); - int row = rowAtPoint(event.getPoint()); - - if (column == model.getTreeColumnIndex()) { - MouseEvent mousePressed = new MouseEvent(treeRenderer, - MouseEvent.MOUSE_PRESSED, - event.getWhen(), - event.getModifiers(), - event.getX() - getCellRect(row, column, true).x, - event.getY(), - event.getClickCount(), - event.isPopupTrigger()); - MouseEvent mouseReleased = new MouseEvent(treeRenderer, - MouseEvent.MOUSE_RELEASED, - event.getWhen(), - event.getModifiers(), - event.getX() - getCellRect(row, column, true).x, - event.getY(), - event.getClickCount(), - event.isPopupTrigger()); - - TreePath targetPath = treeRenderer.getPathForRow(row); - - boolean currentState = treeRenderer.isExpanded(targetPath); - - // dispatch the event and see whether the node changed its state - model.consumeNextExpansionEvent(); - treeRenderer.dispatchEvent(mousePressed); - treeRenderer.dispatchEvent(mouseReleased); - - if (treeRenderer.isExpanded(targetPath) == currentState) { - model.cancelConsume(); - return false; - } else { - model.consumeNextExpansionEvent(); - treeRenderer.dispatchEvent(mousePressed); - treeRenderer.dispatchEvent(mouseReleased); - return true; - } - } else { - return false; - } - } - - private void sendTreeHandleEvents(MouseEvent event) { - int column = model.getTreeColumnIndex(); - int row = rowAtPoint(event.getPoint()); - - MouseEvent mousePressed = new MouseEvent(treeRenderer, - MouseEvent.MOUSE_PRESSED, - event.getWhen(), - event.getModifiers(), - event.getX() - getCellRect(row, column, true).x, - event.getY(), - event.getClickCount(), - event.isPopupTrigger()); - MouseEvent mouseReleased = new MouseEvent(treeRenderer, - MouseEvent.MOUSE_RELEASED, - event.getWhen(), - event.getModifiers(), - event.getX() - getCellRect(row, column, true).x, - event.getY(), - event.getClickCount(), - event.isPopupTrigger()); - - treeRenderer.dispatchEvent(mousePressed); - treeRenderer.dispatchEvent(mouseReleased); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnCellRenderer.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnCellRenderer.java deleted file mode 100644 index 3b9334199b8a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnCellRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Component; -import javax.swing.JLabel; -import javax.swing.JTree; -import javax.swing.tree.TreeCellRenderer; - -public class NbiTreeTableColumnCellRenderer extends JLabel implements TreeCellRenderer { - protected NbiTreeTable treeTable; - - public NbiTreeTableColumnCellRenderer(final NbiTreeTable treeTable) { - this.treeTable = treeTable; - } - - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { - // we base our assumption on which node is selected on whether this row is - // selected in the table, since the selection is not propagated to the tree - if (row == treeTable.getSelectedRow()) { - setOpaque(true); - setForeground(treeTable.getSelectionForeground()); - setBackground(treeTable.getSelectionBackground()); - } else { - setOpaque(false); - setForeground(treeTable.getForeground()); - setBackground(treeTable.getBackground()); - } - - setText(value.toString()); - - return this; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnRenderer.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnRenderer.java deleted file mode 100644 index 695c163bc1cc..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableColumnRenderer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.awt.Component; -import java.awt.Graphics; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.table.TableCellRenderer; -import org.netbeans.installer.utils.LogManager; - -/** - * - * @author Kirill Sorokin - */ -public class NbiTreeTableColumnRenderer extends JTree implements TableCellRenderer { - private NbiTreeTable treeTable; - - private int visibleRow = 0; - - private NbiTreeTableColumnCellRenderer cellRenderer; - - public NbiTreeTableColumnRenderer(final NbiTreeTable treeTable) { - this.treeTable = treeTable; - - setModel(treeTable.getModel().getTreeModel()); - - setRootVisible(false); - setShowsRootHandles(true); - - setTreeColumnCellRenderer(new NbiTreeTableColumnCellRenderer(treeTable)); - - setRowHeight(treeTable.getRowHeight()); - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { - visibleRow = row; - - if (selected) { - setOpaque(true); - setBackground(treeTable.getSelectionBackground()); - setForeground(treeTable.getSelectionForeground()); - } else { - setOpaque(false); - setBackground(treeTable.getBackground()); - setForeground(treeTable.getForeground()); - } - - return this; - } - - public void setBounds(int x, int y, int w, int h) { - if (treeTable != null) { - super.setBounds(x, 0, w, treeTable.getHeight()); - } else { - super.setBounds(x, y, w, h); - } - } - - public void paint(Graphics g) { - g.translate(0, -visibleRow * getRowHeight()); - super.paint(g); - } - - public NbiTreeTableColumnCellRenderer getTreeColumnCellRenderer() { - return cellRenderer; - } - - public void setTreeColumnCellRenderer(final NbiTreeTableColumnCellRenderer renderer) { - cellRenderer = renderer; - setCellRenderer(renderer); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableModel.java b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableModel.java deleted file mode 100644 index 2e121fbc03f2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/NbiTreeTableModel.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.helper.swing; - -import java.util.Vector; -import javax.swing.JTree; -import javax.swing.SwingUtilities; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeExpansionListener; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.table.TableModel; -import javax.swing.tree.TreeModel; - -/** - * - * @author Kirill Sorokin - */ -public abstract class NbiTreeTableModel implements TableModel { - private Vector listeners = new Vector(); - - private TreeModel treeModel; - private JTree tree; - - private TreeExpansionListener treeExpansionListener; - private TreeModelListener treeModelListener; - - private boolean consumeNextExpansionEvent = false; - - public NbiTreeTableModel(final TreeModel treeModel) { - setTreeModel(treeModel); - } - - public abstract int getTreeColumnIndex(); - - public final TreeModel getTreeModel() { - return treeModel; - } - - final void setTreeModel(final TreeModel treeModel) { - removeTreeModelListener(); - this.treeModel = treeModel; - addTreeModelListener(); - } - - public final JTree getTree() { - return tree; - } - - final void setTree(final JTree tree) { - removeTreeExpansionListener(); - this.tree = tree; - addTreeExpansionListener(); - } - - final void consumeNextExpansionEvent() { - consumeNextExpansionEvent = true; - } - - final void cancelConsume() { - consumeNextExpansionEvent = false; - } - - // partial TableModel implementation //////////////////////////////////////////// - public final int getRowCount() { - return tree.getRowCount(); - } - - public abstract int getColumnCount(); - - public abstract String getColumnName(int column); - - public abstract Class getColumnClass(int column); - - public abstract boolean isCellEditable(int row, int column); - - public abstract Object getValueAt(int row, int column); - - public abstract void setValueAt(Object value, int row, int column); - - public void addTableModelListener(TableModelListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - public void removeTableModelListener(TableModelListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - // protected stuff - to be used by extending classes //////////////////////////// - protected void fireTableRowsInserted(int firstRow, int lastRow) { - fireTableDataChanged(new TableModelEvent(this, firstRow, lastRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); - } - - protected void fireTableRowsDeleted(int firstRow, int lastRow) { - fireTableDataChanged(new TableModelEvent(this, firstRow, lastRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); - } - - protected void fireTableRowsUpdated(int firstRow, int lastRow) { - fireTableDataChanged(new TableModelEvent(this, firstRow, lastRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE)); - } - - // private stuff //////////////////////////////////////////////////////////////// - private void removeTreeModelListener() { - if (treeModel != null) { - treeModel.removeTreeModelListener(treeModelListener); - } - } - - private void addTreeModelListener() { - if (treeModelListener == null) { - treeModelListener = new TreeModelListener() { - public void treeNodesChanged(TreeModelEvent event) { - delayedFireTableDataChanged(); - } - public void treeNodesInserted(TreeModelEvent event) { - delayedFireTableDataChanged(); - } - public void treeNodesRemoved(TreeModelEvent event) { - delayedFireTableDataChanged(); - } - public void treeStructureChanged(TreeModelEvent event) { - delayedFireTableDataChanged(); - } - }; - } - - treeModel.addTreeModelListener(treeModelListener); - } - - private void removeTreeExpansionListener() { - if (tree != null) { - tree.removeTreeExpansionListener(treeExpansionListener); - } - } - - private void addTreeExpansionListener() { - if (treeExpansionListener == null) { - treeExpansionListener = new TreeExpansionListener() { - public void treeCollapsed(TreeExpansionEvent event) { - if (consumeNextExpansionEvent) { - consumeNextExpansionEvent = false; - return; - } - - int row = tree.getRowForPath(event.getPath()); - int childrenCount = treeModel.getChildCount(event.getPath().getLastPathComponent()); - fireTableRowsDeleted(row + 1, row + childrenCount); - fireTableRowsUpdated(row, row); - } - - public void treeExpanded(TreeExpansionEvent event) { - if (consumeNextExpansionEvent) { - consumeNextExpansionEvent = false; - return; - } - - int row = tree.getRowForPath(event.getPath()); - int childrenCount = treeModel.getChildCount(event.getPath().getLastPathComponent()); - fireTableRowsInserted(row + 1, row + childrenCount); - fireTableRowsUpdated(row, row); - } - }; - } - - tree.addTreeExpansionListener(treeExpansionListener); - } - - private void fireTableDataChanged(TableModelEvent event) { - for (TableModelListener listener: listeners.toArray(new TableModelListener[0])) { - listener.tableChanged(event); - } - } - - private void fireTableDataChanged() { - fireTableDataChanged(new TableModelEvent(this)); - } - - private void delayedFireTableDataChanged() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - fireTableDataChanged(); - } - }); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/frame-icon.png b/nbi/engine/src/org/netbeans/installer/utils/helper/swing/frame-icon.png deleted file mode 100644 index 1b3bcd61d25b..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/utils/helper/swing/frame-icon.png and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/utils/progress/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/progress/Bundle.properties deleted file mode 100644 index e6995d823967..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/progress/Bundle.properties +++ /dev/null @@ -1,38 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -################################################################################ -# CompositeProgress.java -CP.error.percentage=\ -The specified percentage - {0} is invalid. The total percentage of the \n\ -composite progress (sum of the own percentage and the percentages of the \n\ -children) cannot be less than {1} and greater than {2}. - -CP.error.progress=\ -The specified child progress doesn't exist in the composite progress \n\ -so it can not be removed. - -################################################################################ -# Progress.java -P.error.percentage=\ -The specified percentage - {0} is invalid. The total percentage of the \n\ -progress cannot be less than {1} and greater than {2}. - -################################################################################ -# ProgressListener.java diff --git a/nbi/engine/src/org/netbeans/installer/utils/progress/CompositeProgress.java b/nbi/engine/src/org/netbeans/installer/utils/progress/CompositeProgress.java deleted file mode 100644 index 7c5a5387124f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/progress/CompositeProgress.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.progress; - -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; - -/** - * A specialized subclass of {@link Progress} which is capable having child - * progresses. - * - *

- * Each registered child has an assosiated percentage number. It is called "relative - * percentage" and basically means which part of the composite's total percentage - * does this child "own". Additionally the composite has its "own percentage", which - * is independent of the children. - * - *

- * The composite registers itself as a listener on each added child and updates its - * total percentage according to the children's states. It also propagates the - * change information to its own listeners. - * - *

- * The synchronization behavior of a composite progress is not completely defined, - * if the composite serves as the target of a synchronization link. It will behave - * exactly as a regular progress if it has no children, but in the other case, - * errors may arise if the synchronization routine attempts to set an illegal - * percentage, i.e. if this "attempted" percentage will conflict with the children. - * - *

- * An additional capability of a composite progress is its ability to fetch - * children's detail status whenever a child is updated. This bahaior is controlled - * by the synchronizeDetails flag. - * - * @author Kirill Sorokin - * - * @since 1.0 - */ -public final class CompositeProgress extends Progress implements ProgressListener { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The list of child progresses. - */ - private List progresses; - - /** - * The list of childrens' relative percentages. - */ - private List percentages; - - /** - * The flag which controls whether the composite will adopt its children's - * detail values. If it's set to true, then whenever a child's state changes, - * the composite will update its detail with the detail of the just updated - * child. - */ - private boolean synchronizeDetails; - - // constructors ///////////////////////////////////////////////////////////////// - /** - * Creates a new {@link CompositeProgress} instance. - */ - public CompositeProgress() { - super(); - - progresses = new LinkedList(); - percentages = new LinkedList(); - - synchronizeDetails = false; - } - - /** - * Creates a new {@link CompositeProgress} instance and registers the supplied - * listener. - * - * @param initialListener A progress listener to register upon progress - * creation. - * - * @see #CompositeProgress() - */ - public CompositeProgress(final ProgressListener initialListener) { - this(); - - addProgressListener(initialListener); - } - - // overrides //////////////////////////////////////////////////////////////////// - /** - * Returns the total percentage of the composite, i.e. its own percentage and - * sum of percentages of its child progresses (each multiplied by the relative - * percentage of that child). - * - * @return The total percentage of the composite. - */ - @Override - public int getPercentage() { - int total = 0; - for (int i = 0; i < progresses.size(); i++) { - total += progresses.get(i).getPercentage() * percentages.get(i); - } - - total = (total / COMPLETE) + percentage; - - return total; - } - - /** - * Sets the core composite's percentage. The value is updated only if the - * supplied percentage is different from the current. Also the progress - * listeners are notified only if the update actually took place. - * - * @param percentage The new value for the core composite's percentage. - * - * @throws IllegalArgumentException if the supplied percentage cannot be - * set. - */ - @Override - public void setPercentage(final int percentage) { - if (this.percentage != percentage) { - if (!evaluatePercentage(percentage)) { - throw new IllegalArgumentException(StringUtils.format( - ERROR_WRONG_PERCENTAGE, - percentage, - START, - COMPLETE)); - } - - this.percentage = percentage; - - notifyListeners(); - } - } - - /** - * Adds the specified amount to the core composite's percentage. The added - * amount can be either positive or negative. The percentage value will be - * updated only if the result of the addition is different from the current core - * percentage. Also the listeners are notified only is the update actually took - * place. - * - * @param addition The amount to add to the core composite's percentage. - * - * @throws {@IllegalArgumentException} if the supplied percentage cannot be - * added. - */ - @Override - public void addPercentage(final int addition) { - final int result = this.percentage + addition; - - if (this.percentage != result) { - if (!evaluatePercentage(result)) { - throw new IllegalArgumentException(StringUtils.format( - ERROR_WRONG_PERCENTAGE, - addition, - START, - COMPLETE)); - } - - this.percentage = result; - - notifyListeners(); - } - } - - /** - * Sets the value of the canceled property. The value is updated - * only if the supplied value is different from the current. Also the progress - * listeners are notified only if the update actually took place. - * - *

- * If the progress is in being synchronized from another progress. The cancelled - * status will be propagated to the synchronization source. - * - *

- * Additionally this method propagates the canceled value to the - * child progresses. - * - * @param canceled The new value for the canceled property. - */ - @Override - public void setCanceled(final boolean canceled) { - super.setCanceled(canceled); - - for (Progress child: progresses) { - child.setCanceled(canceled); - } - } - - // composite-specific methods /////////////////////////////////////////////////// - /** - * Add a new child progress to the composite. - * - * @param progress The child progress to add to the composite. - * @param percentage The child's relative percentage within the composite. - * - * @throws IllegalArgumentException if the supplied percentage cannot be - * added. - */ - public void addChild(final Progress progress, final int percentage) { - // check wehther we can add a new child with the given percentage - if (!evaluatePercentage(percentage)) { - throw new IllegalArgumentException(StringUtils.format( - ERROR_WRONG_PERCENTAGE, - percentage, - START, - COMPLETE)); - } - - progresses.add(progress); - percentages.add(percentage); - - progress.addProgressListener(this); - - notifyListeners(); - } - /** - * Remove a child progress from the composite. - * - * @param progress The child progress to remove from the composite. - * - * @throws IllegalArgumentException if the supplied progress is not in - * composite. - */ - public void removeChild(final Progress progress) { - final int index = progresses.indexOf(progress); - if(index != -1) { - percentages.remove(index); - progresses.remove(index); - }else { - throw new IllegalArgumentException(StringUtils.format( - ERROR_WRONG_PROGRESS)); - } - progress.removeProgressListener(this); - } - - /** - * Sets the value of the synchronizeDetails property. - * - * @param synchronizeDetails The new value for the - * synchronizeDetails property. - */ - public void synchronizeDetails(final boolean synchronizeDetails) { - this.synchronizeDetails = synchronizeDetails; - } - - // progress listener implementation ///////////////////////////////////////////// - /** - * This method will get called by the child progresses as they change state - - * the composite automatically registers itself as a listener on each of the - * children. - * - * @param progress The child progress whose state has changed. - */ - public void progressUpdated(final Progress progress) { - if (synchronizeDetails) { - setDetail(progress.getDetail()); - } - - notifyListeners(); - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * This methods evaluates the given percentage in terms of whether it could be - * added to the composite's total percentage. It sums the composite's own - * percentage, the declared percentages of all the children and the percentage - * being evaluated. The return value depends on whether the sum fits into the - * allowed percentage range or not. - * - * @param percentage The percentage to evaluate. - * @return true if the specified percentage can be added to the - * composite, false otherwise. - */ - private boolean evaluatePercentage(final int percentage) { - int total = percentage; - for (Integer value: percentages) { - total += value; - } - - return (total >= START) && (total <= COMPLETE); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The error message which will be displayed when a user tries to set an invalid - * percentage either directly or via a child. - */ - public static final String ERROR_WRONG_PERCENTAGE = - ResourceUtils.getString(CompositeProgress.class, - "CP.error.percentage"); // NOI18N - /** - * The error message which will be displayed when a user tries to remove - * a non-existent child. - */ - public static final String ERROR_WRONG_PROGRESS = - ResourceUtils.getString(CompositeProgress.class, - "CP.error.progress"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/progress/Progress.java b/nbi/engine/src/org/netbeans/installer/utils/progress/Progress.java deleted file mode 100644 index d06a6bf5a26d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/progress/Progress.java +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.progress; - -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.ErrorLevel; - -/** - * This class encapsulates data that describes the course of an operation, such as - * the operation description, detailed status string and completion percentage. - * - *

- * A typical usecase would be for a client to costruct an instance of this object - * and pass it to the operation handler, which will update the progress as the - * operation goes on. The client can register itself as a listener for the progress - * object; this way it will receive notifications on the progress updates. - * - *

- * The client can also use the built-in cancellation facility to inform the - * operation handler of the necessity to break the operation and return. Whether - * the operation will be stopped, however, solely depends on the operation handler's - * politeness. - * - *

- * In some cases the opreation handler is not capable of working directly with the - * progress that was passed to it. In this case it should construct a specialized - * {@link Progress} instance and use the synchronization facility to keep these two - * in sync. - * - * @see #addProgressListener(ProgressListener) - * @see #setCanceled(boolean) - * @see #synchronizeFrom(Progress) - * @see CompositeProgress - * - * @author Kirill Sorokin - * - * @since 1.0 - */ -public class Progress { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The title (i.e. human readable description) of the progress. The title is - * expected not to change often during the course of the progress. - */ - protected String title; - - /** - * The detailed status of the progress. As opposed to the title, the detail - * is expected to change with every couple changes in the procentage. - */ - protected String detail; - - /** - * The current state of the progress expressed in percents. Obviously the most - * often changed property of the progress. - */ - protected int percentage; - - /** - * A flag which indicates whether or not the progress has been canceled. It is - * expected that the updater of the progress will check the value of this - * flag and act accordingly. It should be used to establish some basic - * communication between the invoker of a lengthy operation and the code which - * actually performs the operation. - */ - protected boolean canceled; - - /** - * The listener which controls the synchronization between two progresses. - */ - private ProgressListener synchronizer; - - /** - * The source of the synchronization data. - */ - private Progress source; - - /** - * The list of registered progress listeners. - */ - private List listeners; - - // constructors ///////////////////////////////////////////////////////////////// - /** - * Creates a new {@link Progress} instance. The new instance has its - * title and detail set to empty strings, - * percentage to {@link #START} and canceled to - * false. - */ - public Progress() { - title = StringUtils.EMPTY_STRING; - detail = StringUtils.EMPTY_STRING; - percentage = START; - - canceled = false; - - synchronizer = null; - source = null; - - listeners = new ArrayList(); - } - - /** - * Creates a new {@link Progress} instance and registers the supplied listener. - * - *

- * It's important to remember that listeners in progress are not implemented via - * weak references and hence should be handled with care. The most common case - * would be to dump the complete progresses tree together with all listeners. - * However if it's not the case, be sure to remove the listener with the - * {@link #removeProgressListener(ProgressListener)} method. - * - * @param initialListener A progress listener to register upon progress - * creation. - * - * @see #Progress() - * @see #removeProgressListener(ProgressListener) - */ - public Progress(final ProgressListener initialListener) { - this(); - - addProgressListener(initialListener); - } - - // getters/setters ////////////////////////////////////////////////////////////// - /** - * Returns the value of the title property. - * - * @return The value of the title property. - */ - public String getTitle() { - return title; - } - - /** - * Sets the value of the title property. The value is updated only - * if the supplied title is different from the current. Also the progress - * listeners are notified only if the update actually took place. - * - * @param title The new value for the title property. - */ - public void setTitle(final String title) { - if (!this.title.equals(title)) { - this.title = title; - - notifyListeners(); - } - } - - /** - * Returns the value of the detail property. - * - * @return The value of the detail property. - */ - public String getDetail() { - return detail; - } - - /** - * Sets the value of the detail property. The value is updated only - * if the supplied detail is different from the current. Also the progress - * listeners are notified only if the update actually took place. - * - * @param detail The new value for the detail property. - */ - public void setDetail(final String detail) { - if (!this.detail.equals(detail)) { - this.detail = detail; - - notifyListeners(); - } - } - - /** - * Returns the value of the percentage property. - * - * @return The value of the percentage property. - */ - public int getPercentage() { - return percentage; - } - - /** - * Sets the value of the percentage property. The value is updated - * only if the supplied percentage is different from the current. Also the - * progress listeners are notified only if the update actually took place. - * - * @param percentage The new value for the percentage property. - */ - public void setPercentage(final int percentage) { - if (this.percentage != percentage) { - if ((percentage < START) || (percentage > COMPLETE)) { - LogManager.log(StringUtils.format( - ERROR_WRONG_PERCENTAGE, - percentage, - START, - COMPLETE)); - } else { - this.percentage = percentage; - } - - notifyListeners(); - } - } - - /** - * Sets the value of the percentage property. This method is the - * same as the {@link #setPercentage(int)} one, with the only difference that - * it accepts a long parameter. The parameter is converted to an - * int and the corresponding method is called. - * - * @param percentage The new value for the percentage property. - * - * @throws IllegalArgumentException if the supplied percentage cannot be - * set. - */ - public void setPercentage(final long percentage) { - setPercentage((int) percentage); - } - - /** - * Adds the specified amount to the percentage property. The added - * amount can be either positive or negative. Teh percentage value will be - * updated only if the result of the addition is different from the current - * percentage. Also the listeners are notified only is the update actually took - * place. - * - * @param addition The amount to add to the percentage property. - */ - public void addPercentage(final int addition) { - final int result = percentage + addition; - - if (this.percentage != result) { - if ((result < START) || (result > COMPLETE)) { - LogManager.log(StringUtils.format( - ERROR_WRONG_PERCENTAGE, - result, - START, - COMPLETE)); - } else { - this.percentage = result; - } - - notifyListeners(); - } - } - - /** - * Returns the value of the canceled property. - * - * @return The value of the canceled property. - */ - public boolean isCanceled() { - return canceled; - } - - /** - * Sets the value of the canceled property. The value is updated - * only if the supplied value is different from the current. Also the progress - * listeners are notified only if the update actually took place. - * - *

- * If the progress is in being synchronized from another progress. The cancelled - * status will be propagated to the synchronization source. - * - * @param canceled The new value for the canceled property. - */ - public void setCanceled(final boolean canceled) { - if (this.canceled != canceled) { - this.canceled = canceled; - - // propagate the cancel status to the source - if (source != null) { - source.setCanceled(canceled); - } - - notifyListeners(); - } - } - - // synchronization ////////////////////////////////////////////////////////////// - /** - * Sets up the synchronization of this progress object from the specified - * source. If there was a synchronization link already set up, it is removed. - * - *

- * Once the synchronization is established, the methods that set the core - * progress properties do not have any effect - the properties will be correctly - * set, but will be overwritten with the next source update. - * - *

- * In order to remove the synchronization link on this progress, just supply - * null as the parameter. - * - * @param progress A progress object from which to set up the synchronization, - * or null to cancel the synchronization. - */ - public void synchronizeFrom(final Progress progress) { - if (source != null) { - source.removeProgressListener(synchronizer); - } - - if (progress != null) { - synchronizer = new ProgressListener() { - public void progressUpdated(Progress progress) { - setTitle(progress.getTitle()); - setDetail(progress.getDetail()); - setPercentage(progress.getPercentage()); - } - }; - - source = progress; - source.addProgressListener(synchronizer); - } - } - - /** - * Sets up the reverse synchronization of this progress object from the - * specified source. - * - *

- * This method is very similar to the {@link #synchronizeFrom(Progress)} method. - * The only difference is in that instead of setting the percentage of this - * progress object to the percentage of the source, it is set to the difference - * between {@link #COMPLETE} and the source's percentage. - * - *

- * In order to remove the synchronization link on this progress, just supply - * null as the parameter. - * - * @param progress A progress object from which to set up the synchronization, - * or null to cancel the synchronization. - * - * @see #synchronizeFrom(Progress) - */ - public void reverseSynchronizeFrom(final Progress progress) { - // clear the current source - if (source != null) { - source.removeProgressListener(synchronizer); - } - - if (progress != null) { - synchronizer = new ProgressListener() { - public void progressUpdated(Progress progress) { - setTitle(progress.getTitle()); - setDetail(progress.getDetail()); - setPercentage(Progress.COMPLETE - progress.getPercentage()); - } - }; - - source = progress; - source.addProgressListener(synchronizer); - } - } - - /** - * Sets up the synchronization of this progress object to the specified target. - * This method just calls {@link #synchronizeFrom(Progress)} on the target - * progress, supplying itself as the parameter. - * - * @param progress A progress object to which to set up the synchronization. - * - * @see #synchronizeFrom(Progress) - */ - public void synchronizeTo(final Progress progress) { - progress.synchronizeFrom(this); - } - - /** - * Sets up the reverse synchronization of this progress object to the specified - * target. This method just calls {@link #reverseSynchronizeFrom(Progress)} on - * the target progress, supplying itself as the parameter. - * - * @param progress A progress object to which to set up the synchronization. - * - * @see #reverseSynchronizeFrom(Progress) - */ - public void reverseSynchronizeTo(final Progress progress) { - progress.reverseSynchronizeFrom(this); - } - - // listeners //////////////////////////////////////////////////////////////////// - /** - * Adds (registers) a progress listener to this progrss object. If the argument - * is null, no action will be performed. - * - *

- * In most cases a single {@link Progress} instance will have only one listener, - * so it is feasible to use the specialized constructor overlod instead of this - * method. - * - * @param listener A progress listener to add. - * - * @see ProgressListener - * @see #Progress(ProgressListener) - */ - public void addProgressListener(final ProgressListener listener) { - if (listener == null) return; - - synchronized (listeners) { - listeners.add(listener); - } - } - - /** - * Removes (unregisters) a progress listener from this progress object. If the - * argument is null or is not present in the listeners list, no action will - * be performed. - * - * @param listener A progress listener to remove. - * - * @see ProgressListener - */ - public void removeProgressListener(final ProgressListener listener) { - if (listener == null) return; - - synchronized (listeners) { - listeners.remove(listener); - } - } - - /** - * Notifies the registered listeners that one or more of the progress' - * properties has changed. - * - * @see ProgressListener - */ - protected void notifyListeners() { - final ProgressListener[] clone; - - synchronized (listeners) { - clone = listeners.toArray(new ProgressListener[listeners.size()]); - } - - for (ProgressListener listener: clone) { - listener.progressUpdated(this); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The initial (minimum) value of a progress' percentage. - */ - public static final int START = 0; - - /** - * The final (maximum) value of a progress' percentage. - */ - public static final int COMPLETE = 100; - - /** - * The error message which will be displayed when a user tries to set an invalid - * percentage. - */ - public static final String ERROR_WRONG_PERCENTAGE = - ResourceUtils.getString(Progress.class, - "P.error.percentage"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/progress/ProgressListener.java b/nbi/engine/src/org/netbeans/installer/utils/progress/ProgressListener.java deleted file mode 100644 index 428a120253b4..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/progress/ProgressListener.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.progress; - -/** - * The interface which needs to be implemented by classes which need to listen to - * a progress' state change events. - * - *

- * They will need to register themselves with the progress object by either - * constructing the progress with a specialized constructor or calling the - * {@link Progress#addProgressListener(ProgressListener)} method. - * - * @see Progress#Progress(ProgressListener) - * @see Progress#addProgressListener(ProgressListener) - * - * @author Kirill Sorokin - * - * @since 1.0 - */ -public interface ProgressListener { - /** - * This method will be called when a {@link Progress} being listened changes - * its state. - * - *

- * The actual {@link Progress} which has changed will be passed in as the only - * parameter. A progress' state is considered changed when any of its core - * properties (title, detail, percentage, - * canceled) change. - * - * @param progress The {@link Progress} whose state has changed. - */ - void progressUpdated(final Progress progress); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/LinuxNativeUtils.java b/nbi/engine/src/org/netbeans/installer/utils/system/LinuxNativeUtils.java deleted file mode 100644 index b913b69b2110..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/LinuxNativeUtils.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.Platform; - -/** - * - * @author Kirill Sorokin - */ -public class LinuxNativeUtils extends UnixNativeUtils { - public static final String LIBRARY_PREFIX_LINUX = - NATIVE_JNILIB_RESOURCE_SUFFIX + - "linux/" ; //NOI18N - - public static final String LIBRARY_I386 = - "linux.so"; //NO18N - public static final String LIBRARY_AMD64 = - "linux-amd64.so"; //NO18N - - private static final String PROC_MOUNTS_FILE = "/proc/mounts"; - - public static final String[] POSSIBLE_BROWSER_LOCATIONS_LINUX = new String[]{ - "/usr/bin/firefox", - "/usr/bin/mozilla-firefox", - "/usr/local/firefox/firefox", - "/opt/bin/firefox", - "/usr/bin/mozilla", - "/usr/local/mozilla/mozilla", - "/opt/bin/mozilla" - }; - - public static final String[] FORBIDDEN_DELETING_FILES_LINUX = {}; - - LinuxNativeUtils() { - final String arch = System.getProperty("os.arch"); - String library = arch.equals("amd64") ? - LIBRARY_AMD64 : - arch.equals("i386") || arch.equals("x86") ? - LIBRARY_I386 : null; - - if(library!=null) { - loadLibrary(LIBRARY_PREFIX_LINUX + library); - } - initializeForbiddenFiles(FORBIDDEN_DELETING_FILES_LINUX); - } - - @Override - public File getDefaultApplicationsLocation() { - File usrlocal = new File("/usr/local"); - - if (usrlocal.exists() && - usrlocal.isDirectory() && - FileUtils.canWrite(usrlocal)) { - return usrlocal; - } else { - return SystemUtils.getUserHomeDirectory(); - } - } - - @Override - public List getFileSystemRoots(String... files) throws IOException { - List roots = super.getFileSystemRoots(); - final File mounts = new File(PROC_MOUNTS_FILE); - try { - if(FileUtils.exists(mounts) && FileUtils.canRead(mounts)) { - List strings = FileUtils.readStringList(mounts); - for(int i=0;i lines = new LinkedList (); - lines.add("[InternetShortcut]"); - lines.add("URL=" + shortcut.getURL()); - lines.add("IconFile=" + shortcut.getIconPath()); - lines.add(SystemUtils.getLineSeparator()); - FileUtils.writeStringList(new File(shortcut.getPath()),lines); - } catch (IOException ex) { - throw new NativeException("Can`t create URL shortcut", ex); - } - } - @Override - public File createShortcut(Shortcut shortcut, LocationType locationType) throws NativeException { - try { - final File shortcutFile = getShortcutLocation(shortcut, locationType); - switch (locationType) { - case CURRENT_USER_DESKTOP: - case ALL_USERS_DESKTOP: - case CUSTOM: - // create a symlink for files/directories and .url for internet shortcuts - if (!shortcutFile.exists()) { - if (shortcut instanceof FileShortcut) { - createSymLink(shortcutFile, ((FileShortcut) shortcut).getTarget()); - } else if (shortcut instanceof InternetShortcut) { - createURLShortcut((InternetShortcut) shortcut); - } - } - break; - case CURRENT_USER_START_MENU: - case ALL_USERS_START_MENU: - if (shortcut instanceof FileShortcut && - convertDockProperties(true) == 0) { - //create link in the Dock - if (modifyDockLink((FileShortcut) shortcut, shortcutFile, true)) { - LogManager.log(ErrorLevel.DEBUG, - " Updating Dock"); - convertDockProperties(false); - SystemUtils.executeCommand(null, UPDATE_DOCK_COMMAND); - } - } - break; - default: - LogManager.log("... unknown shortcut type " + locationType); - return null; - } - return shortcutFile; - } catch (IOException e) { - throw new NativeException("Cannot create shortcut", e); - } - } - @Override - public void removeShortcut(Shortcut shortcut, LocationType locationType, boolean cleanupParents) throws NativeException { - try { - final File shortcutFile = getShortcutLocation(shortcut, locationType); - switch(locationType) { - case CURRENT_USER_DESKTOP: - case ALL_USERS_DESKTOP: - case CUSTOM: - // remove symlink from desktop - if(shortcutFile.exists()) { - FileUtils.deleteFile(shortcutFile,false); - } - break; - case CURRENT_USER_START_MENU : - case ALL_USERS_START_MENU : - if (shortcut instanceof FileShortcut && - convertDockProperties(true) == 0) { - //remove link from the Dock - if (modifyDockLink((FileShortcut) shortcut, shortcutFile, false)) { - LogManager.log(ErrorLevel.DEBUG, "... updating Dock"); - if (convertDockProperties(false) == 0) { - SystemUtils.executeCommand(null, UPDATE_DOCK_COMMAND); - } - } - } - break; - default: - LogManager.log("... unknown shortcut type " + locationType); - } - } catch (IOException e) { - throw new NativeException("Cannot remove shortcut", e); - } - } - - // mac os x specific //////////////////////////////////////////////////////////// - public boolean isCheetah() { - return (getOSVersion().startsWith("10.0")); - } - - public boolean isPuma() { - return (getOSVersion().startsWith("10.1")); - } - - public boolean isJaguar() { - return (getOSVersion().startsWith("10.2")); - } - - public boolean isPanther() { - return (getOSVersion().startsWith("10.3")); - } - - public boolean isTiger() { - return (getOSVersion().startsWith("10.4")); - } - - public boolean isLeopard() { - return (getOSVersion().startsWith("10.5")); - } - public boolean isSnowLeopard() { - return (getOSVersion().startsWith("10.6")); - } - - // private ////////////////////////////////////////////////////////////////////// - private String getOSVersion() { - return System.getProperty("os.version"); - } - - private File upToApp( - final File file) { - File executable = file; - - while ((executable != null) && - !executable.getPath().endsWith(APP_SUFFIX)) { - executable = executable.getParentFile(); - } - - return executable; - } - - private void modifyShortcutPath( - final FileShortcut shortcut) { - if (shortcut.canModifyPath()) { - File target = upToApp(shortcut.getTarget()); - - if (target != null) { - shortcut.setTarget(target); - } - } - } - - private boolean modifyDockLink( - final FileShortcut shortcut, - final File dockFile, - final boolean adding) { - OutputStream outputStream = null; - boolean modified = false; - - try { - if(shortcut instanceof FileShortcut) { - modifyShortcutPath(shortcut); - - final DocumentBuilderFactory documentBuilderFactory = - DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - - final DocumentBuilder documentBuilder = - documentBuilderFactory.newDocumentBuilder(); - documentBuilder.setEntityResolver(new PropertyListEntityResolver()); - LogManager.log(ErrorLevel.DEBUG, - " parsing xml file..."); - - final Document document = documentBuilder.parse(dockFile); - LogManager.log(ErrorLevel.DEBUG, - " ...complete"); - - LogManager.log(ErrorLevel.DEBUG, - " getting root element"); - final Element root = document.getDocumentElement(); - - LogManager.log(ErrorLevel.DEBUG, - " getting root/dict element"); - Element dict = XMLUtils.getChild(root, "dict"); - - LogManager.log(ErrorLevel.DEBUG, - " getting root/dict/[key=persistent-apps] element. dict = " + - dict.getNodeName()); - LogManager.log(ErrorLevel.DEBUG,"Get Keys"); - - - List keys = XMLUtils.getChildren(dict, "key"); - LogManager.log(ErrorLevel.DEBUG,"Length = " + keys.size()); - Element persistentAppsKeyNode = null; - int index = 0; - while(keys.get(index)!=null) { - if(keys.get(index).getTextContent().equals("persistent-apps")) { - persistentAppsKeyNode = keys.get(index); - break; - } - index++; - } - - if(persistentAppsKeyNode == null) { - LogManager.log(ErrorLevel.DEBUG, - " Not found.. strange.. Create new one"); - persistentAppsKeyNode = XMLUtils.appendChild(dict,"key","persistent-apps"); - } else { - LogManager.log(ErrorLevel.DEBUG, - " done. KeyNode = " + persistentAppsKeyNode.getTextContent()); - } - LogManager.log(ErrorLevel.DEBUG, - " Getting next element.. expecting it to be array element"); - Element array = keys.get(index); - Node arrayIt = array; - - index = 0 ; - int MAX_SEARCH_ELEMENTS = 20 ; - String nodeName; - while(index < MAX_SEARCH_ELEMENTS && arrayIt!=null) { - nodeName = arrayIt.getNodeName(); - if(nodeName!=null && nodeName.equals("array") && - arrayIt instanceof Element) { - break; - } - - arrayIt = arrayIt.getNextSibling(); - index++; - } - - if(index==MAX_SEARCH_ELEMENTS || arrayIt==null) { - LogManager.log(ErrorLevel.DEBUG, - " is not an array element... very strange"); - return false; - } - array = (Element) arrayIt; - - if(array==null) { - LogManager.log(ErrorLevel.DEBUG, - " null... very strange"); - return false; - } - LogManager.log(ErrorLevel.DEBUG, - " OK. Content = " + array.getNodeName()); - if(!array.getNodeName().equals("array")) { - LogManager.log(ErrorLevel.DEBUG, - " Not an array element"); - return false; - } - - - if(adding) { - LogManager.log(ErrorLevel.DEBUG, - "Adding shortcut with the following properties: "); - - LogManager.log(ErrorLevel.DEBUG, " target = " + shortcut.getTargetPath()); - LogManager.log(ErrorLevel.DEBUG, " name = " + shortcut.getName()); - - dict = XMLUtils.appendChild(array,"dict",null); - XMLUtils.appendChild(dict,"key","tile-data"); - Element dictChild = XMLUtils.appendChild(dict,"dict",null); - XMLUtils.appendChild(dictChild,"key","file-data"); - Element dictCC = XMLUtils.appendChild(dictChild,"dict",null); - XMLUtils.appendChild(dictCC,"key","_CFURLString"); - XMLUtils.appendChild(dictCC,"string",shortcut.getTargetPath()); - XMLUtils.appendChild(dictCC,"key","_CFURLStringType"); - XMLUtils.appendChild(dictCC,"integer","0"); - XMLUtils.appendChild(dictChild,"key","file-label"); - XMLUtils.appendChild(dictChild,"string",shortcut.getName()); - XMLUtils.appendChild(dictChild,"key","file-type"); - XMLUtils.appendChild(dictChild,"integer","41"); - XMLUtils.appendChild(dict,"key","tile-type"); - XMLUtils.appendChild(dict, "string","file-tile"); - LogManager.log(ErrorLevel.DEBUG, - "... adding shortcut to Dock XML finished"); - modified = true; - } else { - LogManager.log(ErrorLevel.DEBUG, - "Removing shortcut with the following properties: "); - LogManager.indent(); - LogManager.log(ErrorLevel.DEBUG, " target = " + shortcut.getTargetPath()); - LogManager.log(ErrorLevel.DEBUG, - "name = " + shortcut.getName()); - - String location = shortcut.getTargetPath(); - List dcts = new LinkedList (); - - for(Element el1: XMLUtils.getChildren(array, "dict")) { - for(Element el2: XMLUtils.getChildren(el1, "dict")) { - for(Element el3: XMLUtils.getChildren(el2, "dict")) { - dcts.addAll(XMLUtils.getChildren(el3, "string")); - } - } - } - - - index = 0; - Node dct = null; - LogManager.log(ErrorLevel.DEBUG, - "Total dict/dict/dict/string items = " + dcts.size()); - LogManager.log(ErrorLevel.DEBUG, - " location = " + location); - - File locationFile = new File(location); - - while(index < dcts.size() && dcts.get(index)!=null) { - Node item = dcts.get(index); - String content = item.getTextContent(); - LogManager.log(ErrorLevel.DEBUG, " content = " + content); - - if (content!=null && !content.equals("")) { - if (content.startsWith(FILE_LOCALHOST)) { - content = content.substring(FILE_LOCALHOST.length()); - } - - File contentFile = new File(content); - - if(locationFile.equals(contentFile)) { - dct = item; - break; - } - } - index++; - } - - if(dct!=null) { - LogManager.log(ErrorLevel.DEBUG, - "Shortcut exists in the dock.plist"); - array.removeChild(dct.getParentNode().getParentNode().getParentNode()); - modified = true; - } else { - LogManager.log(ErrorLevel.DEBUG, - "... shortcut doesn`t exist in the dock.plist"); - modified = false; - } - LogManager.unindent(); - LogManager.log(ErrorLevel.DEBUG, - "... removing shortcut from Dock XML finished"); - } - if(modified) { - LogManager.log(ErrorLevel.DEBUG, - " Saving XML... "); - XMLUtils.saveXMLDocument(document,dockFile); - LogManager.log(ErrorLevel.DEBUG, - " Done (saving xml)"); - } - } else { - LogManager.log(ErrorLevel.DEBUG, - "Adding non-file shortcuts to the Dock is not supported"); - } - } catch (ParserConfigurationException e) { - LogManager.log(ErrorLevel.WARNING,e); - return false; - } catch (XMLException e) { - LogManager.log(ErrorLevel.WARNING,e); - return false; - } catch (SAXException e) { - LogManager.log(ErrorLevel.WARNING,e); - return false; - } catch (IOException e) { - LogManager.log(ErrorLevel.WARNING,e); - return false; - } catch (NullPointerException e) { - LogManager.log(ErrorLevel.WARNING,e); - return false; - } finally { - if (outputStream!=null) { - try { - outputStream.close(); - } catch (IOException ex) { - LogManager.log(ErrorLevel.WARNING, - "Can`t close stream for Dock properties file"); - } - } - } - LogManager.log(ErrorLevel.DEBUG, - " Return " + modified + " from modifyDockLink"); - return modified; - - } - - private File getDockPropertiesFile() { - return new File(SystemUtils.getUserHomeDirectory(), - "Library/Preferences/" + DOCK_PROPERIES);//NOI18N - } - - private int convertDockProperties(boolean decode) { - File dockFile = getDockPropertiesFile(); - int returnResult = 0; - try { - if(!isCheetah() && !isPuma()) { - if((!decode && (isTiger() || isLeopard() || isSnowLeopard())) || decode) { - // decode for all except Cheetah and Puma - // code only for Tiger and Leopard - - ExecutionResults result = SystemUtils.executeCommand(null, - new String[] { PLUTILS,PLUTILS_CONVERT,(decode)? PLUTILS_CONVERT_XML : - PLUTILS_CONVERT_BINARY,dockFile.getPath()}); - returnResult = result.getErrorCode(); - } - } - } catch (IOException ex) { - LogManager.log(ErrorLevel.WARNING,ex); - returnResult = -1; - } - return returnResult; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - private class PropertyListEntityResolver implements EntityResolver { - public static final String PROPERTTY_LIST_DTD_LOCAL = - "/System/Library/DTDs/PropertyList.dtd"; //NOI18N - public static final String PROPERTTY_LIST_DTD_REMOTE = - "http://www.apple.com/DTDs/PropertyList-1.0.dtd"; //NOI18N - public static final String PROPERTTY_LIST_DTD_PUBLIC_ID = - "-//Apple Computer//DTD PLIST 1.0//EN"; //NOI18N - - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - File propDtd = new File(PROPERTTY_LIST_DTD_LOCAL); - - return ((PROPERTTY_LIST_DTD_PUBLIC_ID.equals(publicId) || - PROPERTTY_LIST_DTD_REMOTE.equals(systemId)) && - FileUtils.exists(propDtd)) ? - new InputSource(new FileInputStream(propDtd)): - null; - - } - - } - @Override - protected String [] getPossibleBrowserLocations() { - return POSSIBLE_BROWSER_LOCATIONS_MAC; - } - - public static final String[] POSSIBLE_BROWSER_LOCATIONS_MAC = new String[]{ - "/usr/bin/open" - }; - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String LIBRARY_PATH_MACOSX = - NATIVE_JNILIB_RESOURCE_SUFFIX + "macosx/macosx.dylib"; // NO18N - - public static final String APP_SUFFIX = - ".app"; // NOI18N - - private static final String DOCK_PROPERIES = - "com.apple.dock.plist"; // NOI18N - - private static final String PLUTILS = - "plutil"; // NOI18N - - private static final String PLUTILS_CONVERT = - "-convert"; // NOI18N - - private static final String PLUTILS_CONVERT_XML = - "xml1"; // NOI18N - - private static final String PLUTILS_CONVERT_BINARY = - "binary1"; // NOI18N - - private static final String[] UPDATE_DOCK_COMMAND = new String[] { - "killall", // NOI18N - "-HUP", // NOI18N - "Dock", // NOI18N - }; - - public static final String[] FORBIDDEN_DELETING_FILES_MACOSX = { - "/Applications", // NOI18N - "/Developer", // NOI18N - "/Library", // NOI18N - "/Network", // NOI18N - "/System", // NOI18N - "/Users", // NOI18N - }; -} \ No newline at end of file diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtils.java b/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtils.java deleted file mode 100644 index 9fd820f91c39..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtils.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import org.netbeans.installer.Installer; -import org.netbeans.installer.utils.EngineUtils; -import org.netbeans.installer.utils.helper.EnvironmentScope; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.system.shortcut.Shortcut; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.ApplicationDescriptor; -import org.netbeans.installer.utils.helper.FilesList; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.system.launchers.Launcher; -import org.netbeans.installer.utils.system.launchers.LauncherResource; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.cleaner.OnExitCleanerHandler; -import org.netbeans.installer.utils.system.cleaner.JavaOnExitCleanerHandler; -import org.netbeans.installer.utils.system.cleaner.SystemPropertyOnExitCleanerHandler; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.shortcut.LocationType; - -/** - * - * @author Kirill Sorokin - */ -public abstract class NativeUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - protected static boolean nativeLibraryLoaded; - private static HashSet forbiddenDeletingFiles = new HashSet(); - private static List uninstallerJVMs = new ArrayList (); - private static Platform currentPlatform; - public static final String NATIVE_RESOURCE_SUFFIX = "native/"; // NOI18N - public static final String NATIVE_JNILIB_RESOURCE_SUFFIX = - NATIVE_RESOURCE_SUFFIX + - "jnilib/"; // NOI18N - public static final String NATIVE_LAUNCHER_RESOURCE_SUFFIX = - NATIVE_RESOURCE_SUFFIX + - "launcher/"; // NOI18N - public static final String NATIVE_CLEANER_RESOURCE_SUFFIX = - NATIVE_RESOURCE_SUFFIX + - "cleaner/"; // NOI18N - private static OnExitCleanerHandler cleanerHandler; - - protected abstract Platform getPlatform(); - - public final Platform getCurrentPlatform() { - if (currentPlatform == null) { - currentPlatform = getPlatform(); - } - return currentPlatform; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - // constructor ////////////////////////////////////////////////////////////////// - protected NativeUtils() { - // does nothing - } - - // abstract ///////////////////////////////////////////////////////////////////// - public abstract boolean isSystem64Bit(); - - public abstract boolean isCurrentUserAdmin() throws NativeException; - - public abstract File getDefaultApplicationsLocation() throws NativeException; - - public abstract long getFreeSpace(File file) throws NativeException; - - public abstract boolean isPathValid(String path); - - public abstract boolean isUNCPath(String path); - - public File getRoot(final File file) { - File parent = file; - while (parent.getParentFile() != null) { - parent = parent.getParentFile(); - } - - return parent; - } - - public abstract File getShortcutLocation(Shortcut shortcut, LocationType locationType) throws NativeException; - - public abstract File createShortcut(Shortcut shortcut, LocationType locationType) throws NativeException; - - public abstract void removeShortcut(Shortcut shortcut, LocationType locationType, boolean deleteEmptyParents) throws NativeException; - - public void addUninstallerJVM(LauncherResource jvm) { - if(jvm!=null && !uninstallerJVMs.contains(jvm)) { - uninstallerJVMs.add(jvm); - } - } - protected Launcher createUninstaller(ApplicationDescriptor descriptor, boolean uninstall, Progress progress) throws IOException { - LogManager.log("creating uninstaller..."); - - final File engine = new File(descriptor.getInstallPath(), - "uninstall.jar"); - try { - EngineUtils.cacheEngine(engine, new Progress()); - - final LauncherProperties props = new LauncherProperties(); - - props.addJVM(new LauncherResource(false, SystemUtils.getCurrentJavaHome())); - for(LauncherResource jvm : uninstallerJVMs) { - props.addJVM(jvm); - } - props.addJar(new LauncherResource(true, engine)); - props.setJvmArguments(new String[]{ - "-Xmx256m", - "-Xms64m", - "-D" + Installer.LOCAL_DIRECTORY_PATH_PROPERTY + - "=" + Installer.getInstance().getLocalDirectory()}); - props.setMainClass(EngineUtils.getEngineMainClass().getName()); - - if (uninstall) { - props.setAppArguments(descriptor.getUninstallCommand()); - props.setOutput( - new File(descriptor.getInstallPath(), "uninstall"), - true); - } else { - props.setAppArguments(descriptor.getModifyCommand()); - props.setOutput( - new File(descriptor.getInstallPath(), "modify-install"), - true); - } - return SystemUtils.createLauncher(props, progress); - } finally { - FileUtils.deleteFile(engine); - } - } - - public abstract boolean openBrowser(URI uri); - - public abstract boolean isBrowseSupported(); - - public abstract FilesList addComponentToSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException; - - public abstract void removeComponentFromSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException; - - public abstract String getEnvironmentVariable(String name, EnvironmentScope scope, boolean expand) throws NativeException; - - public abstract void setEnvironmentVariable(String name, String value, EnvironmentScope scope, boolean expand) throws NativeException; - - public abstract List findIrrelevantFiles(File parent) throws IOException; - - public abstract List findExecutableFiles(File parent) throws IOException; - - public abstract void correctFilesPermissions(File parent) throws IOException; - - public abstract void setPermissions( - final File file, - final int mode, - final int change) throws IOException; - - public abstract int getPermissions( - final File file) throws IOException; - - public boolean checkFileAccess(File file, boolean isReadNotModify) throws NativeException { - return true; - } - public final void addDeleteOnExitFile(File file) { - getDeleteOnExitHandler().addDeleteOnExitFile(file); - } - - public final void removeDeleteOnExitFile(File file) { - getDeleteOnExitHandler().removeDeleteOnExitFile(file); - } - protected OnExitCleanerHandler newDeleteOnExitCleanerHandler() { - return new JavaOnExitCleanerHandler(); - } - protected OnExitCleanerHandler getDeleteOnExitHandler() { - if(cleanerHandler == null) { - if(SystemPropertyOnExitCleanerHandler.isSet()) { - cleanerHandler = new SystemPropertyOnExitCleanerHandler(); - } else { - cleanerHandler = newDeleteOnExitCleanerHandler(); - Runtime.getRuntime().addShutdownHook(cleanerHandler); - } - } - return cleanerHandler; - } - - /** - * Return roots for specified files. If it is used with no arguments, - * returns all available roots. - * But when files are not specified, on Unix systems there is - * a possibility of installer freeze because of "df -k" command - - * when unavailable nfs filesystem is mounted. - * - * @param files - files for which we want get roots - * @return List of roots - * @throws IOException - */ - public abstract List getFileSystemRoots(String... files) throws IOException; - - // protected //////////////////////////////////////////////////////////////////// - protected void loadNativeLibrary(String path) throws NativeException { - LogManager.logIndent("loading jni library"); - LogManager.log("library resource path: " + path); - try { - if (path != null) { - final File tempDir = SystemUtils.getTempDirectory(); - if(!tempDir.exists() && !tempDir.mkdirs()) { - throw new NativeException("Cannot create temporary directory " + tempDir.getAbsolutePath()); - } - File file = null; - try { - file = FileUtils.createTempFile(tempDir); - } catch (IOException e) { - throw new NativeException("Cannot create temporary file for native library at " + tempDir.getAbsolutePath(), e); - } - - InputStream input = getClass().getClassLoader().getResourceAsStream(path); - if (input == null) { - throw new NativeException("Cannot find native library at resource " + path);//NOI18N - } - try { - LogManager.log("library file path: " + file.getAbsolutePath()); - FileUtils.writeFile(file, input); - } catch (IOException e) { - file.delete(); - throw new NativeException("Cannot write native library (" + path + ") to temporary file " + file.getAbsolutePath(), e); - } finally { - try { - input.close(); - } catch (IOException e) { - //ignore - } - } - try { - System.load(file.getAbsolutePath()); - LogManager.log("... successfully loaded the library"); - nativeLibraryLoaded = true; - addDeleteOnExitFile(file); - } catch (UnsatisfiedLinkError e) { - LogManager.log("... failed loading the library", e); - final String message = e.getMessage(); - //special handling for #163022 - if (message != null && message.contains("failed to map segment from shared object")) { - throw new NativeException("Could not load library from temporary directory which is located on the filesystem mounted with \"noexec\" option:\n" + - tempDir.getAbsolutePath() + - "\n\nTry to use other temporary directory.", e); - } else { - throw new NativeException("Cannot load native library from path: " + path, e); - } - } - } - } finally { - LogManager.unindent(); - } - - } - - protected void initializeForbiddenFiles(String ... filepaths) { - for (String path : filepaths) { - if(path!=null) { - File file = new File(path); - if(file.exists() && !forbiddenDeletingFiles.contains(file)) { - forbiddenDeletingFiles.add(file); - } - } - } - } - - public boolean isDeletingAllowed(File file) { - return !(forbiddenDeletingFiles.contains(file)); - } - - public static final int FA_MODE_SET = 1; - public static final int FA_MODE_ADD = 2; - public static final int FA_MODE_REMOVE = 4; -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtilsFactory.java b/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtilsFactory.java deleted file mode 100644 index 2eb08d128cb9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/NativeUtilsFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.system; - -/** - * @author Dmitry Lipin - */ -public class NativeUtilsFactory { - - public static synchronized NativeUtils newNativeUtils() { - final String osName = System.getProperty("os.name"); - if (osName.contains("Windows")) { - return new WindowsNativeUtils(); - } else if (osName.contains("Linux")) { - return new LinuxNativeUtils(); - } else if (osName.contains("SunOS") || osName.contains("Solaris")) { - return new SolarisNativeUtils(); - } else if (osName.contains("Mac OS X") || osName.contains("Darwin")) { - return new MacOsNativeUtils(); - } else { - return new UnixNativeUtils(); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/SolarisNativeUtils.java b/nbi/engine/src/org/netbeans/installer/utils/system/SolarisNativeUtils.java deleted file mode 100644 index be28e9ba956a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/SolarisNativeUtils.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system; - -import java.io.IOException; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.Platform; -/** - * - * @author Kirill Sorokin - */ -public class SolarisNativeUtils extends UnixNativeUtils { - - public static final String LIBRARY_PATH_SOLARIS_SPARCV9 = - NATIVE_JNILIB_RESOURCE_SUFFIX + - "solaris-sparc/" + //NOI18N - "solaris-sparcv9.so"; //NOI18N - - public static final String LIBRARY_PATH_SOLARIS_X86 = - NATIVE_JNILIB_RESOURCE_SUFFIX + - "solaris-x86/" + //NOI18N - "solaris-x86.so"; // NOI18N - - public static final String LIBRARY_PATH_SOLARIS_X64 = - NATIVE_JNILIB_RESOURCE_SUFFIX + - "solaris-x86/" + //NOI18N - "solaris-amd64.so"; // NOI18N - - public static final String[] POSSIBLE_BROWSER_LOCATIONS_SOLARIS = new String[]{ - "/usr/sfw/lib/firefox/firefox", - "/opt/csw/bin/firefox", - "/usr/sfw/lib/mozilla/mozilla", - "/opt/csw/bin/mozilla", - "/usr/dt/bin/sun_netscape", - "/usr/bin/firefox", - "/usr/bin/mozilla-firefox", - "/usr/local/firefox/firefox", - "/opt/bin/firefox", - "/usr/bin/mozilla", - "/usr/local/mozilla/mozilla", - "/opt/bin/mozilla" - }; - - private static final String[] FORBIDDEN_DELETING_FILES_SOLARIS = {}; - - SolarisNativeUtils() { - String library = null; - - if (System.getProperty("os.arch").contains("sparc")) { - library = LIBRARY_PATH_SOLARIS_SPARCV9; - } else { - library = SystemUtils.isCurrentJava64Bit() ? - LIBRARY_PATH_SOLARIS_X64 : - LIBRARY_PATH_SOLARIS_X86; - } - - loadLibrary(library); - initializeForbiddenFiles(FORBIDDEN_DELETING_FILES_SOLARIS); - } - @Override - protected Platform getPlatform() { - final String osArch = System.getProperty("os.arch"); - return osArch.contains("sparc") ? - Platform.SOLARIS_SPARC : - Platform.SOLARIS_X86; - } - @Override - protected String [] getPossibleBrowserLocations() { - return POSSIBLE_BROWSER_LOCATIONS_SOLARIS; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/UnixNativeUtils.java b/nbi/engine/src/org/netbeans/installer/utils/system/UnixNativeUtils.java deleted file mode 100644 index d72f9e5552de..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/UnixNativeUtils.java +++ /dev/null @@ -1,1430 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.utils.system; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.EnvironmentScope; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.helper.FilesList; -import org.netbeans.installer.utils.system.shortcut.FileShortcut; -import org.netbeans.installer.utils.system.shortcut.InternetShortcut; -import org.netbeans.installer.utils.system.shortcut.Shortcut; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.ApplicationDescriptor; -import org.netbeans.installer.utils.helper.Pair; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.system.cleaner.ProcessOnExitCleanerHandler; -import org.netbeans.installer.utils.system.launchers.Launcher; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.cleaner.OnExitCleanerHandler; -import org.netbeans.installer.utils.system.shortcut.LocationType; -import org.netbeans.installer.utils.system.unix.shell.BourneShell; -import org.netbeans.installer.utils.system.unix.shell.CShell; -import org.netbeans.installer.utils.system.unix.shell.KornShell; -import org.netbeans.installer.utils.system.unix.shell.Shell; -import org.netbeans.installer.utils.system.unix.shell.TCShell; - -/** - * - * @author Dmitry Lipin - */ -public class UnixNativeUtils extends NativeUtils { - - private boolean isUserAdminSet; - private boolean isUserAdmin; - private boolean checkQuota = true; - private File quotaExecutable = null; - private File browserExecutable = null; - private boolean browserExecutableSet = false; - private Boolean isSystem64Bit = null; - - private static final String[] FORBIDDEN_DELETING_FILES_UNIX = { - System.getProperty("user.home"), - System.getProperty("java.home"), - "/", - "/bin", - "/boot", - "/dev", - "/etc", - "/home", - "/lib", - "/mnt", - "/opt", - "/sbin", - "/share", - "/usr", - "/usr/bin", - "/usr/include", - "/usr/lib", - "/usr/man", - "/usr/sbin", - "/var", - }; - - private static final String CLEANER_RESOURCE = - NATIVE_CLEANER_RESOURCE_SUFFIX + "unix/cleaner.sh"; // NOI18N - - private static final String CLEANER_FILENAME = - "nbi-cleaner.sh"; // NOI18N - - public static final String XDG_DATA_HOME_ENV_VARIABLE = - "XDG_DATA_HOME"; // NOI18N - - public static final String XDG_DATA_DIRS_ENV_VARIABLE = - "XDG_DATA_DIRS"; // NOI18N - - public static final String XDG_DESKTOP_DIR_ENV_VARIABLE = - "XDG_DESKTOP_DIR"; - public static final String XDG_USERDIRS_DIRS = - ".config/user-dirs.dirs";//NOI18N - public static final String XDG_USERDIRS_CONF = - ".config/user-dirs.conf";//NOI18N - public static final String XDG_USERDIRS_GLOBAL_CONF = - "/etc/xdg/user-dirs.conf";//NOI18N - public static final String DESKTOP_EXT = - ".desktop";//NOI18N - - public static final String XDG_CONFIG_HOME_ENV_VARIABLE = - "XDG_CONFIG_HOME";//NOI18N - public static final String XDG_CONFIG_HOME_DEFAULT = - ".config";//NOI18N - public static final String XDG_APPLICATION_MENU_FILE = - "menus/applications.menu";//NOI18N - - public static final String DEFAULT_XDG_DATA_HOME = - ".local/share"; // NOI18N - - public static final String DEFAULT_XDG_DATA_DIRS = - "/usr/share"; // NOI18N - - public UnixNativeUtils() { - initializeForbiddenFiles(); - } - - - protected void loadLibrary(String path) { - try { - loadNativeLibrary(path); - } catch (NativeException e) { - //ok, not loaded, we`ll use Java`s implementation - LogManager.log("Could not load native library due to some reasons, " + //NOI18N - "falling back to the Java implementation", e); //NOI18N - } - } - - @Override - protected Platform getPlatform() { - final String osName = System.getProperty("os.name"); - - if (osName.equals("FreeBSD")) { - return getPlatformFreeBSD(); - } else if (osName.equals("OpenBSD")) { - return getPlatformOpenBSD(); - } else if (osName.endsWith("BSD")) { - return getPlatformBSD(); - } else if (osName.equals("AIX")) { - return getPlatformAIX(); - } else if (osName.toLowerCase(Locale.ENGLISH).startsWith("hp-ux")) { - return getPlatformHPUX(); - } else { - return Platform.UNIX; - } - } - - private Platform getPlatformOpenBSD() { - final String osArch = System.getProperty("os.arch"); - if (osArch.contains("ppc") || osArch.contains("PowerPC")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.OPENBSD_PPC64 : Platform.OPENBSD_PPC; - } else if (osArch.contains("sparc")) { - return Platform.OPENBSD_SPARC; - } else if (osArch.matches("i[3-6]86|x86|amd64|x86_64")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.OPENBSD_X64 : Platform.OPENBSD_X86; - } else { - return Platform.OPENBSD; - } - } - private Platform getPlatformFreeBSD() { - final String osArch = System.getProperty("os.arch"); - if (osArch.contains("ppc") || osArch.contains("PowerPC")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.FREEBSD_PPC64 : Platform.FREEBSD_PPC; - } else if (osArch.contains("sparc")) { - return Platform.FREEBSD_SPARC; - } else if (osArch.matches("i[3-6]86|x86|amd64|x86_64")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.FREEBSD_X64 : Platform.FREEBSD_X86; - } else { - return Platform.FREEBSD; - } - } - private Platform getPlatformBSD() { - final String osArch = System.getProperty("os.arch"); - if (osArch.contains("ppc") || osArch.contains("PowerPC")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.BSD_PPC64 : Platform.BSD_PPC; - } else if (osArch.contains("sparc")) { - return Platform.BSD_SPARC; - } else if (osArch.matches("i[3-6]86|x86|amd64|x86_64")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.BSD_X64 : Platform.BSD_X86; - } else { - return Platform.BSD; - } - } - private Platform getPlatformAIX() { - final String osArch = System.getProperty("os.arch"); - if (osArch.contains("ppc") || osArch.contains("PowerPC")) { - return SystemUtils.isCurrentJava64Bit() ? Platform.AIX_PPC64 : Platform.AIX_PPC; - } else { - return Platform.AIX; - } - } - - private Platform getPlatformHPUX() { - final String osArch = System.getProperty("os.arch"); - if (osArch.toLowerCase(Locale.ENGLISH).replace("-", "_").startsWith("pa_risc")) { - return osArch.startsWith("PA_RISC2.0") ? Platform.HPUX_PA_RISC20 : Platform.HPUX_PA_RISC; - } else if (osArch.toLowerCase(Locale.ENGLISH).startsWith("ia64")) { - return Platform.HPUX_IA64; - } else { - return Platform.HPUX; - } - } - - @Override - public boolean isSystem64Bit() { - if (isSystem64Bit == null) { - isSystem64Bit = false; - - try { - Process p = Runtime.getRuntime().exec("uname -m"); - - // Try if command exited. Wait max 1s. - for (int i = 0; i < 5; i++) { - try { - p.exitValue(); - break; - } catch (IllegalThreadStateException ex) { - // Exception should be ignored - do nothing. - } - - try { - Thread.sleep(200); - } catch (InterruptedException ex) { - // Exception should be ignored - do nothing. - } - } - - BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); - if (br.ready()) { - String line = br.readLine(); - isSystem64Bit = line.endsWith("64"); - } - } catch (IOException ex) { - LogManager.log(ErrorLevel.WARNING, ex); - } - } - - return isSystem64Bit; - } - - @Override - public boolean isCurrentUserAdmin() throws NativeException{ - if(isUserAdminSet) { - return isUserAdmin; - } - boolean result = isCurrentUserAdminNative(); - isUserAdmin = result; - isUserAdminSet = true; - return result; - } - - @Override - protected OnExitCleanerHandler newDeleteOnExitCleanerHandler() { - return new UnixProcessOnExitCleanerHandler(CLEANER_FILENAME); - } - - public void updateApplicationsMenu() { - try { - SystemUtils.executeCommand(null,new String [] { - "pkill", "-u", SystemUtils.getUserName(), "panel"}); - } catch (IOException ex) { - LogManager.log(ErrorLevel.WARNING,ex); - } - } - - public File getShortcutLocation( - final Shortcut shortcut, - final LocationType locationType) throws NativeException { - LogManager.logIndent( - "devising the shortcut location by type: " + locationType); // NOI18N - - if(shortcut.getPath()!=null) { - return new File(shortcut.getPath()); - } - final File shortcutFile; - - switch (locationType) { - case CURRENT_USER_DESKTOP: - case ALL_USERS_DESKTOP: - final File desktopLocation = getDesktopFolder(); - LogManager.log("... desktop folder : " + desktopLocation); - shortcutFile = new File(desktopLocation, getShortcutFileName(shortcut)); - break; - case CURRENT_USER_START_MENU: - final File currentUserAppFolder = - getApplicationsLocation( - getCurrentUserLocation()); - LogManager.log("... current user app folder : " + currentUserAppFolder); - shortcutFile = new File(currentUserAppFolder, - getShortcutFileName(shortcut)); - break; - case ALL_USERS_START_MENU: - final File allUsersAppFolder = - getApplicationsLocation( - getAllUsersLocation()); - LogManager.log("... all users app folder : " + allUsersAppFolder); - shortcutFile = new File(allUsersAppFolder, - getShortcutFileName(shortcut)); - break; - case CUSTOM: - final String folder = shortcut.getRelativePath(); - - LogManager.log("... custom folder : " + folder); - shortcutFile = new File(folder, - getShortcutFileName(shortcut)); - break; - default: - shortcutFile = null; - - } - if(shortcutFile!=null) { - shortcut.setPath(shortcutFile.getAbsolutePath()); - } - LogManager.logUnindent( - "shortcut file: " + shortcutFile); // NOI18N - - return shortcutFile; - } - - private String getShortcutFileName(Shortcut shortcut) { - String fileName = shortcut.getFileName(); - if (fileName == null) { - if (shortcut instanceof FileShortcut) { - final File target = ((FileShortcut) shortcut).getTarget(); - - fileName = target.getName(); - if(!target.isDirectory()) { - fileName += DESKTOP_EXT; - } - } else if(shortcut instanceof InternetShortcut) { - fileName = ((InternetShortcut) shortcut).getURL().getFile() + - DESKTOP_EXT; - } - } - return fileName; - } - - private File getApplicationsLocation(File location) { - return new File(location, "applications"); - } - - private File getAllUsersLocation() { - final String XDG_DATA_DIRS = System.getenv(XDG_DATA_DIRS_ENV_VARIABLE); - final File allUsersLocation; - if (XDG_DATA_DIRS == null) { - allUsersLocation = new File(DEFAULT_XDG_DATA_DIRS); - } else { - // Workaround for Issue 131194 : - // Cannot install netbeans using xfce4 session (incorrect XDG_DATA_DIRS set) - // http://www.netbeans.org/issues/show_bug.cgi?id=131194 - String firstPath = XDG_DATA_DIRS.split(SystemUtils.getPathSeparator())[0].trim(); - if(firstPath.contains(File.separator) && !firstPath.startsWith(File.separator)) { - firstPath = File.separator + firstPath; - } - allUsersLocation = new File(firstPath); - } - - LogManager.log(XDG_DATA_DIRS_ENV_VARIABLE + " = " + allUsersLocation); // NOI18N - - return allUsersLocation; - } - - private File getCurrentUserLocation() { - final File currentUserLocation; - final String XDG_DATA_HOME = System.getenv(XDG_DATA_HOME_ENV_VARIABLE); - - if (XDG_DATA_HOME == null) { - currentUserLocation = new File( - SystemUtils.getUserHomeDirectory(), - DEFAULT_XDG_DATA_HOME); - } else { - currentUserLocation = new File(XDG_DATA_HOME); - } - - LogManager.log(XDG_DATA_DIRS_ENV_VARIABLE + " = " + currentUserLocation); // NOI18N - - return currentUserLocation; - } - - private File getDesktopFolder() { - // TODO - // If using XDG, desktop folder can be obtained simpler using '/usr/bin/xdg-user-dir DESKTOP' command - // See also http://www.netbeans.org/issues/show_bug.cgi?id=144646 - final String desktopDir = System.getenv(XDG_DESKTOP_DIR_ENV_VARIABLE); - final File globalConfigFile = new File(XDG_USERDIRS_GLOBAL_CONF); - final File userHome = SystemUtils.getUserHomeDirectory(); - final File userDirsFile = new File(userHome, XDG_USERDIRS_DIRS); - final File userConfigFile = new File(userHome, XDG_USERDIRS_CONF); - LogManager.log("... getting desktop folder"); - if (desktopDir != null && !desktopDir.equals("")) { - LogManager.log(XDG_DESKTOP_DIR_ENV_VARIABLE + " = " + desktopDir); - File f = new File(desktopDir); - if (f.exists()) { - LogManager.log("... desktop dir : " + f); - return f; - } else { - LogManager.log("... " + XDG_DESKTOP_DIR_ENV_VARIABLE + " is defined but does not exist:" + desktopDir); - } - } else if (System.getenv("XDG_SESSION_COOKIE") == null && System.getenv(XDG_DATA_DIRS_ENV_VARIABLE) == null) { - LogManager.log("... neither XDG_SESSION_COOKIE nor " + XDG_DATA_DIRS_ENV_VARIABLE + " environment variable is defined"); - } else if (!FileUtils.exists(globalConfigFile)) { - LogManager.log("... global XDG config file does not exist"); - } else if (!FileUtils.exists(userDirsFile)) { - LogManager.log("... user XDG config file does not exist"); - } else if (!FileUtils.canRead(userDirsFile)) { - LogManager.log("... cannot read user XDG config file"); - } else { - try { - boolean useXdgDirs = false; - for (File configFile : new File[]{userConfigFile, globalConfigFile}) { - if (!FileUtils.exists(configFile)) { - continue; - } - for (String s : FileUtils.readStringList(configFile)) { - final Matcher matcher = Pattern.compile("enabled=(.*)").matcher(s); - if (matcher.find()) { - if (!Boolean.parseBoolean(matcher.group(1).toLowerCase(Locale.ENGLISH))) { - LogManager.log("... XDG dirs are disabled"); - useXdgDirs = false; - break; - } else { - LogManager.log("... XDG dirs are enabled"); - useXdgDirs = true; - } - } - } - } - - if (useXdgDirs) { - String encoding = StringUtils.EMPTY_STRING;// by default - for (File configFile : new File[]{userConfigFile, globalConfigFile}) { - if (!FileUtils.exists(configFile)) { - continue; - } - for (String s : FileUtils.readStringList(configFile)) { - final Matcher matcher = Pattern.compile("filename_encoding=(.*)").matcher(s); - if (matcher.find()) { - encoding = matcher.group(1); - if (encoding.equals("locale")) { - // http://src.opensolaris.org/source/xref/jds/spec-files/trunk/SUNWxdg-user-dirs.spec - encoding = null; - } - break; - } - } - if (encoding == null || !encoding.equals(StringUtils.EMPTY_STRING)) { - break; - } else { - encoding = StringUtils.ENCODING_UTF8; - } - } - LogManager.log("... using encoding for config file reading : " + encoding ); - List content = (encoding == null) ? FileUtils.readStringList(userDirsFile) : FileUtils.readStringList(userDirsFile, encoding); - - for (String s : content) { - LogManager.log("...... evaluating string : " + s); - Matcher matcher = Pattern.compile("^" + XDG_DESKTOP_DIR_ENV_VARIABLE + "=\"(.*)\"").matcher(s); - if (matcher.find()) { - LogManager.log("...... matches expected pattern"); - final String value = matcher.group(1).replace("$HOME", userHome.getAbsolutePath()); - File f = new File(value); - if (FileUtils.exists(f)) { - return f; - } else { - LogManager.log("... custom desktop directory defined but does not exist: " + f); - LogManager.log("... probably wrong encoding used, fallback to system utils"); - throw new IOException("File " + f + " is defined as desktop folder but does not exist"); - } - } - } - } - } catch (Exception e) { - LogManager.log(e); - //fallback - try { - final File bin = new File("/usr/bin/xdg-user-dir"); - if (FileUtils.exists(bin)) { - String stdout = SystemUtils.executeCommand(bin.getAbsolutePath(), "DESKTOP").getStdOut(); - if (stdout.length() > 0) { - File dsk = new File(stdout); - if (FileUtils.exists(dsk)) { - return dsk; - } else { - LogManager.log("... custom desktop directory defined (system util) but does not exist: " + dsk); - LogManager.log("... probably wrong encoding, fallback to default"); - } - } - } - } catch (Exception ex) { - LogManager.log(ex); - } - } - } - return new File(userHome, "Desktop"); - } - - private void addLocalizedMapEntry(List list, String entryName, Map entryMap) { - if (!entryMap.isEmpty()) { - String name = entryMap.get(new Locale(StringUtils.EMPTY_STRING)); - if(name==null) { - name = entryMap.get(Locale.getDefault()); - } - list.add(entryName + "=" + name); - - for (Map.Entry entry : entryMap.entrySet()) { - if (!name.equals(entry.getValue())) { - list.add(entryName + "[" + entry.getKey() + "]=" + StringUtils.getLocalizedString(entryMap, entry.getKey())); - } - } - } - } - - private List getDesktopEntry(FileShortcut shortcut) { - final List list = new ArrayList (); - - list.add("[Desktop Entry]"); - list.add("Encoding=UTF-8"); - addLocalizedMapEntry(list, "Name", shortcut.getNames()); - addLocalizedMapEntry(list, "Comment", shortcut.getDescriptions()); - list.add("Exec=/bin/sh \"" + shortcut.getTarget() + "\"" + - ((shortcut.getArguments()!=null && shortcut.getArguments().size()!=0) ? - StringUtils.SPACE + shortcut.getArgumentsString() : StringUtils.EMPTY_STRING) - ); - - if(shortcut.getIcon()!=null) { - list.add("Icon=" + shortcut.getIconPath()); - } - if(shortcut.getCategories().length != 0) { - list.add("Categories=" + - StringUtils.asString(shortcut.getCategories(),";")); - } - - list.add("Version=1.0"); - list.add("Type=Application"); - list.add("Terminal=0"); - Properties props = shortcut.getAdditionalProperties(); - props.forEach((k, v) -> list.add(k.toString() + "=" + v)); - list.add(SystemUtils.getLineSeparator()); - return list; - } - - protected List getDesktopEntry(InternetShortcut shortcut) { - final List list = new ArrayList (); - list.add("[Desktop Entry]"); - list.add("Encoding=UTF-8"); - addLocalizedMapEntry(list, "Name", shortcut.getNames()); - addLocalizedMapEntry(list, "Comment", shortcut.getDescriptions()); - - list.add("URL=" + shortcut.getURL()); - if(shortcut.getIcon()!=null) { - list.add("Icon=" + shortcut.getIconPath()); - } - if(shortcut.getCategories().length != 0) { - list.add("Categories=" + - StringUtils.asString(shortcut.getCategories(),";")); - } - list.add("Version=1.0"); - list.add("Type=Link"); - Properties props = shortcut.getAdditionalProperties(); - props.forEach((k, v) -> list.add(k.toString() + "=" + v)); - list.add(SystemUtils.getLineSeparator()); - return list; - } - - private void addExecutablePermissions(File file) throws IOException { - // add x permission bit to r bits - int permissions = SystemUtils.getPermissions(file); - int newPermissions = (permissions + - ((permissions & FileAccessMode.RU) != 0 && (permissions & FileAccessMode.EU)==0 ? FileAccessMode.EU : 0) + - ((permissions & FileAccessMode.RG) != 0 && (permissions & FileAccessMode.EG)==0 ? FileAccessMode.EG : 0) + - ((permissions & FileAccessMode.RO) != 0 && (permissions & FileAccessMode.EO)==0 ? FileAccessMode.EO : 0)); - SystemUtils.setPermissions(file, newPermissions, FA_MODE_SET); - } - - public File createShortcut(Shortcut shortcut, LocationType locationType) throws NativeException { - final File file = getShortcutLocation(shortcut, locationType); - try { - if(shortcut instanceof FileShortcut) { - File target = ((FileShortcut)shortcut).getTarget(); - if(target.isDirectory()) { - createSymLink(file, target); - } else { - FileUtils.writeStringList(file, - getDesktopEntry((FileShortcut)shortcut)); - addExecutablePermissions(file); - postShortcutCreate(shortcut, locationType); - } - } else if(shortcut instanceof InternetShortcut) { - FileUtils.writeStringList(file, - getDesktopEntry((InternetShortcut)shortcut)); - addExecutablePermissions(file); - postShortcutCreate(shortcut, locationType); - } - } catch (IOException e) { - throw new NativeException("Cannot create shortcut", e); - } - - return file; - } - - private void postShortcutCreate(Shortcut shortcut, LocationType locationType) { - if(locationType.equals(LocationType.CURRENT_USER_START_MENU)) { - // #165320 - final String XDG_CONFIG_HOME = System.getenv(XDG_CONFIG_HOME_ENV_VARIABLE); - final File configHome = XDG_CONFIG_HOME != null ? - new File(XDG_CONFIG_HOME) : - new File (SystemUtils.getUserHomeDirectory(), XDG_CONFIG_HOME_DEFAULT); - - final File appsMenu = new File(configHome, XDG_APPLICATION_MENU_FILE); - if(!FileUtils.exists(appsMenu)) { - try { - FileUtils.mkdirs(appsMenu.getParentFile()); - boolean created = appsMenu.createNewFile(); - if(created) { - SystemUtils.sleep(50); - FileUtils.deleteFile(appsMenu); - } - } catch (IOException e) { - LogManager.log(e); - } - } - } - } - - public void removeShortcut(Shortcut shortcut, LocationType locationType, boolean cleanupParents) throws NativeException { - try { - File shortcutFile = getShortcutLocation(shortcut, locationType); - - FileUtils.deleteFile(shortcutFile); - - if(cleanupParents && - (locationType == LocationType.ALL_USERS_START_MENU || - locationType == LocationType.CURRENT_USER_START_MENU)) { - FileUtils.deleteEmptyParents(shortcutFile); - } - } catch (IOException e) { - throw new NativeException("Cannot remove shortcut", e); - } - } - - @Override - public boolean isBrowseSupported() { - initBrowser(); - return browserExecutable!=null; - } - - public boolean openBrowser(URI uri) { - initBrowser(); - if (browserExecutable != null) { - LogManager.log("... using browser: " + browserExecutable); - try { - Runtime.getRuntime().exec(new String[]{browserExecutable.getAbsolutePath(), uri.toString()}); - return true; - } catch (IOException e) { - LogManager.log(e); - } - } - return false; - } - - protected String[] getPossibleBrowserLocations() { - return new String [] {}; - } - - private void initBrowser() { - if(browserExecutableSet) return; - final String[] possibleBrowsers = getPossibleBrowserLocations(); - for (String s : possibleBrowsers) { - File f = new File(s); - if (f.exists()) { - browserExecutable = f; - break; - } - } - browserExecutableSet = true; - } - - public List findExecutableFiles(File parent) throws IOException { - List files = new ArrayList(); - - if (parent.exists()) { - if(parent.isDirectory()) { - File [] children = parent.listFiles(); - for(File child : children) { - files.addAll(findExecutableFiles(child)); - } - } else { - // name based analysis - File child = parent; - String name = child.getName(); - String [] scriptExtensions = { ".sh", ".pl", ".py"}; //shell, perl, python - for(String ext : scriptExtensions) { - if (name.endsWith(ext)) { - files.add(child); - return files; - } - } - // contents based analysis - String line = FileUtils.readFirstLine(child); - if (line != null) { - if (line.startsWith("#!")) { // a script of some sort - files.add(child); - return files; - } - } - // is it an ELF file? - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(child)); - byte[] buf = new byte[4]; - bis.read(buf); - bis.close(); - if (Arrays.equals(buf, ELF_BYTES)){ - files.add(child); - return files; - } - } - } - return files; - } - - public List findIrrelevantFiles(File parent) throws IOException { - List files = new ArrayList(); - - if (parent.exists()) { - if(parent.isDirectory()) { - File [] children = parent.listFiles(); - for(File child : children) { - files.addAll(findIrrelevantFiles(child)); - } - } else { - // contents based analysis - none at this point - - // name based analysis - File child = parent; - String name = child.getName(); - String [] windowsExtensions = { - ".bat", ".cmd", ".dll", ".exe", ".com", - ".vbs", ".vbe", ".wsf", ".wsh"} ; - for(String ext : windowsExtensions) { - if(name.endsWith(ext)) { - files.add(child); - break; - } - } - } - } - return files; - } - - public void chmod(File file, String mode) throws IOException { - chmod(Arrays.asList(file), mode); - } - - public void chmod(File file, int mode) throws IOException { - chmod(file, Integer.toString(mode,8)); - } - - public void chmod(List files, String mode) throws IOException { - for(File file : files) { - File directory = file.getParentFile(); - String name = file.getName(); - - SystemUtils.executeCommand(directory, "chmod", mode, name); - } - } - - public void setPermissions(File file, int mode, int change) throws IOException { - LogManager.log("setting permissions " + Integer.toString(mode, 8) + " on " + file); - - setPermissionsNative(file.getAbsolutePath(), mode, change); - } - - public int getPermissions(File file) throws IOException { - return getPermissionsNative(file.getAbsolutePath()); - } - - public void removeIrrelevantFiles(File parent) throws IOException { - FileUtils.deleteFiles(findIrrelevantFiles(parent)); - } - - public void correctFilesPermissions(File parent) throws IOException { - chmod(findExecutableFiles(parent), "ugo+x"); - } - - public long getFreeSpace(File file) { - if ((file == null) || file.getPath().equals("")) { - return 0; - } else { - long freeSpace = getFreeSpaceNative(file.getPath()); - if (checkQuota) { - // #123587 Disk space check should take into account user quota - try { - LogManager.indent(); - long freeSpaceQuota = getFreeSpaceUsingQuota(file); - if(freeSpaceQuota!=-1L) { - LogManager.log("... free space (due to the quote) is " + freeSpaceQuota + ", physical is : " + freeSpace); - freeSpace = freeSpaceQuota; - } - } catch (IOException e) { - LogManager.log("... quota check is disabled"); - checkQuota = false; - } finally { - LogManager.unindent(); - } - } - return freeSpace; - } - } - - private long getFreeSpaceUsingQuota(File file) throws IOException { - String path = file.getAbsolutePath(); - try { - path = file.getCanonicalPath(); - } catch (IOException e) { - LogManager.log(e); - } - - LogManager.log("Checking free space with quota in " + path); - try { - setEnvironmentVariable("LANG", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_COLLATE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_CTYPE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_MESSAGES", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_MONETARY", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_NUMERIC", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable("LC_TIME", "C", EnvironmentScope.PROCESS, false); - } catch (NativeException e) { - LogManager.log(e); - } - if (quotaExecutable == null) { - for (String q : QUOTA_LOCATIONS) { - final File f = new File(q); - if (FileUtils.exists(f)) { - quotaExecutable = f; - break; - } - } - if (quotaExecutable == null) { - LogManager.log("... no quota executable found"); - throw new IOException(); - } - } - final List stdoutList = new ArrayList(); - - Thread quotaThread = null; - try { - quotaThread = new Thread() { - @Override - public void run() { - try { - LogManager.log("... running command : " + quotaExecutable.getPath() + " -v"); - Process p = new ProcessBuilder(quotaExecutable.getPath(), "-v").start(); - final InputStream is = p.getInputStream(); - final InputStream err = p.getErrorStream(); - p.waitFor(); - final String output = StringUtils.readStream(is); - final String error = StringUtils.readStream(err); - LogManager.log("... stdout:"); - LogManager.log(output); - LogManager.log("... stderr:"); - LogManager.log(error); - LogManager.log("... return : " + p.exitValue()); - stdoutList.add(output); - is.close(); - err.close(); - } catch (IOException e) { - LogManager.log("... error occured when running quota executable", e); - } catch (InterruptedException e) { - LogManager.log("... interrupted"); - } - } - }; - - quotaThread.start(); - quotaThread.join(QUOTA_TIMEOUT_MILLIS); - if (quotaThread.isAlive()) { - LogManager.log("... quota command is hanging more than 5 seconds so killing it"); - quotaThread.interrupt(); - LogManager.log("... killed"); - } - } catch (InterruptedException ie) { - LogManager.log("... interrupted", ie); - quotaThread.interrupt(); - } - if(stdoutList.size()==0) { - LogManager.log("... quota produced no stdout for analysis"); - throw new IOException(); - } - - final String stdout = stdoutList.get(0); - final String[] lines = StringUtils.splitByLines(stdout); - if (lines.length <= 2) { - LogManager.log("... no quota set for the user (number of lines in output less that 3)"); - throw new IOException(); - } - // Usual format is the following - // Disk quotas for (): - // Filesystem usage quota limit timeleft files quota limit timeleft - // /home/ 943880 0 1577704 18992 0 0 - // /home/ 943880 0 1577704 1 18992 0 0 1 - List> pathSpace = new ArrayList>(); - - try { - for (int i = 2; i < lines.length; i++) { - String s = lines[i].trim(); - if (s.startsWith(File.separator) && s.indexOf(StringUtils.SPACE) != -1) { - String quotedPath = s.substring(0, s.indexOf(StringUtils.SPACE)); - String[] numbers = s.substring(s.indexOf(StringUtils.SPACE) + 1). - trim().split("[ |\t]+"); - if (numbers.length < 6) { - LogManager.log("...cannot parse the quota numbers [" + numbers.length + "]"); - throw new IOException(); - } - - final long limit = Long.parseLong(numbers[2]); - final long usage = Long.parseLong(numbers[0]); - final long freespace = (limit - usage) * 1024; - - if (limit > 0 && freespace >= 0) { - pathSpace.add(new Pair<>(quotedPath, freespace)); - } - } - } - if (pathSpace.size() == 0) { - LogManager.log("... no quota set for the user (no paths in quota output)"); - throw new IOException(); - } - String longestPath = StringUtils.EMPTY_STRING; - long freespace = -1L; - for (Pair p : pathSpace) { - final String s = p.getFirst(); - if (s.length() > longestPath.length() && path.startsWith(s)) { - longestPath = s; - freespace = p.getSecond(); - } - } - return freespace; - } catch (NumberFormatException e) { - LogManager.log("...cannot parse the quota numbers", e); - throw new IOException(); - } catch (PatternSyntaxException e) { - LogManager.log("...cannot parse the quota numbers", e); - throw new IOException(); - } - } - - public boolean isUNCPath(String path) { - // for Unix UNC is smth like servername:/folder... - return path.matches("^.+:/.+"); - } - - // other ... ////////////////////////// - - public String getEnvironmentVariable(String name, EnvironmentScope scope, boolean flag) { - return System.getenv(name); - } - - public void setEnvironmentVariable(String name, String value, EnvironmentScope scope, boolean flag) throws NativeException { - if (EnvironmentScope.PROCESS == scope) { - SystemUtils.getEnvironment().put(name, value); - } else { - try { - getCurrentShell().setVar(name, value, scope); - } catch (IOException e) { - throw new NativeException("Cannot set the environment variable value", e); - } - } - } - - public Shell getCurrentShell() { - LogManager.log(ErrorLevel.DEBUG, - "Getting current shell.."); - LogManager.indent(); - Shell [] avaliableShells = { - new BourneShell(), - new CShell() , - new TCShell(), - new KornShell() - }; - String shell = System.getenv("SHELL"); - Shell result = null; - if(shell == null) { - shell = System.getenv("shell"); - } - LogManager.log(ErrorLevel.DEBUG, - "... shell env variable = " + shell); - - if(shell != null) { - if(shell.lastIndexOf(File.separator)!=-1) { - shell = shell.substring(shell.lastIndexOf(File.separator) + 1); - } - LogManager.log(ErrorLevel.DEBUG, - "... searching for the shell with name [" + shell + "] " + - "among available shells names"); - for(Shell sh : avaliableShells) { - if(sh.isCurrentShell(shell)) { - result = sh; - LogManager.log(ErrorLevel.DEBUG, - "... detected shell: " + - sh.getClass().getSimpleName()); - break; - } - } - - } - if(result == null) { - LogManager.log(ErrorLevel.DEBUG, - "... no shell found"); - } - LogManager.unindent(); - LogManager.log(ErrorLevel.DEBUG, - "... finished detecting shell"); - return result; - } - - public File getDefaultApplicationsLocation() { - File opt = new File("/opt"); - - if (opt.exists() && opt.isDirectory() && FileUtils.canWrite(opt)) { - return opt; - } else { - return SystemUtils.getUserHomeDirectory(); - } - } - - public boolean isPathValid(String path) { - return true; - } - - public FilesList addComponentToSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException { - final FilesList list = new FilesList(); - - if (descriptor.getModifyCommand() != null) { - try { - final Launcher launcher = createUninstaller(descriptor, false, new Progress()); - correctFilesPermissions(launcher.getOutputFile()); - list.add(launcher.getOutputFile()); - } catch (IOException e) { - throw new NativeException("Can't create uninstaller", e); - } - } - - if (descriptor.getUninstallCommand() != null) { - try { - final Launcher launcher = createUninstaller(descriptor, true, new Progress()); - correctFilesPermissions(launcher.getOutputFile()); - list.add(launcher.getOutputFile()); - } catch (IOException e) { - throw new NativeException("Can't create uninstaller", e); - } - } - - return list; - } - - public void removeComponentFromSystemInstallManager(ApplicationDescriptor descriptor) { - // does nothing - no support for unix package managers yet - } - - public FilesList createSymLink(File source, File target) throws IOException { - return createSymLink(source, target, true); - } - - public FilesList createSymLink(File source, File target, boolean useRelativePath) throws IOException { - FilesList list = new FilesList(); - - list.add(FileUtils.mkdirs(source.getParentFile())); - list.add(source); - - String relativePath = null; - if (useRelativePath) { - relativePath = FileUtils.getRelativePath(source, target); - } - - SystemUtils.executeCommand( - "ln", - "-s", - relativePath == null ? target.getAbsolutePath() : relativePath, - source.getAbsolutePath()); - - return list; - } - - private String[] getDfCommand(String... args) { - List command = new ArrayList (); - command.add("df");//NOI18N - command.add(getCurrentPlatform().isCompatibleWith(Platform.HPUX) ? "-kP" : "-k"); //NOI18N - // it is also possible to use bdf instead of df -kP but block size is 512 in that case - - if (args != null && args.length > 0) { - for(String arg:args) { - command.add(getExistingParent(arg)); - } - } - return command.toArray(new String[0]); - } - - /** - * Checks if given filename belongs to existing file. - * If not, the closest existing parent filename is returned. - * - * @param fileName - * @return Filename of existing parent or file itself. - */ - private String getExistingParent(String fileName) { - File file = new File(fileName); - - if (file.exists()) { - return fileName; - } else { - return getExistingParent(file.getParent()); - } - } - - @Override - public List getFileSystemRoots(String... files) throws IOException { - try { - setEnvironmentVariable( - "LANG", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_COLLATE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_CTYPE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MESSAGES", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MONETARY", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_NUMERIC", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_TIME", "C", EnvironmentScope.PROCESS, false); - - final String stdout = SystemUtils.executeCommand(getDfCommand(files)).getStdOut(); - final String[] lines = StringUtils.splitByLines(stdout); - - // a quick and dirty solution - we assume that % is present only once in - // each line - in the part where the percentage is reported, hence we - // look for the percentage sign and then for the first slash - final List roots = new LinkedList<>(); - for (int i = 1; i < lines.length; i++) { - int index = lines[i].indexOf("%"); - if (index != -1) { - index = lines[i].indexOf("/", index); - - if (index != -1) { - final String path = lines[i].substring(index); - final File file = new File(path); - - if (!roots.contains(file)) { - roots.add(file); - } - } - } - } - - return roots; - } catch (NativeException e) { - final IOException ioException = - new IOException("Cannot define the environment"); - - throw (IOException) ioException.initCause(e); - } - } - - // native declarations ////////////////////////////////////////////////////////// - private native long getFreeSpace0(String s); - - private native void setPermissions0(String path, int mode, int change); - - private native int getPermissions0(String path); - - private native boolean isCurrentUserAdmin0(); - - private long getFreeSpaceNative(String s) { - return nativeLibraryLoaded ? getFreeSpace0(s) : getFreeSpaceJ(s); - } - - private long getFreeSpaceJ(String s) { - try { - setEnvironmentVariable( - "LANG", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_COLLATE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_CTYPE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MESSAGES", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MONETARY", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_NUMERIC", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_TIME", "C", EnvironmentScope.PROCESS, false); - } catch (NativeException e) { - LogManager.log(e); - } - - try { - final String stdout = SystemUtils.executeCommand(getDfCommand(s)).getStdOut().trim(); - final String[] lines = StringUtils.splitByLines(stdout); - - // a quick and dirty solution - we assume that % is present only once in - // each line - in the part where the percentage is reported, hence we - // look for the percentage sign and then for the first slash - for (int i = 1; i < lines.length; i++) { - int index = lines[i].indexOf("%"); - if (index != -1) { - String parts[] = lines[i].substring(0, index).split("[ ]+"); - if (parts.length > 1) { - return Long.parseLong(parts[parts.length - 2]) * 1024L; - } - } - } - } catch (IOException | NumberFormatException e) { - LogManager.log(e); - } - return 0L; - } - - private void setPermissionsJ(String path, int mode, int change) throws IOException { - switch(change) { - case FA_MODE_SET: - chmod(new File(path), mode); - break; - - case FA_MODE_ADD: - case FA_MODE_REMOVE: - if(mode==0) return; - String fullmode = StringUtils.EMPTY_STRING; - - Integer [] rModes = new Integer [] {FileAccessMode.RU, FileAccessMode.RG, FileAccessMode.RO }; - Integer [] wModes = new Integer [] {FileAccessMode.WU, FileAccessMode.WG, FileAccessMode.WO }; - Integer [] xModes = new Integer [] {FileAccessMode.EU, FileAccessMode.EG, FileAccessMode.EO }; - - List , String >> modes = new ArrayList<>(); - - modes.add(new Pair< >(new ArrayList<>(Arrays.asList(rModes)), "r")); - modes.add(new Pair< >(new ArrayList<>(Arrays.asList(wModes)), "w")); - modes.add(new Pair< >(new ArrayList<>(Arrays.asList(xModes)), "x")); - - for (int i = 0; i < modes.size(); i++) { - String m = StringUtils.EMPTY_STRING; - List list = modes.get(i).getFirst(); - for (int j = 0; j < list.size(); j++) { - if ((mode & list.get(j)) != 0) { - m += (j == 0 ? "u" : (j == 1 ? "g" : "o")); - } - } - if(!m.equals(StringUtils.EMPTY_STRING)) { - m += ((change == FA_MODE_ADD) ? "+" : "-") + modes.get(i).getSecond(); - fullmode = fullmode.equals(StringUtils.EMPTY_STRING) ? m : fullmode + "," + m; - m = StringUtils.EMPTY_STRING; - } - } - - if(!fullmode.equals(StringUtils.EMPTY_STRING)) { - chmod(new File(path), fullmode); - } - break; - default: - break; - } - } - - private void setPermissionsNative(String path, int mode, int change) throws IOException { - if(nativeLibraryLoaded) { - setPermissions0(path,mode,change); - } else { - setPermissionsJ(path,mode,change); - } - } - - private int getPermissionsNative(String path) { - return nativeLibraryLoaded ? getPermissions0(path) : getPermissionsJ(path); - } - - private int getPermissionsJ(String path) { - try { - final String output = SystemUtils.executeCommand("ls", "-ld", path).getStdOut().trim(); - - int permissions = 0; - for (int i = 0; i < 9; i++) { - char character = output.charAt(i + 1); - - if (i % 3 == 0) { - permissions *= 10; - } - - if (character == '-') { - continue; - } else if ((i % 3 == 0) && (character == 'r')) { - permissions += 4; - } else if ((i % 3 == 1) && (character == 'w')) { - permissions += 2; - } else if ((i % 3 == 2) && (character == 'x')) { - permissions += 1; - } else { - return -1; - } - } - - return permissions; - } catch (IOException | IndexOutOfBoundsException e) { - return -1; - } - } - - private boolean isCurrentUserAdminNative() { - return (nativeLibraryLoaded) ? isCurrentUserAdmin0() : isCurrentUserAdminJ(); - } - - private boolean isCurrentUserAdminJ() { - boolean adm = false; - try { - try { - setEnvironmentVariable( - "LANG", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_COLLATE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_CTYPE", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MESSAGES", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_MONETARY", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_NUMERIC", "C", EnvironmentScope.PROCESS, false); - setEnvironmentVariable( - "LC_TIME", "C", EnvironmentScope.PROCESS, false); - } catch (NativeException e) { - LogManager.log(e); - } - String stdout = SystemUtils.executeCommand("id").getStdOut(); - Matcher matcher = Pattern.compile("euid=([0-9]+)\\(").matcher(stdout); - if (!matcher.find()) { - matcher = Pattern.compile("uid=([0-9]+)\\(").matcher(stdout); - } - if (matcher.find()) { - adm = Integer.parseInt(matcher.group(1)) == 0; - } - } catch (IOException | NumberFormatException e) { - LogManager.log(e); - } - return adm; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - private class UnixProcessOnExitCleanerHandler extends ProcessOnExitCleanerHandler { - public UnixProcessOnExitCleanerHandler(String cleanerFileName) { - super(cleanerFileName); - } - protected void writeCleaner(File cleanerFile) throws IOException { - InputStream is = ResourceUtils.getResource(CLEANER_RESOURCE); - CharSequence cs = StreamUtils.readStream(is); - is.close(); - String [] lines = StringUtils.splitByLines(cs); - FileUtils.writeFile(cleanerFile, StringUtils.asString(lines, SystemUtils.getLineSeparator())); - } - - protected void writeCleaningFileList(File listFile, List files) throws IOException { - // be sure that the list file contains end-of-line - // otherwise the installer will run into Issue 104079 - List newList = new LinkedList<> (files); - newList.add(SystemUtils.getLineSeparator()); - FileUtils.writeStringList(listFile, newList); - } - } - - public static class FileAccessMode { - /** Read by user */ - public static final int RU = 0400; - /** Write by user */ - public static final int WU = 0200; - /** Execute by user */ - public static final int EU = 0100; - - /** Read by group */ - public static final int RG = 040; - /** Write by group */ - public static final int WG = 020; - /** Execute by group */ - public static final int EG = 010; - - /** Read by others */ - public static final int RO = 04; - /** Write by others */ - public static final int WO = 02; - /** Execute by others */ - public static final int EO = 01; - } - - @Override - protected void initializeForbiddenFiles(String ... files) { - super.initializeForbiddenFiles(FORBIDDEN_DELETING_FILES_UNIX); - super.initializeForbiddenFiles(files); - } - private static final String [] QUOTA_LOCATIONS = { - "/usr/sbin/quota", //NOI18N - "/usr/bin/quota", //NOI18N - "/sbin/quota", //NOI18N - "/bin/quota", //NOI18N - }; - private static final byte [] ELF_BYTES = new byte[]{'\177','E','L','F'}; - private static final long QUOTA_TIMEOUT_MILLIS = 5000;//NOMAGI -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/WindowsNativeUtils.java b/nbi/engine/src/org/netbeans/installer/utils/system/WindowsNativeUtils.java deleted file mode 100644 index 6a2157bb9734..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/WindowsNativeUtils.java +++ /dev/null @@ -1,1449 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.regex.Pattern; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.EnvironmentScope; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.system.shortcut.FileShortcut; -import org.netbeans.installer.utils.system.shortcut.InternetShortcut; -import org.netbeans.installer.utils.system.shortcut.LocationType; -import org.netbeans.installer.utils.system.shortcut.Shortcut; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.ApplicationDescriptor; -import org.netbeans.installer.utils.system.windows.SystemApplication; -import org.netbeans.installer.utils.system.windows.FileExtension; -import org.netbeans.installer.utils.system.windows.WindowsRegistry; -import org.netbeans.installer.utils.helper.FilesList; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.system.launchers.Launcher; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.cleaner.OnExitCleanerHandler; -import org.netbeans.installer.utils.system.cleaner.ProcessOnExitCleanerHandler; -import static org.netbeans.installer.utils.StringUtils.*; -import static org.netbeans.installer.utils.system.windows.WindowsRegistry.*; - -/** - * - * @author Dmitry Lipin - * @author Kirill Sorokin - */ -public class WindowsNativeUtils extends NativeUtils { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String LIBRARY_PATH_X86 = - NATIVE_JNILIB_RESOURCE_SUFFIX + "windows/windows-x86.dll"; //NOI18N - public static final String LIBRARY_PATH_X64 = - NATIVE_JNILIB_RESOURCE_SUFFIX + "windows/windows-x64.dll"; //NOI18N - public static final String LIBRARY_PATH_IA64 = - NATIVE_JNILIB_RESOURCE_SUFFIX + "windows/windows-ia64.dll"; //NOI18N - - private static final String CLEANER_RESOURCE = - NATIVE_CLEANER_RESOURCE_SUFFIX + - "windows/" + "cleaner.exe"; - - private static final String CLEANER_FILENAME = - "nbi-cleaner.exe"; - - public static final String UNINSTALL_KEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; - - public static final String DISPLAY_NAME = "DisplayName"; - public static final String DISPLAY_ICON = "DisplayIcon"; - public static final String UNINSTALL_STRING = "UninstallString"; - public static final String MODIFY_STRING = "ModifyPath"; - public static final String NO_MODIFY = "NoModify"; - public static final String NO_REPAIR = "NoRepair"; - public static final String INSTALL_LOCATION = "InstallLocation"; - - private static final String NBI_UID_PREFIX = "nbi-"; - private static final String UID_SEPARATOR = "-"; - - private static final int MIN_UID_INDEX = 1; - private static final int MAX_UID_INDEX = 100; - - private static final String SHELL_FOLDERS_KEY = - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; - - public static final String CURRENT_USER_ENVIRONMENT_KEY = - "Environment"; - public static final String ALL_USERS_ENVIRONMENT_KEY = - "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"; - - private static final String RUNONCE_KEY = - "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"; - private static final String RUNONCE_DELETE_VALUE_NAME = - "NBI Temporary Files Delete"; - - private static final String EXT_PREFIX = "NBI."; - private static final String EXT_SUFFIX = ""; - - - private static final String SEP = SEPARATOR; - - /////////////////////////////////////////////////////////////////////////// - // File Association Constants - private static final String PERCEIVED_TYPE_VALUE_NAME = "PerceivedType"; - private static final String CONTENT_TYPE_VALUE_NAME = "Content Type"; - private static final String DEFAULT_ICON_KEY_NAME = "DefaultIcon"; - private static final String SHELL_OPEN_COMMAND = - SEP + "shell" + SEP + "open" + SEP + "command"; - private static final String CONTENT_TYPE_KEY = - "MIME" + SEP + "Database" + SEP + "Content Type"; - private static final String APPLICATIONS_KEY_NAME = "Applications"; - private static final String FRIENDLYAPPNAME_VALUE_NAME = "FriendlyAppName"; - private static final String APPLICATION_VALUE_NAME = "Application"; - private static final String OPEN_WITH_LIST_KEY_NAME = "OpenWithList"; - private static final String EXTENSION_VALUE_NAME = "Extension"; - public static final String DEFAULT_OPEN_COMMAND = "\"%1\""; - - private static final String CURRENT_USER_FILE_EXT_KEY = - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts"; - private static final String CURRENT_USER_MUI_CACHE_KEY = - "Software\\Microsoft\\Windows\\ShellNoRoam\\MUICache"; - private static final String OPEN_WITH_PROGIDS_KEY_NAME = "OpenWithProgids"; - private static final String MRULIST_VALUE_NAME = "MRUList"; - private static final String MRU_VALUES = "abcdefghijklmnopqrstuvwxyz"; - - - // properties for file associations - private static final String CREATED = "created"; - private static final String EXT_PERCEIVEDTYPE_PROPERTY = "perceivedType"; - private static final String EXT_CONTENTTYPE_PROPERTY = "contentType"; - private static final String EXT_LONGEXT_PROPERTY = "longExt"; - private static final String EXT_DESCRIPTION_PROPERTY = "description"; - private static final String EXT_ICON_PROPERTY = "defaultIcon"; - private static final String EXT_HKCRSHELL_OPEN_COMMAND_PROPERTY = "hkcrShellOpenCommand"; - private static final String EXT_HKCU_DEFAULTAPP_PROPERTY = "hkcuDefaultApp"; - private static final String EXT_HKCU_FILEXT_PROPERTY = "hkcuFileExt"; - private static final String EXT_HKCR_APPLICATIONS_PROPERTY = "hkcrApplications"; - private static final String EXT_HKCR_OPENWITHPROGIDS_PROPERTY = "hkcrOpenWithProgids"; - private static final String EXT_HKCR_OPENWITHLIST_PROPERTY = "hkcrOpenWithList"; - private static final String EXT_HKCU_MUICACHE_PROPERTY = "hkcuMuiCache"; - private static final String EXT_HKCU_OPENWITHPROGIDS_PROPERTY = "hkcuOpenWithProgids"; - private static final String EXT_HKCU_OPENWITHLIST_PROPERTY = "hkcuOpenWithList"; - - private static final String CURRENT_USER_CLASSES = "Software\\Classes\\"; - private int clSection; - private String clKey; - private int uninstallSection; - - private boolean isUserAdminSet; - private boolean isUserAdmin; - - private String browserCommand; - - - ////////////////////////////////////////////////////////////////////////// - // file access - // windows API constants - private static final int FILE_READ_DATA = 0; - private static final int FILE_LIST_DIRECTORY = 0; - private static final int FILE_WRITE_DATA = 1; - private static final int FILE_ADD_FILE =1; - private static final int FILE_APPEND_DATA = 4; - private static final int FILE_ADD_SUBDIRECTORY = 4; - private static final int FILE_READ_EA = 8; - private static final int FILE_WRITE_EA = 16; - private static final int FILE_EXECUTE = 32; - private static final int FILE_TRAVERSE = 32; - private static final int FILE_DELETE_CHILD = 64; - private static final int FILE_READ_ATTRIBUTES = 128; - private static final int FILE_WRITE_ATTRIBUTES = 256; - private static final int FILE_DELETE = 65536; - - ////////////////////////////////////////////////////////////////////////// - - private static final WindowsRegistry registry = new WindowsRegistry(); - - private static final String[] FORBIDDEN_DELETING_FILES_WINDOWS = { - System.getenv("ProgramFiles"), - System.getenv("SystemRoot"), - System.getenv("USERPROFILE"), - System.getenv("SystemDrive") + File.separator - }; - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private File defaultApplicationsLocation; - - // constructor ////////////////////////////////////////////////////////////////// - WindowsNativeUtils() { - String libraryPath; - if (SystemUtils.isCurrentJava64Bit()) { - if(System.getProperty("os.arch").equals("ia64")) { - libraryPath = LIBRARY_PATH_IA64; - } else { - libraryPath = LIBRARY_PATH_X64; - } - } else { - libraryPath = LIBRARY_PATH_X86; - } - try { - loadNativeLibrary(libraryPath); - } catch (NativeException e) { - // can`t live without the native library - ErrorManager.notifyCritical("Cannot load native library which is strictly necessary to work correctly.",e); - } - //initializeForbiddenFiles(FORBIDDEN_DELETING_FILES_WINDOWS); - if(nativeLibraryLoaded) { - initializeForbiddenFiles(); - initializeRegistryKeys(); - } - } - @Override - protected Platform getPlatform() { - return SystemUtils.isCurrentJava64Bit() ? - (System.getProperty("os.arch").equals("ia64") ? - Platform.WINDOWS_IA64 : - Platform.WINDOWS_X64) : - Platform.WINDOWS_X86; - } - - private void initializeRegistryKeys() { - boolean result = false; - try { - result = isCurrentUserAdmin(); - } catch (NativeException ex) { - LogManager.log(ex); - } - - try { - clSection = registry.canModifyKey(HKCR, "") ? HKCR : HKCU; - clKey = (result) ? EMPTY_STRING : CURRENT_USER_CLASSES; - uninstallSection = registry.canModifyKey(HKLM,UNINSTALL_KEY) ? HKLM : HKCU; - } catch (NativeException ex) { - LogManager.log(ex); - clSection = HKCU; - clKey = CURRENT_USER_CLASSES; - uninstallSection = HKCU; - } - } - // parent implementation //////////////////////////////////////////////////////// - @Override - public boolean isSystem64Bit() { - String arch = System.getenv("PROCESSOR_ARCHITECTURE"); - String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); - - return arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64"); - } - - @Override - public boolean isCurrentUserAdmin() throws NativeException { - if(isUserAdminSet) { - return isUserAdmin; - } - boolean result = isCurrentUserAdmin0(); - isUserAdmin = result; - isUserAdminSet = true; - return result; - - } - - - @Override - protected OnExitCleanerHandler newDeleteOnExitCleanerHandler() { - return new WindowsProcessOnExitCleanerHandler(CLEANER_FILENAME); - } - - @Override - public File getDefaultApplicationsLocation() throws NativeException { - if (defaultApplicationsLocation == null) { - defaultApplicationsLocation = SystemUtils.getUserHomeDirectory(); - - final String path = SystemUtils.getEnvironmentVariable("ProgramFiles"); - - if (path != null) { - defaultApplicationsLocation = new File(path).getAbsoluteFile(); - } else { - ErrorManager.notify(ErrorLevel.DEBUG, "Value of the environment variable ProgramFiles is not set"); - } - } - - return defaultApplicationsLocation; - } - - @Override - public long getFreeSpace(File file) throws NativeException { - if ((file == null) || !isPathValid(file.getPath())) { - return 0; - } else { - return getFreeSpace0(file.getPath()); - } - } - - @Override - public boolean isUNCPath(String path) { - // for windows UNC is smth like \\servername\folder... - return path.matches("^\\\\\\\\.+(\\\\|/).+"); - } - - @Override - public File getRoot(final File file) { - if(isUNCPath(file.getPath())) { - // tmp = server\folder; - File parent = file; - File previous = null; - File can; - try { - while(parent.getParentFile()!=null) { - can = parent.getCanonicalFile(); - previous = parent; - parent = parent.getParentFile(); - } - } catch (IOException e) { - // this occurs when file path is equal the server name : \\server - // then go to finally and return previous file - } finally { - return previous; - } - } else { - return super.getRoot(file); - } - } - - @Override - public boolean isPathValid(String path) { - // there is a max length limitation - if (path.length() > 256) { - return false; - } - - // the path should be absolute, i.e. should start with ":\" - if (!path.matches("^[A-Z,a-z]:\\\\.*")) { - // the path can be also in UNC form - if(!isUNCPath(path)) { - return false; - } - } - - String[] parts = path.split("\\\\"); - - for (int i = 1; i < parts.length; i++) { - if (Pattern.compile("[\\/:*\\?\"<>|]").matcher(parts[i]).find()) { - return false; - } - if (parts[i].startsWith(" ") || - parts[i].startsWith("\t") || - parts[i].endsWith(" ") || - parts[i].endsWith("\t")) { - return false; - } - } - - return true; - } - - @Override - public File getShortcutLocation(Shortcut shortcut, LocationType locationType) throws NativeException { - if (shortcut.getPath() != null) { - return new File(shortcut.getPath()); - } - - String path = shortcut.getRelativePath(); - if (path == null) { - path = ""; - } - - String fileName = shortcut.getName(); - if(shortcut instanceof FileShortcut) { - fileName += ".lnk"; - } else if(shortcut instanceof InternetShortcut) { - fileName += ".url"; - } - - final String allUsersRootPath = SystemUtils.getEnvironmentVariable("allusersprofile"); - File shortcutFile = null; - switch (locationType) { - case CURRENT_USER_DESKTOP: - String userDesktop = registry.getStringValue(HKCU, SHELL_FOLDERS_KEY, "Desktop", false); - if (userDesktop == null) { - userDesktop = SystemUtils.getUserHomeDirectory() + File.separator + "Desktop"; - } - - shortcutFile = new File(userDesktop, fileName); - break; - - case ALL_USERS_DESKTOP: - String commonDesktop = registry.getStringValue(HKLM, SHELL_FOLDERS_KEY, "Common Desktop", false); - if (commonDesktop == null) { - commonDesktop = allUsersRootPath + File.separator + "Desktop"; - } - - shortcutFile = new File(commonDesktop, fileName); - break; - - case CURRENT_USER_START_MENU: - String userStartMenu = registry.getStringValue(HKCU, SHELL_FOLDERS_KEY, "Programs", false); - if (userStartMenu == null) { - userStartMenu = SystemUtils.getUserHomeDirectory() + File.separator + "Start Menu" + File.separator + "Programs"; - } - - shortcutFile = new File(userStartMenu, path + File.separator + fileName); - break; - - case ALL_USERS_START_MENU: - String commonStartMenu = registry.getStringValue(HKLM, SHELL_FOLDERS_KEY, "Common Programs", false); - if (commonStartMenu == null) { - commonStartMenu = SystemUtils.getUserHomeDirectory() + File.separator + "Start Menu" + File.separator + "Programs"; - } - - shortcutFile = new File(commonStartMenu, path + File.separator + fileName); - break; - case CUSTOM: - shortcutFile = new File(path + File.separator + fileName); - break; - } - if(shortcutFile!=null) { - shortcut.setPath(shortcutFile.getAbsolutePath()); - } - return shortcutFile; - } - - protected void createURLShortcut(InternetShortcut shortcut) throws NativeException { - try { - List lines = new LinkedList (); - lines.add("[InternetShortcut]"); - lines.add("URL=" + shortcut.getURL()); - lines.add("IconFile=" + shortcut.getIconPath()); - lines.add("IconIndex="+ shortcut.getIconIndex()); - lines.add("HotKey=0"); - lines.add("IDList="); - lines.add(SystemUtils.getLineSeparator()); - FileUtils.writeStringList(new File(shortcut.getPath()),lines); - } catch (IOException ex) { - throw new NativeException("Can`t create URL shortcut", ex); - } - } - - @Override - public File createShortcut(Shortcut shortcut, LocationType locationType) throws NativeException { - File shortcutFile = getShortcutLocation(shortcut, locationType); - if(shortcut instanceof FileShortcut) { - createShortcut0((FileShortcut)shortcut); - } else if(shortcut instanceof InternetShortcut) { - createURLShortcut((InternetShortcut)shortcut); - } - - return shortcutFile; - } - - @Override - public void removeShortcut(Shortcut shortcut, LocationType locationType, boolean cleanupParents) throws NativeException { - File shortcutFile = getShortcutLocation(shortcut, locationType); - - try { - FileUtils.deleteFile(shortcutFile); - - if (cleanupParents) { - switch (locationType) { - case CURRENT_USER_START_MENU: - case ALL_USERS_START_MENU: - case CUSTOM: - FileUtils.deleteEmptyParents(shortcutFile); - break; - default: - break; - } - } - } catch (IOException e) { - LogManager.log("Can`t remove shortcut",e); - } - } - - @Override - public FilesList addComponentToSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException { - final FilesList list = new FilesList(); - - // create 'uninstaller' and 'modifier' - Launcher modifyLauncher = null; - Launcher uninstallLauncher = null; - try { - if (descriptor.getModifyCommand() != null) { - modifyLauncher = createUninstaller(descriptor, false, new Progress()); - list.add(modifyLauncher.getOutputFile()); - } - if (descriptor.getUninstallCommand() != null) { - uninstallLauncher = createUninstaller(descriptor, true, new Progress()); - list.add(uninstallLauncher.getOutputFile()); - } - } catch (IOException e) { - throw new NativeException("Can`t create uninstaller", e); - } - - //add to add/remove programs - - LogManager.log("adding new Add or Remove Programs entry with id [" + descriptor.getUid() + "]"); - - final String uid = getVacantUninstallUid(descriptor.getUid()); - final String key = UNINSTALL_KEY + WindowsRegistry.SEPARATOR + uid; - - registry.createKey(uninstallSection, key); - - if (descriptor.getDisplayName() != null) { - LogManager.log("Set '" + DISPLAY_NAME + "' = [" + descriptor.getDisplayName() + "]"); - - registry.setStringValue(uninstallSection, key, DISPLAY_NAME, descriptor.getDisplayName(), false); - } - if (descriptor.getIcon() != null) { - LogManager.log("Set '" + DISPLAY_ICON + "' = [" + descriptor.getIcon() + "]"); - - registry.setStringValue(uninstallSection, key, DISPLAY_ICON, descriptor.getIcon(), false); - } - if (descriptor.getInstallPath() != null) { - LogManager.log("Set '" + INSTALL_LOCATION + "' = [" + descriptor.getInstallPath() + "]"); - - registry.setStringValue(uninstallSection, key, INSTALL_LOCATION, descriptor.getInstallPath(), false); - } - - if (descriptor.getModifyCommand() != null) { - LogManager.log("Set '" + NO_REPAIR + "' = [" + 1 + "]"); - registry.set32BitValue(uninstallSection, key, NO_REPAIR, 1); - - final String command = - QUOTE + - asString(modifyLauncher.getExecutionCommand(), QUOTE + SPACE + QUOTE) + - QUOTE; - - LogManager.log("Set '" + MODIFY_STRING + "' = [" + command + "]"); - registry.setStringValue(uninstallSection, key, MODIFY_STRING, command, false); - } else { - LogManager.log("Set '" + NO_MODIFY + "' = [" + 1 + "]"); - registry.set32BitValue(uninstallSection, key, NO_MODIFY, 1); - } - - if (descriptor.getUninstallCommand() != null) { - final String command = - QUOTE + - asString(uninstallLauncher.getExecutionCommand(), QUOTE + SPACE + QUOTE) + - QUOTE; - - LogManager.log("Set '" + UNINSTALL_STRING + "' = [" + command + "]"); - registry.setStringValue(uninstallSection, key, UNINSTALL_STRING, command, false); - } - - registry.setAdditionalValues(uninstallSection, key, descriptor.getParameters()); - return list; - } - - @Override - public void removeComponentFromSystemInstallManager(ApplicationDescriptor descriptor) throws NativeException { - String properUid = getProperUninstallUid( - descriptor.getUid(), - descriptor.getInstallPath()); - - if (properUid != null) { - registry.deleteKey(uninstallSection, UNINSTALL_KEY, properUid); - } - } - - @Override - public String getEnvironmentVariable(String name, EnvironmentScope scope, boolean expand) throws NativeException { - String value = null; - - if ((scope != null) && (name != null)) { - if (scope == EnvironmentScope.PROCESS) { - value = System.getenv(name); - } else { - String rootKey = null; - int section = 0; - if (scope == EnvironmentScope.CURRENT_USER) { - rootKey = CURRENT_USER_ENVIRONMENT_KEY; - section = HKCU; - } - if (scope == EnvironmentScope.ALL_USERS) { - rootKey = ALL_USERS_ENVIRONMENT_KEY; - section = HKLM; - } - - if (registry.keyExists(section, rootKey)) { - if(registry.valueExists(section, rootKey, name)) { - value = registry.getStringValue(section, rootKey, name, expand); - } else { - LogManager.log(ErrorLevel.DEBUG, "Environment variable " + name + " doesn`t exist."); - } - } else { - LogManager.log(ErrorLevel.DEBUG, "Root environment key doesn`t exist. Can`t get environment variable"); - } - } - } - - return value; - } - - @Override - public void setEnvironmentVariable(String name, String value, EnvironmentScope scope, boolean expand) throws NativeException { - if ((name != null) && (scope != null)) { - if (scope == EnvironmentScope.PROCESS) { - SystemUtils.getEnvironment().put(name, value); - } else { - String rootKey = null; - int section = 0; - if (scope == EnvironmentScope.CURRENT_USER) { - rootKey = CURRENT_USER_ENVIRONMENT_KEY; - section = HKCU; - } - if (scope == EnvironmentScope.ALL_USERS) { - rootKey = ALL_USERS_ENVIRONMENT_KEY; - section = HKLM; - } - - if (registry.keyExists(section, rootKey)) { - if (value != null) { - registry.setStringValue(section, rootKey, name, value, expand); - } else if(registry.valueExists(section, rootKey, name)) { - registry.deleteValue(section, rootKey, name); - } else { - LogManager.log(ErrorLevel.MESSAGE, "Environment variable " + name + " is not set"); - } - notifyEnvironmentChanged0(); - } else { - LogManager.log(ErrorLevel.WARNING, - "Root envonment key doesn`t exist. " + - "Can`t set environment variable"); - } - } - } - } - - @Override - public List findIrrelevantFiles(File parent) throws IOException { - List files = new LinkedList(); - - if (parent.exists()) { - if(parent.isDirectory()) { - for(File child : parent.listFiles()) { - files.addAll(findIrrelevantFiles(child)); - } - } else { - // name based analysis - File child = parent; - String name = child.getName(); - String [] unixExtensions = {".sh", ".so", ".dylib"}; - for(String ext : unixExtensions) { - if(name.endsWith(ext)) { - files.add(child); - break; - } - } - - // contents based analysis - // Switched off due to Issue 97995 - // This analysis can be switched back only after the serious invesigation - // The main additional check should be done based on the name - // If it contains any extenstion (except .sh) then check is failed anyway - // E.G: GlassFish\imq\lib\props\broker\default.properties - /* - String line = FileUtils.readFirstLine(child); - if (line != null) { - if (line.startsWith("#!/bin/sh")) { // shell script - files.add(child); - continue; - } - } - */ - } - } - - return files; - } - - @Override - public List findExecutableFiles(File parent) throws IOException { - List files = new LinkedList(); - - if (parent.exists()) { - if(parent.isDirectory()) { - File [] children = parent.listFiles(); - for(File child : children) { - files.addAll(findIrrelevantFiles(child)); - } - } else { - // name based analysis - File child = parent; - String name = child.getName(); - String [] windowsExecutableExtensions = { - ".exe", ".com", ".bat", ".cmd", ".vbs", - ".vbe", ".js",".jse", ".wsf", ".wsh" }; - for(String ext : windowsExecutableExtensions) { - if (name.endsWith(ext)) { - files.add(child); - break; - } - } - } - } - return files; - } - - @Override - public void correctFilesPermissions(File parent) { - // does nothing, as there is no such thing as execute permissions - } - - @Override - public void setPermissions( - final File file, - final int mode, - final int change) throws IOException { - // does nothing - } - - @Override - public int getPermissions( - final File file) throws IOException { - return 0; - } - - @Override - public List getFileSystemRoots(String... files) throws IOException { - return Arrays.asList(File.listRoots()); - } - - // windows-specific operations ////////////////////////////////////////////////// - public WindowsRegistry getWindowsRegistry() { - return registry; - } - - public void deleteFileOnReboot(File file) throws NativeException { - String path = file.getAbsolutePath(); - - if (isCurrentUserAdmin()) { - deleteFileOnReboot0(path); - } else { - // just in case... - if (!registry.keyExists(HKCU, RUNONCE_KEY)) { - registry.createKey(HKCU, RUNONCE_KEY); - } - - // find an appropriate name, which does not exist - String name = RUNONCE_DELETE_VALUE_NAME; - for (int i = 0; registry.valueExists(HKCU, RUNONCE_KEY, name); i++) { - name = RUNONCE_DELETE_VALUE_NAME + UID_SEPARATOR + i; - } - - // set the value - String command = "cmd /q /c del /F /Q \"" + path + "\""; - registry.setStringValue(HKCU, RUNONCE_KEY, name, command); - } - } - - // private ////////////////////////////////////////////////////////////////////// - private String getVacantUninstallUid(final String baseUid) throws NativeException { - String vacantUid = baseUid; - - String key = UNINSTALL_KEY + WindowsRegistry.SEPARATOR + vacantUid; - if (registry.keyExists(uninstallSection, key)) { - for (int index = MIN_UID_INDEX; index < MAX_UID_INDEX; index++) { - vacantUid = baseUid + UID_SEPARATOR + index; - key = UNINSTALL_KEY + WindowsRegistry.SEPARATOR + vacantUid; - - if (!registry.keyExists(uninstallSection, key)) { - return vacantUid; - } - } - return null; - } else { - return vacantUid; - } - } - - private String getProperUninstallUid(final String baseUid, final String installLocation) throws NativeException { - String properUid = baseUid; - - String key = UNINSTALL_KEY + WindowsRegistry.SEPARATOR + properUid; - if (registry.keyExists(uninstallSection, key) && - registry.getStringValue(uninstallSection, key, INSTALL_LOCATION).equals(installLocation)) { - return properUid; - } else { - for (int index = MIN_UID_INDEX; index < MAX_UID_INDEX; index++) { - properUid = baseUid + UID_SEPARATOR + index; - key = UNINSTALL_KEY + WindowsRegistry.SEPARATOR + properUid; - - if (registry.keyExists(uninstallSection, key) && - registry.getStringValue(uninstallSection, key, INSTALL_LOCATION).equals(installLocation)) { - return properUid; - } - } - return null; - } - } - @Override - public boolean checkFileAccess(File file, boolean isReadNotModify) throws NativeException { - int result = 0; - try { - int accessLevel = 0; - if(isReadNotModify) { - accessLevel = FILE_READ_DATA | FILE_LIST_DIRECTORY; - } else { - accessLevel = FILE_ADD_FILE | - FILE_ADD_SUBDIRECTORY | - FILE_APPEND_DATA | - FILE_WRITE_DATA; - } - result = checkAccessTokenAccessLevel0(file.getPath(), accessLevel); - } catch (UnsatisfiedLinkError e) { - throw new NativeException("Cannot access native method", e); - } - return (result==1); - } - - public synchronized void setFileAssociation(FileExtension ext, SystemApplication app, Properties props) throws NativeException { - if (ext==null && isEmpty(ext.getName())) { - return; - } - notifyAssociationChanged(); - FileExtensionKey feExt = new FileExtensionKey(ext,getLongExtensionName(ext)); - setExtensionDetails(feExt,props); - - if(app!=null && !isEmpty(app.getLocation())) { - SystemApplicationKey appExt = new SystemApplicationKey(app,getApplicationKey(app)); - registerApplication(appExt,feExt,props); - changeDefaultApplication(appExt, feExt, props); - addToOpenWithList(appExt, feExt,props); - } - notifyAssociationChanged(); - } - - public synchronized void removeFileAssociation(FileExtension ext, SystemApplication app, Properties props) throws NativeException { - - if (ext==null && isEmpty(ext.getName())) { - return; - } - notifyAssociationChanged(); - String prefix = EXTENSION_VALUE_NAME + ext.getDotName(); - if(props.getProperty(prefix)!=null) { - //extension was created - if(registry.valueExists(clSection, clKey + ext.getDotName(),EMPTY_STRING)) { - String extKey = registry.getStringValue(clSection, clKey + ext.getDotName(),EMPTY_STRING); - FileExtensionKey feExt = new FileExtensionKey(ext,extKey); - String appKey = getApplicationKey(app); - SystemApplicationKey sap = new SystemApplicationKey(app,appKey); - - removeFromOpenWithList(sap, feExt,props); - rollbackDefaultApplication(sap, feExt,props); - unregisterApplication(sap,feExt, props); - clearExtensionDetails(sap,feExt,props); - } - } - notifyAssociationChanged(); - } - - private void setExtensionDetails(FileExtensionKey ext, Properties props) throws NativeException { - String name = ext.getDotName(); - String extKey = ext.getKey(); - // create key HKEY_CLASSES_ROOT\.EXTENSION - if(!registry.keyExists(clSection, clKey + name)) { - registry.createKey(clSection, clKey + name); - setExtProperty(props, name , CREATED); - } - - // Set perceived and content time if necessary - if(ext.getPerceivedType()!=null) { - if(!registry.valueExists(clSection, clKey + name , PERCEIVED_TYPE_VALUE_NAME)) { - registry.setStringValue(clSection, clKey + name, PERCEIVED_TYPE_VALUE_NAME,ext.getPerceivedType().toString()); - setExtProperty(props, name , EXT_PERCEIVEDTYPE_PROPERTY, CREATED); - } - } - if(!isEmpty(ext.getMimeType())) { - registry.setStringValue(clSection, clKey + name, CONTENT_TYPE_VALUE_NAME,ext.getMimeType()); - if(!registry.keyExists(clSection, clKey + CONTENT_TYPE_KEY,ext.getMimeType())) { - registry.createKey(clSection, clKey + CONTENT_TYPE_KEY,ext.getMimeType()); - registry.setStringValue(clSection, clKey + CONTENT_TYPE_KEY + SEP + ext.getMimeType(), EXTENSION_VALUE_NAME, name); - setExtProperty(props, name, EXT_CONTENTTYPE_PROPERTY, CREATED); - } - } - // make connection with HKEY_CLASSES_ROOT\.EXTENSION - registry.setStringValue(clSection, clKey + name, EMPTY_STRING, extKey); - - // create key HKEY_CLASSES_ROOT\EXT_PREFIX_EXTENSION_EXT_SUFFIX - if(!registry.keyExists(clSection, clKey + extKey)) { - registry.createKey(clSection, clKey + extKey); - setExtProperty(props, name, EXT_LONGEXT_PROPERTY, CREATED); - } - - - // Set extension description and icon if necessary - if(!isEmpty(ext.getDescription())) { - if(registry.valueExists(clSection, clKey + extKey, EMPTY_STRING)) { - setExtProperty(props, name, EXT_DESCRIPTION_PROPERTY, - registry.getStringValue(clSection, clKey + extKey, EMPTY_STRING)); - } - registry.setStringValue(clSection, clKey + extKey, EMPTY_STRING, ext.getDescription()); - - } - if(!isEmpty(ext.getIcon())) { - if(!registry.keyExists(clSection, clKey + extKey, DEFAULT_ICON_KEY_NAME)) { - registry.createKey(clSection, clKey + extKey, DEFAULT_ICON_KEY_NAME); - registry.setStringValue(clSection, clKey + extKey + SEP + DEFAULT_ICON_KEY_NAME,EMPTY_STRING, ext.getIcon()); - setExtProperty(props, name, EXT_ICON_PROPERTY, CREATED); - } - } - - //create current user extension key in HKCU\CURRENT_USER_FILE_EXT_KEY - if(!registry.keyExists(HKCU, CURRENT_USER_FILE_EXT_KEY, name)) { - registry.createKey(HKCU, CURRENT_USER_FILE_EXT_KEY, name); - setExtProperty(props, name, EXT_HKCU_FILEXT_PROPERTY, CREATED); - } - } - - private void clearExtensionDetails(SystemApplicationKey app, FileExtensionKey fe, Properties props) throws NativeException { - String name = fe.getDotName(); - String extKey = fe.getKey(); - String property; - property = getExtProperty(props, name, EXT_HKCU_FILEXT_PROPERTY); - if(property!=null) { - if(registry.keyExists(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name)) { - if(registry.keyExists(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name,OPEN_WITH_LIST_KEY_NAME)) { - registry.deleteKey(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name,OPEN_WITH_LIST_KEY_NAME); - } - if(registry.keyExists(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name,OPEN_WITH_PROGIDS_KEY_NAME)) { - registry.deleteKey(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name,OPEN_WITH_PROGIDS_KEY_NAME); - } - if(registry.getSubKeys(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP+ name).length==0) { - registry.deleteKey(HKCU, CURRENT_USER_FILE_EXT_KEY, name); - } - } - } - - property = getExtProperty(props, name, EXT_DESCRIPTION_PROPERTY); - if(property!=null) { - //restore description - registry.setStringValue(clSection, clKey + extKey, EMPTY_STRING, property); - } - - property = getExtProperty(props, name, EXT_ICON_PROPERTY); - if(property!=null) { - if(registry.keyExists(clSection, clKey + extKey + SEP + DEFAULT_ICON_KEY_NAME)) { - registry.deleteKey(clSection, clKey + extKey + SEP + DEFAULT_ICON_KEY_NAME); - } - } - - property = getExtProperty(props, name, EXT_LONGEXT_PROPERTY); - if(property!=null) { - if(registry.getSubKeys(clSection, clKey + extKey).length==0) { - registry.deleteKey(clSection, clKey + extKey); - } - } - - property = getExtProperty(props, name, EXT_CONTENTTYPE_PROPERTY); - if(property!=null) { - if(registry.getSubKeys(clSection, clKey + CONTENT_TYPE_KEY + SEP + fe.getMimeType()).length ==0) { - registry.deleteKey(clSection, clKey + CONTENT_TYPE_KEY, fe.getMimeType()); - } - } - property = getExtProperty(props, name, EXT_PERCEIVEDTYPE_PROPERTY); - if(property!=null) { - registry.deleteValue(clSection, clKey + name, PERCEIVED_TYPE_VALUE_NAME); - } - - property = getExtProperty(props, name); - if(property!=null) { - if(registry.keyExists(clSection, clKey + name) && registry.getSubKeys(clSection, clKey + name).length==0) { - registry.deleteKey(clSection, clKey + name); - } - } - } - - private void changeDefaultApplication(SystemApplicationKey app, FileExtensionKey fe, Properties props) throws NativeException { - if(app.isUseByDefault() == null || app.isUseByDefault().booleanValue() == true) { - String name = fe.getDotName(); - String extKey = fe.getKey(); - String appKey = app.getKey(); - - if(!registry.keyExists(clSection, clKey + extKey + SHELL_OPEN_COMMAND)) { - registry.createKey(clSection, clKey + extKey + SHELL_OPEN_COMMAND); - registry.setStringValue(clSection, clKey + - extKey + SHELL_OPEN_COMMAND, - EMPTY_STRING, - constructCommand(app)); - setExtProperty(props, name, EXT_HKCRSHELL_OPEN_COMMAND_PROPERTY, CREATED); - } - - //change current user 'default-app' for this extension - String s = null; - if(registry.valueExists(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name, APPLICATION_VALUE_NAME)) { - s = registry.getStringValue(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name, APPLICATION_VALUE_NAME); - } - - if (app.isUseByDefault() != null || s == null) { - registry.setStringValue(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name, APPLICATION_VALUE_NAME, appKey); - if (s != null) { - setExtProperty(props, name, EXT_HKCU_DEFAULTAPP_PROPERTY, s); - } - } - } - } - - private void rollbackDefaultApplication(SystemApplicationKey app, FileExtensionKey fe, Properties props) throws NativeException { - String property; - if(app.isUseByDefault() == null || app.isUseByDefault().booleanValue() == true) { - String name = fe.getDotName(); - String extKey = fe.getKey(); - property = getExtProperty(props, name, EXT_HKCRSHELL_OPEN_COMMAND_PROPERTY); - if(property!=null) { - String s = SHELL_OPEN_COMMAND; - registry.deleteKey(clSection, clKey + extKey + s); // delete command - s = s.substring(0,s.lastIndexOf(SEP)); - registry.deleteKey(clSection, clKey + extKey + s); // delete open - s = s.substring(0,s.lastIndexOf(SEP)); // - registry.deleteKey(clSection, clKey + extKey + s); // delete shell - } - property = getExtProperty(props, name, DOT + EXT_HKCU_DEFAULTAPP_PROPERTY); - - if(registry.keyExists(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name)) { - if(property!=null) { - registry.setStringValue(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name, APPLICATION_VALUE_NAME, property); - } else if(app.isUseByDefault()!=null) { - registry.deleteValue(HKCU, CURRENT_USER_FILE_EXT_KEY + SEP + name, APPLICATION_VALUE_NAME); - } - } - } - } - - private void addToOpenWithList(SystemApplicationKey app, FileExtensionKey ext, Properties props) throws NativeException { - String name = ext.getDotName(); - String extKey = ext.getKey(); - String appName = app.getKey(); - if(app.isAddOpenWithList()) { - if(!isEmpty(name) && !isEmpty(extKey) && !isEmpty(appName)) { - if(!registry.keyExists(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME,appName)) { - registry.createKey(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME,appName); - setExtProperty(props, name, EXT_HKCR_OPENWITHLIST_PROPERTY, CREATED); - } - addCurrentUserOpenWithList(name, extKey,appName, props); - - if(!registry.keyExists(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME)) { - registry.createKey(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME); - setExtProperty(props, name, EXT_HKCR_OPENWITHPROGIDS_PROPERTY, CREATED); - } - registry.setNoneValue(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME, extKey); - addCurrentUserOpenWithProgids(name, extKey, appName, props); - } - } - } - - private void removeFromOpenWithList(SystemApplicationKey app, FileExtensionKey ext, Properties props) throws NativeException { - String property; - String name = ext.getDotName(); - String extKey = ext.getKey(); - String appName = app.getKey(); - property = getExtProperty(props, name, EXT_HKCR_OPENWITHLIST_PROPERTY); - if(property!=null) { - if(registry.keyExists(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME,appName)) { - registry.deleteKey(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME,appName); - } - if(registry.keyExists(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME)) { - if(registry.getSubKeys(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME).length==0) { - registry.deleteKey(clSection, clKey + name + SEP + OPEN_WITH_LIST_KEY_NAME); - } - } - } - property = getExtProperty(props, name, EXT_HKCR_OPENWITHPROGIDS_PROPERTY); - if(property!=null) { - if(registry.keyExists(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME)) { - if(registry.valueExists(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME, extKey)) { - registry.deleteValue(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME, extKey); - } - if(registry.keyEmpty(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME)) { - registry.deleteKey(clSection, clKey + name + SEP + OPEN_WITH_PROGIDS_KEY_NAME); - } - } - } - String cuExtKey = CURRENT_USER_FILE_EXT_KEY + SEP + name; - property = getExtProperty(props,name, EXT_HKCU_OPENWITHPROGIDS_PROPERTY); - if(property!=null) { - if(registry.keyExists(HKCU, cuExtKey, OPEN_WITH_PROGIDS_KEY_NAME)) { - if(registry.valueExists(HKCU, cuExtKey + SEP + OPEN_WITH_PROGIDS_KEY_NAME,ext.getKey())) { - registry.deleteValue(HKCU, cuExtKey + SEP + OPEN_WITH_PROGIDS_KEY_NAME,ext.getKey()); - } - } - } - property = getExtProperty(props,name, EXT_HKCU_OPENWITHLIST_PROPERTY); - if(property!=null &®istry.keyExists(HKCU, cuExtKey, OPEN_WITH_LIST_KEY_NAME)) { - for(int i=0;i=0;i--) { - String str = EMPTY_STRING; - for(int j=i-1;j>=0;j--) { - str = str + SEP + openCommandKey[i-j]; - } - if(registry.keyExists(clSection, clKey + APPLICATIONS_KEY_NAME + SEP + appKey + str)) { - if(registry.getSubKeys(clSection, clKey + APPLICATIONS_KEY_NAME + SEP + appKey + str).length==0) { - registry.deleteKey(clSection, clKey + APPLICATIONS_KEY_NAME + SEP + appKey + str); - } - } - } - } - } - property = getExtProperty(props, name, EXT_HKCU_MUICACHE_PROPERTY); - if(property!=null) { - if(registry.valueExists(HKCU,CURRENT_USER_MUI_CACHE_KEY, app.getLocation())) { - if(property.equals(CREATED)) { - registry.deleteValue(HKCU,CURRENT_USER_MUI_CACHE_KEY, app.getLocation()); - } else { - registry.setStringValue(HKCU,CURRENT_USER_MUI_CACHE_KEY, app.getLocation(),property); - } - } - } - } - - private String getApplicationKey(SystemApplication app) throws NativeException { - String appName = new File(app.getLocation()).getName(); - String appKey = appName; - int index = 1; - while(registry.keyExists(clSection, clKey + APPLICATIONS_KEY_NAME, appKey)) { - if(registry.keyExists(clSection, clKey + APPLICATIONS_KEY_NAME + SEP + appKey + SHELL_OPEN_COMMAND)) { - String command = registry.getStringValue(clSection, clKey + - APPLICATIONS_KEY_NAME + SEP + appKey + SHELL_OPEN_COMMAND, - EMPTY_STRING); - if(command.equals(constructCommand(app))) { - break; - } - } - appKey = appName + DOT + (index++); - } - return appKey; - } - - private String getLongExtensionName(FileExtension ext) throws NativeException { - String dotname = ext.getDotName(); - String name = ext.getName(); - String key = null; - if(registry.keyExists(clSection, clKey + dotname)) { - key = registry.getStringValue(clSection, clKey + dotname,EMPTY_STRING); - } - if(isEmpty(key) || !registry.keyExists(clSection, clKey + key)) { - int index = 1; - do { - key = EXT_PREFIX + name + EXT_SUFFIX + DOT + (index++); - } while(registry.keyExists(clSection, clKey + key)); - } - return key; - } - - private String constructCommand(SystemApplication app) { - String command = app.getCommand(); - if(command==null) { - command = DEFAULT_OPEN_COMMAND; - } - return ("\"" + app.getLocation() + "\"" + SPACE + command); - } - - private boolean isEmpty(String str) { - return (str==null || str.equals(EMPTY_STRING)); - } - - private void initBrowser() { - if (browserCommand != null) { - return; - } - - try { - String type = null; - if (registry.keyExists(WindowsRegistry.HKEY_CURRENT_USER, "Software\\Classes\\.html")) { - type = registry.getStringValue(WindowsRegistry.HKEY_CURRENT_USER, "Software\\Classes\\.html", ""); - } else if (registry.keyExists(WindowsRegistry.HKEY_CLASSES_ROOT, ".html")) { - type = registry.getStringValue(WindowsRegistry.HKEY_CLASSES_ROOT, ".html", ""); - } - - LogManager.log("... html type : " + type); - if (type != null && !type.equals("")) { - browserCommand = null; - String userCmdKey = "Software\\Classes\\" + type + "\\shell\\open\\command"; - String systemCmdKey = type + "\\shell\\open\\command"; - if (registry.keyExists(WindowsRegistry.HKEY_CURRENT_USER, userCmdKey)) { - browserCommand = registry.getStringValue(WindowsRegistry.HKEY_CURRENT_USER, userCmdKey, ""); - LogManager.log("... using user browser"); - } else if (registry.keyExists(WindowsRegistry.HKEY_CLASSES_ROOT, systemCmdKey)) { - browserCommand = registry.getStringValue(WindowsRegistry.HKEY_CLASSES_ROOT, systemCmdKey, ""); - LogManager.log("... using system browser"); - } - if (browserCommand != null && !browserCommand.contains("%1")) { - userCmdKey = "Software\\Classes\\" + type + "\\shell\\opennew\\command"; - systemCmdKey = type + "\\shell\\opennew\\command"; - if (registry.keyExists(WindowsRegistry.HKEY_CURRENT_USER, userCmdKey)) { - browserCommand = registry.getStringValue(WindowsRegistry.HKEY_CURRENT_USER, userCmdKey, ""); - LogManager.log("... using user browser"); - } else if (registry.keyExists(WindowsRegistry.HKEY_CLASSES_ROOT, systemCmdKey)) { - browserCommand = registry.getStringValue(WindowsRegistry.HKEY_CLASSES_ROOT, systemCmdKey, ""); - LogManager.log("... using system browser"); - } - } - LogManager.log("... command : " + browserCommand); - if (browserCommand != null && !browserCommand.equals("")) { - if (browserCommand.contains("%1") && !browserCommand.contains("\"%1\"")) { - browserCommand = browserCommand.replace("%1", "\"%1\""); - } - } - } - } catch (NativeException e) { - LogManager.log(e); - } - } - - public boolean openBrowser(URI uri) { - if (isBrowseSupported()) { - String command = browserCommand.replace("%1", uri.toString()); - try { - LogManager.log("... running : " + command); - Runtime.getRuntime().exec(command); - return true; - } catch (IOException e) { - LogManager.log(e); - - } - } - return false; - } - - @Override - public boolean isBrowseSupported() { - initBrowser(); - return browserCommand!=null; - } - - - private void notifyAssociationChanged() throws NativeException { - notifyAssociationChanged0(); - } - - private class WindowsProcessOnExitCleanerHandler extends ProcessOnExitCleanerHandler { - public WindowsProcessOnExitCleanerHandler(String cleanerDefaultFileName) { - super(cleanerDefaultFileName); - } - protected void writeCleaner(File cleanerFile) throws IOException { - InputStream is = ResourceUtils.getResource(CLEANER_RESOURCE); - FileUtils.writeFile(cleanerFile, is); - is.close(); - } - - protected void writeCleaningFileList(File listFile, List files) throws IOException { - FileUtils.writeStringList(listFile, files, "UNICODE"); - } - - @Override - public void run() { - init(); - if(runningCommand!=null) { - try { - String command = ""; - for(int i=0;i filesList = new ArrayList (); - - @Override - public void addDeleteOnExitFile(File file) { - filesList.add(file); - } - @Override - public void removeDeleteOnExitFile(File file) { - filesList.remove(file); - } - public void run() { - for(File f : filesList) { - f.delete(); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/OnExitCleanerHandler.java b/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/OnExitCleanerHandler.java deleted file mode 100644 index df61201f8b0b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/OnExitCleanerHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.cleaner; - -import java.io.File; - -/** - * - * @author Dmitry Lipin - */ -public abstract class OnExitCleanerHandler extends Thread { - - public abstract void run() ; - - public abstract void removeDeleteOnExitFile(File file); - - public abstract void addDeleteOnExitFile(File file); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/ProcessOnExitCleanerHandler.java b/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/ProcessOnExitCleanerHandler.java deleted file mode 100644 index 6e510f116ef1..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/ProcessOnExitCleanerHandler.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.cleaner; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.ErrorLevel; - -/** - * - * @author Dmitry Lipin - */ - - -public abstract class ProcessOnExitCleanerHandler extends SystemPropertyOnExitCleanerHandler { - protected List runningCommand; - private String cleanerFileName ; - private static final String DELETING_FILES_LIST = "deleteNbiFiles"; - - protected ProcessOnExitCleanerHandler(String cleanerFileName) { - this.cleanerFileName = cleanerFileName; - } - protected File getCleanerFile() throws IOException{ - String name = cleanerFileName; - int idx = name.lastIndexOf("."); - String ext = ""; - if(idx > 0) { - ext = name.substring(idx); - name = name.substring(0, idx); - } - return File.createTempFile(name, ext, SystemUtils.getTempDirectory()); - } - - protected File createTempFileWithFilesList() throws IOException{ - return File.createTempFile(DELETING_FILES_LIST,null, SystemUtils.getTempDirectory()); - } - - protected abstract void writeCleaningFileList(File listFile, List files) throws IOException; - protected abstract void writeCleaner(File cleanerFile) throws IOException; - - public void init(){ - List fileList = getFilesList(); - - if(fileList.size() > 0) { - try { - List paths = new ArrayList(); - for (String s : fileList) { - if (!paths.contains(s)) { - paths.add(s); - } - } - Collections.sort(paths, Collections.reverseOrder()); - File listFile = createTempFileWithFilesList(); - writeCleaningFileList(listFile, paths); - File cleanerFile = getCleanerFile(); - writeCleaner(cleanerFile); - SystemUtils.correctFilesPermissions(cleanerFile); - runningCommand = new ArrayList (); - runningCommand.add(cleanerFile.getCanonicalPath()); - runningCommand.add(listFile.getCanonicalPath()); - } catch (IOException e) { - // do nothing then.. - } - } - } - - public void run() { - init(); - if(runningCommand!=null ) { - try { - ProcessBuilder builder= new ProcessBuilder(runningCommand); - builder.directory(SystemUtils.getUserHomeDirectory()); - builder.start(); - LogManager.log(ErrorLevel.DEBUG, "... cleaning process has been started "); - } catch (IOException ex) { - LogManager.log(ex); - } - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/SystemPropertyOnExitCleanerHandler.java b/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/SystemPropertyOnExitCleanerHandler.java deleted file mode 100644 index 6f1e45b1b255..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/cleaner/SystemPropertyOnExitCleanerHandler.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.cleaner; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Lipin - */ -public class SystemPropertyOnExitCleanerHandler extends OnExitCleanerHandler { - - private static final String FILES_TO_DELETE_PROPERTY = - "nbi.on.exit.delete.files"; - - public SystemPropertyOnExitCleanerHandler() { - if(!isSet()) { - System.setProperty(FILES_TO_DELETE_PROPERTY, ""); - } - } - - public static final boolean isSet() { - return System.getProperty(FILES_TO_DELETE_PROPERTY) != null; - } - - @Override - public void run() { - } - - @Override - public void addDeleteOnExitFile(File file) { - List files = getFilesList(); - String path = file.getAbsolutePath(); - if(!files.contains(path)) { - files.add(path); - System.setProperty(FILES_TO_DELETE_PROPERTY, - StringUtils.asString(files, File.pathSeparator)); - } - } - protected List getFilesList() { - return new ArrayList (StringUtils.asList(System.getProperty( - FILES_TO_DELETE_PROPERTY,""), File.pathSeparator)); - } - - @Override - public void removeDeleteOnExitFile(File file) { - String path = file.getAbsolutePath(); - List list = getFilesList(); - if(list.contains(path)) { - list.remove(path); - System.setProperty(FILES_TO_DELETE_PROPERTY, - StringUtils.asString(list, File.pathSeparator)); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Bundle.properties deleted file mode 100644 index 917ba05c432c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Bundle.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -LP.error.cannot.load.bundle=Can`t load bundle from {0} -LP.error.no.files=There is no files in {0} -LP.error.not.directory={0} is not a directory -LP.error.directory.do.not.exist=Directory {0} does not exist diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Launcher.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Launcher.java deleted file mode 100644 index 5076a16618e2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/Launcher.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import org.netbeans.installer.utils.helper.JavaCompatibleProperties; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.progress.Progress; - -/** - * - * @author Dmitry Lipin - */ -public abstract class Launcher extends LauncherProperties { - - protected Launcher(LauncherProperties pr) { - super(pr); - } - public abstract File create(Progress progress) throws IOException; - public abstract void initialize() throws IOException; - public abstract String [] getExecutionCommand(); - public abstract List getDefaultCompatibleJava(Version version); - public abstract String getExtension(); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherFactory.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherFactory.java deleted file mode 100644 index 79907cc0acde..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers; - -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.system.launchers.impl.CommandLauncher; -import org.netbeans.installer.utils.system.launchers.impl.ExeLauncher; -import org.netbeans.installer.utils.system.launchers.impl.JarLauncher; -import org.netbeans.installer.utils.system.launchers.impl.ShLauncher; - -/** - * - * @author Dmitry Lipin - */ -public final class LauncherFactory { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static Launcher newLauncher( - final LauncherProperties properties, - final Platform platform) { - if (platform.isCompatibleWith(Platform.WINDOWS)) { - return new ExeLauncher(properties); - } - - if (platform.isCompatibleWith(Platform.MACOSX)) { - return new CommandLauncher(properties); - } - - if (platform.isCompatibleWith(Platform.UNIX)) { - return new ShLauncher(properties); - } - - - return new JarLauncher(properties); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private LauncherFactory() { - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java deleted file mode 100644 index 93574f8f824d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers; - -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.PropertyResourceBundle; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.JavaCompatibleProperties; - -/** - * - * @author Dmitry Lipin - */ -public class LauncherProperties implements Cloneable { - protected File stubFile; - protected List jars; - protected List jvms; - protected List otherResources; - - protected HashMap i18nMap; - protected LauncherResource testJVMFile; - protected File outputFile; - protected boolean addExtenstion; - protected List jvmArguments; - protected List appArguments; - protected String mainClass; - protected String testJVMClass; - protected List compatibleJava; - protected String i18nPrefix; - protected String i18nBundleBaseName; - - public LauncherResource getTestJVMFile() { - return testJVMFile; - } - - public LauncherProperties(LauncherProperties nl) { - appArguments = nl.appArguments; - jvmArguments = nl.jvmArguments; - i18nMap = nl.i18nMap; - i18nPrefix = nl.i18nPrefix; - i18nBundleBaseName = nl.i18nBundleBaseName; - jars = nl.jars; - jvms = nl.jvms; - outputFile = nl.outputFile; - addExtenstion = nl.addExtenstion; - compatibleJava = nl.compatibleJava; - mainClass = nl.mainClass; - testJVMClass = nl.testJVMClass; - stubFile = nl.stubFile; - testJVMFile = nl.testJVMFile; - otherResources = nl.otherResources; - } - public LauncherProperties() { - compatibleJava = new ArrayList (); - jvmArguments = new ArrayList (); - appArguments = new ArrayList (); - i18nMap = new HashMap (); - i18nPrefix = null; - i18nBundleBaseName = null; - jars = new ArrayList (); - jvms = new ArrayList (); - otherResources = new ArrayList (); - } - public void setLauncherStub(File launcherStub) { - this.stubFile = launcherStub; - } - - public void addJar(LauncherResource file) { - jars.add(file); - } - public String getMainClass() { - return mainClass; - } - public String getTestJVMClass() { - return testJVMClass; - } - - public void setJvmArguments(String[] jvmArguments) { - this.jvmArguments = new ArrayList (); - for(String s : jvmArguments) { - this.jvmArguments.add(s); - } - } - public void setJvmArguments(List jvmArguments) { - this.jvmArguments = jvmArguments; - } - - public void setI18n(File i18nDir) throws IOException { - loadPropertiesMap(getPropertiesFiles(i18nDir)); - } - - public void setI18n(File [] files) throws IOException { - loadPropertiesMap(files); - } - - public void setI18n(String [] resources) throws IOException { - loadPropertiesMap(resources); - } - - public void setI18n(List resources) throws IOException { - loadPropertiesMap(resources); - } - - public void setI18nPrefix(String i18nPrefix) throws IOException { - this.i18nPrefix = i18nPrefix; - } - public void setI18nBundleBaseName(String i18nBundleBaseName) throws IOException { - this.i18nBundleBaseName = i18nBundleBaseName; - } - public String getI18NResourcePrefix() { - return i18nPrefix; - } - public String getI18NBundleBaseName() { - return i18nBundleBaseName; - } - - public void setOutput(File output) { - setOutput(output, false); - } - - public void setOutput(File output, boolean addExt) { - this.outputFile = output; - this.addExtenstion = addExt; - } - - public void setTestJVM(LauncherResource testJVM) { - this.testJVMFile = testJVM; - } - - public void addCompatibleJava(JavaCompatibleProperties javaProp) { - compatibleJava.add(javaProp); - } - - public void setAppArguments(String[] appArguments) { - this.appArguments = new ArrayList (); - for(String s : appArguments) { - this.appArguments.add(s); - } - } - public void setAppArguments(List appArguments) { - this.appArguments = appArguments; - } - - public File getOutputFile() { - return outputFile; - } - - public List getJars() { - return jars; - } - public List getAppArguments() { - return appArguments; - } - - public List getJvmArguments() { - return jvmArguments; - } - - public List getJavaCompatibleProperties() { - return compatibleJava; - } - - public File getStubFile() { - return stubFile; - } - - public void addJVM(LauncherResource location) { - jvms.add(location); - } - public List getJVMs() { - return jvms; - } - public void setMainClass(String mainClass) { - this.mainClass = mainClass; - } - public void setTestJVMClass(String testClass) { - this.testJVMClass = testClass; - } - HashMap getI18nMap() { - return i18nMap; - } - - public void addOtherResource(LauncherResource resource) { - otherResources.add(resource); - } - - public List getOtherResources() { - return otherResources; - } - - private String getLocaleName(String name) { - String loc = StringUtils.EMPTY_STRING; - int idx = name.indexOf("_"); - int end = name.indexOf(FileUtils.PROPERTIES_EXTENSION); - if(idx!=-1) { - loc = name.substring(idx+1,end); - } - return loc; - } - - private PropertyResourceBundle getBundle(File file) throws IOException { - return getBundle(file.getPath(), new FileInputStream(file)); - } - - private PropertyResourceBundle getBundle(String dest, InputStream is) throws IOException { - if(is==null) { - throw new IOException(ResourceUtils.getString(LauncherProperties.class, - ERROR_CANNOT_LOAD_BUNDLE_KEY, dest)); //NOI18N - } - - try { - return new PropertyResourceBundle(is); - } catch (IOException ex) { - throw new IOException(ResourceUtils.getString(LauncherProperties.class, - ERROR_CANNOT_LOAD_BUNDLE_KEY, dest)); //NOI18N - } finally { - try { - is.close(); - } catch (IOException ex) { - ex=null; - } - } - } - -// resources should be in form of

/// - private void loadPropertiesMap(String [] resources) throws IOException { - i18nMap.clear(); - for(String resource: resources) { - String loc = getLocaleName(ResourceUtils.getResourceFileName(resource)); - i18nMap.put(loc, getBundle(resource, ResourceUtils.getResource(resource))); - } - } - private void loadPropertiesMap(List resources) throws IOException { - String [] array = new String [resources.size()]; - for(int i=0;i getDefaultCompatibleJava(Version version) { - if (version.equals(Version.getVersion("1.5"))) { - List list = new ArrayList (); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_MACOSX, null, null, null, null)); - return list; - } else { - return super.getDefaultCompatibleJava(version); - } - - } - @Override - public void initialize() throws IOException { - super.initialize(); - boolean setDockIcon = true; - boolean setDockName = true; - for(String s : jvmArguments) { - if(s.contains(XDOCK_NAME_PROPERTY_NAME)) { - setDockName = false; - } - if(s.contains(XDOCK_ICON_PROPERTY_NAME)) { - setDockIcon = false; - } - } - - if(setDockIcon && !Boolean.getBoolean(NOTSET_DOCK_ICON_PROPERTY)) { - File iconFile = null; - String uri = System.getProperty(JAVA_APPLICATION_ICON_PROPERTY); - if(uri == null) { - uri = JAVA_APPLICATION_ICON_DEFAULT_URI; - } - - try { - iconFile = FileProxy.getInstance().getFile(uri,true); - LauncherResource iconResource = new LauncherResource (iconFile); - jvmArguments.add(XDOCK_ICON_PROPERTY_NAME + StringUtils.EQUAL + iconResource.getAbsolutePath()); - otherResources.add(iconResource); - } catch (DownloadException e) { - ErrorManager.notify(ResourceUtils.getString( - CommandLauncher.class, ERROR_CANNOT_GET_ICON_KEY, uri), e); - } - } - if(setDockName && !Boolean.getBoolean(NOTSET_DOCK_NAME_PROPERTY)) { - jvmArguments.add(XDOCK_NAME_PROPERTY_NAME + StringUtils.EQUAL + - "$P{" + JAVA_APPLICATION_NAME_LAUNCHER_PROPERTY + "}"); - } - } - - private static final String ERROR_CANNOT_GET_ICON_KEY = - "CdL.error.cannot.get.icon";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java deleted file mode 100644 index c9d48f9c996d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers.impl; - -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.helper.JavaCompatibleProperties; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.system.launchers.Launcher; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.launchers.LauncherResource; -import org.netbeans.installer.utils.progress.Progress; - -/** - * - * @author Dmitry Lipin - */ -public abstract class CommonLauncher extends Launcher { - private static final int BUF_SIZE = 102400; - - protected CommonLauncher(LauncherProperties pr) { - super(pr); - } - protected long addData(FileOutputStream fos, InputStream is, Progress progress, long total) throws IOException{ - byte[] buffer = new byte[BUF_SIZE]; - int readBytes; - int start = progress.getPercentage(); - long totalRead = 0; - long perc = 0; - while (is.available() > 0) { - readBytes = is.read(buffer); - totalRead += readBytes; - fos.write(buffer, 0, readBytes); - if(total!=0) { - perc = (Progress.COMPLETE * totalRead) / total; - progress.setPercentage(start + (int) perc); - } - } - fos.flush(); - return totalRead; - } - - protected long addData(FileOutputStream fos, File file, Progress progress, long total) throws IOException{ - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - return addData(fos,fis,progress,total); - } finally { - if(fis!=null) { - try { - fis.close(); - } catch(IOException ex) { - LogManager.log(ex); - } - } - } - - } - - //add rnd data - protected void addData(FileOutputStream fos) throws IOException { - double rand = Math.random() * Byte.MAX_VALUE; - //fos.write(new byte[] {(byte)rand}); - fos.write(new byte[] {'#'}); - } - - protected long addString(FileOutputStream fos, String string, boolean isUnicode) throws IOException { - byte [] bytes; - if(isUnicode) { - bytes = string.getBytes("UNICODE"); //NOI18N - } else { - bytes = string.getBytes(); - } - fos.write(bytes); - return bytes.length; - } - - protected long addStringBuilder(FileOutputStream fos, StringBuilder builder, boolean isUnicode) throws IOException { - return addString(fos, builder.toString() , isUnicode); - } - - - protected void checkAllParameters() throws IOException { - checkBundledJars(); - checkJvmFile(); - checkOutputFileName(); - checkI18N(); - checkMainClass(); - checkTestJVMFile(); - checkTestJVMClass(); - checkCompatibleJava(); - } - - - - private void checkI18N() throws IOException { - // i18n properties suffix - LogManager.log(ErrorLevel.DEBUG, "Check i18n..."); - String prefix = getI18NResourcePrefix(); - String baseName = getI18NBundleBaseName(); - - if(i18nMap.isEmpty() && prefix!=null && baseName!=null) { - LogManager.log("... i18n properties were not set. using default from resources"); - loadI18n(prefix, baseName); - } - } - - private void loadI18n(String prefix, String baseName) throws IOException { - // load from engine`s entries list - LogManager.log("... loading i18n properties using prefix \"" + prefix + "\" with base name \"" + baseName + "\""); - InputStream is = ResourceUtils.getResource(EngineResources.ENGINE_CONTENTS_LIST); - String[] resources = StringUtils.splitByLines(StreamUtils.readStream(is)); - is.close(); - List list = new ArrayList(); - LogManager.log("... total engine resources: " + resources.length); //NOI18N - for (String res : resources) { - if (res.startsWith(prefix + baseName) && - res.endsWith(FileUtils.PROPERTIES_EXTENSION)) { - list.add(res); - } - } - LogManager.log("... total i18n resources: " + list.size()); //NOI18N - setI18n(list); - } - - protected void checkBundledJars() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking bundled jars..."); - for(LauncherResource f : jars) { - if(f.isBundled()) { - checkParameter("bundled JAR", f.getPath()); - } - } - if(jars.size()==0) { - throw new IOException(ResourceUtils.getString( - CommonLauncher.class, ERROR_NO_JAR_FILES_KEY)); - } - } - - protected void checkJvmFile() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking JVMs..."); - for(LauncherResource file: jvms) { - if(file.isBundled()) { - InputStream is = null; - try { - is = file.getInputStream(); - if(is == null) { - throw new IOException(ResourceUtils.getString( - CommonLauncher.class,ERROR_CANNOT_FIND_JVM_FILE_KEY, file.getPath())); - } - } finally { - if(is!=null) { - try { - is.close(); - } catch (IOException e) { - LogManager.log(e); - } - } - } - - }} - } - - private void checkMainClass() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking main class..."); - // check main-class parameter - // read main class from jar file if it is not specified - if(mainClass==null) { - // get the first - for(LauncherResource file : jars) { - if(file.isBundled() && !file.isBasedOnResource()) { - JarFile jarFile = new JarFile(new File(file.getPath())); - Manifest manifest = jarFile.getManifest(); - jarFile.close(); - if(manifest!=null) { - mainClass = manifest.getMainAttributes(). - getValue(Attributes.Name.MAIN_CLASS); - } - if(mainClass!=null) { - return; - } - } - } - throw new IOException(ResourceUtils.getString(CommonLauncher.class, - ERROR_MAIN_CLASS_UNSPECIFIED_KEY)); - } else{ - for(LauncherResource file : jars) { - if(file.isBundled() && !file.isBasedOnResource() ) { - JarFile jarFile = new JarFile(new File(file.getPath())); - boolean mainClassExists = jarFile.getJarEntry( - ResourceUtils.getResourceClassName(mainClass))!= null; - jarFile.close(); - if(mainClassExists) { - return; - } - } else { - return; - } - } - - throw new IOException(ResourceUtils.getString(CommonLauncher.class, - ERROR_CANNOT_FIND_CLASS_KEY, mainClass)); - } - } - private void checkTestJVMClass() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking testJVM class..."); - if(testJVMClass==null) { - testJVMClass = JavaUtils.TEST_JDK_CLASSNAME; - } - } - - private void checkParameter(String paramDescr, String parameter) throws IOException { - if(parameter==null) { - throw new IOException("Parameter " + paramDescr + " can`t be null"); - } - } - - protected void checkParameter(String paramDescr, File parameter) throws IOException { - if(parameter==null) { - throw new IOException("Parameter " + paramDescr + " can`t be null"); - } - if(!parameter.exists()) { - throw new IOException(paramDescr + " doesn`t exist at " + parameter); - } - } - - protected void checkCompatibleJava() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking compatible java properties..."); - if(compatibleJava.isEmpty()) { - compatibleJava.addAll(getDefaultCompatibleJava(getMinimumJavaVersion())); - } - } - - @Override - public List getDefaultCompatibleJava(Version version) { - final List list = new ArrayList(); - list.add(new JavaCompatibleProperties(version.toJdkStyle(), null, null, null, null)); - return list; - } - - private int getMajorVersion(InputStream is) throws IOException { - DataInputStream classfile = null; - int minor_version = 0; - int major_version = 0; - classfile = new DataInputStream(is); - int magic = classfile.readInt(); - if (magic == 0xcafebabe) { - minor_version = classfile.readUnsignedShort(); - major_version = classfile.readUnsignedShort(); - } - - if (major_version == 45 && minor_version == 3) { - return 1; - } else if (minor_version == 0) { - switch(major_version) { - case 46: return 2; - case 47: return 3; - case 48: return 4; - case 49: return 5; - case 50: return 6; - case 51: return 7; - case 52: return 8; - case 53: return 9; - case 54: return 10; - case 55: return 11; - case 56: return 12; - case 57: return 13; - case 58: return 14; - default : return -1; - } - } else { - return -1; - } - } - private int getMajorVersion(JarFile jar, final String resource) { - - InputStream is = null; - - try { - is = jar.getInputStream(jar.getJarEntry(resource)); - if (is != null) { - return getMajorVersion(is); - } - } catch (IOException e) { - LogManager.log(e); - } finally { - try { - if (is != null) { - is.close(); - } - } catch (IOException e) { - LogManager.log(e); - } - } - return -1; - } - - protected Version getMinimumJavaVersion() { - int majorVersion = -1; - - for (LauncherResource file : jars) { - if (file.isBundled() && !file.isBasedOnResource()) { - File jarFile = new File(file.getPath()); - JarFile jar = null; - try { - jar = new JarFile(jarFile); - Manifest manifest = jar.getManifest(); - String resource = null; - if (manifest != null) { - String mainClassName = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); - if (mainClassName != null) { - resource = ResourceUtils.getResourceClassName(mainClassName); - if(jar.getJarEntry(resource)==null) { - resource = null; - } - } - } - if (resource == null) { - // no main class.. search for other .class resources - Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - if (e.getName().endsWith(".class")) { - resource = e.getName(); - break; - } - } - } - if (resource != null) { - majorVersion = Math.max(majorVersion, getMajorVersion(jar, resource)); - } - } catch (IOException e) { - LogManager.log(e); - } finally { - if (jar != null) { - try { - jar.close(); - } catch (IOException e) { - LogManager.log(e); - } - } - } - } - } - if (majorVersion == -1) { - try { - final String resource = ResourceUtils.getResourceClassName(CommonLauncher.class); - majorVersion = getMajorVersion(ResourceUtils.getResource(resource)); - } catch (IOException e) { - LogManager.log(e); - } - } - - return Version.getVersion((majorVersion == -1) ? - System.getProperty("java.specification.version") : - "1." + majorVersion); - } - protected void checkTestJVMFile() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking testJVM file..."); - if(testJVMFile==null) { - testJVMFile = new LauncherResource(JavaUtils.TEST_JDK_RESOURCE); - } - } - - protected void checkOutputFileName() throws IOException { - LogManager.log(ErrorLevel.DEBUG, "Checking output file name..."); - if(outputFile==null) { - LogManager.log(ErrorLevel.DEBUG, "... output file name is not specified, getting name from the first bundled file"); - String outputFileName = null; - for(LauncherResource file : jars) { - if(file.isBundled() && !file.isBasedOnResource()) { - File jarFile = new File(file.getPath()); - String name = jarFile.getName(); - if(name.endsWith(FileUtils.JAR_EXTENSION)) { - outputFileName = name.substring(0, - name.lastIndexOf(FileUtils.JAR_EXTENSION)); - } - outputFileName += getExtension(); - outputFile = new File(jarFile.getParent(), outputFileName); - break; - } - } - if(outputFile==null) { - String exString = ResourceUtils.getString(CommonLauncher.class, ERROR_CANNOT_GET_OUTPUT_NAME_KEY); - LogManager.log(exString); - throw new IOException(exString); - } - } else if (addExtenstion) { - LogManager.log(ErrorLevel.DEBUG, "... output is defined, adding extension"); - // outfile is defined but we need to set launcher-dependent extension - outputFile = new File(outputFile.getParent(), - outputFile.getName() + getExtension()); - addExtenstion = false; - } - LogManager.log("... out file : " + outputFile); //NOI18N - } - protected String getJavaCounter(int counter) { - return "{" + counter + "}"; - } - protected long getBundledFilesSize() throws IOException { - long total = 0; - - for (LauncherResource jvmFile : jvms) { - total += jvmFile.getSize(); - } - total += testJVMFile.getSize(); - - for (LauncherResource jarFile : jars) { - total += jarFile.getSize(); - } - for(LauncherResource other : otherResources) { - total += other.getSize(); - } - return total; - } - protected long getBundledFilesNumber() { - long total=0; - for (LauncherResource jvmFile : jvms) { - if ( jvmFile .isBundled()) { - total ++; - } - } - if(testJVMFile.isBundled()) { - total++; - } - for (LauncherResource jarFile : jars) { - if ( jarFile.isBundled()) { - total ++; - } - } - for (LauncherResource other : otherResources) { - if (other.isBundled()) { - total ++; - } - } - return total; - } - - private static final String ERROR_NO_JAR_FILES_KEY = - "CnL.error.no.jars";//NOI18N - private static final String ERROR_CANNOT_FIND_JVM_FILE_KEY = - "CnL.error.cannot.find.jvm.file";//NOI18N - private static final String ERROR_CANNOT_FIND_CLASS_KEY = - "CnL.error.cannot.find.class";//NOI18N - private static final String ERROR_MAIN_CLASS_UNSPECIFIED_KEY = - "CnL.error.main.class.unspecified";//NOI18N - private static final String ERROR_CANNOT_GET_OUTPUT_NAME_KEY = - "CnL.error.cannot.get.output.name";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java deleted file mode 100644 index 1beb1d4d7f65..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers.impl; - - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.List; -import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.JavaCompatibleProperties; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.NativeUtils; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.launchers.LauncherResource; - -/** - * - * @author Dmitry Lipin - */ -public class ExeLauncher extends CommonLauncher { - private static final String EXE_EXT = ".exe"; //NOI18N - private static final int EXE_STUB_FILL_SIZE = 450000; - private static final long MAXDWORD = 4294967296L; // actually it is MAXDWORD + 1 - - public static final String DEFAULT_WINDOWS_RESOURCE_SUFFIX = - NativeUtils.NATIVE_LAUNCHER_RESOURCE_SUFFIX + - "windows/"; //NOI18N - public static final String I18N = "i18n"; //NOI18N - public static final String EXE_LAUNCHER_STUB_NAME = "nlw.exe"; //NOI18N - - public static final String EXE_LAUNCHER_STUB = - DEFAULT_WINDOWS_RESOURCE_SUFFIX + EXE_LAUNCHER_STUB_NAME; - public static final String DEFAULT_WINDOWS_RESOURCE_I18N = - DEFAULT_WINDOWS_RESOURCE_SUFFIX + I18N + "/";//NOI18N - public static final String DEFAULT_WINDOWS_RESOURCE_I18N_BUNDLE_NAME = - "launcher"; //NOI18N - /** - * See ShLauncher#MIN_JAVA_VERSION_UNIX for details. - */ - public static final String MIN_JAVA_VERSION_WINDOWS_ALL = "1.8.0"; - public static final String MIN_JAVA_VERSION_WINDOWS = "1.5.0_03"; - public static final String MIN_JAVA_VERSION_WINDOWS_VISTA = "1.5.0_11"; - public static final String MIN_JAVA_VERSION_WINDOWS_2K8 = "1.5.0_17"; - public static final String MIN_JAVA_VERSION_WINDOWS_7 = "1.5.0_19"; - - /* IBM does not report the update number so allow to work even on 1.5.0 */ - public static final String MIN_IBM_JAVA_VERSION = "1.5.0"; - - public static final String OSNAME_WINDOWS = "Windows"; - public static final String OSNAME_WINDOWS_XP = "XP"; - public static final String OSNAME_WINDOWS_VISTA = "Vista"; - public static final String OSNAME_WINDOWS_2K = "2000"; - public static final String OSNAME_WINDOWS_2K3 = "2003"; - public static final String OSNAME_WINDOWS_2K8 = "2008"; - public static final String OSNAME_WINDOWS_7 = "Windows 7"; - - public ExeLauncher(LauncherProperties props) { - super(props); - } - - @Override - public void initialize() throws IOException { - LogManager.log("Checking EXE launcher parameters..."); //NOI18N - checkAllParameters(); - } - - @Override - public File create(Progress progress) throws IOException { - - FileOutputStream fos = null; - try { - progress.setPercentage(Progress.START); - fos = new FileOutputStream(outputFile,false); - - long bundledSize = getBundledFilesSize(); - long total = bundledSize; - if(stubFile!=null) { - total += FileUtils.getSize(stubFile); - } - - addExeInitialStub(fos, progress, total); - - LogManager.log("Adding i18n..."); //NOI18N - addI18NStrings(fos); - - // jvm args - addData(fos,jvmArguments, true); - LogManager.log("JVM Arguments: " + //NOI18N - ((jvmArguments!=null) ? - StringUtils.asString(jvmArguments, " ") : - StringUtils.EMPTY_STRING)); - - // app args - addData(fos,appArguments, true); - LogManager.log("App Arguments: " + //NOI18N - ((appArguments!=null) ? - StringUtils.asString(appArguments, " ") : - StringUtils.EMPTY_STRING)); - - addData(fos, mainClass, true); - LogManager.log("Main Class : " + //NOI18N - mainClass); - - addData(fos, testJVMClass, true); - LogManager.log("TestJVM Class : " + //NOI18N - testJVMClass); - - // add java compatibility properties number - addNumber(fos, Long.parseLong("" + compatibleJava.size())); - addJavaCompatibleProperties(fos); - - //add overall bundled number and size - addNumber(fos, getBundledFilesNumber()); - addNumber(fos, bundledSize, true); - - //add testJVM section - addFileSection(fos, testJVMFile, progress,total); - - //java locations that the launcher should see at first - LogManager.log("Adding JVM external locations and bundled files"); //NOI18N - addData(fos, jvms, progress, total); - - // number of bundled and external jars - LogManager.log("Adding bundled and external jars"); //NOI18N - addData(fos, jars, progress, total); - - // a number of other resources - LogManager.log("Adding other resources"); //NOI18N - addData(fos, otherResources, progress, total); - - } catch (IOException ex) { - LogManager.log(ex); - try { - if(fos!=null) { - fos.close(); - } - } catch (IOException e) { - LogManager.log(e); - } - - try { - FileUtils.deleteFile(outputFile); - } catch (IOException e) { - LogManager.log(e); - } - fos = null; - } finally { - if(fos!=null) { - try { - fos.close(); - } catch (IOException ex) { - LogManager.log(ex.toString()); - throw ex; - } - } - progress.setPercentage(Progress.COMPLETE); - } - - return outputFile; - } - - @Override - public String[] getExecutionCommand() { - return new String [] {outputFile.getAbsolutePath()}; - } - - @Override - public List getDefaultCompatibleJava(Version version) { - if (version.equals(Version.getVersion("1.5"))) { - List list = new ArrayList(); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS_VISTA, null, null, OSNAME_WINDOWS_VISTA, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS, null, null, OSNAME_WINDOWS_XP, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS, null, null, OSNAME_WINDOWS_2K, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS, null, null, OSNAME_WINDOWS_2K3, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS_2K8, null, null, OSNAME_WINDOWS_2K8, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS_7, null, null, OSNAME_WINDOWS_7, null)); - list.add(new JavaCompatibleProperties( - MIN_IBM_JAVA_VERSION, null, "IBM Corporation", null, null)); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_WINDOWS_ALL, null, null, OSNAME_WINDOWS, null)); - return list; - } else { - return super.getDefaultCompatibleJava(version); - } - } - - private String changeJavaPropertyCounter(final String string) { - String str = string; - if(str!=null) { - int counter = 0 ; - while(str.indexOf(getJavaCounter(counter))!=-1) { - str=str.replace(getJavaCounter(counter++), "%s"); - } - } - return str; - } - - private void addExeInitialStub(FileOutputStream fos, Progress progress, long total) throws IOException { - long stubSize; - if(stubFile!=null) { - checkParameter("stub file", stubFile); //NOI18N - stubSize = addData(fos, stubFile,progress, total); - } else { - stubSize = addData(fos, ResourceUtils.getResource(EXE_LAUNCHER_STUB), progress, 0); - } - long length = EXE_STUB_FILL_SIZE - stubSize; - for(long i=0;i props = new LinkedList (); - Enumeration en = defaultBundle.getKeys(); - long numberOfProperties = 0; - while(en.hasMoreElements()) { - en.nextElement(); - numberOfProperties++; - } - addNumber(fos,numberOfProperties); // number of properties - - String propertyName; - en = defaultBundle.getKeys(); - while(en.hasMoreElements()) { - propertyName = en.nextElement(); - props.add(propertyName); - addData(fos, propertyName, false); // save property name as ascii - } - - - addData(fos, defaultBundle, null, StringUtils.EMPTY_STRING, props); - i18nMap.remove(StringUtils.EMPTY_STRING); - Object [] locales = i18nMap.keySet().toArray(); - - for(int i=0;i list, Progress progress, long total) throws IOException{ - addNumber(fos, list.size()); - //add every entry section - LogManager.log("... overall number of files : " + //NOI18N - list.size());//NOI18N - for(LauncherResource file : list) { - LogManager.log(" adding file " + //NOI18N - file.getPath());//NOI18N - addFileSection(fos, file, progress, total); - } - } - private void addData(FileOutputStream fos, List strings, boolean isUnicode) throws IOException { - addData(fos, strings.toArray(new String[0]),isUnicode); - } - private void addData(FileOutputStream fos, String [] strings, boolean isUnicode) throws IOException { - - if(strings!=null) { - addNumber(fos, Integer.valueOf(strings.length).longValue()); // number of array elements - for(String s: strings) { - addData(fos, s, isUnicode); - } - } else { - addNumber(fos, 0L); // no elements - } - - } - - private void addFileSection(FileOutputStream fos, LauncherResource file, Progress progress, long total) throws IOException { - addNumber(fos, file.getPathType().toLong()); - String path; - if(file.isBasedOnResource()) { - path = file.getPathType().getPathString( - ResourceUtils.getResourceFileName(file.getPath())); - } else { - path = file.getAbsolutePath(); - } - addData(fos, path, true); - - if(file.isBundled()) { - addNumber(fos, file.getSize(), true); - InputStream is = null; - try { - is = file.getInputStream(); - addNumber(fos, FileUtils.getCrc32(is), false); - is.close(); - is = file.getInputStream(); - addData(fos, is, progress, total); - is.close(); - is = null; - } finally { - if(is!=null) { - try { - is.close(); - } catch(IOException e) { - LogManager.log(e); - } - } - } - } - } - - private void addData(FileOutputStream fos, PropertyResourceBundle bundle, PropertyResourceBundle backupBundle, String localeName, List propertiesNames) throws IOException { - String propertyName; - String localizedString; - addData(fos, localeName, true); - Enumeration en = bundle.getKeys(); - for(int i=0;i commandList = new ArrayList (); - commandList.add(JavaUtils.getExecutableW(javaLocation).getAbsolutePath()); - commandList.add("-cp"); - String classpath = StringUtils.EMPTY_STRING; - for(LauncherResource jar : jars) { - switch(jar.getPathType()) { - case RELATIVE_JAVAHOME : - classpath+= - new File(javaLocation, jar.getPath()) + - SystemUtils.getPathSeparator(); - break; - case ABSOLUTE : - classpath+= - new File(jar.getPath()) + - SystemUtils.getPathSeparator(); - break; - case RELATIVE_USERHOME: - classpath+= - new File(SystemUtils.getUserHomeDirectory(), jar.getPath()) + - SystemUtils.getPathSeparator(); - break; - case RELATIVE_LAUNCHER_PARENT: - classpath += new File(outputFile.getParentFile(), jar.getPath()) + - SystemUtils.getPathSeparator(); - break; - default: - break; - } - } - commandList.add(classpath); - commandList.addAll(jvmArguments); - commandList.add(mainClass); - commandList.addAll(appArguments); - return commandList.toArray(new String [commandList.size()]); - } - - public List getDefaultCompatibleJava() { - List list = new ArrayList (); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_DEFAULT, null, null, null, null)); - return list; - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java deleted file mode 100644 index 6d695314f539..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.launchers.impl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; -import java.util.PropertyResourceBundle; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.JavaCompatibleProperties; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.launchers.LauncherResource; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.NativeUtils; - -/** - * - * @author Dmitry Lipin - */ -public class ShLauncher extends CommonLauncher { - public static final String SH_LAUNCHER_STUB_NAME = "launcher.sh"; //NOI18N - public static final String DEFAULT_UNIX_RESOURCE_SUFFIX = - NativeUtils.NATIVE_LAUNCHER_RESOURCE_SUFFIX + - "unix/"; //NOI18N - public static final String I18N = "i18n"; //NOI18N - public static final String SH_LAUNCHER_STUB = - DEFAULT_UNIX_RESOURCE_SUFFIX + SH_LAUNCHER_STUB_NAME; - public static final String DEFAULT_UNIX_RESOURCE_I18N = - DEFAULT_UNIX_RESOURCE_SUFFIX + I18N + "/"; //NOI18N - public static final String DEFAULT_UNIX_RESOURCE_I18N_BUNDLE_NAME = - "launcher"; //NOI18N - - private static final String SH_EXT = ".sh"; //NOI18N - private static final int SH_BLOCK = 1024; - private static final String SH_INDENT = " "; //NOI18N - private static final String SH_LINE_SEPARATOR = StringUtils.LF; - private static final String SH_COMMENT = "#"; - - /** - * Minimal supported Java version for the launcher.

- * Due to the URLConnection issues with "spaced" names set this value to 1.5.0_03 - * as these issues were fixed somewhere between Update 1 and Update 3.
- * Related issues: - * 5103449 - * 6181108 - * 6227551 - * 6219199 - * 4979820 - */ - public static final String MIN_JAVA_VERSION_UNIX = "1.5.0_03"; - - /* IBM does not report the update number so allow to work even on 1.5.0*/ - public static final String MIN_IBM_JAVA_VERSION = "1.5.0"; - - private static final String [] JAVA_COMMON_LOCATIONS = { - "/usr/java*", "/usr/java/*", - "/usr/jdk*", "/usr/jdk/*", - "/usr/j2se", "/usr/j2se/*", - "/usr/j2sdk", "/usr/j2sdk/*", - - "/usr/java/jdk*", "/usr/java/jdk/*", - "/usr/jdk/instances", "/usr/jdk/instances/*", - - "/usr/local/java", "/usr/local/java/*", - "/usr/local/jdk*", "/usr/local/jdk/*", - "/usr/local/j2se", "/usr/local/j2se/*", - "/usr/local/j2sdk","/usr/local/j2sdk/*", - - "/opt/java*", "/opt/java/*", - "/opt/jdk*", "/opt/jdk/*", - "/opt/j2sdk", "/opt/j2sdk/*", - "/opt/j2se", "/opt/j2se/*", - - "/usr/lib/jvm", - "/usr/lib/jvm/*", - "/usr/lib/jdk*", - - "/export/jdk*", "/export/jdk/*", - "/export/java", "/export/java/*", - "/export/j2se", "/export/j2se/*", - "/export/j2sdk", "/export/j2sdk/*" - }; - - public ShLauncher(LauncherProperties props) { - super(props); - } - - public void initialize() throws IOException { - LogManager.log("Checking SH launcher parameters..."); // NOI18N - checkAllParameters(); - } - - public File create( Progress progress) throws IOException { - - FileOutputStream fos = null; - try { - - progress.setPercentage(Progress.START); - long total = getBundledFilesSize(); - fos = new FileOutputStream(outputFile,false); - - StringBuilder sb = new StringBuilder(getStubString()); - - addShInitialComment(sb); - addPossibleJavaLocations(sb); - addI18NStrings(sb); - addTestJVMFile(sb); - addClasspathJars(sb); - addJavaCompatible(sb); - addOtherResources(sb); - addNumberVariable(sb, "TOTAL_BUNDLED_FILES_SIZE", getBundledFilesSize()); - addNumberVariable(sb, "TOTAL_BUNDLED_FILES_NUMBER", getBundledFilesNumber()); - - LogManager.log("Main Class : " + mainClass); - addStringVariable(sb, "MAIN_CLASS", mainClass); - - LogManager.log("TestJVM Class : " + testJVMClass); - addStringVariable(sb, "TEST_JVM_CLASS", testJVMClass); - - addNumberVariable(sb, "JVM_ARGUMENTS_NUMBER", jvmArguments.size()); - int counter = 0; - for(String arg : jvmArguments) { - addStringVariable(sb, "JVM_ARGUMENT_" + (counter), - escapeVarSign(escapeSlashes(arg))); - LogManager.log("... jvm argument [" + counter + "] = " + arg); - counter++; - } - - addNumberVariable(sb, "APP_ARGUMENTS_NUMBER", appArguments.size()); - counter = 0; - for(String arg : appArguments) { - addStringVariable(sb, "APP_ARGUMENT_" + (counter), - escapeVarSign(escapeSlashes(arg))); - LogManager.log("... app argument [" + counter + "] = " + arg); - counter++; - } - - - - String token = "_^_^_^_^_^_^_^_^"; // max size: (10^16-1) bytes - - sb.append("LAUNCHER_STUB_SIZE=" + token + SH_LINE_SEPARATOR); - - sb.append("entryPoint \"$@\"" + SH_LINE_SEPARATOR); - nextLine(sb); - - long size = sb.length(); - - long fullBlocks = (size - (size % SH_BLOCK)) / SH_BLOCK + 1; - - String str = Long.toString(fullBlocks); - int spaces = token.length() - str.length(); - - for(int j=0;j < spaces; j++) { - str+= StringUtils.SPACE; - } - - sb.replace(sb.indexOf(token), sb.indexOf(token) + token.length(), str); - - long pads = fullBlocks * SH_BLOCK - size; - - for ( long i=0; i < pads;i++) { - sb.append(SH_COMMENT); - } - addStringBuilder(fos,sb,false); - addBundledData(fos, progress, total); - } catch (IOException ex) { - LogManager.log(ex); - try { - fos.close(); - } catch (IOException e) { - LogManager.log(e); - } - - try { - FileUtils.deleteFile(outputFile); - } catch (IOException e) { - LogManager.log(e); - } - fos = null; - } finally { - - if(fos!=null) { - try { - fos.close(); - } catch (IOException ex) { - LogManager.log(ex); - throw ex; - } - } - progress.setPercentage(Progress.COMPLETE); - } - return outputFile; - } - - public String[] getExecutionCommand() { - return new String [] {outputFile.getAbsolutePath()}; - } - - @Override - public List getDefaultCompatibleJava(Version version) { - if (version.equals(Version.getVersion("1.5"))) { - List list = new ArrayList (); - list.add(new JavaCompatibleProperties( - MIN_JAVA_VERSION_UNIX, null, null, null, null)); - list.add(new JavaCompatibleProperties( - MIN_IBM_JAVA_VERSION, null, "IBM Corporation", null, null)); - return list; - } else { - return super.getDefaultCompatibleJava(version); - } - } - - protected void addOtherResources(StringBuilder sb) throws IOException { - int counter = 0; - addNumberVariable(sb, "OTHER_RESOURCES_NUMBER", otherResources.size()); - - for(LauncherResource resource : otherResources) { - addLauncherResource(sb, resource, "OTHER_RESOURCE_" + counter); - counter ++; - } - - } - - private void addLauncherResource(StringBuilder sb, LauncherResource resource, String id) throws IOException { - long type = resource.getPathType().toLong(); - addNumberVariable(sb, id + "_TYPE", type); //NOI18N - - String path; - if(resource.isBundled()) { - long size = resource.getSize(); - - if(resource.isBasedOnResource()) { - path = resource.getPathType().getPathString( - ResourceUtils.getResourceFileName(resource.getPath())); - } else { - path = resource.getAbsolutePath(); - } - addNumberVariable(sb, id + "_SIZE", size); - addStringVariable(sb, id + "_MD5", resource.getMD5()); - } else { - path = resource.getAbsolutePath(); - } - - - addStringVariable(sb, id + "_PATH", - escapeVarSign(escapeSlashesAndChars(path))); - - } - @Override - public String getI18NResourcePrefix() { - return i18nPrefix != null ? i18nPrefix : - DEFAULT_UNIX_RESOURCE_I18N; - } - @Override - public String getI18NBundleBaseName() { - return i18nBundleBaseName != null ? i18nBundleBaseName : - DEFAULT_UNIX_RESOURCE_I18N_BUNDLE_NAME; - } - - public String getExtension() { - return SH_EXT; - } - - private String escapeChars(String str) { - return (str==null) ? StringUtils.EMPTY_STRING : - str.replace("\n","\\n"). - replace("\t","\\\\t"). - replace("\r","\\\\r"). - replace("`","\\`"). - replace("\"","\\\\\""); - - } - private String escapeSlashesAndChars(String str) { - return escapeSlashes(escapeChars(str)); - } - - private String escapeVarSign(String str) { - return (str==null) ? StringUtils.EMPTY_STRING : - str.replace("$", "\\$"); - } - private String escapeSlashes(String str) { - return (str==null) ? StringUtils.EMPTY_STRING : - str.replace(StringUtils.BACK_SLASH, - StringUtils.DOUBLE_BACK_SLASH); - } - - private String getUTF8(String str, boolean changePropertyCounterStyle) throws UnsupportedEncodingException{ - if(!changePropertyCounterStyle) { - return getUTF8(str); - } else { - String string = StringUtils.EMPTY_STRING; - int maxCounter=0; - while(str.indexOf(getJavaCounter(maxCounter))!=-1) { - maxCounter++; - } - boolean con; - String jc; - for(int i=0;ien = rb.getKeys(); - while(en.hasMoreElements()) { - String name = en.nextElement(); - String value = rb.getString(name); - sb.append(SH_INDENT + "\"" + name + "\")" + SH_LINE_SEPARATOR); - String printString = value; - if(Arrays.equals(printString.getBytes("ISO-8859-1"), printString.getBytes("UTF-8"))) { - printString = escapeChars(changePropertyCounterStyle(printString)); - } else { - printString = getUTF8(printString, true); - } - sb.append(SH_INDENT + SH_INDENT + "printf \"" + printString + "\\n" + "\"" + SH_LINE_SEPARATOR); - sb.append(SH_INDENT + SH_INDENT + ";;" + SH_LINE_SEPARATOR); - - } - sb.append(SH_INDENT + "*)" + SH_LINE_SEPARATOR); - sb.append(SH_INDENT + SH_INDENT + "printf \"$arg\\n\"" + SH_LINE_SEPARATOR); - sb.append(SH_INDENT + SH_INDENT + ";;" + SH_LINE_SEPARATOR); - sb.append(SH_INDENT + "esac" + SH_LINE_SEPARATOR); - sb.append("}" + SH_LINE_SEPARATOR); - nextLine(sb); - } - - } - private void addShInitialComment(StringBuilder sb) throws IOException { - nextLine(sb); - nextLine(sb); - for(int i=0;i<80;i++) { - sb.append(SH_COMMENT); - } - nextLine(sb); - sb.append(SH_COMMENT + " Added by the bundle builder" + //NOI18N - SH_LINE_SEPARATOR); - addNumberVariable(sb,"FILE_BLOCK_SIZE", SH_BLOCK);//NOI18N - nextLine(sb); - } - - private int addJavaPaths(int count, StringBuilder sb, List list) throws IOException { - int counter = count; - for(LauncherResource location : list) { - addLauncherResource(sb, location, "JAVA_LOCATION_" + counter); - counter ++; - } - return counter; - } - private int addJavaPaths(int count, StringBuilder sb, String [] paths) throws IOException { - List list = new ArrayList (); - for(String path : paths) { - list.add(new LauncherResource(LauncherResource.Type.ABSOLUTE, path)); - } - return addJavaPaths(count, sb, list); - } - protected String [] getCommonSystemJavaLocations() { - return JAVA_COMMON_LOCATIONS; - } - private void addPossibleJavaLocations(StringBuilder sb) throws IOException { - int total = 0; - total = addJavaPaths(total, sb, jvms); - total = addJavaPaths(total, sb, getCommonSystemJavaLocations()); - addNumberVariable(sb, "JAVA_LOCATION_NUMBER", total); //NOI18N - nextLine(sb); - } - - private void fillWithPads(FileOutputStream fos, long sz) throws IOException { - long d = (SH_BLOCK - (sz % SH_BLOCK)) % SH_BLOCK; - for ( int i=0; i < d; i++) { - addString(fos, SH_LINE_SEPARATOR, false); - } - } - - private void addLauncherResourceData(FileOutputStream fos, LauncherResource resource, Progress progress, long total) throws IOException { - if(resource.isBundled()) { // if bundle TestJVM - LogManager.log("Bundle testJVM file..."); //NOI18N - InputStream is = null; - try { - String path = resource.getPath(); - LogManager.log("... path is " + path); //NOI18N - is = resource.getInputStream(); - addData(fos, is, progress, total); - fillWithPads(fos, resource.getSize()); - } finally { - try { - if(is!=null) { - is.close(); - } - } catch (IOException ex) { - LogManager.log(ex); - } - } - LogManager.log("... done bundle launcher resource file");//NOI18N - } - } - private void addBundledData(FileOutputStream fos, Progress progress, long total) throws IOException { - addLauncherResourceData(fos, testJVMFile, progress, total); - - for(LauncherResource jvm : jvms) { - addLauncherResourceData(fos, jvm,progress,total); - } - for(LauncherResource jar : jars) { - addLauncherResourceData(fos, jar,progress,total); - } - for(LauncherResource other : otherResources) { - addLauncherResourceData(fos, other,progress,total); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/dockicon.icns b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/dockicon.icns deleted file mode 100644 index 36b0b8c62037..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/dockicon.icns and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/system/resolver/Bundle.properties deleted file mode 100644 index afa681fca58a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -NR.error.cannot.get.default.apps.location=Cannot obtain default applications location -SR.error.cannot.parse.pattern=Cannot parse pattern: {0} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/BundlePropertyResolver.java b/nbi/engine/src/org/netbeans/installer/utils/system/resolver/BundlePropertyResolver.java deleted file mode 100644 index 201c2d33d468..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/BundlePropertyResolver.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.resolver; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.netbeans.installer.utils.ResourceUtils; - -/** - * - * @author Dmitry Lipin - */ -public class BundlePropertyResolver implements StringResolver{ - - public String resolve(String string, ClassLoader loader) { - Matcher matcher; - String parsed = string; - - // P for Properties - matcher = Pattern.compile("(? list; - - public static final String resolve(String string, ClassLoader loader) { - String parsed = string; - if(parsed == null) { - return null; - } - if(list==null) { - list = createStringResolvers(); - } - for(StringResolver resolver : list) { - parsed = resolver.resolve(parsed, loader); - if(parsed == null) { - break; - } - } - return parsed; - } - private static List createStringResolvers() { - List srlist = new ArrayList (); - srlist.add(new NameResolver()); - srlist.add(new BundlePropertyResolver()); - srlist.add(new FieldResolver()); - srlist.add(new MethodResolver()); - srlist.add(new ResourceResolver()); - srlist.add(new SystemPropertyResolver()); - srlist.add(new EnvironmentVariableResolver()); - return srlist; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/SystemPropertyResolver.java b/nbi/engine/src/org/netbeans/installer/utils/system/resolver/SystemPropertyResolver.java deleted file mode 100644 index e5208d50c494..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/resolver/SystemPropertyResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.resolver; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author Dmitry Lipin - */ -public class SystemPropertyResolver implements StringResolver{ - - public String resolve(String string, ClassLoader loader) { - String parsed = string; - Matcher matcher = Pattern.compile("(? arguments; - - public FileShortcut(String name, File target) { - super(name); - setTarget(target); - setArguments(new ArrayList()); - } - - public boolean canModifyPath() { - return modifyPath; - } - - public void setModifyPath(final boolean modifyPath) { - this.modifyPath = modifyPath; - } - - public String getTargetPath() { - return target.getPath(); - } - public File getTarget() { - return target; - } - public void setTarget(File target) { - this.target = target; - } - - - public List getArguments() { - return this.arguments; - } - - public String getArgumentsString() { - if (arguments.size() != 0) { - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < arguments.size(); i++) { - builder.append(arguments.get(i)); - - if (i != arguments.size() - 1) { - builder.append(" "); - } - } - - return builder.toString(); - } else { - return null; - } - } - - public void setArguments(final List arguments) { - this.arguments = arguments; - } - - public void addArgument(final String argument) { - arguments.add(argument); - } - - public void removeArgument(final String argument) { - arguments.remove(argument); - } - @Deprecated - public File getExecutable() { - return getTarget(); - } - @Deprecated - public String getExecutablePath() { - return getTargetPath(); - } - @Deprecated - public void setExecutable(final File executable) { - setTarget(executable); - } - @Deprecated - public boolean canModifyExecutablePath() { - return canModifyPath(); - } - @Deprecated - public void setModifyExecutablePath(final boolean modifyExecutablePath) { - setModifyPath(modifyExecutablePath); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/InternetShortcut.java b/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/InternetShortcut.java deleted file mode 100644 index 5ee8abcd8ec7..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/InternetShortcut.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.shortcut; - -import java.net.URL; - -/** - * - * @author Dmitry Lipin - */ -public class InternetShortcut extends Shortcut { - private URL url; - - public InternetShortcut(final String name, final URL url) { - super(name); - setURL(url); - } - public URL getURL() { - return url; - } - - public void setURL(URL url) { - this.url = url; - } - public String getTargetPath() { - return url.toString(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/LocationType.java b/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/LocationType.java deleted file mode 100644 index 58b7a3c0057c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/LocationType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.shortcut; - -/** - * - * @author Dmitry Lipin - */ -public enum LocationType { - CURRENT_USER_DESKTOP, - ALL_USERS_DESKTOP, - CURRENT_USER_START_MENU, - ALL_USERS_START_MENU, - CUSTOM -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/Shortcut.java b/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/Shortcut.java deleted file mode 100644 index 08ddb58e052b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/shortcut/Shortcut.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.shortcut; - -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import org.netbeans.installer.utils.StringUtils; - -public abstract class Shortcut { - private Map names; - private Map descriptions; - - private String relativePath; - private String fileName; - - - private File workingDirectory; - private File icon; - private int iconIndex; - - private String[] categories; - - private String path; - - private Properties properties; - - - protected Shortcut(final String name) { - setNames(new HashMap()); - setDescriptions(new HashMap()); - setName(name); - setCategories(new String [] {}); - setAdditionalProperties(new Properties()); - } - public Map getNames() { - return names; - } - - public void setNames(final Map names) { - this.names = names; - } - - public String getName() { - return getName(Locale.getDefault()); - } - - public void setName(final String name) { - setName(name, Locale.getDefault()); - } - - public String getName(final Locale locale) { - return StringUtils.getLocalizedString(names,locale); - } - - public void setName(final String name, final Locale locale) { - if (name != null) { - names.put(locale, name); - } else { - names.remove(locale); - } - } - - public Map getDescriptions() { - return descriptions; - } - - public void setDescriptions(final Map comments) { - this.descriptions = comments; - } - - public String getDescription() { - return getDescription(Locale.getDefault()); - } - - public void setDescription(final String description) { - setDescription(description, Locale.getDefault()); - } - - public String getDescription(final Locale locale) { - return StringUtils.getLocalizedString(descriptions,locale); - } - - public void setDescription(final String description, final Locale locale) { - descriptions.put(locale, description); - } - - public String getRelativePath() { - return relativePath; - } - - public void setRelativePath(final String relativePath) { - this.relativePath = relativePath; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(final String fileName) { - this.fileName = fileName; - } - public abstract String getTargetPath(); - - public File getWorkingDirectory() { - return workingDirectory; - } - - public String getWorkingDirectoryPath() { - if (workingDirectory != null) { - return workingDirectory.getAbsolutePath(); - } else { - return null; - } - } - - public void setWorkingDirectory(final File workingDirectory) { - this.workingDirectory = workingDirectory; - } - - public File getIcon() { - return icon; - } - - public String getIconPath() { - if (icon != null) { - return icon.getAbsolutePath(); - } else { - return null; - } - } - - public void setIcon(final File icon) { - this.icon = icon; - } - - public void setIcon(final File icon, int index) { - setIcon(icon); - setIconIndex(index); - } - - - public String[] getCategories() { - return categories; - } - - public void setCategories(final String[] categories) { - this.categories = categories; - } - - public String getPath() { - return path; - } - - public void setPath(final String path) { - this.path = path; - } - - public int getIconIndex() { - return iconIndex; - } - - public void setIconIndex(int iconIndex) { - this.iconIndex = iconIndex; - } - public Properties getAdditionalProperties() { - return properties; - } - - public void setAdditionalProperties(final Properties props) { - this.properties = props; - } - - public void setAdditionalProperty(final String propName, final String propValue) { - properties.put(propName, propValue); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/BourneShell.java b/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/BourneShell.java deleted file mode 100644 index 3bb058c30c01..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/BourneShell.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.unix.shell; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import org.netbeans.installer.utils.helper.EnvironmentScope; - -/** - * - * @author dlm198383 - */ -public class BourneShell extends Shell{ - private String [] SYSTEM_PROFILE_FILES = { - "bashrc", - "profile" - }; - - private String [] USER_PROFILE_HOMEDIRFILES = { - ".bashrc", - ".profile", - ".bash_profile", - ".bash_login", - ".login" - }; - - /** Creates a new instance of Bash */ - public BourneShell() { - } - - public boolean setVar(String name, String value, EnvironmentScope scope) throws IOException { - File file = getShellScript(scope); - if(file==null) { - return false; - } - List strings = getList(file); - - boolean exist = false; - String str; - String substr; - for(int i=0;i strings = getList(file); - - boolean exist = false; - String str; - String substr; - for(int i=0;i strings) { - int idx = 0 ; - int index = strings.size() ; - for(String str:strings) { - idx ++ ; - if(str.startsWith(SET) || str.startsWith(EXPORT) || str.startsWith(SETENV)) { - index = idx; - } - } - return index; - } - protected List getList(File file) throws IOException { - return (file.canRead()) ? - FileUtils.readStringList(file) : - new LinkedList (); - } - protected boolean writeList(List strings, File file) throws IOException{ - if(!file.exists()) { - if(!file.createNewFile()) { - return false; - }; - } - if(file.canWrite()) { - FileUtils.writeStringList(file,strings); - return true; - } - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/TCShell.java b/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/TCShell.java deleted file mode 100644 index 33434c1dd7ab..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/unix/shell/TCShell.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.unix.shell; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import org.netbeans.installer.utils.FileUtils; - -/** - * - * @author dlm198383 - */ -public class TCShell extends CShell{ - private String [] SYSTEM_PROFILE_FILES = { - "tcsh.cshrc", - "tcsh.login", - "profile" - }; - - private String [] USER_PROFILE_HOMEDIRFILES = { - ".tcshrc.user", - ".tcshrc", - ".cshrc.user", - ".cshrc", - ".profile", - ".login" - }; - - public String [] getSystemShellFileNames() { - return SYSTEM_PROFILE_FILES; - } - - public String[] getUserShellFileNames() { - return USER_PROFILE_HOMEDIRFILES; - } - public String [] getAvailableNames() { - return new String [] { "tcsh"}; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/windows/Bundle.properties b/nbi/engine/src/org/netbeans/installer/utils/system/windows/Bundle.properties deleted file mode 100644 index e5a8a24b2e02..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/windows/Bundle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -WR.error.cannot.access.native=Cannot access native method diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/windows/FileExtension.java b/nbi/engine/src/org/netbeans/installer/utils/system/windows/FileExtension.java deleted file mode 100644 index 0bf7d81c25b6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/windows/FileExtension.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.windows; - -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Dmitry Lipin - */ -public class FileExtension { - private String name; - private String description; - private PerceivedType perceivedType; - private String mimeType; - private String icon; - public FileExtension(String extName) { - setName(extName); - } - - protected FileExtension(FileExtension fe) { - name = fe.name; - description = fe.description; - perceivedType = fe.perceivedType; - mimeType = fe.mimeType; - icon = fe.icon; - } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - //remove starting dots - if(name!=null) { - while(name.substring(0,1).equals(StringUtils.DOT)) { - name = name.substring(1); - } - } - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public PerceivedType getPerceivedType() { - return perceivedType; - } - - public void setPerceivedType(PerceivedType perceivedType) { - this.perceivedType = perceivedType; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - public String getDotName() { - return StringUtils.DOT + getName(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/windows/PerceivedType.java b/nbi/engine/src/org/netbeans/installer/utils/system/windows/PerceivedType.java deleted file mode 100644 index 7247f67c3bc0..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/windows/PerceivedType.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.windows; - -/** - * - * @author Dmitry Lipin - */ -public enum PerceivedType { - TEXT, - VIDEO, - AUDIO, - SYSTEM, - IMAGE, - COMPRESSED; - - public String toString() { - switch (this) { - case TEXT: - return "text"; //NOI18N - case VIDEO: - return "video"; //NOI18N - case AUDIO: - return "audio"; //NOI18N - case SYSTEM: - return "system"; //NOI18N - case IMAGE: - return "image"; //NOI18N - case COMPRESSED: - return "compressed"; //NOI18N - default: - return null; - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/windows/SystemApplication.java b/nbi/engine/src/org/netbeans/installer/utils/system/windows/SystemApplication.java deleted file mode 100644 index f90dd32dfab0..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/windows/SystemApplication.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.windows; - -import java.io.File; - -/** - * - * @author Dmitry Lipin - */ -public class SystemApplication { - private String location; - private String friendlyName; - private String command; - private Boolean useByDefault; - private boolean addOpenWithList; - - public SystemApplication(String location) { - this.location = location; - } - public SystemApplication(File file) { - this((file!=null) ? file.getPath() : null); - } - protected SystemApplication(SystemApplication sapp) { - location=sapp.location; - friendlyName=sapp.friendlyName; - command = sapp.command; - useByDefault = sapp.isUseByDefault(); - addOpenWithList = sapp.isAddOpenWithList(); - } - public String getLocation() { - return location; - } - - public void setLocation(String appLocation) { - this.location = appLocation; - } - - public String getFriendlyName() { - return friendlyName; - } - - public void setFriendlyName(String appFriendlyName) { - this.friendlyName = appFriendlyName; - } - - public String getCommand() { - return command; - } - - public void setCommand(String command) { - this.command = command; - } - /** - * @param useByDefault If it is true, then the current app would be set as default.
- * If it is false, then the current app would not be set as default.
- * If it is null, then the current app would be set as default only if there is no default app set for the particular extension yet. - */ - public void setByDefault(Boolean useByDefault) { - this.useByDefault = useByDefault; - } - - public void setOpenWithList(boolean addOpenWithList) { - this.addOpenWithList = addOpenWithList; - } - - public Boolean isUseByDefault() { - return useByDefault; - } - - public boolean isAddOpenWithList() { - return addOpenWithList; - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/system/windows/WindowsRegistry.java b/nbi/engine/src/org/netbeans/installer/utils/system/windows/WindowsRegistry.java deleted file mode 100644 index fec64e308c64..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/system/windows/WindowsRegistry.java +++ /dev/null @@ -1,964 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.system.windows; - -import java.util.Map; -import java.util.Random; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.NativeException; - -/** - * - * @author Dmitry Lipin - * @author Kirill Sorokin - */ -public class WindowsRegistry { - private int mode; - private Boolean wow64process; - ///////////////////////////////////////////////////////////////////////////// - // Instance - - // constructor ////////////////////////////////////////////////////////////// - /** - * - */ - public WindowsRegistry() { - setMode(MODE_DEFAULT); - } - - // queries ////////////////////////////////////////////////////////////////////// - /** - * Checks whether the specified key exists in the registry (can be read). - * - * @param section The section of the registry - * @param key The specified key - * @return true if the specified key exists (can be read), false otherwise - */ - public boolean keyExists(int section, String key) throws NativeException { - validateSection(section); - validateKey(key); - - try { - return checkKeyAccess0(mode,section, key, KEY_READ_LEVEL); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - - public boolean keyExists(int section, String parent, String child) throws NativeException { - //validateSection(section); - validateKey(parent); - validateKeyName(child); - validateParenthood(parent, child); - - try { - return keyExists(section, parent + SEPARATOR + child); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - - /** - * Checks whether the specified value exists in the registry. - * - * @param section The section of the registry - * @param key The specified key - * @param value The specified value - * @return true if the specified value exists, false otherwise - */ - public boolean valueExists(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - - if (keyExists(section, key)) { - try { - return valueExists0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot check for value existance - key does not exist"); - } - } - - /** - * Checks whether the specified value exists in the registry. - * - * @param section The section of the registry - * @param key The specified key - * @param value The specified value - * @return true if the specified value exists, false otherwise - */ - public boolean keyEmpty(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - - if (keyExists(section, key)) { - try { - return keyEmpty0(mode,section, key); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot check -- key does not exist"); - } - } - - /** - * Get the number of the subkeys of the specified key. - * - * @param section The section of the registry - * @param key The specified key - * @return If the key doesn`t exist or can`t be accessed then return -1. - *
Otherwise return the number of subkeys - */ - public int countSubKeys(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - - if (keyExists(section, key)) { - try { - return countSubKeys0(mode,section, key); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot count subkeys -- key does not exist"); - } - } - - /** Get the number of the values of the specified key. - * @param section The section of the registry - * @param key The specified key - * @return If the key doesn`t exist or can`t be accessed then return -1. - *
Otherwise return the number of values - */ - public int countValues(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - - if (keyExists(section, key)) { - try { - return countValues0(mode,section, key); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - - } else { - throw new NativeException("Cannot count values -- key does not exist"); - } - } - - public String[] getSubKeys(int section, String key) throws NativeException { - String[] names = getSubKeyNames(section, key); - String[] subkeys = new String[names.length]; - - for (int i = 0; i < names.length; i++) { - subkeys[i] = constructKey(key, names[i]); - } - - return subkeys; - } - - /** - * Get the array of subkey names of the specified key. - * - * @param section The section of the registry - * @param key The specified key - * @return If the key doesn`t exist or can`t be accessed then return null - *
Otherwise return the array of subkey names - */ - public String[] getSubKeyNames(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - - if (keyExists(section, key)) { - try { - return getSubkeyNames0(mode,section, key); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get subkey names -- key does not exist"); - } - } - - /** Get the array of values names of the specified key. - * @param section The section of the registry - * @param key The specified key - * @return If the key doesn`t exist or can`t be accessed then return null - *
Otherwise return the array of value names - */ - public String[] getValueNames(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - - if (keyExists(section, key)) { - try { - return getValueNames0(mode,section, key); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot list value names -- key does not exist"); - } - } - - /** - * Returns the type of the value. - * - * @param section The section of the registry - * @param key The specified key - * @param value The specified value - * - * @return The possible values are:
- * - * REG_NONE
- * REG_SZ
- * REG_EXPAND_SZ
- * REG_BINARY
- * REG_DWORD=REG_DWORD_LITTLE_ENDIAN
- * REG_DWORD_BIG_ENDIAN
- * REG_LINK
- * REG_MULTI_SZ
- * REG_RESOURCE_LIST
- * REG_FULL_RESOURCE_DESCRIPTOR
- * REG_RESOURCE_REQUIREMENTS_LIST
- * REG_QWORD=REG_QWORD_LITTLE_ENDIAN - */ - public int getValueType(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - return getValueType0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get value type -- value does not exist"); - } - } else { - throw new NativeException("Cannot get value type -- key does not exist"); - } - } - - // key operations /////////////////////////////////////////////////////////////// - /** - * Create the new key in the registry. - * - * @param section The section of the registry - * @param key The specified key - * @return true if the key was successfully created, - *
false otherwise - */ - public void createKey(int section, String key) throws NativeException { - createKey(section, getKeyParent(key), getKeyName(key)); - } - - /** - * Create the new key in the registry. - * - * @param section The section of the registry - * @param parent key The specified parent key - * @param parent key The specified child key - * @return true if the key was successfully created, - *
false otherwise - */ - public void createKey(int section, String parent, String child) throws NativeException { - //validateSection(section); - //validateKey(parent); - //validateKeyName(child); - //validateParenthood(parent, child); - - if (!keyExists(section, parent, child)) { - if (!keyExists(section, parent)) { - createKey(section, getKeyParent(parent), getKeyName(parent)); - } - - try { - createKey0(mode,section, parent, child); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - } - - /** - * Delete the specified key exists in the registry. Note that if the key - * contains subkeys then it would not be deleted. - * - * @param section The section of the registry - * @param key The specified key - * @return true if the specified key was deleted, false otherwise - */ - public void deleteKey(int section, String key) throws NativeException { - deleteKey(section, getKeyParent(key), getKeyName(key)); - } - - /** - * Delete the specified key exists in the registry. - * - * @param section The section of the registry - * @param parentKey The specified parent key - * @param childKey The specified child key - * @return true if the specified key was deleted, false otherwise - */ - public void deleteKey(int section, String parent, String child) throws NativeException { - //validateSection(section); - //validateKey(parent); - //validateKeyName(child); - //validateParenthood(parent, child); - - if (keyExists(section, parent, child)) { - try { - deleteKey0(mode,section, parent, child); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - } - - // value operations ///////////////////////////////////////////////////////////// - /** - * Delete the specified value exists in the registry. - * - * @param section The section of the registry - * @param key The specified key - * @param value The specified value - * @return true if the specified value was deleted, false otherwise - */ - public void deleteValue(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - deleteValue0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - } else { - throw new NativeException("Cannot delete value -- key does not exist"); - } - } - - /** - * - * @param section - * @param key - * @param name - * @return - */ - public String getStringValue(int section, String key, String name) throws NativeException { - return getStringValue(section, key, name, false); - } - - /** Get string value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @param expandable - * If expandable is true and - * the type of the value is REG_EXPAND_SZ the value would be expanded - * @return The value of the name, null in case of any error - */ - public String getStringValue(int section, String key, String name, boolean expand) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - return getStringValue0(mode,section, key, name, expand); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get string value -- value does not exist"); - } - } else { - throw new NativeException("Cannot get string value -- key does not exist"); - } - } - - public void setStringValue(int section, String key, String name, Object value) throws NativeException { - setStringValue(section, key, name, value.toString()); - } - - /** - * - * @param section - * @param key - * @param name - * @param value - */ - public void setStringValue(int section, String key, String name, String value) throws NativeException { - setStringValue(section, key, name, value, false); - } - - /** Set string value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @param value The specified value of the name - * @param expandable - * If expandable is true then the type would be - * REG_EXPAND_SZ or REG_SZ otherwise - * @return true if the value was successfully set - *
false otherwise - */ - public void setStringValue(int section, String key, String name, String value, boolean expandable) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - validateStringValue(value); - - if (keyExists(section, key)) { - try { - setStringValue0(mode,section, key, name, value, expandable); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot set string value -- key does not exist"); - } - } - - /** Get integer value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @return The value of the name, -1 in case of any error - */ - public int get32BitValue(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - return get32BitValue0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get 32-bit value -- value does not exist"); - } - } else { - throw new NativeException("Cannot get 32-bit value -- key does not exist"); - } - } - - /** Set REG_DWORD value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @param value The specified value of the name - * @return true if the value was successfully set - *
false otherwise - */ - public void set32BitValue(int section, String key, String name, int value) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - validate32BitValue(value); - - if (keyExists(section, key)) { - try { - set32BitValue0(mode,section, key, name, value); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot set 32-bit value -- key does not exist"); - } - } - - /** Get the array of strings of the specified value - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @return The multri-string value of the name, null in case of any error - */ - public String[] getMultiStringValue(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - return getMultiStringValue0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get multistring value -- value does not exist"); - } - } else { - throw new NativeException("Cannot get multistring value -- key does not exist"); - } - } - - /** Set REG_MULTI_SZ value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @param value The specified value of the name - * @return true if the value was successfully set - *
false otherwise - */ - public void setMultiStringValue(int section, String key, String name, String[] value) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - validateMultiStringValue(value); - - if (keyExists(section, key)) { - try { - setMultiStringValue0(mode,section, key, name, value); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot set multistring value -- key does not exist"); - } - } - - /** - * Get binary value. - * - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @return The binary value of the name, null in case of any error - */ - public byte[] getBinaryValue(int section, String key, String name) throws NativeException { - //validateSection(section); - //validateKey(key); - //validateValueName(name); - - if (keyExists(section, key)) { - if (valueExists(section, key, name)) { - try { - return getBinaryValue0(mode,section, key, name); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot get binary value -- value does not exist"); - } - } else { - throw new NativeException("Cannot get binary value -- key does not exist"); - } - } - - /** Set binary (REG_BINARY) value. - * @param section The section of the registry - * @param key The specified key - * @param name The specified value - * @param value The specified value of the name - * @return true if the value was successfully set - *
false otherwise - */ - public void setBinaryValue(int section, String key, String name, byte[] value) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - validateBinaryValue(value); - - if (keyExists(section, key)) { - try { - setBinaryValue0(mode,section, key, name, value); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot set binary value -- key does not exist"); - } - } - - /** - * Set new value of REG_NONE type - * - * @param section The section of the registry - * @param key The specified key - * @param value The specified value - */ - public void setNoneValue(int section, String key, String name, byte ... bytes) throws NativeException { - //validateSection(section); - //validateKey(key); - validateValueName(name); - - if (keyExists(section, key)) { - try { - setNoneValue0(mode,section, key, name, bytes); - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } else { - throw new NativeException("Cannot access value -- key does not exist"); - } - } - - public void setAdditionalValues(int section, String key, Map values) throws NativeException { - LogManager.log("setting " + values.size() + " values"); - - for (Map.Entry entry: values.entrySet()) { - final Object value = entry.getValue(); - String name = entry.getKey(); - - LogManager.log(name + " = " + value.toString()); - - if (value instanceof Short) { - LogManager.log("Type is short. Set REG_DWORD value"); - - set32BitValue(section, key, name, ((Short) value).intValue()); - } else if (value instanceof Integer) { - LogManager.log("Type is integer. Set REG_DWORD value"); - - set32BitValue(section, key, name, (Integer) value); - } else if (value instanceof Long) { - LogManager.log("Type is long. Set REG_DWORD value"); - - set32BitValue(section, key, name, ((Long) value).intValue()); - } else if (value instanceof byte[]) { - LogManager.log("Type is byte[]. Set REG_BINARY value"); - - setBinaryValue(section, key, name, (byte[]) value); - } else if (value instanceof String[]) { - LogManager.log("Type is String[]. Set REG_MULTI_SZ value"); - - setMultiStringValue(section, key, name, (String[]) value); - } else if (value instanceof String) { - LogManager.log("Type is String. Set REG_SZ value"); - - setStringValue(section, key, name, (String) value, false); - } else { - LogManager.log("Type can't be determined. Set REG_SZ value"); - - setStringValue(section, key, name, value.toString(), false); - } - } - } - - /** - * Checks whether the specified key exists and can be modified in the registry. - * - * @param section The section of the registry - * @param key The specified key - * @return true if the specified key can exists and can be modified, false otherwise - */ - public boolean canModifyKey(int section, String key) throws NativeException { - //validateSection(section); - //validateKey(key); - try { - if(keyExists(section,key)) { - boolean check = checkKeyAccess0(mode,section, key, KEY_MODIFY_LEVEL); - - if(check) { - // try to create/delete new sub key to be sure that we can modify the parent - // this will require in most cases of vista with UAC enabled - String randomKey = "rndkey" + new Random().nextLong(); - try { - createKey0(mode,section, key, randomKey); - deleteKey0(mode,section, key, randomKey); - } catch (NativeException ex) { - check = false; - } - } - - return check; - } else { - return canModifyKey(section,getKeyParent(key)); - } - } catch (UnsatisfiedLinkError e) { - throw new NativeException(ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING, e); - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public String constructKey(String parent, String child) { - return parent + SEPARATOR + child; - } - - /** - * - * @param key - * @return - */ - public String getKeyParent(String key) { - String temp = key; - - // strip the trailing separators - while (temp.endsWith(SEPARATOR)) { - temp = temp.substring(0, temp.length() - 1); - } - - int index = temp.lastIndexOf(SEPARATOR); - if (index != -1) { - return temp.substring(0, index); - } else { - return StringUtils.EMPTY_STRING; - } - } - - /** - * - * @param key - * @return - */ - public String getKeyName(String key) { - String temp = key; - - // strip the trailing separators - while (temp.endsWith(SEPARATOR)) { - temp = temp.substring(0, temp.length() - 1); - } - - int index = temp.lastIndexOf(SEPARATOR); - if (index != -1) { - return temp.substring(index + 1); - } else { - return temp; - } - } - - - public void setMode(int m) { - if(isModeSupported(m)) { - mode = m; - } - } - - public boolean isAlternativeModeSupported() { - return (IsWow64Process() || System.getProperty("os.arch").equals("amd64")); - } - - public void setMode(Boolean modeChange) { - setMode(modeBooleanToInteger(modeChange)); - } - public boolean isModeSupported(int mode) { - switch (mode) { - case MODE_DEFAULT: - return true; - case MODE_64BIT: - case MODE_32BIT: - return isAlternativeModeSupported(); - default: - return false; - } - } - - public int getMode() { - return mode; - } - public Boolean isAlternativeMode() { - return modeIntegerToBoolean(mode); - } - public boolean IsWow64Process() { - if(wow64process == null) { - wow64process = IsWow64Process0(); - } - return wow64process; - } - - // private ////////////////////////////////////////////////////////////////////// - private Boolean modeIntegerToBoolean(int im) { - if(im==MODE_DEFAULT) { - return null; - } else if(im==MODE_32BIT) { - return System.getProperty("os.arch").equals("amd64"); - } else if(im==MODE_64BIT) { - return IsWow64Process(); - } else { - return null; - } - } - private int modeBooleanToInteger(Boolean bm) { - if(bm == null) { - return MODE_DEFAULT; - } - //running 32-bit application in Windows x64 - if(IsWow64Process()) { - return bm ? MODE_64BIT : MODE_32BIT; - } - //running 64-bit application in Windows x64 - if(System.getProperty("os.arch").equals("amd64")) { - return !bm ? MODE_64BIT : MODE_32BIT; - } - return MODE_DEFAULT; - } - - private void validateSection(int section) throws NativeException { - if ((section < HKEY_CLASSES_ROOT) || (section > HKEY_PERFORMANCE_TEXT)) { - throw new NativeException("Section \"" + section + "\" is " + - "invalid, should be between " + HKEY_CLASSES_ROOT + " " + - "and " + HKEY_PERFORMANCE_TEXT); - } - } - - private void validateKey(String key) throws NativeException { - if (key == null) { - throw new NativeException("Key cannot be null"); - } - } - - private void validateKeyName(String name) throws NativeException { - if (name == null) { - throw new NativeException("Key name cannot be null"); - } - } - - private void validateParenthood(String parent, String child) throws NativeException { - if (parent.equals(child)) { - throw new NativeException("Parent cannot be equal to child"); - } - } - - private void validateValueName(String name) throws NativeException { - if (name == null) { - throw new NativeException("Value name cannot be null"); - } - } - - private void validateStringValue(String value) throws NativeException { - if (value == null) { - throw new NativeException("String value cannot be null"); - } - } - - private void validate32BitValue(int value) throws NativeException { - // it cannot be wrong, but just in case - } - - private void validateMultiStringValue(String[] value) throws NativeException { - if (value == null) { - throw new NativeException("Multistring value cannot be null"); - } - } - - private void validateBinaryValue(byte[] value) throws NativeException { - if (value == null) { - throw new NativeException("Binary value cannot be null"); - } - } - - // native declarations ////////////////////////////////////////////////////// - private native boolean keyExists0(int mode, int section, String key) throws NativeException; - - private native boolean valueExists0(int mode, int section, String key, String value) throws NativeException; - - private native boolean keyEmpty0(int mode, int section, String key) throws NativeException; - - private native int countSubKeys0(int mode, int section, String key) throws NativeException; - - private native int countValues0(int mode, int section, String key) throws NativeException; - - private native String[] getSubkeyNames0(int mode, int section, String key) throws NativeException; - - private native String[] getValueNames0(int mode, int section, String key) throws NativeException; - - private native int getValueType0(int mode, int section, String key, String value) throws NativeException; - - private native void createKey0(int mode, int section, String parent, String child) throws NativeException; - - private native void deleteKey0(int mode, int section, String parent, String child) throws NativeException; - - private native void deleteValue0(int mode, int section, String key, String value) throws NativeException; - - private native String getStringValue0(int mode, int section, String key, String name, boolean expand) throws NativeException; - - private native void setStringValue0(int mode, int section, String key, String name, String value, boolean expandable); - - private native int get32BitValue0(int mode, int section, String key, String name) throws NativeException; - - private native void set32BitValue0(int mode, int section, String key, String name, int value) throws NativeException; - - private native String[] getMultiStringValue0(int mode, int section, String key, String name) throws NativeException; - - private native void setMultiStringValue0(int mode, int section, String key, String name, String[] value) throws NativeException; - - private native byte[] getBinaryValue0(int mode, int section, String key, String name) throws NativeException; - - private native void setBinaryValue0(int mode, int section, String key, String name, byte[] value) throws NativeException; - - private native void setNoneValue0(int mode, int section, String key, String name, Object value) throws NativeException; - - private native boolean checkKeyAccess0(int mode, int section, String key, int level) throws NativeException; - - private native boolean IsWow64Process0(); - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final int HKEY_CLASSES_ROOT = 0; - public static final int HKEY_CURRENT_USER = 1; - public static final int HKEY_LOCAL_MACHINE = 2; - public static final int HKEY_USERS = 3; - public static final int HKEY_CURRENT_CONFIG = 4; - - public static final int HKEY_DYN_DATA = 5; - public static final int HKEY_PERFORMANCE_DATA = 6; - public static final int HKEY_PERFORMANCE_NLSTEXT = 7; - public static final int HKEY_PERFORMANCE_TEXT = 8; - - public static final int HKCR = HKEY_CLASSES_ROOT; - public static final int HKCU = HKEY_CURRENT_USER; - public static final int HKLM = HKEY_LOCAL_MACHINE; - - public static final int REG_NONE = 0; - public static final int REG_SZ = 1; - public static final int REG_EXPAND_SZ = 2; - public static final int REG_BINARY = 3; - public static final int REG_DWORD_LITTLE_ENDIAN = 4; - public static final int REG_DWORD = 4; - public static final int REG_DWORD_BIG_ENDIAN = 5; - public static final int REG_LINK = 6; - public static final int REG_MULTI_SZ = 7; - public static final int REG_RESOURCE_LIST = 8; - public static final int REG_FULL_RESOURCE_DESCRIPTOR = 9; - public static final int REG_RESOURCE_REQUIREMENTS_LIST = 10; - public static final int REG_QWORD_LITTLE_ENDIAN = 11; - public static final int REG_QWORD = 11; - - public static final int MODE_DEFAULT = 0; - public static final int MODE_32BIT = 1; - public static final int MODE_64BIT = 2; - - public static final String SEPARATOR = "\\"; - - private static int KEY_READ_LEVEL = 0; - private static int KEY_MODIFY_LEVEL = 1; - - private static final String ERROR_CANNOT_ACCESS_NATIVE_METHOD_STRING = - ResourceUtils.getString(WindowsRegistry.class, - "WR.error.cannot.access.native");//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/xml/DomExternalizable.java b/nbi/engine/src/org/netbeans/installer/utils/xml/DomExternalizable.java deleted file mode 100644 index 42cb05771bec..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/xml/DomExternalizable.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.xml; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * - * @author Danila_Dugurov - */ - -public interface DomExternalizable { - - void readXML(Element element); - - Element writeXML(Document document); -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/xml/DomUtil.java b/nbi/engine/src/org/netbeans/installer/utils/xml/DomUtil.java deleted file mode 100644 index 281d6f02b258..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/xml/DomUtil.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.xml; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.nio.charset.Charset; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -/** - * - * @author Danila_Dugurov - */ -public class DomUtil { - - private static final DocumentBuilderFactory BUILDER_FACTORY; - private static final TransformerFactory TRANSFORMER_FACTORY; - - static { - BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); - TRANSFORMER_FACTORY = TransformerFactory.newInstance(); - } - - public static Document parseXmlFile(File xmlFile) throws IOException, ParseException { - return parseXmlFile(xmlFile, null); - } - - public static Document parseXmlFile(File xmlFile, Charset charset) throws IOException, ParseException { - final InputStream in = new BufferedInputStream( - new FileInputStream(xmlFile)); - try { - return parseXmlFile(in, charset); - } finally { - try { - in.close(); - } catch (IOException ignord) {//skip - } - } - } - - public static Document parseXmlFile(CharSequence xmlFile) throws ParseException { - try { - final InputStream in = new ByteArrayInputStream( - xmlFile.toString().getBytes(StringUtils.ENCODING_UTF8)); - return parseXmlFile(in); - } catch (UnsupportedEncodingException worntHappend) { - throw new ParseException("utf-8 not supported!", worntHappend); - } catch (IOException worntHappend) { - throw new ParseException("fatal error: I/O mustn't happen here.", worntHappend); - } - } - - public static Document parseXmlFile(InputStream xmlStream, Charset charset) throws IOException, ParseException { - try { - final DocumentBuilder builder = BUILDER_FACTORY.newDocumentBuilder(); - InputSource inputSource; - if (charset != null) { - final Reader reader = new InputStreamReader(xmlStream, charset); - inputSource = new InputSource(reader); - } else { - inputSource = new InputSource(xmlStream); - } - return builder.parse(inputSource); - } catch (ParserConfigurationException worntHappend) { - throw new ParseException("parse configuration error.", worntHappend); - } catch (SAXException ex) { - throw new ParseException("parsing error occuers!", ex); - } - } - - public static Document parseXmlFile(InputStream xmlStream) throws IOException, ParseException { - return parseXmlFile(xmlStream, null); - } - - public static void writeXmlFile(Document document, OutputStream outputStream, Charset charset) throws IOException { - try { - final Source domSource = new DOMSource(document); - Result output; - if (charset != null) { - final Writer writer = new PrintWriter(new OutputStreamWriter(outputStream, charset)); - output = new StreamResult(writer); - } else { - output = new StreamResult(outputStream); - } - final Transformer transformer = TRANSFORMER_FACTORY.newTransformer(); - transformer.transform(domSource, output); - //think :check. is it really flushed here or some action should be done - } catch(TransformerConfigurationException worntHappend) { - throw new IOException(worntHappend.getMessage()); - } catch(TransformerException ex) { - throw new IOException(ex.getMessage()); - } - } - - public static void writeXmlFile(Document document, OutputStream outputStream) throws IOException { - writeXmlFile(document, outputStream, null); - } - - public static void writeXmlFile(Document document, File file) throws IOException { - writeXmlFile(document, file, null); - } - - public static void writeXmlFile(Document document, File file, Charset charset) throws IOException { - OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); - try { - writeXmlFile(document, out, charset); - } finally { - try { - out.close(); - } catch (IOException ignord) {//skip - } - } - } - - public static void addChild(Element parent, T object) { - parent.appendChild(object.writeXML(parent.getOwnerDocument())); - } - - public static void addElement(Element parent, String elemName, String elemText) { - final Element child = parent.getOwnerDocument().createElement(elemName); - child.setTextContent(elemText); - parent.appendChild(child); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/xml/reformat.xslt b/nbi/engine/src/org/netbeans/installer/utils/xml/reformat.xslt deleted file mode 100644 index 6884f6b13c68..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/xml/reformat.xslt +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/DomVisitor.java b/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/DomVisitor.java deleted file mode 100644 index 4b4779bedf01..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/DomVisitor.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.xml.visitors; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.Text; - -/** - * - * @author Danila_Dugurov - */ -public class DomVisitor { - - public void visit(Node node) { - final Class clazz = node.getClass(); - if (Element.class.isAssignableFrom(clazz)) { - visit((Element) node); - } else if (Document.class.isAssignableFrom(clazz)) { - visit((Document) node); - } else if (Text.class.isAssignableFrom(clazz)) { - visit((Text) node); - } else { - throw new RuntimeException("Unhandled node class type " + clazz.getName()); - } - } - - public void visit(Document document) { - visit(document.getDocumentElement()); - } - - public void visit(Element element) { - } - - public void visit(Text text) { - } -} diff --git a/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/RecursiveDomVisitor.java b/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/RecursiveDomVisitor.java deleted file mode 100644 index 86fce7a5e30d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/utils/xml/visitors/RecursiveDomVisitor.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.utils.xml.visitors; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -/** - * - * @author Danila_Dugurov - */ - -public class RecursiveDomVisitor extends DomVisitor { - - public void visit(Element element) { - final NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - visit(children.item(i)); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/Bundle.properties deleted file mode 100644 index ecec098970c6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/Bundle.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# Wizard.java -W.error.failed.to.create.instance=Failed to create the default Wizard instance. -W.error.failed.to.load.components=Failed to load wizard components from {0}, using classloader {1}. -W.error.failed.to.load.component=Failed to load wizard component from XML element {0}, using classloader {1}. -W.error.unknown.ui.mode=Unknown UI mode - {0}. -W.error.cannot.move.backward.silent=Cannot move backward in silent UI mode. -W.error.cannot.move.backward.at.first=Cannot move backward - the wizard is already at the first element. -W.error.parser.unsupports.schemas=The current parser - {0} - does not support schemas. -W.error.interrupted=Interrupted while waiting diff --git a/nbi/engine/src/org/netbeans/installer/wizard/Wizard.java b/nbi/engine/src/org/netbeans/installer/wizard/Wizard.java deleted file mode 100644 index d664ac2e3424..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/Wizard.java +++ /dev/null @@ -1,994 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import org.netbeans.installer.utils.helper.PropertyContainer; -import org.netbeans.installer.utils.helper.UiMode; -import org.netbeans.installer.wizard.components.WizardComponent; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.FinishHandler; -import org.netbeans.installer.utils.helper.Context; -import org.netbeans.installer.wizard.containers.SilentContainer; -import org.netbeans.installer.wizard.containers.WizardContainer; -import org.netbeans.installer.wizard.containers.SwingFrameContainer; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -/** - * This is the main class of the NBI Wizard framework. It represents the wizard as - * a whole. - * - *

- * The wizard serves a the main source of the data input by the user. It is - * organized as a series of pages, each either informing the user about something - * or displaying an input field. The input validation also happens here. - * - *

- * The wizard is a singleton in some sense, i.e. only one instance of {@link Wizard} - * can be created directly, via the {@link #getInstance()} method. All other - * instances that may be created during the course of wizard's workflow will be the - * so-called child wizards. - * - *

- * The wizard operates over a list of {@link WizardComponent}s. In order to add - * "depth", the user needs to create sub-wizards which would have their own - * sequences of components, but will appear as a single component to the parent - * wizard. This effect can be obtained via the - * {@link org.netbeans.installer.wizard.components.WizardSequence} component. - * - *

- * Context. Each wizard can have an associated context. A {@link Context} is a - * simple collection of objects which can be fetched by their class. The context is - * assigned to a wizard at runtime, thus it is possible to switch contexts basing - * on some conditions. The context is intended to be read-only, though it is - * possible to add new objects to it. The most common usecase for a context would - * be passing an instance of an object to all the components of a wizard. - * - *

- * Property container. Since the princial use case for a wizard is collecting some - * user input, the values entered by the user need to be stored somewhere. For this - * purpose a wizard has an associated {@link PropertyContainer}. It serves as a - * storage for the user-entered strings. - * - *

- * The root wizard instance will load its list of components from an URI defined in - * the system property {@link #COMPONENTS_INSTANCE_URI_PROPERTY}, if the property is - * not set, then it falls back to the {@link #DEFAULT_COMPONENTS_INSTANCE_URI}. For - * child wizards, created with one of the - * {@link #createSubWizard(List,int)} methods, expect that their lists of components - * will be passed in directly. The list of components can be constructed using the - * {@link #loadWizardComponents(String)} method. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public class Wizard { - ///////////////////////////////////////////////////////////////////////////////// - // Static - /** - * The instance of the root wizard. - */ - private static Wizard instance; - - /** - * URI which points to the list of components for the root wizard instance. - */ - private static String componentsInstanceUri; - - /** - * URI which points to the XML Schema which will be used to validate the list - * of wizard components stored in XML format. - */ - private static String componentsSchemaUri; - - /** - * Returns the instance of the root {@link Wizard}. If the instance does not - * exist - it is created and all system properties that make sense for the - * {@link Wizard} are parsed: {@link #COMPONENTS_INSTANCE_URI_PROPERTY} and - * {@link #COMPONENTS_SCHEMA_URI_PROPERTY}. - * - * @return The instance of the root {@link Wizard}. - */ - public static synchronized Wizard getInstance() { - if (instance == null) { - // initialize uri for root wizard's components list - if (System.getProperty(COMPONENTS_INSTANCE_URI_PROPERTY) != null) { - componentsInstanceUri = - System.getProperty(COMPONENTS_INSTANCE_URI_PROPERTY); - } else { - componentsInstanceUri = DEFAULT_COMPONENTS_INSTANCE_URI; - } - - // initialize uri for components list xml schema - if (System.getProperty(COMPONENTS_SCHEMA_URI_PROPERTY) != null) { - componentsSchemaUri = - System.getProperty(COMPONENTS_SCHEMA_URI_PROPERTY); - } else { - componentsSchemaUri = DEFAULT_COMPONENTS_SCHEMA_URI; - } - - // create the root wizard and load its components - instance = new Wizard(); - try { - instance.components = loadWizardComponents(componentsInstanceUri); - } catch (InitializationException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - Wizard.class, RESOURCE_FAILED_TO_CREATE_INSTANCE), e); - } - } - - return instance; - } - - /** - * Loads the list of {@link WizardComponent} from an XML file identified by its - * URI. The URI can be of any scheme supported by the - * {@link org.netbeans.installer.downloader.DownloadManager}. - * - * @param componentsUri URI of the XML file which contains the list of - * {@link WizardComponent}s. - * @return The list of {@link WizardComponent} defined in the XML file. - * @throws org.netbeans.installer.utils.exceptions.InitializationException If an - * error occurs during loading of the list. - */ - public static List loadWizardComponents( - final String componentsUri) throws InitializationException { - return loadWizardComponents(componentsUri, Wizard.class.getClassLoader()); - } - - /** - * Loads the list of {@link WizardComponent} from an XML file identified by its - * URI and using the specified {@link ClassLoader} to load the components' - * classes. The URI can be of any scheme supported by the - * {@link org.netbeans.installer.downloader.DownloadManager}. - * - * @param componentsUri URI of the XML file which contains the list of - * {@link WizardComponent}. - * @param classLoader Instance of {@link ClassLoader} which should be used for - * loading the components' classes. - * @return The list of {@link WizardComponent} defined in the XML file. - * @throws org.netbeans.installer.utils.exceptions.InitializationException If an - * error occurs during loading of the list. - */ - public static List loadWizardComponents( - final String componentsUri, - final ClassLoader classLoader) throws InitializationException { - try { - final File schemaFile = FileProxy.getInstance().getFile( - componentsSchemaUri, - classLoader, true); - final File componentsFile = FileProxy.getInstance().getFile( - componentsUri, - classLoader, true); - - final Schema schema = SchemaFactory. - newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI). - newSchema(schemaFile); - - final DocumentBuilderFactory factory = - DocumentBuilderFactory.newInstance(); - try { - factory.setSchema(schema); - } catch (UnsupportedOperationException e) { - // if the parser does not support schemas, let it be -- we can do - // without it anyway -- just log it and proceed - ErrorManager.notifyDebug( - ResourceUtils.getString(Wizard.class, - RESOURCE_PARSER_UNSUPPORTS_SCHEMAS,factory.getClass()), - e); - } - factory.setNamespaceAware(true); - - final Document document = factory.newDocumentBuilder(). - parse(componentsFile); - - return loadWizardComponents(document.getDocumentElement(), classLoader); - } catch (DownloadException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENTS, - componentsUri, - classLoader), e); - } catch (ParserConfigurationException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENTS, - componentsUri, - classLoader), e); - } catch (SAXException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENTS, - componentsUri, - classLoader), e); - } catch (IOException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENTS, - componentsUri, - classLoader), e); - } - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Loads the list of {@link WizardComponent} from the DOM tree identified by its - * root {@link Element} using the specified {@link ClassLoader} to load the - * components' classes. - * - * @param element Root of the DOM tree from which to load the list. - * @param classLoader Instance of {@link ClassLoader} which should be used for - * loading the components' classes. - * @return The list of {@link WizardComponent} defined in the DOM tree. - * @throws org.netbeans.installer.utils.exceptions.InitializationException If an - * error occurs during loading of the list. - */ - private static List loadWizardComponents( - final Element element, - final ClassLoader classLoader) throws InitializationException { - final List components = new LinkedList(); - - for (Element child: XMLUtils.getChildren(element, TAG_COMPONENT)) { - components.add(loadWizardComponent(child, classLoader)); - } - - return components; - } - - /** - * Loads a single {@link WizardComponent} from a DOM {@link Element} using the - * specified {@link ClassLoader} to load the component's class. - * - * @param element DOM {@link Element} from which the component's data should be - * loaded. - * @param classLoader Instance of {@link ClassLoader} which should be used for - * loading the component's class. - * @return The loaded {@link WizardComponent}. - * @throws org.netbeans.installer.utils.exceptions.InitializationException If an - * error occurs during loading of the component. - */ - private static WizardComponent loadWizardComponent( - final Element element, - final ClassLoader classLoader) throws InitializationException { - final WizardComponent component; - - try { - component = (WizardComponent) classLoader.loadClass( - element.getAttribute(ATTRIBUTE_CLASS)).newInstance(); - - Element child = XMLUtils.getChild(element, TAG_COMPONENTS); - if (child != null) { - component.addChildren(loadWizardComponents(child, classLoader)); - } - - child = XMLUtils.getChild(element, TAG_PROPERTIES); - if (child != null) { - component.getProperties().putAll(XMLUtils.parseNbiProperties(child)); - } - } catch (ParseException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENT, - element, - classLoader), e); - } catch (ClassNotFoundException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENT, - element, - classLoader), e); - } catch (IllegalAccessException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENT, - element, - classLoader), e); - } catch (InstantiationException e) { - throw new InitializationException(ResourceUtils.getString( - Wizard.class, - RESOURCE_FAILED_TO_LOAD_COMPONENT, - element, - classLoader), e); - } - - return component; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * List of the {@link WizardComponent} over which the {@link Wizard} should - * iterate. - */ - private List components; - - /** - * Container which should display the UI of the wizard. - */ - private WizardContainer container; - - /** - * Storage for the user input in the panels of the wizard. - */ - private PropertyContainer propertyContainer; - - /** - * {@link Wizard}'s {@link Context}. - */ - private Context context; - - /** - * {@link ClassLoader} that should be used by the wizard. E.g. for loading - * resources. - */ - private ClassLoader classLoader; - - /** - * Index of the currently active component. - */ - private int index; - - /** - * Parent of the {@link Wizard}. It is null if the current - * {@link Wizard} is the root one. - */ - private Wizard parent; - - /** - * Handler of the cancel and finish requests which - * happen either by user request or as part of the normal wizard work flow. - */ - private FinishHandler finishHandler; - - /** - * Specifies whether the wizard is opened in blocking mode. If it is, the - * opening method {@link #openBlocking()} will not return intil the wizard is - * closed from another thread. - */ - private boolean blocking; - - // constructors ///////////////////////////////////////////////////////////////// - /** - * Default constructor. Performs initialization of the basic properties, which, - * however, is not enough for normal operation - the list of - * {@link WizardComponent} is not initialized. - */ - public Wizard() { - this.index = -1; - this.context = new Context(); - this.classLoader = getClass().getClassLoader(); - - this.blocking = false; - } - - /** - * Constructs a new instance of {@link Wizard} with the given parent. Most of - * the properties of the new instance are inherited from the parent. - * - * @param parent Parent {@link Wizard}. - */ - public Wizard( - final Wizard parent) { - this(); - - this.parent = parent; - if (this.parent != null) { - this.container = parent.container; - - this.propertyContainer = parent.propertyContainer; - this.context = new Context(parent.context); - this.classLoader = parent.classLoader; - - this.finishHandler = parent.finishHandler; - } - } - - /** - * Constructs a new instance of {@link Wizard} with the given parent, list of - * {@link WizardComponent} and inital index of the active component. - * - * @param parent Parent {@link Wizard}. - * @param components List of {@link WizardComponent}s over which the wizard - * should iterate. - * @param index Initial index of the active component. - */ - public Wizard( - final Wizard parent, - final List components, - int index) { - this(parent); - - this.components = components; - this.index = index; - } - - /** - * Constructs a new instance of {@link Wizard} with the given parent, list of - * {@link WizardComponent}, inital index of the active component, properties - * container and classloader. - * - * @param parent Parent {@link Wizard}. - * @param components List of {@link WizardComponent} over which the wizard - * should iterate. - * @param index Initial index of the active component. - * @param propertyContainer {@link PropertyContainer} which should be used by - * the wizard. - * @param classLoader {@link ClassLoader} which should be used by the wizard. - */ - public Wizard( - final Wizard parent, - final List components, - final int index, - final PropertyContainer propertyContainer, - final ClassLoader classLoader) { - this(parent, components, index); - - this.propertyContainer = propertyContainer; - this.classLoader = classLoader; - } - - private WizardContainer newWizardContainer() { - // then create the container according to the current UI mode - switch (UiMode.getCurrentUiMode()) { - case SWING: - // init the look and feel - // we have to do it here, not in SwingFrameContainer because - // we must to initialize L&F before calling JFrame constructor because of - // using JFrame.setDefaultLookAndFeelDecorated - try { - UiUtils.initializeLookAndFeel(); - } catch (InitializationException e) { - // error in UI init, no UI is available, no warning dialog can't be opened - UiMode.setCurrentUiMode(UiMode.SILENT); - ErrorManager.notifyCritical(e.getMessage(), e.getCause()); - } - return new SwingFrameContainer(); - case SILENT: - return new SilentContainer(); - default: - ErrorManager.notifyCritical(ResourceUtils.getString( - Wizard.class, - RESOURCE_UNKNOWN_UI_MODE, - UiMode.getCurrentUiMode())); - return null; - } - } - - // wizard lifecycle control methods ///////////////////////////////////////////// - /** - * Opens the wizard. Depending on the current UI mode, an appropriate - * {@link WizardContainer} is chosen, initialized and set to be visible. No - * wizard container is created if the UI Mode is {@link UiMode#SILENT}. - * - *

- * If the current wizard is not the root one - the parent's {@link #open()} - * method is called. - */ - public void open() { - // if a parent exists, ask it - it knows better - if (parent != null) { - parent.open(); - return; - } - - // then create the container according to the current UI mode - container = newWizardContainer(); - - if (container!=null) { - container.open(); - } - next(); - } - - /** - * Opens the wizard in a blocking mode. As opposed to {@link #open()}, this - * method will not return the wizard is closed from another thread. - * - * @see #open() - */ - public void openBlocking() { - this.blocking = true; - - open(); - - while (blocking) { - try { - wait(); - } catch (InterruptedException e) { - ErrorManager.notifyDebug(ResourceUtils.getString( - Wizard.class, RESOURCE_INTERRUPTED), e); - } - } - } - - /** - * Closes the wizard. The current {@link WizardContainer} is hidden and - * deinitialized. No real action is taken if the UI mode is - * {@link UiMode#SILENT}. - * - *

- * If the current wizard is not the ro ot one - the parent's {@link #close()} - * method is called. - */ - public void close() { - // if a parent exists, ask it - it knows better - if (parent != null) { - parent.close(); - return; - } - - // if the container has not yet been initialized -- we do not need to - // do anything with it - if (container!=null) { - container.close(); - } - - if (blocking) { - blocking = false; - notifyAll(); - } - } - - // component flow control methods /////////////////////////////////////////////// - /** - * Proceeds to the next element in the wizard. If the next element is not - * available and the current wizard instance is the root one, then the wizard is - * considered to be at the last element and the wizard's - * {@link FinishHandler#finish()} is called. - * - *

- * If the current wizard is not the root instance and there is no next component, - * then the parent wizard's {@link #next()} method is called. - */ - public void next() { - final WizardComponent component = getNext(); - - // if there is no next component in the current wizard, try to delegate - // the call to the parent wizard, and if there is no parent wizard... finish - // the sequence, and call the finish handler - if (component != null) { - index = components.indexOf(component); - - component.setWizard(this); - component.initialize(); - if (container!=null) { - container.updateWizardUi(component.getWizardUi()); - } - System.setProperty( - CURRENT_COMPONENT_CLASSNAME_PROPERTY, - component.getClass().getName()); - - component.executeForward(); - } else if (parent != null) { - parent.next(); - } else { - finishHandler.finish(); - } - } - - /** - * Moves to the previous element in the wizard. If the previous component is not - * available and the current wizard instance is the root one a critical error is - * shown and the application terminates. - * - *

- * If the current wizard is not the root one and there is no previous component - * in the current sequence, the parent's {@link #previous()} method is called. - */ - public void previous() { - final WizardComponent component = getPrevious(); - - // if there is no previous component in the current wizard, try to delegate - // the call to the parent wizard, and if there is no parent wizard... we - // should be here in the first place - if (component != null) { - index = components.indexOf(component); - - component.setWizard(this); - component.initialize(); - if (container!=null) { - container.updateWizardUi(component.getWizardUi()); - } - - System.setProperty( - CURRENT_COMPONENT_CLASSNAME_PROPERTY, - component.getClass().getName()); - - component.executeBackward(); - } else if (parent != null) { - parent.previous(); - } else { - ErrorManager.notifyCritical(ResourceUtils.getString( - Wizard.class, - RESOURCE_CANNOT_MOVE_BACKWARD_AT_FIRST)); - } - } - - // informational methods //////////////////////////////////////////////////////// - /** - * Checks whether there is exists a component which can be reached using the - * {@link #next()} method. This method checks both the components of the - * current wizard and the parent one. - * - * @return true is there is a next element, false - * otherwise. - */ - public boolean hasNext() { - // if there is no next component in the current wizard, we should check the - // parent wizard if it has one - return (getNext() != null) || ((parent != null) && parent.hasNext()); - } - - /** - * Checks whether there is exists a component which can be reached using the - * {@link #previous()} method. This method checks both the components of the - * current wizard and the parent one. - * - * @return true is there is a previous element, false - * otherwise. - */ - public boolean hasPrevious() { - // if current component is a point of no return - we cannot move backwards, - // i.e. there is no previous component - if ((getCurrent() != null) && getCurrent().isPointOfNoReturn()) { - return false; - } - - for (int i = index - 1; i > -1; i--) { - final WizardComponent component = components.get(i); - - // if the component can be executed backward it is the previous one - if (component.canExecuteBackward()) { - return true; - } - - // if the currently examined component is a point of no return and it - // cannot be executed (since we passed the previous statement) - we have - // no previous component - if (component.isPointOfNoReturn()) { - return false; - } - } - - // if we got this far, there is not previous component in the current wizard, - // but no points of no return we encountered either. thus we should ask the - // parent wizard if it has a previous component - return (parent != null) && parent.hasPrevious(); - } - - // getters/setters ////////////////////////////////////////////////////////////// - /** - * Returns the index of the currently active component. - * - * @return Index of the currently active component. - */ - public int getIndex() { - return index; - } - - /** - * Returns the {@link WizardContainer} which is used by this {@link Wizard} - * instance. - * - * @return {@link WizardContainer} which is used by this {@link Wizard} - * instance. - */ - public WizardContainer getContainer() { - return container; - } - - /** - * Gets the value of the property with the given name. This method in turn calls - * the {@link PropertyContainer#getProperty(String)} method on the property - * container used by this wizard instance. - * - * @param name Name of the property whose value should be obtained. - * @return Value of the specified property, or null is the property - * with the given name does not exist. - */ - public String getProperty(final String name) { - return propertyContainer.getProperty(name); - } - - /** - * Sets the value of the property with the given name to the given value. This - * method in turn calls the {@link PropertyContainer#setProperty(String,String)} - * method on the property container used by this wizard instance. - * - * @param name Name of the property whose value should be set. - * @param value New value for the property. - */ - public void setProperty(final String name, final String value) { - propertyContainer.setProperty(name, value); - } - - /** - * Returns the {@link Context} of this {@link Wizard} instance. - * - * @return {@link Context} of this {@link Wizard} instance. - */ - public Context getContext() { - return context; - } - - /** - * Returns the {@link ClassLoader} used by this {@link Wizard} instance. - * - * @return {@link ClassLoader} used by this {@link Wizard} instance. - */ - public ClassLoader getClassLoader() { - return classLoader; - } - - /** - * Returns the {@link FinishHandler} used by this {@link Wizard} instance. - * - * @return {@link FinishHandler} used by this {@link Wizard} instance. - */ - public FinishHandler getFinishHandler() { - return finishHandler; - } - - /** - * Sets the {@link FinishHandler} which should be used by this {@link Wizard} - * instance. - * - * - * @param finishHandler {@link FinishHandler} which should be used by this - * {@link Wizard} instance. - */ - public void setFinishHandler(final FinishHandler finishHandler) { - this.finishHandler = finishHandler; - } - - // factory methods for children ///////////////////////////////////////////////// - /** - * Creates a new child (or sub-) wizard with the given list of - * {@link WizardComponent}s and the initial index of the active component. - * - * @param components List of {@link WizardComponent}s over which the child - * wizard should iterate. - * @param index Initial index of the active component. - * @return New child (sub-) wizard. - */ - public Wizard createSubWizard( - final List components, - final int index) { - return new Wizard(this, components, index); - } - - /** - * Creates a new child (or sub-) wizard with the given list of - * {@link WizardComponent}s, initial index of the active component, property - * container and class loader. - * - * @param components List of {@link WizardComponent}s over which the child - * wizard should iterate. - * @param index Initial index of the active component. - * @param propertyContainer {@link PropertyContainer} which should be used by - * the child wizard. - * @param classLoader {@link ClassLoader} which should be used by the child - * wizard. - * @return New child (sub-) wizard. - */ - public Wizard createSubWizard( - final List components, - final int index, - final PropertyContainer propertyContainer, - final ClassLoader classLoader) { - return new Wizard(this, components, index, propertyContainer, classLoader); - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Returns the currently active {@link WizardComponent}. - * - * @return Currently active {@link WizardComponent}, or null if the - * index of the active component is outside the list size. - */ - private WizardComponent getCurrent() { - if ((index > -1) && (index < components.size())) { - return components.get(index); - } else { - return null; - } - } - - /** - * Returns the previous component in the current wizard's components - * list. - * - * @return Previous {@link WizardComponent} or null if there is no - * previous component. - */ - private WizardComponent getPrevious() { - // if current component is a point of no return - we cannot move backwards, - // i.e. there is no previous component - if ((getCurrent() != null) && getCurrent().isPointOfNoReturn()) { - return null; - } - - for (int i = index - 1; i > -1; i--) { - final WizardComponent component = components.get(i); - - // if the component can be executed backward it is the previous one - if (component.canExecuteBackward()) { - return component; - } - - // if the currently examined component is a point of no return and it - // cannot be executed (since we passed the previous statement) - we have - // no previous component - if (component.isPointOfNoReturn()) { - return null; - } - } - - // if we reached the before-first index and yet could not find a previous - // component, then there is no previous component - return null; - } - - /** - * Returns the next component in the current wizard's components - * list. - * - * @return Next {@link WizardComponent} or null if there is no - * next component. - */ - private WizardComponent getNext() { - for (int i = index + 1; i < components.size(); i++) { - final WizardComponent component = components.get(i); - - // if the component can be executed forward it is the next one - if (component.canExecuteForward()) { - return component; - } - } - - // if we reached the after-last index and yet could not find a next - // component, then there is no next component - return null; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Name of the system property which is expected to contain the URI which points - * to the XML file with the list of components for the root wizard. - */ - public static final String COMPONENTS_INSTANCE_URI_PROPERTY = - "nbi.wizard.components.instance.uri"; // NOI18N - - /** - * Default URI which points to the XML file with the list of components for the - * root wizard. - */ - public static final String DEFAULT_COMPONENTS_INSTANCE_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/wizard/wizard-components.xml"; // NOI18N - - /** - * Name of the system property which is expected to contain the URI which points - * to the XML schema which defines the format for the serialized list of wizard - * components. - */ - public static final String COMPONENTS_SCHEMA_URI_PROPERTY = - "nbi.wizard.components.schema.uri"; // NOI18N - - /** - * Default URI which points to the XML schema which defines the format for the - * serialized list of wizard components. - */ - public static final String DEFAULT_COMPONENTS_SCHEMA_URI = - FileProxy.RESOURCE_SCHEME_PREFIX + - "org/netbeans/installer/wizard/wizard-components.xsd"; // NOI18N - - /** - * Name of the XML tag which describes a list of components. - */ - public static final String TAG_COMPONENTS = - "components"; // NOI18N - - /** - * Name of the XML tag which describes an individual component. - */ - public static final String TAG_COMPONENT = - "component"; // NOI18N - - /** - * Name of the XMl tag which describes the properties of a component. - */ - public static final String TAG_PROPERTIES = - "properties"; // NOI18N - - /** - * Name of the XML attribute which contains the classname of a component. - */ - public static final String ATTRIBUTE_CLASS = - "class"; // NOI18N - - /** - * Name of the system property which will be set when a component executes. Its - * value will be the fully qualified class name of the component. - */ - public static final String CURRENT_COMPONENT_CLASSNAME_PROPERTY = - "nbi.wizard.current.component.classname"; // NOI18N - - // private ////////////////////////////////////////////////////////////////////// - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_CREATE_INSTANCE = - "W.error.failed.to.create.instance"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_LOAD_COMPONENTS = - "W.error.failed.to.load.components"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_LOAD_COMPONENT = - "W.error.failed.to.load.component"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_UNKNOWN_UI_MODE = - "W.error.unknown.ui.mode"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_CANNOT_MOVE_BACKWARD_AT_FIRST = - "W.error.cannot.move.backward.at.first"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_PARSER_UNSUPPORTS_SCHEMAS = - "W.error.parser.unsupports.schemas";//NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_INTERRUPTED = - "W.error.interrupted";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/components/Bundle.properties deleted file mode 100644 index e822f2ab5c68..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/Bundle.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# WizardComponent.java -WC.title=NetBeans IDE Installer -WC.description=NetBeans IDE Installer Description - -WC.help.button.text=&Help! -WC.back.button.text=< &Back -WC.next.button.text=&Next > -WC.cancel.button.text=Cancel -WC.finish.button.text=&Finish - -WC.cancel.dialog.title=Cancel -WC.cancel.dialog.text=Are you sure you want to cancel? - -##################################################################################### -# WizardAction.java -WA.error.interrupted.exception=An InterruptedException occured. - -WA.canceling.progress.title=Canceling, finishing the current operation... - -WA.cancel.dialog.title=Cancel -WA.cancel.dialog.text=Are you sure you want to cancel? diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/WizardAction.java deleted file mode 100644 index ba146351c236..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardAction.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.helper.NbiThread; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiProgressBar; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.progress.ProgressListener; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This class is a specialization of the {@link WizardComponent} which defines - * behavior specific to actions. - * - *

- * An action is best described by the following characteristics: it represents a - * lengthy process (and hence displays a progress bar) and does not require any user - * input - it just informs the user that something is happening and the wizard did - * not hang. - * - *

- * Optionally an action may provide means to cancel without waiting for it to - * finish. This behavior is controlled by the {@link #isCancelable()} method. - * - *

- * The derivative classes are expected to implement the {@link #execute()} and the - * {@link #isCancelable()} methods. If the action is cancelable, then the code in - * the {@link #execute()} method should check the cancellation status of the action - * via {@link #isCanceled()}. The action will not be interrupted automatically - - * canceling is a deliberate process. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public abstract class WizardAction extends WizardComponent { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * UI of the action. - */ - private WizardUi wizardUi; - - /** - * Whether the action ahs finished execution. - */ - private boolean finished; - - /** - * Whether the action has been canceled. Note this field is simply a - * recommendation to the code in {@link #execute()} that it should clean up and - * return ASAP, it does not force any operation. - */ - private boolean canceled; - - /** - * Creates a new instance of {@link WizardAction}. This is the default - * protected constructor which must be called by the concrete - * implementations. It initializes the fields above. - */ - protected WizardAction() { - finished = false; - canceled = false; - } - - /** - * Executes the action when it is read via a call to - * {@link org.netbeans.installer.wizard.Wizard#next()}. This method runs the - * {@link #execute()} method a new {@link NbiThread}. - * - * @see WizardComponent#executeForward() - */ - public final void executeForward() { - new NbiThread() { - @Override - public void run() { - finished = false; - execute(); - finished = true; - - if (!canceled) { - getWizard().next(); - } - } - }.start(); - } - - /** - * This method has an empty implementation as {@link WizardAction} cannot be - * executed when moving backward. - * - * @see WizardComponent#executeBackward() - */ - public final void executeBackward() { - // does nothing - } - - /** - * This method always returns false, as {@link WizardAction}s - * cannot be executed when moving backward. - * - * @see WizardComponent#canExecuteBackward() - */ - @Override - public final boolean canExecuteBackward() { - return false; - } - - /** - * {@inheritDoc} - */ - public WizardActionUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new WizardActionUi(this); - } - - return (WizardActionUi) wizardUi; - } - - /** - * The default implementation of this method for {@link WizardAction} has an - * empty body. Concrete implementations are expected to override this method - * if they require any custom initialization. - * - * @see WizardComponent#initialize() - */ - public void initialize() { - // does nothing - } - - /** - * The main business-logic method of the action. It must be implemented by - * concrete instances of {@link WizardAction}. - * - *

- * The code in this method is expected to update the progress as it is being - * executed. The {@link Progress} object for the action should be created by - * this method and passed to the UI via the - * {@link WizardActionUi#setProgress(Progress)} method. - * - *

- * The implementing code is also expected to pay attention to the return value - * of the {@link #isCanceled()} method. When the action receives a cancel signal - * (if it supports cancelation) the return value of this method will change to - * true. - */ - public abstract void execute(); - - /** - * Whether this action can be canceled. The default value if true, - * concrete implementations of {@link WizardAction} may override this method to - * disable the possibility to cancel the action. - * - * @return true if the action can be canceled, false - * otherwise. - */ - public boolean isCancelable() { - return true; - } - - /** - * Whether this action has been canceled. This informational method is intended - * to be called by the code in {@link WizardAction#execute()} in order to - * correct its flow in case the action has been canceled. - * - * @return true is the action has been canceled, false - * otherwise. - */ - public boolean isCanceled() { - return canceled; - } - - /** - * Cancels the action. Note that this method does not explicitly "kill" the - * execution of the action, but instead simply sets the cancellation marker and - * waits till the action's execution finishes. In case of a not-very-well - * behaved action, this can take a while. - */ - public void cancel() { - canceled = true; - - while (!finished) { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - ErrorManager.notifyDebug(RESOURCE_INTERRUPTED_EXCEPTION, e); - } - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - /** - * Implementation of the {@link WizardUi} for {@link WizardAction}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardActionUi extends WizardComponentUi - implements ProgressListener { - /** - * Current {@link WizardAction} for this UI. - */ - protected WizardAction action; - - /** - * {@link Progress} object used by the action. - */ - protected Progress progress; - - /** - * Creates a new instance of {@link WizardActionUi}, initializing it with - * the specified instance of {@link WizardAction}. - * - * @param action Instance of {@link WizardAction} which should be used - * by this UI. - */ - public WizardActionUi(final WizardAction action) { - super(action); - - - this.action = action; - } - - /** - * {@inheritDoc} - */ - @Override - public SwingUi getSwingUi(final SwingContainer container) { - if (swingUi == null) { - swingUi = new WizardActionSwingUi(action, container); - } - - return super.getSwingUi(container); - } - - /** - * Sets the current progress object for this action. It will be listened for - * changes and the UI will be updated accordingly. - * - * @param progress Current {@link Progress} object for the action. - */ - public void setProgress(final Progress progress) { - if (this.progress != null) { - this.progress.removeProgressListener(this); - } - - this.progress = progress; - this.progress.addProgressListener(this); - } - - /** - * This method is called when the progress updates. It performs the update - * of all UIs that are created at the moment. - * - * @param progress {@link Progress} object which was updated. - * @see ProgressListener#progressUpdated(Progress) - */ - public void progressUpdated(final Progress progress) { - if (swingUi != null) { - ((WizardActionSwingUi) swingUi).progressUpdated(progress); - } - } - } - - /** - * Implementation of {@link SwingUi} for {@link WizardAction}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardActionSwingUi extends WizardComponentSwingUi { - /** - * Current {@link WizardAction} for this UI. - */ - private WizardAction action; - - /** - * {@link NbiLabel} which represents the progress' title. - */ - private NbiLabel titleLabel; - - /** - * {@link NbiLabel} which represents the progress' detailed status. - */ - private NbiLabel detailLabel; - - /** - * {@link NbiProgressBar} which represents the progress' percentage. - */ - private NbiProgressBar progressBar; - - /** - * Creates a new instance of {@link WizardActionSwingUi}, initializing it - * with the specified instances of {@link WizardAction} and - * {@link SwingContainer}. - * - * @param action Instance of {@link WizardAction} which should be used - * by this UI. - * @param container Instance of {@link SwingContainer} which should be used - * by this UI. - */ - public WizardActionSwingUi( - final WizardAction action, - final SwingContainer container) { - super(action, container); - - this.action = action; - - initComponents(); - } - - /** - * {@inheritDoc} - */ - @Override - public void initializeContainer() { - super.initializeContainer(); - - // set up the help button - container.getHelpButton().setEnabled(false); - container.getHelpButton().setVisible(false); - - // set up the back button - container.getBackButton().setEnabled(false); - container.getBackButton().setVisible(false); - - // set up the next (or finish) button - container.getNextButton().setEnabled(false); - container.getNextButton().setVisible(true); - - // set up the cancel button - container.getCancelButton().setVisible(true); - container.getCancelButton().setEnabled(action.isCancelable()); - } - - /** - * {@inheritDoc} - */ - @Override - public void evaluateCancelButtonClick() { - if (action.isCancelable()) { - final String cancelDialogTitle = ResourceUtils.getString( - WizardAction.class, - RESOURCE_CANCEL_DIALOG_TITLE); - final String canceldialogText = ResourceUtils.getString( - WizardAction.class, - RESOURCE_CANCEL_DIALOG_TEXT); - - if (!UiUtils.showYesNoDialog(cancelDialogTitle, canceldialogText)) { - return; - } - - container.getCancelButton().setEnabled(false); - titleLabel.setText(ResourceUtils.getString( - WizardAction.class, - RESOURCE_CANCELING_PROGRESS_TITLE)); - - new NbiThread() { - public void run() { - ((WizardAction) action).cancel(); - action.getWizard().getFinishHandler().cancel(); - } - }.start(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public NbiButton getDefaultEnterButton() { - return container.getCancelButton(); - } - - /** - * This method is called from the corresponding {@link WizardActionUi} to - * inform this class about the fact that the action's progress has been - * updated. Thismethod updates the title, detail and progress bar components. - * - * @param progress {@link Progress} which has been updated. - */ - public void progressUpdated(final Progress progress) { - if (progress != null) { - if (titleLabel != null) { - titleLabel.setText(progress.getTitle()); - } - - if (detailLabel != null) { - detailLabel.setText(progress.getDetail()); - } - - if (progressBar != null) { - progressBar.setValue(progress.getPercentage()); - } - } - } - - // private ////////////////////////////////////////////////////////////////// - /** - * Initializes and lays out the swing components in this UI. - */ - private void initComponents() { - // titleLabel /////////////////////////////////////////////////////////// - titleLabel = new NbiLabel(); - titleLabel.setFocusable(true); - - // progressBar ////////////////////////////////////////////////////////// - progressBar = new NbiProgressBar(); - - // detailLabel ////////////////////////////////////////////////////////// - detailLabel = new NbiLabel(true); - detailLabel.setFocusable(true); - - // this ///////////////////////////////////////////////////////////////// - add(titleLabel, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.SOUTH, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // ??? (padx, pady) - add(progressBar, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.NORTH, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 0, 11), // padding - 0, 0)); // ??? (padx, pady) - add(detailLabel, new GridBagConstraints( - 0, 2, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 0, 11), // padding - 0, 0)); // ??? (padx, pady) - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_CANCEL_DIALOG_TITLE = - "WA.cancel.dialog.title"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_CANCEL_DIALOG_TEXT = - "WA.cancel.dialog.text"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_INTERRUPTED_EXCEPTION = - "WA.error.interrupted.exception"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_CANCELING_PROGRESS_TITLE = - "WA.canceling.progress.title"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardComponent.java b/nbi/engine/src/org/netbeans/installer/wizard/components/WizardComponent.java deleted file mode 100644 index b2c99347da4e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardComponent.java +++ /dev/null @@ -1,710 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import javax.swing.JComponent; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.helper.NbiProperties; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.Wizard; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This class represents a single unit of a {@link Wizard} sequence. It is a logical - * abstraction of a wizard step, should normally be accompanied by a - * {@link WizardUi} instance. - * - *

- * This class provides a bunch of methods which are used by the wizard in order to - * execute the component, devise whether is can be executed or can be skipped, - * whether the user is allowed to skip the component, etc. - * - *

- * The basic infrastructure used by the concrete implementations of the - * {@link WizardComponent} class is also defined here: support for child components - * and properties. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public abstract class WizardComponent { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * {@link Wizard} which currently executes this component. This field is - * populated at the moment the component is executed, thus it is unsafe to - * assume that it holds a correct value unless it is known that the component - * is active. - */ - private Wizard wizard; - - /** - * List of child components. It is not expected that all implementations will - * make use of this field, thus the presence of children may simply be ignored - * by some. - */ - private List children; - - /** - * Component's properties. These should not be mixed up with the properties - * available through {@link Wizard#getProperty(String)} and - * {@link Wizard#setProperty(String,String)} - these are internal to the - * component, while the wizard's ones are expected to keep the user input. - */ - private NbiProperties properties; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * Creates a new instance of {@link WizardComponent}. This is the default - * protected constructor which must be called by the concrete - * implementations. It initializes the fields above and sets some default - * properties. - */ - protected WizardComponent() { - children = new ArrayList(); - properties = new NbiProperties(); - - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(HELP_BUTTON_TEXT_PROPERTY, - DEFAULT_HELP_BUTTON_TEXT); - setProperty(BACK_BUTTON_TEXT_PROPERTY, - DEFAULT_BACK_BUTTON_TEXT); - setProperty(NEXT_BUTTON_TEXT_PROPERTY, - DEFAULT_NEXT_BUTTON_TEXT); - setProperty(CANCEL_BUTTON_TEXT_PROPERTY, - DEFAULT_CANCEL_BUTTON_TEXT); - setProperty(FINISH_BUTTON_TEXT_PROPERTY, - DEFAULT_FINISH_BUTTON_TEXT); - } - - // execution flow /////////////////////////////////////////////////////////////// - /** - * This method is called when the component was reached with the - * {@link Wizard#next()} method. It is meant to perform the operations required - * by the concrete component, such as perform a search of some sort, etc. - * - *

- * This method is called after {@link #setWizard(Wizard)}, {@link #initialize()} - * and {@link #getWizardUi()}, thus it is safe to assume that the wizard field - * has been correctly initialized and the UI (if it exists) was shown. - */ - public abstract void executeForward(); - - /** - * This method is called when the component was reached with the - * {@link Wizard#previous()} method. It is meant to perform the operations - * required by the concrete component, such as perform a search of some sort, - * etc. - * - *

- * This method is called after {@link #setWizard(Wizard)}, {@link #initialize()} - * and {@link #getWizardUi()}, thus it is safe to assume that the wizard field - * has been correctly initialized and the UI (if it exists) was shown. - */ - public abstract void executeBackward(); - - /** - * This method is called every time a wizard reaches this component. Unlike the - * {@link #executeForward()} and {@link #executeBackward()} methods this one is - * called before the UI is shown and thus is intended to be used to - * prepare the model or data for use by the UI. - * - *

- * This method is called after {@link #setWizard(Wizard)}, thus it is safe to - * assume that the wizard field has been correctly initialized. - */ - public abstract void initialize(); - - /** - * This method is called by the wizard in order to find out whether this - * component can be reached via {@link Wizard#next()}. - * - *

- * It's important to note that if this method returns false, the - * wizard will not assume that it cannot proceed, but will skip this - * component altogether. - * - * @return true if the component can be executed, - * false if the component should be skipped. - */ - public boolean canExecuteForward() { - return true; - } - - /** - * This method is called by the wizard in order to find out whether this - * component can be reached via {@link Wizard#previous()}. - * - *

- * It's important to note that if this method returns false, the - * wizard will not assume that it cannot proceed, but will skip this - * component altogether. - * - * @return true if the component can be executed, - * false if the component should be skipped. - */ - public boolean canExecuteBackward() { - return true; - } - - /** - * This method is called by the wizard in order to find out whether it is - * allowed to execute any components before this via the - * {@link Wizard#previous()} method. If this method returns true it - * will be illegal to call {@link Wizard#previous()} if the current component - * is active. - * - * @return true is the component is the point of no return, - * false otherwise. - */ - public boolean isPointOfNoReturn() { - return false; - } - - // ui /////////////////////////////////////////////////////////////////////////// - /** - * Returns the {@link WizardUi} object for this component. - * - * @return {@link WizardUi} object for this component. - */ - public abstract WizardUi getWizardUi(); - - // wizard /////////////////////////////////////////////////////////////////////// - /** - * Returns the {@link Wizard} which currently executes this component. - * - * @return {@link Wizard} which currently executes this component. - */ - public final Wizard getWizard() { - return wizard; - } - - /** - * Sets the {@link Wizard} which currently executes this component. - * - * @param wizard {@link Wizard} which currently executes this component. - */ - public final void setWizard(final Wizard wizard) { - this.wizard = wizard; - } - - // children ///////////////////////////////////////////////////////////////////// - /** - * Registers a new child for this component. - * - * @param component New child component which should be registered. - */ - public final void addChild(final WizardComponent component) { - children.add(component); - } - - /** - * Unregisters a child component. If it was not previously registered, no action - * is taken. - * - * @param component Child component which should be unregistered. - */ - public final void removeChild(final WizardComponent component) { - children.remove(component); - } - - /** - * Registers several children for this component. - * - * @param components {@link List} of child components which should be - * registered. - */ - public final void addChildren(final List components) { - children.addAll(components); - } - - /** - * Returns the list of currently registered child components. It is not - * guaranteed that operating on this list directly will affect the actual - * children. - * - * @return {@link List} of the registered child components. - */ - public final List getChildren() { - return children; - } - - // properties /////////////////////////////////////////////////////////////////// - /** - * Returns the value of the component's property with the specified name. This - * method attempts to parse the property value using the - * {@link SystemUtils#parseString(String,ClassLoader)} method and supplying - * {@link Wizard#getClassLoader()} as the class loader value. - * - * @param name Name of the property whose value should be returned. - * @return Value of the specified property, parsed via - * {@link SystemUtils#parseString(String,ClassLoader)}. - */ - public final String getProperty(final String name) { - return getProperty(name, true); - } - - /** - * Returns the value of the specified property. Thsi method can either attempt - * to resolve the value, or return it as is. - * - * @param name Name of the property whose value needs to be returned. - * @param resolve Whether to resolve the property value or not. - * @return Value of the specified property, either parsed or not. - */ - public final String getProperty(final String name, final boolean resolve) { - final String value = properties.getProperty(name); - - if (resolve) { - return value != null ? resolveString(value) : null; - } else { - return value; - } - } - - /** - * Sets the specified property to the specified value. If such property does not - * exist - it is created. - * - * @param name Name of the property whose value needs to be set. - * @param value Value of the property. - */ - public final void setProperty(final String name, final String value) { - properties.setProperty(name, value); - } - - /** - * Returns the properties of this component. The values of the properties will - * not be parsed. It is not guaranteed that operating on the return value of - * this method will affect the actual properties of the component. - * - * @return Component's properties. - */ - public final NbiProperties getProperties() { - return properties; - } - - // helpers ////////////////////////////////////////////////////////////////////// - /** - * A helper method - calls {@link SystemUtils#resolveString(String,ClassLoader)} - * supplying {@link Wizard#getClassLoader()} as the class loader value. - * - * @param string String to be resolved. - * @return Resolved string. - */ - protected final String resolveString(final String string) { - return SystemUtils.resolveString(string, wizard.getClassLoader()); - } - - /** - * A helper method - calls {@link SystemUtils#resolvePath(String,ClassLoader)} - * supplying {@link Wizard#getClassLoader()} as the class loader value. - * - * @param path Path to be resolved as a {@link String}. - * @return Resolved path as a {@link File}. - */ - protected final File resolvePath(final String path) { - return SystemUtils.resolvePath(path, wizard.getClassLoader()); - } - - /** - * A helper method - calls - * {@link ResourceUtils#getString(String,String,ClassLoader)}, supplying - * {@link Wizard#getClassLoader()} as the class loader value. - * - * @param baseName Resource bundle base name. - * @param key Name of the key whose value needs to be obtained. - * @return Value of the specified key from the specified bundle. - */ - protected final String getString(final String baseName, final String key) { - return ResourceUtils.getString(baseName, key, wizard.getClassLoader()); - } - - /** - * A helper method - calls - * {@link ResourceUtils#getString(String,String,ClassLoader,Object[])}, - * supplying {@link Wizard#getClassLoader()} as the class loader value. - * - * @param baseName Resource bundle base name. - * @param key Name of the key whose value needs to be obtained. - * @param arguments Objects which should be used to substitute wildcards in the - * key value. - * @return Value of the specified key from the specified bundle with its - * wildcards resolved using the supplied arguments. - */ - protected final String getString( - final String baseName, - final String key, - final Object... arguments) { - return ResourceUtils.getString(baseName, key, wizard.getClassLoader(), arguments); - } - - /** - * A helper method - calls {@link ResourceUtils#getResource(String,ClassLoader)} - * supplying {@link Wizard#getClassLoader()} as the class loader value. - * - * @param path Path to the resource which should be obtained. - * @return {@link InputStream} from the resource, or null if it was - * not found. - */ - protected final InputStream getResource(final String path) { - return ResourceUtils.getResource(path, wizard.getClassLoader()); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - /** - * Implementation of the {@link WizardUi} for {@link WizardComponent}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardComponentUi implements WizardUi { - /** - * Current {@link WizardComponent} for this UI. - */ - protected WizardComponent component; - - /** - * UI implementation for Swing environment. This is initialized lazily, i.e. - * the value of this field will be null, unless the accessor method has been - * called - {@link #getSwingUi(SwingContainer)}. - */ - protected WizardComponentSwingUi swingUi; - - /** - * Creates a new instance of {@link WizardComponentUi}, initializing it with - * the specified instance of {@link WizardComponent}. - * - * @param component Instance of {@link WizardComponent} which should be used - * by this UI. - */ - protected WizardComponentUi(final WizardComponent component) { - this.component = component; - } - - /** - * {@inheritDoc} - */ - public SwingUi getSwingUi(final SwingContainer container) { - if (swingUi == null) { - swingUi = new WizardComponentSwingUi(component, container); - } - - swingUi.initializeContainer(); - swingUi.initialize(); - - return swingUi; - } - } - - /** - * Implementation of {@link SwingUi} for {@link WizardComponent}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardComponentSwingUi extends SwingUi { - /** - * Current {@link WizardComponent} for this UI. - */ - protected WizardComponent component; - - /** - * Current {@link SwingContainer} for this UI. - */ - protected SwingContainer container; - - /** - * Creates a new instance of {@link WizardComponentSwingUi}, initializing it - * with the specified instances of {@link WizardComponent} and - * {@link SwingContainer}. - * - * @param component Instance of {@link WizardComponent} which should be used - * by this UI. - * @param container Instance of {@link SwingContainer} which should be used - * by this UI. - */ - protected WizardComponentSwingUi( - final WizardComponent component, - final SwingContainer container) { - this.component = component; - this.container = container; - } - - /** - * {@inheritDoc} - */ - public String getTitle() { - return component.getProperty(TITLE_PROPERTY); - } - - /** - * {@inheritDoc} - */ - public String getDescription() { - return component.getProperty(DESCRIPTION_PROPERTY); - } - - /** - * {@inheritDoc} - */ - public void evaluateHelpButtonClick() { - // does nothing - } - - /** - * {@inheritDoc} - */ - public void evaluateBackButtonClick() { - component.getWizard().previous(); - } - - /** - * {@inheritDoc} - */ - public void evaluateNextButtonClick() { - component.getWizard().next(); - } - - /** - * {@inheritDoc} - */ - public void evaluateCancelButtonClick() { - final String cancelDialogTitle = ResourceUtils.getString( - WizardComponent.class, - RESOURCE_CANCEL_DIALOG_TITLE); - final String canceldialogText = ResourceUtils.getString( - WizardComponent.class, - RESOURCE_CANCEL_DIALOG_TEXT); - - if (UiUtils.showYesNoDialog(cancelDialogTitle, canceldialogText)) { - component.getWizard().getFinishHandler().cancel(); - } - } - - /** - * {@inheritDoc} - */ - public NbiButton getDefaultEnterButton() { - return container.getNextButton(); - } - - /** - * {@inheritDoc} - */ - public NbiButton getDefaultEscapeButton() { - return container.getCancelButton(); - } - - /** - * {@inheritDoc} - */ - public JComponent getDefaultFocusOwner() { - if (getDefaultEnterButton() != null) { - return getDefaultEnterButton(); - } else { - return null; - } - } - - // protected //////////////////////////////////////////////////////////////// - /** - * Initializes the container. This method sets the appropriate texts on the - * buttons, enables/disables them according to the current position in the - * wizard, etc. - * - *

- * This method is called right before the UI is shown. - */ - protected void initializeContainer() { - // set up the help button - container.getHelpButton().setVisible(false); - container.getHelpButton().setEnabled(false); - - container.getHelpButton().setText( - component.getProperty(HELP_BUTTON_TEXT_PROPERTY)); - - // set up the back button - container.getBackButton().setVisible(true); - if (component.getWizard().hasPrevious()) { - container.getBackButton().setEnabled(true); - } else { - container.getBackButton().setEnabled(false); - } - - container.getBackButton().setText( - component.getProperty(BACK_BUTTON_TEXT_PROPERTY)); - - // set up the next (or finish) button - container.getNextButton().setVisible(true); - container.getNextButton().setEnabled(true); - - if (component.getWizard().hasNext()) { - container.getNextButton().setText( - component.getProperty(NEXT_BUTTON_TEXT_PROPERTY)); - } else { - container.getNextButton().setText( - component.getProperty(FINISH_BUTTON_TEXT_PROPERTY)); - } - - // set up the cancel button - container.getCancelButton().setVisible(true); - container.getCancelButton().setEnabled(true); - - container.getCancelButton().setText( - component.getProperty(CANCEL_BUTTON_TEXT_PROPERTY)); - } - - /** - * Initializes the UI. This methods sets the correct texts for the labels, - * textfields, and initializes other controls. - * - *

- * This method is called right before the UI is shown. - */ - protected void initialize() { - // does nothing - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Name of the property, which contains the component's title. - */ - public static final String TITLE_PROPERTY = - "title"; // NOI18N - - /** - * Name of the property, which contains the component's description. - */ - public static final String DESCRIPTION_PROPERTY = - "description"; // NOI18N - - /** - * Name of the property, which contains the text for the standard 'Help' - * button. - */ - public static final String HELP_BUTTON_TEXT_PROPERTY = - "help.button.text"; // NOI18N - - /** - * Name of the property, which contains the text for the standard 'Back' - * button. - */ - public static final String BACK_BUTTON_TEXT_PROPERTY = - "back.button.text"; // NOI18N - - /** - * Name of the property, which contains the text for the standard 'Next' - * button. - */ - public static final String NEXT_BUTTON_TEXT_PROPERTY = - "next.button.text"; // NOI18N - - /** - * Name of the property, which contains the text for the standard 'Cancel' - * button. - */ - public static final String CANCEL_BUTTON_TEXT_PROPERTY = - "cancel.button.text"; // NOI18N - - /** - * Name of the property, which contains the text for the standard 'Finish' - * button. - */ - public static final String FINISH_BUTTON_TEXT_PROPERTY = - "finish.button.text"; // NOI18N - - // private ////////////////////////////////////////////////////////////////////// - /** - * Default value for the component's title. - */ - private static final String DEFAULT_TITLE = - ResourceUtils.getString(WizardComponent.class, - "WC.title"); // NOI18N - - /** - * Default value for the component's description. - */ - private static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(WizardComponent.class, - "WC.description"); // NOI18N - - /** - * Default text for the standard 'Help' button. - */ - private static final String DEFAULT_HELP_BUTTON_TEXT = - ResourceUtils.getString(WizardComponent.class, - "WC.help.button.text"); // NOI18N - - /** - * Default text for the standard 'Back' button. - */ - private static final String DEFAULT_BACK_BUTTON_TEXT = - ResourceUtils.getString(WizardComponent.class, - "WC.back.button.text"); // NOI18N - - /** - * Default text for the standard 'Next' button. - */ - private static final String DEFAULT_NEXT_BUTTON_TEXT = - ResourceUtils.getString(WizardComponent.class, - "WC.next.button.text"); // NOI18N - - /** - * Default text for the standard 'Cancel' button. - */ - private static final String DEFAULT_CANCEL_BUTTON_TEXT = - ResourceUtils.getString(WizardComponent.class, - "WC.cancel.button.text"); // NOI18N - - /** - * Default text for the standard 'Finish' button. - */ - private static final String DEFAULT_FINISH_BUTTON_TEXT = - ResourceUtils.getString(WizardComponent.class, - "WC.finish.button.text"); // NOI18N - - /** - * Name of a resource bundle entry. - */ - public static final String RESOURCE_CANCEL_DIALOG_TITLE = - "WC.cancel.dialog.title"; // NOI18N - - /** - * Name of a resource bundle entry. - */ - public static final String RESOURCE_CANCEL_DIALOG_TEXT = - "WC.cancel.dialog.text"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/WizardPanel.java deleted file mode 100644 index c24af8cf4320..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardPanel.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components; - -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.helper.UiMode; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This class is a specialization of the {@link WizardComponent} which defines - * behavior specific to panels. - * - *

- * A panel is the most typical wizard component. It's behavioral capabilities are - * extremely limited and hence the only thing that a anel can do is to display a - * bunch of input fields requiing to enter some data. On the other hand a panel can - * be used to inform the user about an event and require him to perform some action - * before the wizard proceeds. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public abstract class WizardPanel extends WizardComponent { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * UI of the panel. - */ - protected WizardUi wizardUi; - - /** - * Creates a new instance of {@link WizardPanel}. This is the default - * protected constructor which must be called by the concrete - * implementations. - */ - protected WizardPanel() { - // does nothing - } - - /** - * Executes the panel when it is read via a call to - * {@link org.netbeans.installer.wizard.Wizard#next()}. When the wizard is run - * in a GUI mode, no action is taken as all the functionality of a panel is - * contained in its UI. When the wizard is run in a silent mode, running this - * method automatically calls - * {@link org.netbeans.installer.wizard.Wizard#next()}. - * - * @see WizardComponent#executeForward() - */ - public final void executeForward() { - // since silent mode does not assume any user interaction we just move - // forward - if (UiMode.getCurrentUiMode() == UiMode.SILENT) { - getWizard().next(); - } - } - - /** - * Executes the panel when it is read via a call to - * {@link org.netbeans.installer.wizard.Wizard#previous()}. When the wizard is - * run in a GUI mode, no action is taken as all the functionality of a panel is - * contained in its UI. - * - * @see WizardComponent#executeForward() - */ - public final void executeBackward() { - // does nothing - } - - /** - * The default implementation of this method for {@link WizardPanel} has an - * empty body. Concrete implementations are expected to override this method - * if they require any custom initialization. - * - * @see WizardComponent#initialize() - */ - public void initialize() { - // does nothing - } - - /** - * {@inheritDoc} - */ - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new WizardPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - /** - * Implementation of the {@link WizardUi} for {@link WizardPanel}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardPanelUi extends WizardComponentUi { - /** - * Current {@link WizardPanel} for this UI. - */ - protected WizardPanel panel; - - /** - * Creates a new instance of {@link WizardPanelUi}, initializing it with - * the specified instance of {@link WizardPanel}. - * - * @param panel Instance of {@link WizardPanel} which should be used - * by this UI. - */ - public WizardPanelUi(final WizardPanel panel) { - super(panel); - - this.panel = panel; - } - - /** - * {@inheritDoc} - */ - @Override - public SwingUi getSwingUi(final SwingContainer container) { - if (swingUi == null) { - swingUi = new WizardPanelSwingUi(panel, container); - } - - return super.getSwingUi(container); - } - } - - /** - * Implementation of {@link SwingUi} for {@link WizardPanel}. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardPanelSwingUi extends WizardComponentSwingUi { - /** - * Current {@link WizardPanel} for this UI. - */ - protected WizardPanel panel; - - /** - * Creates a new instance of {@link WizardPanelSwingUi}, initializing it - * with the specified instances of {@link WizardPanel} and - * {@link SwingContainer}. - * - * @param panel Instance of {@link WizardPanel} which should be used - * by this UI. - * @param container Instance of {@link SwingContainer} which should be used - * by this UI. - */ - public WizardPanelSwingUi( - final WizardPanel panel, - final SwingContainer container) { - super(panel, container); - - this.panel = panel; - } - - /** - * {@inheritDoc} - */ - @Override - public void evaluateBackButtonClick() { - if (validateInput() == null) { - saveInput(); - } - - component.getWizard().previous(); - } - - /** - * {@inheritDoc} - */ - @Override - public void evaluateNextButtonClick() { - String errorMessage = validateInput(); - - if (errorMessage == null) { - saveInput(); - component.getWizard().next(); - } else { - ErrorManager.notifyError(errorMessage); - } - } - - // protected //////////////////////////////////////////////////////////////// - /** - * Saves the user input to the wizard's property container. This method does - * not perform any additional validation of the input as it will be - * validated prior to calling this method - in {@link #validateInput()} - */ - protected void saveInput() { - // does nothing - } - - /** - * Validates the user input. This method performs the validatation of the - * data input by the user on this panel. It either passed the input data to - * the component for validation, or takes the risk and validates the data - * itself. - * - * @return Error message which describes what is incorrect with the user - * input, or null if the user input is correct. - */ - protected String validateInput() { - return null; // null means that everything is OK - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardSequence.java b/nbi/engine/src/org/netbeans/installer/wizard/components/WizardSequence.java deleted file mode 100644 index 3675669dd29a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/WizardSequence.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components; - -import org.netbeans.installer.wizard.Wizard; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This class is a specialization of the {@link WizardComponent} which defines - * behavior specific to sequences. - * - *

- * A sequence is merely a list of {@link WizardComponent}s which executes when the - * sequence itself is executed. This makes wizard sequences the instrument to add - * "depth" to the wizard, enable conditional execution of a set of components, etc. - * It is also the only "standard" component which actually makes use of its child - * components. - * - *

- * {@link WizardSequence} uses child {@link Wizard} instances to execute its - * child components. The {@link Wizard} instances are created via the - * {@link Wizard#createSubWizard(List,int)} method. - * - *

- * A wizard sequence does not have a UI of its own - it completely relies on the UI - * of its child components. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public class WizardSequence extends WizardComponent { - /** - * Current child {@link WIzard} instance which is used to iterate of over the - * list of child {@link WizardComponent}s. - */ - protected Wizard childWizard; - - /** - * Executes the sequence when it is reached via a call to {@link Wizard#next()}. - * This method simply creates a new child instance of {@link Wizard} over the - * list of child components, sets the index of the active component to the - * pre-first one and calls {@link Wizard#next()}. - * - * @see WizardComponent#executeForward() - */ - public void executeForward() { - childWizard = getWizard().createSubWizard( - getChildren(), -1); - - childWizard.next(); - } - - /** - * Executes the sequence when it is reached via a call to - * {@link Wizard#previous()}. This method simply creates a new child instance - * of {@link Wizard} over the of child components, sets the index of the active - * component to the after-last one and calls {@link Wizard#previous()}. - * - * @see WizardComponent#executeBackward() - */ - public void executeBackward() { - childWizard = getWizard().createSubWizard( - getChildren(), getChildren().size()); - - childWizard.previous(); - } - - /** - * The default implementation of this method for {@link WizardSequence} has an - * empty body. Concrete implementations are expected to override this method - * if they require any custom initialization. - * - * @see WizardComponent#initialize() - */ - public void initialize() { - // does nothing - } - - /** - * Whether the sequence can be executed when reached via a call to - * {@link Wizard#next()}. Since the sequence does not contain any logic of its - * own, it searches through the list of child components checking whether there - * is one that can be executed. If such a component is found, the sequence - * considers itself to be able to execute. - * - * @return true is the sequence can be executed, false - * otherwise. - */ - @Override - public boolean canExecuteForward() { - // whether a sequence can be executed completely depends on whether its - // children can be executed, thus we should run through them and check - for (int i = 0; i < getChildren().size(); i++) { - final WizardComponent component = getChildren().get(i); - - // if the component can be executed forward the whole sequence can be - // executed as well - if (component.canExecuteForward()) { - return true; - } - } - - // if none of the components can be executed, it does not make sense to - // execute the sequence as well - return false; - } - - /** - * Whether the sequence can be executed when reached via a call to - * {@link Wizard#previous()}. Since the sequence does not contain any logic of - * its own, it searches through the list of child components checking whether - * there is one that can be executed. If such a component is found, the sequence - * considers itself to be able to execute. - * - * @return true is the sequence can be executed, false - * otherwise. - */ - @Override - public boolean canExecuteBackward() { - // whether a sequence can be executed completely depends on whether its - // children can be executed, thus we should run through them and check - for (int i = getChildren().size() - 1; i > -1; i--) { - final WizardComponent component = getChildren().get(i); - - // if the component can be executed backward the whole sequence can be - // executed as well - if (component.canExecuteBackward()) { - return true; - } - - // if the currently examined component is a point of no return and it - // cannot be executed (since we passed the previous statement) - we have - // no previous component - if (component.isPointOfNoReturn()) { - return false; - } - } - - // if none of the components can be executed it does not make sense to - // execute the sequence as well - return false; - } - - /** - * Whether the sequence is a point of no return. Since the sequence does not - * contain any logic of its own, it searches through the list of child - * components checking whether there is one that is a point of no return. If - * such a component is found and the index of the active component is greater - * than that of the found component, the sequence considers itself to be the - * point of no return. - * - * @return true is the sequence is the point of no return, - * false otherwise. - */ - @Override - public boolean isPointOfNoReturn() { - // if there is a point-of-no-return child and it has already been passed, - // then the sequence of a point of no return, otherwise it's not - if (childWizard != null) { - for (int i = 0; i < getChildren().size(); i++) { - if (getChildren().get(i).isPointOfNoReturn() && - (i < childWizard.getIndex())) { - return true; - } - } - } - - // otherwise, it's not - return false; - } - - /** - * Returns the {@link WizardUi} object for this component. Since the sequence - * does not have an UI of its own, this method always returns null. - * - * @return null. - */ - public WizardUi getWizardUi() { - // a sequence does not have a UI of its own, thus returning null - return null; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/Bundle.properties deleted file mode 100644 index 328b63f1df2e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/Bundle.properties +++ /dev/null @@ -1,111 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -################################################################################ -# CacheEngineAction.java -CEA.title=Cache Engine... -CEA.description=Please wait while the wizard caches the engine. -CEA.error.cannot.cache.engine=Cannot cache the installer engine - -################################################################################ -# CreateBundleAction.java -CBA.title=Creating Bundle... -CBA.description=Please wait while the wizard creates a bundle with the selected components. - -CBA.progress.create.bundle.title=Creating a redistributable bundle at {0} -CBA.progress.add.engine.detail=Add installer engine to the bundle -CBA.progress.add.product.detail=Adding {0} ... -CBA.progress.add.group.detail=Adding {0} ... - -CBA.error.failed.create.bundle=Failed to create the bundle - -################################################################################ -# CreateNativeLauncherAction.java -CNLA.title=Creating Native Launcher... -CNLA.description=Please wait while the wizard creates a launcher for the jar file. -CNLA.error.failed.create.launcher=Failed to create the native launcher - -################################################################################ -# CreateMacOSAppLauncherAction.java -CMALA.title=Creating MacOSX Application Launcher... -CMALA.description=Please wait while the wizard creates a app launcher for the jar file. -CMALA.error.failed.create.launcher=Failed to create the app launcher - -################################################################################ -# DownloadConfigurationLogicAction.java -DCLA.title=Preparing Configuration Logic... -DCLA.description=Please wait while the wizard prepares the configuration logic. -DCLA.progress.remote.title=Downloading configuration logic for {0} -DCLA.progress.local.title=Extracting configuration logic for {0} -DCLA.failed=Failed to download installation logic for {0} -DCLA.dependent.failed=Could not install {0}, since the installation of {1} failed - -################################################################################ -# DownloadInstallationDataAction.java -DIDA.title=Preparing Installation Data... -DIDA.description=Please wait while the wizard prepares the installation data. -DIDA.progress.remote.title=Downloading installation data for {0} -DIDA.progress.local.title=Extracting installation data for {0} -DIDA.failed=Failed to download installation data for {0} -DIDA.dependent.failed=Could not install {0}, since the installation of {1} failed - -################################################################################ -# InitializeRegistryAction.java -IRA.title=Initializing... -IRA.description=Please wait while the setup wizard initializes. -IRA.registry.initialization.failed=Cannot initialize registry - -################################################################################ -# FinalizeRegistryAction.java -FRA.title=Finalizing... -FRA.description=Please wait while the setup wizard finalizes. -FRA.registry.finalization.failed=Cannot finalize registry - -################################################################################ -# InstallAction.java -IA.title=Installing... -IA.description=Please wait while the wizard installs the selected components. -IA.progress.install.title=Installing {0}... -IA.progress.rollback.title=Canceling, rolling back {0}... -IA.install.dependent.failed=Could not install {0}, since the installation of {1} failed -IA.install.unknown.error=Unknown Error - -################################################################################ -# SearchForJavaAction.java -SFJA.title=Searching for Java\u2122 Environments... -SFJA.description=Please wait while the wizard searches your system for existing Java\u2122 environments. -SFJA.prepare.list=Preparing locations list... -SFJA.checking=Checking {0} -SFJA.search.java=Searching for installed Java environments... -SFJA.entry.label={0} (v. {1} [{2}] by {3}) -SFJA.entry.label.noarch={0} (v. {1} by {2}) -SFJA.entry.label.non.final={0} (v. {1} [{2}] (non-final) by {3}) - -################################################################################ -# UninstallAction.java -UA.title=Uninstalling... -UA.description=Please wait while the wizard uninstalls the selected components. -UA.progress.uninstall.title=Uninstalling {0} -UA.uninstall.dependent.failed=Could not uninstall {0}, since the uninstallation of {1} failed - -################################################################################ -# SetInstallationLocationAction.java -SILA.error.source.uid.not.set=Source component UID is not set -SILA.error.cannot.find.component=Component with the given uid {0} does not exist -SILA.error.cannot.get.logic=Could not access configuration logic for {0} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CacheEngineAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CacheEngineAction.java deleted file mode 100644 index 6d578983810d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CacheEngineAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.net.URLDecoder; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.EngineUtils; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Dmitry Lipin - */ -public class CacheEngineAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public CacheEngineAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - } - - public void execute() { - try { - final Progress progress = new Progress(); - - getWizardUi().setProgress(progress); - EngineUtils.cacheEngine(progress); - } catch (IOException e) { - ErrorManager.notifyCritical(ResourceUtils.getString( - CacheEngineAction.class, - ERROR_CANNOT_CACHE_ENGINE_KEY), e); - } - } - - @Override - public boolean isCancelable() { - return false; - } - - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - CacheEngineAction.class, - "CEA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - CacheEngineAction.class, - "CEA.description"); // NOI18N - public static final String ERROR_CANNOT_CACHE_ENGINE_KEY = - "CEA.error.cannot.cache.engine";// NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateBundleAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateBundleAction.java deleted file mode 100644 index f7546c3d9707..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateBundleAction.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarOutputStream; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.filters.RegistryFilter; -import org.netbeans.installer.product.filters.SubTreeFilter; -import org.netbeans.installer.utils.EngineUtils; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.cli.CLIHandler; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.EngineResources; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.helper.ExtendedUri; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Kirill Sorokin - */ -public class CreateBundleAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - CreateBundleAction.class, - "CBA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - CreateBundleAction.class, - "CBA.description"); // NOI18N - public static final String DEFAULT_PROGRESS_CREATE_BUNDLE_TITLE = - ResourceUtils.getString(CreateBundleAction.class, - "CBA.progress.create.bundle.title");//NOI18N - public static final String DEFAULT_PROGRESS_ADD_ENGINE_DETAIL = - ResourceUtils.getString(CreateBundleAction.class, - "CBA.progress.add.engine.detail");//NOI18N - public static final String DEFAULT_PROGRESS_ADD_PRODUCT_DETAIL = - ResourceUtils.getString(CreateBundleAction.class, - "CBA.progress.add.product.detail");//NOI18N - public static final String DEFAULT_PROGRESS_ADD_GROUP_DETAIL = - ResourceUtils.getString(CreateBundleAction.class, - "CBA.progress.add.group.detail");//NOI18N - public static final String DEFAULT_ERROR_FAILED_CREATE_BUNDLE = - ResourceUtils.getString(CreateBundleAction.class, - "CBA.error.failed.create.bundle");//NOI18N - - public static final String PROGRESS_CREATE_BUNDLE_TITLE_PROPERTY = - "progress.create.bundle.title";//NOI18N - public static final String PROGRESS_ADD_ENGINE_DETAIL_PROPERTY = - "progress.add.engine.detail";//NOI18N - public static final String PROGRESS_ADD_PRODUCT_DETAIL_PROPERTY = - "progress.add.product.detail";//NOI18N - public static final String PROGRESS_ADD_GROUP_DETAIL_PROPERTY = - "progress.add.group.detail";//NOI18N - public static final String ERROR_FAILED_CREATE_BUNDLE_PROPERTY = - "error.failed.create.bundle";//NOI18N - - public static final String CUSTOM_DATA_URI_PREFIX_PROPERTY = - "nbi.product.bundled.data.all.location";//NOI18N - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private Progress progress; - private HashSet jarEntries = new HashSet (); - - public CreateBundleAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - setProperty(PROGRESS_CREATE_BUNDLE_TITLE_PROPERTY, - DEFAULT_PROGRESS_CREATE_BUNDLE_TITLE); - setProperty(PROGRESS_ADD_ENGINE_DETAIL_PROPERTY, - DEFAULT_PROGRESS_ADD_ENGINE_DETAIL); - setProperty(PROGRESS_ADD_PRODUCT_DETAIL_PROPERTY, - DEFAULT_PROGRESS_ADD_PRODUCT_DETAIL); - setProperty(PROGRESS_ADD_GROUP_DETAIL_PROPERTY, - DEFAULT_PROGRESS_ADD_GROUP_DETAIL); - } - - public void execute() { - long started = System.currentTimeMillis(); - - LogManager.log("creating bundle"); - LogManager.log(" initializing registry and required products"); - final Registry registry = Registry.getInstance(); - final RegistryFilter filter = - new SubTreeFilter(registry.getProductsToInstall()); - final List products = registry.queryProducts(filter); - final List groups = registry.queryGroups(filter); - - LogManager.log(" products to install: " + StringUtils.asString(registry.getProductsToInstall())); - LogManager.log(" selected products: " + StringUtils.asString(products)); - LogManager.log(" selected groups: " + StringUtils.asString(groups)); - - int percentageChunk = Progress.START; - int percentageLeak = Progress.COMPLETE; - - if (products.size() + groups.size() > 0) { - percentageChunk = - Progress.COMPLETE / (products.size() + groups.size()); - percentageLeak = - Progress.COMPLETE % (products.size() + groups.size()); - } - - final String targetPath = - System.getProperty(Registry.CREATE_BUNDLE_PATH_PROPERTY); - final File targetFile = new File(targetPath); - - progress = new Progress(); - - getWizardUi().setProgress(progress); - - JarFile engine = null; - JarOutputStream output = null; - - try { - LogManager.indent(); - LogManager.log("... creating bundle file at " + targetFile); - progress.setTitle(StringUtils.format( - getProperty(PROGRESS_CREATE_BUNDLE_TITLE_PROPERTY), targetFile)); - progress.setDetail(StringUtils.format( - getProperty(PROGRESS_ADD_ENGINE_DETAIL_PROPERTY))); - - engine = new JarFile(EngineUtils.cacheEngine(new Progress())); - output = new JarOutputStream(new FileOutputStream(targetFile)); - - // transfer the engine, skipping existing bundled components - final Enumeration entries = engine.entries(); - LogManager.log("... adding entries from the engine. Total : " + engine.size()); - while (entries.hasMoreElements()) { - final JarEntry entry = (JarEntry) entries.nextElement(); - - // check for cancel status - if (isCanceled()) return; - - final String name = entry.getName(); - - // skip the (possibly) already cached data - if (name.startsWith(EngineResources.DATA_DIRECTORY)) { - continue; - } - - // skip the signing information if it exists - if (name.startsWith("META-INF/") && - !name.equals("META-INF/") && - !name.equals("META-INF/MANIFEST.MF")) { - continue; - } - - putNextEntry(output,entry); - StreamUtils.transferData(engine.getInputStream(entry), output); - } - - putNextEntry(output, EngineResources.DATA_DIRECTORY + "/"); - - - // transfer the engine files list - putNextEntry(output, EngineResources.ENGINE_CONTENTS_LIST); - StreamUtils.transferData( - ResourceUtils.getResource(EngineResources.ENGINE_CONTENTS_LIST), - output); - InputStream optionsListStream = ResourceUtils.getResource(CLIHandler.OPTIONS_LIST); - if (optionsListStream != null) { - //transfer engine command-line options list - putNextEntry(output, CLIHandler.OPTIONS_LIST); - StreamUtils.transferData(optionsListStream, output); - } - - // load default engine properties and set all components to be installed by default - String [] contents = StringUtils.splitByLines( - StreamUtils.readStream( - ResourceUtils.getResource( - EngineResources.ENGINE_CONTENTS_LIST))); - for(String entry : contents) { - if(entry.matches(EngineResources.ENGINE_PROPERTIES_PATTERN)) { - Properties engineProps = new Properties(); - engineProps.load(ResourceUtils.getResource(entry)); - - if(System.getProperty(Installer.BUNDLE_PROPERTIES_FILE_PROPERTY)!=null) { - Properties pr = new Properties(); - InputStream is = new FileInputStream(new File( - System.getProperty(Installer. - BUNDLE_PROPERTIES_FILE_PROPERTY))); - pr.load(is); - is.close(); - engineProps.putAll(pr); - } - - engineProps.setProperty(Registry.SUGGEST_INSTALL_PROPERTY, - StringUtils.EMPTY_STRING + true); - putNextEntry(output, entry); - engineProps.store(output, null); - } - } - - progress.addPercentage(percentageLeak); - LogManager.log("... adding " + products.size() + " products"); - for (Product product: products) { - // check for cancel status - if (isCanceled()) return; - - progress.setDetail(StringUtils.format( - getProperty(PROGRESS_ADD_PRODUCT_DETAIL_PROPERTY), - product.getDisplayName())); - - LogManager.log("... adding product : " + product.getDisplayName()); - - final List platforms = product.getPlatforms(); - final String entryPrefix = - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/" + - product.getVersion() + "/" + - StringUtils.asString(product.getPlatforms(), " "); - final String uriPrefix = - FileProxy.RESOURCE_SCHEME_PREFIX + - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/" + - product.getVersion() + "/" + - StringUtils.asString(platforms, "%20"); - - // create the required directories structure - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/"); - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/" + - product.getVersion() + "/" + - StringUtils.asString(product.getPlatforms(), " ") + "/"); - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/" + - product.getVersion() + "/" + - StringUtils.asString(product.getPlatforms(), " ") + "/" + - "logic" + "/"); - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - product.getUid() + "/" + - product.getVersion() + "/" + - StringUtils.asString(product.getPlatforms(), " ") + "/" + - "data" + "/"); - - // transfer the icon - putNextEntry(output, entryPrefix + "/icon.png"); - StreamUtils.transferFile( - new File(product.getIconUri().getLocal()), - output); - - // correct the local uri for the icon, so it gets saved correctly in - // the registry file - product.getIconUri().setLocal(new URI(uriPrefix + "/icon.png")); - - // transfer the configuration logic files - final List logicUris = product.getLogicUris(); - for (int i = 0; i < logicUris.size(); i++) { - final ExtendedUri logicUri = logicUris.get(i); - - // check for cancel status - if (isCanceled()) return; - - // transfer the file - putNextEntry(output, - entryPrefix + "/logic/logic," + (i + 1) + ".jar"); - StreamUtils.transferFile( - new File(logicUri.getLocal()), - output); - - // delete the downloaded file -- we need to delete it only in - // case it has been really downloaded, i.e. the local URI is - // different from the main remote one and the alternates - if (!logicUri.getLocal().equals(logicUri.getRemote()) && - !logicUri.getAlternates().contains(logicUri.getLocal())) { - FileUtils.deleteFile(new File(logicUri.getLocal())); - } - - // correct the local uri, so it gets saved correctly - logicUris.get(i).setLocal( - new URI(uriPrefix + "/logic/logic," + (i + 1) + ".jar")); - } - - // transfer the installation data files - final List dataUris = product.getDataUris(); - for (int i = 0; i < dataUris.size(); i++) { - final ExtendedUri dataUri = dataUris.get(i); - - // check for cancel status - if (isCanceled()) return; - - // transfer the file - if (System.getProperty(CUSTOM_DATA_URI_PREFIX_PROPERTY) == null) { - putNextEntry(output, - entryPrefix + "/data/data," + (i + 1) + ".jar"); - StreamUtils.transferFile( - new File(dataUris.get(i).getLocal()), - output); - } - // delete the downloaded file -- we need to delete it only in - // case it has been really downloaded, i.e. the local URI is - // different from the main remote one and the alternates - if (!dataUri.getLocal().equals(dataUri.getRemote()) && - !dataUri.getAlternates().contains(dataUri.getLocal())) { - FileUtils.deleteFile(new File(dataUri.getLocal())); - } - - // correct the local uri, so it gets saved correctly - if (System.getProperty(CUSTOM_DATA_URI_PREFIX_PROPERTY) == null) { - dataUris.get(i).setLocal(new URI( - uriPrefix + "/data/data," + (i + 1) + ".jar")); - } else { - String fileName = product.getUid() + "," + product.getVersion() + "," + StringUtils.asString(platforms, "%20") + "," + (i + 1) + ".jar"; - dataUris.get(i).setLocal(new URI(System.getProperty(CUSTOM_DATA_URI_PREFIX_PROPERTY) + "/" + fileName)); - } - } - - // correct the product's status, so it gets saved correctly in the - // registry file - product.setStatus(Status.NOT_INSTALLED); - - // increment the progress percentage - progress.addPercentage(percentageChunk); - } - - LogManager.log("... adding " + groups.size() + " groups"); - for (Group group: groups) { - // check for cancel status - if (isCanceled()) return; - - // we should skip the registry root, as it is a somewhat artificial - // node and does not have any meaning - if (group.equals(registry.getRegistryRoot())) { - continue; - } - - progress.setDetail(StringUtils.format( - getProperty(PROGRESS_ADD_GROUP_DETAIL_PROPERTY), - group.getDisplayName())); - LogManager.log("... adding group : " + group.getDisplayName()); - final String entryPrefix = - EngineResources.DATA_DIRECTORY + "/" + - group.getUid(); - final String uriPrefix = - FileProxy.RESOURCE_SCHEME_PREFIX + - EngineResources.DATA_DIRECTORY + "/" + - group.getUid(); - - // create the required directories structure - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - group.getUid() + "/"); - - // transfer the icon - putNextEntry(output, entryPrefix + "/icon.png"); - StreamUtils.transferFile( - new File(group.getIconUri().getLocal()), - output); - - // correct the local uri for the icon, so it gets saved correctly in - // the registry file - group.getIconUri().setLocal(new URI(uriPrefix + "/icon.png")); - - // increment the progress percentage - progress.addPercentage(percentageChunk); - } - - // check for cancel status - if (isCanceled()) return; - - // serialize the registry: get the document and save it to the jar file - putNextEntry(output, - EngineResources.DATA_DIRECTORY + "/" + - Registry.DEFAULT_BUNDLED_REGISTRY_FILE_NAME); - XMLUtils.saveXMLDocument( - registry.getRegistryDocument(filter, false, true, true), output); - - // finally perform some minor cleanup to avoid errors later in the main - // registry finalization - we set the local uri to be null, to avoid - // cleanup attempts (they would fail, as the local uris now look like - // resource:<...> - for (Product product: products) { - for (ExtendedUri uri: product.getLogicUris()) { - uri.setLocal(null); - } - for (ExtendedUri uri: product.getDataUris()) { - uri.setLocal(null); - } - } - - // set the products' status back to installed so that they are - // correctly mentioned in the state file - for (Product product: products) { - product.setStatus(Status.INSTALLED); - } - } catch (IOException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_BUNDLE_PROPERTY), e); - } catch (XMLException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_BUNDLE_PROPERTY), e); - } catch (FinalizationException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_BUNDLE_PROPERTY), e); - } catch (URISyntaxException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_BUNDLE_PROPERTY), e); - } finally { - if (engine != null) { - try { - engine.close(); - } catch (IOException e) { - ErrorManager.notifyDebug("Failed to close the stream", e); - } - } - if (output != null) { - try { - output.close(); - } catch (IOException e) { - ErrorManager.notifyDebug("Failed to close the stream", e); - } - } - long seconds = System.currentTimeMillis() - started; - LogManager.log("... generating bundle finished"); - LogManager.log("[bundle] Time : " + (seconds / 1000) + "." + (seconds % 1000) + " seconds"); - LogManager.unindent(); - } - } - - @Override - public void cancel() { - super.cancel(); - - if (progress != null) { - progress.setCanceled(true); - } - } - - private void putNextEntry(JarOutputStream output, String entryName) throws IOException { - putNextEntry(output, new JarEntry(entryName)); - } - - private void putNextEntry(JarOutputStream output, JarEntry je) throws IOException { - if (!jarEntries.add(je.getName())) { - LogManager.log(ErrorLevel.MESSAGE, "... already exist, skipping " + je.getName()); - } else { - output.putNextEntry(je); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateMacOSAppLauncherAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateMacOSAppLauncherAction.java deleted file mode 100644 index 8e93c8095e9b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateMacOSAppLauncherAction.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.zip.ZipOutputStream; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.EngineUtils; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.utils.system.launchers.LauncherResource; -import org.netbeans.installer.utils.system.launchers.impl.CommandLauncher; -import org.netbeans.installer.wizard.components.WizardAction; -import static org.netbeans.installer.wizard.components.actions.CreateNativeLauncherAction.BUNDLED_JVM_FILE_PROPERTY; - -/** - * - * @author Dmitry Lipin - */ -public class CreateMacOSAppLauncherAction extends WizardAction { - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - CreateMacOSAppLauncherAction.class, - "CMALA.title"); // NOI18N - - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - CreateMacOSAppLauncherAction.class, - "CMALA.description"); // NOI18N - public static final String DEFAULT_ERROR_FAILED_CREATE_LAUNCHER = - ResourceUtils.getString( - CreateMacOSAppLauncherAction.class, - "CMALA.error.failed.create.launcher");//NOI18N - public static final String ERROR_FAILED_CREATE_LAUNCHER_PROPERTY = - "error.failed.create.launcher";//NOI18N - - public static final String APP_NAME_PROPERTY = - "nbi.macosx.application.directory.name"; // NOI18N - - public static final String DEFAULT_APP_DIRECTORY_NAME = - "NetBeans Installer"; // NOI18N - - public static final String DEFAULT_ICNS_ICON_NAME = - "icon.icns"; //NOI18N - - - public CreateMacOSAppLauncherAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - setProperty(ERROR_FAILED_CREATE_LAUNCHER_PROPERTY, - DEFAULT_ERROR_FAILED_CREATE_LAUNCHER); - } - - public void execute() { - LogManager.logEntry("creating the macosx app launcher"); - - final String targetPath = - System.getProperty(Registry.CREATE_BUNDLE_PATH_PROPERTY); - final File targetFile = new File(targetPath); - - final Progress progress = new Progress(); - - getWizardUi().setProgress(progress); - - try { - final Platform platform = Registry.getInstance().getTargetPlatform(); - final LauncherProperties properties = new LauncherProperties(); - - final String appNameSystem = System.getProperty(APP_NAME_PROPERTY); - - final String appName = (appNameSystem!=null) ? - appNameSystem : - DEFAULT_APP_DIRECTORY_NAME; - - final String testJDKName = ResourceUtils.getResourceFileName(JavaUtils.TEST_JDK_RESOURCE); - properties.addJar(new LauncherResource( - LauncherResource.Type.RELATIVE_LAUNCHER_PARENT, - "../Resources/" + - appName + - "/" + new File(targetPath).getName())); - properties.setTestJVM(new LauncherResource( - LauncherResource.Type.RELATIVE_LAUNCHER_PARENT, - "../Resources/" + - appName + - "/" + - testJDKName)); - - properties.setJvmArguments(new String[]{ - "-Xmx256m", - "-Xms64m" - }); - - properties.setMainClass(EngineUtils.getEngineMainClass().getName()); - properties.setTestJVMClass(JavaUtils.TEST_JDK_CLASSNAME); - - File tmpDirectory = - FileUtils.createTempFile(SystemUtils.getTempDirectory(), false, true); - FileUtils.mkdirs(tmpDirectory); - - File appDirectory = new File(tmpDirectory, appName + ".app"); - File contentsDirectory = new File(appDirectory, "Contents"); - File resDirectory = new File(contentsDirectory, "Resources"); - File macosDirectory = new File(contentsDirectory, "MacOS"); - File appInsideDir = new File(resDirectory, appName); - File outputFile = new File(macosDirectory, "executable"); - - FileUtils.mkdirs(appDirectory); - FileUtils.mkdirs(contentsDirectory); - FileUtils.mkdirs(resDirectory); - FileUtils.mkdirs(appInsideDir); - FileUtils.mkdirs(macosDirectory); - - final String iconName = DEFAULT_ICNS_ICON_NAME; - - properties.setOutput(outputFile, false); - - - String iconUri = System.getProperty(CommandLauncher.JAVA_APPLICATION_ICON_PROPERTY); - - if(iconUri == null) { - iconUri = CommandLauncher.JAVA_APPLICATION_ICON_DEFAULT_URI; - } - - File iconFile = FileProxy.getInstance().getFile(iconUri,true); - - File iconFileTarget = new File(resDirectory, iconName); - - FileUtils.copyFile(iconFile,iconFileTarget); - - properties.getJvmArguments().add("-Xdock:icon=" + - LauncherResource.Type.RELATIVE_LAUNCHER_PARENT. - getPathString("../Resources/" + iconName)); - - if (System.getProperty(BUNDLED_JVM_FILE_PROPERTY) != null) { - final LauncherResource jvm = new LauncherResource( - new File(System.getProperty(BUNDLED_JVM_FILE_PROPERTY))); - properties.addJVM(jvm); - properties.getJvmArguments().add( - "-D" + BUNDLED_JVM_FILE_PROPERTY + "=" - + jvm.getAbsolutePath()); - } - - File file = SystemUtils.createLauncher(properties, platform, progress). - getOutputFile(); - - File testJDKFile = FileProxy.getInstance().getFile(JavaUtils.TEST_JDK_URI,true); - - FileUtils.copyFile(testJDKFile, - new File(appInsideDir, testJDKName)); - - FileUtils.copyFile(targetFile, - new File(appInsideDir, targetFile.getName())); - - File infoplist = new File(contentsDirectory, "Info.plist"); - FileUtils.writeFile(infoplist, StringUtils.format( - FileUtils.INFO_PLIST_STUB, appName, 1.0, 0, - outputFile.getName(), - iconFileTarget.getName())); - - final String name = targetFile.getName(); - final int index = name.lastIndexOf("."); - final String zipName = name.substring(0, (index==-1) ? name.length() : index) + ".zip"; - - File zipFile = new File(targetFile.getParentFile(), zipName); - ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); - - FileUtils.zip(appDirectory, zos, appDirectory.getParentFile(), new ArrayList ()); - zos.close(); - FileUtils.deleteFile(tmpDirectory, true); - - System.setProperty( - Registry.CREATE_BUNDLE_PATH_PROPERTY, - zipFile.getPath()); - if ( !targetFile.equals(file)) { - FileUtils.deleteFile(targetFile); - System.setProperty( - Registry.CREATE_BUNDLE_PATH_PROPERTY, - file.getPath()); - - } - } catch (IOException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_LAUNCHER_PROPERTY), e); - } catch (DownloadException e) { - ErrorManager.notifyError(getProperty(ERROR_FAILED_CREATE_LAUNCHER_PROPERTY), e); - } - - LogManager.logExit("finished creating the app launcher"); - } - - @Override - public boolean canExecuteForward() { - return !Boolean.getBoolean(Registry.CREATE_BUNDLE_SKIP_NATIVE_LAUNCHER_PROPERTY); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateNativeLauncherAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateNativeLauncherAction.java deleted file mode 100644 index e611148e5336..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/CreateNativeLauncherAction.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.IOException; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.system.launchers.LauncherResource; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.launchers.LauncherProperties; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Dmitry Lipin - */ -public class CreateNativeLauncherAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - CreateNativeLauncherAction.class, - "CNLA.title"); // NOI18N - - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - CreateNativeLauncherAction.class, - "CNLA.description"); // NOI18N - public static final String DEFAULT_ERROR_FAILED_CREATE_LAUNCHER = - ResourceUtils.getString( - CreateNativeLauncherAction.class, - "CNLA.error.failed.create.launcher");//NOI18N - public static final String ERROR_FAILED_CREATE_LAUNCHER_PROPERTY = - "error.failed.create.launcher";//NOI18N - public static final String BUNDLED_JVM_FILE_PROPERTY = - "nbi.bundled.jvm.file"; - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public CreateNativeLauncherAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - setProperty(ERROR_FAILED_CREATE_LAUNCHER_PROPERTY, - DEFAULT_ERROR_FAILED_CREATE_LAUNCHER); - } - - public void execute() { - LogManager.logEntry("creating the native launcher"); - - final String targetPath = - System.getProperty(Registry.CREATE_BUNDLE_PATH_PROPERTY); - final File targetFile = new File(targetPath); - - final Progress progress = new Progress(); - - getWizardUi().setProgress(progress); - try { - final Platform platform = Registry.getInstance().getTargetPlatform(); - final LauncherProperties properties = new LauncherProperties(); - - properties.addJar(new LauncherResource(new File(targetPath))); - - properties.setJvmArguments(new String[]{ - "-Xmx256m", - "-Xms64m" - }); - if(System.getProperty(BUNDLED_JVM_FILE_PROPERTY)!=null) { - final LauncherResource jvm = new LauncherResource( - new File(System.getProperty(BUNDLED_JVM_FILE_PROPERTY))); - properties.addJVM(jvm); - properties.getJvmArguments().add( - "-D" + BUNDLED_JVM_FILE_PROPERTY + "=" + - jvm.getAbsolutePath()); - } - File file = SystemUtils.createLauncher( - properties, platform, progress).getOutputFile(); - - if ( !targetFile.equals(file)) { - FileUtils.deleteFile(targetFile); - System.setProperty( - Registry.CREATE_BUNDLE_PATH_PROPERTY, - file.getPath()); - - } - } catch (IOException e) { - ErrorManager.notifyError( - getProperty(ERROR_FAILED_CREATE_LAUNCHER_PROPERTY), e); - } - LogManager.logExit("finished creating the native launcher"); - } - @Override - public boolean canExecuteForward() { - return !Boolean.getBoolean(Registry.CREATE_BUNDLE_SKIP_NATIVE_LAUNCHER_PROPERTY); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadConfigurationLogicAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadConfigurationLogicAction.java deleted file mode 100644 index 48a105d0d393..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadConfigurationLogicAction.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryType; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -public class DownloadConfigurationLogicAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.description"); // NOI18N - - - public static final String DEFAULT_PROGRESS_TITLE_LOCAL = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.progress.local.title"); //NOI18N - public static final String PROGRESS_TITLE_LOCAL_PROPERTY = - "progress.title.local";//NOI18N - - public static final String DEFAULT_PROGRESS_TITLE_REMOTE = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.progress.remote.title"); //NOI18N - public static final String PROGRESS_TITLE_REMOTE_PROPERTY = - "progress.title.remote";//NOI18N - - public static final String DEFAULT_DOWNLOAD_FAILED_EXCEPTION = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.failed"); //NOI18N - public static final String DOWNLOAD_FAILED_EXCEPTION_PROPERTY = - "download.failed";//NOI18N - - public static final String DEFAULT_DEPENDENT_FAILED_EXCEPTION = - ResourceUtils.getString(DownloadConfigurationLogicAction.class, - "DCLA.dependent.failed"); //NOI18N - - public static final String DEPENDENT_FAILED_EXCEPTION_PROPERTY = - "download.dependent.failed"; //NOI18N - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private CompositeProgress overallProgress; - private Progress currentProgress; - - public DownloadConfigurationLogicAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - setProperty(PROGRESS_TITLE_LOCAL_PROPERTY, DEFAULT_PROGRESS_TITLE_LOCAL); - setProperty(PROGRESS_TITLE_REMOTE_PROPERTY, DEFAULT_PROGRESS_TITLE_REMOTE); - setProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY, DEFAULT_DOWNLOAD_FAILED_EXCEPTION); - setProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY, DEFAULT_DEPENDENT_FAILED_EXCEPTION); - } - - public boolean canExecuteForward() { - for (Product product: Registry.getInstance().getProductsToInstall()) { - if (!product.isLogicDownloaded()) { - return true; - } - } - - return false; - } - - public void execute() { - final Registry registry = Registry.getInstance(); - final List products = registry.getProductsToInstall(); - final int percentageChunk = Progress.COMPLETE / products.size(); - final int percentageLeak = Progress.COMPLETE % products.size(); - - overallProgress = new CompositeProgress(); - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeDetails(true); - - getWizardUi().setProgress(overallProgress); - for (int i = 0; i < products.size(); i++) { - // get the handle of the current item - final Product product = products.get(i); - - // initiate the progress for the current element - currentProgress = new Progress(); - - overallProgress.addChild(currentProgress, percentageChunk); - try { - String prop = product.getRegistryType() == RegistryType.REMOTE ? - PROGRESS_TITLE_REMOTE_PROPERTY : - PROGRESS_TITLE_LOCAL_PROPERTY; - String overallProgressTitle = StringUtils.format( - getProperty(prop), product.getDisplayName()); - - overallProgress.setTitle(overallProgressTitle); - - product.downloadLogic(currentProgress); - - // ensure that the current progress has reached the complete state - // (sometimes it just does not happen and we're left over with 99%) - currentProgress.setPercentage(Progress.COMPLETE); - - // check for cancel status - if (isCanceled()) return; - - // sleep a little so that the user can perceive that something - // is happening - SystemUtils.sleep(200); - } catch (DownloadException e) { - // wrap the download exception with a more user-friendly one - final InstallationException error = new InstallationException( - StringUtils.format( - getProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY), - product.getDisplayName()), e); - - // adjust the product's status and save this error - it will - // be reused later at the PostInstallSummary - product.setStatus(Status.NOT_INSTALLED); - product.setInstallationError(error); - - // since the configuration logic for the current product failed to - // be downloaded, we should cancel the installation of the products - // that may require this one - for(Product dependent: registry.getProducts()) { - if ((dependent.getStatus() == Status.TO_BE_INSTALLED) && - registry.satisfiesRequirement(product, dependent)) { - String exString = StringUtils.format( - getProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY), - dependent.getDisplayName(), - product.getDisplayName()); - - final InstallationException dependentError = - new InstallationException(exString, error); - - dependent.setStatus(Status.NOT_INSTALLED); - dependent.setInstallationError(dependentError); - - products.remove(dependent); - } - } - - // finally notify the user of what has happened - ErrorManager.notify(ErrorLevel.ERROR, error); - } - } - } - - public void cancel() { - if (currentProgress != null) { - currentProgress.setCanceled(true); - } - - if (overallProgress != null) { - overallProgress.setCanceled(true); - } - - super.cancel(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadInstallationDataAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadInstallationDataAction.java deleted file mode 100644 index 0e9c2c333ea2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/DownloadInstallationDataAction.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryType; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -public class DownloadInstallationDataAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.description"); // NOI18N - - public static final String DEFAULT_PROGRESS_TITLE_LOCAL = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.progress.local.title"); //NOI18N - public static final String PROGRESS_TITLE_LOCAL_PROPERTY = - "progress.title.local";//NOI18N - - public static final String DEFAULT_PROGRESS_TITLE_REMOTE = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.progress.remote.title"); //NOI18N - public static final String PROGRESS_TITLE_REMOTE_PROPERTY = - "progress.title.remote";//NOI18N - - public static final String DEFAULT_DOWNLOAD_FAILED_EXCEPTION = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.failed"); //NOI18N - public static final String DOWNLOAD_FAILED_EXCEPTION_PROPERTY = - "download.failed";//NOI18N - - public static final String DEFAULT_DEPENDENT_FAILED_EXCEPTION = - ResourceUtils.getString(DownloadInstallationDataAction.class, - "DIDA.dependent.failed"); //NOI18N - public static final String DEPENDENT_FAILED_EXCEPTION_PROPERTY = - "download.dependent.failed"; //NOI18N - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private CompositeProgress overallProgress; - private Progress currentProgress; - - public DownloadInstallationDataAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - setProperty(PROGRESS_TITLE_LOCAL_PROPERTY, DEFAULT_PROGRESS_TITLE_LOCAL); - setProperty(PROGRESS_TITLE_REMOTE_PROPERTY, DEFAULT_PROGRESS_TITLE_REMOTE); - setProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY, DEFAULT_DOWNLOAD_FAILED_EXCEPTION); - setProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY, DEFAULT_DEPENDENT_FAILED_EXCEPTION); - } - - public void execute() { - LogManager.logEntry("getting all installation data"); - final Registry registry = Registry.getInstance(); - final List products = registry.getProductsToInstall(); - final int percentageChunk = Progress.COMPLETE / products.size(); - final int percentageLeak = Progress.COMPLETE % products.size(); - - overallProgress = new CompositeProgress(); - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeDetails(true); - - getWizardUi().setProgress(overallProgress); - for (int i = 0; i < products.size(); i++) { - // get the handle of the current item - final Product product = products.get(i); - - // initiate the progress for the current element - currentProgress = new Progress(); - - overallProgress.addChild(currentProgress, percentageChunk); - try { - String prop = product.getRegistryType() == RegistryType.REMOTE ? - PROGRESS_TITLE_REMOTE_PROPERTY : - PROGRESS_TITLE_LOCAL_PROPERTY; - String overallProgressTitle = StringUtils.format( - getProperty(prop), product.getDisplayName()); - overallProgress.setTitle(overallProgressTitle); - - product.downloadData(currentProgress); - - // check for cancel status - if (isCanceled()) return; - - // sleep a little so that the user can perceive that something - // is happening - SystemUtils.sleep(200); - } catch (DownloadException e) { - // wrap the download exception with a more user-friendly one - InstallationException error = new InstallationException( - StringUtils.format( - getProperty(DOWNLOAD_FAILED_EXCEPTION_PROPERTY), - product.getDisplayName()), e); - - // adjust the product's status and save this error - it will - // be reused later at the PostInstallSummary - product.setStatus(Status.NOT_INSTALLED); - product.setInstallationError(error); - - // since the installation data for the current product failed to - // be downloaded, we should cancel the installation of the products - // that may require this one - for(Product dependent: registry.getProducts()) { - if ((dependent.getStatus() == Status.TO_BE_INSTALLED) && - registry.satisfiesRequirement(product, dependent)) { - String exString = StringUtils.format( - getProperty(DEPENDENT_FAILED_EXCEPTION_PROPERTY), - dependent.getDisplayName(), - product.getDisplayName()); - - final InstallationException dependentError = - new InstallationException(exString, error); - - dependent.setStatus(Status.NOT_INSTALLED); - dependent.setInstallationError(dependentError); - - products.remove(dependent); - } - } - - // finally notify the user of what has happened - LogManager.log(ErrorLevel.ERROR, error); - } - } - LogManager.logExit("... finished getting of the installation data"); - } - - public void cancel() { - if (currentProgress != null) { - currentProgress.setCanceled(true); - } - - if (overallProgress != null) { - overallProgress.setCanceled(true); - } - - super.cancel(); - } - - public boolean canExecuteForward() { - return Registry.getInstance().getProductsToInstall().size() > 0; - } - - public boolean isPointOfNoReturn() { - return true; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/FinalizeRegistryAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/FinalizeRegistryAction.java deleted file mode 100644 index 8f5ae5fa044d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/FinalizeRegistryAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Kirill Sorokin - */ -public class FinalizeRegistryAction extends WizardAction { - public FinalizeRegistryAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - setProperty(REGISTRY_FINALIZATION_FAILED_PROPERTY, - DEFAULT_REGISTRY_FINALIZATION_FAILED_MESSAGE); - } - - public void execute() { - try { - Registry.getInstance().finalizeRegistry(new Progress()); - } catch (FinalizationException e) { - ErrorManager.notifyError(StringUtils.format( - getProperty(REGISTRY_FINALIZATION_FAILED_PROPERTY)), e); - } - } - - public WizardActionUi getWizardUi() { - return null; // this action does not have a ui - } - - @Override - public boolean isCancelable() { - return false; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - FinalizeRegistryAction.class, - "FRA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - FinalizeRegistryAction.class, - "FRA.description"); // NOI18N - public static final String DEFAULT_REGISTRY_FINALIZATION_FAILED_MESSAGE = - ResourceUtils.getString( - FinalizeRegistryAction.class, - "FRA.registry.finalization.failed"); // NOI18N - public static final String REGISTRY_FINALIZATION_FAILED_PROPERTY = - "registry.finalization.failed"; // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InitializeRegistryAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InitializeRegistryAction.java deleted file mode 100644 index d3cfa58ecb84..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InitializeRegistryAction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Kirill Sorokin - */ -public class InitializeRegistryAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public InitializeRegistryAction() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - setProperty(REGISTRY_INITIALIZATION_FAILED_PROPERTY, - DEFAULT_REGISTRY_INITIALIZATION_FAILED_MESSAGE); - } - - public void execute() { - try { - final Progress progress = new Progress(); - - getWizardUi().setProgress(progress); - Registry.getInstance().initializeRegistry(progress); - } catch (InitializationException e) { - ErrorManager.notifyError( - StringUtils.format( - getProperty(REGISTRY_INITIALIZATION_FAILED_PROPERTY)), e); - } - } - - @Override - public boolean isCancelable() { - return false; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = ResourceUtils.getString( - InitializeRegistryAction.class, - "IRA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = ResourceUtils.getString( - InitializeRegistryAction.class, - "IRA.description"); // NOI18N - public static final String DEFAULT_REGISTRY_INITIALIZATION_FAILED_MESSAGE = - ResourceUtils.getString( - InitializeRegistryAction.class, - "IRA.registry.initialization.failed"); // NOI18N - public static final String REGISTRY_INITIALIZATION_FAILED_PROPERTY = - "registry.initialization.failed"; // NOI18N - -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InstallAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InstallAction.java deleted file mode 100644 index 6f21e5b50567..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/InstallAction.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.wizard.components.actions; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.filters.OrFilter; -import org.netbeans.installer.product.filters.ProductFilter; -import org.netbeans.installer.product.filters.RegistryFilter; -import org.netbeans.installer.utils.helper.DetailedStatus; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.InstallationException; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -public class InstallAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - - public static final String DEFAULT_TITLE = - ResourceUtils.getString(InstallAction.class, - "IA.title"); // NOI18N - - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(InstallAction.class, - "IA.description"); // NOI18N - - public static final String DEFAULT_PROGRESS_INSTALL_TITLE = - ResourceUtils.getString(InstallAction.class, - "IA.progress.install.title"); // NOI18N - - public static final String PROGRESS_INSTALL_TITLE_PROPERTY = - "progress.install.title"; //NOI18N - - public static final String DEFAULT_PROGRESS_ROLLBACK_TITLE = - ResourceUtils.getString(InstallAction.class, - "IA.progress.rollback.title"); // NOI18N - - public static final String PROGRESS_ROLLBACK_TITLE_PROPERTY = - "progress.rollback.title"; //NOI18N - - public static final String DEFAULT_INSTALL_DEPENDENT_FAILED_EXCEPTION = - ResourceUtils.getString(InstallAction.class, - "IA.install.dependent.failed");//NOI18N - - public static final String INSTALL_DEPENDENT_FAILED_EXCEPTION_PROPERTY = - "install.dependent.failed"; - public static final String DEFAULT_INSTALL_UNKNOWN_ERROR = - ResourceUtils.getString(InstallAction.class, - "IA.install.unknown.error");//NOI18N - - public static final String INSTALL_UNKNOWN_ERROR_PROPERTY = - "install.unknown.error"; - - public static final int INSTALLATION_ERROR_CODE = - 127;//NOMAGI - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - private CompositeProgress overallProgress; - private Progress currentProgress; - - public InstallAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - setProperty(PROGRESS_INSTALL_TITLE_PROPERTY, - DEFAULT_PROGRESS_INSTALL_TITLE); - setProperty(PROGRESS_ROLLBACK_TITLE_PROPERTY, - DEFAULT_PROGRESS_ROLLBACK_TITLE); - setProperty(INSTALL_DEPENDENT_FAILED_EXCEPTION_PROPERTY, - DEFAULT_INSTALL_DEPENDENT_FAILED_EXCEPTION); - setProperty(INSTALL_UNKNOWN_ERROR_PROPERTY, - DEFAULT_INSTALL_UNKNOWN_ERROR); - } - - public boolean canExecuteForward() { - return Registry.getInstance().getProductsToInstall().size() > 0; - } - - public boolean isPointOfNoReturn() { - return true; - } - - public void execute() { - LogManager.logIndent("Start products installation"); - final Registry registry = Registry.getInstance(); - final List products = registry.getProductsToInstall(); - int percentageChunk = Progress.COMPLETE / products.size(); - int percentageLeak = Progress.COMPLETE % products.size(); - final Map progresses = new HashMap(); - - overallProgress = new CompositeProgress(); - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeDetails(true); - - getWizardUi().setProgress(overallProgress); - for (int i = 0; i < products.size(); i++) { - // get the handle of the current item - final Product product = products.get(i); - - // initiate the progress for the current element - currentProgress = new Progress(); - - overallProgress.addChild(currentProgress, percentageChunk); - overallProgress.setTitle(StringUtils.format(getProperty(PROGRESS_INSTALL_TITLE_PROPERTY), - product.getDisplayName())); - boolean isProductRolledback = false; - try { - product.install(currentProgress); - - if (isCanceled()) { - LogManager.log("... installation is cancelled : " + - product.getDisplayName() + - "(" + product.getUid() + "/" + product.getVersion() + ")"); - overallProgress.setTitle(StringUtils.format(getProperty(PROGRESS_ROLLBACK_TITLE_PROPERTY), - product.getDisplayName())); - product.rollback(currentProgress); - isProductRolledback = true; - - - for (Product toInstall : registry.getProductsToInstall()) { - LogManager.log("... marking to-be-installed product as not-installed : " + toInstall); - toInstall.setStatus(Status.NOT_INSTALLED); - } - - final RegistryFilter filter = new OrFilter(new ProductFilter(DetailedStatus.INSTALLED_SUCCESSFULLY), - new ProductFilter(DetailedStatus.INSTALLED_WITH_WARNINGS)); - for (Product installed : registry.queryProducts(filter)) { - LogManager.log("... marking installed product as to-be-uninstalled : " + installed); - installed.setStatus(Status.TO_BE_UNINSTALLED); - } - - - for (Product toRollback : registry.getProductsToUninstall()) { - LogManager.log("... also rollbacking " + toRollback.getDisplayName() + - "(" + toRollback.getUid() + "/" + toRollback.getVersion() + ")"); - overallProgress.setTitle(StringUtils.format(getProperty(PROGRESS_ROLLBACK_TITLE_PROPERTY), - toRollback.getDisplayName())); - toRollback.rollback(progresses.get(toRollback)); - } - break; - } - - progresses.put(product, currentProgress); - - // sleep a little so that the user can perceive that something - // is happening - SystemUtils.sleep(200); - } catch (Throwable e) { - LogManager.log(e); - if (!(e instanceof InstallationException)) { - e = new InstallationException(getProperty(INSTALL_UNKNOWN_ERROR_PROPERTY), e); - } - // do not override already set exit code - if (System.getProperties().get(Installer.EXIT_CODE_PROPERTY) == null) { - System.getProperties().put(Installer.EXIT_CODE_PROPERTY, - Integer.valueOf(INSTALLATION_ERROR_CODE)); - } - // adjust the product's status and save this error - it will - // be reused later at the PostInstallSummary - product.setStatus(Status.NOT_INSTALLED); - product.setInstallationError(e); - - // since the current product failed to install, we should cancel the - // installation of the products that may require this one - for (Product dependent : registry.getProducts()) { - if ((dependent.getStatus() == Status.TO_BE_INSTALLED) && - registry.satisfiesRequirement(product, dependent)) { - final String exceptionName = StringUtils.format(getProperty(INSTALL_DEPENDENT_FAILED_EXCEPTION_PROPERTY), - dependent.getDisplayName(), - product.getDisplayName()); - - final InstallationException dependentError = - new InstallationException(exceptionName, e); - - dependent.setStatus(Status.NOT_INSTALLED); - dependent.setInstallationError(dependentError); - - products.remove(dependent); - } - } - - if(!isProductRolledback) { - try{ - overallProgress.setTitle(StringUtils.format( - getProperty(PROGRESS_ROLLBACK_TITLE_PROPERTY), - product.getDisplayName())); - product.rollback(currentProgress); - }catch(Exception uie) { - LogManager.log(uie); - } - } - overallProgress.removeChild(currentProgress); - final int productsToInstallSize = registry.getProductsToInstall().size(); - if(productsToInstallSize > 0) { - final int theRestOfPercentage = Progress.COMPLETE - - overallProgress.getPercentage(); - percentageChunk = theRestOfPercentage / productsToInstallSize; - percentageLeak = theRestOfPercentage % productsToInstallSize; - overallProgress.addPercentage(percentageLeak); - } - - // finally notify the user of what has happened - LogManager.log(ErrorLevel.ERROR, e); - } - } - LogManager.logUnindent("... finished products installation"); - } - - public void cancel() { - if (currentProgress != null) { - currentProgress.setCanceled(true); - } - - if (overallProgress != null) { - overallProgress.setCanceled(true); - } - - super.cancel(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SearchForJavaAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SearchForJavaAction.java deleted file mode 100644 index 70876630fa5b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SearchForJavaAction.java +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.*; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.applications.JavaUtils.JavaInfo; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.utils.system.WindowsNativeUtils; -import org.netbeans.installer.utils.system.windows.WindowsRegistry; -import static org.netbeans.installer.utils.system.windows.WindowsRegistry.HKCU; -import static org.netbeans.installer.utils.system.windows.WindowsRegistry.HKLM; -import org.netbeans.installer.wizard.components.WizardAction; -import org.netbeans.installer.wizard.components.panels.JdkLocationPanel; - -/** - * - * @author Kirill Sorokin - */ -public class SearchForJavaAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private static List javaLocations = new LinkedList<>(); - private static List javaLabels = new LinkedList<>(); - - public SearchForJavaAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - } - - @Override - public void execute() { - execute(new Progress()); - } - - public void execute(Progress progress) { - LogManager.logEntry("search for all java locations"); - getWizardUi().setProgress(progress); - final List locations = new LinkedList<>(); - progress.setTitle(SEARCH_INSTALLED_JAVAS); - progress.setDetail(StringUtils.EMPTY_STRING); - progress.setPercentage(Progress.START); - - SystemUtils.sleep(200); - - progress.setDetail(PREPARE_JAVA_LIST); - if (SystemUtils.isWindows()) { - fetchLocationsFromWindowsRegistry(locations); - } - fetchLocationsFromEnvironment(locations); - fetchLocationsFromFilesystem(locations); - fetchLocationsFromRegistry(locations); - getJavaLocationsInfo(locations, progress); - - sortJavaLocations(); - - progress.setDetail(StringUtils.EMPTY_STRING); - progress.setPercentage(Progress.COMPLETE); - - SystemUtils.sleep(200); - LogManager.logExit("... end of search for all java locations"); - } - - @Override - public boolean canExecuteForward() { - return javaLocations.isEmpty(); - } - - // private ////////////////////////////////////////////////////////////////////// - private static String getLabel(File javaHome) { - JavaInfo javaInfo = JavaUtils.getInfo(javaHome); - - return getLabel(javaHome, javaInfo); - } - - private static String getLabel(File javaHome, JavaInfo javaInfo) { - if (javaInfo.isNonFinal()) { - return StringUtils.format(JAVA_ENTRY_LABEL_NON_FINAL, - javaHome, - javaInfo.getVersion().toJdkStyle(), - javaInfo.getArch(), - javaInfo.getVendor()); - } else { - return StringUtils.format(JAVA_ENTRY_LABEL, - javaHome, - javaInfo.getVersion().toJdkStyle(), - javaInfo.getArch(), - javaInfo.getVendor()); - } - } - - private static String getLabel(File javaHome, Version version, String vendor) { - JavaInfo javaInfo = JavaUtils.getInfo(javaHome); - if (javaInfo == null) { - return StringUtils.format(JAVA_ENTRY_LABEL_NO_ARCH, - javaHome, - version.toJdkStyle(), - vendor); - } else { - return StringUtils.format(JAVA_ENTRY_LABEL, - javaHome, - version.toJdkStyle(), - javaInfo.getArch(), - vendor); - } - } - - private void getJavaLocationsInfo(List locations, Progress progress) { - for (int i = 0; i < locations.size(); i++) { - File javaHome = locations.get(i).getAbsoluteFile(); - - progress.setDetail(StringUtils.format(CHECKING, javaHome)); - - if (isCanceled()) return; // check for cancel status - - LogManager.logIndent("investigating java home candidate: " + javaHome); - - // check whether it is a java installation - the result will be null if - // it is not - JavaInfo javaInfo = JavaUtils.getInfo(javaHome); - - if(javaInfo == null) { - final File jreHome = new File(javaHome, "jre"); - if(FileUtils.exists(jreHome)) { - LogManager.log("investigating java home candidate: " + jreHome); - javaInfo = JavaUtils.getInfo(jreHome); - if(javaInfo!=null) { - javaHome = jreHome; - } - } - } - - if (javaInfo != null) { - LogManager.logUnindent( - "... parsed java: " + javaInfo.getVersion() + " " + // NOI18N - "by " + javaInfo.getVendor() + "; " + // NOI18N - "final=" + !javaInfo.isNonFinal()); // NOI18N - - // filter out "private" jres - if (javaHome.getName().equals("jre") && - JavaUtils.isJdk(javaHome.getParentFile())) { - continue; - } - - // add the location to the list if it's not already there - addJavaLocation(javaHome); - } else { - LogManager.unindent(); - } - SystemUtils.sleep(5); - progress.setPercentage(Progress.COMPLETE * i / locations.size()); - } - - } - - public static void sortJavaLocations(){ - // sort the found java installations: - // 1) by final/non-final - // 2) by version descending (6 has priority over 7u9 and older) - // 3) by path acending - // 4) by vendor descending (so Sun comes first, hehe) - for (int i = 0; i < javaLocations.size(); i++) { - for (int j = javaLocations.size() - 1; j > i ; j--) { - File file1 = javaLocations.get(j); - File file2 = javaLocations.get(j - 1); - - String label1 = javaLabels.get(j); - String label2 = javaLabels.get(j - 1); - - JavaInfo info1 = JavaUtils.getInfo(javaLocations.get(j)); - JavaInfo info2 = JavaUtils.getInfo(javaLocations.get(j - 1)); - - if (info1.isNonFinal() == info2.isNonFinal()) { - if (JavaUtils.isRecommended(info1.getVersion()) == JavaUtils.isRecommended(info2.getVersion())) { - if (info1.getVersion().equals(info2.getVersion())) { - // better than compare directly archs is to compare if archs are both 64bit - if (info1.getArch().endsWith("64") == info2.getArch().endsWith("64")) { - if (file1.getPath().compareTo(file2.getPath()) == 0) { - if (info1.getVendor().compareTo(info2.getVendor()) == 0) { - continue; - } else if (info1.getVendor().compareTo(info2.getVendor()) < 0) { - switchNeighbours(j, file2, file1, label2, label1); - } - } else if (file1.getPath().length() < file2.getPath().length()) { - switchNeighbours(j, file2, file1, label2, label1); - } - } else if (info1.getArch().endsWith("64") && !info2.getArch().endsWith("64")) { - switchNeighbours(j, file2, file1, label2, label1); - } - } else if (info1.getVersion().newerThan(info2.getVersion())) { - switchNeighbours(j, file2, file1, label2, label1); - } - } else if (JavaUtils.isRecommended(info1.getVersion()) && !JavaUtils.isRecommended(info2.getVersion())) { - switchNeighbours(j, file2, file1, label2, label1); - } - } else if (!info1.isNonFinal() && info2.isNonFinal()) { - switchNeighbours(j, file2, file1, label2, label1); - } - } - } - } - - private static void switchNeighbours (int j, File file2, File file1, String label2, String label1) { - javaLocations.set(j, file2); - javaLocations.set(j - 1, file1); - - javaLabels.set(j, label2); - javaLabels.set(j - 1, label1); - } - - public static void addJavaLocation(File location, Version version, String vendor) { - File javaHome = getCanonicalFile(location); - if (!javaLocations.contains(javaHome)) { - javaLocations.add(javaHome); - javaLabels.add(getLabel(javaHome, version, vendor)); - JavaUtils.addJavaInfo(javaHome, new JavaInfo(version, vendor)); - } - } - - public static void addJavaLocation(File location) { - File javaHome = getCanonicalFile(location); - if (!javaLocations.contains(javaHome)) { - javaLocations.add(javaHome); - javaLabels.add(getLabel(javaHome)); - } - } - - public static List getJavaLocations() { - return javaLocations; - } - - public static List getJavaLabels() { - return javaLabels; - } - - private static File getCanonicalFile(final File file) { - File location = file; - if (SystemUtils.isWindows() && location.getAbsolutePath().matches(".*~[0-9]+.*")) { - //Issue #166036 - try { - // if C:\Program Files == C:\Progra~1, get canonical representation - location = location.getCanonicalFile(); - if(location!=file) { - LogManager.log("... using " + location + " instead of " + file); - } - } catch (IOException e) { - } - } - return location; - } - - private void fetchLocationsFromFilesystem(final List locations) { - final List candidateLocations = new ArrayList(); - - for(String location : JAVA_FILESYSTEM_LOCATIONS_COMMON) { - candidateLocations.add(location); - } - - if (SystemUtils.isWindows()) { - candidateLocations.addAll( - Arrays.asList(JAVA_FILESYSTEM_LOCATIONS_WINDOWS)); - } else if (SystemUtils.isMacOS()) { - candidateLocations.addAll( - Arrays.asList(JAVA_FILESYSTEM_LOCATIONS_MACOSX)); - } else { - candidateLocations.addAll( - Arrays.asList(JAVA_FILESYSTEM_LOCATIONS_UNIX)); - } - final File currentJava = SystemUtils.getCurrentJavaHome(); - final File currentJavaParentDir = currentJava.getParentFile(); - if(currentJavaParentDir!=null) { - if(JavaUtils.isJavaHome(currentJava) && JavaUtils.isJdk(currentJavaParentDir)) { - //installer runs on private JRE so perform search for - //all children of the parent directory of the corresponding JDK - String parentDir = currentJavaParentDir.getParent(); - if ( parentDir != null ) { - if(!candidateLocations.contains(parentDir)) { - candidateLocations.add(parentDir); - } - } - } - } - for (String location: candidateLocations) { - final File parent = SystemUtils.resolvePath(location); - - if (parent.exists() && parent.isDirectory()) { - locations.add(parent); - final boolean isWindows = SystemUtils.isWindows(); - final boolean isSolaris = SystemUtils.isSolaris(); - final File[] children = parent.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && - (!isSolaris || !pathname.equals(new File("/export/sybase"))) && //workaround for #143292 - (isWindows || !pathname.getName().startsWith(".")); - } - }); - - if (children != null) { - for (File child: children) { - locations.add(child); - } - } else { - LogManager.log(ErrorLevel.DEBUG, - "Can`t get children of existing directory : " + parent.getPath()); - } - } - } - } - - private void fetchLocationsFromEnvironment(final List locations) { - LogManager.logIndent("checking for possible java locations in environment"); - - for (String name: JAVA_ENVIRONMENT_VARIABLES) { - final String value = System.getenv(name); - - if (value != null) { - LogManager.log("found: " + name + " = " + value); // NOI18N - - final File file = new File(value).getAbsoluteFile(); - if (!locations.contains(file)) { - locations.add(file); - } - } - } - - LogManager.logUnindent("... finished"); - } - - private void fetchLocationsFromWindowsRegistry(final List locations) { - LogManager.logIndent("checking for possible java locations in windows registry"); - - final WindowsNativeUtils nativeUtils = - ((WindowsNativeUtils) SystemUtils.getNativeUtils()); - final WindowsRegistry registry = - nativeUtils.getWindowsRegistry(); - - final int currentMode = registry.getMode(); - List modes = new ArrayList <> (); - modes.add(null); //default mode - - if(registry.isAlternativeModeSupported()) { - LogManager.log("... alternative registry view is also supported"); - modes.add(true);//alternative mode - } - try { - for (Boolean mode : modes) { - registry.setMode(mode); - for (int section : new int[]{HKLM, HKCU}) { - for (String path: JAVA_WINDOWS_REGISTRY_ENTRIES) { - // check whether current path exists in this section - if (!registry.keyExists(section, path)) { - continue; - } - - // get the names of all installed jdks - String[] keys = registry.getSubKeyNames(section, path); - - // iterate over the list of jdks, checking their versions - // and taking actions appropriate to the current search - // mode - for (int i = 0; i < keys.length; i++) { - // get the name of the current examined jdk - String key = keys[i]; - - // get the java home of the current jdk, if it exists - if (!registry.valueExists( - section, - path + WindowsRegistry.SEPARATOR + key, - JavaUtils.JAVAHOME_VALUE)) { - continue; - } - - final String javaHome = registry.getStringValue( - section, - path + WindowsRegistry.SEPARATOR + key, - JavaUtils.JAVAHOME_VALUE, - false); - - LogManager.log("found: " + (section == HKLM ? - "HKEY_LOCAL_MACHINE" : "HKEY_CURRENT_USER") + // NOI18N - "\\" + path + "\\" + key + "\\" + // NOI18N - JavaUtils.JAVAHOME_VALUE + " = " + javaHome); // NOI18N - - - // add java home to the list if it's not there already - final File file = new File(javaHome); - if (file.exists() && - file.isDirectory() && - !locations.contains(file)) { - locations.add(file); - } - } - } - } - } - } catch (NativeException e) { - ErrorManager.notify(ErrorLevel.DEBUG, "Failed to search in the windows registry", e); - } finally { - registry.setMode(currentMode); - } - - LogManager.logUnindent("... finished"); - } - - private void fetchLocationsFromRegistry(final List locations) { - for (Product jdk: Registry.getInstance().getProducts(JDK_PRODUCT_UID)) { - if (jdk.getStatus() == Status.INSTALLED) { - if (!locations.contains(jdk.getInstallationLocation())) { - locations.add(jdk.getInstallationLocation()); - } - } - } - - for (Product product: Registry.getInstance().getProducts(Status.TO_BE_INSTALLED)) { - final String jdkSysPropName = product.getUid() + StringUtils.DOT + - JdkLocationPanel.JDK_LOCATION_PROPERTY; - final String jdkSysProp = System.getProperty(jdkSysPropName); - if (jdkSysProp != null) { - File sprop = new File(jdkSysProp); - if (!locations.contains(sprop)) { - locations.add(sprop); - } - } - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.description"); // NOI18N - public static final String PREPARE_JAVA_LIST = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.prepare.list"); //NOI18N - public static final String CHECKING = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.checking");//NOI18N - public static final String SEARCH_INSTALLED_JAVAS = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.search.java");//NOI18N - public static final String JAVA_ENTRY_LABEL = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.entry.label");//NOI18N - public static final String JAVA_ENTRY_LABEL_NO_ARCH = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.entry.label.noarch");//NOI18N - public static final String JAVA_ENTRY_LABEL_NON_FINAL = - ResourceUtils.getString(SearchForJavaAction.class, - "SFJA.entry.label.non.final");//NOI18N - - private static final String JDK_PRODUCT_UID = "jdk"; //NOI18N - - public static final String [] JAVA_WINDOWS_REGISTRY_ENTRIES = new String [] { - "SOFTWARE\\JavaSoft\\Java Development Kit", // NOI18N - "SOFTWARE\\JRockit\\Java Development Kit", // NOI18N - "SOFTWARE\\IBM\\Java Development Kit", // NOI18N - "SOFTWARE\\IBM\\Java2 Development Kit", // NOI18N - - "SOFTWARE\\JavaSoft\\Java Runtime Environment", // NOI18N - "SOFTWARE\\JRockit\\Java Runtime Environment", // NOI18N - "SOFTWARE\\IBM\\Java Runtime Environment", // NOI18N - "SOFTWARE\\IBM\\Java2 Runtime Environment" // NOI18N - }; - - public static final String[] JAVA_ENVIRONMENT_VARIABLES = new String[] { - "JAVA_HOME", // NOI18N - "JAVAHOME", // NOI18N - "JAVA_PATH", // NOI18N - "JDK_HOME", // NOI18N - "JDKHOME", // NOI18N - "ANT_JAVA", // NOI18N - "JAVA", // NOI18N - "JDK" // NOI18N - }; - - public static final String[] JAVA_FILESYSTEM_LOCATIONS_COMMON = new String[] { - "$S{java.home}", // NOI18N - "$S{java.home}/.." // NOI18N - }; - - public static final String[] JAVA_FILESYSTEM_LOCATIONS_UNIX = new String[] { - "$N{home}", // NOI18N - "$N{home}/java", // NOI18N - "$N{home}/jdk", // NOI18N - "$N{home}/Java", // NOI18N - - "$N{install}", // NOI18N - "$N{install}/Java", // NOI18N - - "/usr", // NOI18N - "/usr/jdk", // NOI18N - "/usr/jdk/instances", // NOI18N - "/usr/java", // NOI18N - "/usr/java/jdk", // NOI18N - "/usr/j2se", // NOI18N - "/usr/j2sdk", // NOI18N - - "/usr/local", // NOI18N - "/usr/local/jdk", // NOI18N - "/usr/local/jdk/instances", // NOI18N - "/usr/local/java", // NOI18N - "/usr/local/j2se", // NOI18N - "/usr/local/j2sdk", // NOI18N - - "/export", // NOI18N - "/export/jdk", // NOI18N - "/export/jdk/instances", // NOI18N - "/export/java", // NOI18N - "/export/j2se", // NOI18N - "/export/j2sdk", // NOI18N - - "/opt", // NOI18N - "/opt/jdk", // NOI18N - "/opt/jdk/instances", // NOI18N - "/opt/java", // NOI18N - "/opt/j2se", // NOI18N - "/opt/j2sdk", // NOI18N - - "/usr/lib/jvm", // NOI18N - }; - - public static final String[] JAVA_FILESYSTEM_LOCATIONS_MACOSX = new String[] { - "/Library/Java", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.5", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.6", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.7", // NOI18N - "/System/Library/Frameworks/JavaVM.framework/Versions/1.7.0" // NOI18N - }; - - public static final String[] JAVA_FILESYSTEM_LOCATIONS_WINDOWS = new String[] { - "$N{install}", // NOI18N - "$N{install}/Java" // NOI18N - }; -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SetInstallationLocationAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SetInstallationLocationAction.java deleted file mode 100644 index 891afe122de6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/SetInstallationLocationAction.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.wizard.components.WizardAction; - -/** - * - * @author Kirill Sorokin - */ -public class SetInstallationLocationAction extends WizardAction { - public static final String SOURCE_UID_PROPERTY = - "source.component";//NOI18N - public static final String RELATIVE_LOCATION_PROPERTY = - "relative.location";//NOI18N - - public void execute() { - final String uid = getProperty(SOURCE_UID_PROPERTY); - final String relativeLocation = getProperty(RELATIVE_LOCATION_PROPERTY); - - if (uid == null) { - ErrorManager.notifyError(ResourceUtils.getString( - SetInstallationLocationAction.class, - ERROR_SOURCE_UID_NOT_SET_KEY)); - return; - } - - // we do expect the property container of the wizard to be a product, if - // it's not we should fail - final Product target = (Product) getWizard().getContext().get(Product.class); - - final List dependencies = target.getDependencyByUid(uid); - final Product source = - Registry.getInstance().getProducts(dependencies.get(0)).get(0); - - if (source == null) { - ErrorManager.notifyError(ResourceUtils.getString( - SetInstallationLocationAction.class, - ERROR_CANNOT_FIND_COMPONENT_KEY, uid)); - return; - } - - File sourceLocation = null; - try { - final File location = source.getInstallationLocation(); - if (SystemUtils.isMacOS() && source.getLogic().wrapForMacOs() && - location.getName().endsWith(".app")) { - sourceLocation = new File( - location, - "Contents/Resources/" + - location.getName().replaceAll("\\.app$","")); - } else { - sourceLocation = location; - } - } catch (InitializationException e) { - ErrorManager.notifyError(ResourceUtils.getString( - SetInstallationLocationAction.class, - ERROR_CANNOT_GET_LOGIC_KEY, - target.getDisplayName()), e); - } - - final File location; - if (relativeLocation != null) { - location = new File(sourceLocation, relativeLocation); - } else { - location = sourceLocation; - } - - target.setInstallationLocation(location.getAbsoluteFile()); - } - - public WizardActionUi getWizardUi() { - return null; // we do not have any ui for this action - } - - public boolean isCancellable() { - return false; - } - - private static final String ERROR_SOURCE_UID_NOT_SET_KEY = - "SILA.error.source.uid.not.set";//NOI18N - private static final String ERROR_CANNOT_FIND_COMPONENT_KEY = - "SILA.error.cannot.find.component";//NOI18N - private static final String ERROR_CANNOT_GET_LOGIC_KEY = - "SILA.error.cannot.get.logic";//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/UninstallAction.java b/nbi/engine/src/org/netbeans/installer/wizard/components/actions/UninstallAction.java deleted file mode 100644 index ae4f6686149a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/actions/UninstallAction.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.actions; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.UninstallUtils; -import org.netbeans.installer.utils.exceptions.UninstallationException; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.progress.CompositeProgress; -import org.netbeans.installer.utils.progress.Progress; -import org.netbeans.installer.wizard.components.WizardAction; - -public class UninstallAction extends WizardAction { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(UninstallAction.class, - "UA.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(UninstallAction.class, - "UA.description"); // NOI18N - public static final String DEFAULT_PROGRESS_UNINSTALL_TITLE_MESSAGE = - ResourceUtils.getString(UninstallAction.class, - "UA.progress.uninstall.title");//NOI18N - public static final String DEFAULT_UNINSTALL_DEPENDENT_FAILED_MESSAGE = - ResourceUtils.getString(UninstallAction.class, - "UA.uninstall.dependent.failed");//NOI18N - - public static final String PROGRESS_UNINSTALL_TITLE_PROPERTY = - "progress.uninstall.title"; - - public static final String UNINSTALL_DEPENDENT_FAILED_PROPERTY = - "uninstall.dependent.failed"; - public static final int UNINSTALLATION_ERROR_CODE = - 126;//NOMAGI - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private CompositeProgress overallProgress; - private Progress currentProgress; - - public UninstallAction() { - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - setProperty(PROGRESS_UNINSTALL_TITLE_PROPERTY, - DEFAULT_PROGRESS_UNINSTALL_TITLE_MESSAGE); - setProperty(UNINSTALL_DEPENDENT_FAILED_PROPERTY, - DEFAULT_UNINSTALL_DEPENDENT_FAILED_MESSAGE); - } - - @Override - public void execute() { - LogManager.logIndent("Start products uninstallation"); - final Registry registry = Registry.getInstance(); - final List products = registry.getProductsToUninstall(); - final int percentageChunk = Progress.COMPLETE / products.size(); - final int percentageLeak = Progress.COMPLETE % products.size(); - - overallProgress = new CompositeProgress(); - overallProgress.setPercentage(percentageLeak); - overallProgress.synchronizeDetails(true); - - getWizardUi().setProgress(overallProgress); - for (Product product : products) { - // initiate the progress for the current element - currentProgress = new Progress(); - - overallProgress.addChild(currentProgress, percentageChunk); - overallProgress.setTitle(StringUtils.format( - getProperty(PROGRESS_UNINSTALL_TITLE_PROPERTY), - product.getDisplayName())); - try { - product.uninstall(currentProgress); - - // sleep a little so that the user can perceive that something - // is happening - SystemUtils.sleep(200); - } catch (UninstallationException e) { - // do not override already set exit code - if (System.getProperties().get(Installer.EXIT_CODE_PROPERTY) == null) { - System.getProperties().put(Installer.EXIT_CODE_PROPERTY, - Integer.valueOf(UNINSTALLATION_ERROR_CODE)); - } - // adjust the component's status and save this error - it will - // be reused later at the PostInstallSummary - product.setStatus(Status.INSTALLED); - product.setUninstallationError(e); - - // since the product failed to uninstall - we should remove - // the components it depends on from our plans to uninstall - for(Product requirement : registry.getProducts()) { - if ((requirement.getStatus() == Status.TO_BE_UNINSTALLED) && - registry.satisfiesRequirement(requirement, product)) { - UninstallationException requirementError = - new UninstallationException( - StringUtils.format( - getProperty(PROGRESS_UNINSTALL_TITLE_PROPERTY), - requirement.getDisplayName(), - product.getDisplayName()), e); - - requirement.setStatus(Status.INSTALLED); - requirement.setUninstallationError(requirementError); - - products.remove(requirement); - } - } - - // finally notify the user of what has happened - ErrorManager.notify(ErrorLevel.ERROR, e); - } - } - LogManager.logUnindent("... finished products uninstallation"); - - LogManager.logUnindent("... starting updates and plugins uninstallation"); - try { - // delete updated files and downloaded plugins in installation folder - FileUtils.deleteFiles(new ArrayList(UninstallUtils.getFilesToDeteleAfterUninstallation())); - - // delete all empty folders in installation directory - FileUtils.deleteFiles(UninstallUtils.getEmptyFolders()); - } catch (IOException ex) { - LogManager.log(ex); - } - LogManager.logUnindent("... finished updates and plugins uninstallation"); - } - - @Override - public boolean canExecuteForward() { - return Registry.getInstance().getProductsToUninstall().size() > 0; - } - - @Override - public boolean isPointOfNoReturn() { - return true; - } - - @Override - public boolean isCancelable() { - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ApplicationLocationPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ApplicationLocationPanel.java deleted file mode 100644 index 0e3083725c4b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ApplicationLocationPanel.java +++ /dev/null @@ -1,619 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.LinkedList; -import java.util.List; -import javax.swing.ComboBoxEditor; -import javax.swing.ComboBoxModel; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.ListCellRenderer; -import javax.swing.ListModel; -import javax.swing.border.EmptyBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.ListDataEvent; -import javax.swing.event.ListDataListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiDirectoryChooser; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiList; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiScrollPane; -import org.netbeans.installer.utils.helper.swing.NbiTextField; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * - * @author Kirill Sorokin - */ -public abstract class ApplicationLocationPanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public ApplicationLocationPanel() { - setProperty(LOCATION_LABEL_TEXT_PROPERTY, - DEFAULT_LOCATION_LABEL_TEXT); - setProperty(LOCATION_BUTTON_TEXT_PROPERTY, - DEFAULT_LOCATION_BUTTON_TEXT); - setProperty(LIST_LABEL_TEXT_PROPERTY, - DEFAULT_LIST_LABEL_TEXT); - - setProperty(ERROR_NOTHING_FOUND_PROPERTY, - DEFAULT_ERROR_NOTHING_FOUND); - } - - public abstract List getLocations(); - - public abstract List getLabels(); - - public abstract File getSelectedLocation(); - - public abstract String validateLocation(String value); - - public abstract void setLocation(File location); - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new ApplicationLocationPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class ApplicationLocationPanelUi extends ErrorMessagePanelUi { - protected ApplicationLocationPanel component; - - public ApplicationLocationPanelUi(final ApplicationLocationPanel component) { - super(component); - - this.component = component; - } - - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new ApplicationLocationPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class ApplicationLocationPanelSwingUi extends ErrorMessagePanelSwingUi { - private ApplicationLocationPanel component; - - private NbiLabel locationLabel; - private NbiTextField locationField; - private NbiButton locationButton; - - private NbiLabel locationsLabel; - private NbiList locationsList; - private NbiScrollPane locationsScrollPane; - - private NbiPanel locationsListReplacement; - - private NbiDirectoryChooser fileChooser; - - public ApplicationLocationPanelSwingUi( - final ApplicationLocationPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - @Override - public JComponent getDefaultFocusOwner() { - return locationField; - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initialize() { - super.initialize(); - - locationLabel.setText(component.getProperty(LOCATION_LABEL_TEXT_PROPERTY)); - locationButton.setText(component.getProperty(LOCATION_BUTTON_TEXT_PROPERTY)); - locationsLabel.setText(component.getProperty(LIST_LABEL_TEXT_PROPERTY)); - - //TODO - //? This should be set somewhere at the early stage otherwise Issue 144955 occurs. - //Now it is workarounded my checking model == null in LocationsComboBoxEditor.getItem() - LocationsListModel model = new LocationsListModel( - component.getLocations(), - component.getLabels()); - locationsList.setModel(model); - - File selectedLocation = component.getSelectedLocation(); - if (model.getSize() > 0) { - if (selectedLocation != null) { - locationField.setText(selectedLocation.getAbsolutePath()); - } else { - locationField.setText(model.getLocationAt(0).getAbsolutePath()); - } - - locationsLabel.setVisible(true); - locationsScrollPane.setVisible(true); - locationsListReplacement.setVisible(false); - } else { - if (selectedLocation != null) { - locationField.setText(selectedLocation.getAbsolutePath()); - } else { - locationField.setText(SystemUtils.resolvePath(DEFAULT_LOCATION).getAbsolutePath()); - } - - locationsLabel.setVisible(false); - locationsScrollPane.setVisible(false); - locationsListReplacement.setVisible(true); - } - - updateErrorMessage(); - } - - @Override - protected void saveInput() { - component.setLocation(new File(locationField.getText().trim())); - } - - @Override - protected String validateInput() { - return component.validateLocation(locationField.getText().trim()); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // locationField //////////////////////////////////////////////////////// - locationField = new NbiTextField(); - locationField.getDocument().addDocumentListener(new DocumentListener() { - public void changedUpdate(final DocumentEvent event) { - locationChanged(); - } - - public void insertUpdate(final DocumentEvent event) { - locationChanged(); - } - - public void removeUpdate(final DocumentEvent event) { - locationChanged(); - } - }); - - // locationLabel //////////////////////////////////////////////////////// - locationLabel = new NbiLabel(); - locationLabel.setLabelFor(locationField); - - // locationButton /////////////////////////////////////////////////////// - locationButton = new NbiButton(); - locationButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - browseButtonPressed(); - } - }); - - // locationsList //////////////////////////////////////////////////////// - locationsList = new NbiList(); - locationsList.setBorder(new EmptyBorder(0, 0, 0, 0)); - locationsList.setCellRenderer(new LocationsListCellRenderer()); - locationsList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent event) { - if (!event.getValueIsAdjusting()) { - listSelectionChanged(); - } - } - }); - - // locationsScrollPane ////////////////////////////////////////////////// - locationsScrollPane = new NbiScrollPane(locationsList); - - // locationsLabel /////////////////////////////////////////////////////// - locationsLabel = new NbiLabel(); - locationsLabel.setLabelFor(locationsList); - - // locationsListReplacement ///////////////////////////////////////////// - locationsListReplacement = new NbiPanel(); - - // fileChooser ////////////////////////////////////////////////////////// - fileChooser = new NbiDirectoryChooser(); - // this ///////////////////////////////////////////////////////////////// - add(locationLabel, new GridBagConstraints( - 0, 1, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(7, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(locationField, new GridBagConstraints( - 0, 2, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 0, 4), // padding - 0, 0)); // padx, pady - ??? - add(locationButton, new GridBagConstraints( - 1, 2, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.NONE, // fill - new Insets(4, 0, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(locationsLabel, new GridBagConstraints( - 0, 3, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(locationsScrollPane, new GridBagConstraints( - 0, 4, // x, y - 2, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(4, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(locationsListReplacement, new GridBagConstraints( - 0, 5, // x, y - 2, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(4, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - } - - private void browseButtonPressed() { - fileChooser.setSelectedFile(new File(locationField.getText())); - - if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - locationField.setText(fileChooser.getSelectedFile().getAbsolutePath()); - } - } - - private void listSelectionChanged() { - final LocationsListModel model = (LocationsListModel) locationsList.getModel(); - - final int index = locationsList.getSelectedIndex(); - if (index != -1) { - String location = model.getLocationAt(index).getAbsolutePath(); - if (!location.equals(locationField.getText())) { - locationField.setText(location); - } - } - } - - private void locationChanged() { - updateErrorMessage(); - - final LocationsListModel model = (LocationsListModel) locationsList.getModel(); - final String value = locationField.getText().trim(); - - for (int i = 0; i < model.getSize(); i++) { - final String element = (String) model.getLocationAt(i).getAbsolutePath(); - - if (value.equals(element)) { - locationsList.setSelectedIndex(i); - return; - } - } - - locationsList.clearSelection(); - } - } - - public static class LocationsListCellRenderer extends JLabel implements ListCellRenderer { - public LocationsListCellRenderer() { - setBorder(new EmptyBorder(3, 3, 3, 3)); - } - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - setText(value.toString()); - setToolTipText(value.toString()); - - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - setOpaque(true); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - setOpaque(false); - } - - return this; - } - } - - public static class LocationsListModel implements ListModel { - private List locations; - private List labels; - - public LocationsListModel(final List locations, final List labels) { - this.locations = locations; - this.labels = labels; - } - - public int getSize() { - return locations.size(); - } - - public Object getElementAt(int index) { - return getLabelAt(index); - } - - public String getLabelAt(int index) { - return labels.get(index); - } - - public File getLocationAt(int index) { - return locations.get(index); - } - - public void addListDataListener(ListDataListener listener) { - // does nothing - } - - public void removeListDataListener(ListDataListener listener) { - // does nothing - } - } - - public static class LocationsComboBoxEditor implements ComboBoxEditor { - private NbiTextField textField; - - private LocationValidator validator; - private LocationsComboBoxModel model; - - public LocationsComboBoxEditor(LocationValidator validator) { - this.validator = validator; - - textField = new NbiTextField(); - textField.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - LocationsComboBoxEditor.this.validator.validate( - textField.getText()); - } - - public void removeUpdate(DocumentEvent e) { - LocationsComboBoxEditor.this.validator.validate( - textField.getText()); - } - - public void changedUpdate(DocumentEvent e) { - LocationsComboBoxEditor.this.validator.validate( - textField.getText()); - } - }); - - // l&f tweaks - if (!SystemUtils.isMacOS()) { - textField.setBorder(new EmptyBorder(1, 1, 1, 1)); - } - } - - public void setModel(LocationsComboBoxModel model) { - this.model = model; - } - - // comboboxeditor /////////////////////////////////////////////////////////// - public Component getEditorComponent() { - return textField; - } - - public void setItem(Object object) { - if (object != null) { - final int index = model.getLabels().indexOf(object); - - if (index != -1) { - textField.setText(model.getLocations().get(index)); - } else { - textField.setText(object.toString()); - } - } else { - textField.setText(""); - } - } - - public Object getItem() { - final String text = textField.getText(); - if(model == null) { - return text; - } - final int index = model.getLocations().indexOf(text); - - if (index != -1) { - return model.getLabels().get(index); - } else { - return text; - } - } - - public void selectAll() { - textField.selectAll(); - } - - public void addActionListener(ActionListener listener) { - textField.addActionListener(listener); - } - - public void removeActionListener(ActionListener listener) { - textField.removeActionListener(listener); - } - } - - public static class LocationsComboBoxModel implements ComboBoxModel { - private List listeners; - - private List locations; - private List labels; - - private String selectedItem; - private boolean selectedItemFromList; - - public LocationsComboBoxModel(List locations, List labels) { - this.locations = new LinkedList(); - for (File file: locations) { - this.locations.add(file.toString()); - } - - this.labels = new LinkedList(); - this.labels.addAll(labels); - - this.listeners = new LinkedList(); - - if (labels.size() > 0) { - this.selectedItem = labels.get(0); - this.selectedItemFromList = true; - } else { - this.selectedItem = StringUtils.EMPTY_STRING; - this.selectedItemFromList = false; - } - } - - public List getLabels() { - return labels; - } - - public List getLocations() { - return locations; - } - - public String getLocation() { - if (selectedItemFromList) { - return locations.get(labels.indexOf(selectedItem)); - } else { - return selectedItem; - } - } - - // comboboxmodel //////////////////////////////////////////////////////////// - public void setSelectedItem(Object item) { - selectedItem = (String) item; - - if (labels.indexOf(item) != -1) { - selectedItemFromList = true; - } else { - selectedItemFromList = false; - } - - fireContentsChanged(-1); - } - - public Object getSelectedItem() { - return selectedItem; - } - - public int getSize() { - return labels.size(); - } - - public Object getElementAt(int index) { - return labels.get(index); - } - - public void addListDataListener(ListDataListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - public void removeListDataListener(ListDataListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - // private ////////////////////////////////////////////////////////////////// - private void fireContentsChanged(int index) { - final ListDataListener[] clone; - synchronized (listeners) { - clone = listeners.toArray(new ListDataListener[listeners.size()]); - } - - final ListDataEvent event = new ListDataEvent( - this, - ListDataEvent.CONTENTS_CHANGED, - index, - index); - - for (ListDataListener listener: clone) { - listener.contentsChanged(event); - } - } - } - - public static interface LocationValidator { - void validate(String location); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String LOCATION_LABEL_TEXT_PROPERTY = - "location.label.text"; // NOI18N - public static final String LOCATION_BUTTON_TEXT_PROPERTY = - "location.button.text"; // NOI18N - public static final String LIST_LABEL_TEXT_PROPERTY = - "list.label.text"; // NOI18N - - public static final String DEFAULT_LOCATION_LABEL_TEXT = - ResourceUtils.getString(ApplicationLocationPanel.class, - "ALP.location.label.text"); // NOI18N - public static final String DEFAULT_LOCATION_BUTTON_TEXT = - ResourceUtils.getString(ApplicationLocationPanel.class, - "ALP.location.button.text"); // NOI18N - public static final String DEFAULT_LIST_LABEL_TEXT = - ResourceUtils.getString(ApplicationLocationPanel.class, - "ALP.list.label.text"); // NOI18N - - - public static final String ERROR_NOTHING_FOUND_PROPERTY = - "error.nothing.found"; // NOI18N - - public static final String DEFAULT_ERROR_NOTHING_FOUND = - ResourceUtils.getString(ApplicationLocationPanel.class, - "ALP.error.nothing.found"); // NOI18N - - public static final String DEFAULT_LOCATION = - ResourceUtils.getString(ApplicationLocationPanel.class, - "ALP.default.location"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/Bundle.properties deleted file mode 100644 index d4071b55620c..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/Bundle.properties +++ /dev/null @@ -1,287 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -################################################################################ -# ApplicationLocationPanel.java -ALP.location.label.text=&Location: -ALP.location.button.text=B&rowse ... -ALP.list.label.text=The &following locations were found by the search algorithm: - -ALP.error.nothing.found=No compatible applications were found. - -#NOI18N -ALP.default.location=$N{install} - -################################################################################ -# ComponentsSelectionPanel.java -CSP.title=Components Selection -CSP.description.both=Select the components that you want to install. Unselect those you want to uninstall. -CSP.description.install=Select the components that you want to install. -CSP.description.uninstall=Unselect the components that you want to uninstall. -CSP.feature.description.title=Feature Description - -#NOI18N -CSP.component.description.text={0} -#NOI18N -CSP.component.description.content.type=text/plain -CSP.sizes.label.text=Installation size: {0} Download Size: {1} -CSP.sizes.label.text.no.download=Installation size: {0} - -CSP.default.installation.size=N/A -CSP.default.download.size=N/A - -CSP.error.no.changes.both=No feature selected. Select at least one feature for installation or uninstallation. -CSP.error.no.changes.install=No feature selected. Select at least one feature for installation. -CSP.error.no.changes.uninstall=No feature selected. Select at least one feature for uninstallation. -CSP.error.requirement.install={1} is required to install {0}. -CSP.error.conflict.install={0} conflicts with {1}. -CSP.error.requirement.uninstall={0} is required by {1}. -CSP.error.not.enough.space.to.download=Insufficient disk space for downloading the installation data. Additional {1} is required in {0}. -CSP.error.not.enough.space.to.extract=Insufficient disk space for extracting the installation data. Additional {1} is required in {0}. -CSP.error.cannot.check.space=Cannot check the free disk space - -################################################################################ -# DestinationPanel.java -DP.title=Installation Folder -DP.description=Choose destination folder. - -DP.destination.label.text=&Installation location: -DP.destination.button.text=B&rowse ... - -DP.error.null=The installation folder cannot be empty. -DP.error.not.valid=The specified installation folder is invalid. -DP.error.contains.exclamation=The installation folder cannot contain the exclamation mark (!). -DP.error.contains.semicolon=The installation folder cannot contain the semicolon character (;). -DP.error.contains.colon=The installation folder cannot contain the colon character (:). -DP.error.contains.ampersand=The installation folder cannot contain the ampersand character (&). -DP.error.contains.wrong.char=The installation folder contains the wrong character({1}). -DP.error.matches.prohibited.regexp=The specified installation folder is invalid (it matches prohibited pattern {1}). -DP.error.not.absolute=The specified installation folder has to be in absolute path form. -DP.error.cannot.canonize=The specified installation folder cannot be canonized. -DP.error.not.directory=The specified installation location is not a folder. -DP.error.not.readable=The specified installation folder is not readable. -DP.error.not.writable=The specified installation folder is read-only. -DP.error.not.empty=The specified installation folder is not empty. -DP.error.not.ends.with.app=The specified installation folder must end with ".app". -DP.error.not.enough.space=Not enough disk space. Additional {1} required in {0}. -DP.error.cannot.get.logic=Cannot obtain configuration logic -DP.error.cannot.check.space=Cannot check the free disk space - -#NOI18N -DP.default.destination=$N{install} - -################################################################################ -# JdkLocationPanel.java -JLP.location.label.text=&JDK\u2122 home folder: -JLP.location.label.text.java=&Java\u2122 environment home folder: -JLP.location.button.text=B&rowse ... -JLP.list.label.text=&List of suitable JDK\u2122 found on this machine: -JLP.list.label.text.java=&List of suitable Java\u2122 environments found on this machine: - -JLP.error.null=The path to the JDK cannot be empty. -JLP.error.null.java=The path to the Java environment cannot be empty. -JLP.error.not.valid.path=The specified JDK folder is invalid. -JLP.error.not.valid.path.java=The specified Java environment folder is invalid. -JLP.error.path.not.exists=The specified JDK folder does not exist. -JLP.error.path.not.exists.java=The specified Java environment folder does not exist. -JLP.error.not.javahome=The specified JDK folder does not contain JDK. -JLP.error.not.javahome.java=The specified Java environment folder does not contain Java environment. -JLP.error.not.jdk=The specified JDK folder contains JRE, but a full JDK is required. -JLP.error.wrong.version.older=The specified JDK folder contains JDK version "{1}", while the minimum is "{2}". -JLP.error.wrong.version.older.java=The specified Java environment folder contains Java version "{1}", while the minimum is "{2}". -JLP.error.wrong.version.newer=The specified JDK folder contains JDK version "{1}", while the maximum is "{2}". -JLP.error.wrong.version.newer.java=The specified Java environment folder contains Java version "{1}", while the maximum is "{2}". -JLP.error.wrong.vendor=The specified JDK folder contains JDK from the unsupported vendor ({1}). The supported vendors are "{2}". -JLP.error.wrong.vendor.java=The specified Java environment folder contains Java from the unsupported vendor ({1}). The supported vendors are "{2}". -JLP.error.unknown=An unknown error occured while validating the path. -#NOI18N -JLP.java.download.page=http://www.oracle.com/technetwork/java/javase/downloads/ -#NOI18N -JLP.java.download.page.mac=http://developer.apple.com/java/download -JLP.error.nothing.found=\ -\ -The installer could not find a compatible JDK installation, specify it manually.
\ -The minimum required version is {0}. To download JDK, visit {2} -JLP.error.nothing.found.java=\ -\ -The installer could not find a compatible Java environment, specify it manually.
\ -The minimum required version is {0}. To download Java environment, visit {2} - -JLP.usedby.label={0} (used by {1}) - -#NOI18N -JLP.minimum.jdk.version=1.0.0 -#NOI18N -JLP.maximum.jdk.version=500.0.0 -#NOI18N -JLP.vendor.jdk.allowed=.* - -################################################################################ -# PostCreateBundleSummaryPanel.java -PoCBSP.dialog.title=Post-Create Bundle Summary -PoCBSP.dialog.description=Click Finish to exit. - -PoCBSP.message.success.text=The installation wizard has successfully performed the selected actions. -#NOI18N -PoCBSP.message.success.content.type=text/plain -PoCBSP.message.errors.text=Some errors were encountered in the course of bundle creation process. -#NOI18N -PoCBSP.message.errors.content.type=text/plain -PoCBSP.successfully.bundled.components.label.text=The following components were successfully bundled: -#NOI18N -PoCBSP.successfully.bundled.components.text={0} -#NOI18N -PoCBSP.successfully.bundled.components.content.type=text/plain -PoCBSP.components.failed.to.bundle.label.text=The following components failed to be bundled: -#NOI18N -PoCBSP.components.failed.to.bundle.text={0} -#NOI18N -PoCBSP.components.failed.to.bundle.content.type=text/plain -PoCBSP.view.log.button.text=View &Log -PoCBSP.send.log.button.text=&Send Log -PoCBSP.components.list.separator=, - -################################################################################ -# PostInstallSummaryPanel.java -PoISP.dialog.title=Installation Wizard - Post-Install Summary - -PoISP.message.success.text=The installation wizard has successfully performed the selected actions. -#NOI18N -PoISP.message.success.content.type=text/plain -PoISP.message.warnings.text=Some warnings were encountered in the course of installation/uninstallation process. -#NOI18N -PoISP.message.warnings.content.type=text/plain -PoISP.message.errors.text=Some errors were encountered in the course of installation/uninstallation process. -#NOI18N -PoISP.message.errors.content.type=text/plain - -PoISP.successfully.installed.label.text=The following components were successfully installed: -#NOI18N -PoISP.successfully.installed.text={0} -#NOI18N -PoISP.successfully.installed.content.type=text/plain - -PoISP.installed.with.warnings.label.text=The following components installed with warnings: -#NOI18N -PoISP.installed.with.warnings.text={0} -#NOI18N -PoISP.installed.with.warnings.content.type=text/plain - -PoISP.failed.to.install.label.text=The following components failed to install: -#NOI18N -PoISP.failed.to.install.text={0} -#NOI18N -PoISP.failed.to.install.content.type=text/plain - -PoISP.successfully.uninstalled.label.text=The following components were successfully uninstalled: -#NOI18N -PoISP.successfully.uninstalled.text={0} -#NOI18N -PoISP.successfully.uninstalled.content.type=text/plain - -PoISP.uninstalled.with.warnings.label.text=The following components uninstalled with warnings: -#NOI18N -PoISP.uninstalled.with.warnings.text={0} -#NOI18N -PoISP.uninstalled.with.warnings.content.type=text/plain - -PoISP.failed.to.uninstall.label.text=The following components failed to uninstall: -#NOI18N -PoISP.failed.to.uninstall.text={0} -#NOI18N -PoISP.failed.to.uninstall.content.type=text/plain - -PoISP.view.details.button.text=View &Details -PoISP.view.log.button.text=View &Log -PoISP.send.log.button.text=&Send Log - -PoISP.components.list.separator=, -PoISP.error.logfile.unavailable=Log file is not available - -PoISP.message.files.remaining=Some files could not be removed from the installation directories of the {0}. You may need to remove them manually. - -################################################################################ -# PreCreateBundleSummaryPanel.java -PrCBSPdialog.title=Pre-Create Bundle Summary -PrCBSPdialog.description=Click Create to create the bundle. - -PrCBSPmessage.text=The wizard has collected all required data to proceed with creating of the bundle. Please review your choice. To continue, click Next. -#NOI18N -PrCBSPmessage.content.type=text/plain -PrCBSPcomponents.to.bundle.label.text=You chose to create a bundle with the following components: -PrCBSPcomponents.to.bundle.text={0}. -#NOI18N -PrCBSPcomponents.to.bundle.content.type=text/plain -PrCBSPcomponents.list.separator=, -PrCBSPdownload.size.label.text=Total download size: {0} -PrCBSPrequired.disk.space.label.text=Required disk space: {0} -PrCBSPcreate.button.text=&Create - -################################################################################ -# PreInstallSummaryPanel.java -PrISP.title=Pre-Install Summary - -PrISP.message.text=The installation wizard has collected all required data to proceed with installation/uninstallation of the selected components. Please review your choice. To continue, click Next. -#NOI18N -PrISP.message.content.type=text/plain -PrISP.components.to.install.label.text=You chose to install the following components: -PrISP.components.to.install.text={0}. -PrISP.components.to.install.content.type=text/plain -PrISP.components.to.uninstall.label.text=You chose to uninstall the following components: -PrISP.components.to.uninstall.text={0}. -#NOI18N -PrISP.components.to.uninstall.content.type=text/plain -PrISP.components.list.separator=, - -PrISP.download.size.label.text=Total download size: {0} -PrISP.required.disk.space.label.text=Required disk space: {0} -PrISP.install.button.text=&Install - -PrISP.error.not.enough.space=Insufficient disk space for proper installation. Additional {1} is required in {0}. -PrISP.error.cannot.check.space=Cannot check the free disk space -PrISP.error.logic.access=Could not access product's configuration logic -PrISP.error.fsroots=Cannot get the list of file system roots -PrISP.error.non.existent.root={0} is set up to be installed to {1} which does not belong to any of the file system roots. -PrISP.error.cannot.write=The wizard does not have write access to {1}, the installation directory of {0}. Please correct the permissions before proceeding. - -################################################################################ -# LicensesPanel.java -LP.title=License Agreement -LP.description=Please read the following license agreement carefully. - -LP.accept.checkbox.text=I &accept the terms in the license agreement -LP.error.cannot.get.logic=Could not access configuration logic - -LP.append.license.format=-------------------------------------------------\n{0}:\n\n{1}\n\n -#NOI18N -LP.overall.license.format={0} -#NOI18N -LP.single.product.license.format={1} -################################################################################ -# TextPanel.java -TP.text= -#NOI18N -TP.content.type=text/plain - - -################################################################################ -# ErrorMessagePanel.java -EMP.cancel.dialog.message=Are you sure you want to cancel? -EMP.cancel.dialog.title=Cancel -EMP.error.failed.input.verify=Failed to verify input diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ComponentsSelectionPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ComponentsSelectionPanel.java deleted file mode 100644 index 6a322f6cb94a..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ComponentsSelectionPanel.java +++ /dev/null @@ -1,1068 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.Color; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.EventObject; -import java.util.LinkedList; -import java.util.List; -import javax.swing.AbstractAction; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.JTree; -import javax.swing.KeyStroke; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import javax.swing.border.TitledBorder; -import javax.swing.event.CellEditorListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.TreeCellEditor; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.RegistryType; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.dependencies.Conflict; -import org.netbeans.installer.product.dependencies.Requirement; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.helper.swing.NbiCheckBox; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiScrollPane; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.utils.helper.swing.NbiTree; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * - * @author Kirill Sorokin - */ -public class ComponentsSelectionPanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public ComponentsSelectionPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - setProperty(DESCRIPTION_INSTALL_PROPERTY, - DEFAULT_DESCRIPTION_INSTALL); - setProperty(DESCRIPTION_UNINSTALL_PROPERTY, - DEFAULT_DESCRIPTION_UNINSTALL); - setProperty(FEATURE_DESCRIPTION_TITLE_PROPERTY, - DEFAULT_FEATURE_DESCRIPTION_TITLE); - - setProperty(COMPONENT_DESCRIPTION_TEXT_PROPERTY, - DEFAULT_COMPONENT_DESCRIPTION_TEXT); - setProperty(COMPONENT_DESCRIPTION_CONTENT_TYPE_PROPERTY, - DEFAULT_COMPONENT_DESCRIPTION_CONTENT_TYPE); - setProperty(SIZES_LABEL_TEXT_PROPERTY, - DEFAULT_SIZES_LABEL_TEXT); - setProperty(SIZES_LABEL_TEXT_NO_DOWNLOAD_PROPERTY, - DEFAULT_SIZES_LABEL_TEXT_NO_DOWNLOAD); - - setProperty(DEFAULT_INSTALLATION_SIZE_PROPERTY, - DEFAULT_INSTALLATION_SIZE); - setProperty(DEFAULT_DOWNLOAD_SIZE_PROPERTY, - DEFAULT_DOWNLOAD_SIZE); - - setProperty(ERROR_NO_CHANGES_PROPERTY, - DEFAULT_ERROR_NO_CHANGES); - setProperty(ERROR_NO_CHANGES_INSTALL_ONLY_PROPERTY, - DEFAULT_ERROR_NO_CHANGES_INSTALL_ONLY); - setProperty(ERROR_NO_CHANGES_UNINSTALL_ONLY_PROPERTY, - DEFAULT_ERROR_NO_CHANGES_UNINSTALL_ONLY); - setProperty(ERROR_REQUIREMENT_INSTALL_PROPERTY, - DEFAULT_ERROR_REQUIREMENT_INSTALL); - setProperty(ERROR_CONFLICT_INSTALL_PROPERTY, - DEFAULT_ERROR_CONFLICT_INSTALL); - setProperty(ERROR_REQUIREMENT_UNINSTALL_PROPERTY, - DEFAULT_ERROR_REQUIREMENT_UNINSTALL); - setProperty(ERROR_NO_ENOUGH_SPACE_TO_DOWNLOAD_PROPERTY, - DEFAULT_ERROR_NO_ENOUGH_SPACE_TO_DOWNLOAD); - setProperty(ERROR_NO_ENOUGH_SPACE_TO_EXTRACT_PROPERTY, - DEFAULT_ERROR_NO_ENOUGH_SPACE_TO_EXTRACT); - setProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY, - DEFAULT_ERROR_CANNOT_CHECK_SPACE); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new ComponentsSelectionPanelUi(this); - } - - return wizardUi; - } - - @Override - public boolean canExecuteForward() { - return canExecute(); - } - - @Override - public boolean canExecuteBackward() { - return canExecute(); - } - - @Override - public void initialize() { - if (!isThereAnythingVisibleToInstall()) { - setProperty( - DESCRIPTION_PROPERTY, - getProperty(DESCRIPTION_UNINSTALL_PROPERTY)); - } - if (!isThereAnythingVisibleToUninstall()) { - setProperty( - DESCRIPTION_PROPERTY, - getProperty(DESCRIPTION_INSTALL_PROPERTY)); - } - } - - // private ////////////////////////////////////////////////////////////////////// - private boolean canExecute() { - return !(Boolean.getBoolean(Registry.FORCE_INSTALL_PROPERTY) || - Boolean.getBoolean(Registry.FORCE_UNINSTALL_PROPERTY)); - } - - private boolean isThereAnythingVisibleToInstall() { - final Registry registry = Registry.getInstance(); - - final List toInstall = new LinkedList(); - toInstall.addAll(registry.getProducts(Status.NOT_INSTALLED)); - toInstall.addAll(registry.getProducts(Status.TO_BE_INSTALLED)); - - for (Product product: toInstall) { - if (product.isVisible()) { - return true; - } - } - - return false; - } - - private boolean isThereAnythingVisibleToUninstall() { - final Registry registry = Registry.getInstance(); - - final List toUninstall = new LinkedList(); - toUninstall.addAll(registry.getProducts(Status.INSTALLED)); - toUninstall.addAll(registry.getProducts(Status.TO_BE_UNINSTALLED)); - - for (Product product: toUninstall) { - if (product.isVisible()) { - return true; - } - } - - return false; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class ComponentsSelectionPanelUi extends ErrorMessagePanelUi { - private ComponentsSelectionPanel panel; - - public ComponentsSelectionPanelUi(final ComponentsSelectionPanel panel) { - super(panel); - - this.panel = panel; - } - - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new ComponentsSelectionPanelSwingUi(panel, container); - } - - return super.getSwingUi(container); - } - } - - public static class ComponentsSelectionPanelSwingUi extends ErrorMessagePanelSwingUi { - ///////////////////////////////////////////////////////////////////////////// - // Instance - private ComponentsSelectionPanel panel; - - private NbiTree componentsTree; - private NbiScrollPane componentsScrollPane; - - private NbiTextPane descriptionPane; - private NbiScrollPane descriptionScrollPane; - - private NbiLabel sizesLabel; - - public ComponentsSelectionPanelSwingUi( - final ComponentsSelectionPanel component, - final SwingContainer container) { - super(component, container); - - this.panel = component; - - initComponents(); - } - - @Override - protected void initialize() { - descriptionPane.setContentType( - panel.getProperty(COMPONENT_DESCRIPTION_CONTENT_TYPE_PROPERTY)); - - if (!panel.isThereAnythingVisibleToInstall()) { - sizesLabel.setVisible(false); - } - - updateDescription(); - updateSizes(); - - super.initialize(); - } - - @Override - protected String validateInput() { - final Registry registry = Registry.getInstance(); - - final List toInstall = - registry.getProducts(Status.TO_BE_INSTALLED); - final List toUninstall = - registry.getProducts(Status.TO_BE_UNINSTALLED); - - if ((toInstall.size() == 0) && (toUninstall.size() == 0)) { - if (!panel.isThereAnythingVisibleToInstall()) { - return panel.getProperty( - ERROR_NO_CHANGES_UNINSTALL_ONLY_PROPERTY); - } - - if (!panel.isThereAnythingVisibleToUninstall()) { - return panel.getProperty( - ERROR_NO_CHANGES_INSTALL_ONLY_PROPERTY); - } - - return panel.getProperty(ERROR_NO_CHANGES_PROPERTY); - } - - for (Product product: toInstall) { - for (Dependency requirement: product.getDependencies( - Requirement.class)) { - final List requirees = - registry.getProducts(requirement); - - boolean satisfied = false; - - for (Product requiree: requirees) { - if ((requiree.getStatus() == Status.TO_BE_INSTALLED) || - (requiree.getStatus() == Status.INSTALLED)) { - satisfied = true; - break; - } - } - - if (!satisfied) { - return StringUtils.format( - panel.getProperty(ERROR_REQUIREMENT_INSTALL_PROPERTY), - product.getDisplayName(), - requirees.get(0).getDisplayName()); - } - } - - for (Dependency conflict: product.getDependencies( - Conflict.class)) { - final List conflictees = registry.getProducts(conflict); - - boolean satisfied = true; - Product unsatisfiedConflict = null; - - for (Product conflictee: conflictees) { - if ((conflictee.getStatus() == Status.TO_BE_INSTALLED) || - (conflictee.getStatus() == Status.INSTALLED)) { - satisfied = false; - unsatisfiedConflict = conflictee; - break; - } - } - - if (!satisfied) { - return StringUtils.format( - panel.getProperty(ERROR_CONFLICT_INSTALL_PROPERTY), - product.getDisplayName(), - unsatisfiedConflict.getDisplayName()); - } - } - } - - for (Product product: toUninstall) { - for (Product dependent: registry.getProducts()) { - if ((dependent.getStatus() == Status.TO_BE_UNINSTALLED) || - (dependent.getStatus() == Status.NOT_INSTALLED)) { - continue; - } - - for (Dependency requirement: dependent.getDependencies(Requirement.class)) { - final List requirees = registry.getProducts(requirement); - - if (requirees.contains(product)) { - boolean satisfied = false; - for (Product requiree: requirees) { - if (requiree.getStatus() == Status.INSTALLED) { - satisfied = true; - break; - } - } - - if (!satisfied) { - return StringUtils.format( - panel.getProperty(ERROR_REQUIREMENT_UNINSTALL_PROPERTY), - product.getDisplayName(), - dependent.getDisplayName()); - } - } - } - } - } - - // devise the error message template which should be used - "not enough - // space to download..." is at least one of the components comes from - // a remote registry, "not enough space to extract..." - otherwise - String template = panel.getProperty( - ERROR_NO_ENOUGH_SPACE_TO_EXTRACT_PROPERTY); - for (Product product: toInstall) { - if (product.getRegistryType() == RegistryType.REMOTE) { - template = panel.getProperty( - ERROR_NO_ENOUGH_SPACE_TO_DOWNLOAD_PROPERTY); - break; - } - } - - // check whether the space available in the local directory (which will - // be used for downloading data) is enough to keep all the installation - // data and configuration logic (plus some margin for safety) - try { - if (!Boolean.getBoolean(SystemUtils.NO_SPACE_CHECK_PROPERTY)) { - - final File localDirectory = Installer.getInstance().getLocalDirectory(); - final long availableSize = SystemUtils.getFreeSpace(localDirectory); - - long requiredSize = 0; - for (Product product : toInstall) { - requiredSize += product.getDownloadSize(); - } - requiredSize += REQUIRED_SPACE_ADDITION; - - if (availableSize < requiredSize) { - return StringUtils.format( - template, - localDirectory, - StringUtils.formatSize(requiredSize - availableSize)); - } - } - } catch (NativeException e) { - ErrorManager.notifyError( - panel.getProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY), - e); - } - - return null; - } - - @Override - public JComponent getDefaultFocusOwner() { - return componentsTree; - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // componentsTree /////////////////////////////////////////////////////// - componentsTree = new NbiTree(); - componentsTree.setModel( - new ComponentsTreeModel()); - componentsTree.setCellRenderer( - new ComponentsTreeCell()); - componentsTree.setEditable( - true); - componentsTree.setCellEditor( - new ComponentsTreeCell()); - componentsTree.setShowsRootHandles( - true); - componentsTree.setRootVisible( - false); - componentsTree.setBorder( - new EmptyBorder(5, 5, 5, 5)); - componentsTree.setRowHeight( - new JCheckBox().getPreferredSize().height); - componentsTree.getSelectionModel().setSelectionMode( - TreeSelectionModel.SINGLE_TREE_SELECTION); - componentsTree.getSelectionModel().addTreeSelectionListener( - new TreeSelectionListener() { - public void valueChanged(TreeSelectionEvent event) { - updateDescription(); - } - }); - componentsTree.getModel().addTreeModelListener( - new TreeModelListener() { - public void treeNodesChanged(TreeModelEvent event) { - updateSizes(); - updateErrorMessage(); - } - public void treeNodesInserted(TreeModelEvent event) { - // does nothing - } - public void treeNodesRemoved(TreeModelEvent event) { - // does nothing - } - public void treeStructureChanged(TreeModelEvent event) { - // does nothing - } - }); - componentsTree.getActionMap().put( - "checkbox.update", - new AbstractAction("checkbox.update") { - public void actionPerformed(ActionEvent event) { - final TreePath path = componentsTree.getSelectionPath(); - - if (path != null) { - componentsTree.getModel().valueForPathChanged(path, null); - } - } - }); - componentsTree.getInputMap().put( - KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false), - "checkbox.update"); - - // componentsScrollPane ///////////////////////////////////////////////// - componentsScrollPane = new NbiScrollPane(componentsTree); - - // descriptionPane ////////////////////////////////////////////////////// - descriptionPane = new NbiTextPane(); - descriptionPane.setBorder( - new EmptyBorder(5, 5, 5, 5)); - - // descriptionScrollPane //////////////////////////////////////////////// - descriptionScrollPane = new NbiScrollPane(descriptionPane); - descriptionScrollPane.setVerticalScrollBarPolicy( - NbiScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - descriptionScrollPane.setBorder( - new TitledBorder(panel.getProperty(FEATURE_DESCRIPTION_TITLE_PROPERTY))); - - // sizesLabel /////////////////////////////////////////////////////////// - sizesLabel = new NbiLabel(); - //sizesLabel.setFocusable(true); - - // this ///////////////////////////////////////////////////////////////// - add(componentsScrollPane, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 0.7, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 0), // padding - 0, 0)); // padx, pady - ??? - add(descriptionScrollPane, new GridBagConstraints( - 1, 0, // x, y - 1, 1, // width, height - 0.3, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 6, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(sizesLabel, new GridBagConstraints( - 0, 1, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(6, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - - // run through all nodes and expand those that have the expand flag set - // to true - for (RegistryNode node: Registry.getInstance().getNodes()) { - if (node.getExpand()) { - componentsTree.expandPath(node.getTreePath()); - } - } - - // l&f-specific tweaks - if (UIManager.getLookAndFeel().getID().equals("GTK")) { - descriptionPane.setOpaque(true); - } - } - - private void updateDescription() { - final TreePath path = componentsTree.getSelectionPath(); - - if (path != null) { - final RegistryNode node = (RegistryNode) path.getLastPathComponent(); - descriptionPane.setText(node.getDescription()); - } else { - descriptionPane.clearText(); - } - - descriptionPane.setCaretPosition(0); - } - - private void updateSizes() { - final Registry registry = Registry.getInstance(); - - long installationSize = 0; - long downloadSize = 0; - for (Product product: registry.getProductsToInstall()) { - installationSize += product.getRequiredDiskSpace(); - downloadSize += product.getDownloadSize(); - } - - String template = panel.getProperty(SIZES_LABEL_TEXT_NO_DOWNLOAD_PROPERTY); - for (RegistryNode remoteNode: registry.getNodes(RegistryType.REMOTE)) { - if (remoteNode.isVisible()) { - template = panel.getProperty( - SIZES_LABEL_TEXT_PROPERTY); - } - } - - if (installationSize == 0) { - sizesLabel.setText(StringUtils.format( - template, - panel.getProperty(DEFAULT_INSTALLATION_SIZE_PROPERTY), - panel.getProperty(DEFAULT_DOWNLOAD_SIZE_PROPERTY))); - } else { - sizesLabel.setText(StringUtils.format( - template, - StringUtils.formatSize(installationSize), - StringUtils.formatSize(downloadSize))); - } - } - } - - public static class ComponentsTreeModel implements TreeModel { - private List listeners = - new LinkedList(); - - public Object getRoot() { - return Registry.getInstance().getRegistryRoot(); - } - - public Object getChild(final Object node, final int index) { - return ((RegistryNode) node).getVisibleChildren().get(index); - } - - public int getChildCount(final Object node) { - return ((RegistryNode) node).getVisibleChildren().size(); - } - - public boolean isLeaf(final Object node) { - return ((RegistryNode) node).getVisibleChildren().size() == 0; - } - - public void valueForPathChanged(final TreePath path, final Object value) { - if (path.getLastPathComponent() instanceof Product) { - final Product product = (Product) path.getLastPathComponent(); - - switch (product.getStatus()) { - case NOT_INSTALLED: - product.setStatus(Status.TO_BE_INSTALLED); - updateRequirements(product); - break; - case TO_BE_INSTALLED: - product.setStatus(Status.NOT_INSTALLED); - break; - case INSTALLED: - product.setStatus(Status.TO_BE_UNINSTALLED); - break; - case TO_BE_UNINSTALLED: - product.setStatus(Status.INSTALLED); - break; - } - } - - final TreeModelListener[] clone; - synchronized (listeners) { - clone = listeners.toArray(new TreeModelListener[0]); - } - - final TreeModelEvent event = new TreeModelEvent(this, path); - for (TreeModelListener listener: clone) { - listener.treeNodesChanged(event); - } - } - - public int getIndexOfChild(final Object node, final Object child) { - return ((RegistryNode) node).getVisibleChildren().indexOf(child); - } - - public void addTreeModelListener(final TreeModelListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - public void removeTreeModelListener(final TreeModelListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - // private ////////////////////////////////////////////////////////////////// - private void updateRequirements(final Product product) { - // check whether the requirements are satisfied and if there - // is an unsatisfied requirement - pick an appropriate - // product and select it - for (Dependency requirement: product.getDependencies( - Requirement.class)) { - final List requirees = - Registry.getInstance().getProducts(requirement); - - boolean requireesNeedUpdate = true; - Product correctRequiree = null; - for (Product requiree: requirees) { - final Version version = requiree.getVersion(); - - if ((requiree.getStatus() == Status.INSTALLED) || - (requiree.getStatus() == Status.TO_BE_INSTALLED)) { - requireesNeedUpdate = false; - break; - } - if ((correctRequiree == null) || - correctRequiree.getVersion().olderThan(version)) { - correctRequiree = requiree; - } - } - - if (requireesNeedUpdate && !requirees.isEmpty()) { - valueForPathChanged(correctRequiree.getTreePath(), null); - } - } - } - } - - public static class ComponentsTreeCell implements TreeCellRenderer, TreeCellEditor { - private List listeners = - new LinkedList(); - - private NbiPanel panel; - private NbiCheckBox checkBox; - private NbiLabel iconLabel; - private NbiLabel titleLabel; - private NbiLabel statusLabel; - - private Color foreground; - private Color background; - - private Color selectionForeground; - private Color selectionBackground; - - public ComponentsTreeCell() { - foreground = UIManager.getColor("Tree.textForeground"); - background = UIManager.getColor("Tree.textBackground"); - - selectionForeground = UIManager.getColor("Tree.selectionForeground"); - selectionBackground = UIManager.getColor("Tree.selectionBackground"); - - initComponents(); - } - - public Component getTreeCellRendererComponent( - final JTree tree, - final Object value, - final boolean selected, - final boolean expanded, - final boolean leaf, - final int row, - final boolean focus) { - return getComponent(tree, value, selected, expanded, leaf, row, focus); - } - - public Component getTreeCellEditorComponent( - final JTree tree, - final Object value, - final boolean selected, - final boolean expanded, - final boolean leaf, - final int row) { - return getComponent(tree, value, selected, expanded, leaf, row, true); - } - - public Object getCellEditorValue() { - return null; - } - - public boolean isCellEditable(final EventObject event) { - return true; - } - - public boolean shouldSelectCell(final EventObject event) { - return true; - } - - public boolean stopCellEditing() { - fireEditingStopped(); - return true; - } - - public void cancelCellEditing() { - fireEditingCanceled(); - } - - public void addCellEditorListener(final CellEditorListener listener) { - synchronized (listeners) { - listeners.add(listener); - } - } - - public void removeCellEditorListener(final CellEditorListener listener) { - synchronized (listeners) { - listeners.remove(listener); - } - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // panel //////////////////////////////////////////////////////////////// - panel = new NbiPanel(); - panel.setLayout(new GridBagLayout()); - panel.setOpaque(false); - - // checkBox ///////////////////////////////////////////////////////////// - checkBox = new NbiCheckBox(); - checkBox.setOpaque(false); - checkBox.setFocusable(false); - checkBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - stopCellEditing(); - } - }); - - // iconLabel //////////////////////////////////////////////////////////// - iconLabel = new NbiLabel(); - iconLabel.setFocusable(false); - iconLabel.addMouseListener(new MouseAdapter() { - public void mouseClicked(final MouseEvent event) { - cancelCellEditing(); - } - - public void mousePressed(final MouseEvent event) { - cancelCellEditing(); - } - - public void mouseReleased(final MouseEvent event) { - cancelCellEditing(); - } - }); - - // titleLabel /////////////////////////////////////////////////////////// - titleLabel = new NbiLabel(); - titleLabel.setFocusable(false); - titleLabel.addMouseListener(new MouseAdapter() { - public void mouseClicked(final MouseEvent event) { - cancelCellEditing(); - } - - public void mousePressed(final MouseEvent event) { - cancelCellEditing(); - } - - public void mouseReleased(final MouseEvent event) { - cancelCellEditing(); - } - }); - - // statusLabel ////////////////////////////////////////////////////////// - statusLabel = new NbiLabel(); - statusLabel.setForeground(Color.GRAY); - statusLabel.setFocusable(false); - statusLabel.addMouseListener(new MouseAdapter() { - public void mouseClicked(final MouseEvent event) { - cancelCellEditing(); - } - - public void mousePressed(final MouseEvent event) { - cancelCellEditing(); - } - - public void mouseReleased(final MouseEvent event) { - cancelCellEditing(); - } - }); - - // this ///////////////////////////////////////////////////////////////// - panel.add(checkBox, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ???); - panel.add(iconLabel, new GridBagConstraints( - 1, 0, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ???); - panel.add(titleLabel, new GridBagConstraints( - 2, 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ???); - panel.add(statusLabel, new GridBagConstraints( - 3, 0, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ???); - } - - private void fireEditingStopped() { - final CellEditorListener[] clone; - synchronized (listeners) { - clone = listeners.toArray(new CellEditorListener[0]); - } - - final ChangeEvent event = new ChangeEvent(this); - for (CellEditorListener listener: clone) { - listener.editingStopped(event); - } - } - - private void fireEditingCanceled() { - final CellEditorListener[] clone; - synchronized (listeners) { - clone = listeners.toArray(new CellEditorListener[0]); - } - - final ChangeEvent event = new ChangeEvent(this); - for (CellEditorListener listener: clone) { - listener.editingCanceled(event); - } - } - - private JComponent getComponent( - final JTree tree, - final Object value, - final boolean selected, - final boolean expanded, - final boolean leaf, - final int row, - final boolean focus) { - if (selected) { - titleLabel.setOpaque(true); - - titleLabel.setForeground(selectionForeground); - titleLabel.setBackground(selectionBackground); - } else { - titleLabel.setOpaque(false); - - titleLabel.setForeground(foreground); - titleLabel.setBackground(background); - } - - if (value instanceof Product) { - final Product product = (Product) value; - - final String title = - " " + product.getDisplayName() + " "; - final String status = - " [" + product.getStatus().getDisplayName() + "]"; - final String tooltip = title + status; - - iconLabel.setIcon(product.getIcon()); - iconLabel.setToolTipText(tooltip); - - titleLabel.setText(title); - titleLabel.setToolTipText(tooltip); - - statusLabel.setText(status); - statusLabel.setToolTipText(tooltip); - - checkBox.setVisible(true); - checkBox.setToolTipText(tooltip); - - if ((product.getStatus() == Status.INSTALLED) || - (product.getStatus() == Status.TO_BE_INSTALLED)) { - checkBox.setSelected(true); - } else { - checkBox.setSelected(false); - } - } else if (value instanceof Group) { - final Group group = (Group) value; - - final String title = - " " + group.getDisplayName() + " "; - final String status = - ""; - final String tooltip = title + status; - - iconLabel.setIcon(group.getIcon()); - iconLabel.setToolTipText(tooltip); - - titleLabel.setText(title); - titleLabel.setToolTipText(tooltip); - - statusLabel.setText(status); - statusLabel.setToolTipText(tooltip); - - checkBox.setVisible(false); - } - - // l&f-specific tweaks - if (UIManager.getLookAndFeel().getID().equals("GTK")) { - panel.setOpaque(false); - } - - return panel; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DESCRIPTION_INSTALL_PROPERTY = - "description.install"; // NOI18N - public static final String DESCRIPTION_UNINSTALL_PROPERTY = - "description.uninstall"; // NOI18N - public static final String FEATURE_DESCRIPTION_TITLE_PROPERTY = - "feature.description.title"; - - public static final String DEFAULT_TITLE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.description.both"); // NOI18N - public static final String DEFAULT_DESCRIPTION_INSTALL = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.description.install"); // NOI18N - public static final String DEFAULT_DESCRIPTION_UNINSTALL = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.description.uninstall"); // NOI18N - public static final String DEFAULT_FEATURE_DESCRIPTION_TITLE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.feature.description.title");// NOI18N - public static final String COMPONENT_DESCRIPTION_TEXT_PROPERTY = - "component.description.text"; // NOI18N - public static final String COMPONENT_DESCRIPTION_CONTENT_TYPE_PROPERTY = - "component.description.content.type"; // NOI18N - public static final String SIZES_LABEL_TEXT_PROPERTY = - "sizes.label.text"; // NOI18N - public static final String SIZES_LABEL_TEXT_NO_DOWNLOAD_PROPERTY = - "sizes.label.text.no.download"; // NOI18N - public static final String DEFAULT_INSTALLATION_SIZE_PROPERTY = - "default.installation.size"; // NOI18N - public static final String DEFAULT_DOWNLOAD_SIZE_PROPERTY = - "default.download.size"; // NOI18N - - public static final String DEFAULT_COMPONENT_DESCRIPTION_TEXT = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.component.description.text"); // NOI18N - public static final String DEFAULT_COMPONENT_DESCRIPTION_CONTENT_TYPE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.component.description.content.type"); // NOI18N - public static final String DEFAULT_SIZES_LABEL_TEXT = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.sizes.label.text"); // NOI18N - public static final String DEFAULT_SIZES_LABEL_TEXT_NO_DOWNLOAD = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.sizes.label.text.no.download"); // NOI18N - public static final String DEFAULT_INSTALLATION_SIZE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.default.installation.size"); // NOI18N - public static final String DEFAULT_DOWNLOAD_SIZE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.default.download.size"); // NOI18N - - public static final String ERROR_NO_CHANGES_PROPERTY = - "error.no.changes.both"; // NOI18N - public static final String ERROR_NO_CHANGES_INSTALL_ONLY_PROPERTY = - "error.no.changes.install"; // NOI18N - public static final String ERROR_NO_CHANGES_UNINSTALL_ONLY_PROPERTY = - "error.no.changes.uninstall"; // NOI18N - public static final String ERROR_REQUIREMENT_INSTALL_PROPERTY = - "error.requirement.install"; // NOI18N - public static final String ERROR_CONFLICT_INSTALL_PROPERTY = - "error.conflict.install"; // NOI18N - public static final String ERROR_REQUIREMENT_UNINSTALL_PROPERTY = - "error.requirement.uninstall"; // NOI18N - public static final String ERROR_NO_ENOUGH_SPACE_TO_DOWNLOAD_PROPERTY = - "error.not.enough.space.to.download"; // NOI18N - public static final String ERROR_NO_ENOUGH_SPACE_TO_EXTRACT_PROPERTY = - "error.not.enough.space.to.extract"; // NOI18N - public static final String ERROR_CANNOT_CHECK_SPACE_PROPERTY = - "error.cannot.check.space"; // NOI18N - - public static final String DEFAULT_ERROR_NO_CHANGES = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.no.changes.both"); // NOI18N - public static final String DEFAULT_ERROR_NO_CHANGES_INSTALL_ONLY = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.no.changes.install"); // NOI18N - public static final String DEFAULT_ERROR_NO_CHANGES_UNINSTALL_ONLY = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.no.changes.uninstall"); // NOI18N - public static final String DEFAULT_ERROR_REQUIREMENT_INSTALL = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.requirement.install"); // NOI18N - public static final String DEFAULT_ERROR_CONFLICT_INSTALL = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.conflict.install"); // NOI18N - public static final String DEFAULT_ERROR_REQUIREMENT_UNINSTALL = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.requirement.uninstall"); // NOI18N - public static final String DEFAULT_ERROR_NO_ENOUGH_SPACE_TO_DOWNLOAD = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.not.enough.space.to.download"); // NOI18N - public static final String DEFAULT_ERROR_NO_ENOUGH_SPACE_TO_EXTRACT = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.not.enough.space.to.extract"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_CHECK_SPACE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "CSP.error.cannot.check.space"); // NOI18N - - public static final long REQUIRED_SPACE_ADDITION = - 10L * 1024L * 1024L; // 10MB -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/DestinationPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/DestinationPanel.java deleted file mode 100644 index 302a7d2ad276..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/DestinationPanel.java +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.*; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.swing.*; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * - * @author Kirill Sorokin - */ -public class DestinationPanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public DestinationPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(DESTINATION_LABEL_TEXT_PROPERTY, - DEFAULT_DESTINATION_LABEL_TEXT); - setProperty(DESTINATION_BUTTON_TEXT_PROPERTY, - DEFAULT_DESTINATION_BUTTON_TEXT); - setProperty(ERROR_NULL_PROPERTY, - DEFAULT_ERROR_NULL); - setProperty(ERROR_NOT_VALID_PROPERTY, - DEFAULT_ERROR_NOT_VALID); - setProperty(ERROR_CONTAINS_EXCLAMATION_PROPERTY, - DEFAULT_ERROR_CONTAINS_EXCLAMATION); - setProperty(ERROR_CONTAINS_SEMICOLON_PROPERTY, - DEFAULT_ERROR_CONTAINS_SEMICOLON); - setProperty(ERROR_CONTAINS_COLON_PROPERTY, - DEFAULT_ERROR_CONTAINS_COLON); - setProperty(ERROR_CONTAINS_AMPERSAND_PROPERTY, - DEFAULT_ERROR_CONTAINS_AMPERSAND); - setProperty(ERROR_CONTAINS_WRONG_CHAR_PROPERTY, - DEFAULT_ERROR_CONTAINS_WRONG_CHAR); - setProperty(ERROR_MATCHES_PROHIBITED_REGEXP, - DEFAULT_ERROR_MATCHES_PROHIBITIED_REGEXP); - setProperty(ERROR_CANNOT_CANONIZE_PROPERTY, - DEFAULT_ERROR_CANNOT_CANONIZE); - setProperty(ERROR_NOT_ABSOLUTE_PROPERTY, - DEFAULT_ERROR_NOT_ABSOLUTE); - setProperty(ERROR_NOT_DIRECTORY_PROPERTY, - DEFAULT_ERROR_NOT_DIRECTORY); - setProperty(ERROR_NOT_READABLE_PROPERTY, - DEFAULT_ERROR_NOT_READABLE); - setProperty(ERROR_NOT_WRITABLE_PROPERTY, - DEFAULT_ERROR_NOT_WRITABLE); - setProperty(ERROR_NOT_EMPTY_PROPERTY, - DEFAULT_ERROR_NOT_EMPTY); - setProperty(ERROR_NOT_ENDS_WITH_APP_PROPERTY, - DEFAULT_ERROR_NOT_ENDS_WITH_APP); - setProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY, - DEFAULT_ERROR_NOT_ENOUGH_SPACE); - setProperty(ERROR_CANNOT_GET_LOGIC_PROPERTY, - DEFAULT_ERROR_CANNOT_GET_LOGIC); - setProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY, - DEFAULT_ERROR_CANNOT_CHECK_SPACE); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new DestinationPanelUi(this); - } - - return wizardUi; - } - - @Override - public void initialize() { - super.initialize(); - final Product product = (Product) getWizard(). - getContext(). - get(Product.class); - - //installation location can be set using .installation.location system property - // Such a simplified approach is useful for silent installation - - // we can almost get rid of state file. - // Limitation is that if we have to install two products with the same uid - // but different versions then such a thing does now work correctly. - final String ilSysProp = product.getUid() + StringUtils.DOT + - Product.INSTALLATION_LOCATION_PROPERTY; - final String il = System.getProperty(ilSysProp); - final String ilSysPropDisabled = ilSysProp + ".initialization.disabled"; - - if (il != null && !Boolean.getBoolean(ilSysPropDisabled)) { - LogManager.log("... try to use installation location for " + product.getDisplayName() + - " from system property " + ilSysProp + " : " + il); - product.setInstallationLocation(new File(il)); - System.setProperty(ilSysPropDisabled, Boolean.toString(true)); - } - - String destination = product.getProperty(Product.INSTALLATION_LOCATION_PROPERTY); - - if (destination == null) { - destination = DEFAULT_DESTINATION; - } - - destination = resolvePath(destination).getAbsolutePath(); - - try { - if (SystemUtils.isMacOS() && (product.getLogic().wrapForMacOs() || - product.getLogic().requireDotAppForMacOs())) { - if (!destination.endsWith(APP_SUFFIX)) { - final File parent = new File(destination).getParentFile(); - final String suffix = product.getDisplayName() + APP_SUFFIX; - - if (parent != null) { - destination = new File( - parent, - suffix).getAbsolutePath(); - } else { - destination = new File( - destination, - suffix).getAbsolutePath(); - } - } - } - } catch (InitializationException e) { - ErrorManager.notifyError( - getProperty(ERROR_CANNOT_GET_LOGIC_PROPERTY), - e); - } - getWizard().setProperty(Product.INSTALLATION_LOCATION_PROPERTY, - destination); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class DestinationPanelUi extends ErrorMessagePanelUi { - protected DestinationPanel component; - - public DestinationPanelUi(DestinationPanel component) { - super(component); - - this.component = component; - } - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new DestinationPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class DestinationPanelSwingUi extends ErrorMessagePanelSwingUi { - protected DestinationPanel component; - - private NbiLabel destinationLabel; - private NbiTextField destinationField; - private NbiButton destinationButton; - - private NbiPanel spacerPanel; - - private NbiDirectoryChooser fileChooser; - - public DestinationPanelSwingUi( - final DestinationPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - @Override - public JComponent getDefaultFocusOwner() { - return destinationField; - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initialize() { - destinationLabel.setText( - component.getProperty(DESTINATION_LABEL_TEXT_PROPERTY)); - destinationButton.setText( - component.getProperty(DESTINATION_BUTTON_TEXT_PROPERTY)); - - final String destination = component.getWizard().getProperty( - Product.INSTALLATION_LOCATION_PROPERTY); - - destinationField.setText(destination); - - super.initialize(); - } - - @Override - protected void saveInput() { - try { - String value = destinationField.getText().trim(); - value = FileUtils.eliminateRelativity(value).getCanonicalPath(); - - component.getWizard().setProperty( - Product.INSTALLATION_LOCATION_PROPERTY, - value); - } catch (IOException e) { - ErrorManager.notifyError( - component.getProperty(ERROR_CANNOT_CANONIZE_PROPERTY), - e); - } - } - - protected NbiTextField getDestinationField() { - return destinationField; - } - - protected NbiButton getDestinationButton() { - return destinationButton; - } - - @Override - protected String validateInput() { - final String string = destinationField.getText().trim(); - final Product product = (Product) component. - getWizard(). - getContext(). - get(Product.class); - - try { - if (string.equals(StringUtils.EMPTY_STRING)) { - return StringUtils.format( - component.getProperty(ERROR_NULL_PROPERTY), - string); - } - - File file = FileUtils.eliminateRelativity(string); - - String filePath = file.getAbsolutePath(); - if (filePath.length() > 45) { - filePath = filePath.substring(0, 45) + "..."; - } - - if (!SystemUtils.isPathValid(file.getAbsolutePath())) { - return StringUtils.format( - component.getProperty(ERROR_NOT_VALID_PROPERTY), - filePath); - } - - final String[] prohibitedParts = product.getLogic().getProhibitedInstallationPathParts(); - if (prohibitedParts != null) { - for (String s : prohibitedParts) { - if (s != null && s.length() > 0) { - String prop = null; - if (s.length() == 1) { // character - if (file.getAbsolutePath().contains(s)) { - if (s.equals("!")) { - prop = ERROR_CONTAINS_EXCLAMATION_PROPERTY; - } else if (s.equals(";")) { - prop = ERROR_CONTAINS_SEMICOLON_PROPERTY; - } else if (s.equals(":")) { - prop = ERROR_CONTAINS_COLON_PROPERTY; - } else if (s.equals("&")) { - prop = ERROR_CONTAINS_AMPERSAND_PROPERTY; - } else { - // no user-friendly description for all other chars at this moment - // can be easily extended later - prop = ERROR_CONTAINS_WRONG_CHAR_PROPERTY; - } - } - } else {// check if path matches regexp.. - if (file.getAbsolutePath().matches(s)) { - prop = ERROR_MATCHES_PROHIBITED_REGEXP; - } - } - if (prop != null) { - return StringUtils.format( - component.getProperty(prop), - filePath, - s); - } - } - } - } - - if (!file.equals(file.getAbsoluteFile())) { - return StringUtils.format( - component.getProperty(ERROR_NOT_ABSOLUTE_PROPERTY), - file.getPath()); - } - - file = FileUtils.getNormalizedPathFile(file); - - filePath = file.getAbsolutePath(); - if (filePath.length() > 45) { - filePath = filePath.substring(0, 45) + "..."; - } - - if (file.exists() && !file.isDirectory()) { - return StringUtils.format( - component.getProperty(ERROR_NOT_DIRECTORY_PROPERTY), - filePath); - } - - if (!FileUtils.canRead(file)) { - return StringUtils.format( - component.getProperty(ERROR_NOT_READABLE_PROPERTY), - filePath); - } - - if (!FileUtils.canWrite(file)) { - return StringUtils.format( - component.getProperty(ERROR_NOT_WRITABLE_PROPERTY), - filePath); - } - - if (!FileUtils.isEmpty(file)) { - return StringUtils.format( - component.getProperty(ERROR_NOT_EMPTY_PROPERTY), - filePath); - } - - if (SystemUtils.isMacOS() && ( - product.getLogic().wrapForMacOs() || - product.getLogic().requireDotAppForMacOs()) && - !file.getAbsolutePath().endsWith(APP_SUFFIX)) { - return StringUtils.format( - component.getProperty(ERROR_NOT_ENDS_WITH_APP_PROPERTY), - filePath); - } - - if(!Boolean.getBoolean(SystemUtils.NO_SPACE_CHECK_PROPERTY)) { - final long requiredSize = - product.getRequiredDiskSpace() + REQUIRED_SPACE_ADDITION; - final long availableSize = - SystemUtils.getFreeSpace(file); - if (availableSize < requiredSize) { - return StringUtils.format( - component.getProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY), - filePath, - StringUtils.formatSize(requiredSize - availableSize)); - } - } - } catch (InitializationException e) { - ErrorManager.notifyError(component.getProperty( - ERROR_CANNOT_GET_LOGIC_PROPERTY), e); - } catch (NativeException e) { - ErrorManager.notifyError(component.getProperty( - ERROR_CANNOT_CHECK_SPACE_PROPERTY), e); - } - - return null; - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // destinationField ///////////////////////////////////////////////////// - destinationField = new NbiTextField(); - destinationField.getDocument().addDocumentListener(new DocumentListener() { - public void changedUpdate(DocumentEvent e) { - updateErrorMessage(); - } - public void insertUpdate(DocumentEvent e) { - updateErrorMessage(); - } - public void removeUpdate(DocumentEvent e) { - updateErrorMessage(); - } - }); - - // destinationLabel ///////////////////////////////////////////////////// - destinationLabel = new NbiLabel(); - destinationLabel.setLabelFor(destinationField); - - // destinationButton //////////////////////////////////////////////////// - destinationButton = new NbiButton(); - destinationButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - browseButtonPressed(); - } - }); - - // fileChooser ////////////////////////////////////////////////////////// - fileChooser = new NbiDirectoryChooser(); - - // spacerPanel ////////////////////////////////////////////////////////// - spacerPanel = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(destinationLabel, new GridBagConstraints( - 0, 0, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(destinationField, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(4, 11, 0, 0), // padding - 0, 0)); // padx, pady - ??? - add(destinationButton, new GridBagConstraints( - 1, 1, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.NONE, // fill - new Insets(4, 4, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacerPanel, new GridBagConstraints( - 1, 50, // x, y - 2, 1, // width, height - 0.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - } - - private void browseButtonPressed() { - final Product product = (Product) component. - getWizard(). - getContext(). - get(Product.class); - - final File currentDestination = new File(destinationField.getText()); - - fileChooser.setSelectedFile(currentDestination); - - if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - String newDestination = - fileChooser.getSelectedFile().getAbsolutePath(); - - try { - String suffix = currentDestination.getName(); - - if (SystemUtils.isMacOS() && ( - product.getLogic().wrapForMacOs() || - product.getLogic().requireDotAppForMacOs())) { - if (!newDestination.endsWith(APP_SUFFIX) && - !suffix.endsWith(APP_SUFFIX)) { - suffix += APP_SUFFIX; - } - } - File newDestFile = new File(newDestination); - if (!(newDestFile.equals(currentDestination) || newDestFile.getName().equals(suffix))) { - newDestination = new File( - newDestination, - suffix).getAbsolutePath(); - } - - } catch (InitializationException e) { - ErrorManager.notifyError(component.getProperty( - ERROR_CANNOT_GET_LOGIC_PROPERTY), e); - } - - destinationField.setText(newDestination); - } - } - - public String getDestinationPath() { - return destinationField.getText().trim(); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(DestinationPanel.class, - "DP.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(DestinationPanel.class, - "DP.description"); // NOI18N - - public static final String DESTINATION_LABEL_TEXT_PROPERTY - = "destination.label.text"; // NOI18N - public static final String DESTINATION_BUTTON_TEXT_PROPERTY - = "destination.button.text"; // NOI18N - - - public static final String DEFAULT_DESTINATION_LABEL_TEXT = - ResourceUtils.getString(DestinationPanel.class, - "DP.destination.label.text"); // NOI18N - public static final String DEFAULT_DESTINATION_BUTTON_TEXT = - ResourceUtils.getString(DestinationPanel.class, - "DP.destination.button.text"); // NOI18N - - - public static final String ERROR_NULL_PROPERTY = - "error.null"; // NOI18N - public static final String ERROR_NOT_VALID_PROPERTY = - "error.not.valid"; // NOI18N - public static final String ERROR_CONTAINS_EXCLAMATION_PROPERTY = - "error.contains.exclamation"; // NOI18N - public static final String ERROR_CONTAINS_SEMICOLON_PROPERTY = - "error.contains.semicolon"; // NOI18N - public static final String ERROR_CONTAINS_COLON_PROPERTY = - "error.contains.colon"; // NOI18N - public static final String ERROR_CONTAINS_AMPERSAND_PROPERTY = - "error.contains.ampersand"; // NOI18N - public static final String ERROR_CONTAINS_WRONG_CHAR_PROPERTY = - "error.contains.wrong.char"; // NOI18N - public static final String ERROR_MATCHES_PROHIBITED_REGEXP = - "error.matches.prohibited.regexp";//NOI18N - public static final String ERROR_NOT_ABSOLUTE_PROPERTY = - "error.not.absolute"; // NOI18N - public static final String ERROR_CANNOT_CANONIZE_PROPERTY = - "error.cannot.canonize"; // NOI18N - public static final String ERROR_NOT_DIRECTORY_PROPERTY = - "error.not.directory"; // NOI18N - public static final String ERROR_NOT_READABLE_PROPERTY = - "error.not.readable"; // NOI18N - public static final String ERROR_NOT_WRITABLE_PROPERTY = - "error.not.writable"; // NOI18N - public static final String ERROR_NOT_EMPTY_PROPERTY = - "error.not.empty"; // NOI18N - public static final String ERROR_NOT_ENDS_WITH_APP_PROPERTY = - "error.not.ends.with.app"; // NOI18N - public static final String ERROR_NOT_ENOUGH_SPACE_PROPERTY = - "error.not.enough.space"; // NOI18N - public static final String ERROR_CANNOT_GET_LOGIC_PROPERTY = - "error.cannot.get.logic";//NOI18N - public static final String ERROR_CANNOT_CHECK_SPACE_PROPERTY = - "error.cannot.check.space"; // NOI18N - - public static final String DEFAULT_ERROR_NULL = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.null"); // NOI18N - public static final String DEFAULT_ERROR_NOT_VALID = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.valid"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_EXCLAMATION = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.contains.exclamation"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_SEMICOLON = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.contains.semicolon"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_COLON = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.contains.colon"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_AMPERSAND = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.contains.ampersand"); // NOI18N - public static final String DEFAULT_ERROR_CONTAINS_WRONG_CHAR = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.contains.wrong.char"); // NOI18N - public static final String DEFAULT_ERROR_MATCHES_PROHIBITIED_REGEXP = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.matches.prohibited.regexp"); // NOI18N - public static final String DEFAULT_ERROR_NOT_ABSOLUTE = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.absolute"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_CANONIZE = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.cannot.canonize"); // NOI18N - public static final String DEFAULT_ERROR_NOT_DIRECTORY = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.directory"); // NOI18N - public static final String DEFAULT_ERROR_NOT_READABLE = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.readable"); // NOI18N - public static final String DEFAULT_ERROR_NOT_WRITABLE = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.writable"); // NOI18N - public static final String DEFAULT_ERROR_NOT_EMPTY = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.empty"); // NOI18N - public static final String DEFAULT_ERROR_NOT_ENDS_WITH_APP = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.ends.with.app"); // NOI18N - public static final String DEFAULT_ERROR_NOT_ENOUGH_SPACE = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.not.enough.space"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_GET_LOGIC = - ResourceUtils.getString(DestinationPanel.class, - "DP.error.cannot.get.logic"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_CHECK_SPACE = - ResourceUtils.getString(ComponentsSelectionPanel.class, - "DP.error.cannot.check.space"); // NOI18N - - public static final String DEFAULT_DESTINATION = - ResourceUtils.getString(DestinationPanel.class, - "DP.default.destination"); // NOI18N - - public static final String APP_SUFFIX = - ".app"; // NOI18N - - public static final long REQUIRED_SPACE_ADDITION = - 10L * 1024L * 1024L; // 10MB -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ErrorMessagePanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ErrorMessagePanel.java deleted file mode 100644 index 57cda9427f36..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/ErrorMessagePanel.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.helper.NbiThread; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelSwingUi; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * - * @author Kirill Sorokin - */ -public class ErrorMessagePanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public ErrorMessagePanel() { - setProperty(CANCEL_DIALOG_MESSAGE_PROPERTY, DEFAULT_CANCEL_DIALOG_MESSAGE_TEXT); - setProperty(CANCEL_DIALOG_TITLE_PROPERTY, DEFAULT_CANCEL_DIALOG_TITLE_TEXT); - setProperty(ERROR_FAILED_VERIFY_INPUT_PROPERTY,DEFAULT_ERROR_FAILED_VERIFY_INPUT_TEXT); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new ErrorMessagePanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class ErrorMessagePanelUi extends WizardPanelUi { - protected ErrorMessagePanel component; - - public ErrorMessagePanelUi(ErrorMessagePanel component) { - super(component); - - this.component = component; - } - - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new ErrorMessagePanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class ErrorMessagePanelSwingUi extends WizardPanelSwingUi { - ///////////////////////////////////////////////////////////////////////////// - // Constants - public static final String ERROR_ICON = - "org/netbeans/installer/wizard/components/panels/error.png"; // NOI18N - public static final String WARNING_ICON = - "org/netbeans/installer/wizard/components/panels/warning.png"; // NOI18N - public static final String INFO_ICON = - "org/netbeans/installer/wizard/components/panels/info.png"; // NOI18N - public static final String EMPTY_ICON = - "org/netbeans/installer/wizard/components/panels/empty.png"; // NOI18N - - public static final Color ERROR_COLOR = - Color.BLACK; - public static final Color WARNING_COLOR = - Color.BLACK; - public static final Color INFO_COLOR = - Color.BLACK; - public static final Color EMPTY_COLOR = - Color.BLACK; - - ///////////////////////////////////////////////////////////////////////////// - // Instance - protected ErrorMessagePanel component; - - private Icon errorIcon; - private Icon warningIcon; - private Icon infoIcon; - private Icon emptyIcon; - - private Color errorColor; - private Color warningColor; - private Color infoColor; - private Color emptyColor; - - private NbiLabel errorLabel; - - private ValidatingThread validatingThread; - - public ErrorMessagePanelSwingUi( - final ErrorMessagePanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - errorIcon = new ImageIcon( - getClass().getClassLoader().getResource(ERROR_ICON)); - warningIcon = new ImageIcon( - getClass().getClassLoader().getResource(WARNING_ICON)); - infoIcon = new ImageIcon( - getClass().getClassLoader().getResource(INFO_ICON)); - emptyIcon = new ImageIcon( - getClass().getClassLoader().getResource(EMPTY_ICON)); - - errorColor = - ERROR_COLOR; - warningColor = - WARNING_COLOR; - infoColor = - INFO_COLOR; - emptyColor = - EMPTY_COLOR; - - initComponents(); - } - - @Override - public void evaluateBackButtonClick() { - if (validatingThread != null) { - validatingThread.finish(); - validatingThread = null; - } - - super.evaluateBackButtonClick(); - } - - @Override - public void evaluateNextButtonClick() { - if (validatingThread != null) { - validatingThread.pause(); - } - - final String errorMessage = validateInput(); - - if (errorMessage == null) { - saveInput(); - if(validatingThread != null) { - validatingThread.finish(); - validatingThread = null; - } - component.getWizard().next(); - } else { - ErrorManager.notifyError(errorMessage); - if (validatingThread != null) { - validatingThread.play(); - } - } - } - - @Override - public void evaluateCancelButtonClick() { - if (validatingThread != null) { - validatingThread.pause(); - } - - if (!UiUtils.showYesNoDialog( - component.getProperty(CANCEL_DIALOG_TITLE_PROPERTY), - component.getProperty(CANCEL_DIALOG_MESSAGE_PROPERTY))) { - if (validatingThread != null) { - validatingThread.play(); - } - return; - } - if (validatingThread != null) { - validatingThread.finish(); - validatingThread = null; - } - component.getWizard().getFinishHandler().cancel(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initialize() { - updateErrorMessage(); - - if (validatingThread == null) { - validatingThread = new ValidatingThread(this, component); - validatingThread.start(); - } else { - validatingThread.play(); - } - } - - protected String getWarningMessage() { - return null; - } - - protected String getInformationalMessage() { - return null; - } - - protected final synchronized void updateErrorMessage() { - String message; - - try { - message = validateInput(); - if (message != null) { - errorLabel.setIcon(errorIcon); - errorLabel.setText(message); - errorLabel.setForeground(errorColor); - container.getNextButton().setEnabled(false); - - return; - } - - message = getWarningMessage(); - if (message != null) { - errorLabel.setIcon(warningIcon); - errorLabel.setText(message); - errorLabel.setForeground(warningColor); - container.getNextButton().setEnabled(true); - - return; - } - - message = getInformationalMessage(); - if (message != null) { - errorLabel.setIcon(infoIcon); - errorLabel.setText(message); - errorLabel.setForeground(infoColor); - container.getNextButton().setEnabled(true); - - return; - } - - errorLabel.setIcon(emptyIcon); - errorLabel.clearText(); - errorLabel.setForeground(emptyColor); - container.getNextButton().setEnabled(true); - } catch (Exception e) { - // we have a good reason to catch Exception here, as most of the - // code that is called is not under the engine's control - // (validateInput() is component-specific) and we do not want to - // propagate unexpected exceptions that could otherwise be handled - // normally - - ErrorManager.notifyError( - component.getProperty(ERROR_FAILED_VERIFY_INPUT_PROPERTY), e); - } - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // errorLabel /////////////////////////////////////////////////////////// - errorLabel = new NbiLabel(); - - // this ///////////////////////////////////////////////////////////////// - add(errorLabel, new GridBagConstraints( - 0, 99, // x, y - 99, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(11, 11, 11, 11), // padding - 0, 0)); // ??? (padx, pady) - } - - ///////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class ValidatingThread extends NbiThread { - ///////////////////////////////////////////////////////////////////////// - // Instance - private ErrorMessagePanelSwingUi swingUi; - private boolean paused; - private boolean stopped; - - public ValidatingThread(final ErrorMessagePanelSwingUi swingUi, WizardPanel panel) { - super(); - - this.swingUi = swingUi; - this.paused = false; - this.stopped = false; - } - - public void run() { - while (true) { - if(stopped) { - break; - } - if (!paused) { - swingUi.updateErrorMessage(); - } - if(stopped) { - break; - } - try { - sleep(VALIDATION_DELAY); - } catch (InterruptedException e) { - ErrorManager.notifyDebug("Interrupted", e); - } - } - } - - public void pause() { - paused = true; - } - - public void finish() { - paused = true; - stopped = true; - } - - public void play() { - paused = false; - stopped = false; - } - - ///////////////////////////////////////////////////////////////////////// - // Constants - public static final long VALIDATION_DELAY = 2000; - } - - public static class ValidatingDocumentListener implements DocumentListener { - ///////////////////////////////////////////////////////////////////////// - // Instance - private ErrorMessagePanelSwingUi swingUi; - - public ValidatingDocumentListener(ErrorMessagePanelSwingUi swingUi) { - this.swingUi = swingUi; - } - - public void insertUpdate(DocumentEvent event) { - swingUi.updateErrorMessage(); - } - - public void removeUpdate(DocumentEvent event) { - swingUi.updateErrorMessage(); - } - - public void changedUpdate(DocumentEvent event) { - swingUi.updateErrorMessage(); - } - } - } - - public static final String CANCEL_DIALOG_MESSAGE_PROPERTY = - "cancel.dialog.message";//NOI18N - public static final String CANCEL_DIALOG_TITLE_PROPERTY = - "cancel.dialog.title";//NOI18N - public static final String ERROR_FAILED_VERIFY_INPUT_PROPERTY = - "error.failed.verify.input";//NOI18N - - - public static final String DEFAULT_CANCEL_DIALOG_MESSAGE_TEXT = - ResourceUtils.getString(ErrorMessagePanel.class, - "EMP.cancel.dialog.message");//NOI18N - public static final String DEFAULT_CANCEL_DIALOG_TITLE_TEXT = - ResourceUtils.getString(ErrorMessagePanel.class, - "EMP.cancel.dialog.title");//NOI18N - public static final String DEFAULT_ERROR_FAILED_VERIFY_INPUT_TEXT = - ResourceUtils.getString(ErrorMessagePanel.class, - "EMP.error.failed.input.verify");//NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/JdkLocationPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/JdkLocationPanel.java deleted file mode 100644 index 2365ea4995f9..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/JdkLocationPanel.java +++ /dev/null @@ -1,748 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.dependencies.InstallAfter; -import org.netbeans.installer.product.filters.OrFilter; -import org.netbeans.installer.product.filters.ProductFilter; -import org.netbeans.installer.product.filters.RegistryFilter; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.helper.Version.VersionDistance; -import org.netbeans.installer.wizard.components.actions.SearchForJavaAction; - -/** - * - * @author Kirill Sorokin - */ -public class JdkLocationPanel extends ApplicationLocationPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - private Version minimumVersion; - private Version maximumVersion; - private Version preferredVersion; - private String vendorAllowed; - private List jdkLocations; - private List jdkLabels; - private static File lastSelectedJava = null; - - public JdkLocationPanel() { - setProperty(MINIMUM_JDK_VERSION_PROPERTY, - DEFAULT_MINIMUM_JDK_VERSION); - setProperty(MAXIMUM_JDK_VERSION_PROPERTY, - DEFAULT_MAXIMUM_JDK_VERSION); - setProperty(VENDOR_JDK_ALLOWED_PROPERTY, - DEFAULT_VENDOR_JDK_ALLOWED); - setProperty(JRE_ALLOWED_PROPERTY, - DEFAULT_JRE_ALLOWED); - setProperty(LOCATION_LABEL_TEXT_PROPERTY, - DEFAULT_LOCATION_LABEL_TEXT); - setProperty(LOCATION_BUTTON_TEXT_PROPERTY, - DEFAULT_LOCATION_BUTTON_TEXT); - setProperty(LIST_LABEL_TEXT_PROPERTY, - DEFAULT_LIST_LABEL_TEXT); - - setProperty(ERROR_NULL_PROPERTY, - DEFAULT_ERROR_NULL); - setProperty(ERROR_NOT_VALID_PATH_PROPERTY, - DEFAULT_ERROR_NOT_VALID_PATH); - setProperty(ERROR_PATH_NOT_EXISTS_PROPERTY, - DEFAULT_ERROR_PATH_NOT_EXISTS); - setProperty(ERROR_NOT_JAVAHOME_PROPERTY, - DEFAULT_ERROR_NOT_JAVAHOME); - setProperty(ERROR_NOT_JDK_PROPERTY, - DEFAULT_ERROR_NOT_JDK); - setProperty(ERROR_WRONG_VERSION_OLDER_PROPERTY, - DEFAULT_ERROR_WRONG_VERSION_OLDER); - setProperty(ERROR_WRONG_VERSION_NEWER_PROPERTY, - DEFAULT_ERROR_WRONG_VERSION_NEWER); - setProperty(ERROR_WRONG_VENDOR_PROPERTY, - DEFAULT_ERROR_WRONG_VENDOR); - setProperty(ERROR_UNKNOWN_PROPERTY, - DEFAULT_ERROR_UNKNOWN); - setProperty(ERROR_NOTHING_FOUND_PROPERTY, - DEFAULT_ERROR_NOTHING_FOUND); - - setProperty(USEDBY_LABEL_PROPERTY, - DEFAULT_USEDBY_LABEL); - - setProperty(JAVA_DOWNLOAD_PAGE_PROPERTY, - !SystemUtils.isMacOS() ? - DEFAULT_JAVA_DOWNLOAD_PAGE : - DEFAULT_JAVA_DOWNLOAD_PAGE_MAC); - } - - @Override - public void initialize() { - super.initialize(); - - minimumVersion = Version.getVersion( - getProperty(MINIMUM_JDK_VERSION_PROPERTY)); - maximumVersion = Version.getVersion( - getProperty(MAXIMUM_JDK_VERSION_PROPERTY)); - vendorAllowed = getProperty(VENDOR_JDK_ALLOWED_PROPERTY); - - if (getProperty(PREFERRED_JDK_VERSION_PROPERTY) != null) { - preferredVersion = Version.getVersion( - getProperty(PREFERRED_JDK_VERSION_PROPERTY)); - } - - addJavaLocationsFromProductDependencies(); - - jdkLocations = new LinkedList(); - jdkLabels = new LinkedList(); - - final Registry registry = Registry.getInstance(); - for (int i = 0; i < SearchForJavaAction.getJavaLocations().size(); i++) { - final File location = SearchForJavaAction.getJavaLocations().get(i); - - String label = SearchForJavaAction.getJavaLabels().get(i); - Version version = null; - - // initialize the version; if the location exists, it must be an - // already installed jdk and we should fetch the version in a - // "traditional" way; otherwise the jdk is only planned for - // installation and we should try to get its version from the - // registry - if (location.exists()) { - version = JavaUtils.getVersion(location); - } - if (version == null) { - version = getVersion(location); - } - - // if we could not fetch the version, we should skip this jdk - // installation - if (version == null) { - continue; - } - - // run through the installed and to-be-installed products and check - // whether this location is already used somewhere - final RegistryFilter filter = new OrFilter( - new ProductFilter(Status.INSTALLED), - new ProductFilter(Status.TO_BE_INSTALLED)); - final List products = new LinkedList(); - for (Product product: registry.queryProducts(filter)) { - final String jdk = product.getProperty(JDK_LOCATION_PROPERTY); - - if ((jdk != null) && jdk.equals(location.getAbsolutePath())) { - products.add(product); - } - } - - final Product product = (Product) getWizard(). - getContext(). - get(Product.class); - - if (products.contains(product)) { - products.remove(product); - } - if (products.size() > 0) { - label = StringUtils.format( - getProperty(USEDBY_LABEL_PROPERTY), - label, - StringUtils.asString(products)); - } - - // if the location exists and is a jdk installation (or if the - // location does not exist - in this case we're positive that it - // WILL be a jdk) and if version satisfies the requirements - add - // the location to the list - if ((!location.exists() || isJreAllowed() || JavaUtils.isJdk(location))) { - String vendor = JavaUtils.getInfo(location).getVendor(); - if (JavaUtils.getInfo(location) == null) { - LogManager.log("JdkLocationPanel - JavaUtils.getInfo(" + location + ") returns null!"); - continue; - } - - if(!version.olderThan(minimumVersion) && - !version.newerThan(maximumVersion) && - vendor.matches(vendorAllowed)) { - jdkLocations.add(location); - jdkLabels.add(label); - } - - } - } - - //reinitialize properties that are different in case of JRE or only-JDK allowance - final boolean jreAllowed = isJreAllowed(); - setProperty(LOCATION_LABEL_TEXT_PROPERTY, - jreAllowed ? DEFAULT_LOCATION_LABEL_TEXT_JAVA : DEFAULT_LOCATION_LABEL_TEXT); - setProperty(LIST_LABEL_TEXT_PROPERTY, - jreAllowed ? DEFAULT_LIST_LABEL_TEXT_JAVA : DEFAULT_LIST_LABEL_TEXT); - setProperty(ERROR_NULL_PROPERTY, - jreAllowed ? DEFAULT_ERROR_NULL_JAVA : DEFAULT_ERROR_NULL); - setProperty(ERROR_NOT_VALID_PATH_PROPERTY, - jreAllowed ? DEFAULT_ERROR_NOT_VALID_PATH_JAVA : DEFAULT_ERROR_NOT_VALID_PATH); - setProperty(ERROR_PATH_NOT_EXISTS_PROPERTY, - jreAllowed ? DEFAULT_ERROR_PATH_NOT_EXISTS_JAVA : DEFAULT_ERROR_PATH_NOT_EXISTS); - setProperty(ERROR_NOT_JAVAHOME_PROPERTY, - jreAllowed ? DEFAULT_ERROR_NOT_JAVAHOME_JAVA : DEFAULT_ERROR_NOT_JAVAHOME); - setProperty(ERROR_WRONG_VERSION_OLDER_PROPERTY, - jreAllowed ? DEFAULT_ERROR_WRONG_VERSION_OLDER_JAVA : DEFAULT_ERROR_WRONG_VERSION_OLDER); - setProperty(ERROR_WRONG_VERSION_NEWER_PROPERTY, - jreAllowed ? DEFAULT_ERROR_WRONG_VERSION_NEWER_JAVA : DEFAULT_ERROR_WRONG_VERSION_NEWER); - setProperty(ERROR_WRONG_VENDOR_PROPERTY, - jreAllowed ? DEFAULT_ERROR_WRONG_VENDOR_JAVA : DEFAULT_ERROR_WRONG_VENDOR); - setProperty(ERROR_NOTHING_FOUND_PROPERTY, - jreAllowed ? DEFAULT_ERROR_NOTHING_FOUND_JAVA : DEFAULT_ERROR_NOTHING_FOUND); - } - - @Override - public List getLocations() { - return jdkLocations; - } - - @Override - public List getLabels() { - return jdkLabels; - } - - private boolean isJreAllowed() { - return "true".equals(getProperty(JRE_ALLOWED_PROPERTY)); - } - - @Override - public File getSelectedLocation() { - // the first obvious choice is the jdk that has already been selected for - // this product; if it has not yet been set, there are still lots of - // choices: - // - reuse the location which is set using .jdk.location system property - // - reuse the location which was selected on another jdk location panel if - // it fits the requirements - // - use the location of the jdk if it is bundled and already installed - // - reuse the location which has been used for an installed product if - // it fits the requirements - // - choose the closest one to the preferred version if it is defined and - // a valid closest version exists - // - use the first item in the list - // - use an empty path - - File jdkLocation = null; - - jdkLocation = getJavaAlreadySelectedForProduct(); - if (jdkLocation != null) { - LogManager.log("... use Java that is already selected for the product: " + jdkLocation); - return jdkLocation; - } - - jdkLocation = getJavaFromSystemProperty(); - if (jdkLocation != null) { - LogManager.log("... use Java that is passed via a system property: " + jdkLocation); - return jdkLocation; - } - - jdkLocation = getJavaAlreadySelectedGlobal(); - if (jdkLocation != null) { - LogManager.log("... use Java that is already selected for another product which be installed: " + jdkLocation); - return jdkLocation; - } - - jdkLocation = getJavaBundledAndInstalled(); - if (jdkLocation != null) { - LogManager.log("... use Java that is bundled and installed: " + jdkLocation); - return jdkLocation; - } - /* - jdkLocation = getJavaFromInstalledProductProperties(); - if (jdkLocation != null) { - LogManager.log("... use Java from properties of installed products: " + jdkLocation); - return jdkLocation; - } - */ - jdkLocation = getJavaPreferredVersionLocation(); - if (jdkLocation != null) { - LogManager.log("... use Java based on the preferred version: " + jdkLocation); - return jdkLocation; - } - - jdkLocation = getJavaFirstItemInTheList(); - if (jdkLocation != null) { - LogManager.log("... use Java from the first item in the overall list: " + jdkLocation); - return jdkLocation; - } else { - LogManager.log("... no Java found"); - return new File(StringUtils.EMPTY_STRING); - } - } - - private File getJavaFirstItemInTheList() { - if(jdkLocations.isEmpty()) { - return null; - } - if(isJreAllowed()) { - for(File f : jdkLocations) { - if(!FileUtils.exists(f) || JavaUtils.isJdk(f)) { - return f; - } - } - } - return jdkLocations.get(0); - } - - - private File getJavaFromSystemProperty() { - final Object obj = getWizard(). - getContext(). - get(Product.class); - if (obj instanceof Product) { - final Product product = (Product) obj; - final String jdkSysPropName = product.getUid() + StringUtils.DOT + - JdkLocationPanel.JDK_LOCATION_PROPERTY; - final String jdkSysProp = System.getProperty(jdkSysPropName); - if (jdkSysProp != null) { - final File f = new File(jdkSysProp); - if (jdkLocations.contains(f)) { - LogManager.log("... using JDK from system property " + jdkSysPropName + " : " + jdkSysProp); - return f; - } - } - } - return null; - } - - private File getJavaAlreadySelectedForProduct() { - final String jdkLocation = - getWizard().getProperty(JDK_LOCATION_PROPERTY); - if (jdkLocation != null && jdkLocations.contains(new File(jdkLocation))) { - return new File(jdkLocation); - } - return null; - } - - private File getJavaAlreadySelectedGlobal() { - return ((lastSelectedJava != null) && - jdkLocations.contains(lastSelectedJava)) ? lastSelectedJava : null; - } - - private File getJavaBundledAndInstalled() { - try { - Registry bundledRegistry = new Registry(); - final String bundledRegistryUri = System.getProperty( - Registry.BUNDLED_PRODUCT_REGISTRY_URI_PROPERTY); - - bundledRegistry.loadProductRegistry( - (bundledRegistryUri != null) ? bundledRegistryUri : Registry.DEFAULT_BUNDLED_PRODUCT_REGISTRY_URI); - - // iterate over bundled JDKs to check whether they are already installed - for (Product bundledJdk : bundledRegistry.getProducts(JDK_PRODUCT_UID)) { - Product globalJdk = Registry.getInstance().getProduct( - JDK_PRODUCT_UID, - bundledJdk.getVersion()); - - if (globalJdk != null) { - final File jdkLoc = globalJdk.getStatus().equals(Status.INSTALLED) ? globalJdk.getInstallationLocation() : JavaUtils.findJDKHome(globalJdk.getVersion()); - - if (jdkLoc != null && jdkLocations.contains(jdkLoc)) { - return jdkLoc; - } - - } - } - - } catch (InitializationException e) { - LogManager.log("Cannot load bundled registry", e); - } - - return null; - } - - private File getJavaFromInstalledProductProperties() { - for (Product product : Registry.getInstance().queryProducts(new OrFilter( - new ProductFilter(Status.INSTALLED), - new ProductFilter(Status.TO_BE_INSTALLED)))) { - final String jdk = product.getProperty(JDK_LOCATION_PROPERTY); - - if (jdk != null) { - final File jdkFile = new File(jdk); - - if (jdkLocations.contains(jdkFile)) { - return jdkFile; - } - } - } - return null; - } - - private File getJavaPreferredVersionLocation() { - if (preferredVersion == null) { - return null; - } - //if JRE is allowed then first search among full JDKs and for closest one - //if JDK is not found then choose the closest between JREs - File closestLocation = null; - VersionDistance closestDistance = null; - if (isJreAllowed()) { - - for (File location : jdkLocations) { - final Version currentVersion = - JavaUtils.getVersion(location); - final VersionDistance currentDistance = - currentVersion.getDistance(preferredVersion); - if (!FileUtils.exists(location) || JavaUtils.isJdk(location)) { - if ((closestDistance == null) || - currentDistance.lessThan(closestDistance)) { - closestLocation = location; - closestDistance = currentDistance; - } - } - } - } - if (closestLocation == null) { - for (File location : jdkLocations) { - final Version currentVersion = - JavaUtils.getVersion(location); - final VersionDistance currentDistance = - currentVersion.getDistance(preferredVersion); - - if ((closestDistance == null) || - currentDistance.lessThan(closestDistance)) { - closestLocation = location; - closestDistance = currentDistance; - } - } - } - return closestLocation; - } - - @Override - public String validateLocation(final String path) { - final File file = new File(path); - - if (path.equals(StringUtils.EMPTY_STRING)) { - return StringUtils.format( - getProperty(ERROR_NULL_PROPERTY)); - } - - if (!SystemUtils.isPathValid(path)) { - return StringUtils.format( - getProperty(ERROR_NOT_VALID_PATH_PROPERTY), path); - } - - if (!file.exists()) { - if(JavaUtils.getInfo(file)==null) { - // JDK location does not exist and is not in the list of installable JDKs - return StringUtils.format( - getProperty(ERROR_PATH_NOT_EXISTS_PROPERTY), path); - } - } else { - if (!JavaUtils.isJavaHome(file)) { - return StringUtils.format( - getProperty(ERROR_NOT_JAVAHOME_PROPERTY), path); - } - - if (!isJreAllowed() && !JavaUtils.isJdk(file)) { - return StringUtils.format( - getProperty(ERROR_NOT_JDK_PROPERTY), path); - } - } - - Version version = getVersion(file); - - if (version == null) { - return StringUtils.format(getProperty(ERROR_UNKNOWN_PROPERTY), path); - } - - if (version.olderThan(minimumVersion)) { - return StringUtils.format( - getProperty(ERROR_WRONG_VERSION_OLDER_PROPERTY), - path, - version, - minimumVersion); - } - - if (version.newerThan(maximumVersion)) { - return StringUtils.format( - getProperty(ERROR_WRONG_VERSION_NEWER_PROPERTY), - path, - version, - maximumVersion); - } - - String vendor = JavaUtils.getInfo(file).getVendor(); - if(!vendor.matches(vendorAllowed)) { - return StringUtils.format( - getProperty(ERROR_WRONG_VENDOR_PROPERTY), - path, - vendor, - vendorAllowed); - } - - return null; - } - - @Override - public void setLocation(final File location) { - lastSelectedJava = location; - SearchForJavaAction.addJavaLocation(location); - getWizard().setProperty(JDK_LOCATION_PROPERTY, location.getAbsolutePath()); - } - - /** - * Returns if JDK version is recommended - #218822 - * @param jdkPath - * @return false if not recommended. If JDK does not exist returns true. - */ - public boolean isJdkVersionRecommended(String jdkPath) { - File jdkFile = new File(jdkPath); - Version version = getVersion(jdkFile); - - return version != null ? JavaUtils.isRecommended(version) : true; - } - - public boolean isArchitectureMatching(String jdkPath) { - if (jdkPath == null || jdkPath.isEmpty()) { - return true; // Better to suppose the arch is matching then to confuse user. - } - - File jdkFile = new File(jdkPath); - JavaUtils.JavaInfo info = JavaUtils.getInfo(jdkFile); - - if (info == null) { - return true; // Better to suppose the arch is matching then to confuse user. - } - - return info.getArch().endsWith("64") || !SystemUtils.getNativeUtils().isSystem64Bit(); - } - - private Version getVersion(File file) { - Version version = JavaUtils.getVersion(file); - - if (version == null) { - for (Product jdk : Registry.getInstance().getProducts(JDK_PRODUCT_UID)) { - if ((jdk.getStatus() == Status.TO_BE_INSTALLED) && jdk.getInstallationLocation().equals(file)) { - version = jdk.getVersion(); - } - } - for (Product jreNested : Registry.getInstance().getProducts(JRE_NESTED_PRODUCT_UID)) { - if ((jreNested.getStatus() == Status.TO_BE_INSTALLED) && jreNested.getInstallationLocation().equals(file)) { - version = jreNested.getVersion(); - } - } - } - - return version; - } - - private void addJavaLocationsFromProductDependencies() { - // finally we should scan the registry for jdks planned for installation, if - // the current product is scheduled to be installed after 'jdk', i.e. has - // an install-after dependency on 'jdk' uid - - final Object objectContext = getWizard().getContext().get(Product.class); - boolean sort = false; - if(objectContext instanceof Product) { - final Product product = (Product) objectContext; - for (Dependency dependency : product.getDependencies(InstallAfter.class)) { - - if (dependency.getUid().equals(JDK_PRODUCT_UID)) { - for (Product jdk : Registry.getInstance().getProducts(JDK_PRODUCT_UID)) { - if (jdk.getStatus() == Status.TO_BE_INSTALLED && - !SearchForJavaAction.getJavaLocations(). - contains(jdk.getInstallationLocation())) { - SearchForJavaAction.addJavaLocation( - jdk.getInstallationLocation(), - jdk.getVersion(), - SUN_MICROSYSTEMS_VENDOR); - sort = true; - } - } - } - if (dependency.getUid().equals(JRE_NESTED_PRODUCT_UID)) { - for (Product jreNested : Registry.getInstance().getProducts(JRE_NESTED_PRODUCT_UID)) { - if (jreNested.getStatus() == Status.TO_BE_INSTALLED) { - SearchForJavaAction.addJavaLocation( - jreNested.getInstallationLocation(), - jreNested.getVersion(), - SUN_MICROSYSTEMS_VENDOR); - sort = true; - } - } - - break; - } - } - } - if(sort) { - SearchForJavaAction.sortJavaLocations(); - } - } -///////////////////////////////////////////////////////////////////////////////// -// Constants - public static final String JDK_LOCATION_PROPERTY = - "jdk.location"; // NOI18N - - public static final String JRE_NESTED = - "jre.nested"; // NOI18N - - public static final String MINIMUM_JDK_VERSION_PROPERTY = - "minimum.jdk.version"; // NOI18N - public static final String MAXIMUM_JDK_VERSION_PROPERTY = - "maximum.jdk.version"; // NOI18N - public static final String PREFERRED_JDK_VERSION_PROPERTY = - "preferred.jdk.version"; // NOI18N - public static final String VENDOR_JDK_ALLOWED_PROPERTY = - "vendor.jdk.allowed.pattern"; // NOI18N - public static final String JRE_ALLOWED_PROPERTY = - "jre.allowed"; // NOI18N - public static final String DEFAULT_JRE_ALLOWED = - "false";//NOI18N - - public static final String DEFAULT_LOCATION_LABEL_TEXT = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.location.label.text"); // NOI18N - public static final String DEFAULT_LOCATION_LABEL_TEXT_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.location.label.text.java"); // NOI18N - public static final String DEFAULT_LOCATION_BUTTON_TEXT = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.location.button.text"); // NOI18N - public static final String DEFAULT_LIST_LABEL_TEXT = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.list.label.text"); // NOI18N - public static final String DEFAULT_LIST_LABEL_TEXT_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.list.label.text.java"); // NOI18N - - public static final String ERROR_NULL_PROPERTY = - "error.null"; // NOI18N - public static final String ERROR_NOT_VALID_PATH_PROPERTY = - "error.not.valid.path"; // NOI18N - public static final String ERROR_PATH_NOT_EXISTS_PROPERTY = - "error.path.not.exists"; // NOI18N - public static final String ERROR_NOT_JAVAHOME_PROPERTY = - "error.not.javahome"; // NOI18N - public static final String ERROR_NOT_JDK_PROPERTY = - "error.not.jdk"; // NOI18N - public static final String ERROR_WRONG_VERSION_OLDER_PROPERTY = - "error.wrong.version.older"; // NOI18N - public static final String ERROR_WRONG_VERSION_NEWER_PROPERTY = - "error.wrong.version.newer"; // NOI18N - public static final String ERROR_WRONG_VENDOR_PROPERTY = - "error.wrong.vendor"; // NOI18N - public static final String ERROR_UNKNOWN_PROPERTY = - "error.unknown"; // NOI18N - - public static final String DEFAULT_ERROR_NULL = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.null"); // NOI18N - public static final String DEFAULT_ERROR_NULL_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.null.java"); // NOI18N - public static final String DEFAULT_ERROR_NOT_VALID_PATH = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.not.valid.path"); // NOI18N - public static final String DEFAULT_ERROR_NOT_VALID_PATH_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.not.valid.path.java"); // NOI18N - public static final String DEFAULT_ERROR_PATH_NOT_EXISTS = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.path.not.exists"); // NOI18N - public static final String DEFAULT_ERROR_PATH_NOT_EXISTS_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.path.not.exists.java"); // NOI18N - public static final String DEFAULT_ERROR_NOT_JAVAHOME = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.not.javahome"); // NOI18N - public static final String DEFAULT_ERROR_NOT_JAVAHOME_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.not.javahome.java"); // NOI18N - public static final String DEFAULT_ERROR_NOT_JDK = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.not.jdk"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VERSION_OLDER = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.version.older"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VERSION_OLDER_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.version.older.java"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VERSION_NEWER = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.version.newer"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VERSION_NEWER_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.version.newer.java"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VENDOR = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.vendor"); // NOI18N - public static final String DEFAULT_ERROR_WRONG_VENDOR_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.wrong.vendor.java"); // NOI18N - - public static final String DEFAULT_ERROR_UNKNOWN = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.unknown"); // NOI18N - public static final String DEFAULT_ERROR_NOTHING_FOUND = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.nothing.found"); // NOI18N - public static final String DEFAULT_ERROR_NOTHING_FOUND_JAVA = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.error.nothing.found.java"); // NOI18N - - public static final String DEFAULT_MINIMUM_JDK_VERSION = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.minimum.jdk.version"); // NOI18N - public static final String DEFAULT_MAXIMUM_JDK_VERSION = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.maximum.jdk.version"); // NOI18N - public static final String DEFAULT_VENDOR_JDK_ALLOWED = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.vendor.jdk.allowed"); - - public static final String JAVA_DOWNLOAD_PAGE_PROPERTY = - "java.download.page"; - - public static final String DEFAULT_JAVA_DOWNLOAD_PAGE = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.java.download.page"); - public static final String DEFAULT_JAVA_DOWNLOAD_PAGE_MAC = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.java.download.page.mac"); - - public static final String DEFAULT_USEDBY_LABEL = - ResourceUtils.getString(JdkLocationPanel.class, - "JLP.usedby.label"); //NOI18N - public static final String USEDBY_LABEL_PROPERTY = - "usedby.label"; //NOI18N - - private static final String SUN_MICROSYSTEMS_VENDOR = - "Sun Microsystems Inc." ; //NOI18N - - private static final String JDK_PRODUCT_UID = - "jdk"; //NOI18N - - private static final String JRE_NESTED_PRODUCT_UID = - "jre-nested"; //NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/LicensesPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/LicensesPanel.java deleted file mode 100644 index 32a131475090..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/LicensesPanel.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.Color; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.LinkedList; -import java.util.List; -import javax.swing.BoundedRangeModel; -import javax.swing.JComponent; -import javax.swing.JScrollBar; -import javax.swing.border.EmptyBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.helper.swing.NbiCheckBox; -import org.netbeans.installer.utils.helper.swing.NbiScrollPane; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.utils.helper.Text; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelSwingUi; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -public class LicensesPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public LicensesPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(ACCEPT_CHECKBOX_TEXT_PROPERTY, - DEFAULT_ACCEPT_CHECKBOX_TEXT); - setProperty(ERROR_CANNOT_GET_LOGIC_PROPERTY, - DEFAULT_ERROR_CANNOT_GET_LOGIC); - setProperty(APPEND_LICENSE_FORMAT_PROPERTY, - DEFAULT_APPEND_LICENSE_FORMAT); - setProperty(SINGLE_PRODUCT_LICENSE_FORMAT_PROPERTY, - DEFAULT_SINGLE_PRODUCT_LICENSE_FORMAT); - setProperty(OVERALL_LICENSE_FORMAT_PROPERTY, - DEFAULT_OVERALL_LICENSE_FORMAT); - } - - @Override - public boolean canExecuteForward() { - List products = Registry.getInstance().getProductsToInstall(); - - boolean doShowPanel = true; - if (products.size() > 0) { - doShowPanel = System.getProperty(OVERALL_LICENSE_RESOURCE_PROPERTY) != null; - if (!doShowPanel) { - for (Product p : products) { - if (p.isLogicDownloaded()) { - try { - if (p.getLogic().getLicense() != null) { - doShowPanel = true; - } - } catch (InitializationException e) { - } - } else { - doShowPanel = true; - } - } - } - } - return products.size() > 0 && doShowPanel; - } - - @Override - public boolean canExecuteBackward() { - return canExecuteForward(); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new LicensesPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class LicensesPanelUi extends WizardPanelUi { - protected LicensesPanel component; - - public LicensesPanelUi(LicensesPanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new LicensesPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class LicensesPanelSwingUi extends WizardPanelSwingUi { - protected LicensesPanel component; - - private List acceptedProducts; - - private NbiTextPane licensePane; - private NbiScrollPane licenseScrollPane; - - private NbiCheckBox acceptCheckBox; - - public LicensesPanelSwingUi( - final LicensesPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - this.acceptedProducts = new LinkedList(); - - initComponents(); - } - - @Override - public JComponent getDefaultFocusOwner() { - return acceptCheckBox; - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initialize() { - acceptCheckBox.setText( - component.getProperty(ACCEPT_CHECKBOX_TEXT_PROPERTY)); - - final List currentProducts = - Registry.getInstance().getProductsToInstall(); - - final StringBuilder text = new StringBuilder(); - - boolean everythingAccepted = true; - - if(System.getProperty(OVERALL_LICENSE_RESOURCE_PROPERTY)!=null) { - if(acceptedProducts.size()==0) { - everythingAccepted = false; - } - final String licenseValue = SystemUtils.resolveString( - System.getProperty(OVERALL_LICENSE_RESOURCE_PROPERTY)); - final String license = SystemUtils.resolveString("$R{" + licenseValue + ";" + StringUtils.ENCODING_UTF8 + "}"); - final String format = component.getProperty(OVERALL_LICENSE_FORMAT_PROPERTY); - if(license!=null) { - text.append(StringUtils.format(format, license)); - } - } else { - final String format = (currentProducts.size() == 1) ? - component.getProperty(SINGLE_PRODUCT_LICENSE_FORMAT_PROPERTY) : - component.getProperty(APPEND_LICENSE_FORMAT_PROPERTY); - - for (Product product: currentProducts) { - if (!acceptedProducts.contains(product)) { - everythingAccepted = false; - } - try { - Text license = product.getLogic().getLicense(); - if(license!=null && license.getText()!=null) { - text.append( - StringUtils.format(format, - product.getDisplayName(), - license.getText())); - } - } catch (InitializationException e) { - ErrorManager.notifyError( - component.getProperty(ERROR_CANNOT_GET_LOGIC_PROPERTY), - e); - } - } - } - if(System.getProperty(OVERALL_LICENSE_CONTENT_TYPE_PROPERTY)!=null) { - licensePane.setContentType(System.getProperty( - OVERALL_LICENSE_CONTENT_TYPE_PROPERTY)); - } - - licensePane.setText(text); - licensePane.setCaretPosition(0); - licensePane.requestFocus(); - - licensePane.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - final int code = e.getKeyCode(); - if (code == KeyEvent.VK_SPACE || code == KeyEvent.VK_ENTER) { - BoundedRangeModel brm = licenseScrollPane.getVerticalScrollBar().getModel(); - brm.setValue(brm.getValue() + brm.getExtent()); - } else if (code == KeyEvent.VK_N || code == KeyEvent.VK_Q) { - container.getCancelButton().doClick(); - } else if (code == KeyEvent.VK_A || code == KeyEvent.VK_Y) { - if (acceptCheckBox.isEnabled()) { - acceptCheckBox.setSelected(true); - acceptCheckBoxToggled(); - } - } - } - }); - - if (System.getProperty(WHOLE_LICENSE_SCROLLING_REQUIRED) != null) { - licenseScrollPane.getVerticalScrollBar().getModel().addChangeListener(new ChangeListener() { - - public void stateChanged(ChangeEvent e) { - JScrollBar vsb = licenseScrollPane.getVerticalScrollBar(); - if (vsb.getValue() >= vsb.getMaximum() - vsb.getModel().getExtent()) { - acceptCheckBox.setEnabled(true); - } - } - }); - acceptCheckBox.setEnabled(false); - } - - if (!everythingAccepted) { - acceptCheckBox.setSelected(false); - } - acceptCheckBoxToggled(); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // licensePane ////////////////////////////////////////////////////////// - licensePane = new NbiTextPane(); - licensePane.setOpaque(true); - licensePane.setBackground(Color.WHITE); - licensePane.setBorder(new EmptyBorder(new Insets(5, 5, 5, 5))); - licensePane.setFocusable(true); - - // licenseScrollPane //////////////////////////////////////////////////// - licenseScrollPane = new NbiScrollPane(licensePane); - - // acceptCheckBox /////////////////////////////////////////////////////// - acceptCheckBox = new NbiCheckBox(); - acceptCheckBox.setSelected(false); - acceptCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - acceptCheckBoxToggled(); - } - }); - - // this ///////////////////////////////////////////////////////////////// - add(licenseScrollPane, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(acceptCheckBox, new GridBagConstraints( - 0, 2, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(7, 11, 11, 11), // padding - 0, 0)); // padx, pady - ??? - } - - private void acceptCheckBoxToggled() { - if (acceptCheckBox.isSelected()) { - for (Product product: Registry. - getInstance().getProductsToInstall()) { - if (!acceptedProducts.contains(product)) { - acceptedProducts.add(product); - } - } - - container.getNextButton().setEnabled(true); - } else { - container.getNextButton().setEnabled(false); - } - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String ACCEPT_CHECKBOX_TEXT_PROPERTY = - "accept.checkbox.text"; // NOI18N - public static final String ERROR_CANNOT_GET_LOGIC_PROPERTY = - "error.cannot.get.logic";//NOI18N - public static final String OVERALL_LICENSE_RESOURCE_PROPERTY = - "nbi.overall.license.resource";//NOI18N - public static final String OVERALL_LICENSE_CONTENT_TYPE_PROPERTY = - "nbi.overall.license.content.type";//NOI18N - public static final String APPEND_LICENSE_FORMAT_PROPERTY = - "append.license.format";//NOI18N - public static final String OVERALL_LICENSE_FORMAT_PROPERTY = - "overall.license.format";//NOI18N - public static final String SINGLE_PRODUCT_LICENSE_FORMAT_PROPERTY = - "single.product.license.format";//NOI18N - private static final String WHOLE_LICENSE_SCROLLING_REQUIRED = - "nbi.whole.license.scrolling.required"; - public static final String DEFAULT_TITLE = - ResourceUtils.getString(LicensesPanel.class, - "LP.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(LicensesPanel.class, - "LP.description"); // NOI18N - public static final String DEFAULT_APPEND_LICENSE_FORMAT = - ResourceUtils.getString(LicensesPanel.class, - "LP.append.license.format"); // NOI18N - public static final String DEFAULT_OVERALL_LICENSE_FORMAT = - ResourceUtils.getString(LicensesPanel.class, - "LP.overall.license.format"); // NOI18N - public static final String DEFAULT_SINGLE_PRODUCT_LICENSE_FORMAT = - ResourceUtils.getString(LicensesPanel.class, - "LP.single.product.license.format"); // NOI18N - public static final String DEFAULT_ACCEPT_CHECKBOX_TEXT = - ResourceUtils.getString(LicensesPanel.class, - "LP.accept.checkbox.text"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_GET_LOGIC = - ResourceUtils.getString(LicensesPanel.class, - "LP.error.cannot.get.logic"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostCreateBundleSummaryPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostCreateBundleSummaryPanel.java deleted file mode 100644 index 507d2d095aac..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostCreateBundleSummaryPanel.java +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.utils.InstallationLogDialog; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_INSTALL; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_UNINSTALL; - -/** - * - * @author Kirill Sorokin - */ -public class PostCreateBundleSummaryPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public PostCreateBundleSummaryPanel() { - setProperty(MESSAGE_SUCCESS_TEXT_PROPERTY, DEFAULT_MESSAGE_SUCCESS_TEXT); - setProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY, DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE); - setProperty(MESSAGE_ERRORS_TEXT_PROPERTY, DEFAULT_MESSAGE_ERRORS_TEXT); - setProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY, DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE); - setProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT); - setProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT); - setProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY, DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE); - setProperty(COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY, DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT); - setProperty(COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY, DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_TEXT); - setProperty(COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY, DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE); - setProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY, DEFAULT_VIEW_LOG_BUTTON_TEXT); - setProperty(SEND_LOG_BUTTON_TEXT_PROPERTY, DEFAULT_SEND_LOG_BUTTON_TEXT); - setProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY, DEFAULT_COMPONENTS_LIST_SEPARATOR); - - setProperty(TITLE_PROPERTY, DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, DEFAULT_DESCRIPTION); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PostCreateBundleSummaryPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PostCreateBundleSummaryPanelUi extends WizardPanelUi { - protected PostCreateBundleSummaryPanel component; - - public PostCreateBundleSummaryPanelUi(PostCreateBundleSummaryPanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PostCreateBundleSummaryPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class PostCreateBundleSummaryPanelSwingUi extends WizardPanelSwingUi { - protected PostCreateBundleSummaryPanel component; - - private NbiTextPane messagePane; - - private NbiLabel successfullyBundledComponentsLabel; - private NbiTextPane successfullyBundledComponentsPane; - private NbiLabel componentsFailedToBundleLabel; - private NbiTextPane componentsFailedToBundlePane; - - private NbiButton viewLogButton; - private NbiButton sendLogButton; - - private NbiPanel spacer; - - private InstallationLogDialog logDialog; - - public PostCreateBundleSummaryPanelSwingUi( - final PostCreateBundleSummaryPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - - // set up the back button - container.getBackButton().setEnabled(false); - - // set up the next (or finish) button - container.getNextButton().setText( - component.getProperty(FINISH_BUTTON_TEXT_PROPERTY)); - - // set up the cancel button - container.getCancelButton().setEnabled(false); - } - - @Override - protected void initialize() { - final Registry registry = Registry.getInstance(); - - final boolean errorsEncountered = - registry.getProducts(FAILED_TO_INSTALL).size() > 0 && - registry.getProducts(FAILED_TO_UNINSTALL).size() > 0; - - if (errorsEncountered) { - messagePane.setContentType(component.getProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY)); - messagePane.setText(component.getProperty(MESSAGE_ERRORS_TEXT_PROPERTY)); - } else { - messagePane.setContentType(component.getProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY)); - messagePane.setText(component.getProperty(MESSAGE_SUCCESS_TEXT_PROPERTY)); - } - - List components; - - components = registry.getProducts(INSTALLED_SUCCESSFULLY); - if (components.size() > 0) { - successfullyBundledComponentsLabel.setVisible(true); - successfullyBundledComponentsPane.setVisible(true); - - successfullyBundledComponentsLabel.setText(component.getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY)); - successfullyBundledComponentsPane.setContentType(component.getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY)); - successfullyBundledComponentsPane.setText(StringUtils.format(component.getProperty(SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY), StringUtils.asString(components, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - successfullyBundledComponentsLabel.setVisible(false); - successfullyBundledComponentsPane.setVisible(false); - } - - components = registry.getProducts(FAILED_TO_INSTALL); - if (components.size() > 0) { - componentsFailedToBundleLabel.setVisible(true); - componentsFailedToBundlePane.setVisible(true); - - componentsFailedToBundleLabel.setText(component.getProperty(COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY)); - componentsFailedToBundlePane.setContentType(component.getProperty(COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY)); - componentsFailedToBundlePane.setText(StringUtils.format(component.getProperty(COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY), StringUtils.asString(components, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - componentsFailedToBundleLabel.setVisible(false); - componentsFailedToBundlePane.setVisible(false); - } - - viewLogButton.setText(component.getProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY)); - sendLogButton.setText(component.getProperty(SEND_LOG_BUTTON_TEXT_PROPERTY)); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // messagePane ////////////////////////////////////////////////////////// - messagePane = new NbiTextPane(); - - // successfullyBundledComponentsPane //////////////////////////////////// - successfullyBundledComponentsPane = new NbiTextPane(); - - // successfullyBundledComponentsLabel /////////////////////////////////// - successfullyBundledComponentsLabel = new NbiLabel(); - successfullyBundledComponentsLabel.setLabelFor( - successfullyBundledComponentsPane); - - // componentsFailedToBundlePane ///////////////////////////////////////// - componentsFailedToBundlePane = new NbiTextPane(); - - // componentsFailedToBundleLabel //////////////////////////////////////// - componentsFailedToBundleLabel = new NbiLabel(); - componentsFailedToBundleLabel.setLabelFor(componentsFailedToBundlePane); - - // viewLogButton //////////////////////////////////////////////////////// - viewLogButton = new NbiButton(); - viewLogButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - viewLogButtonClicked(); - } - }); - - // sendLogButton //////////////////////////////////////////////////////// - sendLogButton = new NbiButton(); - sendLogButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - sendLogButtonClicked(); - } - }); - sendLogButton.setEnabled(false); - - // spacer /////////////////////////////////////////////////////////////// - spacer = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(messagePane, new GridBagConstraints( - 0, 0, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyBundledComponentsLabel, new GridBagConstraints( - 0, 1, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyBundledComponentsPane, new GridBagConstraints( - 0, 2, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToBundleLabel, new GridBagConstraints( - 0, 3, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToBundlePane, new GridBagConstraints( - 0, 4, // x, y - 2, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacer, new GridBagConstraints( - 0, 5, // x, y - 2, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(viewLogButton, new GridBagConstraints( - 0, 6, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(3, 11, 11, 0), // padding - 0, 0)); // padx, pady - ??? - add(sendLogButton, new GridBagConstraints( - 1, 6, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.WEST, // anchor - GridBagConstraints.NONE, // fill - new Insets(3, 6, 11, 11), // padding - 0, 0)); // padx, pady - ??? - } - - private void viewLogButtonClicked() { - if (LogManager.getLogFile() != null) { - if (logDialog == null) { - logDialog = new InstallationLogDialog(); - } - logDialog.setVisible(true); - logDialog.loadLogFile(); - } else { - ErrorManager.notifyError("Log file is not available."); - } - } - - private void sendLogButtonClicked() { - // does nothing - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String MESSAGE_SUCCESS_TEXT_PROPERTY = - "message.success.text"; // NOI18N - public static final String MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY = - "message.success.content.type"; // NOI18N - public static final String MESSAGE_ERRORS_TEXT_PROPERTY = - "message.errors.text"; // NOI18N - public static final String MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY = - "message.errors.content.type"; // NOI18N - public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT_PROPERTY = - "successfully.bundled.components.label.text"; // NOI18N - public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT_PROPERTY = - "successfully.bundled.components.text"; // NOI18N - public static final String SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE_PROPERTY = - "successfully.bundled.components.content.type"; // NOI18N - public static final String COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT_PROPERTY = - "components.failed.to.bundle.label.text"; // NOI18N - public static final String COMPONENTS_FAILED_TO_BUNDLE_TEXT_PROPERTY = - "components.failed.to.bundle.text"; // NOI18N - public static final String COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE_PROPERTY = - "components.failed.to.bundle.content.type"; // NOI18N - public static final String VIEW_LOG_BUTTON_TEXT_PROPERTY = - "view.log.button.text"; // NOI18N - public static final String SEND_LOG_BUTTON_TEXT_PROPERTY = - "send.log.button.text"; // NOI18N - public static final String COMPONENTS_LIST_SEPARATOR_PROPERTY = - "components.list.separator"; // NOI18N - - public static final String DEFAULT_MESSAGE_SUCCESS_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.message.success.text"); // NOI18N - public static final String DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.message.success.content.type"); // NOI18N - public static final String DEFAULT_MESSAGE_ERRORS_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.message.errors.text"); // NOI18N - public static final String DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.message.errors.content.type"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_LABEL_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.successfully.bundled.components.label.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.successfully.bundled.components.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_BUNDLED_COMPONENTS_CONTENT_TYPE = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.successfully.bundled.components.content.type"); // NOI18N - public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_LABEL_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.components.failed.to.bundle.label.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.components.failed.to.bundle.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_FAILED_TO_BUNDLE_CONTENT_TYPE = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.components.failed.to.bundle.content.type"); // NOI18N - public static final String DEFAULT_VIEW_LOG_BUTTON_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.view.log.button.text"); // NOI18N - public static final String DEFAULT_SEND_LOG_BUTTON_TEXT = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.send.log.button.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_LIST_SEPARATOR = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.components.list.separator"); // NOI18N - - public static final String DEFAULT_TITLE = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.dialog.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(PostCreateBundleSummaryPanel.class, - "PoCBSP.dialog.description"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostInstallSummaryPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostInstallSummaryPanel.java deleted file mode 100644 index 2f70be7dc108..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PostInstallSummaryPanel.java +++ /dev/null @@ -1,748 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelSwingUi; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; -import org.netbeans.installer.wizard.containers.SwingFrameContainer; -import org.netbeans.installer.wizard.utils.InstallationDetailsDialog; -import org.netbeans.installer.wizard.utils.InstallationLogDialog; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.INSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_INSTALL; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_SUCCESSFULLY; -import static org.netbeans.installer.utils.helper.DetailedStatus.UNINSTALLED_WITH_WARNINGS; -import static org.netbeans.installer.utils.helper.DetailedStatus.FAILED_TO_UNINSTALL; - -/** - * - * @author Kirill Sorokin - */ -public class PostInstallSummaryPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public PostInstallSummaryPanel() { - setProperty(MESSAGE_SUCCESS_TEXT_PROPERTY, DEFAULT_MESSAGE_SUCCESS_TEXT); - setProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY, DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE); - setProperty(MESSAGE_WARNINGS_TEXT_PROPERTY, DEFAULT_MESSAGE_WARNINGS_TEXT); - setProperty(MESSAGE_WARNINGS_CONTENT_TYPE_PROPERTY, DEFAULT_MESSAGE_WARNINGS_CONTENT_TYPE); - setProperty(MESSAGE_ERRORS_TEXT_PROPERTY, DEFAULT_MESSAGE_ERRORS_TEXT); - setProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY, DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE); - setProperty(SUCCESSFULLY_INSTALLED_LABEL_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_INSTALLED_LABEL_TEXT); - setProperty(SUCCESSFULLY_INSTALLED_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_INSTALLED_TEXT); - setProperty(SUCCESSFULLY_INSTALLED_CONTENT_TYPE_PROPERTY, DEFAULT_SUCCESSFULLY_INSTALLED_CONTENT_TYPE); - setProperty(INSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY, DEFAULT_INSTALLED_WITH_WARNINGS_LABEL_TEXT); - setProperty(INSTALLED_WITH_WARNINGS_TEXT_PROPERTY, DEFAULT_INSTALLED_WITH_WARNINGS_TEXT); - setProperty(INSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY, DEFAULT_INSTALLED_WITH_WARNINGS_CONTENT_TYPE); - setProperty(FAILED_TO_INSTALL_WARNINGS_LABEL_TEXT_PROPERTY, DEFAULT_FAILED_TO_INSTALL_WARNINGS_LABEL_TEXT); - setProperty(FAILED_TO_INSTALL_TEXT_PROPERTY, DEFAULT_FAILED_TO_INSTALL_TEXT); - setProperty(FAILED_TO_INSTALL_CONTENT_TYPE_PROPERTY, DEFAULT_FAILED_TO_INSTALL_CONTENT_TYPE); - setProperty(SUCCESSFULLY_UNINSTALLED_LABEL_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_UNINSTALLED_LABEL_TEXT); - setProperty(SUCCESSFULLY_UNINSTALLED_TEXT_PROPERTY, DEFAULT_SUCCESSFULLY_UNINSTALLED_TEXT); - setProperty(SUCCESSFULLY_UNINSTALLED_CONTENT_TYPE_PROPERTY, DEFAULT_SUCCESSFULLY_UNINSTALLED_CONTENT_TYPE); - setProperty(UNINSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY, DEFAULT_UNINSTALLED_WITH_WARNINGS_LABEL_TEXT); - setProperty(UNINSTALLED_WITH_WARNINGS_TEXT_PROPERTY, DEFAULT_UNINSTALLED_WITH_WARNINGS_TEXT); - setProperty(UNINSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY, DEFAULT_UNINSTALLED_WITH_WARNINGS_CONTENT_TYPE); - setProperty(FAILED_TO_UNINSTALL_WARNINGS_LABEL_TEXT_PROPERTY, DEFAULT_FAILED_TO_UNINSTALL_WARNINGS_LABEL_TEXT); - setProperty(FAILED_TO_UNINSTALL_TEXT_PROPERTY, DEFAULT_FAILED_TO_UNINSTALL_TEXT); - setProperty(FAILED_TO_UNINSTALL_CONTENT_TYPE_PROPERTY, DEFAULT_FAILED_TO_UNINSTALL_CONTENT_TYPE); - setProperty(MESSAGE_FILES_REMAINING_PROPERTY, DEFAULT_MESSAGE_FILES_REMAINING); - setProperty(VIEW_DETAILS_BUTTON_TEXT_PROPERTY, DEFAULT_VIEW_DETAILS_BUTTON_TEXT); - setProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY, DEFAULT_VIEW_LOG_BUTTON_TEXT); - setProperty(SEND_LOG_BUTTON_TEXT_PROPERTY, DEFAULT_SEND_LOG_BUTTON_TEXT); - setProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY, DEFAULT_COMPONENTS_LIST_SEPARATOR); - setProperty(ERROR_LOGFILE_UNAVAILABLE_PROPERTY, DEFAULT_ERROR_LOGFILE_UNAVAILABLE_TEXT); - - setProperty(TITLE_PROPERTY, DEFAULT_DIALOG_TITLE); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PostInstallSummaryPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PostInstallSummaryPanelUi extends WizardPanelUi { - protected PostInstallSummaryPanel component; - - public PostInstallSummaryPanelUi(PostInstallSummaryPanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PostInstallSummaryPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class PostInstallSummaryPanelSwingUi extends WizardPanelSwingUi { - protected PostInstallSummaryPanel component; - - private NbiTextPane messagePane; - - private NbiLabel successfullyInstalledComponentsLabel; - private NbiTextPane successfullyInstalledComponentsPane; - private NbiLabel componentsInstalledWithWarningsLabel; - private NbiTextPane componentsInstalledWithWarningsPane; - private NbiLabel componentsFailedToInstallLabel; - private NbiTextPane componentsFailedToInstallPane; - - private NbiLabel successfullyUninstalledComponentsLabel; - private NbiTextPane successfullyUninstalledComponentsPane; - private NbiLabel componentsUninstalledWithWarningsLabel; - private NbiTextPane componentsUninstalledWithWarningsPane; - private NbiLabel componentsFailedToUninstallLabel; - private NbiTextPane componentsFailedToUninstallPane; - - private NbiButton viewDetailsButton; - private NbiButton viewLogButton; - private NbiButton sendLogButton; - - private NbiPanel spacer; - - private InstallationDetailsDialog detailsDialog; - private InstallationLogDialog logDialog; - - public PostInstallSummaryPanelSwingUi( - final PostInstallSummaryPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - - // set up the back button - container.getBackButton().setEnabled(false); - - // set up the next (or finish) button - container.getNextButton().setText( - component.getProperty(FINISH_BUTTON_TEXT_PROPERTY)); - - // set up the cancel button - container.getCancelButton().setEnabled(false); - } - - @Override - protected void initialize() { - final Registry registry = Registry.getInstance(); - - final boolean errorsEncountered = - registry.getProducts(FAILED_TO_INSTALL).size() > 0 && - registry.getProducts(FAILED_TO_UNINSTALL).size() > 0; - final boolean warningsEncountered = - registry.getProducts(INSTALLED_WITH_WARNINGS).size() > 0 && - registry.getProducts(UNINSTALLED_WITH_WARNINGS).size() > 0; - - if (errorsEncountered) { - messagePane.setContentType(component.getProperty(MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY)); - messagePane.setText(component.getProperty(MESSAGE_ERRORS_TEXT_PROPERTY)); - } else if (warningsEncountered) { - messagePane.setContentType(component.getProperty(MESSAGE_WARNINGS_CONTENT_TYPE_PROPERTY)); - messagePane.setText(component.getProperty(MESSAGE_WARNINGS_TEXT_PROPERTY)); - } else { - messagePane.setContentType(component.getProperty(MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY)); - messagePane.setText(component.getProperty(MESSAGE_SUCCESS_TEXT_PROPERTY)); - } - - List products; - - products = registry.getProducts(INSTALLED_SUCCESSFULLY); - if (products.size() > 0) { - successfullyInstalledComponentsLabel.setVisible(true); - successfullyInstalledComponentsPane.setVisible(true); - - successfullyInstalledComponentsLabel.setText(component.getProperty(SUCCESSFULLY_INSTALLED_LABEL_TEXT_PROPERTY)); - successfullyInstalledComponentsPane.setContentType(component.getProperty(SUCCESSFULLY_INSTALLED_CONTENT_TYPE_PROPERTY)); - successfullyInstalledComponentsPane.setText(StringUtils.format(component.getProperty(SUCCESSFULLY_INSTALLED_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - successfullyInstalledComponentsLabel.setVisible(false); - successfullyInstalledComponentsPane.setVisible(false); - } - - products = registry.getProducts(INSTALLED_WITH_WARNINGS); - if (products.size() > 0) { - componentsInstalledWithWarningsLabel.setVisible(true); - componentsInstalledWithWarningsPane.setVisible(true); - - componentsInstalledWithWarningsLabel.setText(component.getProperty(INSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY)); - componentsInstalledWithWarningsPane.setContentType(component.getProperty(INSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY)); - componentsInstalledWithWarningsPane.setText(StringUtils.format(component.getProperty(INSTALLED_WITH_WARNINGS_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - componentsInstalledWithWarningsLabel.setVisible(false); - componentsInstalledWithWarningsPane.setVisible(false); - } - - products = registry.getProducts(FAILED_TO_INSTALL); - if (products.size() > 0) { - componentsFailedToInstallLabel.setVisible(true); - componentsFailedToInstallPane.setVisible(true); - - componentsFailedToInstallLabel.setText(component.getProperty(FAILED_TO_INSTALL_WARNINGS_LABEL_TEXT_PROPERTY)); - componentsFailedToInstallPane.setContentType(component.getProperty(FAILED_TO_INSTALL_CONTENT_TYPE_PROPERTY)); - componentsFailedToInstallPane.setText(StringUtils.format(component.getProperty(FAILED_TO_INSTALL_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - componentsFailedToInstallLabel.setVisible(false); - componentsFailedToInstallPane.setVisible(false); - } - - products = registry.getProducts(UNINSTALLED_SUCCESSFULLY); - if (products.size() > 0) { - successfullyUninstalledComponentsLabel.setVisible(true); - successfullyUninstalledComponentsPane.setVisible(true); - - successfullyUninstalledComponentsLabel.setText(component.getProperty(SUCCESSFULLY_UNINSTALLED_LABEL_TEXT_PROPERTY)); - successfullyUninstalledComponentsPane.setContentType(component.getProperty(SUCCESSFULLY_UNINSTALLED_CONTENT_TYPE_PROPERTY)); - successfullyUninstalledComponentsPane.setText(StringUtils.format(component.getProperty(SUCCESSFULLY_UNINSTALLED_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - successfullyUninstalledComponentsLabel.setVisible(false); - successfullyUninstalledComponentsPane.setVisible(false); - } - - List notCompletelyRemoved = new LinkedList(); - for (Product product: products) { - if (!FileUtils.isEmpty(product.getInstallationLocation())) { - notCompletelyRemoved.add(product); - } - } - - if (notCompletelyRemoved.size() > 0) { - final String text = successfullyUninstalledComponentsPane.getText(); - successfullyUninstalledComponentsPane.setText(text + StringUtils.format( - component.getProperty(MESSAGE_FILES_REMAINING_PROPERTY), - StringUtils.asString(notCompletelyRemoved))); - } - - products = registry.getProducts(UNINSTALLED_WITH_WARNINGS); - if (products.size() > 0) { - componentsUninstalledWithWarningsLabel.setVisible(true); - componentsUninstalledWithWarningsPane.setVisible(true); - - componentsUninstalledWithWarningsLabel.setText(component.getProperty(UNINSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY)); - componentsUninstalledWithWarningsPane.setContentType(component.getProperty(UNINSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY)); - componentsUninstalledWithWarningsPane.setText(StringUtils.format(component.getProperty(UNINSTALLED_WITH_WARNINGS_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - componentsUninstalledWithWarningsLabel.setVisible(false); - componentsUninstalledWithWarningsPane.setVisible(false); - } - - notCompletelyRemoved = new LinkedList(); - for (Product product: products) { - if (!FileUtils.isEmpty(product.getInstallationLocation())) { - notCompletelyRemoved.add(product); - } - } - - if (notCompletelyRemoved.size() > 0) { - final String text = componentsUninstalledWithWarningsPane.getText(); - componentsUninstalledWithWarningsPane.setText(text + StringUtils.format( - component.getProperty(MESSAGE_FILES_REMAINING_PROPERTY), - StringUtils.asString(notCompletelyRemoved))); - } - - products = registry.getProducts(FAILED_TO_UNINSTALL); - if (products.size() > 0) { - componentsFailedToUninstallLabel.setVisible(true); - componentsFailedToUninstallPane.setVisible(true); - - componentsFailedToUninstallLabel.setText(component.getProperty(FAILED_TO_UNINSTALL_WARNINGS_LABEL_TEXT_PROPERTY)); - componentsFailedToUninstallPane.setContentType(component.getProperty(FAILED_TO_UNINSTALL_CONTENT_TYPE_PROPERTY)); - componentsFailedToUninstallPane.setText(StringUtils.format(component.getProperty(FAILED_TO_UNINSTALL_TEXT_PROPERTY), StringUtils.asString(products, component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY)))); - } else { - componentsFailedToUninstallLabel.setVisible(false); - componentsFailedToUninstallPane.setVisible(false); - } - - final String viewDetailsButtonText = component.getProperty(VIEW_DETAILS_BUTTON_TEXT_PROPERTY); - viewDetailsButton.setText(StringUtils.stripMnemonic(viewDetailsButtonText)); - viewDetailsButton.setMnemonic(StringUtils.fetchMnemonic(viewDetailsButtonText)); - - final String viewLogButtonText = component.getProperty(VIEW_LOG_BUTTON_TEXT_PROPERTY); - viewLogButton.setText(StringUtils.stripMnemonic(viewLogButtonText)); - viewLogButton.setMnemonic(StringUtils.fetchMnemonic(viewLogButtonText)); - - final String sendLogButtonText = component.getProperty(SEND_LOG_BUTTON_TEXT_PROPERTY); - sendLogButton.setText(StringUtils.stripMnemonic(sendLogButtonText)); - sendLogButton.setMnemonic(StringUtils.fetchMnemonic(sendLogButtonText)); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // messagePane ////////////////////////////////////////////////////////// - messagePane = new NbiTextPane(); - - // successfullyInstalledComponentsPane ////////////////////////////////// - successfullyInstalledComponentsPane = new NbiTextPane(); - - // successfullyInstalledComponentsLabel ///////////////////////////////// - successfullyInstalledComponentsLabel = new NbiLabel(); - successfullyInstalledComponentsLabel.setLabelFor( - successfullyInstalledComponentsPane); - - // componentsInstalledWithWarningsPane ////////////////////////////////// - componentsInstalledWithWarningsPane = new NbiTextPane(); - - // componentsInstalledWithWarningsLabel ///////////////////////////////// - componentsInstalledWithWarningsLabel = new NbiLabel(); - componentsInstalledWithWarningsLabel.setLabelFor( - componentsInstalledWithWarningsPane); - - // componentsFailedToInstallPane //////////////////////////////////////// - componentsFailedToInstallPane = new NbiTextPane(); - - // componentsFailedToInstallLabel /////////////////////////////////////// - componentsFailedToInstallLabel = new NbiLabel(); - componentsFailedToInstallLabel.setLabelFor( - componentsFailedToInstallPane); - - // successfullyUninstalledComponentsPane //////////////////////////////// - successfullyUninstalledComponentsPane = new NbiTextPane(); - - // successfullyUninstalledComponentsLabel /////////////////////////////// - successfullyUninstalledComponentsLabel = new NbiLabel(); - successfullyUninstalledComponentsLabel.setLabelFor( - successfullyUninstalledComponentsPane); - - // componentsUninstalledWithWarningsPane //////////////////////////////// - componentsUninstalledWithWarningsPane = new NbiTextPane(); - - // componentsUninstalledWithWarningsLabel /////////////////////////////// - componentsUninstalledWithWarningsLabel = new NbiLabel(); - componentsUninstalledWithWarningsLabel.setLabelFor( - componentsUninstalledWithWarningsPane); - - // componentsFailedToUninstallPane ////////////////////////////////////// - componentsFailedToUninstallPane = new NbiTextPane(); - - // componentsFailedToUninstallLabel ///////////////////////////////////// - componentsFailedToUninstallLabel = new NbiLabel(); - componentsFailedToUninstallLabel.setLabelFor( - componentsFailedToUninstallPane); - - // viewDetailsButton //////////////////////////////////////////////////// - viewDetailsButton = new NbiButton(); - viewDetailsButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - viewDetailsButtonClicked(); - } - }); - - // viewLogButton //////////////////////////////////////////////////////// - viewLogButton = new NbiButton(); - viewLogButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - viewLogButtonClicked(); - } - }); - - // sendLogButton //////////////////////////////////////////////////////// - sendLogButton = new NbiButton(); - sendLogButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - sendLogButtonClicked(); - } - }); - sendLogButton.setEnabled(false); - - // spacer /////////////////////////////////////////////////////////////// - spacer = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(messagePane, new GridBagConstraints( - 0, 0, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyInstalledComponentsLabel, new GridBagConstraints( - 0, 1, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyInstalledComponentsPane, new GridBagConstraints( - 0, 2, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsInstalledWithWarningsLabel, new GridBagConstraints( - 0, 3, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsInstalledWithWarningsPane, new GridBagConstraints( - 0, 4, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToInstallLabel, new GridBagConstraints( - 0, 5, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToInstallPane, new GridBagConstraints( - 0, 6, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyUninstalledComponentsLabel, new GridBagConstraints( - 0, 7, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(successfullyUninstalledComponentsPane, new GridBagConstraints( - 0, 8, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsUninstalledWithWarningsLabel, new GridBagConstraints( - 0, 9, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsUninstalledWithWarningsPane, new GridBagConstraints( - 0, 10, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToUninstallLabel, new GridBagConstraints( - 0, 11, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsFailedToUninstallPane, new GridBagConstraints( - 0, 12, // x, y - 3, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacer, new GridBagConstraints( - 0, 13, // x, y - 3, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(viewDetailsButton, new GridBagConstraints( - 0, 14, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(3, 11, 11, 0), // padding - 0, 0)); // padx, pady - ??? - add(viewLogButton, new GridBagConstraints( - 1, 14, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(3, 6, 11, 0), // padding - 0, 0)); // padx, pady - ??? - add(sendLogButton, new GridBagConstraints( - 2, 14, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.WEST, // anchor - GridBagConstraints.NONE, // fill - new Insets(3, 6, 11, 11), // padding - 0, 0)); // padx, pady - ??? - if(container instanceof SwingFrameContainer) { - final SwingFrameContainer sfc = (SwingFrameContainer) container; - sfc.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent event) { - SwingUi currentUi = component.getWizardUi().getSwingUi(container); - if (currentUi != null) { - if (!container.getCancelButton().isEnabled() && // cancel button is disabled - !container.getCancelButton().isVisible() && // no cancel button at this panel - !container.getBackButton().isVisible() && // no back button at this panel - container.getNextButton().isVisible() && // next button is visible - container.getNextButton().isEnabled()) { // and enabled - currentUi.evaluateNextButtonClick(); - sfc.removeWindowListener(this); - } - } - } - }); - } - } - - private void viewDetailsButtonClicked() { - if (detailsDialog == null) { - detailsDialog = new InstallationDetailsDialog(); - } - detailsDialog.setVisible(true); - } - - private void viewLogButtonClicked() { - if (LogManager.getLogFile() != null) { - if (logDialog == null) { - logDialog = new InstallationLogDialog(); - } - logDialog.setVisible(true); - logDialog.loadLogFile(); - } else { - ErrorManager.notify(ErrorLevel.ERROR, - component.getProperty(ERROR_LOGFILE_UNAVAILABLE_PROPERTY)); - } - } - - private void sendLogButtonClicked() { - // does nothing - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String MESSAGE_SUCCESS_TEXT_PROPERTY = - "message.success.text"; // NOI18N - public static final String MESSAGE_SUCCESS_CONTENT_TYPE_PROPERTY = - "message.success.content.type"; // NOI18N - public static final String MESSAGE_WARNINGS_TEXT_PROPERTY = - "message.warnings.text"; // NOI18N - public static final String MESSAGE_WARNINGS_CONTENT_TYPE_PROPERTY = - "message.warnings.content.type"; // NOI18N - public static final String MESSAGE_ERRORS_TEXT_PROPERTY = - "message.errors.text"; // NOI18N - public static final String MESSAGE_ERRORS_CONTENT_TYPE_PROPERTY = - "message.errors.content.type"; // NOI18N - public static final String SUCCESSFULLY_INSTALLED_LABEL_TEXT_PROPERTY = - "successfully.installed.label.text"; // NOI18N - public static final String SUCCESSFULLY_INSTALLED_TEXT_PROPERTY = - "successfully.installed.text"; // NOI18N - public static final String SUCCESSFULLY_INSTALLED_CONTENT_TYPE_PROPERTY = - "successfully.installed.content.type"; // NOI18N - public static final String INSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY = - "installed.with.warnings.label.text"; // NOI18N - public static final String INSTALLED_WITH_WARNINGS_TEXT_PROPERTY = - "installed.with.warnings.text"; // NOI18N - public static final String INSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY = - "installed.with.warnings.content.type"; // NOI18N - public static final String FAILED_TO_INSTALL_WARNINGS_LABEL_TEXT_PROPERTY = - "failed.to.install.label.text"; // NOI18N - public static final String FAILED_TO_INSTALL_TEXT_PROPERTY = - "failed.to.install.text"; // NOI18N - public static final String FAILED_TO_INSTALL_CONTENT_TYPE_PROPERTY = - "failed.to.install.content.type"; // NOI18N - public static final String SUCCESSFULLY_UNINSTALLED_LABEL_TEXT_PROPERTY = - "successfully.uninstalled.label.text"; // NOI18N - public static final String SUCCESSFULLY_UNINSTALLED_TEXT_PROPERTY = - "successfully.uninstalled.text"; // NOI18N - public static final String SUCCESSFULLY_UNINSTALLED_CONTENT_TYPE_PROPERTY = - "successfully.uninstalled.content.type"; // NOI18N - public static final String UNINSTALLED_WITH_WARNINGS_LABEL_TEXT_PROPERTY = - "uninstalled.with.warnings.label.text"; // NOI18N - public static final String UNINSTALLED_WITH_WARNINGS_TEXT_PROPERTY = - "uninstalled.with.warnings.text"; // NOI18N - public static final String UNINSTALLED_WITH_WARNINGS_CONTENT_TYPE_PROPERTY = - "uninstalled.with.warnings.content.type"; // NOI18N - public static final String FAILED_TO_UNINSTALL_WARNINGS_LABEL_TEXT_PROPERTY = - "failed.to.uninstall.label.text"; // NOI18N - public static final String FAILED_TO_UNINSTALL_TEXT_PROPERTY = - "failed.to.uninstall.text"; // NOI18N - public static final String FAILED_TO_UNINSTALL_CONTENT_TYPE_PROPERTY = - "failed.to.uninstall.content.type"; // NOI18N - public static final String MESSAGE_FILES_REMAINING_PROPERTY = - "message.files.remaining"; // NOI18N - public static final String VIEW_DETAILS_BUTTON_TEXT_PROPERTY = - "view.details.button.text"; // NOI18N - public static final String VIEW_LOG_BUTTON_TEXT_PROPERTY = - "view.log.button.text"; // NOI18N - public static final String SEND_LOG_BUTTON_TEXT_PROPERTY = - "send.log.button.text"; // NOI18N - public static final String COMPONENTS_LIST_SEPARATOR_PROPERTY = - "components.list.separator"; // NOI18N - public static final String ERROR_LOGFILE_UNAVAILABLE_PROPERTY = - "error.logfile.unavailable";//NOI18N - - public static final String DEFAULT_MESSAGE_SUCCESS_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.success.text"); // NOI18N - public static final String DEFAULT_MESSAGE_SUCCESS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.success.content.type"); // NOI18N - public static final String DEFAULT_MESSAGE_WARNINGS_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.warnings.text"); // NOI18N - public static final String DEFAULT_MESSAGE_WARNINGS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.warnings.content.type"); // NOI18N - public static final String DEFAULT_MESSAGE_ERRORS_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.errors.text"); // NOI18N - public static final String DEFAULT_MESSAGE_ERRORS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.errors.content.type"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_INSTALLED_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.installed.label.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_INSTALLED_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.installed.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_INSTALLED_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.installed.content.type"); // NOI18N - public static final String DEFAULT_INSTALLED_WITH_WARNINGS_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.installed.with.warnings.label.text"); // NOI18N - public static final String DEFAULT_INSTALLED_WITH_WARNINGS_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.installed.with.warnings.text"); // NOI18N - public static final String DEFAULT_INSTALLED_WITH_WARNINGS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.installed.with.warnings.content.type"); // NOI18N - public static final String DEFAULT_FAILED_TO_INSTALL_WARNINGS_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.install.label.text"); // NOI18N - public static final String DEFAULT_FAILED_TO_INSTALL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.install.text"); // NOI18N - public static final String DEFAULT_FAILED_TO_INSTALL_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.install.content.type"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_UNINSTALLED_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.uninstalled.label.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_UNINSTALLED_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.uninstalled.text"); // NOI18N - public static final String DEFAULT_SUCCESSFULLY_UNINSTALLED_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.successfully.uninstalled.content.type"); // NOI18N - public static final String DEFAULT_UNINSTALLED_WITH_WARNINGS_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.uninstalled.with.warnings.label.text"); // NOI18N - public static final String DEFAULT_UNINSTALLED_WITH_WARNINGS_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.uninstalled.with.warnings.text"); // NOI18N - public static final String DEFAULT_UNINSTALLED_WITH_WARNINGS_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.uninstalled.with.warnings.content.type"); // NOI18N - public static final String DEFAULT_FAILED_TO_UNINSTALL_WARNINGS_LABEL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.uninstall.label.text"); // NOI18N - public static final String DEFAULT_FAILED_TO_UNINSTALL_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.uninstall.text"); // NOI18N - public static final String DEFAULT_FAILED_TO_UNINSTALL_CONTENT_TYPE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.failed.to.uninstall.content.type"); // NOI18N - public static final String DEFAULT_MESSAGE_FILES_REMAINING = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.message.files.remaining"); // NOI18N - public static final String DEFAULT_VIEW_DETAILS_BUTTON_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.view.details.button.text"); // NOI18N - public static final String DEFAULT_VIEW_LOG_BUTTON_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.view.log.button.text"); // NOI18N - public static final String DEFAULT_SEND_LOG_BUTTON_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.send.log.button.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_LIST_SEPARATOR = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.components.list.separator"); // NOI18N - public static final String DEFAULT_ERROR_LOGFILE_UNAVAILABLE_TEXT = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.error.logfile.unavailable");//NOI18N - - public static final String DEFAULT_DIALOG_TITLE = - ResourceUtils.getString(PostInstallSummaryPanel.class, - "PoISP.dialog.title"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreCreateBundleSummaryPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreCreateBundleSummaryPanel.java deleted file mode 100644 index 7a15bd46c539..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreCreateBundleSummaryPanel.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.util.List; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelSwingUi; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * - * @author Kirill Sorokin - */ -public class PreCreateBundleSummaryPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public PreCreateBundleSummaryPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - setProperty(DESCRIPTION_PROPERTY, - DEFAULT_DESCRIPTION); - - setProperty(MESSAGE_TEXT_PROPERTY, - DEFAULT_MESSAGE_TEXT); - setProperty(MESSAGE_CONTENT_TYPE_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE); - setProperty(COMPONENTS_TO_BUNDLE_LABEL_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_BUNDLE_LABEL_TEXT); - setProperty(COMPONENTS_TO_BUNDLE_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_BUNDLE_TEXT); - setProperty(COMPONENTS_TO_BUNDLE_CONTENT_TYPE_PROPERTY, - DEFAULT_COMPONENTS_TO_BUNDLE_CONTENT_TYPE); - setProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY, - DEFAULT_COMPONENTS_LIST_SEPARATOR); - setProperty(DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY, - DEFAULT_DOWNLOAD_SIZE_LABEL_TEXT); - setProperty(REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY, - DEFAULT_REQUIRED_DISK_SPACE_LABEL_TEXT); - setProperty(CREATE_BUTTON_TEXT_PROPERTY, - DEFAULT_CREATE_BUTTON_TEXT); - } - - @Override - public boolean canExecuteForward() { - return Registry.getInstance().getProductsToInstall().size() > 0; - } - - @Override - public boolean canExecuteBackward() { - return Registry.getInstance().getProductsToInstall().size() > 0; - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PreCreateBundleSummaryPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PreCreateBundleSummaryPanelUi extends WizardPanelUi { - protected PreCreateBundleSummaryPanel component; - - public PreCreateBundleSummaryPanelUi(PreCreateBundleSummaryPanel component) { - super(component); - - this.component = component; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PreCreateBundleSummaryPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class PreCreateBundleSummaryPanelSwingUi extends WizardPanelSwingUi { - protected PreCreateBundleSummaryPanel component; - - private NbiTextPane messagePane; - private NbiLabel componentsToBundleLabel; - private NbiTextPane componentsToBundlePane; - private NbiLabel downloadSizeLabel; - private NbiLabel requiredDiskSpaceLabel; - - private NbiPanel spacer; - - public PreCreateBundleSummaryPanelSwingUi( - final PreCreateBundleSummaryPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - container.getNextButton().setText( - component.getProperty(CREATE_BUTTON_TEXT_PROPERTY)); - } - - @Override - protected void initialize() { - final String messageContentType = component.getProperty(MESSAGE_CONTENT_TYPE_PROPERTY); - messagePane.setContentType(messageContentType); - - final String messageText = component.getProperty(MESSAGE_TEXT_PROPERTY); - messagePane.setText(messageText); - - List componentsToBundle = Registry.getInstance().getProductsToInstall(); - - componentsToBundleLabel.setVisible(true); - componentsToBundlePane.setVisible(true); - downloadSizeLabel.setVisible(true); - requiredDiskSpaceLabel.setVisible(true); - - final String componentsToInstallLabelText = component.getProperty( - COMPONENTS_TO_BUNDLE_LABEL_TEXT_PROPERTY); - componentsToBundleLabel.setText(componentsToInstallLabelText); - - final String componentsToInstallContentType = component.getProperty( - COMPONENTS_TO_BUNDLE_CONTENT_TYPE_PROPERTY); - componentsToBundlePane.setContentType(componentsToInstallContentType); - - final String componentsToInstallText = StringUtils.format( - component.getProperty(COMPONENTS_TO_BUNDLE_TEXT_PROPERTY), - StringUtils.asString(componentsToBundle, - component.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY))); - componentsToBundlePane.setText(componentsToInstallText); - - long downloadSize = 0; - for (Product component: componentsToBundle) { - downloadSize += component.getDownloadSize(); - } - - long requiredDiskSpace = 0; - for (Product component: componentsToBundle) { - requiredDiskSpace += component.getRequiredDiskSpace(); - } - - final String downloadSizeLabelText = StringUtils.format( - component.getProperty(DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY), - StringUtils.formatSize(downloadSize)); - downloadSizeLabel.setText(downloadSizeLabelText); - - final String requiredDiskSpaceLabelText = StringUtils.format( - component.getProperty(REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY), - StringUtils.formatSize(requiredDiskSpace)); - requiredDiskSpaceLabel.setText(requiredDiskSpaceLabelText); - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // messagePane ////////////////////////////////////////////////////////// - messagePane = new NbiTextPane(); - - // componentsToBundlePane /////////////////////////////////////////////// - componentsToBundlePane = new NbiTextPane(); - - // componentsToBundleLabel ////////////////////////////////////////////// - componentsToBundleLabel = new NbiLabel(); - componentsToBundleLabel.setLabelFor(componentsToBundlePane); - - // downloadSizeLabel //////////////////////////////////////////////////// - downloadSizeLabel = new NbiLabel(); - //downloadSizeLabel.setFocusable(true); - - // requiredDiskSpaceLabel /////////////////////////////////////////////// - requiredDiskSpaceLabel = new NbiLabel(); - //requiredDiskSpaceLabel.setFocusable(true); - - // spacer /////////////////////////////////////////////////////////////// - spacer = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(messagePane, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToBundleLabel, new GridBagConstraints( - 0, 2, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToBundlePane, new GridBagConstraints( - 0, 3, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(downloadSizeLabel, new GridBagConstraints( - 0, 4, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(25, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(requiredDiskSpaceLabel, new GridBagConstraints( - 0, 5, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacer, new GridBagConstraints( - 0, 6, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 11, 11), // padding - 0, 0)); // padx, pady - ??? - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String MESSAGE_TEXT_PROPERTY = - "message.text"; // NOI18N - public static final String MESSAGE_CONTENT_TYPE_PROPERTY = - "message.content.type"; // NOI18N - public static final String COMPONENTS_TO_BUNDLE_LABEL_TEXT_PROPERTY = - "components.to.bundle.label.text"; // NOI18N - public static final String COMPONENTS_TO_BUNDLE_TEXT_PROPERTY = - "components.to.bundle.text"; // NOI18N - public static final String COMPONENTS_TO_BUNDLE_CONTENT_TYPE_PROPERTY = - "components.to.bundle.content.type"; // NOI18N - public static final String COMPONENTS_LIST_SEPARATOR_PROPERTY = - "components.list.separator"; // NOI18N - public static final String DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY = - "download.size.label.text"; // NOI18N - public static final String REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY = - "required.disk.space.label.text"; // NOI18N - public static final String CREATE_BUTTON_TEXT_PROPERTY = - "create.button.text"; // NOI18N - - public static final String DEFAULT_MESSAGE_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPmessage.text"); // NOI18N - public static final String DEFAULT_MESSAGE_CONTENT_TYPE = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPmessage.content.type"); // NOI18N - public static final String DEFAULT_COMPONENTS_TO_BUNDLE_LABEL_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPcomponents.to.bundle.label.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_TO_BUNDLE_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPcomponents.to.bundle.text"); // NOI18N - public static final String DEFAULT_COMPONENTS_TO_BUNDLE_CONTENT_TYPE = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPcomponents.to.bundle.content.type"); // NOI18N - public static final String DEFAULT_COMPONENTS_LIST_SEPARATOR = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPcomponents.list.separator"); // NOI18N - public static final String DEFAULT_DOWNLOAD_SIZE_LABEL_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPdownload.size.label.text"); // NOI18N - public static final String DEFAULT_REQUIRED_DISK_SPACE_LABEL_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPrequired.disk.space.label.text"); // NOI18N - public static final String DEFAULT_CREATE_BUTTON_TEXT = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPcreate.button.text");//NOI18N - - - public static final String DEFAULT_TITLE = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPdialog.title"); // NOI18N - public static final String DEFAULT_DESCRIPTION = - ResourceUtils.getString(PreCreateBundleSummaryPanel.class, - "PrCBSPdialog.description"); // NOI18N -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreInstallSummaryPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreInstallSummaryPanel.java deleted file mode 100644 index d88c0e9f4546..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/PreInstallSummaryPanel.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.NativeException; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * - * @author Kirill Sorokin - */ -public class PreInstallSummaryPanel extends ErrorMessagePanel { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public PreInstallSummaryPanel() { - setProperty(TITLE_PROPERTY, - DEFAULT_TITLE); - - setProperty(MESSAGE_TEXT_PROPERTY, - DEFAULT_MESSAGE_TEXT); - setProperty(MESSAGE_CONTENT_TYPE_PROPERTY, - DEFAULT_MESSAGE_CONTENT_TYPE); - setProperty(COMPONENTS_TO_INSTALL_LABEL_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_INSTALL_LABEL_TEXT); - setProperty(COMPONENTS_TO_INSTALL_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_INSTALL_TEXT); - setProperty(COMPONENTS_TO_INSTALL_CONTENT_TYPE_PROPERTY, - DEFAULT_COMPONENTS_TO_INSTALL_CONTENT_TYPE); - setProperty(COMPONENTS_TO_UNINSTALL_LABEL_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_UNINSTALL_LABEL_TEXT); - setProperty(COMPONENTS_TO_UNINSTALL_TEXT_PROPERTY, - DEFAULT_COMPONENTS_TO_UNINSTALL_TEXT); - setProperty(COMPONENTS_TO_UNINSTALL_CONTENT_TYPE_PROPERTY, - DEFAULT_COMPONENTS_TO_UNINSTALL_CONTENT_TYPE); - setProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY, - DEFAULT_COMPONENTS_LIST_SEPARATOR); - setProperty(DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY, - DEFAULT_DOWNLOAD_SIZE_LABEL_TEXT); - setProperty(REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY, - DEFAULT_REQUIRED_DISK_SPACE_LABEL_TEXT); - setProperty(INSTALL_BUTTON_TEXT_PROPERTY, - DEFAULT_INSTALL_BUTTON_TEXT); - - setProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY, - DEFAULT_ERROR_NOT_ENOUGH_SPACE); - setProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY, - DEFAULT_ERROR_CANNOT_CHECK_SPACE); - setProperty(ERROR_LOGIC_ACCESS_PROPERTY, - DEFAULT_ERROR_LOGIC_ACCESS); - setProperty(ERROR_FSROOTS_PROPERTY, - DEFAULT_ERROR_FSROOTS); - setProperty(ERROR_NON_EXISTENT_ROOT_PROPERTY, - DEFAULT_ERROR_NON_EXISTENT_ROOT); - setProperty(ERROR_CANNOT_WRITE_PROPERTY, - DEFAULT_ERROR_CANNOT_WRITE); - } - - @Override - public boolean canExecuteForward() { - return Registry.getInstance().getProductsToInstall().size() + - Registry.getInstance().getProductsToUninstall().size() > 0; - } - - @Override - public boolean canExecuteBackward() { - return Registry.getInstance().getProductsToInstall().size() + - Registry.getInstance().getProductsToUninstall().size() > 0; - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new PreInstallSummaryPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class PreInstallSummaryPanelUi extends ErrorMessagePanelUi { - protected PreInstallSummaryPanel panel; - - public PreInstallSummaryPanelUi(PreInstallSummaryPanel panel) { - super(panel); - - this.panel = panel; - } - - @Override - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new PreInstallSummaryPanelSwingUi(panel, container); - } - - return super.getSwingUi(container); - } - } - - public static class PreInstallSummaryPanelSwingUi extends ErrorMessagePanelSwingUi { - protected PreInstallSummaryPanel panel; - - private NbiTextPane messagePane; - private NbiLabel componentsToInstallLabel; - private NbiTextPane componentsToInstallPane; - private NbiLabel componentsToUninstallLabel; - private NbiTextPane componentsToUninstallPane; - private NbiLabel downloadSizeLabel; - private NbiLabel requiredDiskSpaceLabel; - - private NbiPanel spacer; - - public PreInstallSummaryPanelSwingUi( - final PreInstallSummaryPanel panel, - final SwingContainer container) { - super(panel, container); - - this.panel = panel; - - initComponents(); - } - - // protected //////////////////////////////////////////////////////////////// - @Override - protected void initializeContainer() { - super.initializeContainer(); - container.getNextButton().setText( - panel.getProperty(INSTALL_BUTTON_TEXT_PROPERTY)); - } - - @Override - protected void initialize() { - final String messageContentType = panel.getProperty(MESSAGE_CONTENT_TYPE_PROPERTY); - messagePane.setContentType(messageContentType); - - final String messageText = panel.getProperty(MESSAGE_TEXT_PROPERTY); - messagePane.setText(messageText); - - List componentsToInstall = Registry.getInstance().getProductsToInstall(); - List componentsToUninstall = Registry.getInstance().getProductsToUninstall(); - - if (componentsToUninstall.size() > 0) { - componentsToUninstallLabel.setVisible(true); - componentsToUninstallPane.setVisible(true); - - final String componentsToUninstallLabelText = panel.getProperty( - COMPONENTS_TO_UNINSTALL_LABEL_TEXT_PROPERTY); - componentsToUninstallLabel.setText(componentsToUninstallLabelText); - - final String componentsToUninstallContentType = panel.getProperty( - COMPONENTS_TO_UNINSTALL_CONTENT_TYPE_PROPERTY); - componentsToUninstallPane.setContentType(componentsToUninstallContentType); - - final String componentsToUninstallText = StringUtils.format( - panel.getProperty(COMPONENTS_TO_UNINSTALL_TEXT_PROPERTY), - StringUtils.asString(componentsToUninstall, - panel.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY))); - componentsToUninstallPane.setText(componentsToUninstallText); - } else { - componentsToUninstallLabel.setVisible(false); - componentsToUninstallPane.setVisible(false); - } - - if (componentsToInstall.size() > 0) { - componentsToInstallLabel.setVisible(true); - componentsToInstallPane.setVisible(true); - downloadSizeLabel.setVisible(true); - requiredDiskSpaceLabel.setVisible(true); - - final String componentsToInstallLabelText = panel.getProperty( - COMPONENTS_TO_INSTALL_LABEL_TEXT_PROPERTY); - componentsToInstallLabel.setText(componentsToInstallLabelText); - - final String componentsToInstallContentType = panel.getProperty( - COMPONENTS_TO_INSTALL_CONTENT_TYPE_PROPERTY); - componentsToInstallPane.setContentType(componentsToInstallContentType); - - final String componentsToInstallText = StringUtils.format( - panel.getProperty(COMPONENTS_TO_INSTALL_TEXT_PROPERTY), - StringUtils.asString(componentsToInstall, - panel.getProperty(COMPONENTS_LIST_SEPARATOR_PROPERTY))); - - componentsToInstallPane.setText(componentsToInstallText); - - long downloadSize = 0; - for (Product component: componentsToInstall) { - downloadSize += component.getDownloadSize(); - } - - long requiredDiskSpace = 0; - for (Product component: componentsToInstall) { - requiredDiskSpace += component.getRequiredDiskSpace(); - } - - final String downloadSizeLabelText = StringUtils.format( - panel.getProperty(DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY), - StringUtils.formatSize(downloadSize)); - - downloadSizeLabel.setText(downloadSizeLabelText); - - final String requiredDiskSpaceLabelText = StringUtils.format( - panel.getProperty(REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY), - StringUtils.formatSize(requiredDiskSpace)); - - requiredDiskSpaceLabel.setText(requiredDiskSpaceLabelText); - } else { - componentsToInstallLabel.setVisible(false); - componentsToInstallPane.setVisible(false); - downloadSizeLabel.setVisible(false); - requiredDiskSpaceLabel.setVisible(false); - } - } - - @Override - protected String validateInput() { - try { - if(!Boolean.getBoolean(SystemUtils.NO_SPACE_CHECK_PROPERTY)) { - final List toInstall = Registry.getInstance().getProductsToInstall(); - final Map spaceMap = new HashMap(); - final File downloadDataDir = Installer.getInstance().getLocalDirectory(); - - // only roots for appropriate files - final String[] installFiles = new String[toInstall.size() + 1]; - for (int i = 0; i < toInstall.size(); i++) { - installFiles[i] = toInstall.get(i).getInstallationLocation().getAbsolutePath(); - } - installFiles[installFiles.length - 1] = downloadDataDir.getAbsolutePath(); - final List roots = SystemUtils.getFileSystemRoots(installFiles); - - LogManager.log("Roots : " + StringUtils.asString(roots)); - - File downloadDataDirRoot = FileUtils.getRoot(downloadDataDir, roots); - long downloadSize = 0; - for (Product product: toInstall) { - downloadSize+=product.getDownloadSize(); - } - // the critical check point - we download all the data - spaceMap.put(downloadDataDirRoot, downloadSize); - long lastDataSize = 0; - - for (Product product: toInstall) { - final File installLocation = product.getInstallationLocation(); - final File root = FileUtils.getRoot(installLocation, roots); - final long productSize = product.getRequiredDiskSpace(); - - LogManager.log(" [" + root + "] <- " + installLocation); - - if ( root != null ) { - Long ddSize = spaceMap.get(downloadDataDirRoot); - // remove space that was freed after the remove of previos product data - spaceMap.put(downloadDataDirRoot, - Long.valueOf(ddSize - lastDataSize)); - - Long size = spaceMap.get(root); - size = Long.valueOf( - (size != null ? size.longValue() : 0L) + - productSize); - spaceMap.put(root, size); - lastDataSize = product.getDownloadSize(); - } else { - return StringUtils.format( - panel.getProperty(ERROR_NON_EXISTENT_ROOT_PROPERTY), - product, installLocation); - } - } - - for (Map.Entry entry: spaceMap.entrySet()) { - File root = entry.getKey(); - - try { - final long availableSpace = - SystemUtils.getFreeSpace(root); - final long requiredSpace = entry.getValue() + REQUIRED_SPACE_ADDITION; - - if (availableSpace < requiredSpace) { - return StringUtils.format( - panel.getProperty(ERROR_NOT_ENOUGH_SPACE_PROPERTY), - root, - StringUtils.formatSize(requiredSpace - availableSpace)); - } - } catch (NativeException e) { - ErrorManager.notifyError( - panel.getProperty(ERROR_CANNOT_CHECK_SPACE_PROPERTY), - e); - } - } - } - final List toUninstall = - Registry.getInstance().getProductsToUninstall(); - for (Product product: toUninstall) { - if (!FileUtils.canWrite(product.getInstallationLocation())) { - return StringUtils.format( - panel.getProperty(ERROR_CANNOT_WRITE_PROPERTY), - product, - product.getInstallationLocation()); - } - } - - } catch (IOException e) { - ErrorManager.notifyError( - panel.getProperty(ERROR_FSROOTS_PROPERTY), e); - } - - return null; - } - - // private ////////////////////////////////////////////////////////////////// - private void initComponents() { - // messagePane ////////////////////////////////////////////////////////// - messagePane = new NbiTextPane(); - - // componentsToUninstallPane //////////////////////////////////////////// - componentsToUninstallPane = new NbiTextPane(); - - // componentsToUninstallLabel /////////////////////////////////////////// - componentsToUninstallLabel = new NbiLabel(); - componentsToUninstallLabel.setLabelFor(componentsToUninstallPane); - - // componentsToInstallPane ////////////////////////////////////////////// - componentsToInstallPane = new NbiTextPane(); - - // componentsToInstallLabel ///////////////////////////////////////////// - componentsToInstallLabel = new NbiLabel(); - componentsToInstallLabel.setLabelFor(componentsToInstallPane); - - // downloadSizeLabel //////////////////////////////////////////////////// - downloadSizeLabel = new NbiLabel(); - //downloadSizeLabel.setFocusable(true); - - // requiredDiskSpaceLabel /////////////////////////////////////////////// - requiredDiskSpaceLabel = new NbiLabel(); - //requiredDiskSpaceLabel.setFocusable(true); - - // spacer /////////////////////////////////////////////////////////////// - spacer = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - add(messagePane, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToUninstallLabel, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToUninstallPane, new GridBagConstraints( - 0, 2, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToInstallLabel, new GridBagConstraints( - 0, 3, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(15, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(componentsToInstallPane, new GridBagConstraints( - 0, 4, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(downloadSizeLabel, new GridBagConstraints( - 0, 5, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(25, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(requiredDiskSpaceLabel, new GridBagConstraints( - 0, 6, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(3, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - add(spacer, new GridBagConstraints( - 0, 7, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 11, 11, 11), // padding - 0, 0)); // padx, pady - ??? - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String DEFAULT_TITLE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.title"); - - public static final String MESSAGE_TEXT_PROPERTY = - "message.text"; - public static final String MESSAGE_CONTENT_TYPE_PROPERTY = - "message.content.type"; - public static final String COMPONENTS_TO_INSTALL_LABEL_TEXT_PROPERTY = - "components.to.install.label.text"; - public static final String COMPONENTS_TO_INSTALL_TEXT_PROPERTY = - "components.to.install.text"; - public static final String COMPONENTS_TO_INSTALL_CONTENT_TYPE_PROPERTY = - "components.to.install.content.type"; - public static final String COMPONENTS_TO_UNINSTALL_LABEL_TEXT_PROPERTY = - "components.to.uninstall.label.text"; - public static final String COMPONENTS_TO_UNINSTALL_TEXT_PROPERTY = - "components.to.uninstall.text"; - public static final String COMPONENTS_TO_UNINSTALL_CONTENT_TYPE_PROPERTY = - "components.to.uninstall.content.type"; - public static final String COMPONENTS_LIST_SEPARATOR_PROPERTY = - "components.list.separator"; - public static final String DOWNLOAD_SIZE_LABEL_TEXT_PROPERTY = - "download.size.label.text"; - public static final String REQUIRED_DISK_SPACE_LABEL_TEXT_PROPERTY = - "required.disk.space.label.text"; - public static final String INSTALL_BUTTON_TEXT_PROPERTY = - "install.button.text"; - - - public static final String ERROR_NOT_ENOUGH_SPACE_PROPERTY = - "error.not.enough.space"; // NOI18N - public static final String ERROR_CANNOT_CHECK_SPACE_PROPERTY = - "error.cannot.check.space"; // NOI18N - public static final String ERROR_LOGIC_ACCESS_PROPERTY = - "error.logic.access"; // NOI18N - public static final String ERROR_FSROOTS_PROPERTY = - "error.fsroots"; // NOI18N - public static final String ERROR_NON_EXISTENT_ROOT_PROPERTY = - "error.non.existent.root"; // NOI18N - public static final String ERROR_CANNOT_WRITE_PROPERTY = - "error.cannot.write"; // NOI18N - - public static final String DEFAULT_MESSAGE_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.message.text"); - public static final String DEFAULT_MESSAGE_CONTENT_TYPE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.message.content.type"); - public static final String DEFAULT_COMPONENTS_TO_INSTALL_LABEL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.install.label.text"); - public static final String DEFAULT_COMPONENTS_TO_INSTALL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.install.text"); - public static final String DEFAULT_COMPONENTS_TO_INSTALL_CONTENT_TYPE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.install.content.type"); - public static final String DEFAULT_COMPONENTS_TO_UNINSTALL_LABEL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.uninstall.label.text"); - public static final String DEFAULT_COMPONENTS_TO_UNINSTALL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.uninstall.text"); - public static final String DEFAULT_COMPONENTS_TO_UNINSTALL_CONTENT_TYPE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.to.uninstall.content.type"); - public static final String DEFAULT_COMPONENTS_LIST_SEPARATOR = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.components.list.separator"); - public static final String DEFAULT_DOWNLOAD_SIZE_LABEL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.download.size.label.text"); - public static final String DEFAULT_REQUIRED_DISK_SPACE_LABEL_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.required.disk.space.label.text"); - public static final String DEFAULT_INSTALL_BUTTON_TEXT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.install.button.text"); - public static final String DEFAULT_ERROR_NOT_ENOUGH_SPACE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.not.enough.space"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_CHECK_SPACE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.cannot.check.space");// NOI18N - public static final String DEFAULT_ERROR_LOGIC_ACCESS = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.logic.access");// NOI18N - public static final String DEFAULT_ERROR_FSROOTS = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.fsroots"); // NOI18N - public static final String DEFAULT_ERROR_NON_EXISTENT_ROOT = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.non.existent.root"); // NOI18N - public static final String DEFAULT_ERROR_CANNOT_WRITE = - ResourceUtils.getString(PreInstallSummaryPanel.class, - "PrISP.error.cannot.write"); // NOI18N - - public static final long REQUIRED_SPACE_ADDITION = - 10L * 1024L * 1024L; // 10MB -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/TextPanel.java b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/TextPanel.java deleted file mode 100644 index 198d2395373f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/TextPanel.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.panels; - -import java.awt.GridBagConstraints; -import java.awt.Insets; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; -import org.netbeans.installer.wizard.components.WizardPanel; -import org.netbeans.installer.wizard.components.WizardPanel.WizardPanelUi; -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * - * @author Kirill Sorokin - */ -public class TextPanel extends WizardPanel { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String TEXT_PROPERTY = - "text"; // NOI18N - public static final String CONTENT_TYPE_PROPERTY = - "content.type"; // NOI18N - - public static final String DEFAULT_TEXT = - ResourceUtils.getString(TextPanel.class, - "TP.text"); // NOI18N - public static final String DEFAULT_CONTENT_TYPE = - ResourceUtils.getString(TextPanel.class, - "TP.content.type"); // NOI18N - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public TextPanel() { - setProperty(TEXT_PROPERTY, DEFAULT_TEXT); - setProperty(CONTENT_TYPE_PROPERTY, DEFAULT_CONTENT_TYPE); - } - - @Override - public WizardUi getWizardUi() { - if (wizardUi == null) { - wizardUi = new TextPanelUi(this); - } - - return wizardUi; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - public static class TextPanelUi extends WizardPanelUi { - protected TextPanel component; - - public TextPanelUi(TextPanel component) { - super(component); - - this.component = component; - } - - public SwingUi getSwingUi(SwingContainer container) { - if (swingUi == null) { - swingUi = new TextPanelSwingUi(component, container); - } - - return super.getSwingUi(container); - } - } - - public static class TextPanelSwingUi extends WizardPanelSwingUi { - protected TextPanel component; - - private NbiTextPane textPane; - - public TextPanelSwingUi( - final TextPanel component, - final SwingContainer container) { - super(component, container); - - this.component = component; - - initComponents(); - } - - @Override - public String getTitle() { - return null; // text panels do not have a title - } - - @Override - protected void initialize() { - textPane.setContentType( - component.getProperty(CONTENT_TYPE_PROPERTY)); - textPane.setText( - component.getProperty(TEXT_PROPERTY)); - } - - private void initComponents() { - // textPane ///////////////////////////////////////////////////////////// - textPane = new NbiTextPane(); - - // this ///////////////////////////////////////////////////////////////// - add(textPane, new GridBagConstraints( - 0, 0, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 11, 11), // padding - 0, 0)); // ??? (padx, pady) - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/empty.png b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/empty.png deleted file mode 100644 index 4bf131f171ee..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/empty.png and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.png b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.png deleted file mode 100644 index 7d0ea445ad52..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.png and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.svg b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.svg deleted file mode 100644 index 57a6e4ba0602..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/error.svg +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.png b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.png deleted file mode 100644 index 862f04bde3c0..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.png and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.svg b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.svg deleted file mode 100644 index db4c01180fbf..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/info.svg +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.png b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.png deleted file mode 100644 index f40c804a52ea..000000000000 Binary files a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.png and /dev/null differ diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.svg b/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.svg deleted file mode 100644 index e5932382e489..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/panels/warning.svg +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/Bundle.properties deleted file mode 100644 index 552f5dcc467e..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/CreateBundleSequence.java b/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/CreateBundleSequence.java deleted file mode 100644 index 0f2cf50cf30d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/CreateBundleSequence.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.wizard.components.sequences; - -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.helper.ExecutionMode; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.wizard.components.WizardSequence; -import org.netbeans.installer.wizard.components.actions.CreateBundleAction; -import org.netbeans.installer.wizard.components.actions.CreateMacOSAppLauncherAction; -import org.netbeans.installer.wizard.components.actions.CreateNativeLauncherAction; -import org.netbeans.installer.wizard.components.actions.DownloadConfigurationLogicAction; -import org.netbeans.installer.wizard.components.actions.DownloadInstallationDataAction; -import org.netbeans.installer.wizard.components.panels.ComponentsSelectionPanel; -import org.netbeans.installer.wizard.components.panels.PostCreateBundleSummaryPanel; -import org.netbeans.installer.wizard.components.panels.PreCreateBundleSummaryPanel; - -/** - * - * @author Dmitry Lipin - */ -public class CreateBundleSequence extends WizardSequence { - private DownloadConfigurationLogicAction downloadConfigurationLogicAction; - private DownloadInstallationDataAction downloadInstallationDataAction; - private PreCreateBundleSummaryPanel preCreateBundleSummaryPanel; - private CreateBundleAction createBundleAction; - private CreateNativeLauncherAction createNativeLauncherAction; - private CreateMacOSAppLauncherAction createAppLauncherAction; - private PostCreateBundleSummaryPanel postCreateBundleSummaryPanel; - - public CreateBundleSequence() { - downloadConfigurationLogicAction = new DownloadConfigurationLogicAction(); - downloadInstallationDataAction = new DownloadInstallationDataAction(); - preCreateBundleSummaryPanel = new PreCreateBundleSummaryPanel(); - createBundleAction = new CreateBundleAction(); - createNativeLauncherAction = new CreateNativeLauncherAction(); - createAppLauncherAction = new CreateMacOSAppLauncherAction(); - postCreateBundleSummaryPanel = new PostCreateBundleSummaryPanel(); - } - - @Override - public void executeForward() { - final Registry registry = Registry.getInstance(); - - // remove all current children (if there are any), as the components - // selection has probably changed and we need to rebuild from scratch - getChildren().clear(); - - // we're creating a bundle - we only need to download and package things - addChild(preCreateBundleSummaryPanel); - addChild(downloadConfigurationLogicAction); - addChild(downloadInstallationDataAction); - addChild(createBundleAction); - - if (registry.getTargetPlatform().isCompatibleWith(Platform.MACOSX)) { - addChild(createAppLauncherAction); - } else { - addChild(createNativeLauncherAction); - } - addChild(postCreateBundleSummaryPanel); - - super.executeForward(); - } - - @Override - public boolean canExecuteForward() { - return ExecutionMode.CREATE_BUNDLE == ExecutionMode.getCurrentExecutionMode(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/MainSequence.java b/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/MainSequence.java deleted file mode 100644 index 4f9f4a980f51..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/MainSequence.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.installer.wizard.components.sequences; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.helper.ExecutionMode; -import org.netbeans.installer.wizard.components.WizardSequence; -import org.netbeans.installer.wizard.components.actions.DownloadConfigurationLogicAction; -import org.netbeans.installer.wizard.components.actions.DownloadInstallationDataAction; -import org.netbeans.installer.wizard.components.actions.InstallAction; -import org.netbeans.installer.wizard.components.actions.UninstallAction; -import org.netbeans.installer.wizard.components.panels.ComponentsSelectionPanel; -import org.netbeans.installer.wizard.components.panels.LicensesPanel; -import org.netbeans.installer.wizard.components.panels.PostInstallSummaryPanel; -import org.netbeans.installer.wizard.components.panels.PreInstallSummaryPanel; - -/** - * - * @author Kirill Sorokin - * @author Dmitry Lipin - */ -public class MainSequence extends WizardSequence { - private DownloadConfigurationLogicAction downloadConfigurationLogicAction; - private LicensesPanel licensesPanel; - private PreInstallSummaryPanel preInstallSummaryPanel; - private UninstallAction uninstallAction; - private DownloadInstallationDataAction downloadInstallationDataAction; - private InstallAction installAction; - private PostInstallSummaryPanel postInstallSummaryPanel; - private Map productSequences; - - public MainSequence() { - downloadConfigurationLogicAction = new DownloadConfigurationLogicAction(); - licensesPanel = new LicensesPanel(); - preInstallSummaryPanel = new PreInstallSummaryPanel(); - uninstallAction = new UninstallAction(); - downloadInstallationDataAction = new DownloadInstallationDataAction(); - installAction = new InstallAction(); - postInstallSummaryPanel = new PostInstallSummaryPanel(); - productSequences = new HashMap(); - } - - @Override - public void executeForward() { - final Registry registry = Registry.getInstance(); - final List toInstall = registry.getProductsToInstall(); - final List toUninstall = registry.getProductsToUninstall(); - - // remove all current children (if there are any), as the components - // selection has probably changed and we need to rebuild from scratch - getChildren().clear(); - - // if we're installing, we ask for input, run a wizard sequence for - // each selected component and then download and install - if (toInstall.size() > 0) { - addChild(downloadConfigurationLogicAction); - addChild(licensesPanel); - - for (Product product : toInstall) { - if (!productSequences.containsKey(product)) { - productSequences.put( - product, - new ProductWizardSequence(product)); - } - - addChild(productSequences.get(product)); - } - } - - addChild(preInstallSummaryPanel); - - if (toUninstall.size() > 0) { - addChild(uninstallAction); - } - - if (toInstall.size() > 0) { - addChild(downloadInstallationDataAction); - addChild(installAction); - } - - addChild(postInstallSummaryPanel); - - super.executeForward(); - } - - public boolean canExecuteForward() { - return ExecutionMode.NORMAL == ExecutionMode.getCurrentExecutionMode(); - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/ProductWizardSequence.java b/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/ProductWizardSequence.java deleted file mode 100644 index 6afb6ecffb92..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/components/sequences/ProductWizardSequence.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.components.sequences; - -import java.util.List; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.wizard.components.WizardComponent; -import org.netbeans.installer.wizard.components.WizardSequence; - - -public class ProductWizardSequence extends WizardSequence { - private Product product; - - public ProductWizardSequence(final Product product) { - this.product = product; - } - - public void executeForward() { - childWizard = getWizard().createSubWizard( - product.getWizardComponents(), - -1, - product, - product.getClassLoader()); - - childWizard.getContext().put(product); - childWizard.next(); - } - - public void executeBackward() { - childWizard = getWizard().createSubWizard( - product.getWizardComponents(), - product.getWizardComponents().size(), - product, - product.getClassLoader()); - - childWizard.getContext().put(product); - childWizard.previous(); - } - - public boolean canExecuteForward() { - if (product.isLogicDownloaded()) { - List components = product.getWizardComponents(); - - for (int i = 0; i < components.size(); i++) { - WizardComponent component = components.get(i); - - // if the component can be executed forward the whole sequence - // can be executed as well - if (component.canExecuteForward()) { - return true; - } - } - } - - return false; - } - - public boolean canExecuteBackward() { - if (product.isLogicDownloaded()) { - List components = product.getWizardComponents(); - - for (int i = components.size() - 1; i > -1; i--) { - WizardComponent component = components.get(i); - - // if the component can be executed backward the whole sequence can - // be executed as well - if (component.canExecuteBackward()) { - return true; - } - - // if the currently examined component is a point of no return and - // it cannot be executed (since we passed the previous statement) - - // we have no previous component - if (component.isPointOfNoReturn()) { - return false; - } - } - } - - return false; - } - - public boolean isPointOfNoReturn() { - if (product.isLogicDownloaded()) { - List components = product.getWizardComponents(); - - if (childWizard != null) { - for (int i = 0; i < components.size(); i++) { - if (components.get(i).isPointOfNoReturn() && (i < childWizard.getIndex())) { - return true; - } - } - } - } - - return false; - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/containers/Bundle.properties deleted file mode 100644 index ece095d18a6b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/Bundle.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# SwingFrameContainer.java -SFC.error.failed.to.download.icon=Failed to download wizard icon from URI - {0}. -SFC.error.failed.to.set.icon=Failed to set the swing frame container icon. -SFC.error.failed.to.attach.error.handler=Failed to attach custom error handler to the EDT. -SFC.frame.title.prefix=NBI -SFC.frame.title.pattern={0} - {1} - -SFC.error.close.operation=Cannot set the default close operation diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK8.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK8.java deleted file mode 100644 index d2c4c9fdb983..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK8.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import com.apple.eawt.Application; -import com.apple.eawt.ApplicationAdapter; -import com.apple.eawt.ApplicationEvent; - -/** - * - * @author christian.oyarzun - */ -public class InitializeMacJDK8 { - public static void initialize(SwingFrameContainer frameContainer) - { - final Application application = Application.getApplication(); - if(application == null) { - // e.g. running OpenJDK port via X11 on Mac OS X - return; - } - application.removeAboutMenuItem(); - application.removePreferencesMenuItem(); - application.addApplicationListener(new ApplicationAdapter() { - - @Override - public void handleQuit(ApplicationEvent event) { - frameContainer.cancelContainer(); - } - }); - - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK9.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK9.java deleted file mode 100644 index ebcdff69958b..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/InitializeMacJDK9.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import java.awt.Desktop; -import java.awt.desktop.QuitEvent; -import java.awt.desktop.QuitHandler; -import java.awt.desktop.QuitResponse; - -/** - * - * @author christian.oyarzun - */ -public class InitializeMacJDK9 { -public static void initialize(SwingFrameContainer frameContainer) - { - Desktop desktop = Desktop.getDesktop(); - if (desktop != null) - { - desktop.setQuitHandler((QuitEvent e, QuitResponse response) -> frameContainer.cancelContainer()); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/SilentContainer.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/SilentContainer.java deleted file mode 100644 index a68fb883bf0d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/SilentContainer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * - * @author Dmitry Lipin - */ -public class SilentContainer implements WizardContainer { - - public void setVisible(boolean visible) { - //do nothing - } - - public void updateWizardUi(WizardUi ui) { - //do nothing - } - - public void open() { - //do nothing - } - - public void close() { - //do nothing - } - -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingContainer.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingContainer.java deleted file mode 100644 index 69e210d95065..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingContainer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import org.netbeans.installer.utils.helper.swing.NbiButton; - -/** - * This is the specialization of the {@link WizardContainer} interface with regard - * to Swing UI mode - {@link UiMode#SWING}. It defines several methods which are - * specific to the Swing-based containers. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public interface SwingContainer extends WizardContainer { - /** - * Returns the Swing implementation of the standard Help button. - * - * @return Help button instance. - */ - NbiButton getHelpButton(); - - /** - * Returns the Swing implementation of the standard Back button. - * - * @return Back button instance. - */ - NbiButton getBackButton(); - - /** - * Returns the Swing implementation of the standard Next button. - * - * @return Next button instance. - */ - NbiButton getNextButton(); - - /** - * Returns the Swing implementation of the standard Cancel button. - * - * @return Cancel button instance. - */ - NbiButton getCancelButton(); -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingFrameContainer.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingFrameContainer.java deleted file mode 100644 index 9fc28dd53041..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/SwingFrameContainer.java +++ /dev/null @@ -1,1017 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import com.apple.eawt.Application; -import com.apple.eawt.ApplicationAdapter; -import com.apple.eawt.ApplicationEvent; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import javax.swing.AbstractAction; -import javax.swing.ImageIcon; -import javax.swing.JRootPane; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileProxy; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.UiUtils; -import org.netbeans.installer.utils.exceptions.DownloadException; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiFrame; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiSeparator; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; -import org.netbeans.installer.wizard.ui.SwingUi; -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This class is a conscrete implementation of the {@link SwingContainer} interface. - * In this case the container is an {@link NbiFrame}. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public class SwingFrameContainer extends NbiFrame implements SwingContainer { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Instance of {@link SwingUi} that is currently shown by the container. - */ - private SwingUi currentUi; - - /** - * Content pane used by the container. - */ - private WizardFrameContentPane contentPane; - - /** - * Prefix of the container frame title. - */ - private String frameTitlePrefix; - - /** - * Pattern which should be used to combine the container frame's title prefix - * and the title of the current UI. - */ - private String frameTitlePattern; - - /** - * Creates a new instance of {@link SwingFrameContainer}. The constructor calls - * the initialization routine of the parent class and searches the system - * properties for settings which may be releavant to this type of container. - * Additionally it initializes and lays out the core swing components of the - * container. - */ - public SwingFrameContainer() { - super(); - - frameWidth = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_WIDTH_PROPERTY, - DEFAULT_WIZARD_FRAME_WIDTH); - frameMinimumWidth = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_MINIMUM_WIDTH_PROPERTY, - DEFAULT_WIZARD_FRAME_MINIMUM_WIDTH); - frameMaximumWidth = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_MAXIMUM_WIDTH_PROPERTY, - DEFAULT_WIZARD_FRAME_MAXIMUM_WIDTH); - - frameHeight = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_HEIGHT_PROPERTY, - DEFAULT_WIZARD_FRAME_HEIGHT); - frameMinimumHeight = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_MINIMUM_HEIGHT_PROPERTY, - DEFAULT_WIZARD_FRAME_MINIMUM_HEIGHT); - frameMaximumHeight = UiUtils.getDimension(System.getProperties(), - WIZARD_FRAME_MAXIMUM_HEIGHT_PROPERTY, - DEFAULT_WIZARD_FRAME_MAXIMUM_HEIGHT); - - boolean customIconLoaded = false; - if (System.getProperty(WIZARD_FRAME_ICON_URI_PROPERTY) != null) { - final String frameIconUri = - System.getProperty(WIZARD_FRAME_ICON_URI_PROPERTY); - - try { - frameIcon = FileProxy.getInstance().getFile(frameIconUri,true); - customIconLoaded = true; - } catch (DownloadException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON, - frameIconUri), e); - } - } - - if (!customIconLoaded) { - final String frameIconUri = DEFAULT_WIZARD_FRAME_ICON_URI; - - try { - frameIcon = FileProxy.getInstance().getFile(frameIconUri,true); - customIconLoaded = true; - } catch (DownloadException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON, - frameIconUri), e); - } - } - - frameTitlePrefix = DEFAULT_WIZARD_FRAME_TITLE_PREFIX; - if (System.getProperty(WIZARD_FRAME_TITLE_PREFIX_PROPERTY) != null) { - frameTitlePrefix = - System.getProperty(WIZARD_FRAME_TITLE_PREFIX_PROPERTY); - } - - frameTitlePattern = DEFAULT_WIZARD_FRAME_TITLE_PATTERN; - if (System.getProperty(WIZARD_FRAME_TITLE_PATTERN_PROPERTY) != null) { - frameTitlePattern = - System.getProperty(WIZARD_FRAME_TITLE_PATTERN_PROPERTY); - } - - initComponents(); - } - - /** - * This method overrides {@link NbiFrame#setVisible()} and at the same time - * implements {@link WizardContainer#setVisible()}. It is responsible for - * showing and hiding the wizard container frame. - * - * @param visible Whether to show the frame - true, or to hide - * it - false. - */ - @Override - public void setVisible(final boolean visible) { - super.setVisible(visible); - - if (visible == false) { - dispose(); - } - } - - /** - * {@inheritDoc} - */ - public void updateWizardUi(final WizardUi wizardUi) { - if(wizardUi==null) { - currentUi = null; - return; - } - if (!SwingUtilities.isEventDispatchThread()) { - try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - updateWizardUi(wizardUi); - } - }); - } catch (InterruptedException e) { - LogManager.log("Error during updating wizard UI", e); - } catch (InvocationTargetException e) { - LogManager.log("Error during updating wizard UI", e); - } - return; - } - - // save the ui reference - currentUi = wizardUi.getSwingUi(this); - - final int currentHeight = getSize().height; - - // update the frame title - if (currentUi.getTitle() != null) { - setTitle(StringUtils.format( - frameTitlePattern, - frameTitlePrefix, - currentUi.getTitle())); - } else { - setTitle(frameTitlePrefix); - } - - // change the panel - contentPane.updatePanel(currentUi); - - // resize the frame if needed - final int neededMinimumHeight = - this.getLayout().minimumLayoutSize(this).getSize().height; - - if(isResizable() && (neededMinimumHeight > currentHeight)) { - setPreferredSize(new Dimension(getSize().width, - neededMinimumHeight + EXTRA_SIZE)); - setMinimumSize(new Dimension(getSize().width, - neededMinimumHeight + EXTRA_SIZE)); - pack(); - } - contentPane.repaint(); - - // handle the default buttons - Enter - - getRootPane().setDefaultButton(currentUi.getDefaultEnterButton()); - - // handle the default buttons - Escape - getRootPane().getInputMap(JRootPane.WHEN_IN_FOCUSED_WINDOW).put( - KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), - CANCEL_ACTION_NAME); - getRootPane().getActionMap().put(CANCEL_ACTION_NAME, new AbstractAction() { - public void actionPerformed(ActionEvent event) { - if(currentUi == null) { - return; - } - final NbiButton button = currentUi.getDefaultEscapeButton(); - if (button != null && button.isEnabled()) { - if (button.equals(getHelpButton())) { - currentUi.evaluateHelpButtonClick(); - } - if (button.equals(getBackButton())) { - currentUi.evaluateBackButtonClick(); - } - if (button.equals(getNextButton())) { - currentUi.evaluateNextButtonClick(); - } - if (button.equals(getCancelButton())) { - currentUi.evaluateCancelButtonClick(); - } - } - } - }); - - // set the default focus for the current page - if (currentUi.getDefaultFocusOwner() != null) { - currentUi.getDefaultFocusOwner().requestFocusInWindow(); - } - - // a11y - getAccessibleContext().setAccessibleName(currentUi.getTitle()); - getAccessibleContext().setAccessibleDescription(currentUi.getDescription()); - } - - /** - * {@inheritDoc} - */ - public NbiButton getHelpButton() { - return contentPane.getHelpButton(); - } - - /** - * {@inheritDoc} - */ - public NbiButton getBackButton() { - return contentPane.getBackButton(); - } - - /** - * {@inheritDoc} - */ - public NbiButton getNextButton() { - return contentPane.getNextButton(); - } - - /** - * {@inheritDoc} - */ - public NbiButton getCancelButton() { - return contentPane.getCancelButton(); - } - - public void open() { - try { - SwingUtilities.invokeAndWait(new Runnable() { - - public void run() { - Thread.currentThread().setUncaughtExceptionHandler( - ErrorManager.getExceptionHandler()); - } - }); - } catch (InvocationTargetException e) { - ErrorManager.notifyDebug(ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_FAILED_TO_ATTACH_ERROR_HANDLER), e); - } catch (InterruptedException e) { - ErrorManager.notifyDebug(ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_FAILED_TO_ATTACH_ERROR_HANDLER), e); - } - - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - setVisible(true); - } - }); - } - - public void close() { - setVisible(false); - } - - // protected //////////////////////////////////////////////////////////////////// - /** - * Initializes and lays out the Swing components for the container frame. This - * method also sets some frame properties which will be required at runtime, - * such as size, position, etc. - */ - private void initComponents() { - try { - setDefaultCloseOperation(NbiFrame.DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent event) { - cancelContainer(); - } - }); - // perform some additional intiialization for Mac OS - initializeMacOS(); - } catch (SecurityException e) { - // we might fail here with a custom security manager (e.g. the netbeans - // one); in this case just log the exception and "let it be" (c) - ErrorManager.notifyDebug( - ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_ERROR_SET_CLOSE_OPERATION), - e); - } - - Dimension size = new Dimension(frameWidth, frameHeight); - setSize(size); - setPreferredSize(size); - setMinimumSize(size); - - try { - setIconImage(new ImageIcon(frameIcon.toURI().toURL()).getImage()); - } catch (MalformedURLException e) { - ErrorManager.notifyWarning(ResourceUtils.getString( - SwingFrameContainer.class, - RESOURCE_FAILED_TO_SET_FRAME_CONTAINER_ICON), e); - } - - final String resizable = System.getProperty(WIZARD_FRAME_RESIZABLE_PROPERTY); - if(resizable!=null && (resizable.equals("false") || resizable.equals("FALSE"))) { - setResizable(false); - } - - contentPane = new WizardFrameContentPane(); - setContentPane(contentPane); - - contentPane.getHelpButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - if(currentUi!=null) { - currentUi.evaluateHelpButtonClick(); - } - } - }); - - contentPane.getBackButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - if(currentUi!=null) { - currentUi.evaluateBackButtonClick(); - } - } - }); - - contentPane.getNextButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - if(currentUi!=null) { - currentUi.evaluateNextButtonClick(); - } - } - }); - - contentPane.getCancelButton().addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - if(currentUi!=null) { - currentUi.evaluateCancelButtonClick(); - } - } - }); - } - - private void initializeMacOS() { - if (SystemUtils.isMacOS()) { - if (!initializeMacJDK("org.netbeans.installer.wizard.containers.initializeMacJDK8")) { // NOI18N - // JDK 8 failed, try JDK 9 - initializeMacJDK("org.netbeans.installer.wizard.containers.initializeMacJDK9"); - } - } - } - - private boolean initializeMacJDK(String className) { - try { - Class initializer = Class.forName(className); - @SuppressWarnings("unchecked") - Method m = initializer.getDeclaredMethod("initialize", new Class[0] ); // NOI18N - m.invoke(initializer, this); - return true; - }catch (NoClassDefFoundError e) { - }catch (ClassNotFoundException e) { - }catch (Exception e) { - } - return false; - } - - void cancelContainer() { - if (currentUi != null) { - if (contentPane.getCancelButton().isEnabled()) { - currentUi.evaluateCancelButtonClick(); - } - } - } - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - /** - * This class is an extension of {@link NbiFrameContentPane} which adds some - * functionality specific to the wizard container's needs. It is used as the - * content pane for the wizard frame. - * - * @author Kirill Sorokin - * @since 1.0 - */ - public static class WizardFrameContentPane extends NbiFrameContentPane { - /** - * {@link NbiLabel} which would be used to display the - * {@link WizardComponent}'s title. - */ - private NbiLabel titleLabel; - - /** - * {@link NbiTextPane} which would be used to display the - * {@link WizardComponent}'s description. - */ - private NbiTextPane descriptionPane; - - /** - * Container for the title and description components. - */ - private NbiPanel titlePanel; - - /** - * Container for the title and description images (left&right). - */ - private NbiPanel titleDescriptionImageRightPanel; - private NbiPanel titleDescriptionImageLeftPanel; - - /** - * Separator between the wizard page header (title and description) and the - * main wizard page contents. - */ - private NbiSeparator topSeparator; - - /** - * Separator between the wizard page footer (standard wizard container - * buttons) and the main wizard page contents. - */ - private NbiSeparator bottomSeparator; - - /** - * The standard Help button. - */ - private NbiButton helpButton; - - /** - * The standard Back button. - */ - private NbiButton backButton; - - /** - * The standard Next button. - */ - private NbiButton nextButton; - - /** - * The standard Cancel button. - */ - private NbiButton cancelButton; - - /** - * Spacer panel which used to correctly position the standard buttons. - */ - private NbiPanel spacerPanel; - - /** - * Container for the standard buttons swing components. - */ - private NbiPanel buttonsPanel; - - /** - * Reference to the {@link SwingUi} being currently displayed. - */ - private NbiPanel currentPanel; - - /** - * Creates a new instance of {@link WizardFrameContentPane}. The default - * constructor simply initializes and lays out the swing components - * required by the content pane. - */ - public WizardFrameContentPane() { - initComponents(); - } - - /** - * - * @param panel - */ - public void updatePanel(final SwingUi panel) { - if (currentPanel != null) { - remove(currentPanel); - } - currentPanel = panel; - - if (panel.getTitle() != null) { - titleLabel.setText(panel.getTitle()); - descriptionPane.setText(panel.getDescription()); - - titlePanel.setVisible(true); - topSeparator.setVisible(true); - - currentPanel.setOpaque(false); - } else { - titlePanel.setVisible(false); - topSeparator.setVisible(false); - - currentPanel.setOpaque(true); - currentPanel.setBackground(Color.WHITE); - } - - add(currentPanel, BorderLayout.CENTER); - - validate(); - } - - /** - * Returns the Swing implementation of the standard Help - * button. This method is called by the {@link SwingFrameContainer} when it - * needs to get the handle of the button. - * - * @return Help button instance. - * @see SwingFrameContainer#getHelpButton. - */ - public NbiButton getHelpButton() { - return helpButton; - } - - /** - * Returns the Swing implementation of the standard Back - * button. This method is called by the {@link SwingFrameContainer} when it - * needs to get the handle of the button. - * - * @return Back button instance. - * @see SwingFrameContainer#getBackButton. - */ - public NbiButton getBackButton() { - return backButton; - } - - /** - * Returns the Swing implementation of the standard Next - * button. This method is called by the {@link SwingFrameContainer} when it - * needs to get the handle of the button. - * - * @return Next button instance. - * @see SwingFrameContainer#getNextButton. - */ - public NbiButton getNextButton() { - return nextButton; - } - - /** - * Returns the Swing implementation of the standard Cancel - * button. This method is called by the {@link SwingFrameContainer} when it - * needs to get the handle of the button. - * - * @return Cancel button instance. - * @see SwingFrameContainer#getCancelButton. - */ - public NbiButton getCancelButton() { - return cancelButton; - } - - // private ////////////////////////////////////////////////////////////////// - /** - * Initializes and lays out the swing components required by the content - * pane. - */ - private void initComponents() { - // titleLabel /////////////////////////////////////////////////////////// - titleLabel = new NbiLabel(); - titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); - - // descriptionPane ////////////////////////////////////////////////////// - descriptionPane = new NbiTextPane(); - - NbiPanel titleDescriptionPanel = new NbiPanel(); - titleDescriptionPanel.setLayout(new GridBagLayout()); - titleDescriptionPanel.setOpaque(true); - - // titlePanel /////////////////////////////////////////////////////////// - titlePanel = new NbiPanel(); - - titlePanel.setLayout(new GridBagLayout()); - titlePanel.setOpaque(true); - titlePanel.setBackground(Color.WHITE); - titleDescriptionPanel.setBackground(Color.WHITE); - - final String backgroundImageUri = System.getProperty(WIZARD_FRAME_HEAD_BACKGROUND_IMAGE_URI_PROPERTY); - if(backgroundImageUri != null) { - titleDescriptionPanel.setBackgroundImage(backgroundImageUri, NbiPanel.ANCHOR_TOP); - } else { - titleDescriptionPanel.setBackground(Color.WHITE); - } - - final String leftImageUri = System.getProperty(WIZARD_FRAME_HEAD_LEFT_IMAGE_URI_PROPERTY); - int titlePanelDx = 0; - if(leftImageUri!=null) { - titleDescriptionImageLeftPanel = new NbiPanel(); - titleDescriptionImageLeftPanel .setBackgroundImage(leftImageUri , NbiPanel.ANCHOR_TOP_RIGHT); - final ImageIcon icon = titleDescriptionImageLeftPanel .getBackgroundImage(NbiPanel.ANCHOR_TOP_RIGHT); - titleDescriptionImageLeftPanel .setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); - titleDescriptionImageLeftPanel .setPreferredSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageLeftPanel .setMaximumSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageLeftPanel .setMinimumSize(new Dimension(icon.getIconWidth(),0)); - titleDescriptionImageLeftPanel .setSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageLeftPanel .setOpaque(false); - titlePanel.add(titleDescriptionImageLeftPanel , new GridBagConstraints( - titlePanelDx++, 0, // x, y - 1, 2, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.NORTH, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - } - - final String rightImageUri = System.getProperty(WIZARD_FRAME_HEAD_RIGHT_IMAGE_URI_PROPERTY); - if(rightImageUri!=null) { - titleDescriptionImageRightPanel = new NbiPanel(); - titleDescriptionImageRightPanel.setBackgroundImage(rightImageUri , NbiPanel.ANCHOR_TOP_RIGHT); - final ImageIcon icon = titleDescriptionImageRightPanel.getBackgroundImage(NbiPanel.ANCHOR_TOP_RIGHT); - titleDescriptionImageRightPanel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); - titleDescriptionImageRightPanel.setPreferredSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageRightPanel.setMaximumSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageRightPanel.setMinimumSize(new Dimension(icon.getIconWidth(),0)); - titleDescriptionImageRightPanel.setSize(new Dimension(icon.getIconWidth(),icon.getIconHeight())); - titleDescriptionImageRightPanel.setOpaque(false); - titlePanel.add(titleDescriptionImageRightPanel, new GridBagConstraints( - titlePanelDx + 1, 0, // x, y - 1, 2, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.NORTH, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - } - - // topSeparator ///////////////////////////////////////////////////////// - topSeparator = new NbiSeparator(); - if (SystemUtils.isMacOS()) { - // JSeparator`s height on Aqua L&F equals to 12px which is too much in SwingFrameContainer - // thus we descrease it to 7px - // TODO: possibly move this code to NbiSeparator later - Dimension d = topSeparator.getPreferredSize(); - if (d != null && d.getHeight() == 12) { - d.setSize(d.getWidth(), 7); - topSeparator.setPreferredSize(d); - } - } - - titleDescriptionPanel.add(titleLabel, new GridBagConstraints( - 0 , 0, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(11, 11, 0, 11), // padding - 0, 0)); // padx, pady - ??? - titleDescriptionPanel.add(descriptionPane, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.PAGE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(6, 22, 4, 11), // padding - 0, 0)); // padx, pady - ??? - - titlePanel.add(titleDescriptionPanel, new GridBagConstraints( - titlePanelDx , 0, // x, y - 1, 2, // width, height - 1.0, 1.0, // weight-x, weight-y - GridBagConstraints.LINE_START, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - - titlePanel.add(topSeparator, new GridBagConstraints( - 0, 2, // x, y - 2 + titlePanelDx, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - - // bottomSeparator ////////////////////////////////////////////////////// - bottomSeparator = new NbiSeparator(); - if (SystemUtils.isMacOS()) { - // JSeparator`s height on Aqua L&F equals to 12px which is too much in SwingFrameContainer - // thus we descrease it to 7px - // TODO: possibly move this code to NbiSeparator later - Dimension d = topSeparator.getPreferredSize(); - if (d != null && d.getHeight() == 12) { - d.setSize(d.getWidth(), 7); - topSeparator.setPreferredSize(d); - } - } - // helpButton /////////////////////////////////////////////////////////// - helpButton = new NbiButton(); - - // backButton /////////////////////////////////////////////////////////// - backButton = new NbiButton(); - - // nextButton /////////////////////////////////////////////////////////// - nextButton = new NbiButton(); - - // cancelButton ///////////////////////////////////////////////////////// - cancelButton = new NbiButton(); - - // spacerPanel ////////////////////////////////////////////////////////// - spacerPanel = new NbiPanel(); - - // buttonsPanel ///////////////////////////////////////////////////////// - buttonsPanel = new NbiPanel(); - - buttonsPanel.add(bottomSeparator, new GridBagConstraints( - 0, 0, // x, y - 5, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.HORIZONTAL, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - buttonsPanel.add(helpButton, new GridBagConstraints( - 0, 1, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(11, 11, 11, 11), // padding - 0, 0)); // padx, pady - ??? - buttonsPanel.add(spacerPanel, new GridBagConstraints( - 1, 1, // x, y - 1, 1, // width, height - 1.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.BOTH, // fill - new Insets(0, 0, 0, 0), // padding - 0, 0)); // padx, pady - ??? - buttonsPanel.add(backButton, new GridBagConstraints( - 2, 1, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(11, 0, 11, 6), // padding - 0, 0)); // padx, pady - ??? - buttonsPanel.add(nextButton, new GridBagConstraints( - 3, 1, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(11, 0, 11, 11), // padding - 0, 0)); // padx, pady - ??? - buttonsPanel.add(cancelButton, new GridBagConstraints( - 4, 1, // x, y - 1, 1, // width, height - 0.0, 0.0, // weight-x, weight-y - GridBagConstraints.CENTER, // anchor - GridBagConstraints.NONE, // fill - new Insets(11, 0, 11, 11), // padding - 0, 0)); // padx, pady - ??? - - // currentPanel ///////////////////////////////////////////////////////// - currentPanel = new NbiPanel(); - - // this ///////////////////////////////////////////////////////////////// - setLayout(new BorderLayout()); - - add(titlePanel, BorderLayout.PAGE_START); - add(currentPanel, BorderLayout.CENTER); - add(buttonsPanel, BorderLayout.PAGE_END); - - // debugging plug /////////////////////////////////////////////////////// - //KeyboardFocusManager.getCurrentKeyboardFocusManager(). - // addPropertyChangeListener(new PropertyChangeListener() { - // public void propertyChange(PropertyChangeEvent event) { - // if (event.getPropertyName().equals("focusOwner")) { - // if (event.getNewValue() != null) { - // System.out.println(event.getNewValue()); - // } - // } - // } - //}); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Name of the system property which is expected to contain the desired value - * for the initial width of the wizard frame. - */ - public static final String WIZARD_FRAME_WIDTH_PROPERTY = - "nbi.wizard.ui.swing.frame.width"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the minimum width of the wizard frame. - */ - public static final String WIZARD_FRAME_MINIMUM_WIDTH_PROPERTY = - "nbi.wizard.ui.swing.frame.minimum.width"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the maximum width of the wizard frame. - */ - public static final String WIZARD_FRAME_MAXIMUM_WIDTH_PROPERTY = - "nbi.wizard.ui.swing.frame.maximum.width"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the initial height of the wizard frame. - */ - public static final String WIZARD_FRAME_HEIGHT_PROPERTY = - "nbi.wizard.ui.swing.frame.height"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the minimum height of the wizard frame. - */ - public static final String WIZARD_FRAME_MINIMUM_HEIGHT_PROPERTY = - "nbi.wizard.ui.swing.frame.minimum.height"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the maximum height of the wizard frame. - */ - public static final String WIZARD_FRAME_MAXIMUM_HEIGHT_PROPERTY = - "nbi.wizard.ui.swing.frame.maximum.height"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the URI of the wizard frame icon. - */ - public static final String WIZARD_FRAME_ICON_URI_PROPERTY = - "nbi.wizard.ui.swing.frame.icon"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the standard prefix of the wizard frame's title. - */ - public static final String WIZARD_FRAME_TITLE_PREFIX_PROPERTY = - "nbi.wizard.ui.swing.frame.title.prefix"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the URI of the wizard frame head background image (right side). - */ - public static final String WIZARD_FRAME_HEAD_RIGHT_IMAGE_URI_PROPERTY = - "nbi.wizard.ui.swing.frame.head.right.image"; // NOI18N - /** - * Name of the system property which is expected to contain the desired value - * for the URI of the wizard frame head background image (left side). - */ - public static final String WIZARD_FRAME_HEAD_LEFT_IMAGE_URI_PROPERTY = - "nbi.wizard.ui.swing.frame.head.left.image"; // NOI18N - - public static final String WIZARD_FRAME_HEAD_BACKGROUND_IMAGE_URI_PROPERTY = - "nbi.wizard.ui.swing.frame.head.background.image"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the pattern for merging the standard title prefix with the component's - * title. - */ - public static final String WIZARD_FRAME_TITLE_PATTERN_PROPERTY = - "nbi.wizard.ui.swing.frame.title.pattern"; // NOI18N - - /** - * Name of the system property which is expected to contain the desired value - * for the making the wizard window be resizable. - *
If this property is not set at all or set to any string different from - * "false" and "FALSE" then the wizard is resiazable. - */ - public static final String WIZARD_FRAME_RESIZABLE_PROPERTY = - "nbi.wizard.ui.swing.frame.resizable"; // NOI18N - - /** - * Default value for the wizard frame's initial width. - */ - public static final int DEFAULT_WIZARD_FRAME_WIDTH = - NbiFrame.DEFAULT_FRAME_WIDTH; - - /** - * Default value for the wizard frame's minimum width. - */ - public static final int DEFAULT_WIZARD_FRAME_MINIMUM_WIDTH = - NbiFrame.DEFAULT_FRAME_MINIMUM_WIDTH; - - /** - * Default value for the wizard frame's maximum width. - */ - public static final int DEFAULT_WIZARD_FRAME_MAXIMUM_WIDTH = - NbiFrame.DEFAULT_FRAME_MAXIMUM_WIDTH; - - /** - * Default value for the wizard frame's initial height. - */ - public static final int DEFAULT_WIZARD_FRAME_HEIGHT = - NbiFrame.DEFAULT_FRAME_HEIGHT; - - /** - * Default value for the wizard frame's minimum height. - */ - public static final int DEFAULT_WIZARD_FRAME_MINIMUM_HEIGHT = - NbiFrame.DEFAULT_FRAME_MINIMUM_WIDTH; - - /** - * Default value for the wizard frame's maximum height. - */ - public static final int DEFAULT_WIZARD_FRAME_MAXIMUM_HEIGHT = - NbiFrame.DEFAULT_FRAME_MAXIMUM_HEIGHT; - - /** - * Default value for the wizard frame's icon's URI. - */ - public static final String DEFAULT_WIZARD_FRAME_ICON_URI = - NbiFrame.DEFAULT_FRAME_ICON_URI; - - /** - * Default value for the wizard frame's standard title prefix. - */ - public static final String DEFAULT_WIZARD_FRAME_TITLE_PREFIX = - ResourceUtils.getString(SwingFrameContainer.class, - "SFC.frame.title.prefix"); // NOI18N - - /** - * Default value for the pattern for merging the standard title prefix with the - * component's title. - */ - public static final String DEFAULT_WIZARD_FRAME_TITLE_PATTERN = - ResourceUtils.getString(SwingFrameContainer.class, - "SFC.frame.title.pattern"); // NOI18N - - // private ////////////////////////////////////////////////////////////////////// - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON = - "SFC.error.failed.to.download.icon"; // NOI18N - private static final String RESOURCE_ERROR_SET_CLOSE_OPERATION = - "SFC.error.close.operation"; //NOI18N - private static final String RESOURCE_FAILED_TO_SET_FRAME_CONTAINER_ICON = - "SFC.error.failed.to.set.icon";//NOI18N - /** - * Name of a resource bundle entry. - */ - private static final String RESOURCE_FAILED_TO_ATTACH_ERROR_HANDLER = - "SFC.error.failed.to.attach.error.handler"; // NOI18N - - /** - * Name of the {@link AbstractAction} which is invoked when the user presses the - * Escape button. - */ - private static final String CANCEL_ACTION_NAME = - "evaluate.cancel"; // NOI18N - - private static final int EXTRA_SIZE = 15; -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/containers/WizardContainer.java b/nbi/engine/src/org/netbeans/installer/wizard/containers/WizardContainer.java deleted file mode 100644 index 233865c7b5d8..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/containers/WizardContainer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.containers; - -import org.netbeans.installer.wizard.ui.WizardUi; - -/** - * This interface represents the container for the UI of a {@link WizardComponent}. - * Each {@link Wizard} "owns" an instance of this class and uses it to initialize - * the UI of its active component. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public interface WizardContainer { - /** - * Shows or hides the container. The behavior of this method is - * component-specific. A frame would probably map this method directly, while - * a console-mode container could draw itself or clear the screen. - * - * @param visible Whether to show the container - true, or hide - * it - false. - */ - void setVisible(final boolean visible); - - /** - * Updates the container with a new UI. This method is usually called by the - * wizard when the active component changes - the wizard wants to display its - * UI. - * - * @param ui UI which needs to be shown. - */ - void updateWizardUi(final WizardUi ui); - - /** - * Opens(creates) the container. This method is usually called by the wizard upon - * container initialization - * - */ - void open(); - - /** - * Closes(destroyes) the container. This method is usually called by the wizard upon - * container closing - * - */ - void close(); - -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/ui/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/ui/Bundle.properties deleted file mode 100644 index 57acfb437507..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/ui/Bundle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### diff --git a/nbi/engine/src/org/netbeans/installer/wizard/ui/SwingUi.java b/nbi/engine/src/org/netbeans/installer/wizard/ui/SwingUi.java deleted file mode 100644 index 0ec6ff4379a2..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/ui/SwingUi.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.ui; - -import javax.swing.JComponent; -import org.netbeans.installer.utils.helper.swing.NbiButton; -import org.netbeans.installer.utils.helper.swing.NbiPanel; - -/** - * This class represents the UI of a {@link WizardComponent} for the - * {@link UiMode#SWING} UI mode. - * - * @author Kirill Sorokin - * @since 1.0 - */ -public abstract class SwingUi extends NbiPanel { - /** - * Returns the title of the component. The way the title is displayed is - * dependent on the container. A frame could expose the title in the windows - * heading, for example. - * - * @return Title of the component, or null if the component does - * not have a title. - */ - public abstract String getTitle(); - - /** - * Returns the description of the component. The way the description is - * displayed is dependent on the container. - * - * @return Description of the component, or null if the component - * does not have a description. - */ - public abstract String getDescription(); - - /** - * Hook, allowing the component's UI to execute some custom logic when the user - * activates the standard Help button. The expected behavior would - * be to display a help dialog which describes the required user input for the - * current component. - */ - public abstract void evaluateHelpButtonClick(); - - /** - * Hook, allowing the component's UI to execute some custom logic when the user - * activates the standard Back button. The expected behavior would - * be to call the {@link Wizard#previous()} method. - */ - public abstract void evaluateBackButtonClick(); - - /** - * Hook, allowing the component's UI to execute some custom logic when the user - * activates the standard Next button. The expected behavior would - * be to call the {@link Wizard#next()} method. - */ - public abstract void evaluateNextButtonClick(); - - /** - * Hook, allowing the component's UI to execute some custom logic when the user - * activates the standard Cancel button. The expected behavior - * would be to cancel the wizard execution. - */ - public abstract void evaluateCancelButtonClick(); - - /** - * Returns the button which should be activated when the user presses the - * Enter key. - * - * @return Default handler for the Enter key. - */ - public abstract NbiButton getDefaultEnterButton(); - - /** - * Returns the button which should be activated when the user presses the - * Escape key. - * - * @return Default handler for the Escape key. - */ - public abstract NbiButton getDefaultEscapeButton(); - - /** - * Returns the Swing component which should have focus when this UI is shown. - * - * @return Default focus owner for this UI. - */ - public abstract JComponent getDefaultFocusOwner(); -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/ui/WizardUi.java b/nbi/engine/src/org/netbeans/installer/wizard/ui/WizardUi.java deleted file mode 100644 index 13a89c7e59e6..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/ui/WizardUi.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.ui; - -import org.netbeans.installer.wizard.containers.SwingContainer; - -/** - * This class represents the UI of a wizard component. It is an abstraction over the - * set of possible UI modes for the wizard and provides factory methods which create - * objects representing component's UI for a concrete wizard UI mode, such as - * {@link SwingUi}. - * - * @see org.netbeans.installer.utils.helper.UiMode - * - * @author Kirill Sorokin - * @since 1.0 - */ -public interface WizardUi { - /** - * Creates an instance of {@link SwingUi} and initializes it with the specified - * {@link SwingContainer} object, thus initializaing the component's UI for - * {@link org.netbeans.installer.utils.helper.UiMode#SWING}. - * - * @param container Instance of {@link SwingContainer} which will "contain" the - * resulting UI. - * @return Instance of {@link SwingUi} which represents the component's UI for - * the swing UI mode. - */ - SwingUi getSwingUi(final SwingContainer container); -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/utils/Bundle.properties b/nbi/engine/src/org/netbeans/installer/wizard/utils/Bundle.properties deleted file mode 100644 index 7eae5a54b94f..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/utils/Bundle.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -IDD.installation.details.label=Installation details -IDD.component.label=Component -IDD.status.label=Status - -ILD.loading.logfile=Loading log file. Please wait... -ILD.error.reading.log=Cannot read log file {0}. -ILD.error.log.contents=Log contents are not available. diff --git a/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationDetailsDialog.java b/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationDetailsDialog.java deleted file mode 100644 index fe326b1ad872..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationDetailsDialog.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.utils; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.border.EmptyBorder; -import javax.swing.event.TreeModelListener; -import javax.swing.table.TableCellRenderer; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.helper.DetailedStatus; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.helper.swing.NbiDialog; -import org.netbeans.installer.utils.helper.swing.NbiScrollPane; -import org.netbeans.installer.utils.helper.swing.NbiTreeTableColumnCellRenderer; -import org.netbeans.installer.utils.helper.swing.NbiTreeTable; -import org.netbeans.installer.utils.helper.swing.NbiTreeTableModel; - -public class InstallationDetailsDialog extends NbiDialog { - private NbiTreeTable detailsTreeTable; - private NbiScrollPane detailsScrollPane; - private static final String TITLE_INSTALLATION_DETAILS_KEY = - "IDD.installation.details.label"; - private static final String TITLE_COMPONENTS_KEY = - "IDD.component.label"; - private static final String TITLE_STATUS_KEY = - "IDD.status.label"; - - public InstallationDetailsDialog() { - super(); - - initComponents(); - initialize(); - } - - private void initialize() { - setTitle(ResourceUtils.getString( - InstallationDetailsDialog.class, - TITLE_INSTALLATION_DETAILS_KEY)); - } - - private void initComponents() { - setLayout(new GridBagLayout()); - - detailsTreeTable = new NbiTreeTable(new InstallationDetailsTreeTableModel()); - detailsTreeTable.setShowVerticalLines(false); - detailsTreeTable.setOpaque(false); - detailsTreeTable.setTableHeader(null); - detailsTreeTable.setRowHeight(detailsTreeTable.getRowHeight() + 4); - detailsTreeTable.setIntercellSpacing(new Dimension(0, 0)); - detailsTreeTable.setTreeColumnCellRenderer(new InstallationDetailsTreeColumnCellRenderer(detailsTreeTable)); - detailsTreeTable.getColumnModel().getColumn(1).setMaxWidth(200); - detailsTreeTable.getColumnModel().getColumn(1).setMinWidth(200); - detailsTreeTable.getColumnModel().getColumn(1).setCellRenderer(new InstallationStatusCellRenderer()); - detailsTreeTable.setRowSelectionAllowed(false); - detailsTreeTable.setColumnSelectionAllowed(false); - detailsTreeTable.setCellSelectionEnabled(false); - - detailsScrollPane = new NbiScrollPane(detailsTreeTable); - - add(detailsScrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); - } - - private static class InstallationDetailsTreeModel implements TreeModel { - private List components = new ArrayList(); - private Map> propertiesMap = new HashMap>(); - - private Object root = new Object(); - - public InstallationDetailsTreeModel() { - final Registry registry = Registry.getInstance(); - - components.addAll(registry.getProducts(DetailedStatus.INSTALLED_SUCCESSFULLY)); - components.addAll(registry.getProducts(DetailedStatus.INSTALLED_WITH_WARNINGS)); - components.addAll(registry.getProducts(DetailedStatus.FAILED_TO_INSTALL)); - - components.addAll(registry.getProducts(DetailedStatus.UNINSTALLED_SUCCESSFULLY)); - components.addAll(registry.getProducts(DetailedStatus.UNINSTALLED_WITH_WARNINGS)); - components.addAll(registry.getProducts(DetailedStatus.FAILED_TO_UNINSTALL)); - } - - public Object getRoot() { - return root; - } - - public Object getChild(Object parent, int index) { - if (parent.equals(root)) { - return components.get(index); - } else { - if (parent instanceof Product) { - initComponentProperties((Product) parent); - return propertiesMap.get(parent).get(index); - } else { - return null; - } - } - } - - public int getChildCount(Object parent) { - if (parent.equals(root)) { - return components.size(); - } - - if (parent instanceof Product) { - initComponentProperties((Product) parent); - return propertiesMap.get(parent).size(); - } else { - return 0; - } - } - - private void initComponentProperties(Product component) { - List properties = propertiesMap.get(component); - if (properties == null) { - properties = new ArrayList(); - - switch (component.getDetailedStatus()) { - case INSTALLED_WITH_WARNINGS: - for (Throwable warning: component.getInstallationWarnings()) { - properties.add("Warning: " + warning.getMessage()); - } - case INSTALLED_SUCCESSFULLY: - properties.add("Installation location: " + component.getInstallationLocation()); - break; - case FAILED_TO_INSTALL: - properties.add("Error: " + component.getInstallationError().getMessage()); - break; - case UNINSTALLED_WITH_WARNINGS: - for (Throwable warning: component.getUninstallationWarnings()) { - properties.add("Warning: " + warning.getMessage()); - } - case UNINSTALLED_SUCCESSFULLY: - break; - case FAILED_TO_UNINSTALL: - properties.add("Error: " + component.getUninstallationError().getMessage()); - break; - default: - break; - } - - propertiesMap.put(component, properties); - } - } - - public boolean isLeaf(Object node) { - return !((node.equals(root)) || (node instanceof Product)); - } - - public void valueForPathChanged(TreePath path, Object newValue) { - // do nothing we are read-only - } - - public int getIndexOfChild(Object parent, Object child) { - LogManager.log(ErrorLevel.DEBUG,"getIndexOfChild"); - if (parent.equals(root)) { - return components.indexOf(child); - } else { - String string = (String) child; - if (string.startsWith("Installation Location: ")) { - return 0; - } - if (string.startsWith("Disk space:")) { - return 1; - } - return -1; - } - } - - public void addTreeModelListener(TreeModelListener listener) { - // do nothing we are read-only - } - - public void removeTreeModelListener(TreeModelListener listener) { - // do nothing we are read-only - } - } - - private static class InstallationDetailsTreeTableModel extends NbiTreeTableModel { - public InstallationDetailsTreeTableModel() { - super(new InstallationDetailsTreeModel()); - } - - public int getTreeColumnIndex() { - return 0; - } - - public int getColumnCount() { - return 2; - } - - public String getColumnName(int column) { - switch (column) { - case 0: - return ResourceUtils.getString( - InstallationDetailsDialog.class, - TITLE_COMPONENTS_KEY); - case 1: - return ResourceUtils.getString( - InstallationDetailsDialog.class, - TITLE_STATUS_KEY); - default: - return null; - } - } - - public Class getColumnClass(int column) { - return Object.class; - } - - public boolean isCellEditable(int row, int column) { - return false; - } - - public Object getValueAt(int row, int column) { - Object node = getTree().getPathForRow(row).getLastPathComponent(); - - switch (column) { - case 0: - return node; - case 1: - if (node instanceof Product) { - return ((Product) node).getDetailedStatus(); - } else { - return null; - } - default: - return null; - } - } - - public void setValueAt(Object value, int row, int column) { - // do nothing, we're read-only - } - } - - public static class InstallationDetailsTreeColumnCellRenderer extends NbiTreeTableColumnCellRenderer { - private static final EmptyBorder EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0); - private static final EmptyBorder PADDED_BORDER = new EmptyBorder(0, 0, 0, 5); - - public InstallationDetailsTreeColumnCellRenderer(final NbiTreeTable treeTable) { - super(treeTable); - } - - public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean selected, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) { - setOpaque(false); - setForeground(treeTable.getForeground()); - setBackground(treeTable.getBackground()); - - if (value instanceof Product) { - Product component = (Product) value; - - setIcon(component.getIcon()); - setText(component.getDisplayName()); - - setBorder(EMPTY_BORDER); - } else { - setIcon(null); - setText((value != null) ? value.toString() : ""); - - setBorder(PADDED_BORDER); - } - - return this; - } - } - - public static class InstallationStatusCellRenderer extends JLabel - implements TableCellRenderer { - public InstallationStatusCellRenderer() { - setBorder(new EmptyBorder(0, 5, 0, 5)); - } - - public Component getTableCellRendererComponent( - JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) { - setOpaque(false); - setBackground(table.getBackground()); - setForeground(table.getForeground()); - setText((value instanceof DetailedStatus) ? value.toString() : ""); - - return this; - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationLogDialog.java b/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationLogDialog.java deleted file mode 100644 index 5151439a6965..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/utils/InstallationLogDialog.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.wizard.utils; - -import java.awt.BorderLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.io.File; -import java.io.IOException; -import javax.swing.JScrollPane; -import javax.swing.border.EmptyBorder; -import org.netbeans.installer.utils.helper.ErrorLevel; -import org.netbeans.installer.utils.ErrorManager; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.ResourceUtils; -import org.netbeans.installer.utils.helper.swing.NbiDialog; -import org.netbeans.installer.utils.helper.swing.NbiLabel; -import org.netbeans.installer.utils.helper.swing.NbiPanel; -import org.netbeans.installer.utils.helper.swing.NbiScrollPane; -import org.netbeans.installer.utils.helper.swing.NbiTextPane; - -public class InstallationLogDialog extends NbiDialog { - private NbiTextPane logPane; - private NbiPanel logPanel; - private NbiScrollPane logScrollPane; - - private NbiLabel errorLabel; - - private File logFile; - private static final String MSG_LOADING_LOGFILE_KEY = - "ILD.loading.logfile";//NOI18N - private static final String ERROR_READING_LOGFILE_KEY = - "ILD.error.reading.log";//NOI18N - private static final String ERROR_LOG_CONTENTS = - "ILD.error.log.contents";//NOI18N - public InstallationLogDialog() { - super(); - - initComponents(); - initialize(); - } - - private void initialize() { - logFile = LogManager.getLogFile(); - - setTitle(logFile.getAbsolutePath()); - } - - private void initComponents() { - setLayout(new GridBagLayout()); - - logPane = new NbiTextPane(); - logPane.setFont(new Font("Monospaced", - logPane.getFont().getStyle(), logPane.getFont().getSize())); - - logPanel = new NbiPanel(); - logPanel.setLayout(new BorderLayout()); - logPanel.add(logPane, BorderLayout.CENTER); - - logScrollPane = new NbiScrollPane(logPanel); - logScrollPane.setViewportBorder(new EmptyBorder(new Insets(5, 5, 5, 5))); - logScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - errorLabel = new NbiLabel(); - - add(logScrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(11, 11, 11, 11), 0, 0)); - add(errorLabel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets(11, 11, 11, 11), 0, 0)); - } - - public void loadLogFile() { - try { - logScrollPane.setVisible(false); - errorLabel.setVisible(true); - - errorLabel.setText(ResourceUtils.getString( - InstallationLogDialog.class, - MSG_LOADING_LOGFILE_KEY)); - logPane.setText(FileUtils.readFile(logFile)); - logPane.setCaretPosition(0); - - logScrollPane.setVisible(true); - errorLabel.setVisible(false); - } catch (IOException e) { - ErrorManager.notify(ErrorLevel.WARNING, - ResourceUtils.getString(InstallationLogDialog.class, - ERROR_READING_LOGFILE_KEY, - logFile), - e); - - errorLabel.setText(ResourceUtils.getString( - InstallationLogDialog.class, ERROR_LOG_CONTENTS)); - - logScrollPane.setVisible(false); - errorLabel.setVisible(true); - } - } -} diff --git a/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xml b/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xml deleted file mode 100644 index 5d37138f079d..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - diff --git a/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xsd b/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xsd deleted file mode 100644 index 10e05f34a450..000000000000 --- a/nbi/engine/src/org/netbeans/installer/wizard/wizard-components.xsd +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/engine/tests/org/MyTestCase.java b/nbi/engine/tests/org/MyTestCase.java deleted file mode 100644 index fb8529799d50..000000000000 --- a/nbi/engine/tests/org/MyTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org; - -import java.io.File; -import java.io.FileInputStream; -import junit.framework.TestCase; -import java.util.logging.LogManager; -import org.netbeans.installer.utils.FileUtils; - -/** - * - * @author Danila Dugurov - */ -public class MyTestCase extends TestCase { - - public static final File testWD = new File("testWD"); - public static final File testOutput = new File("testOutput"); - - protected void setUp() throws Exception { - super.setUp(); - testWD.mkdirs(); - testOutput.mkdirs(); - } - - protected void tearDown() throws Exception { - FileUtils.deleteFile(testWD, true); - FileUtils.deleteFile(testOutput, true); - } -} diff --git a/nbi/engine/tests/org/RunAllSuite.java b/nbi/engine/tests/org/RunAllSuite.java deleted file mode 100644 index 04b00760c32d..000000000000 --- a/nbi/engine/tests/org/RunAllSuite.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org; - -import junit.framework.TestSuite; -import org.util.DomVisitorTest; - -/** - * - * @author Danila_Dugurov - */ -public class RunAllSuite extends TestSuite { - - public RunAllSuite() { - addTestSuite(DomVisitorTest.class); - //addTestSuite(WindowsRegistryTest.class); - //todo: dinamic add test case without manual registration - } - //this done only becouse without it netbeans faild to run tests - public void testFake() {} -} diff --git a/nbi/engine/tests/org/registry/TestCircles.java b/nbi/engine/tests/org/registry/TestCircles.java deleted file mode 100644 index 2f9a7e978c8d..000000000000 --- a/nbi/engine/tests/org/registry/TestCircles.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.registry; -import junit.framework.TestCase; - -/** - * - * @author Danila_Dugurov - */ - -public class TestCircles extends TestCase { - /* - private List list; - - public void testThingInSelf() { - try { - list = new LinkedList(); - Product component = new Product(); - component.addRequirement(component); - list.add(component); - checkCircles(); - fail(); - } catch (UnresolvedDependencyException ex) { - } - } - - public void testMoreSofisticatedRequirements() { - try { - list = new LinkedList(); - Product component = new Product(); - Product depp = new Product(); - Product jony = new Product(); - list.add(component); - list.add(depp); - list.add(jony); - component.addRequirement(depp); - depp.addRequirement(jony); - jony.addRequirement(component); - checkCircles(); - fail(); - } catch (UnresolvedDependencyException ex) { - } - } - - public void testRequirementsAndConflicts() { - try { - list = new LinkedList(); - Product component = new Product(); - Product depp = new Product(); - Product jonny = new Product(); - list.add(component); - list.add(depp); - list.add(jonny); - component.addRequirement(depp); - depp.addRequirement(jonny); - jonny.addConflict(component); - checkCircles(); - fail(); - } catch (UnresolvedDependencyException ex) { - } - } - - public void testSofisticatedRequirementsAndConflicts() { - try { - list = new LinkedList(); - Product root = new Product(); - Product depp = new Product(); - Product jonny = new Product(); - Product independant = new Product(); - list.add(root); - list.add(depp); - list.add(jonny); - list.add(independant); - root.addRequirement(depp); - root.addRequirement(jonny); - jonny.addConflict(depp); - jonny.addRequirement(independant); - depp.addRequirement(independant); - checkCircles(); - fail(); - } catch (UnresolvedDependencyException ex) { - } - } - - public void testOkConflicts() { - try { - list = new LinkedList(); - Product root = new Product(); - Product depp = new Product(); - Product jonny = new Product(); - list.add(depp); - list.add(jonny); - list.add(root); - root.addConflict(depp); - root.addConflict(jonny); - jonny.addRequirement(depp); - checkCircles(); - } catch (UnresolvedDependencyException ex) { - fail(); - } - } - - private void checkCircles() throws UnresolvedDependencyException { - for (Product component : list) { - final Stack visited = new Stack(); - final Set conflictSet = new HashSet(); - final Set requirementSet = new HashSet(); - checkCircles(component, visited, conflictSet, requirementSet); - } - } - - private void checkCircles(Product component, Stack visited, - Set conflictSet, Set requirementSet) - throws UnresolvedDependencyException { - if (visited.contains(component) || conflictSet.contains(component)) - throw new UnresolvedDependencyException("circles found"); - visited.push(component); - requirementSet.add(component); - if (!Collections.disjoint(requirementSet, component.getConflicts())) - throw new UnresolvedDependencyException("circles found"); - conflictSet.addAll(component.getConflicts()); - for (Product comp : component.getRequirements()) - checkCircles(comp, visited, conflictSet, requirementSet); - visited.pop(); - }*/ - public void testNone() { - } -} diff --git a/nbi/engine/tests/org/server/AbstractServer.java b/nbi/engine/tests/org/server/AbstractServer.java deleted file mode 100644 index 3a50bc46376c..000000000000 --- a/nbi/engine/tests/org/server/AbstractServer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.server; - -/** - * - * @author Danila_Dugurov - */ -public abstract class AbstractServer { - - protected final int serverPort; - protected final String testDataPath; - - protected AbstractServer(String testDataPath, int serverPort) { - this.testDataPath = testDataPath; - this.serverPort = serverPort; - } - - public abstract void start() throws Exception; - public abstract void stop() throws Exception; -} diff --git a/nbi/engine/tests/org/server/TestDataGenerator.java b/nbi/engine/tests/org/server/TestDataGenerator.java deleted file mode 100644 index 544576b48c8e..000000000000 --- a/nbi/engine/tests/org/server/TestDataGenerator.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.server; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import org.*; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.exceptions.UnexpectedExceptionError; - -/** - * - * @author Danila_Dugurov - */ -public class TestDataGenerator { - - public static final int K_BYTE = 1024; - public static final int M_BYTE = 1024 * K_BYTE; - - File dirToGenerate; - - public static final String[] testFiles = new String[] { - "smallest.data", - "small.data", - "smallaverage.data", - "bigaverage.data", - "big.data", - "bigest.data"}; - - public static final int[] testFileSizes = new int[] { - K_BYTE - 435, - M_BYTE - 237 * K_BYTE - 1, - 10 * M_BYTE - 139 * K_BYTE - 23, - 50 * M_BYTE - K_BYTE - 758, - 100 * M_BYTE - 3, - 200 * M_BYTE - }; - - public static final byte MAGIC_BYTE = (byte) 201; - - public static final byte[] buffer = new byte[4096]; - - static { - for (int i = 0; i < buffer.length; i++) { - buffer[i] = MAGIC_BYTE; - } - } - - public static final URL[] testUrls = new URL[testFiles.length]; - - static { - try { - for (int i = 0 ; i < testUrls.length; i++) { - testUrls[i] = new URL("http://localhost:" + WithServerTestCase.PORT + "/" + testFiles[i]); - } - } catch (MalformedURLException mustNotHappend) { - throw new UnexpectedExceptionError("wrong urls!", mustNotHappend); - } - } - - public TestDataGenerator(String dirToGenerate) { - this.dirToGenerate = new File(dirToGenerate); - this.dirToGenerate.mkdirs(); - } - - public void generateTestData() throws IOException { - for (int index = 0; index < testFiles.length; index++) { - final File file = new File(dirToGenerate, testFiles[index]); - if (file.exists()) continue; - fillWithMagicBytes(file, index); - } - } - - private void fillWithMagicBytes(File testFile, int index) throws IOException { - OutputStream out = new BufferedOutputStream(new FileOutputStream(testFile)); - int alreadyWritten = 0; - while (alreadyWritten < testFileSizes[index]) { - int writeCount = alreadyWritten + buffer.length <= testFileSizes[index] ? buffer.length : testFileSizes[index] - alreadyWritten; - out.write(buffer, 0, writeCount); - alreadyWritten += writeCount; - } - out.flush(); - out.close(); - } - - public void deleteTestData() { - for (int index = 0; index < testFiles.length; index++) { - final File file = new File(dirToGenerate, testFiles[index]); - file.delete(); - } - } -} diff --git a/nbi/engine/tests/org/server/WithServerTestCase.java b/nbi/engine/tests/org/server/WithServerTestCase.java deleted file mode 100644 index 52c27056fa2d..000000000000 --- a/nbi/engine/tests/org/server/WithServerTestCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.server; - -import org.*; -import org.server.impl.DefaultJettyServer; - -/** - * - * @author Danila_Dugurov - */ -/** - *this test case which invoke test server and generate test data, offcouse if wasn't generated yet. - */ -public class WithServerTestCase extends MyTestCase { - - public static final int PORT = 8080; - - private final AbstractServer server = new DefaultJettyServer("testData", PORT); - private final TestDataGenerator dataGenerator = new TestDataGenerator("testData"); - - protected void setUp() throws Exception { - super.setUp(); - dataGenerator.generateTestData(); - server.start(); - } - - protected void tearDown() throws Exception { - server.stop(); - dataGenerator.deleteTestData(); - //this method is depricated because test data rather big - //and it's not good idea to delete and generate it after every test. - super.tearDown(); - } -} diff --git a/nbi/engine/tests/org/server/impl/DefaultJettyServer.java b/nbi/engine/tests/org/server/impl/DefaultJettyServer.java deleted file mode 100644 index ef936c33f89e..000000000000 --- a/nbi/engine/tests/org/server/impl/DefaultJettyServer.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.server.impl; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.*; -import org.mortbay.jetty.Handler; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.handler.ContextHandler; -import org.mortbay.jetty.handler.DefaultHandler; -import org.mortbay.jetty.handler.ResourceHandler; -import org.mortbay.jetty.servlet.Context; -import org.mortbay.jetty.servlet.ServletHandler; -import org.mortbay.jetty.servlet.ServletHolder; -import org.server.*; - -/** - * - * @author Danila_Dugurov - */ -public class DefaultJettyServer extends AbstractServer { - - private Server httpServer; - - public DefaultJettyServer(String testDataPath, int serverPort) { - super(testDataPath, serverPort); - } - - public void start() throws Exception { - if (httpServer == null) httpServer = new Server(serverPort); - if (httpServer.isRunning()) return; - final ResourceHandler handler = new ResourceHandler(); - handler.setResourceBase(testDataPath); -// Context redirect = new Context(httpServer,"/",Context.SESSIONS); - // redirect.addServlet(new ServletHolder(new RedirectServlet()), "/redirect/*"); - ServletHandler redirectServlet = new ServletHandler(); - redirectServlet.addServletWithMapping(RedirectServlet.class, "/redirect/*"); - httpServer.addHandler(handler); - httpServer.addHandler(redirectServlet); - httpServer.start(); - } - - public void stop() throws Exception { - if (httpServer == null && httpServer.isStopped()) return; - httpServer.stop(); - } -} diff --git a/nbi/engine/tests/org/server/impl/RedirectServlet.java b/nbi/engine/tests/org/server/impl/RedirectServlet.java deleted file mode 100644 index 6f243170b358..000000000000 --- a/nbi/engine/tests/org/server/impl/RedirectServlet.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.server.impl; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Danila_Dugurov - */ -public class RedirectServlet extends HttpServlet { - - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - final String fileName = req.getPathInfo().substring(req.getPathInfo().lastIndexOf("/") + 1); - final String path = req.getPathInfo().substring(0,req.getPathInfo().lastIndexOf("/")); - resp.sendRedirect("/" + fileName); - } -} diff --git a/nbi/engine/tests/org/util/DomVisitorTest.java b/nbi/engine/tests/org/util/DomVisitorTest.java deleted file mode 100644 index 737b146e9710..000000000000 --- a/nbi/engine/tests/org/util/DomVisitorTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.util; - -import java.util.LinkedList; -import java.util.List; - -import org.MyTestCase; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.xml.DomExternalizable; -import org.netbeans.installer.utils.xml.DomUtil; -import org.netbeans.installer.utils.xml.visitors.DomVisitor; -import org.netbeans.installer.utils.xml.visitors.RecursiveDomVisitor; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * - * @author Danila_Dugurov - */ - -public class DomVisitorTest extends MyTestCase { - - public void testSimpleVisitor() { - MyComponent component1 = new MyComponent("one", "leaf", 10); - MyComponent component2 = new MyComponent("two", "composite", 20); - MyComponent component3 = new MyComponent("three", "composite", 30); - MyComponent component4 = new MyComponent("four", "leaf", 40); - MyComponent component5 = new MyComponent("five", "leaf", 50); - final List deserialized = new LinkedList(); - try { - final Document document = DomUtil.parseXmlFile(""); - Element root = document.getDocumentElement(); - - DomUtil.addChild(root, component1); - DomUtil.addChild(root, component2); - DomUtil.addChild(root, component3); - DomUtil.addChild(root, component4); - DomUtil.addChild(root, component5); - - DomVisitor visitor = new RecursiveDomVisitor() { - public void visit(Element element) { - if ("component".equals(element.getNodeName())) { - final MyComponent component = new MyComponent(); - component.readXML(element); - deserialized.add(component); - } else - super.visit(element); - } - }; - visitor.visit(document); - } catch(ParseException wontHappend) { - } - assertEquals(component1, deserialized.get(0)); - assertEquals(component2, deserialized.get(1)); - assertEquals(component3, deserialized.get(2)); - assertEquals(component4, deserialized.get(3)); - assertEquals(component5, deserialized.get(4)); - System.out.println(component1); - System.out.println(component2); - System.out.println(component3); - System.out.println(component4); - System.out.println(component5); - } -} -class MyComponent implements DomExternalizable { - String name; - - String type; - - int cost; - - public MyComponent(String name, String type, int cost) { - this.name = name; - this.type = type; - this.cost = cost; - } - - public MyComponent() { - - } - - public void readXML(Element element) { - final RecursiveDomVisitor visitor = new RecursiveDomVisitor() { - public void visit(Element element) { - if ("name".equals(element.getNodeName())) { - name = element.getTextContent(); - } else if ("type".equals(element.getNodeName())) { - type = element.getTextContent(); - } else if ("cost".equals(element.getNodeName())) { - cost = Integer.parseInt(element.getTextContent()); - } else super.visit(element); - } - }; - visitor.visit(element); - } - - public Element writeXML(Document document) { - final Element root = document.createElement("component"); - Element element = document.createElement("name"); - element.setTextContent(name); - root.appendChild(element); - element = document.createElement("type"); - element.setTextContent(type); - root.appendChild(element); - element = document.createElement("cost"); - element.setTextContent(String.valueOf(cost)); - root.appendChild(element); - return root; - } - - public String toString() { - return "name: " + name + " type: " + type + " cost: " + cost; - } - - @Override - public boolean equals(Object other) { - if (other == null) return false; - if (other instanceof MyComponent) { - final MyComponent component = (MyComponent) other; - return component.name.equals(this.name) && - component.type.equals(this.type) && - component.cost == this.cost; - }//TODO: nullPointer he he. - return false; - } - - @Override - public int hashCode() { - return -1;//TODO: he-he - } - -} diff --git a/nbi/engine/tests/org/util/system/WindowsRegistryTest.java b/nbi/engine/tests/org/util/system/WindowsRegistryTest.java deleted file mode 100644 index 3bbdb038823a..000000000000 --- a/nbi/engine/tests/org/util/system/WindowsRegistryTest.java +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.util.system; - -import junit.framework.*; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.system.WindowsNativeUtils; -import org.netbeans.installer.utils.system.windows.*; - -/** - * - * @author dlm198383 - */ -public class WindowsRegistryTest extends TestCase { - private static WindowsRegistry registry = null; - private SystemUtils su = null; - private String sep = "\\"; - private int HKLM = WindowsRegistry.HKEY_LOCAL_MACHINE; - private int HKCU = WindowsRegistry.HKEY_CURRENT_USER; - private int HKCC = WindowsRegistry.HKEY_CURRENT_CONFIG; - private int HKCR = WindowsRegistry.HKEY_CLASSES_ROOT; - private int HKU = WindowsRegistry.HKEY_USERS; - private String sw = "Software"; - String subkey = "WindowsRegistryTest"; - String valueName = "Name"; - String stringValue = "Value"; - - public WindowsRegistryTest(String testName) { - super(testName); - } - /* - protected void setUp() throws Exception { - init(); - } - - protected void tearDown() throws Exception { - } - - private void init() { - if(su==null) { - su = SystemUtils.getInstance(); - if(su instanceof WindowsNativeUtils) { - registry = ((WindowsNativeUtils)su).getWindowsRegistry(); - } - - } - } - public void testInitialize() { - init(); - } - - - public void testNullKeysAndValues() { - if(!registry.isKeyExists(HKCU, "")) { - fail(); - return; - } - if(registry.isValueExists(HKCU, null, null)) { - fail(); - return; - } - if(!registry.isKeyEmpty(HKCU, null)) { - fail(); - return; - } - if(registry.getStringValue(HKCU, null,null)!=null) { - fail(); - return; - } - if(registry.getBinaryValue(HKCU, null,null)!=null) { - fail(); - return; - } - if(registry.getMultiStringValue(HKCU, null,null)!=null) { - fail(); - return; - } - if(registry.get32BitValue(HKCU, null,null)!=-1) { - fail(); - return; - } - if(registry.isKeyExists(HKCU,subkey)) { - if(!registry.deleteKey(HKCU,subkey)) { - fail(); - } - } - if(!registry.createKey(HKCU,null,subkey)) { - fail(); - } - if(registry.deleteKey(HKCU,subkey,null)) { - fail(); - } - if(registry.createKey(HKCU,null,subkey)) { - fail(); - } - if(registry.deleteKey(HKCU,null,null)) { - fail(); - } - if(registry.createKey(HKCU,null,subkey)) { - fail(); - } - if(registry.deleteKey(HKCU,null)) { - fail(); - } - if(!registry.deleteKey(HKCU,null,subkey)) { - fail(); - } - return; - } - - public void testIsKeyExists() { - - String keys = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; - if(registry.isKeyExists(HKCU, keys)) { - return; - } - fail(); - } - - - public void testIsValueExists() { - if(!registry.isValueExists(HKCU, - "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", - "User Agent")) { - fail(); - } - - } - - public void testIsKeyEmpty() { - if(!registry.isKeyEmpty( - HKCU, - "Software\\Microsoft\\Windows")) { - fail(); - } - } - - - public void testAddRemoveStringValue() { - - if(registry.isKeyExists(HKCU,sw + sep + subkey)) { - if(!registry.deleteKey(HKCU,sw,subkey)) { - fail("Can`t delete key"); - } - } - - if(!registry.createKey(HKCU,sw,subkey)) { - fail("Can`t create key"); - } - - - if(registry.isValueExists(HKCU,sw + sep + subkey,valueName)) { - if(!registry.deleteValue(HKCU,sw + sep + subkey, valueName)) { - fail("Can`t delete value"); - } - } - - if(!registry.setStringValue(HKCU,sw + sep + subkey, valueName, stringValue, false)) { - fail("Can`t set string value"); - } - - String getV = registry.getStringValue(HKCU,sw + sep + subkey, valueName, false); - - if(getV == null) { - fail("getStringValue return null"); - } - - if(!getV.equals(stringValue)) { - fail("\n\ngetStringValue returned \"" + getV + "\"!=\""+stringValue + "\"\n"); - } - - if(!registry.setStringValue(HKCU,sw + sep + subkey, valueName, stringValue, false)) { - fail("Can`t set string value"); - } - - String env = "USERPROFILE"; - String value = System.getenv(env); - if(value==null) { - env = "TEMP"; - value = System.getenv(env); - } - if(value==null) { - env = "SYSTEMROOT"; - value = System.getenv(env); - } - if(value!=null) { - if(!registry.setStringValue(HKCU,sw + sep + subkey, valueName, "%" + env +"%", true)) { - fail("Can`t set string value"); - } - getV = registry.getStringValue(HKCU,sw + sep + subkey, valueName, true); - - if(getV == null) { - fail("getStringValue return null"); - } - - if(!getV.equals(value)) { - fail("\n\ngetStringValue returned \"" + getV + "\"!=\""+value + "\"\n"); - } - } - - if(!registry.deleteValue(HKCU,sw + sep + subkey, valueName)) { - fail(); - } - if(!registry.deleteKey(HKCU,sw,subkey)) { - fail("Can`t delete key"); - } - } - - public void testAddRemoveKey() { - - if(registry.isKeyExists(HKCU,sw + sep + subkey)) { - if(!registry.deleteKey(HKCU,sw, subkey)) { - fail("Can`t delete key"); - } - } - - if(!registry.createKey(HKCU,sw,subkey)) { - fail("Can`t create key"); - } - - if(!registry.deleteKey(HKCU,sw, subkey)) { - fail("Can`t delete key"); - } - } - public void testAddRemoveBinaryValue() { - if(registry.isKeyExists(HKCU,sw + sep + subkey)) { - if(!registry.deleteKey(HKCU,sw,subkey)) { - fail("Can`t delete key"); - } - } - - if(!registry.createKey(HKCU,sw,subkey)) { - fail("Can`t create key"); - } - - - if(registry.isValueExists(HKCU,sw + sep + subkey,valueName)) { - if(!registry.deleteValue(HKCU,sw + sep + subkey, valueName)) { - fail("Can`t delete value"); - } - } - byte [] data = new byte [] {0,Byte.MIN_VALUE,Byte.MIN_VALUE/2, Byte.MAX_VALUE, Byte.MAX_VALUE/2}; - - if(!registry.setBinaryValue(HKCU,sw + sep + subkey, valueName, data)) { - fail("Can`t set string value"); - } - byte [] getV = registry.getBinaryValue(HKCU,sw + sep + subkey, valueName); - if(getV == null) { - fail("getBinaryValue return null"); - } - - if(getV.length!=data.length) { - fail("getBinaryValue return unexpected length of data"); - } - for(int i=0;i - - - - - - - Builds, tests, and runs the project NBI Ant Tasks. - - - diff --git a/nbi/infra/build/.ant-lib/nbproject/build-impl.xml b/nbi/infra/build/.ant-lib/nbproject/build-impl.xml deleted file mode 100644 index 149e16949ae8..000000000000 --- a/nbi/infra/build/.ant-lib/nbproject/build-impl.xml +++ /dev/null @@ -1,1079 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set src.src-registries-management.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/build/.ant-lib/nbproject/genfiles.properties b/nbi/infra/build/.ant-lib/nbproject/genfiles.properties deleted file mode 100644 index a58489633b7c..000000000000 --- a/nbi/infra/build/.ant-lib/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=2fa8d85b -build.xml.script.CRC32=96f1a860 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=bbd5c38e -nbproject/build-impl.xml.script.CRC32=33b0815a -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/build/.ant-lib/nbproject/project.properties b/nbi/infra/build/.ant-lib/nbproject/project.properties deleted file mode 100644 index 1ebc46567f88..000000000000 --- a/nbi/infra/build/.ant-lib/nbproject/project.properties +++ /dev/null @@ -1,93 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -application.title=NBI Ant Tasks Library -application.vendor=Kirill Sorokin -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/nbi-ant-tasks.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${ant.core.lib}:\ - ${reference.NBI_Engine.jar}:\ - ${reference.NBI_Library__Registries_Management.jar} -# Space-separated list of extra javac options -javac.compilerargs=-Xlint:unchecked -javac.deprecation=true -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.build.ant.utils.VerifyFile -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -project.NBI_Engine=../../../engine -project.NBI_Library__Registries_Management=../../lib/registries-management -reference.NBI_Engine.jar=${project.NBI_Engine}/dist/nbi-engine.jar -reference.NBI_Library__Registries_Management.jar=${project.NBI_Library__Registries_Management}/dist/registries-management.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -src.dir=src -src.src-registries-management.dir=src-registries-management diff --git a/nbi/infra/build/.ant-lib/nbproject/project.xml b/nbi/infra/build/.ant-lib/nbproject/project.xml deleted file mode 100644 index 6e34442584f8..000000000000 --- a/nbi/infra/build/.ant-lib/nbproject/project.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - org.netbeans.modules.java.j2seproject - - - NBI Library: Ant Tasks - 1.6.5 - - - - - - - - - NBI_Engine - jar - - jar - clean - jar - - - NBI_Library__Registries_Management - jar - - jar - clean - jar - - - - diff --git a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/AddPackage.java b/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/AddPackage.java deleted file mode 100644 index c756bf2af273..000000000000 --- a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/AddPackage.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.registries; - -import java.io.File; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.impl.RegistriesManagerImpl; - -/** - * - * @author ks152834 - */ -public class AddPackage extends Task { - private File root; - private File archive; - private String parentUid; - private String parentVersion; - private String parentPlatforms; - - public void setRoot(final File root) { - this.root = root; - } - - public void setArchive(final File archive) { - this.archive = archive; - } - - public void setUid(final String parentUid) { - this.parentUid = parentUid; - } - - public void setVersion(final String parentVersion) { - this.parentVersion = parentVersion; - } - - public void setPlatforms(final String parentPlatforms) { - this.parentPlatforms = parentPlatforms; - } - - @Override - public void execute() throws BuildException { - try { - new RegistriesManagerImpl().addPackage( - root, - archive, - parentUid, - parentVersion, - parentPlatforms); - } catch (ManagerException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/CreateBundle.java b/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/CreateBundle.java deleted file mode 100644 index bd0485b9b8eb..000000000000 --- a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/CreateBundle.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.registries; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.Vector; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.Property; -import org.netbeans.installer.infra.build.ant.utils.Utils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.impl.RegistriesManagerImpl; - -/** - * - * @author ks152834 - */ -public class CreateBundle extends Task { - private List componentObjects = new LinkedList(); - - private File root; - private File target; - private Platform platform; - private Vector properties = new Vector (); - private Vector bundleProperties = new Vector (); - private boolean keepTempBundles = false; - - public void setRoot(final File root) { - this.root = root; - } - - public void setPlatform(final String platform) { - try { - this.platform = StringUtils.parsePlatform(platform); - } catch (ParseException e) { - log(e.getMessage()); - } - } - - public void setTarget(final File target) { - this.target = target; - } - - public Component createComponent() { - final Component component = new Component(); - - componentObjects.add(component); - return component; - } - - public void addProperty(Property p) { - properties.addElement(p); - } - public void addBundleProperty(BundleProperty p) { - bundleProperties.addElement(p); - } - public void setKeepTempBundles(boolean keepTempBundles) { - this.keepTempBundles = keepTempBundles; - } - @Override - public void execute() throws BuildException { - try { - final List components = new LinkedList(); - for (Component component: componentObjects) { - components.add(component.getUid() + "," + component.getVersion()); - } - - System.out.println( - "Creating bundle: " + platform + ": " + components); - Properties props = readProperties(properties); - Properties bundleprops = readProperties(bundleProperties); - RegistriesManagerImpl impl = new RegistriesManagerImpl(); - final File bundle = impl.createBundle( - root, - platform, - components.toArray(new String[components.size()]), - props, - bundleprops); - - Utils.copy(bundle, target); - if(!keepTempBundles) { - impl.deleteBundles(root); - } - } catch (ManagerException e) { - throw new BuildException(e); - } catch (IOException e) { - throw new BuildException(e); - } - } - - private Properties readProperties(Vector antProperties) throws IOException { - Properties props = new Properties(); - for(Property prop : antProperties) { - if(prop.getName()!=null) { - if(prop.getValue()!=null) { - props.setProperty(prop.getName(), prop.getValue()); - } else if(prop.getLocation()!=null) { - props.setProperty(prop.getName(), - new File(prop.getLocation().getFileName()).getAbsolutePath()); - } - } else if(prop.getFile()!=null || prop.getUrl()!=null) { - InputStream is = null; - try { - is = (prop.getFile()!=null) ? - new FileInputStream(prop.getFile()) : - prop.getUrl().openStream(); - - Properties loadedProps = new Properties(); - loadedProps.load(is); - is.close(); - if ( prop.getPrefix() != null ) { - for(Object p : loadedProps.keySet()) { - props.setProperty(prop.getPrefix() + p, - loadedProps.getProperty(p.toString())); - } - } else { - props.putAll(loadedProps); - } - } finally { - if (is != null) { - is.close(); - } - } - } - } - - return props; - } - public static class Component { - private String uid; - private String version; - - public void setUid(final String uid) { - this.uid = uid; - } - - public String getUid() { - return uid; - } - - public void setVersion(final String version) { - this.version = version; - } - - public String getVersion() { - return version; - } - } - public static class BundleProperty extends Property { - - } -} diff --git a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/ExportRegistry.java b/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/ExportRegistry.java deleted file mode 100644 index f84aafaa6e71..000000000000 --- a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/ExportRegistry.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.registries; - -import java.io.File; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.impl.RegistriesManagerImpl; - -/** - * - * @author ks152834 - */ -public class ExportRegistry extends Task { - private File root; - private File destination; - private String codebase; - - public void setRoot(final File root) { - this.root = root; - } - - public void setDestination(final File destination) { - this.destination = destination; - } - - public void setCodebase(final String codebase) { - this.codebase = codebase; - } - - @Override - public void execute() throws BuildException { - try { - new RegistriesManagerImpl().exportRegistry( - root, - destination, - codebase); - } catch (ManagerException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/GenerateComponentsJs.java b/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/GenerateComponentsJs.java deleted file mode 100644 index 5e6bd6d40024..000000000000 --- a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/GenerateComponentsJs.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.registries; - -import java.io.File; -import java.io.IOException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.impl.RegistriesManagerImpl; - -/** - * - * @author ks152834 - */ -public class GenerateComponentsJs extends Task { - private File root; - private File file; - private String locale; - private File bundlesList; - - public void setRoot(final File root) { - this.root = root; - } - - public void setFile(final File file) { - this.file = file; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public void setBundlesList(final File bundles) { - this.bundlesList = bundles; - } - - @Override - public void execute() throws BuildException { - try { - final String contents = - new RegistriesManagerImpl().generateComponentsJs(root, bundlesList, locale); - - Utils.write(file, contents); - } catch (ManagerException e) { - throw new BuildException(e); - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/UpdateEngine.java b/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/UpdateEngine.java deleted file mode 100644 index 72ef084bac09..000000000000 --- a/nbi/infra/build/.ant-lib/src-registries-management/org/netbeans/installer/infra/build/ant/registries/UpdateEngine.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.registries; - -import java.io.File; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.impl.RegistriesManagerImpl; - -/** - * - * @author ks152834 - */ -public class UpdateEngine extends Task { - private File root; - private File archive; - - public void setRoot(final File root) { - this.root = root; - } - - public void setArchive(final File archive) { - this.archive = archive; - } - - @Override - public void execute() throws BuildException { - try { - new RegistriesManagerImpl().updateEngine(root, archive); - } catch (ManagerException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Absolutize.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Absolutize.java deleted file mode 100644 index 805501bd8c6a..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Absolutize.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import org.apache.tools.ant.Task; - -/** - * This class is an ant task which absolutizes the path contained in a given - * property with regard to the ant project's basedir. - * - * @author Kirill Sorokin - */ -public class Absolutize extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Name of the property whose value should be corrected. - */ - private String property = null; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'property' property. - * - * @param property The new value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. A File object is constructed from the - * property value and is then compared to its absolute variant. If they differ - * the absolute path is put back to the property. - */ - public void execute() { - final String value = getProject().getProperty(property); - final File file = new File(value); - - if (!file.equals(file.getAbsoluteFile())) { - getProject().setProperty( - property, - new File(getProject().getBaseDir(), value).getAbsolutePath()); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ForEach.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ForEach.java deleted file mode 100644 index ae8827bcd5e6..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ForEach.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.util.LinkedList; -import java.util.List; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * This class is an ant task which adds the for-loop functionality. It is an - * arbitrary tasks container, which is capable of executing its childrne ina loop. - * - *

- * Two types of loops are supported. First, iterating of over a list of values; in - * this case the list and separator (optional) attributes - * should be set and the property speficied with property attribute - * will be set to each of the value speficied in the the list. - * - *

- * Second, iterating of a range of integers. In this case the from, - * to and increment (optional) attributes should be set, - * meaning the starting point, the finish point and the step. Note that if one - * specifies a negative step, the iteration could go backwards. - * - *

- * If a mixture of attributes is supplied, iterating over a list is preferred. - * - * @author Kirill Sorokin - */ -public class ForEach extends Task implements TaskContainer { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The list of values over which the iteration process should go. - */ - private String list; - - /** - * Separator token which should be used to split the list string into individual - * values. - */ - private String separator; - - /** - * Starting point for iteration over an integer range. - */ - private int from; - - /** - * Ending point for iteration over an integer range. - */ - private int to; - - /** - * Step amount for iteration over an integer range. - */ - private int increment; - - /** - * Name of the property which has to be set for each iteration. - */ - private String property; - - /** - * List of child tasks which should be executed at each iteration. - */ - private List children; - - /** - * Flag which marks incorrect attribute values. - */ - private boolean wrongArgs; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * Constructs a new instance of the {@link ForEach} task. It simply sets the - * default values for the attributes. - */ - public ForEach() { - separator = DEFAULT_SEPARATOR; - - from = DEFAULT_FROM; - to = DEFAULT_TO; - increment = DEFAULT_INCREMENT; - - children = new LinkedList(); - } - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'list' property. - * - * @param list The new value for the 'list' property. - */ - public void setList(final String list) { - this.list = list; - } - - /** - * Setter for the 'separator' property. - * - * @param separator The new value for the 'separator' property. - */ - public void setSeparator(final String separator) { - this.separator = separator; - } - - /** - * Setter for the 'property' property. - * - * @param property The new value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - /** - * Setter for the 'from' property. - * - * @param from The new value for the 'from' property. - */ - public void setFrom(final String from) { - try { - this.from = Integer.parseInt(from); - } catch (NumberFormatException e) { - log("Wrong value for parameter 'from' : " + from); // NOI18N - wrongArgs = true; - } - } - - /** - * Setter for the 'to' property. - * - * @param to The new value for the 'to' property. - */ - public void setTo(final String to) { - try { - this.to = Integer.parseInt(to); - } catch (NumberFormatException e) { - log("Wrong value for parameter 'to' : " + to); // NOI18N - wrongArgs = true; - } - } - - /** - * Setter for the 'increment' property. - * - * @param increment The new value for the 'increment' property. - */ - public void setIncrement(final String increment) { - try { - this.increment = Integer.parseInt(increment); - } catch (NumberFormatException e) { - log("Wrong value for parameter 'increment' : " + increment); // NOI18N - wrongArgs = true; - } - } - - /** - * Registers a child task. The supplied Task object will be added - * to the list of child tasks and then executed at each iteration. - * - * @param task The Task object to register. - */ - public void addTask(final Task task) { - children.add(task); - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. Basing on which attributes were set, the choice is made of - * whether the iteration should happen over a list or an integer range. Then the - * iteration takes place the specified property is set and the child tasks are - * executed. - * - * @throws org.apache.tools.ant.BuildException if a child task fails to execute. - */ - public void execute() throws BuildException { - if (wrongArgs) { - throw new BuildException( - "Correct parameters were not supplied."); // NOI18N - } - - if (list != null) { - final String[] items = list.split(separator); - - for (String value: items) { - executeChildren(value); - } - return; - } else { - for (int i = from; i <= to; i += increment) { - executeChildren(Integer.toString(i)); - } - } - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Sets the specified property to the given value and executes the children. - */ - private void executeChildren(String value) throws BuildException { - getProject().setProperty(this.property, value); - - for (Task task: this.children) { - task.perform(); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Default value for the 'separator' property. - */ - private static final String DEFAULT_SEPARATOR = - " "; // NOI18N - - /** - * Default value for the 'from' property. - */ - private static final int DEFAULT_FROM = - 0; // NOMAGI - - /** - * Default value for the 'to' property. - */ - private static final int DEFAULT_TO = - 0; // NOMAGI - - /** - * Default value for the 'increment' property. - */ - private static final int DEFAULT_INCREMENT = - 1; // NOMAGI -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/GroupDescriptor.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/GroupDescriptor.java deleted file mode 100644 index ea5a624baf1a..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/GroupDescriptor.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which creates a group package descriptor based on the - * existing project properties and writes it to the specified file. - * - * @author Kirill Sorokin - */ -public class GroupDescriptor extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * File to which the group descriptor should be written. - */ - private File file; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'file' property. - * - * @param path The new value of the 'file' property. - */ - public void setFile(final String path) { - file = new File(path); - if (!file.equals(file.getAbsoluteFile())) { - file = new File(getProject().getBaseDir(), path); - } - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. This method writes the group package descriptor xml code - * to the specified file. - * - * @throws org.apache.tools.ant.BuildException if a I/O error occurs. - */ - public void execute() throws BuildException { - Utils.setProject(getProject()); - - final StringBuilder xml = new StringBuilder(); - - // header /////////////////////////////////////////////////////////////////// - xml.append("\n"); // NOI18N - xml.append("\n"); // NOI18N - xml.append(" \n"); // NOI18N - - // core data //////////////////////////////////////////////////////////////// - final String uid = get("group.uid"); // NOI18N - final String offset = get("group.offset"); // NOI18N - final String expand = get("group.expand"); // NOI18N - final String visible = get("group.visible"); // NOI18N - - xml.append(" \n"); // NOI18N - - // locales ////////////////////////////////////////////////////////////////// - final String locales = - get("group.locales.list").trim(); // NOI18N - - // display name ///////////////////////////////////////////////////////////// - String displayName = - get("group.display.name.default"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - - if (!locales.equals("")) { // NOI18N - for (String locale: locales.split(" ")) { // NOI18N - displayName = get( - "group.display.name." + locale); // NOI18N - if (displayName != null) { - xml.append(" \n"); // NOI18N - } - } - } - xml.append(" \n"); // NOI18N - - // description ////////////////////////////////////////////////////////////// - String description = - get("group.description.default"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - - if (!locales.equals("")) { // NOI18N - for (String locale: locales.split(" ")) { // NOI18N - description = get( - "group.description." + locale); // NOI18N - if (description != null) { - xml.append(" \n"); // NOI18N - } - } - } - xml.append(" \n"); // NOI18N - - // icon ///////////////////////////////////////////////////////////////////// - final String size = get("group.icon.size"); // NOI18N - final String md5 = get("group.icon.md5"); // NOI18N - final String uri = get("group.icon.correct.uri"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append(" " + // NOI18N - uri.replace(" ", "%20") + "\n"); // NOI18N - xml.append(" \n"); // NOI18N - - // properties /////////////////////////////////////////////////////////////// - final int length = Integer.parseInt( - get("group.properties.length")); // NOI18N - - if (length > 0) { - xml.append(" \n"); // NOI18N - for (int i = 1; i <= length; i++) { - final String name = get( - "group.properties." + i + ".name"); // NOI18N - final String value = get( - "group.properties." + i + ".value"); // NOI18N - xml.append(" " + value + "\n"); // NOI18N - } - xml.append(" \n"); // NOI18N - } - - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - xml.append("\n"); // NOI18N - - - try { - Utils.write(file, xml); - } catch (IOException e) { - throw new BuildException(e); - } - } - // private ////////////////////////////////////////////////////////////////////// - /** - * Gets a group's property's string value. - * - * @param name Name of the property whose value is required. - * @return The value of the property as a string. - */ - private String get(String name) { - return Utils.resolveProperty(getProject().getProperty(name)); - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/If.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/If.java deleted file mode 100644 index b3ab962ce0e2..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/If.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.util.LinkedList; -import java.util.List; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -/** - * This class is an ant task, which adds conditional execution capabilities. It - * examines the value of the given property and executed the nested tasks only if - * the the property's value equals to the given string. - * - * @author Kirill Sorokin - */ -public class If extends Task implements TaskContainer { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Name of the property whose value should be checked. - */ - private String property; - - /** - * String which should be equal to the property's value in order for the nested - * tasks to execute. - */ - private String value; - - /** - * List of child tasks which should be executed if the condition is satisfied. - */ - private List children; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * Constructs a new instance of the {@link If} task. It simply sets the - * default values for the attributes. - */ - public If() { - children = new LinkedList(); - } - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'property' property. - * - * @param property The new value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - /** - * Setter for the 'value' property. - * - * @param value The new value for the 'value' property. - */ - public void setValue(final String value) { - this.value = value; - } - - /** - * Registers a child task. The supplied Task object will be added - * to the list of child tasks and executed if the condition is satisfied. - * - * @param task The Task object to register. - */ - public void addTask(final Task task) { - children.add(task); - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. If the required value is set, then the property's value is - * compared to it and the child tasks are executes if they are equal. If the - * required value is not set, then the child tasks are executed if the property - * was set, without regard to its value. - * - * @throws org.apache.tools.ant.BuildException if a child task fails to execute. - */ - public void execute() throws BuildException { - if (getProject().getProperty(property) != null) { - if (value == null || getProject().getProperty(property).equals(value)) { - executeChildren(); - } - } - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Executes the child tasks. - */ - private void executeChildren() throws BuildException { - for (Task task: this.children) { - task.perform(); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/LoadLocales.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/LoadLocales.java deleted file mode 100644 index f21e468a5d40..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/LoadLocales.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which is capable of loading localized properties data. - * - * @author Kirill Sorokin - */ -public class LoadLocales extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The basename of the .properties file. - */ - private String basename; - - /** - * Name of the property whose value should be set to the list of found locales. - */ - private String localesList; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'basename' property. - * - * @param basename New value for the 'basename' property. - */ - public void setBasename(final String basename) { - this.basename = basename; - final File basenameFile = new File(basename); - if(! (basenameFile.equals(basenameFile.getAbsoluteFile()))) { - this.basename = new File(getProject().getBaseDir(), basename).getPath(); - } - } - - /** - * Setter for the 'localesList' property. - * - * @param localesList New value for the 'localesList' property. - */ - public void setList(final String localesList) { - this.localesList = localesList; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. The properties are loaded from the resource file with the - * given base name and the corresponding project properties are set. - * - * @throws org.apache.tools.ant.BuildException if an I/O error occurs. - */ - public void execute() throws BuildException { - Utils.setProject(getProject()); - - String locales = ""; // NOI18N - - try { - // handle the default locale - File file = new File(basename + ".properties"); // NOI18N - - Properties properties = new Properties(); - - properties.load(new FileInputStream(file)); - - for (Map.Entry entry: properties.entrySet()) { - getProject().setProperty( - entry.getKey() + ".default", // NOI18N - entry.getValue().toString()); - } - - for (Locale locale: Locale.getAvailableLocales()) { - file = new File(basename + "_" + locale + ".properties"); // NOI18N - if (file.exists()) { - locales += " " + locale; // NOI18N - properties = new Properties(); - properties.load(new FileInputStream(file)); - - for (Map.Entry entry: properties.entrySet()) { - getProject().setProperty( - "" + entry.getKey() + "." + locale, // NOI18N - entry.getValue().toString()); - } - } - } - } catch (IOException e) { - throw new BuildException(e); - } - - getProject().setProperty(localesList, locales.trim()); - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Md5.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Md5.java deleted file mode 100644 index fda70490714c..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Md5.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which is capable of calculating an MD5 digital digest - * for a given file and output it to a project property. - * - * @author Kirill Sorokin - */ -public class Md5 extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * File for which the digest should be calculated. - */ - private File file; - - /** - * Name of the property whose value should contain the digest. - */ - private String property; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'file' property. - * - * @param path New value for the 'file' property. - */ - public void setFile(final String path) { - file = new File(path); - if (!file.equals(file.getAbsoluteFile())) { - file = new File(getProject().getBaseDir(), path); - } - } - - /** - * Setter for the 'property' property. - * - * @param property New value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. - * - * @throws org.apache.tools.ant.BuildException if an I/O error occurs. - */ - public void execute() throws BuildException { - Utils.setProject(getProject()); - - try { - getProject().setProperty(property, Utils.getMd5(file)); - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUntar.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUntar.java deleted file mode 100644 index 84d357718b1d..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUntar.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.Untar; -import org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -public class NativeUntar extends Untar { - private File dest; //req - private File source; // req - - @Override - public void setDest(File d) { - this.dest = d; - - super.setDest(d); - } - - @Override - public void setSrc(File s) { - this.source = s; - - super.setSrc(s); - } - - @Override - public void execute() throws BuildException { - try { - Utils.setProject(getProject()); - log("trying native untar"); - - Utils.nativeUntar(source, dest); - } catch (IOException e) { - log("native untar failed, falling back to java implementation"); - - Utils.delete(dest); - UntarCompressionMethod compression = new UntarCompressionMethod(); - if(source.getName().endsWith(".tar.gz") || source.getName().endsWith(".tgz")) { - compression.setValue("gzip"); - } else if(source.getName().endsWith(".tar.bz2") || source.getName().endsWith(".tar.bzip2")) { - compression.setValue("bzip2"); - } else { - compression.setValue("none"); - } - setCompression(compression); - super.execute(); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUnzip.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUnzip.java deleted file mode 100644 index a7b6042d3e36..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/NativeUnzip.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.Expand; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -public class NativeUnzip extends Expand { - private File dest; //req - private File source; // req - - @Override - public void setDest(File d) { - this.dest = d; - - super.setDest(d); - } - - @Override - public void setSrc(File s) { - this.source = s; - - super.setSrc(s); - } - - @Override - public void execute() throws BuildException { - try { - Utils.setProject(getProject()); - log("trying native unzip"); - - Utils.nativeUnzip(source, dest); - } catch (IOException e) { - log("native unzip failed, falling back to java implementation"); - - Utils.delete(dest); - super.execute(); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Package.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Package.java deleted file mode 100644 index 25b3b239b4f1..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Package.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; -import org.netbeans.installer.infra.build.ant.utils.FileEntry; - -/** - * This class is an ant task which is capable of properly packaging a directory into - * an archive. In addition to simply jarring the directory, it pack200-packages the - * jar files present in the source directory and composes a files list which - * contains some useful metadata about the files in the archive, such as the - * checksums, sizes, etc. - * - * @author Kirill Sorokin - */ -public class Package extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The target archive file. - */ - private File file; - - /** - * The sources directory. - */ - private File directory; - - /** - * List of {@link FileEntry} objects, which represent the metadata for the files - * which should be included into the archive. - */ - private List entries; - - private long directoriesCount; - private long filesCount; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * Constructs a new instance of the {@link Package} task. It simply sets the - * default values for the attributes. - */ - public Package() { - entries = new LinkedList(); - } - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'file' property. - * - * @param path New value for the 'file' property. - */ - public void setFile(final String path) { - file = new File(path); - if (!file.equals(file.getAbsoluteFile())) { - file = new File(getProject().getBaseDir(), path); - } - } - - /** - * Setter for the 'directory' property. - * - * @param path New value for the 'directory' property. - */ - public void setDirectory(final String path) { - directory = new File(path); - if (!directory.equals(directory.getAbsoluteFile())) { - directory = new File(getProject().getBaseDir(), path); - } - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. The source directory is recursively browsed, its files are - * examined, packaged and added to the archive; some additional metadata is - * calculated and then added to the files list. - * - * @throws org.apache.tools.ant.BuildException if an I/O error occurs. - */ - public void execute() throws BuildException { - Utils.setProject(getProject()); - - JarOutputStream output = null; - try { - output = new JarOutputStream(new FileOutputStream(file)); - output.setLevel(9); - - log("browsing, packing, archiving directory " + directory.getCanonicalPath()); // NOI18N - browse(directory.getCanonicalFile(), - output, - directory.getCanonicalPath().length()); - - log("adding manifest and files list"); // NOI18N - output.putNextEntry(new JarEntry(METAINF_ENTRY)); - - output.putNextEntry(new JarEntry(MANIFEST_ENTRY)); - output.write("Manifest-Version: 1.0\n\n".getBytes("UTF-8")); // NOI18N - - output.putNextEntry(new JarEntry(FILES_LIST_ENTRY)); - OutputStreamWriter writer = - new OutputStreamWriter(output, "UTF-8"); // NOI18N - - writer.write("\n"); // NOI18N - writer.write("\n"); // NOI18N - for (FileEntry entry: entries) { - writer.write(" " + entry. // NOI18N - getName(). - replace("&", "&"). // NOI18N - replace("\'","'"). //NOI18N - replace("\"","""). //NOI18N - replace("<", "<"). // NOI18N - replace(">", ">") + "\n"); // NOI18N - } - writer.write("\n"); // NOI18N - - writer.flush(); - writer.close(); - - output.flush(); - output.close(); - - log("archived " + directoriesCount + // NOI18N - " directories and " + filesCount + " files"); // NOI18N - } catch (IOException e) { - throw new BuildException(e); - } - } - private String getShortPath(File file, final int offset) throws IOException { - return file.getAbsolutePath().substring(offset + 1); - } - // private ////////////////////////////////////////////////////////////////////// - private void browse( - final File parent, - final JarOutputStream output, - final int offset) throws IOException { - FileInputStream fis = null; - final List toSkip = new LinkedList(); - - for (File child: parent.listFiles()) { - if (toSkip.contains(child)) { - log(" skipping " + getShortPath(child,offset)); // NOI18N - continue; - } - - log(" visiting " + getShortPath(child,offset)); // NOI18N - - final String path = child.getAbsolutePath(); - String name = path.substring(offset + 1).replace('\\', '/'); // NOMAGI - - FileEntry entry; - JarEntry jarEntry; - - if (child.isDirectory()) { - log(" archiving directory: " + name); // NOI18N - - name = name + "/"; // NOI18N - entry = new FileEntry(child, name); - - output.putNextEntry(new JarEntry(name)); - - directoriesCount++; - - browse(child, output, offset); - } else { - entry = new FileEntry(child, name); - log(" archiving file: " + name); // NOI18N - jarEntry = new JarEntry(name); - jarEntry.setTime(entry.getLastModified()); - jarEntry.setSize(entry.getSize()); - output.putNextEntry(jarEntry); - - fis = new FileInputStream(child); - Utils.copy(fis, output); - fis.close(); - - filesCount++; - } - - entries.add(entry); - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - private static final String METAINF_ENTRY = - "META-INF/"; // NOI18N - private static final String FILES_LIST_ENTRY = - "META-INF/files.list"; // NOI18N - private static final String MANIFEST_ENTRY = - "META-INF/manifest.mf"; // NOI18N -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ProductDescriptor.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ProductDescriptor.java deleted file mode 100644 index b7e92273ba97..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ProductDescriptor.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which creates a product package descriptor based on the - * existing project properties and writes it to the specified file. - * - * @author Kirill Sorokin - */ -public class ProductDescriptor extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * File to which the product descriptor should be written. - */ - private File file; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'file' property. - * - * @param path The new value of the 'file' property. - */ - public void setFile(final String path) { - file = new File(path); - if (!file.equals(file.getAbsoluteFile())) { - file = new File(getProject().getBaseDir(), path); - } - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. This method writes the product package descriptor xml code - * to the specified file. - * - * @throws org.apache.tools.ant.BuildException if a I/O error occurs. - */ - public void execute() throws BuildException { - Utils.setProject(getProject()); - - StringBuilder xml = new StringBuilder(); - - // header /////////////////////////////////////////////////////////////////// - xml.append("\n"); // NOI18N - xml.append("\n"); // NOI18N - xml.append(" \n"); // NOI18N - - // core data //////////////////////////////////////////////////////////////// - String uid = get("product.uid"); // NOI18N - final String version = get("product.version"); // NOI18N - final String platform = get("product.platforms"); // NOI18N - final String status = get("product.status"); // NOI18N - final String offset = get("product.offset"); // NOI18N - final String expand = get("product.expand"); // NOI18N - final String visible = get("product.visible"); // NOI18N - final String features = get("product.features"); // NOI18N - - xml.append(" \n"); // NOI18N - - // locales ////////////////////////////////////////////////////////////////// - final String locales = get("product.locales.list").trim(); // NOI18N - - // display name ///////////////////////////////////////////////////////////// - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - if (!locales.equals("")) { // NOI18N - for (String locale: locales.split(" ")) { // NOI18N - String name = get("product.display.name." + locale); - if (name != null) { - xml.append(" \n"); // NOI18N - } - } - } - xml.append(" \n"); // NOI18N - - // description ////////////////////////////////////////////////////////////// - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - if (!locales.equals("")) { // NOI18N - for (String locale: locales.split(" ")) { // NOI18N - String desc = get("product.description." + locale); - if (desc != null) { - xml.append(" \n"); // NOI18N - } - } - } - xml.append(" \n"); // NOI18N - - // icon ///////////////////////////////////////////////////////////////////// - String size = get("product.icon.size"); // NOI18N - String md5 = get("product.icon.md5"); // NOI18N - String uri = get("product.icon.correct.uri"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append(" " + // NOI18N - uri.replace(" ", "%20") + "\n"); // NOI18N - xml.append(" \n"); // NOI18N - - // properties /////////////////////////////////////////////////////////////// - if (getInt("product.properties.length") > 0) { // NOI18N - xml.append(" \n"); // NOI18N - for (int i = 1; i <= - getInt("product.properties.length"); i++) { // NOI18N - String name = get("product.properties." + i + ".name"); // NOI18N - String value = get("product.properties." + i + ".value"); // NOI18N - xml.append(" \n"); // NOI18N - } - xml.append(" \n"); // NOI18N - } - - // configuration logic ////////////////////////////////////////////////////// - xml.append(" \n"); // NOI18N - for (int i = 1; i <= getInt("product.logic.length"); i++) { // NOI18N - size = get("product.logic." + i + ".size"); // NOI18N - md5 = get("product.logic." + i + ".md5"); // NOI18N - uri = get("product.logic." + i + ".correct.uri"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append( - " " + // NOI18N - uri.replace(" ", "%20") + // NOI18N - "\n"); // NOI18N - xml.append(" \n"); // NOI18N - } - xml.append(" \n"); // NOI18N - - // installation data //////////////////////////////////////////////////////// - xml.append(" \n"); // NOI18N - for (int i = 1; i <= getInt("product.data.length"); i++) { // NOI18N - size = get("product.data." + i + ".size"); // NOI18N - md5 = get("product.data." + i + ".md5"); // NOI18N - uri = get("product.data." + i + ".correct.uri"); // NOI18N - - xml.append(" \n"); // NOI18N - xml.append( - " " + // NOI18N - uri.replace(" ", "%20") + // NOI18N - "\n"); // NOI18N - xml.append(" \n"); // NOI18N - } - xml.append(" \n"); // NOI18N - - // requirements ///////////////////////////////////////////////////////////// - xml.append(" \n"); // NOI18N - xml.append(" " + // NOI18N - get("product.disk.space") + "\n"); // NOI18N - xml.append(" \n"); // NOI18N - - // dependencies ///////////////////////////////////////////////////////////// - if (getInt("product.requirements.length") + // NOI18N - getInt("product.conflicts.length") + // NOI18N - getInt("product.install-afters.length") > 0) { // NOI18N - xml.append(" \n"); // NOI18N - - for (int i = 1; i <= - getInt("product.requirements.length"); i++) { // NOI18N - uid = get("product.requirements." + i + ".uid"); // NOI18N - - String lower = get( - "product.requirements." + i + // NOI18N - ".version-lower"); // NOI18N - String upper = get( - "product.requirements." + i + // NOI18N - ".version-upper"); // NOI18N - int alternativeRequirements = - getInt( - "product.requirements." + i +// NOI18N - ".alternatives.length");// NOI18N - - if(alternativeRequirements==0) { - xml.append(" \n"); // NOI18N - } else { - xml.append(" \n"); // NOI18N - - for(int j=1;j<=alternativeRequirements;j++) { - int reqs = getInt( - "product.requirements." + i + - ".alternatives." + j + - ".requirements.length"); - - if (reqs > 0 ) { - xml.append(" \n"); - for(int k = 1 ; k <= reqs; k++) { - String prefix = - "product.requirements." + i + - ".alternatives." + j + - ".requirements." + k + "."; - uid = get(prefix + "uid"); // NOI18N - lower = get(prefix + "version-lower"); // NOI18N - upper = get(prefix + "version-upper"); // NOI18N - - xml.append( - " \n"); // NOI18N - } - xml.append(" \n"); - } - } - - xml.append(" \n"); - } - } - - for (int i = 1; i <= - getInt("product.conflicts.length"); i++) { // NOI18N - uid = get("product.conflicts." + i + ".uid"); // NOI18N - - String lower = get( - "product.conflicts." + i + ".version-lower"); // NOI18N - String upper = get( - "product.conflicts." + i + ".version-upper"); // NOI18N - - xml.append(" \n"); // NOI18N - } - - for (int i = 1; i <= - getInt("product.install-afters.length"); i++) { // NOI18N - uid = get("product.install-afters." + i + ".uid"); // NOI18N - - xml.append(" \n"); // NOI18N - } - - xml.append(" \n"); // NOI18N - } - - xml.append(" \n"); // NOI18N - xml.append(" \n"); // NOI18N - xml.append("\n"); // NOI18N - - try { - Utils.write(file, xml); - } catch (IOException e) { - throw new BuildException(e); - } - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Gets a project's property's string value. - * - * @param name Name of the property whose value is required. - * @return The value of the property as a string. - */ - private String get(String name) { - return Utils.resolveProperty(getProject().getProperty(name)); - } - - /** - * Gets a project's property's integer value. - * - * @param name Name of the property whose value is required. - * @return The value of the property as an integer. - */ - private int getInt(String name) { - if (get(name) == null) { - return 0; - } else { - return Integer.parseInt(get(name)); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleaseEngine.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleaseEngine.java deleted file mode 100644 index 466bdfe66944..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleaseEngine.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task that is capable or releasing an NBI engine to the - * registries server. - * - * @author Kirill Sorokin - */ -public class ReleaseEngine extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * URL of the registries server to which the engine should be released. - */ - private String url; - - /** - * The engine distributive file. - */ - private File archive; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'url' property. - * - * @param url The new value of the 'url' property. - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * Setter for the 'archive' property. - * - * @param path The new value of the 'archive' property. - */ - public void setArchive(String path) { - archive = new File(path); - if (!archive.equals(archive.getAbsoluteFile())) { - archive = new File(getProject().getBaseDir(), path); - } - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. This method sends an HTTP POST request tyo the server, - * uploading the engine's archive. - * - * @throws org.apache.tools.ant.BuildException if an I/O error occurs. - */ - public void execute() throws BuildException { - try { - final Map args = new HashMap(); - - args.put("archive", archive); // NOI18N - - - String response = Utils.post(url + "/update-engine", args); // NOI18N - - log(response); - if (!response.startsWith("200")) { // NOI18N - throw new BuildException("Failed to release the engine."); // NOI18N - } - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleasePackage.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleasePackage.java deleted file mode 100644 index 0db68a6a5c51..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/ReleasePackage.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task that is capable or releasing an NBI package archive. - * - * @author Kirill Sorokin - */ -public class ReleasePackage extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * URL of the registries server to which the package should be released. - */ - private String url; - - /** - * Name of the registry into which the package should be imported. - */ - private String registry; - - /** - * Uid of the parent component for the package. - */ - private String uid; - - /** - * Version of the parent component for the package. - */ - private String version; - - /** - * Platforms of the parent component for the package. - */ - private String platforms; - - /** - * The package archive. - */ - private File archive; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'url' property. - * - * @param url The new value of the 'url' property. - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * Setter for the 'registry' property. - * - * @param registry The new value of the 'registry' property. - */ - public void setRegistry(String registry) { - this.registry = registry; - } - - /** - * Setter for the 'uid' property. - * - * @param uid The new value of the 'uid' property. - */ - public void setUid(String uid) { - this.uid = uid; - } - - /** - * Setter for the 'version' property. - * - * @param version The new value of the 'version' property. - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Setter for the 'platforms' property. - * - * @param platforms The new value of the 'platforms' property. - */ - public void setPlatforms(String platforms) { - this.platforms = platforms; - } - - /** - * Setter for the 'archive' property. - * - * @param path The new value of the 'archive' property. - */ - public void setArchive(String path) { - archive = new File(path); - if (!archive.equals(archive.getAbsoluteFile())) { - archive = new File(getProject().getBaseDir(), path); - } - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. This method sends an HTTP POST request to the server, - * uploading the package archive. - * - * @throws org.apache.tools.ant.BuildException if an I/O error occurs. - */ - public void execute() throws BuildException { - try { - final Map args = new HashMap(); - - - args.put("registry", registry); // NOI18N - args.put("uid", uid); // NOI18N - args.put("version", version); // NOI18N - args.put("platforms", platforms); // NOI18N - args.put("archive", archive); // NOI18N - - String response = Utils.post(url + "/add-package", args); // NOI18N - - log(response); - if (!response.startsWith("200")) { // NOI18N - throw new BuildException("Failed to release the package."); // NOI18N - } - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SetProperty.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SetProperty.java deleted file mode 100644 index c9f152c5c576..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SetProperty.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which is capable of setting a property value basing on - * either a supplied value or a value of another property. - * - * @author Kirill Sorokin - */ -public class SetProperty extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Name of the target property whose value should be set. - */ - private String property; - - /** - * Name of the source property whose value should be evaluated and set as the - * value of the target property. - */ - private String source; - - /** - * String which should be set as the value for the target property. - */ - private String value; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'property' property. - * - * @param property New value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - /** - * Setter for the 'source' property. - * - * @param source New value for the 'source' property. - */ - public void setSource(final String source) { - this.source = source; - } - - /** - * Setter for the 'value' property. - * - * @param value New value for the 'value' property. - */ - public void setValue(final String value) { - this.value = value; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. If the source property was specified, its value is - * evaluated and set as the value of the target property. Otherwise the literal - * string value is used. - */ - public void execute() { - final Project project = getProject(); - final String string = (source != null) ? - project.getProperty(Utils.resolveProperty(source, project)) : - value; - final String resolved = Utils.resolveProperty(string, project); - log("Setting " + property + " to " + resolved); - project.setProperty(property, resolved); - } - - -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SizeOf.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SizeOf.java deleted file mode 100644 index 48355b7b6751..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/SizeOf.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * This class is an ant task which is capable of calculating the size of a file (or - * a directory) and storing it as the value of a given property. - * - * @author Kirill Sorokin - */ -public class SizeOf extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * File for which the size should be calculated. - */ - private File file; - - /** - * Name of the property whose value should contain the size. - */ - private String property; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'file' property. - * - * @param path New value for the 'path' property. - */ - public void setFile(final String path) { - file = new File(path); - if (!file.equals(file.getAbsoluteFile())) { - file = new File(getProject().getBaseDir(), path); - } - } - - /** - * Setter for the 'property' property. - * - * @param property New value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. - */ - public void execute() { - Utils.setProject(getProject()); - - getProject().setProperty(property, Long.toString(Utils.size(file))); - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Sum.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Sum.java deleted file mode 100644 index aed75e87eab0..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/Sum.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import org.apache.tools.ant.Task; - -/** - * This class is an ant task which is capable of summing two integer values and - * storing the result as the value of a property. - * - * @author Kirill Sorokin - */ -public class Sum extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Name of the first item. - */ - private String arg1; - - /** - * Name of the second item. - */ - private String arg2; - - /** - * Name of the property shich should hold the result. - */ - private String property; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'arg1' property. - * - * @param arg1 New value for the 'arg1' property. - */ - public void setArg1(final String arg1) { - this.arg1 = arg1; - } - - /** - * Setter for the 'arg2' property. - * - * @param arg2 New value for the 'arg2' property. - */ - public void setArg2(final String arg2) { - this.arg2 = arg2; - } - - /** - * Setter for the 'property' property. - * - * @param property New value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. - */ - public void execute() { - getProject().setProperty( - property, - Long.toString(Long.parseLong(arg1) + Long.parseLong(arg2))); - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/UriToPath.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/UriToPath.java deleted file mode 100644 index ba8f11868d49..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/UriToPath.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.netbeans.installer.infra.build.ant.utils.Utils; - -/** - * Thsi class is an ant task which converts an URI to a relative path. This is - * useful for caching the downloads. - * - * @author Kirill Sorokin - */ -public class UriToPath extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * URI which should be converted. - */ - private String uriString; - - /** - * Name of the property whose value should contain the size. - */ - private String property; - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the 'uri' property. - * - * @param uri New value for the 'uri' property. - */ - public void setUri(final String uri) { - this.uriString = uri; - } - - /** - * Setter for the 'property' property. - * - * @param property New value for the 'property' property. - */ - public void setProperty(final String property) { - this.property = property; - } - - // execution //////////////////////////////////////////////////////////////////// - /** - * Executes the task. - */ - public void execute() throws BuildException { - try { - final URI uri = new URI(uriString); - - String path = uri.getSchemeSpecificPart(); - while (path.startsWith("/")) { // NOI18N - path = path.substring(1); - } - - if (uri.getScheme().equals("file")) { - path = "local/" + path; - } - path = path.replace(":", "_").replace("*", "_"); - getProject().setProperty(property, path); - } catch (URISyntaxException e) { - throw new BuildException("Cannot parse URI.",e); // NOI18N - } - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/WriteFileList.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/WriteFileList.java deleted file mode 100644 index 3be6c58a8c83..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/WriteFileList.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant; - -import java.io.File; -import java.io.FileFilter; -import java.io.FileOutputStream; -import java.io.IOException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -/** - * - * @author Dmitry Lipin - */ -public class WriteFileList extends Task{ - private String dir; - private String output; - private String mask; - - private void check(String s, String desc) throws BuildException { - if(s==null) { - throw new BuildException("Error! Parameter '" + desc + "' can`t be null!!"); - } - } - - private void write(StringBuilder sb, String s) { - sb.append(s); - sb.append(System.getProperty("line.separator")); - - } - private void listFile(File parent, File f, StringBuilder sb) throws IOException { - String path = f.getPath(); - String parentPath = parent.getPath(); - path = path.substring(parentPath.length()); - path = path.replaceAll("\\\\","/"); - if(path.length()>0) { - path = path.substring(1); - } - - if(f.isFile()) { - if(path.length()>0 && path.matches(mask)) { - write(sb, path); - } - } else if(f.isDirectory()) { - - if(path.length()>0) { - path = path + "/"; - if(path.matches(mask)) { - write(sb, path); - } - } - File [] dirs = f.listFiles(new FileFilter() { - public boolean accept(File pathname) { - return (pathname.isDirectory()); - } } - ); - - for(File file: dirs) { - listFile(parent, file, sb); - } - - File [] files = f.listFiles(new FileFilter() { - public boolean accept(File pathname) { - return (pathname.isFile() && !pathname.isDirectory()); - } } - ); - for(File file: files) { - listFile(parent, file, sb); - } - } - } - public void execute() throws BuildException { - check(dir,"starting directory"); - check(output,"output file"); - check(mask,"file mask"); - - File root = new File(dir); - if (!root.equals(root.getAbsoluteFile())) { - root = new File(getProject().getBaseDir(), dir); - } - File outFile = new File(output); - if (!outFile.equals(outFile.getAbsoluteFile())) { - outFile = new File(getProject().getBaseDir(), output); - } - FileOutputStream fos = null; - - log("Root directory : " + root); - log("Output file : " + outFile); - log("Mask : " + mask); - - try { - StringBuilder sb = new StringBuilder(); - listFile(root, root, sb); - fos = new FileOutputStream(outFile); - fos.write(sb.toString().getBytes()); - } catch (IOException ex) { - throw new BuildException(ex); - } finally { - if(fos!=null) { - try { - fos.close(); - } catch (IOException ex) { - throw new BuildException(ex); - } - } - } - - } - - public void setDir(final String dir) { - this.dir = dir; - } - - public void setOutput(final String output) { - this.output = output; - } - - public void setMask(final String mask) { - this.mask = mask; - } - -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/FileEntry.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/FileEntry.java deleted file mode 100644 index 16988dd2d70f..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/FileEntry.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.utils; - -import java.io.File; -import java.io.IOException; - -/** - * This class represents the collection of meta data for a file. - * - * @author Kirill Sorokin - */ -public class FileEntry { - /** - * The file's size. - */ - private long size; - - /** - * The file's MD5 checksum. - */ - private String md5; - - /** - * Whether the entry is a file or a directory. - */ - private boolean directory; - - /** - * Whether the directory is empty. - */ - private boolean empty; - - /** - * Whether the file is a jar file. - */ - private boolean jarFile; - - /** - * Whether the file is a packed jar file. - */ - private boolean packedJarFile; - - /** - * Whether the file is a signed jar file. - */ - private boolean signedJarFile; - - /** - * The file's modification date. - */ - private long lastModified; - - /** - * The file's permissions (e.g. 775). - */ - private int permissions; - - /** - * The entry's name. - */ - private String name; - - /** - * Constructs a new FileEntry instance from the given file. - * - * @param file The file for which to calculate the metadata. - * @param name The name of the entry. - * @throws java.io.IOException if an I/O error occurs. - */ - public FileEntry(final File file, final String name) throws IOException { - this.directory = file.isDirectory(); - - if (!directory) { - this.size = file.length(); - this.md5 = Utils.getMd5(file); - - this.jarFile = Utils.isJarFile(file); - if (jarFile) { - this.packedJarFile = false; // we cannot determine this - this.signedJarFile = Utils.isSigned(file); - } - } else { - this.empty = Utils.isEmpty(file); - } - - this.permissions = Utils.getPermissions(file); - this.lastModified = file.lastModified(); - this.name = name; - } - - /** - * Getter of the 'size' property. - * - * @return Value of the 'size' property. - */ - public long getSize() { - return size; - } - - /** - * Setter for the 'size' property. - * - * @param size New value for the 'size' property. - */ - public void setSize(final long size) { - this.size = size; - } - - /** - * Getter of the 'md5' property. - * - * @return Value of the 'md5' property. - */ - public String getMd5() { - return md5; - } - - /** - * Setter for the 'md5' property. - * - * @param md5 New value for the 'md5' property. - */ - public void setMd5(final String md5) { - this.md5 = md5; - } - - /** - * Getter of the 'directory' property. - * - * @return Value of the 'directory' property. - */ - public boolean isDirectory() { - return directory; - } - - /** - * Setter for the 'directory' property. - * - * @param directory New value for the 'directory' property. - */ - public void setDirectory(final boolean directory) { - this.directory = directory; - } - - /** - * Getter of the 'empty' property. - * - * @return Value of the 'empty' property. - */ - public boolean isEmpty() { - return empty; - } - - /** - * Setter for the 'empty' property. - * - * @param empty New value for the 'empty' property. - */ - public void setEmpty(final boolean empty) { - this.empty = empty; - } - - /** - * Getter of the 'jarFile' property. - * - * @return Value of the 'jarFile' property. - */ - public boolean isJarFile() { - return jarFile; - } - - /** - * Setter for the 'jarFile' property. - * - * @param jarFile New value for the 'jarFile' property. - */ - public void setJarFile(final boolean jarFile) { - this.jarFile = jarFile; - } - - /** - * Getter of the 'packedJarFile' property. - * - * @return Value of the 'packedJarFile' property. - */ - public boolean isPackedJarFile() { - return packedJarFile; - } - - /** - * Setter for the 'packedJarFile' property. - * - * @param packedJarFile New value for the 'packedJarFile' property. - */ - public void setPackedJarFile(final boolean packedJarFile) { - this.packedJarFile = packedJarFile; - } - - /** - * Getter of the 'signedJarFile' property. - * - * @return Value of the 'signedJarFile' property. - */ - public boolean isSignedJarFile() { - return signedJarFile; - } - - /** - * Setter for the 'signedJarFile' property. - * - * @param signedJarFile New value for the 'signedJarFile' property. - */ - public void setSignedJarFile(final boolean signedJarFile) { - this.signedJarFile = signedJarFile; - } - - /** - * Getter of the 'lastModified' property. - * - * @return Value of the 'lastModified' property. - */ - public long getLastModified() { - return lastModified; - } - - /** - * Setter for the 'lastModified' property. - * - * @param lastModified New value for the 'lastModified' property. - */ - public void setLastModified(final long lastModified) { - this.lastModified = lastModified; - } - - /** - * Getter of the 'permissions' property. - * - * @return Value of the 'permissions' property. - */ - public int getPermissions() { - return permissions; - } - - /** - * Setter for the 'permissions' property. - * - * @param permissions New value for the 'permissions' property. - */ - public void setPermissions(final int permissions) { - this.permissions = permissions; - } - - /** - * Getter of the 'name' property. - * - * @return Value of the 'name' property. - */ - public String getName() { - return name; - } - - /** - * Setter for the 'name' property. - * - * @param name New value for the 'name' property. - */ - public void setName(final String name) { - this.name = name; - } -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java deleted file mode 100644 index 042be6d9ffe4..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java +++ /dev/null @@ -1,1350 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.utils; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Stack; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.apache.tools.ant.Project; -import org.apache.tools.bzip2.CBZip2InputStream; - -/** - * A collection of utility methods used throughout the custom tasks classes. - * - * @author Kirill Sorokin - */ -public final class Utils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - /** - * The current ant project. Some of its methods will get called in process of - * the executions of some of the utility procedures. Thus the ant tasks using the - * class are strongly encouraged to call the {@link #setProject(Project)} - * method prior to suing any other functionality. - */ - private static byte[] buffer = new byte[102400]; - - private static Project project = null; - - private static boolean tarInitialized = false; - - private static String tarExecutable = null; - - private static boolean lsInitialized = false; - private static String lsExecutable = null; - private static String xmx; - private static String permSize; - private static String maxPermSize; - /** - * Setter for the 'project' property. - * - * @param project New value for the 'project' property. - */ - public static void setProject(final Project project) { - Utils.project = project; - } - - /** - * Calculates the MD5 checksum for the given file. - * - * @param file File for which the checksum should be calculated. - * @return The MD5 checksum of the file. - * @throws java.io.IOException if an I/O error occurs. - */ - public static String getMd5(final File file) throws IOException { - return getDigest(file, MD5); - } - - /** - * Checks whether the given file is a directory. - * - * @param file File to check for being a directory. - * @return true if the file is a directory, false - * otherwise. - */ - public static boolean isEmpty(final File file) { - if (file.listFiles().length == 0) { - return true; - } else { - return false; - } - } - - /** - * Checks whether the given file is a jar archive. - * - * @param file File to check for being a jar archive. - * @return true if the file is a jar archive, false - * otherwise. - */ - @SuppressWarnings("CallToThreadDumpStack") - public static boolean isJarFile(final File file) { - if (file.getName().endsWith(JAR_EXTENSION)) { - JarFile jar = null; - try { - jar = new JarFile(file); - return true; - } catch (IOException e) { - e.printStackTrace(); - return false; - } finally { - if (jar != null) { - try { - jar.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } else { - return false; - } - } - - /** - * Checks whether the given file is a signed jar archive. - * - * @param file File to check for being a signed jar archive. - * @return true if the file is a signed jar archive, - * false otherwise. - * @throws java.io.IOException if an I/O error occurs. - */ - public static boolean isSigned(final File file) throws IOException { - JarFile jar = new JarFile(file); - - try { - Enumeration entries = jar.entries(); - boolean signatureInfoPresent = false; - boolean signatureFilePresent = false; - while (entries.hasMoreElements()) { - String entryName = entries.nextElement().getName(); - if (entryName.startsWith("META-INF/")) { - if (entryName.endsWith(".RSA") || entryName.endsWith(".DSA")) { - signatureFilePresent = true; - if(signatureInfoPresent) { - break; - } - } else if (entryName.endsWith(".SF")) { - signatureInfoPresent = true; - if(signatureFilePresent) { - break; - } - } - } - } - return signatureFilePresent && signatureInfoPresent; - } finally { - jar.close(); - } - } - - /** - * Verifies that the jar archive is correct. This method tries to access all - * jar archive entries and to load all the classes. - * - * @param file Jar archive to check. - * @return true is the archive is correct, false - * otherwise. - * @throws java.io.IOException if an I/O error occurs. - */ - public static boolean verify(final File file) throws IOException { - Results results = runClass(VERIFIER_CLASSNAME, file.getAbsolutePath()); - - if (results.getExitcode() == 0) { - return true; - } else { - System.out.println(results.getStdout()); - System.out.println(results.getStderr()); - System.out.println(results.getExitcode()); - return false; - } - } - - /** - * Verifies that the if jar archive is placed next to jad, the jad file - * contains correct jar size - * - * @param file Jar archive to check. - * @return true is the archive is correct, false - * otherwise. - * @throws java.io.IOException if an I/O error occurs. - */ - public static boolean verifyJad(final File file) throws IOException { - final String name = file.getName(); - if(name.endsWith(".jar")) { - File jad = new File(file.getParent(), - name.substring(0, name.length()-4) + ".jad"); - if(jad.exists()) { - FileInputStream fis = new FileInputStream(jad); - String string = read(fis).toString(); - fis.close(); - final Matcher matcher = Pattern.compile( - "MIDlet-Jar-Size: ([0-9]+).*"). - matcher(string); - if (matcher.find()) { - final long size = new Long(matcher.group(1)).longValue(); - final long realSize = file.length(); - if(realSize!=size) { - System.out.println("... java descriptor file exist : " + jad); - System.out.println("... expected jar size : " + size); - System.out.println("... real jar size : " + realSize); - return false; - } - } - - } - } - return true; - } - - /** - * Fully reads an input stream into a character sequence using the system's - * default encoding. - * - * @param in Input sream to read. - * @return The read data as a character sequence. - * @throws java.io.IOException if an I/O error occurs. - */ - public static CharSequence read(final InputStream in) throws IOException { - StringBuilder builder = new StringBuilder(); - byte[] buf = new byte[1024]; - while (in.available() > 0) { - int read = in.read(buf); - - String readString = new String(buf, 0, read); - for(String string : readString.split(NEWLINE_REGEXP)) { - builder.append(string).append(LINE_SEPARATOR); - } - } - - return builder; - } - - /** - * Fully transfers the given input stream to the given output stream. - * @param in Input stream to read and transfer. - * @param out Output stream to transfer data to. - * @throws java.io.IOException if an I/O error occurs. - */ - public static void copy( - final InputStream in, - final OutputStream out) throws IOException { - int read; - while (in.available() > 0) { - read = in.read(buffer); - if (read > 0) { - out.write(buffer, 0, read); - } - } - } - - /** - * Unzips a zip archive to the specified directory. - * - * @param file Zip archive to extract. - * @param directory Directory which will be the target for the extraction. - * @throws java.io.IOException if an I/O error occurs. - */ - public static void unzip( - final File file, - final File directory) throws IOException { - ZipFile zip = new ZipFile(file); - - if (directory.exists() && directory.isFile()) { - throw new IOException("Directory is an existing file, cannot unzip."); - } - - if (!directory.exists() && !directory.mkdirs()) { - throw new IOException("Cannot create directory"); - } - - Enumeration entries = - (Enumeration) zip.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - - File entryFile = new File(directory, entry.getName()); - - InputStream in; - OutputStream out; - if (entry.getName().endsWith(SLASH)) { - entryFile.mkdirs(); - } else { - in = zip.getInputStream(entry); - out = new FileOutputStream(entryFile); - - copy(in, out); - - in.close(); - out.close(); - } - - entryFile.setLastModified(entry.getTime()); - } - - zip.close(); - } - - public static void nativeUnzip( - final File file, - final File directory) throws IOException { - final String[] command = new String[] { - getUnzipExecutable(), - file.getAbsolutePath(), - "-d", - directory.getAbsolutePath()}; - - if (project != null) { - project.log(" running command: " + Arrays.asList(command)); - } - - final Results results = run(command); - - if (results.getExitcode() != 0) { - System.out.println(results.getStdout()); - System.out.println(results.getStderr()); - throw new IOException(); - } - } - - private static String findTarExecutable() { - if (!tarInitialized) { - for (String s : new String[]{NATIVE_GNUTAR_EXECUTABLE, NATIVE_GTAR_EXECUTABLE, NATIVE_TAR_EXECUTABLE}) { - try { - run(s); - tarExecutable = s; - break; - } catch (IOException ex) { - } - } - } - tarInitialized = true; - return tarExecutable; - } - - private static String findLsExecutable() { - if (!lsInitialized) { - try { - run(LS_EXECUTABLE); - lsExecutable = LS_EXECUTABLE; - } catch (IOException ex) { - } - lsInitialized = true; - } - return lsExecutable; - } - /** - * Untars a tar(.tar.gz|.tgz|.tar.bz2|.tar.bzip2) archive to the specified directory. - * - * @param file Tar archive to extract. - * @param directory Directory which will be the target for the extraction. - * @throws java.io.IOException if an I/O error occurs. - */ - - public static void nativeUntar( - final File file, - final File directory) throws IOException { - boolean gzipCompression = - file.getName().endsWith(".tar.gz") || - file.getName().endsWith(".tgz"); - boolean bzip2Compression = - file.getName().endsWith(".tar.bz2") || - file.getName().endsWith(".tar.bzip2"); - - File tempSource = null; - if (gzipCompression || bzip2Compression) { - tempSource = File.createTempFile("temp-tar-file", ".tar", directory); - if (project != null) { - project.log("... extract compressed tar archive to temporary file " + tempSource); - } - final FileInputStream fis = new FileInputStream(file); - InputStream is = (gzipCompression) ? new GZIPInputStream(fis) : new CBZip2InputStream(fis); - FileOutputStream fos = null; - try { - fos = new FileOutputStream(tempSource); - copy(is, fos); - } catch (IOException e) { - if(fos != null) { - fos.close(); - fos = null; - } - tempSource.delete(); - throw e; - } finally { - if(fos != null) { - fos.close(); - } - is.close(); - } - } - String tar = getTarExecutable(); - if(tar==null) { - throw new IOException("... native tar executable not available"); - } - - - final String[] command = new String[]{ - tar, - "xvf", - ((tempSource != null) ? tempSource : file).getName(), - "-C", - directory.getAbsolutePath().replace("\\","/") - }; - - if (project != null) { - project.log(" running command: " + Arrays.asList(command)); - } - try { - final Results results = run( - ((tempSource != null) ? tempSource : file).getAbsoluteFile().getParentFile(), - command); - - if (results.getExitcode() != 0) { - System.out.println(results.getStdout()); - System.out.println(results.getStderr()); - throw new IOException(); - } - } finally { - if (tempSource != null) { - tempSource.delete(); - } - } - } - /** - * Deletes a file. If the file is a directory its contents are recursively - * deleted. - * - * @param file File to be deleted. - */ - public static void delete(final File file) { - if (file.isDirectory()) { - for (File child: file.listFiles()) { - delete(child); - } - } - if (!file.delete()) { - file.deleteOnExit(); - } - } - - /** - * Measures the size of a file. If the file is a directory, its size would be - * equal to the sum of sizes of all its files and subdirectories. - * - * @param file File whose size should be measured. - * @return The size of file. - */ - public static long size(final File file) { - long size = 0; - - if (file.isDirectory()) { - for (File child: file.listFiles()) { - size += size(child); - } - } - - return size + file.length(); - } - - /** - * Converts the given string to its java-style ASCII equivalent, escaping - * non ASCII characters with their \\uXXXX sequences. - * - * @param string String to escape. - * @return The escaped string. - */ - @SuppressWarnings("CallToThreadDumpStack") - public static String toAscii(final String string) { - Properties properties = new Properties(); - - properties.put(UBERKEY, string); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try { - properties.store(outputStream, ""); - } catch (IOException e) { - e.printStackTrace(); - return string; - } - - Matcher matcher = Pattern.compile(UBERKEY_REGEXP, Pattern.MULTILINE).matcher(outputStream.toString()); - - if (matcher.find()) { - return matcher.group(1); - } else { - return string; - } - } - - /** - * Writes the given character sequence to the given file. - * - * @param file File to which the character sequence should be written. - * @param chars Character sequence which should be written to the file. - * @throws java.io.IOException if an I/O error occurs. - */ - public static void write( - final File file, - final CharSequence chars) throws IOException { - OutputStreamWriter writer = - new OutputStreamWriter(new FileOutputStream(file), UTF8); - writer.write(chars.toString()); - writer.close(); - } - - /** - * Copies the contents of a file to the given output stream. - * - * @param source File whose contents should be copied. - * @param target Output stream to which the file's contents should be - * transferred. - * @throws java.io.IOException if an I/O error occurs. - */ - public static void copy( - final File source, - final OutputStream target) throws IOException { - FileInputStream input = new FileInputStream(source); - copy(input, target); - input.close(); - } - - /** - * Copies one file to another. - * - * @param source File to be copied. - * @param target File which should be come the copy of the source one. - * @throws java.io.IOException if an I/O error occurs. - */ - public static void copy( - final File source, - final File target) throws IOException { - FileOutputStream out = new FileOutputStream(target); - copy(source, out); - out.close(); - } - - /** - * Sends an HTTP POST request to the given URL. The supplied parameters will be - * passed as part of the request body according to - * {@link http://www.faqs.org/rfcs/rfc1945.html}. - * - * @param url URL to which the POST request should be sent. - * @param args Request parameters. - * @return The first line of the server response, e.g. "HTTP/1.x 200 OK". - * @throws java.io.IOException if an I/O error occurs. - */ - public static String post( - final String url, - final Map args) throws IOException { - final String boundary = "---------------" + Math.random(); - final byte[] realBoundary = ("--" + boundary).getBytes("UTF-8"); - final byte[] endBoundary = ("--" + boundary + "--").getBytes("UTF-8"); - final byte[] crlf = new byte[]{13, 10}; - - final HttpURLConnection connection = - (HttpURLConnection) new URL(url).openConnection(); - - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", - "multipart/form-data; boundary=" + boundary); - connection.setDoOutput(true); - connection.setDoInput(true); - - connection.connect(); - final OutputStream out = connection.getOutputStream(); - - final Iterator iterator = args.keySet().iterator(); - while (iterator.hasNext()) { - String key = iterator.next(); - Object value = args.get(key); - - out.write(realBoundary); - out.write(crlf); - - if (value instanceof File) { - File file = (File) value; - - out.write(("Content-Disposition: form-data; name=\"" + - key + "\"; filename=\"" + - file.getName() + "\"").getBytes("UTF-8")); - out.write(crlf); - - out.write(("Content-Type: " + - "application/octet-stream").getBytes("UTF-8")); - out.write(crlf); - out.write(crlf); - - copy(file, out); - } - - if (value instanceof String) { - String string = (String) value; - - out.write(("Content-Disposition: form-data; " + - "name=\"" + key + "\"").getBytes("UTF-8")); - out.write(crlf); - out.write(crlf); - - out.write(string.getBytes("UTF-8")); - } - - out.write(crlf); - } - - out.write(endBoundary); - out.close(); - - return "" + connection.getResponseCode() + " " + connection.getResponseMessage(); - } - - /** - * Signs the given jar file using the data provided in the given keystore. - * - * @param file Jar archive which will be signed. - * @param keystore Path to the keystore file. - * @param alias Keystore alias. - * @param password Keystore password. - * @return The results of executing the jarsigner utility. - * @throws java.io.IOException if an I/O error occurs. - */ - public static Results sign( - final File file, - final String keystore, - final String alias, - final String password) throws IOException { - List command = new ArrayList(); - - command.add(getJarSignerExecutable()); - command.add("-keystore"); - command.add(keystore); - command.add(file.getAbsolutePath()); - command.add(alias); - - Process process = new ProcessBuilder(command).start(); - process.getOutputStream().write(password.getBytes()); - - return handleProcess(process); - } - - private static int getPermissionsAnalized(final File file) { - if (file.isDirectory()) { - return getIntegerValue(DEFAULT_PERMISSION_DIR_PROP, DEFAULT_PERMISSION_DIR); - - } else { - return isExecutableAnalized(file) ? - getIntegerValue(DEFAULT_EXECUTABLE_PERMISSION_FILE_PROP, DEFAULT_EXECUTABLE_PERMISSION_FILE) : - getIntegerValue(DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE_PROP, DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE); - } - } - private static int getIntegerValue(String prop, int defaultValue) { - int result = defaultValue; - String value = project.getProperty(prop); - if (value != null && !value.equals("")) { - try { - result = Integer.parseInt(value); - } catch (NumberFormatException e) { - if (project != null) { - project.log("Error while parsing property " + prop - + " which value is [" + value + "]" - + " but should be integer", e, Project.MSG_WARN); - } - } - } - return result; - } - - private static boolean isExecutableAnalized(File file) { - int index = file.getName().lastIndexOf("."); - String ext = (index != -1) ? file.getName().substring(index + 1) : ""; - - for (String e : EXECUTABLE_EXTENSIONS) { - if (ext.equals(e)) { - return true; - } - } - for (String e : NOT_EXECUTABLE_EXTENSIONS) { - if (ext.equals(e)) { - return false; - } - } - - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - byte[] bytes = new byte[64]; - - int c; - c = fis.read(bytes); - if (c >= 4) { // length of ELF header and min length of "#!/X" string - if (bytes[0] == '\177' - && bytes[1] == 'E' - && bytes[2] == 'L' - && bytes[3] == 'F') { - return true; - } else if (bytes[0] == '#' && bytes[1] == '!') { - String s = new String(bytes, 0, c); - String[] array = s.split("(?:\r\n|\n|\r)"); - - if (array.length > 0) { - //read the first line only - //allow lines like "#! /bin/sh" - if (array[0].replaceAll("#!(\\s)+/", "#!/").startsWith("#!/")) { - return true; - } - } - } - } - } catch (IOException e) { - if(fis!=null) { - try { - fis.close(); - } catch (IOException ex) { - } - } - } - - return false; - } - - public static int getPermissions(final File file) { - try { - final String lsExec = getLsExecutable(); - if (lsExec == null) { - //no ls found - return getPermissionsAnalized(file); - } - final Results results = run(file.getParentFile(), lsExec, "-ld", file.getName()); - - final String output = results.getStdout().toString().trim(); - - if (project != null) { - project.log(" " + output); - } else { - System.out.println(output); - } - - int permissions = 0; - - if(output.length() < 9) { - return 777; - } - - for (int i = 0; i < 9; i++) { - char character = output.charAt(i + 1); - - if (i % 3 == 0) { - permissions *= 10; - } - - if (character == '-') { - continue; - } else if ((i % 3 == 0) && (character == 'r')) { - permissions += 4; - } else if ((i % 3 == 1) && (character == 'w')) { - permissions += 2; - } else if ((i % 3 == 2) && (character == 'x')) { - permissions += 1; - } else { - return 777; - } - } - - return permissions; - } catch (IOException e) { - return -1; - } - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Calculates the digital digest of the given file's contents using the - * supplied algorithm. - * - * @param file File for which the digest should be calculated. - * @param algorithm Algorithm which should be used for calculating the digest. - * @return The calculated digest as a string. - * @throws java.io.IOException if an I/O error occurs. - */ - private static String getDigest( - final File file, - final String algorithm) throws IOException { - try { - MessageDigest md = MessageDigest.getInstance(algorithm); - md.reset(); - - InputStream input = null; - try { - input = new FileInputStream(file); - - while (input.available() > 0) { - md.update(buffer, 0, input.read(buffer)); - } - } finally { - if (input != null) { - input.close(); - } - } - - byte[] bytes = md.digest(); - - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < bytes.length; i++) { - byte b = bytes[i]; - - String byteHex = Integer.toHexString(b); - if (byteHex.length() == 1) { - byteHex = "0" + byteHex; - } - if (byteHex.length() > 2) { - byteHex = byteHex.substring(byteHex.length() - 2); - } - - builder.append(byteHex); - } - - return builder.toString(); - } catch (NoSuchAlgorithmException e) { - throw new IOException("Could not find the aglorithm"); - } - } - - /** - * Runs the given class in a separate JVM. - * - * @param clazz Classname of the class which should be run. - * @param args Command-line arguments for the class. - * @return Results of executing the command (exitcode, stdout and stderr - * contents). - * @throws java.io.IOException if an I/O error occurs. - */ - private static Results runClass( - final String clazz, - final String... args) throws IOException { - final String classPath = project.getProperty(CLASSPATH_VALUE_PROPERTY); - - final List command = new ArrayList(); - - command.add(getVerificationJavaExecutable()); - command.add(CLASSPATH_ARG); - command.add(classPath); - command.add(clazz); - command.addAll(Arrays.asList(args)); - - return run(command.toArray(new String[command.size()])); - } - - @SuppressWarnings("SleepWhileInLoop") - private static Results handleProcess(Process process) throws IOException { - StringBuilder processStdOut = new StringBuilder(); - StringBuilder processStdErr = new StringBuilder(); - - int errorCode = 0; - boolean doRun = true; - long delay = INITIAL_DELAY; - - final String projectMaxTime = project.getProperty(MAX_EXECUTION_TIME_PROPERTY); - long maxExecutionTime = (projectMaxTime!=null) ? - Long.parseLong(projectMaxTime) : - MAX_EXECUTION_TIME; - long start = System.currentTimeMillis(); - long end = start + maxExecutionTime; - - while(doRun && (maxExecutionTime==0 || System.currentTimeMillis() < end)) { - try { - Thread.sleep(delay); - if(delay < MAX_DELAY) { - delay += DELTA_DELAY; - } - } catch (InterruptedException e) { - // do nothing - this may happen every now and then - } - - try { - errorCode = process.exitValue(); - doRun = false; - } catch (IllegalThreadStateException e) { - // do nothing - the process is still running - } - - CharSequence string = read(process.getInputStream()); - if (string.length() > 0) { - processStdOut.append(string); - } - - string = read(process.getErrorStream()); - if (string.length() > 0) { - processStdErr.append(string); - } - } - process.destroy(); - return new Results(processStdOut, processStdErr, errorCode); - } - /** - * Runs the specified command using the ProcessBuilder class. - * - * @param command Path to the executable and its arguments. - * @return Results of executing the command (exitcode, stdout and stderr - * contents). - * @throws java.io.IOException if an I/O error occurs. - */ - private static Results run(final String... command) throws IOException { - - Process process = new ProcessBuilder(command).start(); - - return handleProcess(process); - } - - private static Results run(File directory, final String... command) throws IOException { - - Process process = new ProcessBuilder(command).directory(directory).start(); - - return handleProcess(process); - } - - public static String getLsExecutable() { - final String value = project.getProperty(LS_EXECUTABLE_PROPERTY); - return (value == null || value.equals("")) ? findLsExecutable() : value; - } - public static String getUnzipExecutable() { - return getExecutable(UNZIP_EXECUTABLE_PROPERTY, NATIVE_UNZIP_EXECUTABLE); - } - public static String getTarExecutable() { - final String value = project.getProperty(TAR_EXECUTABLE_PROPERTY); - return (value == null || value.equals("")) ? findTarExecutable() : value; - } - public static String getJarSignerExecutable() { - return getExecutable(JARSIGNER_EXECUTABLE_PROPERTY, JARSIGNER_EXECUTABLE); - } - public static String getVerificationJavaExecutable() { - return getExecutable(VERIFICATION_JAVA_EXECUTABLE_PROPERTY, VERIFICATION_JAVA_EXECUTABLE); - } - private static String getExecutable(String propName, String defaultValue) { - final String value = project.getProperty(propName); - return (value == null || value.equals("")) ? defaultValue : value; - } - /** - * Resolving the project property - * - * @param string Property to resolve - * @return Results of resolving the property - */ - public static String resolveProperty(String string) { - return resolveProperty(string,project); - } - - /** - * Resolving the project property - * - * @param string Property to resolve - * @param prj Project to resolve the property for - * @return Results of resolving the property - */ - public static String resolveProperty(String string, Project prj) { - final List resolving = new ArrayList (); - return resolveProperty(string, prj, resolving); - } - - private static String resolveProperty(String string, Project prj, List resolving) { - if(string==null || string.isEmpty()) { - return string; - } - StringBuilder result = new StringBuilder(string.length()); - StringBuilder buf = null; - Stack started = new Stack (); - boolean inside = false; - - for (int i = 0; i < string.length(); i++) { - char c = string.charAt(i); - switch (c) { - case '$': - if (i + 1 < string.length() && string.charAt(i + 1) == '{') { - if (inside) { - started.push(buf); - } - i++; - inside = true; - buf = new StringBuilder(); - } else { - (inside ? buf : result).append("$"); - } - break; - case '}': - if (inside) { - final String propName = buf.toString(); - String propValue; - - if(resolving.contains(propName)) { - propValue = null; - } else { - resolving.add(propName); - propValue = resolveProperty(prj.getProperty(propName),prj,resolving); - resolving.remove(propName); - } - final String resolved = propValue != null ? propValue : "${" + propName + "}"; - if (!started.empty()) { - buf = started.pop().append(resolved); - } else { - result.append(resolved); - inside = false; - } - } else { - result.append(c); - } - break; - default: - (inside ? buf : result).append(c); - } - } - - if (inside) { - do { - if (!started.empty()) { - buf = started.pop().append("${").append(buf); - } else { - result.append("${").append(buf); - buf = null; - } - } while (buf != null); - } - return result.toString(); - } - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The private default constructor which prevents the class from being - * instantiated. - */ - private Utils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Inner Classes - /** - * This class is a container for the results of executing a process. It keeps - * the values of <stdout>, <stderr> and - * the exitcode. - * - * @author Kirill Sorokin - */ - public static class Results { - /** - * Value of <stdout>. - */ - private CharSequence stdout; - - /** - * Value of <stdout>. - */ - private CharSequence stderr; - - /** - * Value of the exitcode. - */ - private int exitcode; - - /** - * Creates a new instance of Results. The constructor simply - * initializes the class properties with the passed-in values. - * - * @param stdout Contents of the process's <stdout>. - * @param stderr Contents of the process's <stderr>. - * @param exitcode The process's exitcode. - */ - public Results( - final CharSequence stdout, - final CharSequence stderr, - final int exitcode) { - this.stdout = stdout; - this.stderr = stderr; - this.exitcode = exitcode; - } - - /** - * Getter for the 'stdout' property. - * - * @return Value of the 'stdout' property. - */ - public CharSequence getStdout() { - return stdout; - } - - /** - * Getter for the 'stderr' property. - * - * @return Value of the 'stderr' property. - */ - public CharSequence getStderr() { - return stderr; - } - - /** - * Getter for the 'exitcode' property. - * - * @return Value of the 'exitcode' property. - */ - public int getExitcode() { - return exitcode; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Maximum allowed execution time for a process. - */ - public static final int MAX_EXECUTION_TIME = - 300000; // NOMAGI - - /** - * Property for setting maximum allowed execution time for a process. - */ - public static final String MAX_EXECUTION_TIME_PROPERTY = - "process.max.execution.time"; // NOI18N - - /** - * Max delay (in milliseconds) which to wait between checking the process state. - */ - public static final int MAX_DELAY = - 50; // NOMAGI - - /** - * Delta delay (in milliseconds) which to increase the delay between checking the process state. - */ - public static final int DELTA_DELAY = - 1; // NOMAGI - /** - * Initial delay (in milliseconds) between checking the process state. - */ - public static final int INITIAL_DELAY = - 1; // NOMAGI - - /** - * Prefix for JVM command-line arguments. - */ - public static final String ARG_PREFIX = - "-J"; // NOI18N - - /** - * Maximum heap size command-line argument prefix. - */ - public static final String XMX_ARG = - "-Xmx"; // NOI18N - - /** - * PermSize command-line argument prefix. - */ - public static final String PERM_SIZE_ARG = - "-XX:PermSize="; // NOI18N - - /** - * MacPermSize command-line argument prefix. - */ - public static final String MAX_PERM_SIZE_ARG = - "-XX:MaxPermSize="; // NOI18N - - /** - * Classpath command-line argument prefix. - */ - public static final String CLASSPATH_ARG = - "-cp"; // NOI18N - - /** - * Classname of the class which should be called to verify the unpacked jar - * file. - */ - public static final String VERIFIER_CLASSNAME = - "org.netbeans.installer.infra.build.ant.utils.VerifyFile"; // NOI18N - - /** - * Name of the ant project's property which contains the classpath which should - * be used for running classes. - */ - public static final String CLASSPATH_VALUE_PROPERTY = - "custom.tasks.cls"; // NOI18N - - /** - * MD5 digital digest algorithm code name. - */ - public static final String MD5 = - "MD5"; // NOI18N - - /** - * Extension of jar files. - */ - public static final String JAR_EXTENSION = - ".jar"; // NOI18N - - /** - * Marker file which indicated that the jar file is signed. - */ - public static final String SUN_MICR_RSA = - "META-INF/SUN_MICR.RSA"; // NOI18N - - /** - * Marker file which indicated that the jar file is signed. - */ - public static final String SUN_MICR_SF = - "META-INF/SUN_MICR.SF"; // NOI18N - - /** - * A regular expression which matches any line separator. - */ - public static final String NEWLINE_REGEXP = - "(?:\n\r|\r\n|\n|\r)"; // NOI18N - - /** - * Forward slash. - */ - public static final String SLASH = - "/"; // NOI18N - - /** - * An artificial key name used in converting a string to ASCII. - */ - public static final String UBERKEY = - "uberkey"; // NOI18N - - /** - * An artificial regular expression used in converting a string to ASCII. - */ - public static final String UBERKEY_REGEXP = - "uberkey=(.*)$"; // NOI18N - - /** - * Name of the UTF-8 encoding. - */ - public static final String UTF8 = - "UTF-8"; // NOI18N - - - /** - * Name of the system property which contains the operating system name. - */ - public static final String OS_NAME = - "os.name"; // NOI18N - - /** - * Name of the windows operating system. - */ - public static final String WINDOWS = - "Windows"; // NOI18N - - /** - * Name of the windows operating system. - */ - public static final boolean IS_WINDOWS = - System.getProperty(OS_NAME).contains(WINDOWS); // NOI18N - /** - * Name of the system property which contains the current java home. - */ - public static final String JAVA_HOME = - "java.home"; // NOI18N - /** - * Value of the system property which contains the current java home. - */ - public static final String JAVA_HOME_VALUE = - System.getProperty(JAVA_HOME); // NOI18N - - /** - * Path to the java executable on non-windows platforms. Relative to the java - * home. - */ - public static final String JAVA = - "bin/java"; // NOI18N - - /** - * Path to the java executable on windows platforms. Relative to the java - * home. - */ - public static final String JAVA_EXE = - "bin\\java.exe"; // NOI18N - - private static final String VERIFICATION_JAVA_EXECUTABLE = - JAVA_HOME_VALUE + File.separator + ((IS_WINDOWS) ? JAVA_EXE : JAVA); - - private static final String NATIVE_UNZIP_EXECUTABLE = - (IS_WINDOWS) ? "unzip.exe" : "unzip"; //NOI18N - private static final String NATIVE_TAR_EXECUTABLE = - (IS_WINDOWS) ? "tar.exe" : "tar"; //NOI18N - private static final String NATIVE_GTAR_EXECUTABLE = - (IS_WINDOWS) ? "gtar.exe" : "gtar"; //NOI18N - private static final String NATIVE_GNUTAR_EXECUTABLE = - (IS_WINDOWS) ? "gnutar.exe" : "gnutar"; //NOI18N - - public static final String TAR_EXECUTABLE_PROPERTY = - "tar.executable"; - public static final String UNZIP_EXECUTABLE_PROPERTY = - "unzip.executable"; - public static final String LS_EXECUTABLE_PROPERTY = - "ls.executable"; - public static final String JARSIGNER_EXECUTABLE_PROPERTY = - "jarsigner.executable"; - public static final String VERIFICATION_JAVA_EXECUTABLE_PROPERTY = - "verification.java.executable"; - - public static final String DEFAULT_EXECUTABLE_PERMISSION_FILE_PROP = - "default.file.executable.permissions"; - public static final String DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE_PROP = - "default.file.not.executable.permissions"; - public static final String DEFAULT_PERMISSION_DIR_PROP = - "default.dir.permissions"; - - private static final String JARSIGNER_EXECUTABLE = JAVA_HOME_VALUE + - ((IS_WINDOWS) ? "\\..\\bin\\jarsigner.exe" : "/../bin/jarsigner");//NOI18N - private static final String LS_EXECUTABLE = - (IS_WINDOWS) ? "ls.exe" : "ls";//NOI18N - public static final String LINE_SEPARATOR = System.getProperty("line.separator"); - - public static final String [] EXECUTABLE_EXTENSIONS = - {"so", "a", "jnilib", "dylib", "sl", - "sh", "pl", "rb", "py", "command"}; - public static final String [] NOT_EXECUTABLE_EXTENSIONS = - {"jar", "zip", "gz", "bzip2", "tgz", "txt", "xml", - "html", "htm", "pdf", "conf", "css", "java"}; - public static final int DEFAULT_EXECUTABLE_PERMISSION_FILE = 755;//rwx r-x r-x - public static final int DEFAULT_NOT_EXECUTABLE_PERMISSION_FILE = 644;//rwx r-- r-- - public static final int DEFAULT_PERMISSION_DIR = 755; //rwx r-x r-x -} diff --git a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/VerifyFile.java b/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/VerifyFile.java deleted file mode 100644 index 999b965f5fbb..000000000000 --- a/nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/VerifyFile.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.build.ant.utils; - -import java.io.File; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Enumeration; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -/** - * This class verifies the given jar file (first command-line argument) wrt its - * validitity, i.e. checks that all classes are loadable. It browses the jar entries - * and if it's a class, tries to load it. Mostly it watches for - * ClassFormatErrors and ignores several expected exceptions. - * - * It does not provide any means to validate the input data, since it's expected to - * be called exclusively from from Package. - * - * The success/failure is reported via exitcode, 0 means success, 1 - failure. - * - * @see org.netbeans.installer.infra.build.ant.Package - * - * @author Kirill Sorokin - */ -public class VerifyFile { - /** - * The main method. - * - * @param args command-line arguments - */ - public static void main(String[] args) { - File file = new File(args[0]); - - try { - JarFile jar = new JarFile(file); - URLClassLoader loader = - new URLClassLoader(new URL[]{file.toURI().toURL()}); - - Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - - if (getClassName(entry) != null) { - try { - System.out.println( - "loading class " + getClassName(entry)); // NOI18N - loader.loadClass(getClassName(entry)); - } catch (NoClassDefFoundError e) { - // do nothing; this is OK - classpath issues - } catch (IllegalAccessError e) { - // do nothing; this is also somewhat OK, since we do not - // define any security policies - } - } - } - - jar.close(); - - System.exit(0); - } catch (Throwable e) { - // we need to catch everything here in order to not - // allow unexpected exceptions to pass through - e.printStackTrace(); - System.exit(1); - } - } - - /** - * Converts a jar entry to a class name. - * - * @param entry JarEntry to process. - * @return The classname of the jar entry or null if it cannot be - * devised. - */ - private static String getClassName(JarEntry entry) { - final String name = entry.getName(); - - if (name.endsWith(".class")) { // NOI18N - final String className = - name.substring(0, name.length() - 6).replace('/', '.'); // NOMAGI - if (className.matches( - "([a-zA-Z][a-zA-Z0-9_]+\\.)+[a-zA-Z][a-zA-Z0-9_]+")) { // NOI18N - return className; - } else { - return null; - } - } - - return null; - } -} diff --git a/nbi/infra/build/.common/.templates/engine-template.properties b/nbi/infra/build/.common/.templates/engine-template.properties deleted file mode 100644 index 0cd0f727562a..000000000000 --- a/nbi/infra/build/.common/.templates/engine-template.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the engine sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path=engine - -# name of the engine's distributive file -engine.dist.file.name=nbi-engine.jar diff --git a/nbi/infra/build/.common/.templates/engine-template.xml b/nbi/infra/build/.common/.templates/engine-template.xml deleted file mode 100644 index 7f5d38e3ba29..000000000000 --- a/nbi/infra/build/.common/.templates/engine-template.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the engine use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/nbi/infra/build/.common/.templates/group-template.properties b/nbi/infra/build/.common/.templates/group-template.properties deleted file mode 100644 index 1aea95d4501f..000000000000 --- a/nbi/infra/build/.common/.templates/group-template.properties +++ /dev/null @@ -1,74 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../../.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the group's sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path= - -# core group's properties -# * ${group.uid} - the unique identifier for the group; a registry can contain -# only one group with a given identifier -group.uid= - -# miscellaneous group properties -# * ${group.offset} - order of the group's node among its parent's children, -# the bigger the offset value, the further the group's node will be -# * ${group.expand} - whether to automatically expand the group's node in the -# components tree or not; 'true'/'false' -# * ${group.visible} - whether the group's node is visible or not (note that -# this value will be modified at nbi runtime, 'true' may become 'false' if -# the group is filtered out); 'true'/'false' -group.offset=10000 -group.expand=true -group.visible=true - -# additional groups's properties; these will appear in the group's descriptor -# and in the registry in the form of value -# tags. -# * ${group.properties.length} - total number of the properties -# * indices should start with 1 -# * properties are not i18n compliant -group.properties.length=0 -#group.properties.1.name= -#group.properties.1.value= - -# sources parameters; a search-and-replace will be run over the sources after -# check-out, replacing [token] => [value]; regular expressions are not allowed -# * ${sources.params.length} - total number of the parameters -# * indices should start with 1 -# * parameters are not i18n compliant -sources.params.length=0 -#sources.params.1.token= -#sources.params.1.value= diff --git a/nbi/infra/build/.common/.templates/group-template.xml b/nbi/infra/build/.common/.templates/group-template.xml deleted file mode 100644 index e49fe303bba8..000000000000 --- a/nbi/infra/build/.common/.templates/group-template.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the group use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/nbi/infra/build/.common/.templates/product-template.properties b/nbi/infra/build/.common/.templates/product-template.properties deleted file mode 100644 index 8e3e334b7f6c..000000000000 --- a/nbi/infra/build/.common/.templates/product-template.properties +++ /dev/null @@ -1,160 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../../.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the products's sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path= - -# core product properties: -# * ${product.uid} - product "family" (e.g. nb-ide) -# * ${product.version} - actual products' version; together with the uid it -# forms the unique identifier for the product) -# * ${product.platforms} - the list of platforms that are supported by this -# product (note that this property is not related to native libraries) -product.uid= -product.version= -product.platforms=windows linux solaris-sparc solaris-x86 macosx-ppc macosx-x86 - -# miscellaneous product properties: -# * ${product.status} - default status that the product will have in the -# registry. it is meant to be always "not-installed", unless you want -# something really exotic -# * ${product.offset} - order of the product's node among its parent's -# children, the bigger the offset value, the further the product's node will -# be -# * ${product.expand} - whether to automatically expand the product's node in -# the components tree or not; 'true'/'false' -# * ${product.visible} - whether the product's node is visible or not (note -# that this value will be modified at nbi runtime, 'true' may become 'false' -# if the product is filtered out); 'true'/'false' -# * ${product.features} - list of features that this porduct belongs to; the -# list should be space-separated -product.status=not-installed -product.offset=10000 -product.expand=false -product.visible=true -product.features= - -# list of configuration logic jar files; normally the first one would be the -# distributive file of the product's netbeans project - see also ${build.logic} -# property in product.properties -# * ${product.logic.length} - total number of the files -# * ${product.logic.N.uri} - uri at which the configuration logic file is located or -# * ${product.logic.N.path} - local path at which the configuration logic file is located -# * indices should start with 1 -product.logic.length=1 -product.logic.1.uri= -product.logic.1.path= - -# list of product installation data files -# * ${product.data.length} - total number of the files -# * ${product.data.N.uri} - uri at which the installation data file is located or -# * ${product.data.N.path} - local path at which the installation data file is located -# * ${product.data.N.zip} - whether the data file is a zip archive which needs to -# be extracted or it is a file that should be used directly; 'true'/'false' -# * ${product.data.N.tar} - whether the data file is a tar(|.gz|.bz2) archive which needs to -# be extracted or it is a file that should be used directly; 'true'/'false' -# * indices should start with 1 -product.data.length=1 -product.data.1.uri= -product.data.1.path= -product.data.1.zip= -product.data.1.tar= - - -# modificator for the required disk space parameter; the core value will be the -# sum of unzipped unstallation data files -# * the measurement unit is one byte -product.disk.space.modificator=0 - -# product's requirements (i.e. other products that should be installed -# in order for this product to succesfully install and function) -# * ${product.requirements.length} - total number of the requirements -# * indices should start with 1 -product.requirements.length=0 -#product.requirements.1.uid= -#product.requirements.1.version-lower= -#product.requirements.1.version-upper= - -# each product requirement can have several alternative requirements blocks -# each alternative requirement block has several requirements -# * product.requirements.{i}.alternatives.length - -# total number of alternative requirements blocks -# * product.requirements.{i}.alternatives.{j}.requirements.length - -# total number of requirements in specific OR block -# * if length is not specified it is taken as zero -# * indices should start with 1 -#product.requirements.1.alternatives.length= -#product.requirements.1.alternatives.1.requirements.length -#product.requirements.1.alternatives.1.requirements.1.uid= -#product.requirements.1.alternatives.1.requirements.1.version-lower= -#product.requirements.1.alternatives.1.requirements.1.version-upper= - -# product's conflicts (i.e. other products that prevent this product from -# functioning correctly, and thus cannot be installed together with it) -# * ${product.conflicts.length} - total number of the conflicts -# * indices should start with 1 -product.conflicts.length=0 -#product.conflicts.1.uid= -#product.conflicts.1.version-lower= -#product.conflicts.1.version-upper= - -# other products that should be installed prior to this product; these -# dependencies do not imply that the dependent product will be installed at -# all, but if both the current and the dependent product are selected for -# installation, the latter will be installed first -# * ${product.install-afters.length} - total number of the install-afters -# * indices should start with 1 -product.install-afters.length=0 -#product.install-afters.1.uid= - -# additional product's properties; these will appear in the product's -# descriptor and in the registry in the form of -# value tags. -# * ${product.properties.length} - total number of the properties -# * indices should start with 1 -# * properties are not i18n compliant -product.properties.length=0 -#product.properties.1.name= -#product.properties.1.value= - -# sources parameters; a search-and-replace will be run over the sources after -# check-out, replacing [token] => [value]; regular expressions are not allowed -# * ${sources.params.length} - total number of the parameters -# * indices should start with 1 -# * parameters are not i18n compliant -sources.params.length=0 -#sources.params.1.token= -#sources.params.1.value= diff --git a/nbi/infra/build/.common/.templates/product-template.xml b/nbi/infra/build/.common/.templates/product-template.xml deleted file mode 100644 index e5c8050474dd..000000000000 --- a/nbi/infra/build/.common/.templates/product-template.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the group use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/nbi/infra/build/.common/common.properties b/nbi/infra/build/.common/common.properties deleted file mode 100644 index 2eb2ec20d5eb..000000000000 --- a/nbi/infra/build/.common/common.properties +++ /dev/null @@ -1,238 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -##################################################################################### -# Initialization. Properties that are used during build script initialization. - -# location of the custom tasks' sources and the destination directory for their -# build -custom.tasks.src=${common.dir}/../.ant-lib/src -custom.tasks.cls=${basedir}/.ant-lib - -##################################################################################### -# Check-out. Properties that are used during check-out. - -# whether to check out sources, or copy them from the location specified in -# ${sources.dir}; 'true'/'false' -checkout.sources=true - -# coordinates of the project's sources within the cvs repository -# * ${cvs.root} - obvious -# * ${cvs.branch} - the branch from which the sources should be checked out; if -# this property is empty, then the sources will be checked out from trunk -# * ${cvs.timestamp} - the timestamp for which the sources should be checked out; if -# this property is empty, then the latest sources will be checked out -# * ${cvs.module} - the module that should be checked out; at this point the -# build framework is not compatible with modules which alias several other -# modules -cvs.root=:pserver:anoncvs@netbeans.org:/cvs -cvs.branch= -cvs.module=nbi -cvs.timestamp= - -# coordinates of the project's sources' localized files within the cvs -# repository -# * ${translatedfiles.module} - name of the cvs module with the localized files -# * ${translatedfiles.path} - path to the localized files for the project -# within the cvs module -translatedfiles.module=translatedfiles -translatedfiles.path=src/${cvs.module}/${cvs.path} - -# sources parameters; a search-and-replace will be run over the sources after -# check-out, replacing [token] => [value]; regular expressions are not allowed -# * ${sources.params.length} - total number of the parameters -# * indices should start with 1 -# * parameters are not i18n compliant -sources.params.length=0 -#sources.params.1.token= -#sources.params.1.value= - -# several simple shorthands for various directories -# * ${cvs.module.dir} - path to the root of the cvs module -# * ${cvs.dir} - path to the current project's sources root -# * ${translatedfiles.dir} - path to the localized files for the project -cvs.module.dir=${work.dir}/${cvs.module} -cvs.dir=${cvs.module.dir}/${cvs.path} -translatedfiles.dir=${work.dir}/${translatedfiles.module}/${translatedfiles.path} - -##################################################################################### -# NB Projects. Properties related to cleaning/building netbeans projects. - -# path to the netbeans project that should be built; relative to the -# ${cvs.dir} -nbproject.path=. - -# names of targets in component's (or engine's) build script that will be -# called as part of the build process -# * ${nb.target.clean} - will be called when cleaning the netbeans project -# * ${nb.target.build} - will be called when building the netbeans project -nb.target.clean=clean -nb.target.build=jar - -# additional properties which will be passed to the netbeans project build -# script -# * ${nb.platform.home} - location of the jdk codenamed "JDK 1.5", this jdk -# is expected to be used by all netbeans projects -# * ${nb.ignore.native} - tells the netbeans project's build script to skip -# building native components, if it is able to do so - these will be built -# as part of the project's global build script -# * ${nb.no.dependencies} - tells the netbeans project's build script to skip -# building its dependencies, the dependencies are expected to be built by the -# project's global build script -# * ${nb.dont.build.custom.tasks} - tells the netbeans project's build script -# to skip building custom tasks for it, as they will already be built by the -# global script -# * ${nb.custom.tasks.cls} - points the netbeans project's build script to the -# location of the built custom tasks -nb.platform.home=-Dplatforms.JDK_1.5.home=${java.home} -nb.platform.home.macos=-Dplatforms.JDK_1.5.home=${java.home} -nb.ignore.native=-Dignore.native=true -nb.no.dependencies=-Dno.dependencies=true -nb.dont.build.custom.tasks=-Ddont.build.custom.tasks=true -nb.custom.tasks.cls=-Dcustom.tasks.cls=${custom.tasks.cls} - -# default path to the distributives directory of the netbeans project; relative -# to ${nbproject.path} -nb.dist.path=dist - -# path to the classes directory of the netbeans project; relative to -# ${nbproject.path} -nb.classes.dir=build/classes - -# path to the manifest file of the netbeans project; relative to the -# ${nbproject.path} -nbproject.manifest=manifest.mf - -# path to the dist directory that the nbproject should use; since we do not use -# the netbeans' packaging mechanism, we have the flexibility to specify any -# distributives directory we want -nbproject.dist.dir=${cvs.dir}/${nbproject.path}/${nb.dist.path} - -##################################################################################### -# Native. Properties related to cleaning/building native components. - -# path to the directory with the sources for the native components; relative -# to the root of the project's sources -native.path=${cvs.module}/${cvs.path}/native - -# path to the directory with the localized files for the native components; -# relative to the root of the project's localized files directory -translatedfiles.native.path=${translatedfiles.module}/${translatedfiles.path}/native - -# list of platforms for which the native components should be built -# * the list should be space-separated -native.platforms=windows linux solaris-x86 solaris-sparc macosx - -# directory on the remote machine where the build script should operate -# * this is the default value, the actual value is expected to be passed in -# through the environment properties -remote.work.dir=~/.nbi-build - -# ssh properties: executable name, set of arguments and the command. -# * ${remote.host}, ${remote.port} and ${remote.user} are environment specific -# and are expected to be passed in through the environment properties -ssh.executable=ssh -ssh.arguments=-l ${remote.user} -p ${remote.port} ${remote.host} -ssh.command.clean=rm -rf ${remote.work.dir}; -ssh.command.build=rm -rf ${remote.work.dir}; \ - mkdir ${remote.work.dir}; \ - cd ${remote.work.dir}; \ - if [ "${cvs.branch}" = "" ]; then \ - if [ "${cvs.timestamp}" = "" ]; then \ - cvs -d ${cvs.root} co -P ${native.path}; \ - cvs -d ${cvs.root} co -P ${translatedfiles.native.path}; \ - else\ - cvs -D ${cvs.timestamp} -d ${cvs.root} co -P ${native.path}; \ - cvs -D ${cvs.timestamp} -d ${cvs.root} co -P ${translatedfiles.native.path}; \ - fi;\ - else \ - if [ "${cvs.timestamp}" = "" ]; then \ - cvs -d ${cvs.root} co -r ${cvs.branch} -P ${native.path}; \ - cvs -d ${cvs.root} co -r ${cvs.branch} -P ${translatedfiles.native.path}; \ - else \ - cvs -D ${cvs.timestamp} -d ${cvs.root} co -r ${cvs.branch} -P ${native.path}; \ - cvs -D ${cvs.timestamp} -d ${cvs.root} co -r ${cvs.branch} -P ${translatedfiles.native.path}; \ - fi;\ - fi; \ - cp -r ${translatedfiles.native.path} ${native.path}; \ - cd ${native.path}/${platform}; \ - make - -# scp properties: executable name, set of arguments, remote directory, local -# directory -# * ${remote.host}, ${remote.port} and ${remote.user} are platform and -# environment specific and are expected to be passed in through the -# environment properties -# * name of the file to copy is platform specific and is defined elsewhere, -# most likely in the base build script for a project type (engine, product, -# etc.) -# * ${platform} will be defined at runtime, as these commands will be executed -# in loop over the list of platforms -scp.executable=scp -scp.arguments=-P ${remote.port} -scp.remote.dir=${remote.user}@${remote.host}:${remote.work.dir}/${native.path}/${platform}/${nb.dist.path} -scp.local.dir=${work.dir}/${native.path}/${platform}/${nb.dist.path} - -# names of the native distributive files for various platforms -native.dist.file.windows=windows.dll -native.dist.file.linux=linux.so -native.dist.file.solaris-x86=solaris-x86.so -native.dist.file.solaris-sparc=solaris-sparc.so -native.dist.file.macosx=macosx.dylib - -##################################################################################### -# Release. Properties controlling the 'release' process -release.to.server=true - -##################################################################################### -# Miscellaneous. Properties that are used elsewhere. - -# these properties control the environment for the jarsigner process -# * ${jarsigner.enabled} - whether to sign jars -# * ${jarsigner.xmx} - max heap size for the jarsigner process -# * ${jarsigner.executable} - path to jarsigner executable (optional) -jarsigner.enabled=true -jarsigner.xmx=1024m - -# these properties control the environment for the pack200 and unpack200 -# processes -# * ${pack200.enabled} - whether to repackage jars (can be specified in each product) -# * ${use.internal.packer} - whether to use the same JVM for packing jars (can be specified in each product) -# it is risky because of memory leaks and possible OOMs -# * ${use.internal.unpacker} - whether to use the same JVM for unpacking jars (can be specified in each product) -# it is risky because of memory leaks and possible OOMs -# * ${pack200.xmx} - -Xmx jvm argument value -# * ${pack200.perm.size} - -XX:PermSize jvm argument value -# * ${pack200.max.perm.size} - -XX:MaxPermSize jvm argument value -# * ${pack200.executable} - path to pack200 executable (optional) -# * ${unpack200.executable} - path to unpack200 executable (optional) -# * ${verification.java.executable} - path to java executable that would be used for verification of packaged jars (optional) -pack200.xmx=768m -pack200.perm.size=32m -pack200.max.perm.size=512m - -# these properties control the environment for the external processes running during the build -# * ${process.max.execution.time} - maximum time (in milliseconds) for running the process -# if set to zero then processes would run without timeout -# default value is 600000=10min (defined in nbi/infra/build/.ant-lib/src/org/netbeans/installer/infra/build/ant/utils/Utils.java) - -# these properties control native executable paths -# * ${tar.executable} - path to native tar/gtar/gnutar executable -# * ${ls.executable} - path to native ls executable -# * ${unzip.executable} - path to native unzip executable diff --git a/nbi/infra/build/.common/common.xml b/nbi/infra/build/.common/common.xml deleted file mode 100644 index 83bfccefbfa6..000000000000 --- a/nbi/infra/build/.common/common.xml +++ /dev/null @@ -1,818 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This build script is a targets library and must not be used - directly. - - - diff --git a/nbi/infra/build/.common/engine.properties b/nbi/infra/build/.common/engine.properties deleted file mode 100644 index 988058e6dc2f..000000000000 --- a/nbi/infra/build/.common/engine.properties +++ /dev/null @@ -1,50 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# whether to build native components or not; 'true'/'false' -# * the engine has a bunch of native code dependencies, thus it is feasible to -# rebuild them every time -build.native=true - -# whether to build the netbeans part of the project or not; 'true'/'false' -# * essentially the engine IS a netbeans project, thus we should always build -# it -build.nbproject=true - -# dummy value for the custom parameter; which will be passed to the netbeans -# project build script; more sensible value is present in the base product -# build script -nb.custom.parameter=-Dtrue=true - -# name of the distributive file for the netbeans project -# * ${engine.dist.file.name} is expected to be defined in the derivative -# instance build script -nbproject.dist.file.name=${engine.dist.file.name} - -# path to the engine's distributive file; the file at this path would be -# considered the result of the build script and be copied to the distributives -# directory -nbproject.dist.file=${nbproject.dist.dir}/${nbproject.dist.file.name} - -# names of the distributive files for the native jni libraries for the engine -native.dist.file.windows=windows.dll -native.dist.file.linux=linux.so -native.dist.file.solaris-x86=solaris-x86.so -native.dist.file.solaris-sparc=solaris-sparc.so -native.dist.file.macosx=macosx.dylib diff --git a/nbi/infra/build/.common/engine.xml b/nbi/infra/build/.common/engine.xml deleted file mode 100644 index 78fd611478bf..000000000000 --- a/nbi/infra/build/.common/engine.xml +++ /dev/null @@ -1,306 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This is the base build script for nbi engine and is not intended to - be called directly. In order to create a derivative implementation - script, see - ${basedir}/.templates/engine-template.xml - - - diff --git a/nbi/infra/build/.common/group.properties b/nbi/infra/build/.common/group.properties deleted file mode 100644 index bd7f5c7344c8..000000000000 --- a/nbi/infra/build/.common/group.properties +++ /dev/null @@ -1,49 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# groups do not normally have any native components, thus there is no need to -# attempt to build anything native -build.native=false - -# groups do not normally have any netbeans projects, thus there is no need to -# attempt to build any nbproject -build.nbproject=false - -# various directories and file paths that will be used for packaging the -# group -package.dir=${work.dir}/package - -package.descriptor.path=registry.xml - -group.path=groups/${group.uid} -group.icon.path=${group.path}/icon.png - -group.dist.file.name=${group.uid}.jar - -# path to the group's icon; the contents of this file will be copied to the -# file identified by ${group.icon.file} -group.icon=${cvs.dir}/data/icon.png - -# path to the group's localizing bundle; the bundle is expected to contain -# two properties: 'group.display.name' and 'group.description', which will be -# used in creating the registry entry for this group -group.bundle=${cvs.dir}/data/Bundle - -# uri of the group's icon, which will appear in the registry -group.icon.uri=resource:${group.icon.path} diff --git a/nbi/infra/build/.common/group.xml b/nbi/infra/build/.common/group.xml deleted file mode 100644 index 25e1b2352805..000000000000 --- a/nbi/infra/build/.common/group.xml +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This is the base build script for nbi group package and is not - intended to be called directly. In order to create a derivative - implementation script, see - ${basedir}/.templates/group-template.xml - - - diff --git a/nbi/infra/build/.common/product.properties b/nbi/infra/build/.common/product.properties deleted file mode 100644 index 4f066d7f4a85..000000000000 --- a/nbi/infra/build/.common/product.properties +++ /dev/null @@ -1,91 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# whether to build native components or not; 'true'/'false' -# * normally a product does not have any native components, thus -# ${build.native} should be 'false' in most of the cases -build.native=false - -# whether to build the netbeans part of the project or not; 'true'/'false' -build.nbproject=true - -nbproject.dist.file.name=${product.uid},logic.jar - -# whether to build engine or not; 'true'/'false' -build.engine=true - -# whether to repackage the installation data or not; 'true'/'false'/'default' -# * if set to 'false' the data will be taken as it is (i.e. will be considered -# as already packaged) -# * if set to 'true' the data will be downloaded and packaged -# * if set to 'default' packaged data will be taken if it's available, -# otherwise raw data will be downloaded and packaged -package.data=default - -# whether the packaged data should be released (copied) to the local packaged -# data repository; 'true'/'false' -release.packaged.data=true - -# various properties controlling the engine's build process -engine.dir=${common.dir}/../engine -engine.work.dir=${work.dir}/.engine -engine.dist.dir=${dist.dir}/.engine -engine.dist.file.name=engine.jar - -# path to the distributive file of the engine; it will be used as the classpath -# for building the product's netbeans project -# * if the ${build.engine} has been set to 'false', make sure that -# ${engine.dist.file} points to a precompiled engine -engine.dist.file=${engine.dist.dir}/${engine.dist.file.name} - -downloads.cache.dir=${packaged.data.dir}/.raw - -# various paths and file names that will be used for packaging the -# product -package.dir=${work.dir}/package - -package.descriptor.path=registry.xml - -product.path=products/${product.uid}/${product.version}/${product.platforms} -product.logic.path=${product.path}/logic -product.data.path=${product.path}/data -product.icon.path=${product.path}/icon.png - -product.icon.uri=resource:${product.icon.path} - -product.dist.file.name=${product.uid},${product.version},${product.platforms}.jar - -# name of the product's configuration logic jar with index ${i} -product.logic.file.name=logic,${i}.jar -product.data.file.name=data,${i}.jar - -# list of the locally cached pre-packaged data files -# * the length of the list equals to ${product.data.length} -# * ${packaged.data.dir} is the path to the local packaged data repository and -# is environment specific; it is expected to be passed in via the environment -# properties -product.packaged.data.file=${packaged.data.dir}/${product.uid},${product.version},${product.platforms},${i}.jar -product.packaged.data.properties.file=${packaged.data.dir}/${product.uid},${product.version},${product.platforms},${i}.jar.properties - -# product icon and the localizing bundle, which is expected to contain -# display names and descriptions for all locales, supported by the product -# * these are file paths as opposed to uris for configuration logic and -# installation data -product.icon=${cvs.dir}/data/icon.png -product.bundle=${cvs.dir}/data/Bundle diff --git a/nbi/infra/build/.common/product.xml b/nbi/infra/build/.common/product.xml deleted file mode 100644 index a384bf612f7f..000000000000 --- a/nbi/infra/build/.common/product.xml +++ /dev/null @@ -1,728 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This is the base build script for nbi product package and is not - intended to be called directly. In order to create a derivative - implementation script, see - ${basedir}/.templates/product-template.xml - - - diff --git a/nbi/infra/build/engine/build.properties b/nbi/infra/build/engine/build.properties deleted file mode 100644 index 471aa14ac0c0..000000000000 --- a/nbi/infra/build/engine/build.properties +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# path to the directory where the base build scripts library and properties -# reside -common.dir=../../../../nbi/infra/build/.common - -# path to the local working directory; this directory which will be the target -# for checking out the sources and will be used for the build process -# * this path can be either absolute or relative in any unix environment, -# however, only relative paths are supported on windows, as the cygwin scp -# command does not properly handle colon in local paths -work.dir=./build - -# path to the local distributive directory; this directory will contain the -# distributive file, when (if) the build script finishes successfully -dist.dir=./dist - -# path to the engine sources within the cvs module; it should be a relative -# path from the module's root, e.g. for 'nbi/engine', where 'nbi is the module -# name, the path should be 'engine' -cvs.path=engine - -# name of the engine's distributive file -engine.dist.file.name=nbi-engine.jar - -# tells the netbeans project to DO build its dependencies (it's turned off by -# default) - this is done by setting a dummy property -nb.no.dependencies=-Dtrue=true diff --git a/nbi/infra/build/engine/build.xml b/nbi/infra/build/engine/build.xml deleted file mode 100644 index bc92a66ff35a..000000000000 --- a/nbi/infra/build/engine/build.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - In order to 'clean', 'checkout' and 'build' the engine use the - 'build-all' target. To 'clean', 'checkout', 'build' and - 'release' - use 'release-all'. - - For more details, please see the source of this build script. - - - diff --git a/nbi/infra/build/jvm/build.properties b/nbi/infra/build/jvm/build.properties deleted file mode 100644 index 552f5dcc467e..000000000000 --- a/nbi/infra/build/jvm/build.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# diff --git a/nbi/infra/build/jvm/build.sh b/nbi/infra/build/jvm/build.sh deleted file mode 100644 index 7bb99950f6c5..000000000000 --- a/nbi/infra/build/jvm/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -set -x - -DIRNAME=`dirname $0` -cd ${DIRNAME} - -. ./build-private.sh - -export ANT_OPTS - -if [ -z "$JVM_BUILDS_HOST" ] ; then - echo "JVM_BUILDS_HOST environment variable is not specified" - exit 1 -fi - -OPTIONS=--noconfig - -ant ${OPTIONS} -f ${DIRNAME}/build.xml\ - -Dtarget.platform=${TARGET_PLATFORM}\ - -Dglassfish.builds.host=\"${JVM_BUILDS_HOST}\"\ - $* - -ERROR_CODE=$? - -if [ $ERROR_CODE != 0 ]; then - echo "ERROR: $ERROR_CODE - Bundle JVM creation build failed" - exit $ERROR_CODE; -fi \ No newline at end of file diff --git a/nbi/infra/build/jvm/build.xml b/nbi/infra/build/jvm/build.xml deleted file mode 100644 index 721c12d01833..000000000000 --- a/nbi/infra/build/jvm/build.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/build/jvm/conf/common.properties b/nbi/infra/build/jvm/conf/common.properties deleted file mode 100644 index 45c5b24a089f..000000000000 --- a/nbi/infra/build/jvm/conf/common.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -jvm.sub.dir=jre1.8.0_101 -jvm.file.prefix=jre-8u101 -jvm.version=8u101 -jvm.build=b13 -jvm.build.type=fcs -zip.executable=zip -tar.executable=tar -sh.executable=sh diff --git a/nbi/infra/build/jvm/conf/linux.properties b/nbi/infra/build/jvm/conf/linux.properties deleted file mode 100644 index 8ddece013f12..000000000000 --- a/nbi/infra/build/jvm/conf/linux.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -unzip.sfx.file=${basedir}/tools/unzipsfx/${jvm.platform}/unzipsfx -jvm.file.name=${jvm.file.prefix}-${jvm.platform}.tar.gz -jvm.source.file=${glassfish.builds.host}/java/re/j2sdk/${jvm.version}/promoted/${jvm.build.type}/${jvm.build}/bundles/${jvm.platform}/${jvm.file.name} -jvm.source.file.compression=z -jvm.dest.file=${jvm.file.prefix}-${jvm.platform}.bin diff --git a/nbi/infra/build/jvm/conf/solaris.properties b/nbi/infra/build/jvm/conf/solaris.properties deleted file mode 100644 index be9ec34e6691..000000000000 --- a/nbi/infra/build/jvm/conf/solaris.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -unzip.sfx.file=${basedir}/tools/unzipsfx/${jvm.platform}/unzipsfx -jvm.file.name=${jvm.file.prefix}-${jvm.platform}.tar -jvm.source.file=${glassfish.builds.host}/java/re/j2sdk/${jvm.version}/promoted/${jvm.build.type}/${jvm.build}/bundles/${jvm.platform}/${jvm.file.name} -jvm.source.file.compression= -jvm.dest.file=${jvm.file.prefix}-${jvm.platform}.sh diff --git a/nbi/infra/build/jvm/conf/windows.properties b/nbi/infra/build/jvm/conf/windows.properties deleted file mode 100644 index 4b92583cc388..000000000000 --- a/nbi/infra/build/jvm/conf/windows.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -unzip.sfx.file=${basedir}/tools/unzipsfx/${jvm.platform}/unzipsfx.exe -jvm.file.name=${jvm.file.prefix}-${jvm.platform}.tar.gz -jvm.source.file=${glassfish.builds.host}/java/re/jdk/${jvm.version}/promoted/${jvm.build.type}/${jvm.build}/bundles/${jvm.platform}/${jvm.file.name} -jvm.source.file.compression=gzip -jvm.dest.file=${jvm.file.prefix}-${jvm.platform}.exe diff --git a/nbi/infra/build/jvm/readme.txt b/nbi/infra/build/jvm/readme.txt deleted file mode 100644 index 76546348d8d3..000000000000 --- a/nbi/infra/build/jvm/readme.txt +++ /dev/null @@ -1,26 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -Helper util for creating bundled JVM. -Should be run on each required platform. -To specify x64 target, environment variable TARGET_PLATFORM can be set to solaris-sparcv9 or solaris/linux/windows-amd64. -Another option - just run Ant on x64 JVM if it is possible. -build-private.sh file is missing but contains only one line with java builds host (JVM_BUILDS_HOST=...). - -Notes: UnzipSFX Version 5.51 (22 May 2004) on Linux doesn`t work with symlinks so v.5.50 is used. diff --git a/nbi/infra/build/jvm/scripts/pack200.sh b/nbi/infra/build/jvm/scripts/pack200.sh deleted file mode 100644 index b71dd59c1ea2..000000000000 --- a/nbi/infra/build/jvm/scripts/pack200.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -x -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -ROOT_DIR=`pwd` - -for src in `find . -name "*.jar"` -do - name=`basename "$src"` - if [ "$name" != "jce.jar" ] && \ - [ "$name" != "local_policy.jar" ] && \ - [ "$name" != "sunjce_provider.jar" ] && \ - [ "$name" != "sunpkcs11.jar" ] && \ - [ "$name" != "US_export_policy.jar" ] && \ - [ "$name" != "sunmscapi.jar" ] ; then - echo "Packing $src ..." - dest="$src.pack.gz" - "$ROOT_DIR"/bin/pack200 -J-Xmx1024m "$dest" "$src" - if [ 0 -eq $? ] ; then - echo "... unpacking $dest..." - "$ROOT_DIR"/bin/unpack200 "$dest" "$src.tmp.jar" - if [ 0 -eq $? ] ; then - echo "... OK" - else - echo "... failed" - rm "$dest"; - fi - rm -f "$src.tmp.jar" - else - echo "... failed" - rm -f "$dest" - fi - fi -done - -for src in `find . -name "*.jar.pack.gz"` -do - jar=`echo "$src" | sed "s/\.pack\.gz//"` - rm -f "$jar" -done \ No newline at end of file diff --git a/nbi/infra/build/jvm/scripts/unpack200.sh b/nbi/infra/build/jvm/scripts/unpack200.sh deleted file mode 100644 index 6e9017ccb4e6..000000000000 --- a/nbi/infra/build/jvm/scripts/unpack200.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -x -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -ROOT_DIR=`pwd` - -for src in `find . -name "*.jar.pack.gz"` -do - name=`basename "$src"` - echo "Unpacking $src" - dest=`echo "$src" | sed "s/\.pack\.gz//"` - "$ROOT_DIR"/bin/unpack200 -J-Xmx1024m "$src" "$dest" - if [ 0 -eq $? ] ; then - rm -f "$src" - else - exit $? - fi -done - diff --git a/nbi/infra/build/jvm/tools/unzipsfx/linux-amd64/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/linux-amd64/LICENSE deleted file mode 100644 index d76258faa58e..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/linux-amd64/LICENSE +++ /dev/null @@ -1,53 +0,0 @@ -This is version 2002-Feb-16 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2002 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, - Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, - Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, - Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, - Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, - Paul von Behren, Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form (compiled executables) must reproduce - the above copyright notice, definition, disclaimer, and this list of - conditions in documentation and/or other materials provided with the - distribution. The sole exception to this condition is redistribution - of a standard UnZipSFX binary as part of a self-extracting archive; - that is permitted without inclusion of this license, as long as the - normal UnZipSFX banner has not been removed from the binary or disabled. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its - own source and binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/linux-i586/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/linux-i586/LICENSE deleted file mode 100644 index d76258faa58e..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/linux-i586/LICENSE +++ /dev/null @@ -1,53 +0,0 @@ -This is version 2002-Feb-16 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2002 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, - Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, - Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, - Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, - Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, - Paul von Behren, Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form (compiled executables) must reproduce - the above copyright notice, definition, disclaimer, and this list of - conditions in documentation and/or other materials provided with the - distribution. The sole exception to this condition is redistribution - of a standard UnZipSFX binary as part of a self-extracting archive; - that is permitted without inclusion of this license, as long as the - normal UnZipSFX banner has not been removed from the binary or disabled. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its - own source and binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/solaris-amd64/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/solaris-amd64/LICENSE deleted file mode 100644 index 8511cdb52344..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/solaris-amd64/LICENSE +++ /dev/null @@ -1,49 +0,0 @@ -This is version 2000-Apr-09 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, - Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, - Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, - Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, - Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, - Paul von Behren, Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form must reproduce the above copyright - notice, definition, disclaimer, and this list of conditions in - documentation and/or other materials provided with the distribution. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and - binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/solaris-i586/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/solaris-i586/LICENSE deleted file mode 100644 index 8511cdb52344..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/solaris-i586/LICENSE +++ /dev/null @@ -1,49 +0,0 @@ -This is version 2000-Apr-09 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, - Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, - Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, - Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, - Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, - Paul von Behren, Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form must reproduce the above copyright - notice, definition, disclaimer, and this list of conditions in - documentation and/or other materials provided with the distribution. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and - binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/solaris-sparcv9/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/solaris-sparcv9/LICENSE deleted file mode 100644 index 8511cdb52344..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/solaris-sparcv9/LICENSE +++ /dev/null @@ -1,49 +0,0 @@ -This is version 2000-Apr-09 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, - Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, - Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, - Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, - Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, - Paul von Behren, Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form must reproduce the above copyright - notice, definition, disclaimer, and this list of conditions in - documentation and/or other materials provided with the distribution. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and - binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/windows-amd64/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/windows-amd64/LICENSE deleted file mode 100644 index 9cc83dca0aa0..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/windows-amd64/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -This is version 2005-Feb-10 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth, - Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, - David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, - Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, - Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, - Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren, - Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form (compiled executables) must reproduce - the above copyright notice, definition, disclaimer, and this list of - conditions in documentation and/or other materials provided with the - distribution. The sole exception to this condition is redistribution - of a standard UnZipSFX binary (including SFXWiz) as part of a - self-extracting archive; that is permitted without inclusion of this - license, as long as the normal SFX banner has not been removed from - the binary or disabled. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its - own source and binary releases. diff --git a/nbi/infra/build/jvm/tools/unzipsfx/windows-i586/LICENSE b/nbi/infra/build/jvm/tools/unzipsfx/windows-i586/LICENSE deleted file mode 100644 index 9cc83dca0aa0..000000000000 --- a/nbi/infra/build/jvm/tools/unzipsfx/windows-i586/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -This is version 2005-Feb-10 of the Info-ZIP copyright and license. -The definitive version of this document should be available at -ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. - - -Copyright (c) 1990-2005 Info-ZIP. All rights reserved. - -For the purposes of this copyright and license, "Info-ZIP" is defined as -the following set of individuals: - - Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, - Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth, - Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, - David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, - Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, - Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, - Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren, - Rich Wales, Mike White - -This software is provided "as is," without warranty of any kind, express -or implied. In no event shall Info-ZIP or its contributors be held liable -for any direct, indirect, incidental, special or consequential damages -arising out of the use of or inability to use this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. Redistributions of source code must retain the above copyright notice, - definition, disclaimer, and this list of conditions. - - 2. Redistributions in binary form (compiled executables) must reproduce - the above copyright notice, definition, disclaimer, and this list of - conditions in documentation and/or other materials provided with the - distribution. The sole exception to this condition is redistribution - of a standard UnZipSFX binary (including SFXWiz) as part of a - self-extracting archive; that is permitted without inclusion of this - license, as long as the normal SFX banner has not been removed from - the binary or disabled. - - 3. Altered versions--including, but not limited to, ports to new operating - systems, existing ports with new graphical interfaces, and dynamic, - shared, or static library versions--must be plainly marked as such - and must not be misrepresented as being the original source. Such - altered versions also must not be misrepresented as being Info-ZIP - releases--including, but not limited to, labeling of the altered - versions with the names "Info-ZIP" (or any variation thereof, including, - but not limited to, different capitalizations), "Pocket UnZip," "WiZ" - or "MacZip" without the explicit permission of Info-ZIP. Such altered - versions are further prohibited from misrepresentative use of the - Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). - - 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," - "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its - own source and binary releases. diff --git a/nbi/infra/lib/registries-management/build.xml b/nbi/infra/lib/registries-management/build.xml deleted file mode 100644 index 15c6172f35fd..000000000000 --- a/nbi/infra/lib/registries-management/build.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Library: Registries Management. - - - diff --git a/nbi/infra/lib/registries-management/nbproject/build-impl.xml b/nbi/infra/lib/registries-management/nbproject/build-impl.xml deleted file mode 100644 index 34caa4012a0f..000000000000 --- a/nbi/infra/lib/registries-management/nbproject/build-impl.xml +++ /dev/null @@ -1,1067 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/lib/registries-management/nbproject/genfiles.properties b/nbi/infra/lib/registries-management/nbproject/genfiles.properties deleted file mode 100644 index 3bfcaa2cf358..000000000000 --- a/nbi/infra/lib/registries-management/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=d50f1366 -build.xml.script.CRC32=33f5916b -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=f760434a -nbproject/build-impl.xml.script.CRC32=c61891c0 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/lib/registries-management/nbproject/project.properties b/nbi/infra/lib/registries-management/nbproject/project.properties deleted file mode 100644 index 1ea11d9e0662..000000000000 --- a/nbi/infra/lib/registries-management/nbproject/project.properties +++ /dev/null @@ -1,89 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -application.title=NBI Registries Management Library -application.vendor=ks152834 -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/registries-management.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${reference.NBI_Engine.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -project.NBI_Engine=../../../engine -reference.NBI_Engine.jar=${project.NBI_Engine}/dist/nbi-engine.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/nbi/infra/lib/registries-management/nbproject/project.xml b/nbi/infra/lib/registries-management/nbproject/project.xml deleted file mode 100644 index 99f8963335c2..000000000000 --- a/nbi/infra/lib/registries-management/nbproject/project.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - org.netbeans.modules.java.j2seproject - - - NBI Library: Registries Management - 1.6.5 - - - - - - - - - - NBI_Engine - jar - - jar - clean - jar - - - - diff --git a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/ManagerException.java b/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/ManagerException.java deleted file mode 100644 index 0b3c37924f51..000000000000 --- a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/ManagerException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.lib.registries; - -/** - * - * @author Kirill Sorokin - */ -public class ManagerException extends Exception { - /** - * - * @param message - */ - public ManagerException(String message) { - super(message); - } - - /** - * - * @param cause - */ - public ManagerException(Throwable cause) { - super(cause); - } - - /** - * - * @param message - * @param cause - */ - public ManagerException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/RegistriesManager.java b/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/RegistriesManager.java deleted file mode 100644 index 549dfbf35d06..000000000000 --- a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/RegistriesManager.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.lib.registries; - -import java.io.File; -import java.util.Properties; -import org.netbeans.installer.utils.helper.Platform; - -public interface RegistriesManager { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final String ENGINE_JAR = "engine.jar"; - - public static final String REGISTRY_XML = "registry.xml"; - public static final String BUNDLES_LIST = "bundles.list"; - - public static final String BUNDLES = "bundles"; - - public static final String COMPONENTS = "components"; - public static final String PRODUCTS = COMPONENTS + "/products"; - public static final String GROUPS = COMPONENTS + "/groups"; - - public static final String TEMP = "temp"; - - // engine operations //////////////////////////////////////////////////////////// - File getEngine( - final File root) throws ManagerException; - - void updateEngine( - final File root, - final File archive) throws ManagerException; - - // components operations //////////////////////////////////////////////////////// - void addPackage( - final File root, - final File archive, - final String parentUid, - final String parentVersion, - final String parentPlatforms) throws ManagerException; - - void removeProduct( - final File root, - final String uid, - final String version, - final String platforms) throws ManagerException; - - void removeGroup( - final File root, - final String uid) throws ManagerException; - - // bundles ////////////////////////////////////////////////////////////////////// - File createBundle( - final File root, - final Platform platform, - final String[] components) throws ManagerException; - - // bundles ////////////////////////////////////////////////////////////////////// - File createBundle( - final File root, - final Platform platform, - final String[] components, - final Properties props, - final Properties bundleProps) throws ManagerException; - - void deleteBundles( - final File root) throws ManagerException; - - void generateBundles( - final File root) throws ManagerException; - - // miscellanea ////////////////////////////////////////////////////////////////// - void initializeRegistry( - final File root) throws ManagerException; - - File exportRegistry( - final File root, - final File destination, - final String codebase) throws ManagerException; - - String generateComponentsJs( - final File root) throws ManagerException; - - String generateComponentsJs( - final File root, final File bundlesList) throws ManagerException; - - String generateComponentsJs( - final File root, final File bundlesList, final String locale) throws ManagerException; -} diff --git a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/DummyFinishHandler.java b/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/DummyFinishHandler.java deleted file mode 100644 index 5bb78fb867de..000000000000 --- a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/DummyFinishHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.lib.registries.impl; - -import org.netbeans.installer.utils.helper.FinishHandler; - -/** - * - * @author Kirill Sorokin - */ -public class DummyFinishHandler implements FinishHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Static - public static final DummyFinishHandler INSTANCE = new DummyFinishHandler(); - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public DummyFinishHandler() { - } - - public void cancel() { - // does nothing - } - - public void finish() { - // does nothing - } - - public void criticalExit() { - // does nothing - } -} diff --git a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/RegistriesManagerImpl.java b/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/RegistriesManagerImpl.java deleted file mode 100644 index dfb68b59585a..000000000000 --- a/nbi/infra/lib/registries-management/src/org/netbeans/installer/infra/lib/registries/impl/RegistriesManagerImpl.java +++ /dev/null @@ -1,1109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.lib.registries.impl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.Queue; -import java.util.concurrent.locks.ReentrantLock; -import org.netbeans.installer.Installer; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.filters.TrueFilter; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.ExecutionResults; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.infra.lib.registries.ManagerException; -import org.netbeans.installer.infra.lib.registries.RegistriesManager; -import org.netbeans.installer.utils.helper.Pair; -import org.netbeans.installer.utils.progress.Progress; - -/** - * - * @author Kirill Sorokin - */ -public class RegistriesManagerImpl implements RegistriesManager { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static Map locks = - new HashMap(); - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - - // engine operations //////////////////////////////////////////////////////////// - public File getEngine( - final File root) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - - return new File(root, ENGINE_JAR); - } finally { - lock.unlock(); - } - } - - public void updateEngine( - final File root, - final File archive) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - deleteBundles(root); - - FileUtils.copyFile(archive, new File(root, ENGINE_JAR)); - } catch (IOException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - - // component operations ///////////////////////////////////////////////////////// - public void addPackage( - final File root, - final File archive, - final String parentUid, - final String parentVersion, - final String parentPlatforms) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - deleteBundles(root); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), false); - - final File registryXml = - new File(root, REGISTRY_XML); - final File componentsDir = - new File(root, COMPONENTS); - final File archiveDir = - FileUtils.createTempFile(new File(root, TEMP), false); - final File archiveRegistryXml = - new File(archiveDir, REGISTRY_XML); - - FileUtils.unjar(archive, archiveDir); - FileUtils.modifyFile(archiveRegistryXml, - "(\\>)resource:(.*?\\<\\/)", - "$1" + componentsDir.toURI() + "$2", true, - StringUtils.ENCODING_UTF8); - - final Registry registry = new Registry(); - registry.setLocalDirectory(tempDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.loadProductRegistry(registryXml); - - final Registry archiveRegistry = new Registry(); - archiveRegistry.setLocalDirectory(tempDir); - archiveRegistry.setFinishHandler(DummyFinishHandler.INSTANCE); - archiveRegistry.loadProductRegistry(archiveRegistryXml); - - final Queue nodes = new LinkedList(); - - for (Product product: archiveRegistry.getProducts()) { - final List existingProducts = registry.getProducts( - product.getUid(), - product.getVersion(), - product.getPlatforms()); - - if (existingProducts.size() > 0) { - for (Product existingProduct: existingProducts) { - nodes.offer(existingProduct); - } - } - } - - for (Group group: archiveRegistry.getGroups()) { - if (!group.equals(archiveRegistry.getRegistryRoot())) { - final Group existingGroup = registry.getGroup( - group.getUid()); - - if (existingGroup != null) { - nodes.offer(existingGroup); - } - } - } - - if (nodes.size() > 0) { - while (nodes.peek() != null) { - final RegistryNode node = nodes.poll(); - - node.getParent().removeChild(node); - - if (node instanceof Product) { - final Product temp = (Product) node; - final String path = PRODUCTS + "/" + - temp.getUid() + "/" + - temp.getVersion() + "/" + - StringUtils.asString(temp.getPlatforms(), " "); - - FileUtils.deleteFile(new File(root, path), true); - } - - if (node instanceof Group) { - final Group temp = (Group) node; - final String path = GROUPS + "/" + - temp.getUid(); - - FileUtils.deleteFile(new File(root, path), true); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - final File productsDir = new File(root, PRODUCTS); - FileUtils.mkdirs(productsDir); - FileUtils.copyFile( - new File(archiveDir, "products"), // temp hack - productsDir, - true); - - final File groupsDir = new File(root, GROUPS); - FileUtils.mkdirs(groupsDir); - FileUtils.copyFile( - new File(archiveDir, "groups"), // temp hack - groupsDir, - true); - - RegistryNode parent; - - List parents = null; - if ((parentVersion != null) && - !parentVersion.equals("null") && - (parentPlatforms != null) && - !parentPlatforms.equals("null")) { - parents = registry.getProducts( - parentUid, - Version.getVersion(parentVersion), - StringUtils.parsePlatforms(parentPlatforms)); - } - if ((parents == null) || (parents.size() == 0)) { - parent = registry.getGroup(parentUid); - if (parent == null) { - parent = registry.getRegistryRoot(); - } - } else { - parent = parents.get(0); - } - - parent.attachRegistry(archiveRegistry); - - registry.saveProductRegistry( - registryXml, - TrueFilter.INSTANCE, - true, - true, - true); - - FileUtils.deleteFile(archiveDir, true); - FileUtils.deleteFile(tempDir, true); - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } catch (ParseException e) { - throw new ManagerException(e); - } catch (XMLException e) { - throw new ManagerException(e); - } catch (FinalizationException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - - public void removeProduct( - final File root, - final String uid, - final String version, - final String platforms) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - deleteBundles(root); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), false); - - final File registryXml = - new File(root,REGISTRY_XML); - final File productsDir = - new File(root, PRODUCTS); - final File groupsDir = - new File(root, GROUPS); - - final Registry registry = new Registry(); - - registry.setLocalDirectory(tempDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.loadProductRegistry(registryXml); - - final List existing = registry.getProducts( - uid, - Version.getVersion(version), - StringUtils.parsePlatforms(platforms)); - - if (existing != null) { - existing.get(0).getParent().removeChild(existing.get(0)); - - final Queue nodes = new LinkedList(); - nodes.offer(existing.get(0)); - - while(nodes.peek() != null) { - final RegistryNode node = nodes.poll(); - - if (node instanceof Product) { - final Product product = (Product) node; - - final File uidDir = new File( - productsDir, - product.getUid()); - final File versionDir = new File( - uidDir, - product.getVersion().toString()); - final File platformsDir = new File( - versionDir, - StringUtils.asString(product.getPlatforms(), " ")); - - FileUtils.deleteFile(platformsDir, true); - if (FileUtils.isEmpty(versionDir)) { - FileUtils.deleteFile(versionDir, true); - } - if (FileUtils.isEmpty(uidDir)) { - FileUtils.deleteFile(uidDir, true); - } - - } - - if (node instanceof Group) { - final Group group = (Group) node; - - final File uidDir = new File( - groupsDir, - group.getUid()); - - FileUtils.deleteFile(uidDir, true); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - registry.saveProductRegistry( - registryXml, - TrueFilter.INSTANCE, - true, - true, - true); - - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } catch (ParseException e) { - throw new ManagerException(e); - } catch (FinalizationException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - - public void removeGroup( - final File root, - final String uid) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - deleteBundles(root); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), false); - - final File registryXml = - new File(root,REGISTRY_XML); - final File productsDir = - new File(root, PRODUCTS); - final File groupsDir = - new File(root, GROUPS); - - final Registry registry = new Registry(); - - registry.setLocalDirectory(tempDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.loadProductRegistry(registryXml); - - final Group existing = registry.getGroup(uid); - if (existing != null) { - existing.getParent().removeChild(existing); - - Queue nodes = new LinkedList(); - nodes.offer(existing); - - while(nodes.peek() != null) { - final RegistryNode node = nodes.poll(); - - if (node instanceof Product) { - final Product product = (Product) node; - - final File uidDir = new File( - productsDir, - product.getUid()); - final File versionDir = new File( - uidDir, - product.getVersion().toString()); - final File platformsDir = new File( - versionDir, - StringUtils.asString(product.getPlatforms(), " ")); - - FileUtils.deleteFile(platformsDir, true); - if (FileUtils.isEmpty(versionDir)) { - FileUtils.deleteFile(versionDir, true); - } - if (FileUtils.isEmpty(uidDir)) { - FileUtils.deleteFile(uidDir, true); - } - - } - - if (node instanceof Group) { - final Group group = (Group) node; - - final File uidDir = new File( - groupsDir, - group.getUid()); - - FileUtils.deleteFile(uidDir, true); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - registry.saveProductRegistry( - registryXml, - TrueFilter.INSTANCE, - true, - true, - true); - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } catch (FinalizationException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - - // bundles ////////////////////////////////////////////////////////////////////// - public File createBundle( - final File root, - final Platform platform, - final String[] components, - Properties props, - Properties bundleProps) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - - return createBundleNoLock(root, platform, components,props,bundleProps); - } finally { - lock.unlock(); - } - } - // bundles ////////////////////////////////////////////////////////////////////// - public File createBundle( - final File root, - final Platform platform, - final String[] components) throws ManagerException { - return createBundle(root,platform,components,new Properties(),new Properties()); - } - public void generateBundles( - final File root) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), false); - - final File registryXml = - new File(root,REGISTRY_XML); - - for (Platform platform: Platform.values()) { - final Registry registry = new Registry(); - - registry.setLocalDirectory(tempDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.loadProductRegistry(registryXml); - - final List products = registry.getProducts(platform); - for (int i = 1; i <= products.size(); i++) { - final Product[] combination = new Product[i]; - - iterate(platform, root, registry, combination, 0, products, 0); - } - } - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - - public void deleteBundles( - final File root) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - - deleteBudlesNoLock(root); - } finally { - lock.unlock(); - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public void initializeRegistry( - final File root) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - } finally { - lock.unlock(); - } - } - - public File exportRegistry( - final File root, - final File destination, - final String codebase) throws ManagerException { - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - initializeRegistryNoLock(root); - - final File registryXml = - new File(root, REGISTRY_XML); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), true, true); - final File tempUserDir = - FileUtils.createTempFile(tempDir, false); - final File tempRegistryXml = - FileUtils.createTempFile(tempDir, false); - - FileUtils.mkdirs(destination.getParentFile()); - - final Registry registry = new Registry(); - registry.setLocalDirectory(tempUserDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.loadProductRegistry(registryXml); - - registry.saveProductRegistry( - tempRegistryXml, - TrueFilter.INSTANCE, - false, - true, - true); - - FileUtils.copyFile( - new File(root, COMPONENTS), - new File(destination, COMPONENTS), - true); - - final String replacement = - codebase.endsWith("/") ? codebase : codebase + "/"; - FileUtils.modifyFile( - tempRegistryXml, - "uri>" + root.toURI().toString(), - "uri>" + replacement, - StringUtils.ENCODING_UTF8); - - FileUtils.copyFile( - tempRegistryXml, - new File(destination, REGISTRY_XML)); - FileUtils.copyFile( - new File(root, ENGINE_JAR), - new File(destination, ENGINE_JAR)); - - FileUtils.deleteFile(tempUserDir); - FileUtils.deleteFile(tempRegistryXml); - - return destination; - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } catch (FinalizationException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - public String generateComponentsJs( - final File root) throws ManagerException { - return generateComponentsJs(root, null, null); - } - public String generateComponentsJs( - final File root, final File bundlesList) throws ManagerException { - return generateComponentsJs(root, bundlesList, null); - } - - public String generateComponentsJs( - final File root, File bundlesList, final String localeString) throws ManagerException { - - Properties props = new Properties(); - try { - if (bundlesList != null) { - FileInputStream is = new FileInputStream(bundlesList); - props.load(is); - is.close(); - } - } catch (IOException e){ - throw new ManagerException(e); - } - - final List , String>> bundles = new LinkedList, String>> (); - - for (Map.Entry entry : props.entrySet()) { - List list = StringUtils.asList(entry.getValue().toString()); - bundles.add(new Pair(list, entry.getKey().toString())); - } - - final Map notes = new HashMap(); - //notes.put("nb-javase", "for Java SE, includes GUI Builder, Profiler"); - - Locale locale = StringUtils.parseLocale(localeString==null ? "" : localeString); - - final ReentrantLock lock = getLock(root); - - try { - lock.lock(); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), true, true); - final File tempUserDir = - FileUtils.createTempFile(tempDir, true, true); - - final StringBuilder out = new StringBuilder(); - - final Registry registry = loadRegistry( - root, - tempUserDir, - Platform.GENERIC); - - final List products = - getProducts(registry.getRegistryRoot()); - final List groups = - getGroups(registry.getRegistryRoot()); - - final Map productMapping = - new HashMap(); - - final List productUids = - new LinkedList(); - final List productVersions = - new LinkedList(); - final List productDisplayNames = - new LinkedList(); - final List productNotes = - new LinkedList(); - final List productDescriptions = - new LinkedList(); - final List productDownloadSizes = - new LinkedList(); - final List> productPlatforms = - new LinkedList>(); - final List productProperties = - new LinkedList(); - - final List defaultGroupProducts = - new LinkedList(); - final List> groupProducts = - new LinkedList>(); - final List groupDisplayNames = - new LinkedList(); - final List groupDescriptions = - new LinkedList(); - - for (int i = 0; i < products.size(); i++) { - final Product product = products.get(i); - - boolean existingFound = false; - for (int j = 0; j < productUids.size(); j++) { - if (productUids.get(j).equals(product.getUid()) && - productVersions.get(j).equals(product.getVersion().toString())) { - productPlatforms.get(j).addAll(product.getPlatforms()); - productMapping.put(i, j); - existingFound = true; - break; - } - } - - if (existingFound) { - continue; - } - - long size = (long) Math.ceil( - ((double) product.getDownloadSize()) / 1024. ); - productUids.add(product.getUid()); - productVersions.add(product.getVersion().toString()); - productDisplayNames.add(product.getDisplayName(locale).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - productDescriptions.add(product.getDescription(locale).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - productDownloadSizes.add(Long.toString(size)); - productPlatforms.add(product.getPlatforms()); - - if (notes.get(product.getUid()) != null) { - productNotes.add(notes.get(product.getUid()).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - } else { - productNotes.add(""); - } - - String properties = "PROPERTY_NONE"; - for(Pair ,String> pair : bundles) { - if(pair.getFirst().contains(product.getUid())) { - properties += " | PROPERTY_" + pair.getSecond(); - } - } - productProperties.add(properties); - - productMapping.put(i, productUids.size() - 1); - } - - for(int i = 0; i < productUids.size(); i++) { - out.append("add_product_info(\n"); - out.append(" \""+ productUids.get(i) + "\",\n"); - out.append(" \"" + productVersions.get(i) + "\",\n"); - out.append(" \"" + productDisplayNames.get(i) + "\",\n"); - out.append(" \"" + productNotes.get(i) + "\",\n"); - out.append(" \"" + productDescriptions.get(i) + "\",\n"); - out.append(" " + productDownloadSizes.get(i) + ",\n"); - //out.append(" " + productProperties.get(i) + "),\n"); - out.append(" \"" + StringUtils.asString(productPlatforms.get(i)) + "\");\n"); - out.append("\n"); - } - - - // groups - for (int i = 0; i < productUids.size(); i++) { - defaultGroupProducts.add(Integer.valueOf(i)); - } - - for (Group group: groups) { - List components = new LinkedList(); - for (int i = 0; i < products.size(); i++) { - if (products.get(i).getParent().equals(group)) { - Integer index = Integer.valueOf(productMapping.get(i)); - if (!components.contains(index)) { - components.add(index); - defaultGroupProducts.remove(index); - } - } - } - - groupProducts.add(components); - groupDisplayNames.add(group.getDisplayName(locale).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - groupDescriptions.add(group.getDescription(locale).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - } - - if (defaultGroupProducts.size() > 0) { - groupProducts.add(0, defaultGroupProducts); - groupDisplayNames.add(0, ""); - groupDescriptions.add(0, ""); - } - - out.append("\n"); - for (int i = 0; i < groupProducts.size(); i++) { - List uids = new LinkedList(); - for(int j=0;j,String> pair : bundles) { - List uids = pair.getFirst(); - String bundleId = pair.getSecond(); - out.append("add_bundle_info(\"" + bundleId + "\", \"" + StringUtils.asString(uids) + "\");\n"); - } - - return out.toString(); - } catch (IOException e) { - throw new ManagerException(e); - } finally { - lock.unlock(); - } - } - // private ////////////////////////////////////////////////////////////////////// - private synchronized ReentrantLock getLock( - final File root) { - if (locks.get(root) == null) { - locks.put(root, new ReentrantLock()); - } - - return locks.get(root); - } - - private File createBundleNoLock( - final File root, - final Platform platform, - final String[] components, - Properties props, - Properties bundleProps) throws ManagerException { - try { - final String key = "" + platform.getCodeName() + ": " + - StringUtils.asString(components); - - final File bundlesListFile = - new File(root, BUNDLES_LIST); - - final List bundlesList = - FileUtils.readStringList(bundlesListFile); - if (bundlesList.contains(key)) { - return new File(bundlesList.get(bundlesList.indexOf(key) + 1)); - } - - final File registryXml = - new File(root, REGISTRY_XML); - - final File tempDir = - FileUtils.createTempFile(new File(root, TEMP), true, true); - final File tempUserDir = - FileUtils.createTempFile(tempDir, true, true); - final File tempStatefile = - FileUtils.createTempFile(tempDir, false); - - File bundle = new File( - FileUtils.createTempFile(new File(root, BUNDLES), false), - "bundle.jar"); - - final Registry registry = new Registry(); - registry.setLocalDirectory(tempUserDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.setTargetPlatform(platform); - registry.loadProductRegistry(registryXml); - - List products = new LinkedList(); - for (String string: components) { - final String[] parts = string.split(","); - System.out.println(" processing: " + string); - - final Product product = registry.getProduct( - parts[0], - Version.getVersion(parts[1])); - - products.add(product); - product.setStatus(Status.INSTALLED); - } - registry.saveStateFile(tempStatefile, new Progress()); - - bundle.getParentFile().mkdirs(); - - final File javaHome = new File(System.getProperty("java.home")); - - final File tempPropertiesFile = FileUtils.createTempFile(tempDir, false); - OutputStream os = new FileOutputStream(tempPropertiesFile); - props.store(os,null); - os.close(); - - final File tempBundlePropertiesFile = FileUtils.createTempFile(tempDir, false); - os = new FileOutputStream(tempBundlePropertiesFile); - bundleProps.store(os,null); - os.close(); - - final ExecutionResults results = SystemUtils.executeCommand( - JavaUtils.getExecutable(javaHome).getAbsolutePath(), - "-Dnbi.product.remote.registries=" + registryXml.toURI(), - "-jar", - getEngine(root).getAbsolutePath(), - "--silent", - "--state", - tempStatefile.getAbsolutePath(), - "--create-bundle", - bundle.getAbsolutePath(), - "--ignore-lock", - "--platform", - platform.toString(), - "--userdir", - tempUserDir.getAbsolutePath(), - "--properties", - tempPropertiesFile.getAbsolutePath(), - "--bundle-properties", - tempBundlePropertiesFile.getAbsolutePath()); - - if (results.getErrorCode() != 0) { - throw new ManagerException("Could not create bundle - error in running the engine." + - "\nOutput:\n" + results.getStdOut() + - "\nStderr:\n" + results.getStdErr()); - } - - FileUtils.deleteFile(tempStatefile); - FileUtils.deleteFile(tempPropertiesFile); - FileUtils.deleteFile(tempBundlePropertiesFile); - FileUtils.deleteFile(tempUserDir, true); - - if (platform.isCompatibleWith(Platform.WINDOWS)) { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".exe")); - } else if (platform.isCompatibleWith(Platform.MACOSX)) { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".zip")); - } else { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".sh")); - } - if (!bundle.exists()) { - throw new ManagerException("Could not create bundle." + - "\nOutput:\n" + results.getStdOut() + - "\nStderr:\n" + results.getStdErr()); - - } - bundlesList.add(key); - bundlesList.add(bundle.getAbsolutePath()); - FileUtils.writeStringList(bundlesListFile, bundlesList); - - return bundle; - } catch (IOException e) { - throw new ManagerException(e); - } catch (InitializationException e) { - throw new ManagerException(e); - } catch (FinalizationException e) { - throw new ManagerException(e); - } - } - - private void deleteBudlesNoLock( - final File root) throws ManagerException { - try { - FileUtils.writeFile(new File(root, BUNDLES_LIST), ""); - FileUtils.deleteFile(new File(root, BUNDLES), true); - FileUtils.mkdirs(new File(root, BUNDLES)); - } catch (IOException e) { - throw new ManagerException(e); - } - } - - private void initializeRegistryNoLock( - final File root) throws ManagerException { - try { - if (!root.exists()) { - FileUtils.mkdirs(root); - } - - final File temp = new File(root, TEMP); - if (!temp.exists()) { - FileUtils.mkdirs(temp); - } - - //Issue #183611 - //Locale.setDefault(new Locale("en", "US")); - - System.setProperty( - Installer.LOCAL_DIRECTORY_PATH_PROPERTY, temp.getAbsolutePath()); - System.setProperty( - Installer.IGNORE_LOCK_FILE_PROPERTY, "true"); - System.setProperty( - LogManager.LOG_TO_CONSOLE_PROPERTY, "false"); - System.setProperty( - Registry.LAZY_LOAD_ICONS_PROPERTY, "true"); - - final File registryXml = new File(root, REGISTRY_XML); - if (!registryXml.exists()) { - new Registry().saveProductRegistry( - registryXml, - TrueFilter.INSTANCE, - true, - true, - true); - } - - final File bundlesList = new File(root, BUNDLES_LIST); - if (!bundlesList.exists()) { - FileUtils.writeFile(bundlesList, ""); - } - - final File bundles = new File(root, BUNDLES); - if (!bundles.exists()) { - FileUtils.mkdirs(bundles); - } - - final File components = new File(root, COMPONENTS); - if (!components.exists()) { - FileUtils.mkdirs(components); - } - } catch (FinalizationException e) { - throw new ManagerException(e); - } catch (IOException e) { - throw new ManagerException(e); - } - } - - private Registry loadRegistry( - final File root, - final File tempUserDir, - final Platform platform) throws ManagerException { - try { - final File registryXml = - new File(root, REGISTRY_XML); - - final Registry registry = new Registry(); - registry.setLocalDirectory(tempUserDir); - registry.setFinishHandler(DummyFinishHandler.INSTANCE); - registry.setTargetPlatform(platform); - registry.loadProductRegistry(registryXml); - - return registry; - } catch (InitializationException e) { - throw new ManagerException(e); - } - } - - private void iterate( - final Platform platform, - final File root, - final Registry registry, - final Product[] combination, - final int index, - final List products, - final int start) throws ManagerException { - for (int i = start; i < products.size(); i++) { - combination[index] = products.get(i); - - if (index == combination.length - 1) { - for (Product product: products) { - product.setStatus(Status.NOT_INSTALLED); - } - for (Product product: combination) { - product.setStatus(Status.TO_BE_INSTALLED); - } - - if (registry.getProductsToInstall().size() == combination.length) { - String[] components = new String[combination.length]; - - for (int j = 0; j < combination.length; j++) { - components[j] = combination[j].getUid() + "," + - combination[j].getVersion().toString(); - } - - createBundle(root, platform, components); - } - } else { - iterate(platform, root, registry, combination, index + 1, products, i + 1); - } - } - } - - private List getProducts(RegistryNode root) { - final List list = new LinkedList(); - - for (RegistryNode node: root.getChildren()) { - if (node instanceof Product) { - list.add((Product) node); - } - - list.addAll(getProducts(node)); - } - - return list; - } - - private List getGroups(RegistryNode root) { - final List list = new LinkedList(); - - for (RegistryNode node: root.getChildren()) { - if (node instanceof Group) { - list.add((Group) node); - } - - list.addAll(getGroups(node)); - } - - return list; - } -} diff --git a/nbi/infra/server/build.xml b/nbi/infra/server/build.xml deleted file mode 100644 index 694368beb088..000000000000 --- a/nbi/infra/server/build.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Server. - - - diff --git a/nbi/infra/server/modules/ejb/build.xml b/nbi/infra/server/modules/ejb/build.xml deleted file mode 100644 index 5b9c1e25aeaa..000000000000 --- a/nbi/infra/server/modules/ejb/build.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Server - EJB. - - - diff --git a/nbi/infra/server/modules/ejb/nbproject/ant-deploy.xml b/nbi/infra/server/modules/ejb/nbproject/ant-deploy.xml deleted file mode 100644 index e86b4a518748..000000000000 --- a/nbi/infra/server/modules/ejb/nbproject/ant-deploy.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${lefty}?xml version="1.0" encoding="UTF-8"?${righty} -${lefty}!DOCTYPE resources PUBLIC - "-//Sun Microsystems Inc.//DTD Application Server 9.0 Resource Definitions //EN" - "${sjsas.root}/lib/dtds/sun-resources_1_2.dtd"${righty} -${lefty}resources${righty} -${lefty}/resources${righty} - - - - - - - -]]> - - - - -]]> - - - - - - - ]]> - - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/ejb/nbproject/build-impl.xml b/nbi/infra/server/modules/ejb/nbproject/build-impl.xml deleted file mode 100644 index a80ebfd2143a..000000000000 --- a/nbi/infra/server/modules/ejb/nbproject/build-impl.xml +++ /dev/null @@ -1,557 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - Platform is not correctly set up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set main.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/ejb/nbproject/genfiles.properties b/nbi/infra/server/modules/ejb/nbproject/genfiles.properties deleted file mode 100644 index 4f4d539de930..000000000000 --- a/nbi/infra/server/modules/ejb/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=f00a642d -build.xml.script.CRC32=09b6834b -build.xml.stylesheet.CRC32=997c846c -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=e2e8faf4 -nbproject/build-impl.xml.script.CRC32=db9f01b6 -nbproject/build-impl.xml.stylesheet.CRC32=3f678fdd diff --git a/nbi/infra/server/modules/ejb/nbproject/project.properties b/nbi/infra/server/modules/ejb/nbproject/project.properties deleted file mode 100644 index 3d039836a56a..000000000000 --- a/nbi/infra/server/modules/ejb/nbproject/project.properties +++ /dev/null @@ -1,71 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.dir}/jar -build.classes.excludes=**/*.java,**/*.form,**/.nbattrs -build.dir=build -build.ear.classes.dir=${build.dir}/jar -build.generated.dir=${build.dir}/generated -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=${javac.classpath}:${build.classes.dir} -debug.test.classpath=\ - ${run.test.classpath} -dist.dir=dist -dist.ear.jar=${dist.dir}/${jar.name} -dist.jar=${dist.dir}/${jar.name} -dist.javadoc.dir=${dist.dir}/javadoc -j2ee.platform=1.5 -j2ee.server.type=J2EE -jar.compress=false -jar.name=ejb.jar -javac.classpath=\ - ${reference.NetBeans_Installer_Engine.jar} -javac.debug=true -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.preview=true -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -meta.inf=${source.root}/conf -meta.inf.excludes=sun-cmp-mappings.xml -platform.active=JDK_1.5 -project.NetBeans_Installer_Engine=../../../../engine -reference.NetBeans_Installer_Engine.jar=${project.NetBeans_Installer_Engine}/dist/nbi-engine.jar -resource.dir=setup -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.root=src -src.dir=${source.root}/java -test.src.dir=test diff --git a/nbi/infra/server/modules/ejb/nbproject/project.xml b/nbi/infra/server/modules/ejb/nbproject/project.xml deleted file mode 100644 index 3eddbe8ed28b..000000000000 --- a/nbi/infra/server/modules/ejb/nbproject/project.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - org.netbeans.modules.j2ee.ejbjarproject - - - NBI Server - EJB - 1.6 - - reference.NetBeans_Installer_Engine.jar - - - - - - - - - - NetBeans_Installer_Engine - jar - - jar - clean - jar - - - - diff --git a/nbi/infra/server/modules/ejb/src/conf/MANIFEST.MF b/nbi/infra/server/modules/ejb/src/conf/MANIFEST.MF deleted file mode 100644 index 59499bce4a2b..000000000000 --- a/nbi/infra/server/modules/ejb/src/conf/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/nbi/infra/server/modules/ejb/src/conf/sun-ejb-jar.xml b/nbi/infra/server/modules/ejb/src/conf/sun-ejb-jar.xml deleted file mode 100644 index a4275d653f74..000000000000 --- a/nbi/infra/server/modules/ejb/src/conf/sun-ejb-jar.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - diff --git a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/DummyFinishHandler.java b/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/DummyFinishHandler.java deleted file mode 100644 index f6f74efd95ca..000000000000 --- a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/DummyFinishHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.ejb; - -import org.netbeans.installer.utils.helper.FinishHandler; - -/** - * - * @author Kirill Sorokin - */ -public class DummyFinishHandler implements FinishHandler { - public DummyFinishHandler() { - } - - public void cancel() { - // does nothing - } - - public void finish() { - // does nothing - } - - public void criticalExit() { - // does nothing - } -} diff --git a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/IconCorrectingFilter.java b/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/IconCorrectingFilter.java deleted file mode 100644 index f13d47379f9d..000000000000 --- a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/IconCorrectingFilter.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.ejb; - -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.filters.RegistryFilter; - -/** - * - * @author Kirill Sorokin - */ -public class IconCorrectingFilter implements RegistryFilter { - public boolean accept(final RegistryNode node) { - if (node.getIconUri().getLocal() != null) { - if (node.getIconUri().getLocal().getScheme().equals("file")) { - node.getIconUri().setLocal(null); - } - } - - return true; - } -} diff --git a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/Manager.java b/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/Manager.java deleted file mode 100644 index 9176c8dfac28..000000000000 --- a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/Manager.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.ejb; - -import java.io.File; -import java.util.List; -import javax.ejb.Local; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Platform; - -/** - * This is the business interface for RegistryManager enterprise bean. - */ -@Local -public interface Manager { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - public static final File ROOT = new File("D:/temp/nbi-server/dev"); - public static final File TEMP = new File(ROOT, "temp"); - public static final File REGISTRIES = new File(ROOT, "registries"); - public static final File UPLOADS = new File(TEMP, "uploads"); - public static final File BUNDLES = new File(TEMP, "bundles"); - public static final File EXPORTED = new File(TEMP, "exported"); - public static final File NBI = new File(TEMP, ".nbi"); - - public static final File REGISTRIES_LIST = new File(ROOT, "registries.list"); - public static final File ENGINE = new File(ROOT, "nbi-engine.jar"); - - public static final String PRODUCTS = "products"; - public static final String GROUPS = "groups"; - public static final String REGISTRY_XML = "registry.xml"; - - public static final String JNLP_STUB = - "\n" + - "\n" + - " \n" + - " NetBeans Installer\n" + - " Sun Microsystems, Inc.\n" + - " NetBeans Installer Engine\n" + - " NetBeans Installer Engine\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - // registry operations ////////////////////////////////////////////////////////// - void addRegistry(String registry) throws ManagerException; - - void removeRegistry(String registry) throws ManagerException; - - String getRegistry(String name) throws ManagerException; - - List getRegistries() throws ManagerException; - - // engine operations //////////////////////////////////////////////////////////// - File getEngine() throws ManagerException; - - void updateEngine(File engine) throws ManagerException; - - // components operations //////////////////////////////////////////////////////// - void addPackage(String name, File archive, String parentUid, String parentVersion, String parentPlatforms, String uriPrefix) throws ManagerException; - - void removeProduct(String name, String uid, String version, String platforms) throws ManagerException; - - void removeGroup(String name, String uid) throws ManagerException; - - // miscellanea ////////////////////////////////////////////////////////////////// - File exportRegistries(String[] registryNames, String codebase) throws ManagerException; - - String getJnlp(String[] registryNames, String codebase) throws ManagerException; - - File getFile(String name, String file) throws ManagerException; - - Registry loadRegistry(String... names) throws ManagerException; - - List getProducts(String... names) throws ManagerException; - - File createBundle(Platform platform, String[] names, String[] components) throws ManagerException; - - void deleteBundles() throws ManagerException; - - void generateBundles(String[] names) throws ManagerException; -} diff --git a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerBean.java b/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerBean.java deleted file mode 100644 index cfd1b7ac9fb8..000000000000 --- a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerBean.java +++ /dev/null @@ -1,883 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.ejb; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.locks.ReentrantLock; -import java.util.jar.JarOutputStream; -import java.util.zip.ZipEntry; -import javax.ejb.Stateless; -import org.netbeans.installer.Installer; -import org.netbeans.installer.downloader.DownloadManager; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.filters.TrueFilter; -import org.netbeans.installer.utils.FileUtils; -import org.netbeans.installer.utils.LogManager; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.XMLUtils; -import org.netbeans.installer.utils.applications.JavaUtils; -import org.netbeans.installer.utils.exceptions.FinalizationException; -import org.netbeans.installer.utils.exceptions.InitializationException; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.exceptions.XMLException; -import org.netbeans.installer.utils.helper.ExecutionResults; -import org.netbeans.installer.utils.helper.Platform; -import org.netbeans.installer.utils.helper.Status; -import org.netbeans.installer.utils.helper.Version; -import org.netbeans.installer.utils.progress.Progress; -import org.w3c.dom.Document; - -/** - * - * @author Kirill Sorokin - */ -@Stateless -public class ManagerBean implements Manager { - ///////////////////////////////////////////////////////////////////////////////// - // Static - private static ReentrantLock bundlesLock = new ReentrantLock(); - - private static Map registries = new HashMap(); - private static Map bundles = new HashMap(); - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - public ManagerBean() { - try { - ROOT.mkdirs(); - - TEMP.mkdirs(); - REGISTRIES.mkdirs(); - UPLOADS.mkdirs(); - BUNDLES.mkdirs(); - NBI.mkdirs(); - - if (!REGISTRIES_LIST.exists()) { - REGISTRIES_LIST.createNewFile(); - } - - loadRegistriesList(); - - //Issue #183611 - //Locale.setDefault(new Locale("en", "US")); - - DownloadManager.getInstance().setLocalDirectory(NBI); - DownloadManager.getInstance().setFinishHandler(new DummyFinishHandler()); - - System.setProperty( - Installer.LOCAL_DIRECTORY_PATH_PROPERTY, NBI.getAbsolutePath()); - System.setProperty( - Installer.IGNORE_LOCK_FILE_PROPERTY, "true"); - System.setProperty( - LogManager.LOG_TO_CONSOLE_PROPERTY, "false"); - System.setProperty( - Registry.LAZY_LOAD_ICONS_PROPERTY, "true"); - } catch (IOException e) { - e.printStackTrace(); - } catch (ManagerException e) { - e.printStackTrace(); - } - } - - // registry operations ////////////////////////////////////////////////////////// - public void addRegistry(String registryName) throws ManagerException { - if (registries.get(registryName) == null) { - registries.put(registryName, initializeRegistry(registryName)); - } - - saveRegistriesList(); - } - - public void removeRegistry(String registryName) throws ManagerException { - try { - if (registries.get(registryName) != null) { - FileUtils.deleteFile(registries.get(registryName), true); - registries.remove(registryName); - } - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - - saveRegistriesList(); - } - - public String getRegistry(String registryName) throws ManagerException { - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - final File registryDir = registries.get(registryName); - final File registryXml = new File(registryDir, REGISTRY_XML); - - try { - return FileUtils.readFile(registryXml); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - public List getRegistries() throws ManagerException { - return new ArrayList(registries.keySet()); - } - - // engine operations //////////////////////////////////////////////////////////// - public File getEngine() throws ManagerException { - return ENGINE; - } - - public void updateEngine(File engine) throws ManagerException { - deleteBundles(); - - ENGINE.delete(); - - try { - FileUtils.moveFile(engine, ENGINE); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - // component operations ///////////////////////////////////////////////////////// - public void addPackage(String registryName, File archive, String parentUid, String parentVersion, String parentPlatforms, String uriPrefix) throws ManagerException { - deleteBundles(); - - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - try { - final File localRegistryDir = - registries.get(registryName); - final File localRegistryXml = - new File(localRegistryDir, REGISTRY_XML); - final File packageRegistryDir = - FileUtils.createTempFile(TEMP, false); - final File packageRegistryXml = - new File(packageRegistryDir, "registry.xml"); - - FileUtils.unjar(archive, packageRegistryDir); - FileUtils.modifyFile(packageRegistryXml, - "(\\>)resource:(.*?\\<\\/)", - "$1" + uriPrefix.replace("&", "&") + "$2", true, StringUtils.ENCODING_UTF8); - - final Registry localRegistry = new Registry(); - localRegistry.setLocalDirectory(NBI); - localRegistry.setFinishHandler(new DummyFinishHandler()); - localRegistry.loadProductRegistry(localRegistryXml); - - final Registry packageRegistry = new Registry(); - packageRegistry.setLocalDirectory(NBI); - packageRegistry.setFinishHandler(new DummyFinishHandler()); - packageRegistry.loadProductRegistry(packageRegistryXml); - - final Queue nodes = new LinkedList(); - - for (Product product: packageRegistry.getProducts()) { - final List existingProducts = localRegistry.getProducts( - product.getUid(), - product.getVersion(), - product.getPlatforms()); - - if (existingProducts.size() > 0) { - for (Product existingProduct: existingProducts) { - nodes.offer(existingProduct); - } - } - } - - for (Group group: packageRegistry.getGroups()) { - if (!group.equals(packageRegistry.getRegistryRoot())) { - final Group existingGroup = localRegistry.getGroup( - group.getUid()); - - if (existingGroup != null) { - nodes.offer(existingGroup); - } - } - } - - if (nodes.size() > 0) { - while (nodes.peek() != null) { - final RegistryNode node = nodes.poll(); - - node.getParent().removeChild(node); - - if (node instanceof Product) { - final Product temp = (Product) node; - final String path = PRODUCTS + "/" + - temp.getUid() + "/" + - temp.getVersion() + "/" + - StringUtils.asString(temp.getPlatforms(), " "); - - FileUtils.deleteFile(new File(localRegistryDir, path), true); - } - - if (node instanceof Group) { - final Group temp = (Group) node; - final String path = GROUPS + "/" + - temp.getUid(); - - FileUtils.deleteFile(new File(localRegistryDir, path), true); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - FileUtils.copyFile( - new File(packageRegistryDir, PRODUCTS), - new File(localRegistryDir, PRODUCTS), - true); - FileUtils.copyFile( - new File(packageRegistryDir, GROUPS), - new File(localRegistryDir, GROUPS), - true); - - RegistryNode parent; - - List parents = null; - if ((parentVersion != null) && - !parentVersion.equals("null") && - (parentPlatforms != null) && - !parentPlatforms.equals("null")) { - parents = localRegistry.getProducts( - parentUid, - Version.getVersion(parentVersion), - StringUtils.parsePlatforms(parentPlatforms)); - } - if ((parents == null) || (parents.size() == 0)) { - parent = localRegistry.getGroup(parentUid); - if (parent == null) { - parent = localRegistry.getRegistryRoot(); - } - } else { - parent = parents.get(0); - } - - parent.attachRegistry(packageRegistry); - - localRegistry.saveProductRegistry( - localRegistryXml, - TrueFilter.INSTANCE, - true, - true, - true); - - FileUtils.deleteFile(archive); - FileUtils.deleteFile(packageRegistryDir, true); - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not update component", e); - } catch (XMLException e) { - e.printStackTrace(); - throw new ManagerException("Could not update component", e); - } catch (FinalizationException e) { - e.printStackTrace(); - throw new ManagerException("Could not update component", e); - } catch (ParseException e) { - e.printStackTrace(); - throw new ManagerException("Could not update component", e); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - public void removeProduct(String registryName, String uid, String version, String platforms) throws ManagerException { - deleteBundles(); - - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - final File registryDir = registries.get(registryName); - final File productsDir = new File(registryDir, PRODUCTS); - final File groupsDir = new File(registryDir, GROUPS); - final File registryXml = new File(registryDir, REGISTRY_XML); - - try { - final Registry registry = new Registry(); - - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - registry.loadProductRegistry(registryXml); - - final List existing = registry.getProducts( - uid, - Version.getVersion(version), - StringUtils.parsePlatforms(platforms)); - - if (existing != null) { - existing.get(0).getParent().removeChild(existing.get(0)); - - Queue nodes = new LinkedList(); - nodes.offer(existing.get(0)); - - while(nodes.peek() != null) { - RegistryNode node = nodes.poll(); - - if (node instanceof Product) { - Product temp = (Product) node; - FileUtils.deleteFile(new File(productsDir, temp.getUid() + "/" + temp.getVersion())); - } - - if (node instanceof Group) { - Group temp = (Group) node; - FileUtils.deleteFile(new File(groupsDir, temp.getUid())); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - registry.saveProductRegistry(registryXml, TrueFilter.INSTANCE, true, true, true); - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not remove component", e); - } catch (FinalizationException e) { - e.printStackTrace(); - throw new ManagerException("Could not remove component", e); - } catch (ParseException e) { - e.printStackTrace(); - throw new ManagerException("Could not update component", e); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - public void removeGroup(String registryName, String uid) throws ManagerException { - deleteBundles(); - - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - final File registryDir = registries.get(registryName); - final File productsDir = new File(registryDir, PRODUCTS); - final File groupsDir = new File(registryDir, GROUPS); - final File registryXml = new File(registryDir, REGISTRY_XML); - - try { - final Registry registry = new Registry(); - - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - registry.loadProductRegistry(registryXml); - - final Group existing = registry.getGroup(uid); - - if (existing != null) { - existing.getParent().removeChild(existing); - - Queue nodes = new LinkedList(); - nodes.offer(existing); - - while(nodes.peek() != null) { - RegistryNode node = nodes.poll(); - - if (node instanceof Product) { - Product temp = (Product) node; - FileUtils.deleteFile(new File(productsDir, temp.getUid() + "/" + temp.getVersion())); - } - - if (node instanceof Group) { - Group temp = (Group) node; - FileUtils.deleteFile(new File(groupsDir, temp.getUid())); - } - - for (RegistryNode child: node.getChildren()) { - nodes.offer(child); - } - } - } - - registry.saveProductRegistry(registryXml, TrueFilter.INSTANCE, true, true, true); - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not remove component", e); - } catch (FinalizationException e) { - e.printStackTrace(); - throw new ManagerException("Could not remove component", e); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - // miscellanea ////////////////////////////////////////////////////////////////// - public File exportRegistries(String[] registryNames, String codebase) throws ManagerException { - try { - final File userDir = FileUtils.createTempFile(TEMP, false); - final File registryFile = FileUtils.createTempFile(TEMP, false); - - final File target = new File( - EXPORTED, - StringUtils.asString(registryNames, ", ") + ".jar"); - - FileUtils.mkdirs(target.getParentFile()); - - final Registry registry = new Registry(); - - registry.setLocalDirectory(userDir); - registry.setFinishHandler(new DummyFinishHandler()); - - for (String registryName: registryNames) { - registry.loadProductRegistry( - new File(registries.get(registryName), REGISTRY_XML)); - } - - registry.saveProductRegistry( - registryFile, - TrueFilter.INSTANCE, - false, - true, - true); - - final JarOutputStream out = - new JarOutputStream(new FileOutputStream(target)); - - for (String registryName: registryNames) { - final List excludes = new LinkedList(); - - excludes.add(new File(registries.get(registryName), REGISTRY_XML)); - - FileUtils.zip( - registries.get(registryName), - out, - registries.get(registryName).getParentFile(), - excludes); - - } - - FileUtils.modifyFile( - registryFile, - ">.*?registry=(.+?)&file=", - ">" + codebase + "/$1/", - true, StringUtils.ENCODING_UTF8); - FileUtils.modifyFile( - registryFile, - "%2F", - "/", StringUtils.ENCODING_UTF8); - FileUtils.modifyFile( - registryFile, - "+", - "%20", StringUtils.ENCODING_UTF8); - - out.putNextEntry(new ZipEntry("registry.xml")); - StreamUtils.transferFile(registryFile, out); - - out.putNextEntry(new ZipEntry("nbi-engine.jar")); - StreamUtils.transferFile(getEngine(), out); - - out.putNextEntry(new ZipEntry("nbi.jnlp")); - StreamUtils.writeChars(out, StringUtils.format( - JNLP_STUB, - codebase, - "nbi.jnlp", - codebase + "/nbi-engine.jar", - codebase + "/registry.xml")); - - FileUtils.deleteFile(userDir); - FileUtils.deleteFile(registryFile); - - out.close(); - - return target; - } catch (IOException e) { - throw new ManagerException("Cannot export", e); - } catch (InitializationException e) { - throw new ManagerException("Cannot export", e); - } catch (FinalizationException e) { - throw new ManagerException("Cannot export", e); - } - } - - public String getJnlp(String[] registryNames, String codebase) throws ManagerException { - try { - String jnlp = "install?true=true"; - for (String registryName: registryNames) { - jnlp += "®istry=" + URLEncoder.encode(registryName, "UTF-8"); - } - - String engine = codebase + "/nbi-engine.jar"; - - String registry = ""; - for (String registryName: registryNames) { - registry += - codebase + - "/get-registry?registry=" + - URLEncoder.encode(registryName, "UTF-8") + - "\n"; - } - registry = registry.trim(); - - return StringUtils.format(JNLP_STUB, codebase, jnlp, engine, registry); - } catch (UnsupportedEncodingException e) { - throw new ManagerException("Whoah..", e); - } - } - - public File getFile(String registryName, String file) throws ManagerException { - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - final File registryDir = registries.get(registryName); - - return new File(registryDir, file); - } - - public Registry loadRegistry(String... registryNames) throws ManagerException { - if (registryNames.length > 0) { - List files = new LinkedList(); - - for (String name: registryNames) { - if (registries.get(name) == null) { - addRegistry(name); - } - - files.add(new File(registries.get(name), REGISTRY_XML)); - } - - try { - final Registry registry = new Registry(); - - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - for (File file: files) { - registry.loadProductRegistry(file); - } - - return registry; - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - return null; - } - - public List getProducts(String... registryNames) throws ManagerException { - List components = new LinkedList(); - - if (registryNames.length > 0) { - final List files = new LinkedList(); - for (String registryName: registryNames) { - if (registries.get(registryName) == null) { - addRegistry(registryName); - } - - files.add(new File(registries.get(registryName), REGISTRY_XML)); - } - - try { - final Registry registry = new Registry(); - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - - for (File file: files) { - registry.loadProductRegistry(file); - } - - components.addAll(registry.getProducts()); - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - return components; - } - - public File createBundle(Platform platform, String[] registryNames, String[] components) throws ManagerException { - bundlesLock.lock(); - try { - final String key = - StringUtils.asString(registryNames) + - StringUtils.asString(components) + - platform; - - if ((bundles.get(key) != null) && bundles.get(key).exists()) { - return bundles.get(key); - } - - if (bundles.get(key) != null) { - bundles.remove(key); - } - - try { - File statefile = FileUtils.createTempFile(TEMP, false); - File userDir = FileUtils.createTempFile(TEMP, false); - File bundle = new File( - FileUtils.createTempFile(BUNDLES, false), - "bundle.jar"); - - File javaHome = new File(System.getProperty("java.home")); - - String remote = ""; - List files = new LinkedList(); - for (String name: registryNames) { - if (registries.get(name) == null) { - addRegistry(name); - } - File xml = new File(registries.get(name), REGISTRY_XML); - - files.add(xml); - remote += xml.toURI().toString() + "\n"; - } - remote = remote.trim(); - - final Registry registry = new Registry(); - - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - registry.setTargetPlatform(platform); - for (File file: files) { - registry.loadProductRegistry(file); - } - - for (String string: components) { - String[] parts = string.split(","); - - registry.getProduct( - parts[0], - Version.getVersion(parts[1])).setStatus(Status.INSTALLED); - } - registry.saveStateFile(statefile, new Progress()); - - bundle.getParentFile().mkdirs(); - - ExecutionResults results = SystemUtils.executeCommand( - JavaUtils.getExecutable(javaHome).getAbsolutePath(), - "-Dnbi.product.remote.registries=" + remote, - "-jar", - ENGINE.getAbsolutePath(), - "--silent", - "--state", - statefile.getAbsolutePath(), - "--create-bundle", - bundle.getAbsolutePath(), - "--ignore-lock", - "--platform", - platform.toString(), - "--userdir", - userDir.getAbsolutePath()); - - System.out.println(results.getErrorCode()); - System.out.println(results.getStdOut()); - System.out.println(results.getStdErr()); - - if (results.getErrorCode() != 0) { - throw new ManagerException("Could not create bundle - error in running the engine"); - } - - FileUtils.deleteFile(statefile); - FileUtils.deleteFile(userDir, true); - - if (platform == Platform.WINDOWS) { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".exe")); - } else if (platform.isCompatibleWith(Platform.MACOSX)) { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".zip")); - } else { - bundle = new File( - bundle.getAbsolutePath().replaceFirst("\\.jar$", ".sh")); - } - - bundles.put(key, bundle); - - return bundle; - } catch (InitializationException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } catch (FinalizationException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } finally { - bundlesLock.unlock(); - } - } - - public void generateBundles(String[] registryNames) throws ManagerException { - try { - final List files = new ArrayList(); - for (String name: registryNames) { - if (registries.get(name) == null) { - addRegistry(name); - } - - files.add(new File(registries.get(name), REGISTRY_XML)); - } - - for (Platform platform: Platform.values()) { - final Registry registry = new Registry(); - - registry.setLocalDirectory(NBI); - registry.setFinishHandler(new DummyFinishHandler()); - for (File file: files) { - registry.loadProductRegistry(file); - } - - final List products = registry.getProducts(platform); - - for (int i = 1; i <= products.size(); i++) { - Product[] combination = new Product[i]; - - iterate(platform, registryNames, registry, combination, 0, products, 0); - } - } - } catch (InitializationException e) { - throw new ManagerException("Cannot generate bundles", e); - } - } - - public void deleteBundles() throws ManagerException { - bundlesLock.lock(); - try { - for (File file: bundles.values()) { - FileUtils.deleteFile(file); - } - - bundles.clear(); - } catch (IOException e) { - throw new ManagerException("Cannot clear bundles", e); - } finally { - bundlesLock.unlock(); - } - } - - // private ////////////////////////////////////////////////////////////////////// - private void loadRegistriesList() throws ManagerException { - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(REGISTRIES_LIST))); - - String line = null; - while ((line = reader.readLine()) != null) { - line = line.trim(); - registries.put(line, initializeRegistry(line)); - } - - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - private void saveRegistriesList() throws ManagerException { - try { - PrintWriter writer = new PrintWriter( - new OutputStreamWriter(new FileOutputStream(REGISTRIES_LIST))); - - try { - registries.keySet().forEach(writer::println); - } finally { - writer.close(); - } - } catch (IOException e) { - e.printStackTrace(); - throw new ManagerException("Could not load registry", e); - } - } - - private File initializeRegistry(String name) throws ManagerException { - File directory = new File(REGISTRIES, name); - File registryxml = new File(directory, REGISTRY_XML); - - directory.mkdirs(); - - if (!registryxml.exists()) { - try { - Document document = Registry. - getInstance().getEmptyRegistryDocument(); - XMLUtils.saveXMLDocument(document, registryxml); - } catch (XMLException e) { - e.printStackTrace(); - throw new ManagerException("Cannot initialize registry", e); - } - } - - return directory; - } - - private void iterate(Platform platform, String[] registryNames, Registry registry, Product[] combination, int index, List products, int start) throws ManagerException { - for (int i = start; i < products.size(); i++) { - combination[index] = products.get(i); - - if (index == combination.length - 1) { - for (Product product: products) { - product.setStatus(Status.NOT_INSTALLED); - } - for (Product product: combination) { - product.setStatus(Status.TO_BE_INSTALLED); - } - - if (registry.getProductsToInstall().size() == combination.length) { - String[] components = new String[combination.length]; - - for (int j = 0; j < combination.length; j++) { - components[j] = combination[j].getUid() + "," + - combination[j].getVersion().toString(); - } - - createBundle(platform, registryNames, components); - } - } else { - iterate(platform, registryNames, registry, combination, index + 1, products, i + 1); - } - } - } -} diff --git a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerException.java b/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerException.java deleted file mode 100644 index 42857ed9aca9..000000000000 --- a/nbi/infra/server/modules/ejb/src/java/org/netbeans/installer/infra/server/ejb/ManagerException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.ejb; - -/** - * - * @author Kirill Sorokin - */ -public class ManagerException extends Exception { - /** - * - * @param message - */ - public ManagerException(String message) { - super(message); - } - - /** - * - * @param message - * @param cause - */ - public ManagerException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/nbi/infra/server/modules/war-admin/build.xml b/nbi/infra/server/modules/war-admin/build.xml deleted file mode 100644 index 26e095a4f1e8..000000000000 --- a/nbi/infra/server/modules/war-admin/build.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Server - Admin. - - - diff --git a/nbi/infra/server/modules/war-admin/nbproject/ant-deploy.xml b/nbi/infra/server/modules/war-admin/nbproject/ant-deploy.xml deleted file mode 100644 index e86b4a518748..000000000000 --- a/nbi/infra/server/modules/war-admin/nbproject/ant-deploy.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${lefty}?xml version="1.0" encoding="UTF-8"?${righty} -${lefty}!DOCTYPE resources PUBLIC - "-//Sun Microsystems Inc.//DTD Application Server 9.0 Resource Definitions //EN" - "${sjsas.root}/lib/dtds/sun-resources_1_2.dtd"${righty} -${lefty}resources${righty} -${lefty}/resources${righty} - - - - - - - -]]> - - - - -]]> - - - - - - - ]]> - - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-admin/nbproject/build-impl.xml b/nbi/infra/server/modules/war-admin/nbproject/build-impl.xml deleted file mode 100644 index e2d18169425e..000000000000 --- a/nbi/infra/server/modules/war-admin/nbproject/build-impl.xml +++ /dev/null @@ -1,787 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - Platform is not correctly set up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.web.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.war - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.jsp.includes - - - - - - - - - - - - - - - - - - - - Must select a file in the IDE or set jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. - - - Launching ${browse.url} - - - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-admin/nbproject/genfiles.properties b/nbi/infra/server/modules/war-admin/nbproject/genfiles.properties deleted file mode 100644 index 7a31614c204e..000000000000 --- a/nbi/infra/server/modules/war-admin/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=b5d867bf -build.xml.script.CRC32=fb55c113 -build.xml.stylesheet.CRC32=e4ec34a3 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=3e3b536d -nbproject/build-impl.xml.script.CRC32=2bab7749 -nbproject/build-impl.xml.stylesheet.CRC32=bc8f1c1e diff --git a/nbi/infra/server/modules/war-admin/nbproject/project.properties b/nbi/infra/server/modules/war-admin/nbproject/project.properties deleted file mode 100644 index 6cef413e73df..000000000000 --- a/nbi/infra/server/modules/war-admin/nbproject/project.properties +++ /dev/null @@ -1,91 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.web.dir}/WEB-INF/classes -build.classes.excludes=**/*.java,**/*.form -build.dir=build -build.ear.classes.dir=${build.ear.web.dir}/WEB-INF/classes -build.ear.web.dir=${build.dir}/web -build.generated.dir=${build.dir}/generated -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -build.web.dir=${build.dir}/web -build.web.excludes=${build.classes.excludes} -client.urlPart= -compile.jsps=false -conf.dir=${source.root}/conf -debug.classpath=${javac.classpath}:${build.classes.dir}:${build.ear.classes.dir} -debug.test.classpath=\ - ${run.test.classpath} -display.browser=true -dist.dir=dist -dist.ear.war=${dist.dir}/${war.ear.name} -dist.javadoc.dir=${dist.dir}/javadoc -dist.war=${dist.dir}/${war.name} -j2ee.platform=1.5 -j2ee.server.type=J2EE -jar.compress=false -javac.classpath=\ - ${reference.NBI_Server_-_EJB.dist}:\ - ${reference.NetBeans_Installer_Engine.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.debug=true -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.preview=true -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jspcompilation.classpath=${jspc.classpath}:${javac.classpath} -lib.dir=${web.docbase.dir}/WEB-INF/lib -platform.active=JDK_1.5 -project.NBI_Server_-_EJB=../ejb -project.NetBeans_Installer_Engine=../../../../engine -reference.NBI_Server_-_EJB.dist=${project.NBI_Server_-_EJB}/dist/ejb.jar -reference.NetBeans_Installer_Engine.jar=${project.NetBeans_Installer_Engine}/dist/nbi-engine.jar -resource.dir=setup -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -# Space-separated list of JVM arguments used when running class with main method -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): -runmain.jvmargs= -source.root=src -src.dir=${source.root}/java -test.src.dir=test -war.content.additional= -war.ear.name=war-admin.war -war.name=war-admin.war -war.package=true -web.docbase.dir=web -webinf.dir=${web.docbase.dir}/WEB-INF diff --git a/nbi/infra/server/modules/war-admin/nbproject/project.xml b/nbi/infra/server/modules/war-admin/nbproject/project.xml deleted file mode 100644 index 67770d75e706..000000000000 --- a/nbi/infra/server/modules/war-admin/nbproject/project.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - org.netbeans.modules.web.project - - - NBI Server - Admin - 1.6 - - - - ${reference.NBI_Server_-_EJB.dist} - WEB-INF/lib - - - ${reference.NetBeans_Installer_Engine.jar} - WEB-INF/lib - - - - - - - - - - - - - NBI_Server_-_EJB - jar - - dist - clean - dist - - - NetBeans_Installer_Engine - jar - - jar - clean - jar - - - - diff --git a/nbi/infra/server/modules/war-admin/src/conf/MANIFEST.MF b/nbi/infra/server/modules/war-admin/src/conf/MANIFEST.MF deleted file mode 100644 index 59499bce4a2b..000000000000 --- a/nbi/infra/server/modules/war-admin/src/conf/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddPackage.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddPackage.java deleted file mode 100644 index 029b7763e074..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddPackage.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class AddPackage extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "add-package"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddRegistry.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddRegistry.java deleted file mode 100644 index 95673a5593ff..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/AddRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author ks152834 - * @version - */ -public class AddRegistry extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "add-registry"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/DeleteBundles.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/DeleteBundles.java deleted file mode 100644 index ca183bbf61f7..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/DeleteBundles.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class DeleteBundles extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "delete-bundles"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ExportRegistry.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ExportRegistry.java deleted file mode 100644 index d8353db1224b..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ExportRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class ExportRegistry extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "export-registry"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/GenerateBundles.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/GenerateBundles.java deleted file mode 100644 index 78d2b882755d..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/GenerateBundles.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class GenerateBundles extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "generate-bundles"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ManageRegistries.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ManageRegistries.java deleted file mode 100644 index 8c324b598baf..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/ManageRegistries.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.Platform; - -/** - * - * @author ks152834 - * @version - */ -public class ManageRegistries extends HttpServlet { - @EJB - private Manager manager; - - protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setContentType("text/html; charset=UTF-8"); - - final PrintWriter out = response.getWriter(); - - try { - final List registries = manager.getRegistries(); - final String userAgent = request.getHeader("User-Agent"); - - Platform platform = SystemUtils.getCurrentPlatform(); - if (userAgent.contains("Windows")) { - platform = Platform.WINDOWS; - } - if (userAgent.contains("PPC Mac OS")) { - platform = Platform.MACOSX_PPC; - } - if (userAgent.contains("Intel Mac OS")) { - platform = Platform.MACOSX_X86; - } - if (userAgent.contains("Linux")) { - platform = Platform.LINUX; - } - if (userAgent.contains("SunOS i86pc")) { - platform = Platform.SOLARIS_X86; - } - if (userAgent.contains("SunOS sun4u")) { - platform = Platform.SOLARIS_SPARC; - } - - if (request.getParameter("platform") != null) { - try { - platform = StringUtils.parsePlatform( - request.getParameter("platform")); - } catch (ParseException e) { - e.printStackTrace(out); - } - } - - out.println(""); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" Registries Manager"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("

"); - out.println(" Add Registry |"); - if (registries.size() > 0) { - out.println(" Remove Registry |"); - out.println(" Delete Bundles | "); - out.println(" Generate Bundles | "); - out.println(" Export Registry | "); - } else { - out.println(" Remove Registry |"); - out.println(" Delete Bundles | "); - out.println(" Generate Bundles | "); - out.println(" Export Registry | "); - } - out.println(" Update Engine"); - out.println("
"); - out.println(" "); - if (registries.size() == 0) { - out.println("

"); - out.println(" Currently there are no existing registries on this server."); - out.println("

"); - } else { - String selected = request.getParameter("registry"); - - out.println(" "); - - out.println(" "); - - for (String registry: registries) { - out.println("
"); - - buildRegistryTable(out, registry, manager.loadRegistry(registry).getRegistryRoot(), platform); - - out.println("
"); - } - } - out.println(" "); - out.println("
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("
Please define a name for a new registry.
close window
"); - out.println("
"); - out.println("
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("
Please define the URL prefix for the export.
close window
"); - out.println("
"); - out.println("
"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("
Please point to a package.
close window
"); - out.println("
"); - out.println("
"); - out.println("

" + userAgent + "

"); - out.println(" "); - out.println(""); - - } catch (ManagerException e) { - e.printStackTrace(out); - } - - out.close(); - } - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - processRequest(request, response); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - processRequest(request, response); - } - - private void buildRegistryTable(PrintWriter out, String registry, RegistryNode root, Platform platform) { - out.println(" "); - - final ArrayList nodes = new ArrayList(); - nodes.add(root); - - buildRegistryNodes(out, registry, nodes, platform); - - out.println("
"); - } - - private void buildRegistryNodes(PrintWriter out, String registry, List nodes, Platform platform) { - for (RegistryNode node: nodes) { - try { - if (node instanceof Product) { - if (!((Product) node).getPlatforms().contains(platform)) { - continue; - } - } - - String icon = null; - String displayName = node.getDisplayName(); - String treeHandle = null; - - if (node.getIconUri() == null) { - icon = "img/default-icon.png"; - } else { - icon = node.getIconUri().getRemote().toString(); - } - - if (node.getChildren().size() > 0) { - treeHandle = "img/tree-handle-open.png"; - } else { - treeHandle = "img/tree-handle-empty.png"; - } - - String id = null; - - String uid = node.getUid(); - String version = null; - String type = null; - String platforms = null; - String title = ""; - - if (node instanceof Product) { - version = ((Product) node).getVersion().toString(); - platforms = StringUtils.asString(((Product) node).getPlatforms(), " "); - title = StringUtils.asString(((Product) node).getPlatforms()); - type = "component"; - - id = registry + "_" + uid + "_" + version + "_" + platforms.replace(" ", "_") + "_" + type; - } - - if (node instanceof Group) { - type = "group"; - - id = registry + "_" + uid + "_" + type; - } - - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" " + displayName + ""); - if (node.getParent() != null) { - out.println(" Remove"); - } else { - out.println(" "); - } - out.println(" Add Package"); - - out.println(" "); - - if (node.getChildren().size() > 0) { - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - buildRegistryNodes(out, registry, node.getChildren(), platform); - out.println("
"); - out.println(" "); - - out.println(" "); - } - } catch (Throwable e) { - e.printStackTrace(out); - } - } - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveGroup.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveGroup.java deleted file mode 100644 index 208b3c2492c5..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveGroup.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author ks152834 - * @version - */ -public class RemoveGroup extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "remove-group"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveProduct.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveProduct.java deleted file mode 100644 index 3dd5b524a67e..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveProduct.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class RemoveProduct extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "remove-product"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveRegistry.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveRegistry.java deleted file mode 100644 index f8dbf72139a4..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RemoveRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.*; -import java.net.*; - -import javax.servlet.*; -import javax.servlet.http.*; - -/** - * - * @author ks152834 - * @version - */ -public class RemoveRegistry extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "remove-registry"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RunCommand.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RunCommand.java deleted file mode 100644 index 028d0212fff1..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/RunCommand.java +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.ejb.EJB; -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.utils.FileUtils; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class RunCommand extends HttpServlet { - ///////////////////////////////////////////////////////////////////////////////// - // Constants - private static final String UTF = "UTF-8"; - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - @EJB - private Manager manager; - - protected void doPost(HttpServletRequest request, - HttpServletResponse response) throws IOException { - String command = (String) request.getAttribute("command"); - - String registry = null; - String uid = null; - String version = null; - String platforms = null; - File archive = null; - - String codebase = null; - - String fallback = null; - - try { - if (isMultiPartFormData(request)) { - Map parameters = getParameters(request); - - registry = (String) parameters.get("registry"); - - uid = (String) parameters.get("uid"); - version = (String) parameters.get("version"); - platforms = (String) parameters.get("platforms"); - - archive = (File) parameters.get("archive"); - - codebase = (String) parameters.get("codebase"); - - fallback = (String) parameters.get("fallback"); - } else { - registry = request.getParameter("registry"); - - uid = request.getParameter("uid"); - version = request.getParameter("version"); - platforms = request.getParameter("platforms"); - - codebase = request.getParameter("codebase"); - - fallback = request.getParameter("fallback"); - } - - String getFilePrefix = null; - if (registry != null) { - getFilePrefix = getHostUrl(request) + "/nbi/dev/get-file?registry=" + - URLEncoder.encode(registry, "UTF-8") + "&file="; - } - - if (command.equals("add-registry")) { - manager.addRegistry(registry); - } - - if (command.equals("remove-registry")) { - manager.removeRegistry(registry); - } - - if (command.equals("update-engine")) { - manager.updateEngine(archive); - } - - if (command.equals("add-package")) { - manager.addPackage(registry, archive, uid, version, platforms, getFilePrefix); - } - - if (command.equals("remove-product")) { - manager.removeProduct(registry, uid, version, platforms); - } - - if (command.equals("remove-group")) { - manager.removeGroup(registry, uid); - } - - if (command.equals("generate-bundles")) { - manager.generateBundles(new String[]{registry}); - } - - if (command.equals("delete-bundles")) { - manager.deleteBundles(); - } - - if (command.equals("export-registry")) { - manager.exportRegistries(new String[]{registry}, codebase); - } - - response.getWriter().write( - "The \"" + command + "\" command was successfully executed."); - - if (archive != null) { - archive.delete(); - } - - if (fallback != null) { - response.setStatus(HttpServletResponse.SC_SEE_OTHER); - response.setHeader("Location", fallback); - } - } catch (ManagerException e) { - e.printStackTrace(response.getWriter()); - - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - - response.getWriter().close(); - } - - /** - * Reads the servlet parameters passed in via multipart/form-data http request. - * The resulting map would contain values of two types: String and File, - * depending on the type of parameter. - * - * @param request - * The request for which to read the parameters. - * @throws java.io.IOException - * If an I/O error happens. - * @return - * The parameters map. - */ - private Map getParameters(HttpServletRequest request) - throws IOException { - final Map parameters = new HashMap(); - final ServletInputStream input = request.getInputStream(); - final String boundary = getBoundary(request); - final String endBoundary = boundary + "--"; - - byte[] buffer = new byte[boundary.length() + 102400]; - byte[] remainder = null; - OutputStream output = null; - String name = null; - String filename = null; - - // read the servlet input stream line by line and react accordingly - while (true) { - int length = read(input, buffer); - String line = new String(buffer, 0, length, UTF); - - // if we've reached a boundary this means that the current parameter's - // data stream finished, we should start parsing the next one - if (line.startsWith(boundary)) { - // first we finish with the previous parameter, if there was one. if - // it was a string, we need to put it to the map, if it was a file, - // we just need to close the stream - if (output != null) { - output.close(); - - if (parameters.get(name) == null) { - parameters.put(name, - ((ByteArrayOutputStream) output).toString(UTF)); - } - } - - // if this is the end - break the loop and return the parameters - if (line.startsWith(endBoundary)) { - break; - } - - // parse the parameter descriptor - we need to find out whether it is - // a string or a file and the name of this parameter. descriptor may - // be longer than our buffer is, thus we need to make sure a - // complete line is read before proceeding any further - String descriptor = new String(buffer, 0, read(input, buffer), UTF); - while (descriptor.trim().equals(descriptor)) { - descriptor += new String(buffer, 0, read(input, buffer), UTF); - } - - name = getName(descriptor); - filename = getFileName(descriptor); - - // initialize the target output stream for parameter's data and read - // the remaining lines before parameter data (one for strings, two - // for files) - read(input, buffer); - if (filename == null) { - output = new ByteArrayOutputStream(); - } else { - read(input, buffer); - - Manager.UPLOADS.mkdirs(); - File file = FileUtils.createTempFile(Manager.UPLOADS); - - parameters.put(name, file); - output = new FileOutputStream(file); - } - - remainder = null; - - // once we've finished with the boundary - we should proceed - // directly to the next line, since it won't make any sense to store - // this data anywhere - continue; - } - - // we need to watch very carefully for EOLs, since the last one does not - // really belong to the parameter's data, hence the mind-bending logic - if (remainder != null) { - output.write(remainder); - } - - if (buffer[length - 1] == 10) { - if ((length >= 2) && (buffer[length - 2] == 13)) { - remainder = new byte[]{13, 10}; - } else { - remainder = new byte[]{10}; - } - } else if (buffer[length - 1] == 13) { - if ((length >= 2) && (buffer[length - 2] == 10)) { - remainder = new byte[]{10, 13}; - } else { - remainder = new byte[]{13}; - } - } else { - remainder = new byte[0]; - } - - // write the parameter's data to the target output stream (would be - // bytearrayoutputstream for strings and fileoutputstream for files) - output.write(buffer, 0, length - remainder.length); - } - - return parameters; - } - - // entry desriptor parsing ////////////////////////////////////////////////////// - /** - * Gets the value of "name" attribute from a multipart/form-data entry. A - * shorthand for getAttribute(descriptor, "name"). - * - * @param descriptor - * The descriptor string to parse. - * @return - * The value of the "name" attribute of null, if this attribute is - * not present. - */ - private String getName(String descriptor) { - return getAttribute(descriptor, "name"); - } - - /** - * Gets the value of "filename" attribute from a multipart/form-data entry. A - * shorthand for getAttribute(descriptor, "filename"). - * - * @param descriptor - * The descriptor string to parse. - * @return - * The value of the "filename" attribute of null, if this attribute is - * not present. - */ - private String getFileName(String descriptor) { - return getAttribute(descriptor, "filename"); - } - - /** - * Gets attrbutes' values for a multipart/form-data entry descriptor. The - * descriptor is expected to have attributes in the form ="". - * - * @param descriptor - * The descriptor string to parse. - * @param name - * The name of the attribute. - * @return - * The value of the attribute or null if this attribute is not present. - */ - private String getAttribute(String descriptor, String name) { - Matcher matcher = Pattern.compile(name + "=\"(.*?)\"").matcher(descriptor); - if (matcher.find()) { - return matcher.group(1); - } else { - return null; - } - } - - // request properties accessors ///////////////////////////////////////////////// - /** - * Checks whether the request is multipart/form-data. - * - * @param request - * An HttpServletReequest object for which the check should be done. - * @return - * True is the request is multipart/form-data, false otherwise. - */ - private boolean isMultiPartFormData(HttpServletRequest request) { - return request.getContentType().startsWith("multipart/form-data"); - } - - /** - * Gets the boundary value of a multipart/form-data request. - * - * @param request - * An HttpServletRequest object for which the boundary value should be - * extracted. - * @return - * The boundary value or null, if it cannot be obtained. - */ - private String getBoundary(HttpServletRequest request) { - Matcher matcher = Pattern.compile("boundary=(.*)$").matcher(request.getContentType()); - if (matcher.find()) { - return "--" + matcher.group(1); - } else { - return null; - } - } - - // utility methods ////////////////////////////////////////////////////////////// - /** - * Reads a line into the specified byte array. The data is read until a newline - * character is encountered (all of "\n", "\r", "\n\r", "\r\n" are considered a - * newline character) or a maximum number of bytes is read. Thus the clients - * should not expect the result to be always a complete line. The amximum number - * of bytes is dictated by the length of the byte array. - * - * This wrapper is introduced in order not to return -1, when a line cannot be - * read, but to throw an IOException instead, since this situation is erroneous - * anyway. - * - * @param input - * A ServletInputStream from which to read data. - * @param buffer - * A byte array where to put the data - * @throws java.io.IOException - * If an I/O error happens. - * @return - * The number of bytes read. - */ - private int read(ServletInputStream input, byte[] buffer) throws IOException { - int length = input.readLine(buffer, 0, buffer.length); - - if (length == -1) { - throw new IOException("Could not read a complete " + - "buffer without reaching an EOL or reached " + - "the end of stream prematurely"); - } - - return length; - } - - private String getHostUrl(HttpServletRequest request) throws MalformedURLException { - URL url = new URL(request.getRequestURL().toString()); - String string = url.toString(); - - return string.substring(0, string.indexOf(url.getFile())); - } -} diff --git a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/UpdateEngine.java b/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/UpdateEngine.java deleted file mode 100644 index 4f06b2440e13..000000000000 --- a/nbi/infra/server/modules/war-admin/src/java/org/netbeans/installer/infra/server/admin/servlets/UpdateEngine.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.admin.servlets; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class UpdateEngine extends HttpServlet { - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - request.setAttribute("command", "update-engine"); - - request.getRequestDispatcher("/run-command").forward(request, response); - } -} diff --git a/nbi/infra/server/modules/war-admin/web/WEB-INF/sun-web.xml b/nbi/infra/server/modules/war-admin/web/WEB-INF/sun-web.xml deleted file mode 100644 index dcf8c3a3f137..000000000000 --- a/nbi/infra/server/modules/war-admin/web/WEB-INF/sun-web.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - /nbi-admin - - - - Enable debug info compilation in the generated servlet class - - - Maintain a one-to-one correspondence between static content and the generated servlet class' java code - - - diff --git a/nbi/infra/server/modules/war-admin/web/WEB-INF/web.xml b/nbi/infra/server/modules/war-admin/web/WEB-INF/web.xml deleted file mode 100644 index 24e3584f0a55..000000000000 --- a/nbi/infra/server/modules/war-admin/web/WEB-INF/web.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - run-command - org.netbeans.installer.infra.server.admin.servlets.RunCommand - - - add-package - org.netbeans.installer.infra.server.admin.servlets.AddPackage - - - remove-product - org.netbeans.installer.infra.server.admin.servlets.RemoveProduct - - - update-engine - org.netbeans.installer.infra.server.admin.servlets.UpdateEngine - - - add-registry - org.netbeans.installer.infra.server.admin.servlets.AddRegistry - - - remove-registry - org.netbeans.installer.infra.server.admin.servlets.RemoveRegistry - - - remove-group - org.netbeans.installer.infra.server.admin.servlets.RemoveGroup - - - manage-registries - org.netbeans.installer.infra.server.admin.servlets.ManageRegistries - - - generate-bundles - org.netbeans.installer.infra.server.admin.servlets.GenerateBundles - - - DeleteBundles - org.netbeans.installer.infra.server.admin.servlets.DeleteBundles - - - ExportRegistry - org.netbeans.installer.infra.server.admin.servlets.ExportRegistry - - - run-command - /run-command - - - add-package - /add-package - - - remove-product - /remove-product - - - update-engine - /update-engine - - - add-registry - /add-registry - - - remove-registry - /remove-registry - - - remove-group - /remove-group - - - manage-registries - /manage-registries - - - generate-bundles - /generate-bundles - - - DeleteBundles - /delete-bundles - - - ExportRegistry - /export-registry - - - - 30 - - - - manage-registries - - diff --git a/nbi/infra/server/modules/war-admin/web/css/main.css b/nbi/infra/server/modules/war-admin/web/css/main.css deleted file mode 100644 index c506fab0802d..000000000000 --- a/nbi/infra/server/modules/war-admin/web/css/main.css +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -body { - margin: 0px 0px 0px 0px; - padding: 10px 10px 10px 10px; - background-color: #ffffff; - font-family: Verdana, Arial, sans-serif; - font-size: 12px; -} - -p { - width: 700px; - margin: 0px 0px 10px 0px; - padding: 5px 10px 5px 10px; - background-color: #fcfcfc; -} - -p.small { - font-size: 10px; -} - -div.top-menu { - width: 680px; - margin: 0px 0px 10px 0px; - padding: 5px 10px 5px 10px; - border: 1px solid #c0c0c0; - background-color: #fcfcfc; -} - -select#registries-select, select#platforms-select { - display: block; - margin: 10px 0px 10px 0px; - width: 700px; -} - -div.registry { - margin: 10px 0px 10px 0px; - width: 700px; -} - -table.registry { - width: 100%; - margin: 0px 0px 0px 0px; - border: 0px solid #ff0000; - border-collapse: collapse; -} - -table.registry tr { - border: 0px solid #ffffff; -} - -table.registry td { - border: 0px solid #ffffff; - padding: 0px 0px 0px 0px; -} - -table.registry td.tree-handle { - width: 16px; -} - -table.registry td.tree-handle img { - cursor: pointer; -} - -table.registry td.icon { -} - -table.registry td.display-name { - width: 100%; - padding: 2px 5px 2px 5px; - font-family: Tahoma, Arial, sans-serif; - font-size: 12px; - cursor: default; -} - -table.registry td.option { - padding: 2px 5px 2px 5px; - font-family: Tahoma, Arial, sans-serif; - font-size: 12px; - white-space: nowrap; -} - -table.registry td.children { - border: 0px solid #000000; -} - -div.pop-up { - width: 500px; - border: 1px solid black; - background-color: #fcfcfc; - display: none; - padding: 50px 10px 50px 10px; -} - -div#form-registry { - position: absolute; - top: 100px; - left: 100px; -} - -div#form-archive { - position: absolute; - top: 100px; - left: 100px; -} - -div.pop-up table { - width: 100%; - margin: auto 0px auto 0px; - border-collapse: collapse; -} - -div.pop-up table td { - padding: 2px 5px 2px 5px; -} diff --git a/nbi/infra/server/modules/war-admin/web/img/default-icon.png b/nbi/infra/server/modules/war-admin/web/img/default-icon.png deleted file mode 100644 index dcc540472144..000000000000 Binary files a/nbi/infra/server/modules/war-admin/web/img/default-icon.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-admin/web/img/default-icon.svg b/nbi/infra/server/modules/war-admin/web/img/default-icon.svg deleted file mode 100644 index 6fd722d72b11..000000000000 --- a/nbi/infra/server/modules/war-admin/web/img/default-icon.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-admin/web/img/tree-handle-closed.png b/nbi/infra/server/modules/war-admin/web/img/tree-handle-closed.png deleted file mode 100644 index 1e9cda503e46..000000000000 Binary files a/nbi/infra/server/modules/war-admin/web/img/tree-handle-closed.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-admin/web/img/tree-handle-empty.png b/nbi/infra/server/modules/war-admin/web/img/tree-handle-empty.png deleted file mode 100644 index a338a90a62f2..000000000000 Binary files a/nbi/infra/server/modules/war-admin/web/img/tree-handle-empty.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-admin/web/img/tree-handle-open.png b/nbi/infra/server/modules/war-admin/web/img/tree-handle-open.png deleted file mode 100644 index 3760f7c8c65f..000000000000 Binary files a/nbi/infra/server/modules/war-admin/web/img/tree-handle-open.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-admin/web/js/main.js b/nbi/infra/server/modules/war-admin/web/js/main.js deleted file mode 100644 index 8d394eeaf8d5..000000000000 --- a/nbi/infra/server/modules/war-admin/web/js/main.js +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function show_form_registry() { - document.forms["Form"].registry.value = ""; - document.getElementById("form-registry").style.display = "block"; -} - -function close_form_registry() { - document.getElementById("form-registry").style.display = "none"; - - update_current_registry(); -} - -function show_form_codebase() { - document.forms["Form"].codebase.value = ""; - document.getElementById("form-codebase").style.display = "block"; -} - -function close_form_registry() { - document.getElementById("form-codebase").style.display = "none"; -} - -function show_form_archive() { - document.getElementById("form-archive").style.display = "block"; -} - -function close_form_archive() { - document.getElementById("form-archive").style.display = "none"; -} - -function add_registry() { - document.forms["Form"].action = "add-registry"; - - show_form_registry(); -} - -function remove_registry() { - var select = document.getElementById("registries-select"); - var registry = select.options[select.selectedIndex].value; - - document.forms["Form"].registry.value = registry; - document.forms["Form"].action = "remove-registry"; - document.forms["Form"].submit(); -} - -function update_engine() { - document.forms["Form"].action = "update-engine"; - - show_form_archive(); -} - -function update_current_registry() { - var platformsSelect = document.getElementById("platforms-select"); - var registriesSelect = document.getElementById("registries-select"); - - if ((platformsSelect != null) && (registriesSelect != null)) { - var platform = platformsSelect.options[platformsSelect.selectedIndex].value; - var registry = registriesSelect.options[registriesSelect.selectedIndex].value; - - document.forms["Form"].registry.value = registry; - - for (i = 0; i < registriesSelect.options.length; i++) { - var value = registriesSelect.options[i].value; - document.getElementById("registry-" + value).style.display = "none"; - } - - document.getElementById("registry-" + registry).style.display = "block"; - - document.forms["Form"].fallback.value = document.forms["Form"].fallback_base.value + "?registry=" + registry + "&platform=" + platform; - } else { - document.forms["Form"].fallback.value = document.forms["Form"].fallback_base.value; - } -} - -function update_target_platform() { - var platformsSelect = document.getElementById("platforms-select"); - var registriesSelect = document.getElementById("registries-select"); - - var platform = platformsSelect.options[platformsSelect.selectedIndex].value; - var registry = registriesSelect.options[registriesSelect.selectedIndex].value; - - window.location = document.forms["Form"].fallback_base.value + "?registry=" + registry + "&platform=" + platform; -} - -function remove_component(uid, version, platforms) { - var action; - if (version == "null") { - action = "remove-group"; - } else { - action = "remove-product"; - } - - document.forms["Form"].action = action; - document.forms["Form"].uid.value = uid; - document.forms["Form"].version.value = version; - document.forms["Form"].platforms.value = platforms; - document.forms["Form"].submit(); -} - -function add_package(uid, version, platforms) { - document.forms["Form"].action = "add-package"; - document.forms["Form"].uid.value = uid; - document.forms["Form"].version.value = version; - document.forms["Form"].platforms.value = platforms; - - show_form_archive(); -} - -function delete_bundles() { - var select = document.getElementById("registries-select"); - var registry = select.options[select.selectedIndex].value; - - document.forms["Form"].registry.value = registry; - document.forms["Form"].action = "delete-bundles"; - document.forms["Form"].submit(); -} - -function generate_bundles() { - var select = document.getElementById("registries-select"); - var registry = select.options[select.selectedIndex].value; - - document.forms["Form"].registry.value = registry; - document.forms["Form"].action = "generate-bundles"; - document.forms["Form"].submit(); -} - -function export_registry() { - var select = document.getElementById("registries-select"); - var registry = select.options[select.selectedIndex].value; - - document.forms["Form"].registry.value = registry; - document.forms["Form"].action = "export-registry"; - - show_form_codebase(); -} - -function _expand(id) { - var row = document.getElementById(id); - - if (row.style.display == "none") { - row.style.display = "table-row"; - } else { - row.style.display = "none"; - } -} diff --git a/nbi/infra/server/modules/war-client/build.xml b/nbi/infra/server/modules/war-client/build.xml deleted file mode 100644 index aba48d9072af..000000000000 --- a/nbi/infra/server/modules/war-client/build.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Server - Client. - - - diff --git a/nbi/infra/server/modules/war-client/nbproject/ant-deploy.xml b/nbi/infra/server/modules/war-client/nbproject/ant-deploy.xml deleted file mode 100644 index e86b4a518748..000000000000 --- a/nbi/infra/server/modules/war-client/nbproject/ant-deploy.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${lefty}?xml version="1.0" encoding="UTF-8"?${righty} -${lefty}!DOCTYPE resources PUBLIC - "-//Sun Microsystems Inc.//DTD Application Server 9.0 Resource Definitions //EN" - "${sjsas.root}/lib/dtds/sun-resources_1_2.dtd"${righty} -${lefty}resources${righty} -${lefty}/resources${righty} - - - - - - - -]]> - - - - -]]> - - - - - - - ]]> - - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-client/nbproject/build-impl.xml b/nbi/infra/server/modules/war-client/nbproject/build-impl.xml deleted file mode 100644 index 8626c3a9819f..000000000000 --- a/nbi/infra/server/modules/war-client/nbproject/build-impl.xml +++ /dev/null @@ -1,787 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - Platform is not correctly set up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set build.web.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.war - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.jsp.includes - - - - - - - - - - - - - - - - - - - - Must select a file in the IDE or set jsp.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. - - - Launching ${browse.url} - - - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-client/nbproject/genfiles.properties b/nbi/infra/server/modules/war-client/nbproject/genfiles.properties deleted file mode 100644 index da6a53ff1dd0..000000000000 --- a/nbi/infra/server/modules/war-client/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=b62c56cf -build.xml.script.CRC32=aae6d60a -build.xml.stylesheet.CRC32=e4ec34a3 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=de7a0603 -nbproject/build-impl.xml.script.CRC32=f1bd3c65 -nbproject/build-impl.xml.stylesheet.CRC32=bc8f1c1e diff --git a/nbi/infra/server/modules/war-client/nbproject/project.properties b/nbi/infra/server/modules/war-client/nbproject/project.properties deleted file mode 100644 index f35d75b19696..000000000000 --- a/nbi/infra/server/modules/war-client/nbproject/project.properties +++ /dev/null @@ -1,91 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.web.dir}/WEB-INF/classes -build.classes.excludes=**/*.java,**/*.form -build.dir=build -build.ear.classes.dir=${build.ear.web.dir}/WEB-INF/classes -build.ear.web.dir=${build.dir}/web -build.generated.dir=${build.dir}/generated -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -build.web.dir=${build.dir}/web -build.web.excludes=${build.classes.excludes} -client.urlPart= -compile.jsps=false -conf.dir=${source.root}/conf -debug.classpath=${javac.classpath}:${build.classes.dir}:${build.ear.classes.dir} -debug.test.classpath=\ - ${run.test.classpath} -display.browser=true -dist.dir=dist -dist.ear.war=${dist.dir}/${war.ear.name} -dist.javadoc.dir=${dist.dir}/javadoc -dist.war=${dist.dir}/${war.name} -j2ee.platform=1.5 -j2ee.server.type=J2EE -jar.compress=false -javac.classpath=\ - ${reference.NBI_Server_-_EJB.dist}:\ - ${reference.NetBeans_Installer_Engine.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.debug=true -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.preview=true -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jspcompilation.classpath=${jspc.classpath}:${javac.classpath} -lib.dir=${web.docbase.dir}/WEB-INF/lib -platform.active=JDK_1.5 -project.NBI_Server_-_EJB=../ejb -project.NetBeans_Installer_Engine=../../../../engine -reference.NBI_Server_-_EJB.dist=${project.NBI_Server_-_EJB}/dist/ejb.jar -reference.NetBeans_Installer_Engine.jar=${project.NetBeans_Installer_Engine}/dist/nbi-engine.jar -resource.dir=setup -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -# Space-separated list of JVM arguments used when running class with main method -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): -runmain.jvmargs= -source.root=src -src.dir=${source.root}/java -test.src.dir=test -war.content.additional= -war.ear.name=war-client.war -war.name=war-client.war -war.package=true -web.docbase.dir=web -webinf.dir=${web.docbase.dir}/WEB-INF diff --git a/nbi/infra/server/modules/war-client/nbproject/project.xml b/nbi/infra/server/modules/war-client/nbproject/project.xml deleted file mode 100644 index 187baf5af196..000000000000 --- a/nbi/infra/server/modules/war-client/nbproject/project.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - org.netbeans.modules.web.project - - - NBI Server - Client - 1.6 - - - - ${reference.NBI_Server_-_EJB.dist} - WEB-INF/lib - - - ${reference.NetBeans_Installer_Engine.jar} - WEB-INF/lib - - - - - - - - - - - - - NBI_Server_-_EJB - jar - - dist - clean - dist - - - NetBeans_Installer_Engine - jar - - jar - clean - jar - - - - diff --git a/nbi/infra/server/modules/war-client/src/conf/MANIFEST.MF b/nbi/infra/server/modules/war-client/src/conf/MANIFEST.MF deleted file mode 100644 index 59499bce4a2b..000000000000 --- a/nbi/infra/server/modules/war-client/src/conf/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components.java deleted file mode 100644 index 6bcd6713932d..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.dependencies.Requirement; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Dependency; -import org.netbeans.installer.utils.helper.Platform; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class Components extends HttpServlet { - @EJB - private Manager manager; - - protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final List fixed = Arrays.asList( - "nb-ide"); - final List standard = Arrays.asList( - "nb-ide", - "glassfish"); - final List selected = Arrays.asList( - "nb-xml", - "nb-soa", - "nb-identity", - "glassfish", - "openesb", - "sjsam"); - final Map> desires = - new HashMap>(); - desires.put("nb-visualweb", Arrays.asList("glassfish")); - - final Map comments = - new HashMap(); - comments.put("jdk", "WTF!T!&!&"); - - try { - response.setContentType("text/javascript; charset=UTF-8"); - final PrintWriter out = response.getWriter(); - - final Registry registry = manager.loadRegistry("NetBeans 6.1"); - - final List products = registry.getProducts(); - final List groups = registry.getGroups(); - - final Map productMapping = - new HashMap(); - - final List productUids = - new LinkedList(); - final List productVersions = - new LinkedList(); - final List productDisplayNames = - new LinkedList(); - final List productDownloadSizes = - new LinkedList(); - final List> productPlatforms = - new LinkedList>(); - final List productProperties = - new LinkedList(); - final List>> productRequirements = - new LinkedList>>(); - final List> productDesires = - new LinkedList>(); - final List productComments = - new LinkedList(); - - final List defaultGroupProducts = - new LinkedList(); - final List> groupProducts = - new LinkedList>(); - final List groupDisplayNames = - new LinkedList(); - - for (int i = 0; i < products.size(); i++) { - final Product product = products.get(i); - - boolean existingFound = false; - for (int j = 0; j < productUids.size(); j++) { - if (productUids.get(j).equals(product.getUid()) && - productVersions.get(j).equals(product.getVersion().toString())) { - productPlatforms.get(j).addAll(product.getPlatforms()); - productMapping.put(i, j); - existingFound = true; - break; - } - } - - if (existingFound) { - continue; - } - - long size = (long) Math.ceil( - ((double) product.getDownloadSize()) / 1024. ); - productUids.add(product.getUid()); - productVersions.add(product.getVersion().toString()); - productDisplayNames.add(product.getDisplayName()); - productDownloadSizes.add(Long.toString(size)); - productPlatforms.add(product.getPlatforms()); - - String properties = "PROPERTY_NONE"; - if (fixed.contains(product.getUid())) { - properties += " | PROPERTY_FIXED"; - } - if (standard.contains(product.getUid())) { - properties += " | PROPERTY_STANDARD"; - } - if (selected.contains(product.getUid())) { - properties += " | PROPERTY_SELECTED"; - } - productProperties.add(properties); - - List> requirements = new LinkedList>(); - productRequirements.add(requirements); - - List currentDesires = new LinkedList(); - productDesires.add(currentDesires); - - productComments.add(""); - - productMapping.put(i, productUids.size() - 1); - } - - for (int i = 0; i < products.size(); i++) { - final int index = productMapping.get(i); - final Product product = products.get(i); - - List> requirements = productRequirements.get(index); - for (Dependency requirement: product.getDependencies(Requirement.class)) { - List requireeIds = new LinkedList(); - requirements.add(requireeIds); - for (Product requiree: registry.getProducts(requirement)) { - requireeIds.add( - productMapping.get(products.indexOf(requiree))); - } - } - - List currentDesires = productDesires.get(index); - productDesires.set(index, currentDesires); - if (desires.get(product.getUid()) != null) { - for (String uid: desires.get(product.getUid())) { - for (Product desiree: products) { - if (desiree.getUid().equals(uid)) { - int indexOf = productMapping.get(products.indexOf(desiree)); - if (!currentDesires.contains(indexOf)) { - currentDesires.add(indexOf); - } - } - } - } - } - - if (comments.get(product.getUid()) != null) { - productComments.set(index, comments.get(product.getUid())); - } - } - - out.println("product_uids = new Array();"); - for (int i = 0; i < productUids.size(); i++) { - out.println(" product_uids[" + i + "] = \"" + productUids.get(i) + "\";"); - } - out.println(); - - out.println("product_versions = new Array();"); - for (int i = 0; i < productVersions.size(); i++) { - out.println(" product_versions[" + i + "] = \"" + productVersions.get(i) + "\";"); - } - out.println(); - - out.println("product_display_names = new Array();"); - for (int i = 0; i < productDisplayNames.size(); i++) { - out.println(" product_display_names[" + i + "] = \"" + productDisplayNames.get(i) + "\";"); - } - out.println(); - - out.println("product_download_sizes = new Array();"); - for (int i = 0; i < productDownloadSizes.size(); i++) { - out.println(" product_download_sizes[" + i + "] = " + productDownloadSizes.get(i) + ";"); - } - out.println(); - - out.println("product_platforms = new Array();"); - for (int i = 0; i < productPlatforms.size(); i++) { - out.println(" product_platforms[" + i + "] = new Array();"); - for (int j = 0; j < productPlatforms.get(i).size(); j++) { - out.println(" product_platforms[" + i + "][" + j + "] = \"" + productPlatforms.get(i).get(j) + "\";"); - } - } - out.println(); - - out.println("product_properties = new Array();"); - for (int i = 0; i < productProperties.size(); i++) { - out.println(" product_properties[" + i + "] = " + productProperties.get(i) + ";"); - } - out.println(); - - out.println("product_requirements = new Array();"); - for (int i = 0; i < productRequirements.size(); i++) { - out.println(" product_requirements[" + i + "] = new Array();"); - for (int j = 0; j < productRequirements.get(i).size(); j++) { - out.println(" product_requirements[" + i + "][" + j + "] = new Array();"); - for (int k = 0; k < productRequirements.get(i).get(j).size(); k++) { - out.println(" product_requirements[" + i + "][" + j + "][" + k + "] = " + productRequirements.get(i).get(j).get(k) + ";"); - } - } - } - - out.println("product_desires = new Array();"); - for (int i = 0; i < productDesires.size(); i++) { - out.println(" product_desires[" + i + "] = new Array();"); - for (int j = 0; j < productDesires.get(i).size(); j++) { - out.println(" product_desires[" + i + "][" + j + "] = " + productDesires.get(i).get(j) + ";"); - } - } - out.println(); - - out.println("product_comments = new Array();"); - for (int i = 0; i < productComments.size(); i++) { - out.println(" product_comments[" + i + "] = \"" + productComments.get(i) + "\";"); - } - out.println(); - - - for (int i = 0; i < productUids.size(); i++) { - defaultGroupProducts.add(Integer.valueOf(i)); - } - - for (Group group: groups) { - // skip the registry root - if (group.getUid().equals("")) { - continue; - } - - List components = new LinkedList(); - for (int i = 0; i < products.size(); i++) { - if (group.isAncestor(products.get(i))) { - Integer index = Integer.valueOf(productMapping.get(i)); - if (!components.contains(index)) { - components.add(index); - defaultGroupProducts.remove(index); - } - } - } - - groupProducts.add(components); - groupDisplayNames.add(group.getDisplayName()); - } - - if (groupProducts.size() > 0) { - out.println("group_products = new Array();"); - out.println(" group_products[0] = new Array();"); - for (int j = 0; j < defaultGroupProducts.size(); j++) { - out.println(" group_products[0][" + j + "] = " + defaultGroupProducts.get(j) + ";"); - } - for (int i = 0; i < groupProducts.size(); i++) { - out.println(" group_products[" + (i + 1) + "] = new Array();"); - for (int j = 0; j < groupProducts.get(i).size(); j++) { - out.println(" group_products[" + (i + 1) + "][" + j + "] = " + groupProducts.get(i).get(j) + ";"); - } - } - out.println(); - - out.println("group_display_names = new Array();"); - out.println(" group_display_names[0] = \"\";"); - for (int i = 0; i < groupDisplayNames.size(); i++) { - out.println(" group_display_names[" + (i + 1) + "] = \"" + groupDisplayNames.get(i) + "\";"); - } - out.println(); - } else { - out.println("group_products = new Array();"); - out.println(" group_products[0] = new Array();"); - for (int j = 0; j < defaultGroupProducts.size(); j++) { - out.println(" group_products[0][" + j + "] = " + defaultGroupProducts.get(j) + ";"); - } - out.println(); - - out.println("group_display_names = new Array();"); - out.println(" group_display_names[0] = \"\";"); - out.println(); - } - - out.close(); - } catch (ManagerException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - processRequest(request, response); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - processRequest(request, response); - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components2.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components2.java deleted file mode 100644 index bca38ce72638..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Components2.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.product.Registry; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.helper.Platform; - -public class Components2 extends HttpServlet { - @EJB - private Manager manager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final List java = Arrays.asList( - "nb-platform", - "nb-base", - "nb-javase"); - final List javaee = Arrays.asList( - "nb-platform", - "nb-base", - "nb-javase", - "nb-javaee", - "nb-groovy", - "glassfish", - "tomcat", - "sjsas"); - final List javame = Arrays.asList( - "nb-platform", - "nb-base", - "nb-javase", - "nb-javame"); - final List ruby = Arrays.asList( - "nb-platform", - "nb-base", - "nb-ruby"); - final List cnd = Arrays.asList( - "nb-platform", - "nb-base", - "nb-cnd"); - final List php = Arrays.asList( - "nb-platform", - "nb-base", - "nb-php"); - - final List full = Arrays.asList( - "nb-platform", - "nb-base", - "nb-javase", - "nb-javaee", - "nb-javame", - "nb-cnd", - "nb-soa", - "nb-uml", - "nb-ruby", - "nb-groovy", - "nb-php", - "glassfish", - "openesb", - "sjsam", - "tomcat", - "sjsas"); - final List hidden = Arrays.asList( - "nb-platform", - //"nb-base", - //"nb-php", - "openesb", - "sjsam"); - final Map notes = new HashMap(); - //notes.put("nb-javase", "for Java SE, includes GUI Builder, Profiler"); - - try { - response.setContentType("text/javascript; charset=UTF-8"); - final PrintWriter out = response.getWriter(); - - final Registry registry = manager.loadRegistry("NetBeans"); - - final List products = getProducts(registry.getRegistryRoot()); - final List groups = getGroups(registry.getRegistryRoot()); - - final Map productMapping = - new HashMap(); - - final List productUids = - new LinkedList(); - final List productVersions = - new LinkedList(); - final List productDisplayNames = - new LinkedList(); - final List productNotes = - new LinkedList(); - final List productDescriptions = - new LinkedList(); - final List productDownloadSizes = - new LinkedList(); - final List> productPlatforms = - new LinkedList>(); - final List productProperties = - new LinkedList(); - - final List defaultGroupProducts = - new LinkedList(); - final List> groupProducts = - new LinkedList>(); - final List groupDisplayNames = - new LinkedList(); - final List groupDescriptions = - new LinkedList(); - - for (int i = 0; i < products.size(); i++) { - final Product product = products.get(i); - - boolean existingFound = false; - for (int j = 0; j < productUids.size(); j++) { - if (productUids.get(j).equals(product.getUid()) && - productVersions.get(j).equals(product.getVersion().toString())) { - productPlatforms.get(j).addAll(product.getPlatforms()); - productMapping.put(i, j); - existingFound = true; - break; - } - } - - if (existingFound) { - continue; - } - - long size = (long) Math.ceil( - ((double) product.getDownloadSize()) / 1024. ); - productUids.add(product.getUid()); - productVersions.add(product.getVersion().toString()); - productDisplayNames.add(product.getDisplayName().replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - productDescriptions.add(product.getDescription().replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - productDownloadSizes.add(Long.toString(size)); - productPlatforms.add(product.getPlatforms()); - - if (notes.get(product.getUid()) != null) { - productNotes.add(notes.get(product.getUid()).replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - } else { - productNotes.add(""); - } - - String properties = "PROPERTY_NONE"; - if (java.contains(product.getUid())) { - properties += " | PROPERTY_JAVA"; - } - if (javaee.contains(product.getUid())) { - properties += " | PROPERTY_JAVAEE"; - } - if (javame.contains(product.getUid())) { - properties += " | PROPERTY_JAVAME"; - } - if (ruby.contains(product.getUid())) { - properties += " | PROPERTY_RUBY"; - } - if (cnd.contains(product.getUid())) { - properties += " | PROPERTY_CND"; - } - if (php.contains(product.getUid())) { - properties += " | PROPERTY_PHP"; - } - if (full.contains(product.getUid())) { - properties += " | PROPERTY_FULL"; - } - if (hidden.contains(product.getUid())) { - properties += " | PROPERTY_HIDDEN"; - } - productProperties.add(properties); - - productMapping.put(i, productUids.size() - 1); - } - - out.println("product_uids = new Array();"); - for (int i = 0; i < productUids.size(); i++) { - out.println(" product_uids[" + i + "] = \"" + productUids.get(i) + "\";"); - } - out.println(); - - out.println("product_versions = new Array();"); - for (int i = 0; i < productVersions.size(); i++) { - out.println(" product_versions[" + i + "] = \"" + productVersions.get(i) + "\";"); - } - out.println(); - - out.println("product_display_names = new Array();"); - for (int i = 0; i < productDisplayNames.size(); i++) { - out.println(" product_display_names[" + i + "] = \"" + productDisplayNames.get(i) + "\";"); - } - out.println(); - - out.println("product_notes = new Array();"); - for (int i = 0; i < productNotes.size(); i++) { - out.println(" product_notes[" + i + "] = \"" + productNotes.get(i) + "\";"); - } - out.println(); - - out.println("product_descriptions = new Array();"); - for (int i = 0; i < productDescriptions.size(); i++) { - out.println(" product_descriptions[" + i + "] = \"" + productDescriptions.get(i) + "\";"); - } - out.println(); - - out.println("product_download_sizes = new Array();"); - for (int i = 0; i < productDownloadSizes.size(); i++) { - out.println(" product_download_sizes[" + i + "] = " + productDownloadSizes.get(i) + ";"); - } - out.println(); - - out.println("product_platforms = new Array();"); - for (int i = 0; i < productPlatforms.size(); i++) { - out.println(" product_platforms[" + i + "] = new Array();"); - for (int j = 0; j < productPlatforms.get(i).size(); j++) { - out.println(" product_platforms[" + i + "][" + j + "] = \"" + productPlatforms.get(i).get(j) + "\";"); - } - } - out.println(); - - out.println("product_properties = new Array();"); - for (int i = 0; i < productProperties.size(); i++) { - out.println(" product_properties[" + i + "] = " + productProperties.get(i) + ";"); - } - out.println(); - - for (int i = 0; i < productUids.size(); i++) { - defaultGroupProducts.add(Integer.valueOf(i)); - } - - for (Group group: groups) { - List components = new LinkedList(); - for (int i = 0; i < products.size(); i++) { - if (products.get(i).getParent().equals(group)) { - Integer index = Integer.valueOf(productMapping.get(i)); - if (!components.contains(index)) { - components.add(index); - defaultGroupProducts.remove(index); - } - } - } - - groupProducts.add(components); - groupDisplayNames.add(group.getDisplayName().replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - groupDescriptions.add(group.getDescription().replace("\"", "\\\"").replaceAll("\r\n|\r|\n", "\\\n")); - } - - if (defaultGroupProducts.size() > 0) { - groupProducts.add(0, defaultGroupProducts); - groupDisplayNames.add(0, ""); - groupDescriptions.add(0, ""); - } - - out.println("group_products = new Array();"); - for (int i = 0; i < groupProducts.size(); i++) { - out.println(" group_products[" + i + "] = new Array();"); - for (int j = 0; j < groupProducts.get(i).size(); j++) { - out.println(" group_products[" + i + "][" + j + "] = " + groupProducts.get(i).get(j) + ";"); - } - } - out.println(); - - out.println("group_display_names = new Array();"); - for (int i = 0; i < groupDisplayNames.size(); i++) { - out.println(" group_display_names[" + i + "] = \"" + groupDisplayNames.get(i) + "\";"); - } - out.println(); - - out.println("group_descriptions = new Array();"); - for (int i = 0; i < groupDescriptions.size(); i++) { - out.println(" group_descriptions[" + i + "] = \"" + groupDescriptions.get(i) + "\";"); - } - out.println(); - - out.close(); - } catch (ManagerException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private List getProducts(RegistryNode root) { - final List list = new LinkedList(); - - for (RegistryNode node: root.getChildren()) { - if (node instanceof Product) { - list.add((Product) node); - } - - list.addAll(getProducts(node)); - } - - return list; - } - - private List getGroups(RegistryNode root) { - final List list = new LinkedList(); - - for (RegistryNode node: root.getChildren()) { - if (node instanceof Group) { - list.add((Group) node); - } - - list.addAll(getGroups(node)); - } - - return list; - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/CreateBundle.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/CreateBundle.java deleted file mode 100644 index 8a5d4f03eac6..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/CreateBundle.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.URLEncoder; -import java.util.Date; -import java.util.List; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.product.components.Group; -import org.netbeans.installer.product.RegistryNode; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; -import org.netbeans.installer.utils.exceptions.ParseException; -import org.netbeans.installer.utils.helper.Platform; - -import static org.netbeans.installer.utils.helper.Platform.WINDOWS; -import static org.netbeans.installer.utils.helper.Platform.LINUX; -import static org.netbeans.installer.utils.helper.Platform.SOLARIS_X86; -import static org.netbeans.installer.utils.helper.Platform.SOLARIS_SPARC; -import static org.netbeans.installer.utils.helper.Platform.MACOSX; -import static org.netbeans.installer.utils.helper.Platform.MACOSX_X86; -import static org.netbeans.installer.utils.helper.Platform.MACOSX_PPC; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class CreateBundle extends HttpServlet { - @EJB - private Manager manager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - if (request.getParameterValues("component") != null) { - doPost(request, response); - return; - } - - response.setContentType("text/html; charset=UTF-8"); - - String[] registries = request.getParameterValues("registry"); - - PrintWriter out = response.getWriter(); - - try { - String userAgent = request.getHeader("User-Agent"); - - Platform platform = SystemUtils.getCurrentPlatform(); - if (userAgent.contains("Windows")) { - platform = WINDOWS; - } - if (userAgent.contains("PPC Mac OS")) { - platform = MACOSX_PPC; - } - if (userAgent.contains("Intel Mac OS")) { - platform = MACOSX_X86; - } - if (userAgent.contains("Linux")) { - platform = LINUX; - } - if (userAgent.contains("SunOS i86pc")) { - platform = SOLARIS_X86; - } - if (userAgent.contains("SunOS sun4u")) { - platform = SOLARIS_SPARC; - } - - - if (request.getParameter("platform") != null) { - try { - platform = StringUtils.parsePlatform( - request.getParameter("platform")); - } catch (ParseException e) { - e.printStackTrace(out); - } - } - - out.println(""); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" Registries Manager"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - out.println("

"); - out.println(" Select the components that you would like to include in the bundle and click Next."); - out.println("

"); - out.println("
"); - - String registriesUrl = ""; - - for (String registry: registries) { - registriesUrl += "®istry=" + URLEncoder.encode(registry, "UTF-8"); - out.println(" "); - } - out.println(" "); - out.println(" "); - - out.println(" "); - - out.println("
"); - buildRegistryTable(out, manager.loadRegistry(registries).getRegistryRoot(), platform); - out.println("
"); - - out.println(" "); - - out.println("
"); - out.println("
"); - out.println("

" + userAgent + "

"); - out.println(" "); - out.println(""); - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - e.printStackTrace(out); - } - - out.close(); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - try { - final String[] registries = - request.getParameterValues("registry"); - final String[] components = - request.getParameterValues("component"); - final Platform platform = - StringUtils.parsePlatform(request.getParameter("platform")); - - final File file = - manager.createBundle(platform, registries, components); - - String filename = ""; - for (String name: components) { - filename += name.substring(0, name.indexOf(",")) + "_"; - } - filename += platform.toString(); - if (platform == WINDOWS) { - filename += ".exe"; - } else if (platform.isCompatibleWith(MACOSX)) { - filename += ".zip"; - } else { - filename += ".sh"; - } - - final OutputStream output = response.getOutputStream(); - - response.setContentType( - "application/octet-stream"); - response.setHeader( - "Content-Disposition", - "attachment; filename=" + filename); - response.setHeader( - "Last-Modified", - StringUtils.httpFormat(new Date(file.lastModified()))); - response.setHeader( - "Accept-Ranges", - "bytes"); - - Utils.transfer(request, response, output, file); - } catch (ParseException e) { - e.printStackTrace(response.getWriter()); - } catch (ManagerException e) { - e.printStackTrace(response.getWriter()); - } - } - - private void buildRegistryTable(PrintWriter out, RegistryNode root, Platform platform) { - out.println(" "); - - buildRegistryNodes(out, root.getChildren(), platform); - - out.println("
"); - } - - private void buildRegistryNodes(PrintWriter out, List nodes, Platform platform) { - for (RegistryNode node: nodes) { - if (node instanceof Product) { - if (!((Product) node).getPlatforms().contains(platform)) { - continue; - } - } - - String icon = null; - String displayName = node.getDisplayName(); - String treeHandle = null; - - if (node.getIconUri() == null) { - icon = "img/default-icon.png"; - } else { - icon = node.getIconUri().getRemote().toString(); - } - - if (node.getChildren().size() > 0) { - treeHandle = "img/tree-handle-open.png"; - } else { - treeHandle = "img/tree-handle-empty.png"; - } - - String id = null; - - String uid = node.getUid(); - String version = null; - String type = null; - String platforms = null; - String title = ""; - - if (node instanceof Product) { - version = ((Product) node).getVersion().toString(); - platforms = StringUtils.asString(((Product) node).getPlatforms(), " "); - title = StringUtils.asString(((Product) node).getPlatforms()); - type = "component"; - - id = uid + "_" + version + "_" + platforms.replace(" ", "_") + "_" + type; - } - - if (node instanceof Group) { - type = "group"; - - id = uid + "_" + type; - } - - out.println(" "); - - out.println(" "); - out.println(" "); - if (version != null) { - out.println(" "); - } else { - out.println(" "); - } - out.println(" " + displayName + ""); - - out.println(" "); - - if (node.getChildren().size() > 0) { - out.println(" "); - - out.println(" "); - out.println(" "); - out.println(" "); - buildRegistryNodes(out, node.getChildren(), platform); - out.println("
"); - out.println(" "); - - out.println(" "); - } - } - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Feed.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Feed.java deleted file mode 100644 index 9d27bcb86e55..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Feed.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.product.components.Product; -import org.netbeans.installer.utils.StringUtils; -import org.netbeans.installer.utils.SystemUtils; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class Feed extends HttpServlet { - @EJB - private Manager manager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final PrintWriter out = response.getWriter(); - final String[] registries = request.getParameterValues("registry"); - - try { - List components; - String feedType; - - // if the user did not specify any registry to look for the components, - // we cannot guess for him - will return an empty feed - if ((registries == null) || (registries.length == 0)) { - components = new ArrayList(); - } else { - components = manager.getProducts(registries); - } - - feedType = request.getParameter("feed-type"); - if (feedType == null) { - feedType = "rss-2.0"; - } - - response.setContentType("text/xml"); - - out.println(""); - - if (feedType.equals("rss-2.0")) { - buildRss(components, out); - } - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - e.printStackTrace(out); - } - - out.close(); - } - - private void buildRss(List components, PrintWriter out) throws IOException { - out.println(""); - out.println(" "); - - out.println(" <![CDATA[NetBeans Installer Components Feed]]>"); - out.println(" http://localhost/"); - out.println(" "); - - for (Product component: components) { - out.println(" "); - out.println(" " + component.getUid() + "_" + component.getVersion() + ""); - out.println(" <![CDATA[" + component.getDisplayName() + "]]>"); - out.println(" http://localhost/"); - out.println(" "); - out.println(" " + StringUtils.httpFormat(component.getBuildDate()) + ""); - out.println(" "); - } - - out.println(" "); - out.println(""); - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetEngine.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetEngine.java deleted file mode 100644 index 12e7ffde3c34..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetEngine.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Date; -import javax.ejb.EJB; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.utils.StreamUtils; -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class GetEngine extends HttpServlet { - @EJB - private Manager manager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - try { - File engine = manager.getEngine(); - - response.setContentType("application/java-archive"); - - response.setHeader("Content-Disposition", - "attachment; filename=nbi-engine.jar"); - response.setHeader("Content-Length", - Long.toString(engine.length())); - response.setHeader("Last-Modified", - StringUtils.httpFormat(new Date(engine.lastModified()))); - - final InputStream input = new FileInputStream(engine); - final OutputStream output = response.getOutputStream(); - - StreamUtils.transferData(input, output); - - input.close(); - output.close(); - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - e.printStackTrace(response.getWriter()); - } - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetFile.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetFile.java deleted file mode 100644 index 85ed5825b246..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetFile.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; -import org.netbeans.installer.utils.StringUtils; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class GetFile extends HttpServlet { - @EJB - private Manager manager; - - @Override - protected void doGet( - final HttpServletRequest request, - final HttpServletResponse response) throws ServletException, IOException { - try { - final String registry = request.getParameter("registry"); - final String path = request.getParameter("file"); - - final File file = manager.getFile(registry, path); - final String filename = file.getName(); - - final OutputStream output = response.getOutputStream(); - - response.setContentType( - "application/octet-stream"); - response.setHeader( - "Content-Disposition", - "attachment; filename=" + filename); - response.setHeader( - "Last-Modified", - StringUtils.httpFormat(new Date(file.lastModified()))); - response.setHeader( - "Accept-Ranges", - "bytes"); - - try { - Utils.transfer(request, response, output, file); - } finally { - output.close(); - } - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - e.printStackTrace(); - e.printStackTrace(response.getWriter()); - } - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetRegistry.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetRegistry.java deleted file mode 100644 index a25ce21d40d6..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/GetRegistry.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import javax.ejb.EJB; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class GetRegistry extends HttpServlet { - @EJB - private Manager registryManager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - try { - response.setContentType("text/xml"); - - String registry = request.getParameter("registry"); - - response.getWriter().write(registryManager.getRegistry(registry)); - response.getWriter().close(); - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - e.printStackTrace(response.getWriter()); - } - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Install.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Install.java deleted file mode 100644 index 4fa3f1fb610d..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Install.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class Install extends HttpServlet { - @EJB - private Manager registryManager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - try { - String[] names = request.getParameterValues("registry"); - if ((names == null) || (names.length == 0)) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - response.getWriter().println("Please define a registry"); - - return; - } - - response.setContentType("application/x-java-jnlp-file"); - String codebase = - getServerUrl(request) + getServletContext().getContextPath(); - - response.getWriter().write(registryManager.getJnlp(names, codebase)); - response.getWriter().close(); - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - e.printStackTrace(response.getWriter()); - } - } - - private String getServerUrl(HttpServletRequest request) throws MalformedURLException { - URL url = new URL(request.getRequestURL().toString()); - String string = url.toString(); - - return string.substring(0, string.indexOf(url.getFile())); - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Registries.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Registries.java deleted file mode 100644 index c93980521e07..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Registries.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.List; -import javax.ejb.EJB; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.infra.server.ejb.Manager; -import org.netbeans.installer.infra.server.ejb.ManagerException; - -/** - * - * @author Kirill Sorokin - * @version - */ -public class Registries extends HttpServlet { - @EJB - private Manager manager; - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setContentType("text/html; encoding=UTF-8"); - - PrintWriter out = response.getWriter(); - - try { - - List registries = manager.getRegistries(); - - - out.println(""); - out.println(""); - out.println(" "); - out.println(" "); - out.println(" Registries"); - out.println(" "); - out.println(" "); - out.println(" "); - out.println(" "); - - out.println("

"); - out.println(" Please select the registries that you would like to work with. The either click Install to immediately launch the installer, or Next to select the components and create a bundle."); - out.println("

"); - - out.println("
"); - for (String registry: registries) { - out.println(" " + registry + "
"); - } - out.println("

"); - out.println("   "); - out.println(" "); - out.println("
"); - - - out.println(" "); - out.println(""); - } catch (ManagerException e) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - e.printStackTrace(response.getWriter()); - } - - out.close(); - } -} diff --git a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Utils.java b/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Utils.java deleted file mode 100644 index e668058e2e5e..000000000000 --- a/nbi/infra/server/modules/war-client/src/java/org/netbeans/installer/infra/server/client/servlets/Utils.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.server.client.servlets; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.RandomAccessFile; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.netbeans.installer.utils.StreamUtils; - -public final class Utils { - public static void transfer( - HttpServletRequest request, - HttpServletResponse response, - OutputStream output, - File file) throws IOException { - RandomAccessFile input = null; - try { - input = new RandomAccessFile(file, "r"); - - final String range = request.getHeader("Range"); - if (range == null) { - response.setStatus(HttpServletResponse.SC_OK); - - input.seek(0); - - response.setHeader( - "Content-Length", - Long.toString(file.length())); - - StreamUtils.transferData(input, output); - } else { - Matcher matcher = Pattern.compile("^bytes=([0-9]*)-([0-9]*)$").matcher(range); - - if (!matcher.find()) { - response.setStatus(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return; - } else { - long start = -1; - long finish = -1; - - if (!matcher.group(1).equals("")) { - start = Long.parseLong(matcher.group(1)); - } - - if (!matcher.group(2).equals("")) { - finish = Long.parseLong(matcher.group(2)); - } - - if ((start != -1) && - (finish != -1) && - ((start > finish) || (finish > file.length()))) { - response.setStatus(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return; - } - - response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); - - if (start == -1) { - start = file.length() - finish; - finish = -1; - } - - input.seek(start); - - long length = (finish == -1 ? file.length() - start : finish - start) + 1; - - response.setHeader("Content-Length", Long.toString(length)); - response.setHeader("Content-Range", "bytes " + start + "-" + (finish == -1 ? file.length() - 1 : finish) + "/" + file.length()); - - if (finish == -1) { - StreamUtils.transferData(input, output); - } else { - StreamUtils.transferData(input, output, finish - start + 1); - } - } - } - } catch (IOException e) { - response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - e.printStackTrace(); - e.printStackTrace(new PrintStream(output)); - } finally { - if (input != null) { - input.close(); - } - } - } - -} diff --git a/nbi/infra/server/modules/war-client/web/WEB-INF/sun-web.xml b/nbi/infra/server/modules/war-client/web/WEB-INF/sun-web.xml deleted file mode 100644 index 46d963bc4eb5..000000000000 --- a/nbi/infra/server/modules/war-client/web/WEB-INF/sun-web.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - /nbi - - - - Enable debug info compilation in the generated servlet class - - - Maintain a one-to-one correspondence between static content and the generated servlet class' java code - - - diff --git a/nbi/infra/server/modules/war-client/web/WEB-INF/web.xml b/nbi/infra/server/modules/war-client/web/WEB-INF/web.xml deleted file mode 100644 index 4e5b4a970cc6..000000000000 --- a/nbi/infra/server/modules/war-client/web/WEB-INF/web.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - get-registry - org.netbeans.installer.infra.server.client.servlets.GetRegistry - - - get-file - org.netbeans.installer.infra.server.client.servlets.GetFile - - - nbi-engine.jar - org.netbeans.installer.infra.server.client.servlets.GetEngine - - - install - org.netbeans.installer.infra.server.client.servlets.Install - - - registries - org.netbeans.installer.infra.server.client.servlets.Registries - - - create-bundle - org.netbeans.installer.infra.server.client.servlets.CreateBundle - - - feed - org.netbeans.installer.infra.server.client.servlets.Feed - - - Components - org.netbeans.installer.infra.server.client.servlets.Components - - - Components2 - org.netbeans.installer.infra.server.client.servlets.Components2 - - - get-registry - /get-registry - - - get-file - /get-file - - - nbi-engine.jar - /nbi-engine.jar - - - install - /install - - - registries - /registries - - - create-bundle - /create-bundle - - - feed - /feed - - - Components - /js/components.js - - - Components2 - /download-2/js/components.js - - - - 30 - - - - registries - - diff --git a/nbi/infra/server/modules/war-client/web/img/default-icon.png b/nbi/infra/server/modules/war-client/web/img/default-icon.png deleted file mode 100644 index dcc540472144..000000000000 Binary files a/nbi/infra/server/modules/war-client/web/img/default-icon.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-client/web/img/default-icon.svg b/nbi/infra/server/modules/war-client/web/img/default-icon.svg deleted file mode 100644 index 6fd722d72b11..000000000000 --- a/nbi/infra/server/modules/war-client/web/img/default-icon.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - diff --git a/nbi/infra/server/modules/war-client/web/img/empty.gif b/nbi/infra/server/modules/war-client/web/img/empty.gif deleted file mode 100644 index 6e289cecc51b..000000000000 Binary files a/nbi/infra/server/modules/war-client/web/img/empty.gif and /dev/null differ diff --git a/nbi/infra/server/modules/war-client/web/img/tree-handle-closed.png b/nbi/infra/server/modules/war-client/web/img/tree-handle-closed.png deleted file mode 100644 index 1e9cda503e46..000000000000 Binary files a/nbi/infra/server/modules/war-client/web/img/tree-handle-closed.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-client/web/img/tree-handle-empty.png b/nbi/infra/server/modules/war-client/web/img/tree-handle-empty.png deleted file mode 100644 index a338a90a62f2..000000000000 Binary files a/nbi/infra/server/modules/war-client/web/img/tree-handle-empty.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-client/web/img/tree-handle-open.png b/nbi/infra/server/modules/war-client/web/img/tree-handle-open.png deleted file mode 100644 index 3760f7c8c65f..000000000000 Binary files a/nbi/infra/server/modules/war-client/web/img/tree-handle-open.png and /dev/null differ diff --git a/nbi/infra/server/modules/war-client/web/js/main.js b/nbi/infra/server/modules/war-client/web/js/main.js deleted file mode 100644 index d5b58918dc9d..000000000000 --- a/nbi/infra/server/modules/war-client/web/js/main.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function install_now() { - document.forms.Form.action = "install"; - document.forms.Form.submit(); -} - -function create_bundle() { - document.forms.Form.action = "create-bundle"; - document.forms.Form.submit(); -} - -function update_target_platform() { - var platformsSelect = document.getElementById("platforms-select"); - - var platform = platformsSelect.options[platformsSelect.selectedIndex].value; - - window.location = "create-bundle?platform=" + platform + "&" + document.forms.Form.registries.value; -} - -function _expand(id) { - var row = document.getElementById(id); - - if (row.style.display == "none") { - row.style.display = "table-row"; - } else { - row.style.display = "none"; - } -} diff --git a/nbi/infra/server/nbproject/ant-deploy.xml b/nbi/infra/server/nbproject/ant-deploy.xml deleted file mode 100644 index e86b4a518748..000000000000 --- a/nbi/infra/server/nbproject/ant-deploy.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${lefty}?xml version="1.0" encoding="UTF-8"?${righty} -${lefty}!DOCTYPE resources PUBLIC - "-//Sun Microsystems Inc.//DTD Application Server 9.0 Resource Definitions //EN" - "${sjsas.root}/lib/dtds/sun-resources_1_2.dtd"${righty} -${lefty}resources${righty} -${lefty}/resources${righty} - - - - - - - -]]> - - - - -]]> - - - - - - - ]]> - - - - - - - - ]]> - ]]> - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/nbproject/build-impl.xml b/nbi/infra/server/nbproject/build-impl.xml deleted file mode 100644 index 4dcb077689ed..000000000000 --- a/nbi/infra/server/nbproject/build-impl.xml +++ /dev/null @@ -1,365 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set build.dir - Must set build.generated.dir - Must set dist.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. - - - Launching ${browse.url} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/server/nbproject/genfiles.properties b/nbi/infra/server/nbproject/genfiles.properties deleted file mode 100644 index 047de5dc17ab..000000000000 --- a/nbi/infra/server/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=89687d60 -build.xml.script.CRC32=5e8af181 -build.xml.stylesheet.CRC32=978fa8b5 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=ecb3731e -nbproject/build-impl.xml.script.CRC32=e4fd67b2 -nbproject/build-impl.xml.stylesheet.CRC32=ffbde67e diff --git a/nbi/infra/server/nbproject/project.properties b/nbi/infra/server/nbproject/project.properties deleted file mode 100644 index 9833c177f69d..000000000000 --- a/nbi/infra/server/nbproject/project.properties +++ /dev/null @@ -1,54 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.archive.dir=${build.dir}/jar -build.classes.dir=${build.archive.dir} -build.classes.excludes=**/*.java,**/*.form,**/.nbattrs -build.dir=build -build.generated.dir=${build.dir}/generated -client.module.uri=war-client.war -client.urlPart= -debug.classpath=${javac.classpath}:${build.classes.dir}:${jar.content.additional}:${run.classpath} -display.browser=true -dist.dir=dist -dist.jar=${dist.dir}/nbi-server.ear -j2ee.appclient.mainclass.args=-client ${dist.jar} ${j2ee.appclient.tool.args} -j2ee.platform=1.5 -j2ee.server.type=J2EE -jar.compress=false -jar.content.additional=\ - ${reference.NBI_Server_-_EJB.dist-ear};\ - ${reference.NBI_Server_-_Admin.dist-ear};\ - ${reference.NBI_Server_-_Client.dist-ear} -jar.name=NBI Server.ear -javac.debug=true -javac.deprecation=false -javac.source=${default.javac.source} -javac.target=${default.javac.target} -meta.inf=src/conf -no.dependencies=false -platform.active=default_platform -project.NBI_Server_-_Admin=modules/war-admin -project.NBI_Server_-_Client=modules/war-client -project.NBI_Server_-_EJB=modules/ejb -reference.NBI_Server_-_Admin.dist-ear=${project.NBI_Server_-_Admin}/dist/war-admin.war -reference.NBI_Server_-_Client.dist-ear=${project.NBI_Server_-_Client}/dist/war-client.war -reference.NBI_Server_-_EJB.dist-ear=${project.NBI_Server_-_EJB}/dist/ejb.jar -resource.dir=setup -source.root=. diff --git a/nbi/infra/server/nbproject/project.xml b/nbi/infra/server/nbproject/project.xml deleted file mode 100644 index a52c31e3a189..000000000000 --- a/nbi/infra/server/nbproject/project.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - org.netbeans.modules.j2ee.earproject - - - NBI Server - 1.6 - - - - ${reference.NBI_Server_-_EJB.dist-ear} - / - - - ${reference.NBI_Server_-_Admin.dist-ear} - / - - - ${reference.NBI_Server_-_Client.dist-ear} - / - - - - - - NBI_Server_-_Admin - j2ee_ear_archive - - dist-ear - clean-ear - dist-ear - - - NBI_Server_-_Client - j2ee_ear_archive - - dist-ear - clean-ear - dist-ear - - - NBI_Server_-_EJB - j2ee_ear_archive - - dist-ear - clean-ear - dist-ear - - - - diff --git a/nbi/infra/server/src/conf/MANIFEST.MF b/nbi/infra/server/src/conf/MANIFEST.MF deleted file mode 100644 index 59499bce4a2b..000000000000 --- a/nbi/infra/server/src/conf/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/nbi/infra/server/src/conf/application.xml b/nbi/infra/server/src/conf/application.xml deleted file mode 100644 index 5679a80f56cc..000000000000 --- a/nbi/infra/server/src/conf/application.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - server - - - war-admin.war - /nbi/dev/admin - - - - - war-client.war - /nbi/dev - - - - ejb.jar - - diff --git a/nbi/infra/server/src/conf/sun-application.xml b/nbi/infra/server/src/conf/sun-application.xml deleted file mode 100644 index 68b73c87d0c7..000000000000 --- a/nbi/infra/server/src/conf/sun-application.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - diff --git a/nbi/infra/utils/basic-style-checker/build.xml b/nbi/infra/utils/basic-style-checker/build.xml deleted file mode 100644 index 9fa80977fcc0..000000000000 --- a/nbi/infra/utils/basic-style-checker/build.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - Builds, tests, and runs the project NBI Utils: Basic Style Checker. - - - diff --git a/nbi/infra/utils/basic-style-checker/check.xml b/nbi/infra/utils/basic-style-checker/check.xml deleted file mode 100644 index 32098062e674..000000000000 --- a/nbi/infra/utils/basic-style-checker/check.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/basic-style-checker/manifest.mf b/nbi/infra/utils/basic-style-checker/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/basic-style-checker/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/basic-style-checker/nbproject/build-impl.xml b/nbi/infra/utils/basic-style-checker/nbproject/build-impl.xml deleted file mode 100644 index edbc37673edf..000000000000 --- a/nbi/infra/utils/basic-style-checker/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/basic-style-checker/nbproject/genfiles.properties b/nbi/infra/utils/basic-style-checker/nbproject/genfiles.properties deleted file mode 100644 index 85e3d26a8d4e..000000000000 --- a/nbi/infra/utils/basic-style-checker/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=62a1bdde -build.xml.script.CRC32=fded62d6 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=5c0531c6 -nbproject/build-impl.xml.script.CRC32=28e17cff -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/basic-style-checker/nbproject/project.properties b/nbi/infra/utils/basic-style-checker/nbproject/project.properties deleted file mode 100644 index 5f7d8d25d691..000000000000 --- a/nbi/infra/utils/basic-style-checker/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/NBI_Utils__Basic_Style_Checker.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${ant.core.lib} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=basicstylechecker.BasicStyleCheckerEngine -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/basic-style-checker/nbproject/project.xml b/nbi/infra/utils/basic-style-checker/nbproject/project.xml deleted file mode 100644 index 4151fb4c611f..000000000000 --- a/nbi/infra/utils/basic-style-checker/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - NBI Utils: Basic Style Checker - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/BasicStyleCheckerEngine.java b/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/BasicStyleCheckerEngine.java deleted file mode 100644 index 1fe9c085f809..000000000000 --- a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/BasicStyleCheckerEngine.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.style; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.infra.utils.style.checkers.Checker; -import org.netbeans.installer.infra.utils.style.checkers.LineLengthChecker; -import org.netbeans.installer.infra.utils.style.checkers.UnescapedStringChecker; - -/** - * - * @author ks152834 - */ -public class BasicStyleCheckerEngine { - public static void main(String[] args) throws IOException { - BasicStyleCheckerEngine engine = new BasicStyleCheckerEngine(); - - for (String arg: args) { - engine.check(new File(arg)); - } - } - - private List checkers; - - public BasicStyleCheckerEngine() { - checkers = new LinkedList(); - - checkers.add(new LineLengthChecker()); - checkers.add(new UnescapedStringChecker()); - } - - public void check( - final File file) throws IOException { - final BufferedReader reader = new BufferedReader(new FileReader(file)); - - String line = null; - for (int i = 1; (line = reader.readLine()) != null; i++) { - String error = ""; - - for (Checker checker: checkers) { - if (checker.accept(file)) { - final String message = checker.check(line); - - if (message != null) { - error += " " + message + "\n"; - } - } - } - - if (!error.equals("")) { - System.out.println(" Line " + i + ":"); - System.out.println(error); - } - } - - reader.close(); - } -} diff --git a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/ant/BasicStyleCheckerTask.java b/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/ant/BasicStyleCheckerTask.java deleted file mode 100644 index e5b487ea8cfb..000000000000 --- a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/ant/BasicStyleCheckerTask.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.style.ant; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.FileSet; -import org.netbeans.installer.infra.utils.style.BasicStyleCheckerEngine; - -/** - * - * @author ks152834 - */ -public class BasicStyleCheckerTask extends Task { - private List filesets; - - public BasicStyleCheckerTask() { - this.filesets = new LinkedList(); - } - - public void addFileSet(FileSet fileset) { - filesets.add(fileset); - } - - @Override - public void execute() throws BuildException { - BasicStyleCheckerEngine engine = new BasicStyleCheckerEngine(); - - try { - for (FileSet fileset: filesets) { - final DirectoryScanner scanner = - fileset.getDirectoryScanner(getProject()); - - for (String filename: scanner.getIncludedFiles()) { - final File file = - new File(fileset.getDir(getProject()), filename); - - System.out.println(file.getCanonicalPath()); - engine.check(file); - } - } - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/Checker.java b/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/Checker.java deleted file mode 100644 index 57e2a4bcbf02..000000000000 --- a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/Checker.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.style.checkers; - -import java.io.File; - -/** - * - * @author ks152834 - */ -public interface Checker { - boolean accept(final File file); - - String check(final String line); -} diff --git a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/LineLengthChecker.java b/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/LineLengthChecker.java deleted file mode 100644 index a3eec93aab1f..000000000000 --- a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/LineLengthChecker.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.style.checkers; - -import java.io.File; - -/** - * - * @author ks152834 - */ -public class LineLengthChecker implements Checker { - public boolean accept(final File file) { - return file.getName().endsWith(".java"); - } - - public String check(final String line) { - if (line.length() > 85) { - return "Line length exceeeds 85 characters."; - } - - return null; - } -} diff --git a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/UnescapedStringChecker.java b/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/UnescapedStringChecker.java deleted file mode 100644 index d9d047f35870..000000000000 --- a/nbi/infra/utils/basic-style-checker/src/org/netbeans/installer/infra/utils/style/checkers/UnescapedStringChecker.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.style.checkers; - -import java.io.File; - -/** - * - * @author ks152834 - */ -public class UnescapedStringChecker implements Checker { - public boolean accept(final File file) { - return file.getName().endsWith(".java"); // NOI18N - } - - public String check(final String line) { - if ((line.indexOf("\"") > -1) && // NOI18N - (line.indexOf("// NOI18N") == -1)) { // NOI18N - return "Unescaped string constant."; // NOI18N - } - - return null; - } -} diff --git a/nbi/infra/utils/comment-correcter/build.xml b/nbi/infra/utils/comment-correcter/build.xml deleted file mode 100644 index c6d5511a2cdd..000000000000 --- a/nbi/infra/utils/comment-correcter/build.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - Builds, tests, and runs the project Comment Correcter. - - - diff --git a/nbi/infra/utils/comment-correcter/cddl.txt b/nbi/infra/utils/comment-correcter/cddl.txt deleted file mode 100644 index c51a8836c9a8..000000000000 --- a/nbi/infra/utils/comment-correcter/cddl.txt +++ /dev/null @@ -1,17 +0,0 @@ -The contents of this file are subject to the terms of the Common Development -and Distribution License (the License). You may not use this file except in -compliance with the License. - -You can obtain a copy of the License at http://www.netbeans.org/cddl.html -or http://www.netbeans.org/cddl.txt. - -When distributing Covered Code, include this CDDL Header Notice in each file -and include the License file at http://www.netbeans.org/cddl.txt. -If applicable, add the following below the CDDL Header, with the fields -enclosed by brackets [] replaced by your own identifying information: - - "Portions Copyrighted [year] [name of copyright owner]" - -The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun -Microsystems, Inc. All Rights Reserved. diff --git a/nbi/infra/utils/comment-correcter/correct.xml b/nbi/infra/utils/comment-correcter/correct.xml deleted file mode 100644 index 850e72ee5126..000000000000 --- a/nbi/infra/utils/comment-correcter/correct.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/comment-correcter/manifest.mf b/nbi/infra/utils/comment-correcter/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/comment-correcter/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/comment-correcter/nbproject/build-impl.xml b/nbi/infra/utils/comment-correcter/nbproject/build-impl.xml deleted file mode 100644 index 9a0c9c33ff53..000000000000 --- a/nbi/infra/utils/comment-correcter/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/comment-correcter/nbproject/genfiles.properties b/nbi/infra/utils/comment-correcter/nbproject/genfiles.properties deleted file mode 100644 index 4412e49ee329..000000000000 --- a/nbi/infra/utils/comment-correcter/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=0a667d1f -build.xml.script.CRC32=e96ce7fd -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=e87620a8 -nbproject/build-impl.xml.script.CRC32=6f75975a -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/comment-correcter/nbproject/project.properties b/nbi/infra/utils/comment-correcter/nbproject/project.properties deleted file mode 100644 index dcf3bf5be1ef..000000000000 --- a/nbi/infra/utils/comment-correcter/nbproject/project.properties +++ /dev/null @@ -1,88 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -application.title=Comment Correcter -application.vendor=Kirill Sorokin -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/comment_correcter.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -includes=** -jar.compress=false -javac.classpath=\ - ${ant.core.lib} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.utils.comment.CommentCorrecter -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/comment-correcter/nbproject/project.xml b/nbi/infra/utils/comment-correcter/nbproject/project.xml deleted file mode 100644 index 495dbd3605ad..000000000000 --- a/nbi/infra/utils/comment-correcter/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - NBI Utils: Comment Correcter - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/CommentCorrecter.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/CommentCorrecter.java deleted file mode 100644 index 8a03abc2b3c6..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/CommentCorrecter.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.LinkedList; -import java.util.List; -import org.netbeans.installer.infra.utils.comment.handlers.FileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.HtmlFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.JspFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.MakefileFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.PropertiesFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.ShellFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.SourcesFileHandler; -import org.netbeans.installer.infra.utils.comment.handlers.XmlFileHandler; -import org.netbeans.installer.infra.utils.comment.utils.Utils; - -/** - * This is the main class for the initial comment correcting utility. - * - *

- * It contains the main method which allows calling the utility from - * the command line. - * - *

- * This class is a singleton. Programmatic clients are expected to call its - * {@link #getInstance()} method to obtain an instance of the class. After an - * instance of the class has been obtained it should be initialized with the desired - * initial comment text and line length. - * - *

- * Optionally the clients may want to insert additional file type handlers via the - * {@link #addHandler(FileHandler)} method. - * - *

- * After the class has been intialized, the client should call the - * {@link #updateFile(File)} method which would perform the comment update procedure - * on the given file (or recurse into the directory structure if the supplied file - * is a directory). - * - * @author Kirill Sorokin - */ -public final class CommentCorrecter { - ///////////////////////////////////////////////////////////////////////////////// - // Main - /** - * Allows the initial comment correcting utility to be called from the command - * line. - * - *

- * The method expects two command-line parameters to be passed in: path to the - * file for which the initial comment should be corrected (if the supplied path - * points to a directory, it will be traversed) and path to the file which - * contains the desired text of the initial comment. - * - *

- * An optional third parameter can also be supplied - desired line length for - * the intial comment. The default value for it is 85 characters. If the supplied - * parameter is invalid - the default value will be used. - * - * @param args Command-line parameters. - * @throws java.io.IOException if an I/O errors occurs during the update - * procedure. - */ - public static void main(String[] args) throws IOException { - if (args.length < 2) { // NOMAGI - System.out.println( - "Wrong number of input parameters."); // NOI18N - System.out.println( - "Usage:"); // NOI18N - System.out.println( - " java -jar comment-correcter.jar " + // NOI18N - " [length]"); // NOI18N - System.out.println( - " * is a path to the directory/file on"); // NOI18N - System.out.println( - " which ot perform the correction"); // NOI18N - System.out.println( - " * is a path to the file " + // NOI18N - "which contains the"); // NOI18N - System.out.println( - " * text of the comment"); // NOI18N - System.out.println( - " * [length] is the desired line length " + // NOI18N - "for the text"); // NOI18N - System.exit(0); - } - - final File file = new File(args[0]); // NOMAGI - final File text = new File(args[1]); // NOMAGI - - if (args.length > 2) { // NOMAGI - getInstance().setLineLength(Integer.parseInt(args[2])); // NOMAGI - } else { - getInstance().setLineLength(DEFAULT_LINE_LENGTH); - } - - getInstance().setText(Utils.readFile(text)); - getInstance().updateFile(file); - } - - ///////////////////////////////////////////////////////////////////////////////// - // Static - /** - * The only instance of the {@link CommentCorrecter} class. - */ - private static CommentCorrecter instance; - - /** - * Returns the only instance of the class. - * - * @return The instance of the {@link CommentCorrecter} class. - */ - public static synchronized CommentCorrecter getInstance() { - if (instance == null) { - instance = new CommentCorrecter(); - - instance.addHandler(new SourcesFileHandler()); - instance.addHandler(new XmlFileHandler()); - instance.addHandler(new PropertiesFileHandler()); - instance.addHandler(new ShellFileHandler()); - instance.addHandler(new MakefileFileHandler()); - instance.addHandler(new HtmlFileHandler()); - instance.addHandler(new JspFileHandler()); - } - - return instance; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * List of the registered file type handlers. One of these will be picked to - * perform the actual update procedure. - */ - private List handlers; - - /** - * The desired initial comment line length. Defaults to 85 characters. - */ - private int lineLength; - - /** - * The desired text of the initial comment. - */ - private String text; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * Constructs a new instance of {@link CommentCorrecter}. The functionality of - * the constructor is limited to intializing the instance fields to default - * values. - */ - private CommentCorrecter() { - handlers = new LinkedList(); - lineLength = DEFAULT_LINE_LENGTH; - } - - // public /////////////////////////////////////////////////////////////////////// - /** - * Registers a new file type handler. - * - * @param handler A file type handler instance which should be registered in - * the comment corrceting utility. - * @throws java.lang.IllegalArgumentException if the parameter is null. - */ - public void addHandler(final FileHandler handler) { - if (handler == null) { - throw new IllegalArgumentException( - "The 'handler' parameter cannot be null."); // NOI18N - } - handlers.add(handler); - } - - /** - * Sets the desired line length for the initial comment. - * - * @param lineLength The desired line length. - * @throws java.lang.IllegalArgumentException if the parameter is not a positive - * integer. - */ - public void setLineLength(final int lineLength) { - if (lineLength <= 0) { - throw new IllegalArgumentException( - "The 'lineLength' parameter must be positive."); // NOI18N - } - this.lineLength = lineLength; - } - - /** - * Sets the desired text of the initial comment. - * - * @param text The desired text of the initial comment. - * @throws java.lang.IllegalArgumentException if the parameter is null. - */ - public void setText(final String text) { - if (text == null) { - throw new IllegalArgumentException( - "The 'text' parameter cannot be null."); // NOI18N - } - this.text = text; - } - - /** - * Performs the initial comment update operation on the given file. If the file - * is a directory, its children will be parsed instead. - * - *

- * This method is CLI-interactive - for each parsed file a query will be - * displayed requiring the user to tell the utility what to do with the file. - * The available options are: insert the new initial comment, update the current - * initial comment (if it exists), skip the file. - * - * @param file The file for which the comment update procedure should be - * performed. - * @throws java.io.IOException if an I/O error occurs of there are problems - * with validating the supplied file. - * @throws java.lang.IllegalArgumentException if the parameter is null. - * @throws java.lang.IllegalStateException if the class has not been - * initialized, i.e. the text property is null. - */ - public void updateFile(final File file) throws IOException { - // basic validation - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - if (text == null) { - throw new IllegalStateException( - "The 'text' property has not been initialized."); // NOI18N - } - - // file validation - if (!file.exists()) { - throw new IOException( - "The given file '" + file + // NOI18N - "' does not exist."); // NOI18N - } - - if (file.isDirectory()) { - final File[] children = file.listFiles(); - - if (children != null) { - for (File child: children) { - updateFile(child); - } - } - } else { - System.out.println(file.getAbsolutePath()); - - final FileHandler handler = getHandler(file); - if (handler != null) { - handler.load(file); - - final String comment = handler.getCurrentComment(); - - System.out.println("current initial comment:"); // NOI18N - System.out.println(); - System.out.println( - comment != null ? comment : ""); // NOI18N - System.out.println(); - - System.out.print( - "Insert (I), Update (U), Skip? [Skip]: "); // NOI18N - - final String input = new BufferedReader( - new InputStreamReader(System.in)).readLine(); - - if (input.startsWith("I") || // NOI18N - input.startsWith("i")) { // NOI18N - handler.insertComment(text, lineLength); - handler.save(file); - } - - if (input.startsWith("U") || // NOI18N - input.startsWith("u")) { // NOI18N - handler.updateComment(text, lineLength); - handler.save(file); - } - - System.out.println(); - } else { - System.out.println( - " ...not recognized by any handler - skipping"); // NOI18N - System.out.println(); - } - } - } - - /** - * Finds the appropriate file handler for the given file. This method iterates - * over the list of registered handlers and returns the first which agrees to - * work with the file. - * - * @param file The file for which to find a handler. - * @return An instance {@link FileHandler} which is capable of working with the - * given file, or null if such a handler was not found. - * @throws java.lang.IllegalArgumentException if the parameter is null. - */ - public FileHandler getHandler(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - for (FileHandler handler: handlers) { - if (handler.accept(file)) { - return handler; - } - } - - return null; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The default line length for the initial comment. - */ - public static final int DEFAULT_LINE_LENGTH = 85; -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/ant/CommentCorrecterTask.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/ant/CommentCorrecterTask.java deleted file mode 100644 index 53547263afd7..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/ant/CommentCorrecterTask.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.ant; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.FileSet; -import org.netbeans.installer.infra.utils.comment.CommentCorrecter; -import org.netbeans.installer.infra.utils.comment.handlers.FileHandler; -import org.netbeans.installer.infra.utils.comment.utils.Utils; - -/** - * This is the apache ant interface of the initial comment correcting utility. - * - *

- * The ant task defined in this class supports two arguments: text - - * its value should be the path to the file which contains the desired intiial - * comment text; 'lineLength' - a positive integer defining the requried line length - * for the comment (optional). - * - *

- * The task supports the nested <fileset> elements which should be - * used to define the set of files for which the correction should take place. - * - * @author Kirill Sorokin - */ -public final class CommentCorrecterTask extends Task { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The file with the desired initial comment text. - */ - private File text; - - /** - * The desired line length for the comment. - */ - private int lineLength; - - /** - * List of FileSet which define the set of files for which the - * comment correction should take place. - */ - private List filesets; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * The default and only constructor for the ant task. It only sets the defaults - * values for the class fields. - */ - public CommentCorrecterTask() { - lineLength = CommentCorrecter.DEFAULT_LINE_LENGTH; - filesets = new LinkedList(); - } - - // setters ////////////////////////////////////////////////////////////////////// - /** - * Setter for the text property. - * - * @param path New value for the text property. - */ - public void setText(String path) { - text = new File(path).getAbsoluteFile(); - } - - /** - * Setter for the lineLength property. - * - * @param string New value for the text property as a string - it - * will be converted to an integer. - */ - public void setLineLength(String string) { - try { - lineLength = Integer.parseInt(string); - } catch (NumberFormatException e) { - log(e.getMessage()); - } - } - - /** - * Adds a new FileSet to the list. The list of file sets will be - * used to perform the comment correction. - * - * @param fileset The file set to add to the list. - */ - public void addFileSet(FileSet fileset) { - filesets.add(fileset); - } - - /** - * Executes the ant task, performing initial comment correction on the set of - * files defined in filesets. Overrides the execute() - * method in the Task class. - * - * @throws org.apache.tools.ant.BuildException if parameters validation fails or - * an I/O error occurs - */ - @Override - public void execute() throws BuildException { - if (text == null) { - throw new BuildException( - "The 'text' attribute is required."); // NOI18N - } - - try { - final String comment = Utils.readFile(text); - - for (FileSet fileset: filesets) { - final DirectoryScanner scanner = - fileset.getDirectoryScanner(getProject()); - - for (String filename: scanner.getIncludedFiles()) { - final File file = - new File(fileset.getDir(getProject()), filename); - - log(file.getAbsolutePath()); - - final FileHandler handler = - CommentCorrecter.getInstance().getHandler(file); - if (handler != null) { - handler.load(file); - - final String current = handler.getCurrentComment(); - if (current == null) { - log(" ...inserting " + // NOI18N - "the initial comment"); // NOI18N - handler.insertComment(comment, lineLength); - } else { - final String correct = - handler.getCorrectComment(comment, lineLength); - if (current.equals(correct)) { - log(" ...skipping -- " + // NOI18N - "the comment is up to date"); // NOI18N - } else { - log(" ...updating " + // NOI18N - "the initial comment"); // NOI18N - handler.updateComment(comment, lineLength); - } - } - - handler.save(file); - } else { - log(" ...skipping -- " + // NOI18N - "not recognized by any handler"); // NOI18N - } - } - } - } catch (IOException e) { - throw new BuildException(e); - } - } -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/BlockFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/BlockFileHandler.java deleted file mode 100644 index 38f166f6a3bb..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/BlockFileHandler.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import org.netbeans.installer.infra.utils.comment.utils.Utils; -import java.io.File; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * The base class for ahndling file types in which block comments are used, such as - * java source files or xml documents. - * - * @author Kirill Sorokin - */ -public abstract class BlockFileHandler implements FileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The regular expression pattern which matches the initial comment. - */ - protected final Pattern commentPattern; - - /** - * The comment opening string. - */ - protected final String commentStart; - - /** - * The prefix which should be used for each line in the comment. If there should - * be no prefix - an empty line should be used. - */ - protected final String commentPrefix; - - /** - * The comment closing string. - */ - protected final String commentEnd; - - /** - * The cached file contents. - */ - protected String contents; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * The constructor which should be called by the extending classes. It merely - * sets the class fields, performnig some basic validation. - * - * @param commentPattern The regular expression pattern which matches the - * initial comment. - * @param commentStart The comment opening string. - * @param commentPrefix The prefix which should be used for each line in the - * comment. - * @param commentEnd The comment closing string. - * @throws java.lang.IllegalArgumentException if the parameters validation - * fails. - */ - protected BlockFileHandler( - final Pattern commentPattern, - final String commentStart, - final String commentPrefix, - final String commentEnd) { - if (commentPattern == null) { - throw new IllegalArgumentException( - "The 'commentPattern' parameter cannot be null."); // NOI18N - } - this.commentPattern = commentPattern; - - if (commentStart == null) { - throw new IllegalArgumentException( - "The 'commentStart' parameter cannot be null."); // NOI18N - } - this.commentStart = commentStart; - - if (commentPrefix == null) { - throw new IllegalArgumentException( - "The 'commentPrefix' parameter cannot be null."); // NOI18N - } - this.commentPrefix = commentPrefix; - - if (commentEnd == null) { - throw new IllegalArgumentException( - "The 'commentEnd' parameter cannot be null."); // NOI18N - } - this.commentEnd = commentEnd; - } - - // public /////////////////////////////////////////////////////////////////////// - /** - * {@inheritDoc} - */ - public final void load(final File file) throws IOException { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - contents = Utils.readFile(file); - } - - /** - * {@inheritDoc} - */ - public final void save(final File file) throws IOException { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - Utils.writeFile(file, contents); - } - - /** - * {@inheritDoc} - */ - public final String getCurrentComment() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final Matcher matcher = commentPattern.matcher(contents); - - if (matcher.find()) { - return matcher.group(1); - } else { - return null; - } - } - - /** - * {@inheritDoc} - */ - public final String getCorrectComment(final String text, final int lineLength) { - return commentStart + - Utils.reformat(text, commentPrefix, lineLength) + - commentEnd + Utils.NL; - } - - /** - * {@inheritDoc} - */ - public final void insertComment(final String text, final int lineLength) { - if (text == null) { - throw new IllegalArgumentException( - "The 'text' parameter cannot be null."); // NOI18N - } - if (lineLength <= 0) { - throw new IllegalArgumentException( - "The 'lineLength' parameter must be positive."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final String comment = getCorrectComment(text, lineLength); - final int position = getCommentPosition(); - - final String prefix = contents.substring(0, position); - final String suffix = contents.substring(position); - - contents = prefix + comment + suffix; - } - - /** - * {@inheritDoc} - */ - public final void updateComment(final String text, final int lineLength) { - if (text == null) { - throw new IllegalArgumentException( - "The 'text' parameter cannot be null."); // NOI18N - } - if (lineLength <= 0) { - throw new IllegalArgumentException( - "The 'lineLength' parameter must be positive."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final String currentComment = getCurrentComment(); - - if (currentComment == null) { - insertComment(text, lineLength); - return; - } - - final String correctComment = - getCorrectComment(text, lineLength); - - final String prefix = - contents.substring(0, contents.indexOf(currentComment)); - final String suffix = - contents.substring(prefix.length() + currentComment.length()); - - contents = prefix + correctComment + suffix; - } - - // protected //////////////////////////////////////////////////////////////////// - /** - * Calculates the proper initial comment position. This is used in the - * insertComment method to devise the position at which to insert - * the new comment. Extending classes may want to override this method to - * provide initial comment position that is correct for their file type (e.g. in - * xml documents the comment should appear only after the - * <?xml ... ?> tag. - * - * @return The proper position for the initial comment. - */ - protected int getCommentPosition() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - return 0; - } -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/FileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/FileHandler.java deleted file mode 100644 index 6c9476bdb8fe..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/FileHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import java.io.File; -import java.io.IOException; - -/** - * The interface that all file handlers, i.e. classes handling comment correction - * for concrete file types, should implement. - * - *

- * It requires the implementing classes to provide functionality of loading/saving a - * file, extracting the current initial comment, iserting a new one and updating - * (replacing) the current. - * - * @author Kirill Sorokin - */ -public interface FileHandler { - /** - * Checks whether the given ile can be processed by this file handler. - * - * @param file The file for which to run the compatibility check. - * @return true if the current file handler is capable of handling - * the file, false otherwise. - */ - boolean accept(final File file); - - /** - * Loads the file into file handler's cache. - * - * @param file The file to load. - * @throws java.io.IOException if an I/O error occurs. - * @throws java.lang.IllegalArgumentException if the parameter validation fails. - */ - void load(final File file) throws IOException; - - /** - * Saves the cached file contents to the given file on disk. - * - * @param file The file to which the cache should be saved. - * @throws java.io.IOException if an I/O error occurs. - * @throws java.lang.IllegalArgumentException if the parameter validation fails. - * @throws java.lang.IllegalStateException if the file contents cache - * is null. - */ - void save(final File file) throws IOException; - - /** - * Extracts the current initial comment from the cached file contents. - * - * @return Teh current initial comment or null if the initial - * comment does not exist. - * @throws java.lang.IllegalStateException if the file handler does not have - * anything loaded. - */ - String getCurrentComment(); - - /** - * Constructs the correct initial comment. - * - * @param text The text of the initial comment. - * @param lineLength The desired line length for the comment. - * @return The correct, formatted, initial comment for this type of file. - */ - String getCorrectComment(final String text, final int lineLength); - - /** - * Inserts the initial comment to the cached file contents. If an intiial - * comment already exists in the file it is prepended by the new one. - * - * @param text The text of the new initial comment. - * @param lineLength The desired line length for the comment. - * @throws java.lang.IllegalArgumentException if the parameters validation - * fails. - * @throws java.lang.IllegalStateException if the file handler does not have - * anything loaded. - */ - void insertComment(final String text, final int lineLength); - - /** - * Updates the current initial comment in the cached file contents. If there is - * no initia comment, then this method falls back to - * {@link #insertComment(String, int)}. - * - * @param text The text of the new initial comment. - * @param lineLength The desired line length for the comment. - * @throws java.lang.IllegalArgumentException if the parameters validation - * fails. - * @throws java.lang.IllegalStateException if the file handler does not have - * anything loaded. - */ - void updateComment(final String text, final int lineLength); -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/HtmlFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/HtmlFileHandler.java deleted file mode 100644 index e76c4d07908e..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/HtmlFileHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import org.netbeans.installer.infra.utils.comment.utils.Utils; -import java.io.File; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling HTML documents. - * - * @author Kirill Sorokin - */ -public class HtmlFileHandler extends BlockFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link HtmlFileHandler}. The constuctor - * simply falls back to the - * {@link BlockFileHandler#BlockFileHandler(Pattern, String, String, String)} - * passing in the parameters relevant to HTML files. - */ - public HtmlFileHandler() { - super(COMMENT_PATTERN, - COMMENT_START, - COMMENT_PREFIX, - COMMENT_END); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".html") || // NOI18N - file.getName().endsWith(".htm"); // NOI18N - } - - /** - * {@inheritDoc} - */ - @Override - public int getCommentPosition() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final Matcher matcher = COMMENT_POSITION_PATTERN.matcher(contents); - if (matcher.find()) { - return contents.indexOf(matcher.group(1)); - } else { - return 0; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - private static final Pattern COMMENT_POSITION_PATTERN = Pattern.compile( - "\\A\\s*(?:<\\?xml.*?\\?>)?\\s*]*>\\s*(.*)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The regular expression pattern which matches the initial comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "\\A\\s*(?:<\\?xml.*?\\?>)?\\s*" + // NOI18N - "]*>\\s*(\\s*\n)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The comment opening string. - */ - private static final String COMMENT_START = - "" + Utils.NL; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/JspFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/JspFileHandler.java deleted file mode 100644 index 7ee39a4bd480..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/JspFileHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import org.netbeans.installer.infra.utils.comment.utils.Utils; -import java.io.File; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling JSP documents. - * - * @author Kirill Sorokin - */ -public class JspFileHandler extends BlockFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link JspFileHandler}. The constuctor - * simply falls back to the - * {@link BlockFileHandler#BlockFileHandler(Pattern, String, String, String)} - * passing in the parameters relevant to JSP files. - */ - public JspFileHandler() { - super(COMMENT_PATTERN, - COMMENT_START, - COMMENT_PREFIX, - COMMENT_END); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".jsp") || // NOI18N - file.getName().endsWith(".jspx"); // NOI18N - } - - /** - * {@inheritDoc} - */ - @Override - public int getCommentPosition() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final Matcher matcher = COMMENT_POSITION_PATTERN.matcher(contents); - if (matcher.find()) { - return contents.indexOf(matcher.group(1)); - } else { - return 0; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - private static final Pattern COMMENT_POSITION_PATTERN = Pattern.compile( - "\\A\\s*(?:<\\?xml.*?\\?>)?\\s*(.*)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The regular expression pattern which matches the initial comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "\\A\\s*(?:<\\?xml.*?\\?>)?\\s*(<%--.*?--%>\\s*\\n)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The comment opening string. - */ - private static final String COMMENT_START = - "<%--" + Utils.NL; // NOI18N - - /** - * The prefix which should be used for each line in the comment. - */ - private static final String COMMENT_PREFIX = - " "; // NOI18N - - /** - * The comment closing string. - */ - private static final String COMMENT_END = - "--%>" + Utils.NL; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/LineFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/LineFileHandler.java deleted file mode 100644 index b3dc8414b9ab..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/LineFileHandler.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import org.netbeans.installer.infra.utils.comment.utils.Utils; -import java.io.File; -import java.io.IOException; -import java.util.regex.Pattern; - -/** - * The base class for handling file types in which line-based comments are used, - * such as java-style properties files or shell scripts. - * - * @author Kirill Sorokin - */ -public abstract class LineFileHandler implements FileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * The regular expression pattern which matches the line which is a comment. - */ - protected final Pattern commentPattern; - - /** - * The regular expression pattern which matches the line which should be - * ignored. This is used to skip the non-whitespace lines that can preceed the - * initial comment such as #!/bin/sh in shell scripts. - */ - protected final Pattern ignorePattern; - - /** - * The prefix which should be used for each line in the comment. If there should - * be no prefix - an empty line should be used (which is very unlikely in this - * case). - */ - protected final String commentPrefix; - - /** - * The cached file contents. - */ - protected String contents; - - // constructor ////////////////////////////////////////////////////////////////// - /** - * The constructor which should be called by the extending classes. It merely - * sets the class fields, performnig some basic validation. - * - * @param commentPattern The regular expression pattern which matches the line - * which is a comment. - * @param ignorePattern The regular expression pattern which matches the line - * which should be ignored. - * @param commentPrefix The prefix which should be used for each line in the - * comment. - * @throws java.lang.IllegalArgumentException if the parameters validation - * fails. - */ - protected LineFileHandler( - final Pattern commentPattern, - final Pattern ignorePattern, - final String commentPrefix) { - if (commentPattern == null) { - throw new IllegalArgumentException( - "The 'commentPattern' parameter cannot be null."); // NOI18N - } - this.commentPattern = commentPattern; - - if (ignorePattern == null) { - throw new IllegalArgumentException( - "The 'ignorePattern' parameter cannot be null."); // NOI18N - } - this.ignorePattern = ignorePattern; - - if (commentPrefix == null) { - throw new IllegalArgumentException( - "The 'commentPrefix' parameter cannot be null."); // NOI18N - } - this.commentPrefix = commentPrefix; - } - - // public /////////////////////////////////////////////////////////////////////// - /** - * {@inheritDoc} - */ - public final void load(final File file) throws IOException { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - contents = Utils.readFile(file); - } - - /** - * {@inheritDoc} - */ - public final void save(final File file) throws IOException { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - Utils.writeFile(file, contents); - } - - /** - * {@inheritDoc} - */ - public final String getCurrentComment() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final StringBuilder builder = new StringBuilder(); - final String[] lines = contents.split(Utils.NL_PATTERN); - - int i = 0; - - // skip the leading whitespace and ignored lines - for (; i < lines.length; i++) { - if (!lines[i].trim().equals("") && - !ignorePattern.matcher(lines[i]).matches()) { - break; - } - } - - // read the comment - for (; i < lines.length; i++) { - if (commentPattern.matcher(lines[i]).matches()) { - builder.append(lines[i]).append(Utils.NL); - } else { - break; - } - } - - return builder.length() > 0 ? builder.toString() : null; - } - - /** - * {@inheritDoc} - */ - public final String getCorrectComment(final String text, final int lineLength) { - return commentPrefix + Utils.NL + - Utils.reformat(text, commentPrefix, lineLength) + - commentPrefix + Utils.NL; - } - - /** - * {@inheritDoc} - */ - public final void insertComment(final String text, final int lineLength) { - if (text == null) { - throw new IllegalArgumentException( - "The 'text' parameter cannot be null."); // NOI18N - } - if (lineLength <= 0) { - throw new IllegalArgumentException( - "The 'lineLength' parameter must be positive."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final StringBuilder builder = new StringBuilder(); - final String[] lines = contents.split(Utils.NL_PATTERN); - final String comment = getCorrectComment(text, lineLength); - - int i = 0; - - // transfer the existing leading whitespace and ignored lines - for (; i < lines.length; i++) { - if (!lines[i].trim().equals("") && - !ignorePattern.matcher(lines[i]).matches()) { - break; - } else { - builder.append(lines[i]).append(Utils.NL); - } - } - - // transfer the comment and an empty line - builder.append(comment).append(Utils.NL); - - // transfer the rest of file - for (; i < lines.length; i++) { - builder.append(lines[i]).append(Utils.NL); - } - - contents = builder.toString(); - } - - /** - * {@inheritDoc} - */ - public final void updateComment(final String text, final int lineLength) { - if (text == null) { - throw new IllegalArgumentException( - "The 'text' parameter cannot be null."); // NOI18N - } - if (lineLength <= 0) { - throw new IllegalArgumentException( - "The 'lineLength' parameter must be positive."); // NOI18N - } - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final String currentComment = getCurrentComment(); - - if (currentComment == null) { - insertComment(text, lineLength); - return; - } - - final String correctComment = getCorrectComment(text, lineLength); - - // we don't need to update anything if the current initial comment is the - // same as the correct one - if (currentComment.equals(correctComment)) { - return; - } - - final StringBuilder builder = new StringBuilder(); - final String[] lines = contents.split(Utils.NL_PATTERN); - - int i = 0; - - // skip the leading whitespace and the ignored lines - for (; i < lines.length; i++) { - final String trimmed = lines[i].trim(); - - if (!trimmed.equals("") && - !ignorePattern.matcher(lines[i]).matches()) { - break; - } - - builder.append(lines[i]).append(Utils.NL); - } - - // skip the comment - for (; i < lines.length; i++) { - if (!commentPattern.matcher(lines[i]).matches()) { - break; - } - } - - // skip the empty lines after the comment - for (; i < lines.length; i++) { - if (!lines[i].trim().equals("")) { - break; - } - } - - // output the correct comment and an empty line - builder.append(correctComment).append(Utils.NL); - - // transfer the rest of the file - for (; i < lines.length; i++) { - builder.append(lines[i]).append(Utils.NL); - } - - contents = builder.toString(); - } -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/MakefileFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/MakefileFileHandler.java deleted file mode 100644 index 2fdbe113983a..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/MakefileFileHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import java.io.File; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling makefiles. - * - * @author Kirill Sorokin - */ -public class MakefileFileHandler extends LineFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link MakefileFileHandler}. The constuctor simply - * falls back to the - * {@link LineFileHandler#LineFileHandler(Pattern, Pattern, String)} passing in - * the parameters relevant to makefiles. - */ - public MakefileFileHandler() { - super(COMMENT_PATTERN, - IGNORE_PATTERN, - COMMENT_PREFIX); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().equals("Makefile") || // NOI18N - file.getName().endsWith(".mk"); // NOI18N - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The regular expression pattern which matches the line which is a comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "^\\s*#.*"); // NOI18N - - /** - * The regular expression pattern which matches the line which should be - * ignored. - */ - private static final Pattern IGNORE_PATTERN = Pattern.compile( - "^$"); // NOI18N - - /** - * The prefix which should be used for each line in the comment. - */ - private static final String COMMENT_PREFIX = - "# "; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/PropertiesFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/PropertiesFileHandler.java deleted file mode 100644 index dd176820a64f..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/PropertiesFileHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import java.io.File; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling java-style properties - * files. - * - * @author Kirill Sorokin - */ -public class PropertiesFileHandler extends LineFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link PropertiesFileHandler}. The constuctor - * simply falls back to the - * {@link LineFileHandler#LineFileHandler(Pattern, Pattern, String)} passing in - * the parameters relevant to properties files. - */ - public PropertiesFileHandler() { - super(COMMENT_PATTERN, - IGNORE_PATTERN, - COMMENT_PREFIX); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".properties"); // NOI18N - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The regular expression pattern which matches the line which is a comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "^\\s*#.*"); // NOI18N - - /** - * The regular expression pattern which matches the line which should be - * ignored. - */ - private static final Pattern IGNORE_PATTERN = Pattern.compile( - "^$"); // NOI18N - - /** - * The prefix which should be used for each line in the comment. - */ - private static final String COMMENT_PREFIX = - "# "; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/ShellFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/ShellFileHandler.java deleted file mode 100644 index dbae79aa4bda..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/ShellFileHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import java.io.File; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling shell scripts. - * - * @author Kirill Sorokin - */ -public class ShellFileHandler extends LineFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link ShellFileHandler}. The constuctor - * simply falls back to the - * {@link LineFileHandler#LineFileHandler(Pattern, Pattern, String)} passing in - * the parameters relevant to shell scripts. - */ - public ShellFileHandler() { - super(COMMENT_PATTERN, IGNORE_PATTERN, COMMENT_PREFIX); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".sh"); // NOI18N - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The regular expression pattern which matches the line which is a comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "^\\s*#.*"); // NOI18N - - /** - * The regular expression pattern which matches the line which should be - * ignored. - */ - private static final Pattern IGNORE_PATTERN = Pattern.compile( - "^\\S*#!.*"); // NOI18N - - /** - * The prefix which should be used for each line in the comment. - */ - private static final String COMMENT_PREFIX = - "# "; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/SourcesFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/SourcesFileHandler.java deleted file mode 100644 index e5c5b75a7754..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/SourcesFileHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import java.io.File; -import java.util.regex.Pattern; -import org.netbeans.installer.infra.utils.comment.utils.Utils; - -/** - * A {@link FileHandler} implementation capable of handling Java, C, C++ source and - * header files. - * - * @author Kirill Sorokin - */ -public class SourcesFileHandler extends BlockFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link SourcesFileHandler}. The constuctor - * simply falls back to the - * {@link BlockFileHandler#BlockFileHandler(Pattern, String, String, String)} - * passing in the parameters relevant to source files. - */ - public SourcesFileHandler() { - super(COMMENT_PATTERN, - COMMENT_START, - COMMENT_PREFIX, - COMMENT_END); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".java") || // NOI18N - file.getName().endsWith(".c") || // NOI18N - file.getName().endsWith(".cpp") || // NOI18N - file.getName().endsWith(".h") || // NOI18N - file.getName().endsWith(".js") || // NOI18N - file.getName().endsWith(".css"); // NOI18N - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * The regular expression pattern which matches the initial comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "\\A\\s*(/\\*.*?\\*/\\s*\\n)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The comment opening string. - */ - private static final String COMMENT_START = - "/*" + Utils.NL; // NOI18N - - /** - * The prefix which should be used for each line in the comment. - */ - private static final String COMMENT_PREFIX = - " * "; // NOI18N - - /** - * The comment closing string. - */ - private static final String COMMENT_END = - " */" + Utils.NL; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/XmlFileHandler.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/XmlFileHandler.java deleted file mode 100644 index cc05d4f76916..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/handlers/XmlFileHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.handlers; - -import org.netbeans.installer.infra.utils.comment.utils.Utils; -import java.io.File; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A {@link FileHandler} implementation capable of handling XML documents. - * - * @author Kirill Sorokin - */ -public class XmlFileHandler extends BlockFileHandler { - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * Creates a new instance of {@link XmlFileHandler}. The constuctor - * simply falls back to the - * {@link BlockFileHandler#BlockFileHandler(Pattern, String, String, String)} - * passing in the parameters relevant to XML files. - */ - public XmlFileHandler() { - super(COMMENT_PATTERN, - COMMENT_START, - COMMENT_PREFIX, - COMMENT_END); - } - - /** - * {@inheritDoc} - */ - public boolean accept(final File file) { - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - if (!file.isFile()) { - return false; - } - - return file.getName().endsWith(".xml") || // NOI18N - file.getName().endsWith(".xsd") || // NOI18N - file.getName().endsWith(".xslt"); // NOI18N - } - - /** - * {@inheritDoc} - */ - @Override - public int getCommentPosition() { - if (contents == null) { - throw new IllegalStateException( - "The contents cache has not been intialized."); // NOI18N - } - - final Matcher matcher = COMMENT_POSITION_PATTERN.matcher(contents); - if (matcher.find()) { - return contents.indexOf(matcher.group(1)); - } else { - return 0; - } - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - private static final Pattern COMMENT_POSITION_PATTERN = Pattern.compile( - "\\A\\s*<\\?xml.*?\\?>\\s*(.*)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The regular expression pattern which matches the initial comment. - */ - private static final Pattern COMMENT_PATTERN = Pattern.compile( - "\\A\\s*<\\?xml.*?\\?>\\s*(\\s*\\n)", // NOI18N - Pattern.MULTILINE | Pattern.DOTALL); - - /** - * The comment opening string. - */ - private static final String COMMENT_START = - "" + Utils.NL; // NOI18N -} diff --git a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/utils/Utils.java b/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/utils/Utils.java deleted file mode 100644 index af2ca06abb52..000000000000 --- a/nbi/infra/utils/comment-correcter/src/org/netbeans/installer/infra/utils/comment/utils/Utils.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.comment.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringReader; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -/** - * This is the helper utility methods class for the initial comment correcter - * utility. - * - * It provides means to read a text file into a string, write a string to a file and - * to reformat a given text to the given line length. It also holds several - * constants that are used elsewhere. - * - * @author Kirill Sorokin - */ -public final class Utils { - ///////////////////////////////////////////////////////////////////////////////// - // Static - /** - * Reads the given text file into a string. - * - * @param file The file to read. - * @return Contents of the file as a string. - * @throws java.io.IOException if an I/O error occurs of there are problems - * with validating the supplied file. - * @throws java.lang.IllegalArgumentException if the parameter is null. - */ - public static String readFile( - final File file) throws IOException { - // basic validation - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - - // file validation - if (!file.exists()) { - throw new IOException( - "The given file '" + file + // NOI18N - "' does not exist."); // NOI18N - } - if (!file.isFile()) { - throw new IOException( - "The given file '" + file + // NOI18N - "' exists but is a directory."); // NOI18N - } - - // read the file - final StringBuilder string = new StringBuilder(); - - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(file)); - - String line = null; - while ((line = reader.readLine()) != null) { - string.append(line + NL); - } - } finally { - if (reader != null) { - reader.close(); - } - } - - return string.toString(); - } - - /** - * Writes the given string to a file. The file contents are overwritten be the - * string. - * - * @param file The file to which the string should be written. - * @param string - * @throws java.io.IOException if an I/O errors occurs of there are problems - * with validating the supplied file. - * @throws java.lang.IllegalArgumentException if either of the parameters is - * null. - */ - public static void writeFile( - final File file, - final String string) throws IOException { - // basic validation - if (file == null) { - throw new IllegalArgumentException( - "The 'file' parameter cannot be null."); // NOI18N - } - if (string == null) { - throw new IllegalArgumentException( - "The 'string' parameter cannot be null."); // NOI18N - } - - // file validation - final File parent = file.getParentFile(); - if (file.exists() && !file.isFile()) { - throw new IOException( - "The given file '" + file + // NOI18N - "' exists and is not a file."); // NOI18N - } - if (parent.exists() && !parent.isDirectory()) { - throw new IOException( - "The parent of the given file '" + parent + // NOI18N - "' exists and is not a directory."); // NOI18N - } - if (!parent.exists() && !parent.mkdirs()) { - throw new IOException( - "The parent of the given file '" + parent + // NOI18N - "' does not exist and could not be created."); // NOI18N - } - - // write the file - final BufferedReader reader = - new BufferedReader(new StringReader(string)); - - PrintWriter writer = null; - try { - writer = new PrintWriter(new FileWriter(file)); - - String line = null; - while ((line = reader.readLine()) != null) { - writer.println(line); - } - } finally { - if (writer != null) { - writer.close(); - } - } - } - - /** - * Reformats the given text to the given line length. - * - *

- * Optinally the caller may specify a prefix which will be prepended to every - * string in the reformatted file. - * - * @param string The text to reformat. - * @param prefix The prefix to attach to the lines of the reformatted text. - * @param length The desired line length. - * @return The reformatted as a string. - * @throws java.lang.IllegalArgumentException if either of the parameters is - * null or if the line length is negative or zero. - */ - public static String reformat( - final String string, - final String prefix, - final int length) { - // basic validation - if (string == null) { - throw new IllegalArgumentException( - "The 'string' parameter cannot be null."); // NOI18N - } - if (prefix == null) { - throw new IllegalArgumentException( - "The 'prefix' parameter cannot be null."); // NOI18N - } - if (length <= 0) { - throw new IllegalArgumentException( - "The 'length' parameter should be positive."); // NOI18N - } - - final List lines = new LinkedList(); - lines.addAll(Arrays.asList(string.split(NL_PATTERN))); - - final int realLength = length - prefix.length(); - - for (int i = 0; i < lines.size(); i++) { - String line = lines.get(i); - - // if the current line's length is greater than the required one, we - // find the space character which will allow us to wrap the line - // satisfying the required length (the new line will be inserted into - // the list and processed at the next iteration); if the line cannot be - // wrapped - it is NOT modified - // if the line's length is less than the required one, and the line is - // not empty (which would the end of a paragraph), and is not the last - // line in the text, we try to attach the next line to it and wrap the - // sum if it's required - if (line.length() > realLength) { - final int index = findPrevious(line, ' ', realLength); - - if (index != -1) { - lines.add(i, line.substring(0, index)); - lines.set(i + 1, line.substring(index + 1)); - } - } else if (!line.trim().equals(EL) && (i < lines.size() - 1)) { - final String next = lines.get(i + 1); - - if (!next.trim().equals(EL)) { - if (!line.endsWith(SP)) { - line = line + SP + next; - } else { - line = line + next; - } - - if (line.length() > realLength) { - int index = findPrevious(line, ' ', realLength); - - if (index != -1) { - lines.set(i, line.substring(0, index)); - lines.set(i + 1, line.substring(index + 1)); - } - } else { - lines.set(i, line); - lines.remove(i + 1); - } - } - } - } - - // concatenate the lines and return the result - final StringBuilder builder = new StringBuilder(); - for (String line: lines) { - builder.append(prefix).append(line).append(NL); - } - - return builder.toString(); - } - - // private ////////////////////////////////////////////////////////////////////// - /** - * Finds the previous entry of the given character in the given string, starting - * at the given offset. - * - * @param string The string in which to perform the search. - * @param ch The character to look for. - * @param offset The offset from which to start searching. - * @return The previous index of the given character of -1 if the - * character cannot be found. - * @throws java.lang.IllegalArgumentException if the string parameter is null. - */ - private static int findPrevious( - final String string, - final char ch, - final int offset) { - // basic validation - if (string == null) { - throw new IllegalArgumentException( - "The 'string' parameter cannot be null."); // NOI18N - } - - for (int i = offset; i > 0; i--) { - if (string.charAt(i) == ch) { - return i; - } - } - - return -1; - } - - ///////////////////////////////////////////////////////////////////////////////// - // Instance - /** - * A dummy private default constructor, which prevents the class - * from being instantiated. - */ - private Utils() { - // does nothing - } - - ///////////////////////////////////////////////////////////////////////////////// - // Constants - /** - * Newline character combination for the current platform. This would be - * equal to \r\n on windows, \n on unices and \r on mac. - */ - public static final String NL = - System.getProperty("line.separator"); // NOI18N - - /** - * Empty line constant. - */ - public static final String EL = - ""; // NOI18N - - /** - * Space character constant. - */ - public static final String SP = - " "; // NOI18N - - /** - * A platform-agnostic pattern which will match the end of the line. - */ - public static final String NL_PATTERN = - "\r\n|\n|\r"; // NOI18N -} diff --git a/nbi/infra/utils/file-renamer/build.xml b/nbi/infra/utils/file-renamer/build.xml deleted file mode 100644 index 3debfb21f795..000000000000 --- a/nbi/infra/utils/file-renamer/build.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - Builds, tests, and runs the project File Renamer. - - - diff --git a/nbi/infra/utils/file-renamer/manifest.mf b/nbi/infra/utils/file-renamer/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/file-renamer/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/file-renamer/nbproject/build-impl.xml b/nbi/infra/utils/file-renamer/nbproject/build-impl.xml deleted file mode 100644 index 124c6c4e99e2..000000000000 --- a/nbi/infra/utils/file-renamer/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/file-renamer/nbproject/genfiles.properties b/nbi/infra/utils/file-renamer/nbproject/genfiles.properties deleted file mode 100644 index 532d2d464de2..000000000000 --- a/nbi/infra/utils/file-renamer/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=a76d7faf -build.xml.script.CRC32=aa32d553 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=b119966e -nbproject/build-impl.xml.script.CRC32=8728ea4d -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/file-renamer/nbproject/project.properties b/nbi/infra/utils/file-renamer/nbproject/project.properties deleted file mode 100644 index 95cdd2e9f643..000000000000 --- a/nbi/infra/utils/file-renamer/nbproject/project.properties +++ /dev/null @@ -1,77 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/File_Renamer.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.utils.filerenamer.Main -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/file-renamer/nbproject/project.xml b/nbi/infra/utils/file-renamer/nbproject/project.xml deleted file mode 100644 index aecbb7c6be78..000000000000 --- a/nbi/infra/utils/file-renamer/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - File Renamer - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/file-renamer/src/org/netbeans/installer/infra/utils/filerenamer/Main.java b/nbi/infra/utils/file-renamer/src/org/netbeans/installer/infra/utils/filerenamer/Main.java deleted file mode 100644 index 8fde6f50a56b..000000000000 --- a/nbi/infra/utils/file-renamer/src/org/netbeans/installer/infra/utils/filerenamer/Main.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.filerenamer; - -import java.io.File; - -/** - * - * @author Kirill Sorokin - */ -public class Main { - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - final File file = new File("D:/temp/data"); - - final String token = "_"; - final String replacement = ","; - - for (File source: file.listFiles()) { - if (source.isFile()) { - System.out.println(source); - - final String name = source.getName(); - final File target = new File( - source.getParentFile(), - name.replace(token, replacement)); - - System.out.println(" ... " + target); - source.renameTo(target); - } - } - } - -} diff --git a/nbi/infra/utils/newline-correcter/build.xml b/nbi/infra/utils/newline-correcter/build.xml deleted file mode 100644 index c38f1cef7471..000000000000 --- a/nbi/infra/utils/newline-correcter/build.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - Builds, tests, and runs the project NewLine Correcter. - - - diff --git a/nbi/infra/utils/newline-correcter/manifest.mf b/nbi/infra/utils/newline-correcter/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/newline-correcter/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/newline-correcter/nbproject/build-impl.xml b/nbi/infra/utils/newline-correcter/nbproject/build-impl.xml deleted file mode 100644 index 57de8317e79a..000000000000 --- a/nbi/infra/utils/newline-correcter/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/newline-correcter/nbproject/genfiles.properties b/nbi/infra/utils/newline-correcter/nbproject/genfiles.properties deleted file mode 100644 index e0ef48bfa245..000000000000 --- a/nbi/infra/utils/newline-correcter/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=59628f19 -build.xml.script.CRC32=eef4af3a -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=6900359b -nbproject/build-impl.xml.script.CRC32=b7817e34 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/newline-correcter/nbproject/project.properties b/nbi/infra/utils/newline-correcter/nbproject/project.properties deleted file mode 100644 index 07ebe48f8a09..000000000000 --- a/nbi/infra/utils/newline-correcter/nbproject/project.properties +++ /dev/null @@ -1,78 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/NewLine_Correcter.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.utils.newlinecorrecter.Main -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/newline-correcter/nbproject/project.xml b/nbi/infra/utils/newline-correcter/nbproject/project.xml deleted file mode 100644 index 4e7f3fa05ad8..000000000000 --- a/nbi/infra/utils/newline-correcter/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - NewLine Correcter - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/newline-correcter/src/org/netbeans/installer/infra/utils/newlinecorrecter/Main.java b/nbi/infra/utils/newline-correcter/src/org/netbeans/installer/infra/utils/newlinecorrecter/Main.java deleted file mode 100644 index b9a24e7af0a5..000000000000 --- a/nbi/infra/utils/newline-correcter/src/org/netbeans/installer/infra/utils/newlinecorrecter/Main.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.newlinecorrecter; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.LinkedList; -import java.util.List; - -public class Main { - public static void main(String[] args) throws IOException { - final File file = new File("D:/temp/nbi-build/build.sh"); - final String newline = "\n"; - - final List lines = new LinkedList(); - - BufferedReader reader = new BufferedReader(new FileReader(file)); - String line2read = null; - while ((line2read = reader.readLine()) != null) { - lines.add(line2read); - } - reader.close(); - - PrintWriter writer = new PrintWriter(new FileWriter(file)); - for (String line2write: lines) { - writer.write(line2write + newline); - } - writer.close(); - } -} diff --git a/nbi/infra/utils/platform-tester/build.xml b/nbi/infra/utils/platform-tester/build.xml deleted file mode 100644 index 061966a05267..000000000000 --- a/nbi/infra/utils/platform-tester/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - diff --git a/nbi/infra/utils/platform-tester/manifest.mf b/nbi/infra/utils/platform-tester/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/platform-tester/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/platform-tester/nbproject/build-impl.xml b/nbi/infra/utils/platform-tester/nbproject/build-impl.xml deleted file mode 100644 index 35132e0c1ecd..000000000000 --- a/nbi/infra/utils/platform-tester/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/platform-tester/nbproject/genfiles.properties b/nbi/infra/utils/platform-tester/nbproject/genfiles.properties deleted file mode 100644 index 23627af3f522..000000000000 --- a/nbi/infra/utils/platform-tester/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=44b4aef5 -build.xml.script.CRC32=4bcf9fc8 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=04c83258 -nbproject/build-impl.xml.script.CRC32=d9abd48d -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/platform-tester/nbproject/project.properties b/nbi/infra/utils/platform-tester/nbproject/project.properties deleted file mode 100644 index 9bf0b8cb384c..000000000000 --- a/nbi/infra/utils/platform-tester/nbproject/project.properties +++ /dev/null @@ -1,78 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/platform-tester.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.utils.platformtester.Main -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/platform-tester/nbproject/project.xml b/nbi/infra/utils/platform-tester/nbproject/project.xml deleted file mode 100644 index 87cea082b491..000000000000 --- a/nbi/infra/utils/platform-tester/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - NBI Utils: Platform Tester - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/platform-tester/src/org/netbeans/installer/infra/utils/platformtester/Main.java b/nbi/infra/utils/platform-tester/src/org/netbeans/installer/infra/utils/platformtester/Main.java deleted file mode 100644 index 5515c347c5b8..000000000000 --- a/nbi/infra/utils/platform-tester/src/org/netbeans/installer/infra/utils/platformtester/Main.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils.platformtester; - -import java.util.Properties; -import java.util.TreeSet; - -/** - * - * @author ks152834 - */ -public class Main { - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - final Properties properties = System.getProperties(); - - System.out.println( - "os.name => " + properties.get("os.name")); // NOI18N - System.out.println( - "os.arch => " + properties.get("os.arch")); // NOI18N - System.out.println( - "os.version => " + properties.get("os.version")); // NOI18N - - System.out.println( - ""); // NOI18N - System.out.println( - "---------------------------------------------"); // NOI18N - System.out.println( - "Other properties:"); // NOI18N - System.out.println( - ""); // NOI18N - - for (Object key: new TreeSet (properties.keySet())) { - System.out.println(key.toString() + - " => " + properties.get(key).toString()); // NOI18N - } - } -} diff --git a/nbi/infra/utils/port-occupation/build.xml b/nbi/infra/utils/port-occupation/build.xml deleted file mode 100644 index 1ad4b8a70038..000000000000 --- a/nbi/infra/utils/port-occupation/build.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - Builds, tests, and runs the project Port Occupation. - - - diff --git a/nbi/infra/utils/port-occupation/manifest.mf b/nbi/infra/utils/port-occupation/manifest.mf deleted file mode 100644 index 328e8e5bc3b7..000000000000 --- a/nbi/infra/utils/port-occupation/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbi/infra/utils/port-occupation/nbproject/build-impl.xml b/nbi/infra/utils/port-occupation/nbproject/build-impl.xml deleted file mode 100644 index 4e681615a7bf..000000000000 --- a/nbi/infra/utils/port-occupation/nbproject/build-impl.xml +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - Must select one file in the IDE or set profile.class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbi/infra/utils/port-occupation/nbproject/genfiles.properties b/nbi/infra/utils/port-occupation/nbproject/genfiles.properties deleted file mode 100644 index 47d3ffeb3c30..000000000000 --- a/nbi/infra/utils/port-occupation/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=eaf11473 -build.xml.script.CRC32=ac7f9955 -build.xml.stylesheet.CRC32=a12b3d02 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=a2481592 -nbproject/build-impl.xml.script.CRC32=60dfcd48 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/nbi/infra/utils/port-occupation/nbproject/project.properties b/nbi/infra/utils/port-occupation/nbproject/project.properties deleted file mode 100644 index 25469b243b63..000000000000 --- a/nbi/infra/utils/port-occupation/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -application.title=Port Occupation -application.vendor=ks152834 -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/Port_Occupation.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=org.netbeans.installer.infra.utils.Main -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -src.dir=src -test.src.dir=test diff --git a/nbi/infra/utils/port-occupation/nbproject/project.xml b/nbi/infra/utils/port-occupation/nbproject/project.xml deleted file mode 100644 index 0e6e6011ad95..000000000000 --- a/nbi/infra/utils/port-occupation/nbproject/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.netbeans.modules.java.j2seproject - - - Port Occupation - 1.6.5 - - - - - - - - - diff --git a/nbi/infra/utils/port-occupation/src/org/netbeans/installer/infra/utils/Main.java b/nbi/infra/utils/port-occupation/src/org/netbeans/installer/infra/utils/Main.java deleted file mode 100644 index 5cb96416e6e2..000000000000 --- a/nbi/infra/utils/port-occupation/src/org/netbeans/installer/infra/utils/Main.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.netbeans.installer.infra.utils; - -import java.io.IOException; -import java.net.ServerSocket; - -/** - * - * @author Kirill Sorokin - */ -public class Main { - public static void main(String[] args) { - for (String arg: args) { - if (arg.matches("[0-9]+")) { - occupy(Integer.parseInt(arg)); - } - - if (arg.matches("[0-9]+-[0-9]+")) { - int start = Integer.parseInt(arg.substring(0, arg.indexOf("-"))); - int end = Integer.parseInt(arg.substring(arg.indexOf("-") + 1)); - - for (int port = start; port <= end; port++) { - occupy(port); - } - } - } - } - - private static void occupy(final int port) { - new Thread() { - public void run() { - try { - System.out.println("occupying: " + port); - new ServerSocket(port).accept(); - } catch (IOException e) { - System.out.println(" failed: " + port + " (" + e.getMessage() + ")"); - } - } - }.start(); - } -} diff --git a/nbi/l10n.list b/nbi/l10n.list deleted file mode 100644 index 43409db5cc4c..000000000000 --- a/nbi/l10n.list +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -#i18n bundles for NBI installers -nbi/engine/src/**/Bundle*.properties -nbi/engine/src/data/engine*.properties -nbi/engine/native/launcher/**/launcher*.properties diff --git a/nbi/licenseinfo.xml b/nbi/licenseinfo.xml deleted file mode 100644 index 1eab6f83687b..000000000000 --- a/nbi/licenseinfo.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - infra/server/modules/war-client/web/img/default-icon.png - infra/server/modules/war-client/web/img/empty.gif - infra/server/modules/war-client/web/img/tree-handle-closed.png - infra/server/modules/war-client/web/img/tree-handle-open.png - infra/server/modules/war-client/web/img/tree-handle-empty.png - infra/server/modules/war-admin/web/img/default-icon.png - infra/server/modules/war-admin/web/img/tree-handle-closed.png - infra/server/modules/war-admin/web/img/tree-handle-open.png - infra/server/modules/war-admin/web/img/tree-handle-empty.png - engine/src/org/netbeans/installer/utils/helper/swing/frame-icon.png - engine/src/org/netbeans/installer/wizard/components/panels/empty.png - engine/src/org/netbeans/installer/wizard/components/panels/warning.png - engine/src/org/netbeans/installer/wizard/components/panels/info.png - engine/src/org/netbeans/installer/wizard/components/panels/error.png - engine/src/org/netbeans/installer/utils/system/launchers/impl/dockicon.icns - engine/native/launcher/windows/resources/icon.ico - - - - - engine/native/launcher/windows/resources/nlw-alt.exe.manifest - engine/native/launcher/windows/resources/nlw.exe.manifest - - RAT recognises files as binary - -