diff options
author | Alexander Kurtakov | 2017-10-09 07:14:05 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-10-09 07:22:37 +0000 |
commit | 0aa14c050b4201458ad17d51dd5370a3a7997a7d (patch) | |
tree | 84d8720463107cf306183d8e04460f02e1028838 | |
parent | f6a067057b657e611b25a467de21e6a625a02c32 (diff) | |
download | rt.equinox.p2-0aa14c050b4201458ad17d51dd5370a3a7997a7d.tar.gz rt.equinox.p2-0aa14c050b4201458ad17d51dd5370a3a7997a7d.tar.xz rt.equinox.p2-0aa14c050b4201458ad17d51dd5370a3a7997a7d.zip |
Bug 525735 - Move touchpoint.natives bundle to Java 8I20171009-2000
* Bump BREE.
* Bump minor version.
* Enable warning for newer Java versions.
* Add missing override annotations.
* Try-with-resources.
* Remove redundant type arguments.
* Lambda conversion.
Change-Id: I414b791948fd6c4f0c65df00fd6bdf3cd9814134
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
24 files changed, 239 insertions, 186 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/.classpath b/bundles/org.eclipse.equinox.p2.touchpoint.natives/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/.classpath +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.touchpoint.natives/.settings/org.eclipse.jdt.core.prefs index 449cf187f..0d5a93204 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/.settings/org.eclipse.jdt.core.prefs @@ -6,29 +6,45 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch org.eclipse.jdt.core.circularClasspath=error org.eclipse.jdt.core.classpath.exclusionPatterns=enabled org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000 +org.eclipse.jdt.core.compiler.problem.APILeak=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled org.eclipse.jdt.core.compiler.problem.discouragedReference=error org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning @@ -36,41 +52,79 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF index 27724409d..d5376157c 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.touchpoint.natives;singleton:=true -Bundle-Version: 1.2.200.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.touchpoint.natives.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,7 +10,7 @@ Export-Package: org.eclipse.equinox.internal.p2.touchpoint.natives;x-internal:=t org.eclipse.equinox.internal.p2.touchpoint.natives.actions;x-internal:=true Require-Bundle: org.eclipse.equinox.common, org.eclipse.equinox.app;bundle-version="1.3.0";resolution:=optional -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.engine, diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf index e397bf7f6..ba2ac0962 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf @@ -13,3 +13,7 @@ provides.2.version=1.2.100.$qualifier$ provides.3.namespace=org.eclipse.equinox.p2.iu provides.3.name=org.eclipse.equinox.p2.touchpoint.natives provides.3.version=1.2.200.$qualifier$ + +provides.4.namespace=org.eclipse.equinox.p2.iu +provides.4.name=org.eclipse.equinox.p2.touchpoint.natives +provides.4.version=1.3.0.$qualifier$ diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/pom.xml b/bundles/org.eclipse.equinox.p2.touchpoint.natives/pom.xml index 62bd13d37..cae549847 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/pom.xml +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.touchpoint.natives</artifactId> - <version>1.2.200-SNAPSHOT</version> + <version>1.3.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Activator.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Activator.java index e3c7010d5..69a77f29d 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Activator.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,18 +21,12 @@ public class Activator implements BundleActivator { return context; } - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) - */ + @Override public void start(BundleContext aContext) throws Exception { Activator.context = aContext; } - /* - * (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ + @Override public void stop(BundleContext aContext) throws Exception { context = null; } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java index 0e3ecc828..482de70ba 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2016 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -140,7 +140,7 @@ public class BackupStore implements IBackupStore { */ private boolean closed; - private Map<String, String> renamedInPlace = new HashMap<String, String>(); + private Map<String, String> renamedInPlace = new HashMap<>(); /** * Generates a BackupStore with a default prefix of ".p2bu" for backup directory and @@ -180,6 +180,7 @@ public class BackupStore implements IBackupStore { * must be closed if this instance is garbage collected and the user * of the instance has not either restored or discarded. */ + @Override protected void finalize() throws Throwable { try { if (socket != null && !socket.isClosed()) @@ -193,6 +194,7 @@ public class BackupStore implements IBackupStore { * Returns the unique backup name (this is the name of generated backup directories). * @return the backup name. */ + @Override public String getBackupName() { return backupName; } @@ -223,6 +225,7 @@ public class BackupStore implements IBackupStore { * @throws ClosedBackupStoreException - if the BackupStore has been closed * @throws IllegalArgumentException - on type mismatch (file vs. directory) of earlier backup, or if file does not exist */ + @Override public boolean backup(File file) throws IOException { if (closed) throw new ClosedBackupStoreException("Can not perform backup()"); //$NON-NLS-1$ @@ -331,6 +334,7 @@ public class BackupStore implements IBackupStore { * @param file - file to backup or directory * @throws IOException if backup operation failed */ + @Override public void backupAll(File file) throws IOException { if (!file.exists()) return; @@ -350,6 +354,7 @@ public class BackupStore implements IBackupStore { * @param file * @throws IOException */ + @Override public void backupCopyAll(File file) throws IOException { if (!file.exists()) return; @@ -391,6 +396,7 @@ public class BackupStore implements IBackupStore { * @throws ClosedBackupStoreException - if the BackupStore has been closed * @throws IllegalArgumentException - on type mismatch (file vs. directory) of earlier backup, or if file is a Directory */ + @Override public boolean backupCopy(File file) throws IOException { if (closed) throw new ClosedBackupStoreException(Messages.BackupStore_backupCopy_closed_store); @@ -435,6 +441,7 @@ public class BackupStore implements IBackupStore { * @throws IllegalArgumentException if file is not a directory, or is not empty. * @throws IOException if directory can not be moved to the backup store, or if the directory is not writeable */ + @Override public boolean backupDirectory(File file) throws IOException { if (!file.isDirectory()) throw new IllegalArgumentException(NLS.bind(Messages.BackupStore_not_a_directory, file.getAbsolutePath())); @@ -476,12 +483,13 @@ public class BackupStore implements IBackupStore { * @throws IOException if the backup was not fully restored - unrestored items have been logged. * @throws ClosedBackupStoreException if the backup is already closed. */ + @Override public void restore() throws IOException { if (closed) throw new ClosedBackupStoreException(Messages.BackupStore_restore_closed_store); // put back all files // collect things that could not be restored (so final status can be reported) - Set<File> unrestorable = new HashSet<File>(); + Set<File> unrestorable = new HashSet<>(); boolean restored = true; if (!backupRoot.exists()) { logError(NLS.bind(Messages.BackupStore_missing_backup_directory, backupRoot.getAbsolutePath())); @@ -509,6 +517,7 @@ public class BackupStore implements IBackupStore { * Discards and closes this BackupStore. Does nothing if this store is already * restored or discarded. */ + @Override public void discard() { if (closed) return; diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/LazyBackupStore.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/LazyBackupStore.java index e3dbc4c6f..fb321e9f0 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/LazyBackupStore.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/LazyBackupStore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,8 +16,6 @@ import java.io.IOException; /** * LazyBackupStore is a BackupStore that only instantiates a real backup store * when needed. - * - * */ public class LazyBackupStore implements IBackupStore { private BackupStore delegate; @@ -31,22 +29,26 @@ public class LazyBackupStore implements IBackupStore { this.prefix = prefix; } + @Override public boolean backup(File file) throws IOException { loadDelegate(); return delegate.backup(file); } + @Override public boolean backupDirectory(File file) throws IOException { loadDelegate(); return delegate.backupDirectory(file); } + @Override public void discard() { if (delegate == null) return; delegate.discard(); } + @Override public void restore() throws IOException { if (delegate == null) return; @@ -59,21 +61,25 @@ public class LazyBackupStore implements IBackupStore { delegate = new BackupStore(null, prefix); } + @Override public String getBackupName() { loadDelegate(); return delegate.getBackupName(); } + @Override public boolean backupCopy(File file) throws IOException { loadDelegate(); return delegate.backupCopy(file); } + @Override public void backupCopyAll(File file) throws IOException { loadDelegate(); delegate.backupCopyAll(file); } + @Override public void backupAll(File file) throws IOException { loadDelegate(); delegate.backupAll(file); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java index 67ff28ea1..346458adf 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2016 Rapicorp, Inc and others. + * Copyright (c) 2014, 2017 Rapicorp, Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -58,6 +58,7 @@ public class NativePackageExtractionApplication implements IApplication { private boolean stackTrace = false; + @Override public Object start(IApplicationContext context) throws Exception { try { processArguments((String[]) context.getArguments().get("application.args")); //$NON-NLS-1$ @@ -114,14 +115,8 @@ public class NativePackageExtractionApplication implements IApplication { } private void persistInformation() throws CoreException { - try { - BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(resultFile)); - try { - extractedData.store(os, "Data extracted from eclipse located at " + installation); //$NON-NLS-1$ - } finally { - if (os != null) - os.close(); - } + try (BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(resultFile))) { + extractedData.store(os, "Data extracted from eclipse located at " + installation); //$NON-NLS-1$ } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, Activator.ID, Messages.NativePackageExtractionApplication_PersistencePb + resultFile.getAbsolutePath(), e)); } @@ -203,7 +198,7 @@ public class NativePackageExtractionApplication implements IApplication { //Code copied from the InstructionParser class private Map<String, String> parseInstruction(String statement) { - Map<String, String> instructions = new HashMap<String, String>(); + Map<String, String> instructions = new HashMap<>(); int openBracket = statement.indexOf('('); int closeBracket = statement.lastIndexOf(')'); @@ -240,21 +235,12 @@ public class NativePackageExtractionApplication implements IApplication { if (profileId == null) { if (installation != null) { File configIni = new File(installation, "configuration/config.ini"); //$NON-NLS-1$ - InputStream in = null; - try { - Properties ciProps = new Properties(); - in = new BufferedInputStream(new FileInputStream(configIni)); + Properties ciProps = new Properties(); + try (InputStream in = new BufferedInputStream(new FileInputStream(configIni))) { ciProps.load(in); profileId = ciProps.getProperty(PROP_P2_PROFILE); } catch (IOException e) { // Ignore - } finally { - if (in != null) - try { - in.close(); - } catch (IOException e) { - // Ignore; - } } if (profileId == null) profileId = installation.toString(); @@ -312,6 +298,7 @@ public class NativePackageExtractionApplication implements IApplication { } } + @Override public void stop() { //We don't handle application stopping } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativeTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativeTouchpoint.java index 2c8544962..b001c4ee2 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativeTouchpoint.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativeTouchpoint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,14 +33,15 @@ public class NativeTouchpoint extends Touchpoint { private static final String INSTALL_COMMANDS = "installCommands.txt"; //$NON-NLS-1$ private static final String INSTALL_PREFIX = "installPrefix"; //$NON-NLS-1$ - private static Map<IProfile, IBackupStore> backups = new WeakHashMap<IProfile, IBackupStore>(); + private static Map<IProfile, IBackupStore> backups = new WeakHashMap<>(); - private List<NativePackageEntry> packagesToInstall = new ArrayList<NativePackageEntry>(); + private List<NativePackageEntry> packagesToInstall = new ArrayList<>(); private Properties installCommandsProperties = new Properties(); private IProvisioningAgent agent; private String distro; + @Override public IStatus initializeOperand(IProfile profile, Map<String, Object> parameters) { agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT); IArtifactKey artifactKey = (IArtifactKey) parameters.get(PARM_ARTIFACT); @@ -57,15 +58,18 @@ public class NativeTouchpoint extends Touchpoint { return Status.OK_STATUS; } + @Override public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map<String, Object> touchpointParameters) { touchpointParameters.put(PARM_BACKUP, getBackupStore(profile)); return null; } + @Override public String qualifyAction(String actionId) { return Activator.ID + "." + actionId; //$NON-NLS-1$ } + @Override public IStatus prepare(IProfile profile) { // does not have to do anything - everything is already in the correct place // the commit means that the backup is discarded - if that fails it is not a @@ -73,6 +77,7 @@ public class NativeTouchpoint extends Touchpoint { return super.prepare(profile); } + @Override public IStatus commit(IProfile profile) { promptForNativePackage(); IBackupStore store = getBackupStore(profile); @@ -88,7 +93,7 @@ public class NativeTouchpoint extends Touchpoint { UIServices serviceUI = (UIServices) agent.getService(UIServices.SERVICE_NAME); String text = Messages.PromptForNative_IntroText; String downloadLinks = ""; //$NON-NLS-1$ - List<NativePackageEntry> entriesWithoutDownloadLink = new ArrayList<NativePackageEntry>(packagesToInstall.size()); + List<NativePackageEntry> entriesWithoutDownloadLink = new ArrayList<>(packagesToInstall.size()); for (NativePackageEntry nativePackageEntry : packagesToInstall) { text += '\t' + nativePackageEntry.name + ' ' + formatVersion(nativePackageEntry) + '\n'; if (nativePackageEntry.getDownloadLink() != null) { @@ -128,14 +133,8 @@ public class NativeTouchpoint extends Touchpoint { if (f == null) return; - try { - InputStream is = new BufferedInputStream(new FileInputStream(f)); - try { - properties.load(is); - } finally { - if (is != null) - is.close(); - } + try (InputStream is = new BufferedInputStream(new FileInputStream(f))) { + properties.load(is); } catch (IOException e) { //fallthrough to return empty string } @@ -195,6 +194,7 @@ public class NativeTouchpoint extends Touchpoint { return buffer.toString(); } + @Override public IStatus rollback(IProfile profile) { IStatus returnStatus = Status.OK_STATUS; IBackupStore store = getBackupStore(profile); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java index f20bafb0e..212c5571d 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,7 +61,7 @@ public class Util { } catch (ProvisionException e) { // the download cache doesn't exist or couldn't be read. Create new cache. String repositoryName = location + " - Agent download cache"; //$NON-NLS-1$ - Map<String, String> properties = new HashMap<String, String>(1); + Map<String, String> properties = new HashMap<>(1); properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString()); repository = manager.createRepository(location, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); } @@ -94,16 +94,13 @@ public class Util { * If a path is specified, the path is consider as entry point in zip, as when the to directory in zip would have been the specified path. */ public static File[] unzipFile(File zipFile, File outputDir, String path, String[] includePatterns, String[] excludePatterns, IBackupStore store, String taskName, IProgressMonitor monitor) throws IOException { - InputStream in = new FileInputStream(zipFile); - try { + try (InputStream in = new FileInputStream(zipFile)) { return unzipStream(in, zipFile.length(), outputDir, path, includePatterns, excludePatterns, store, taskName, monitor); } catch (IOException e) { // add the file name to the message IOException ioException = new IOException(NLS.bind(Messages.Util_Error_Unzipping, zipFile, e.getMessage())); ioException.initCause(e); throw ioException; - } finally { - in.close(); } } @@ -123,90 +120,90 @@ public class Util { */ public static File[] unzipStream(InputStream stream, long size, File outputDir, String path, String[] includePatterns, String[] excludePatterns, IBackupStore store, String taskName, IProgressMonitor monitor) throws IOException { InputStream is = monitor == null ? stream : stream; // new ProgressMonitorInputStream(stream, size, size, taskName, monitor); TODO Commented code - ZipInputStream in = new ZipInputStream(new BufferedInputStream(is)); - ZipEntry ze = in.getNextEntry(); - if (ze == null) { - // There must be at least one entry in a zip file. - // When there isn't getNextEntry returns null. - in.close(); - throw new IOException(Messages.Util_Invalid_Zip_File_Format); - } + try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(is))) { + ZipEntry ze = in.getNextEntry(); + if (ze == null) { + // There must be at least one entry in a zip file. + // When there isn't getNextEntry returns null. + in.close(); + throw new IOException(Messages.Util_Invalid_Zip_File_Format); + } - if (path != null && path.trim().length() == 0) - path = null; - Pattern pathRegex = path == null ? null : createAntStylePattern("(" + path + ")(*)"); //$NON-NLS-1$ //$NON-NLS-2$ + if (path != null && path.trim().length() == 0) + path = null; + Pattern pathRegex = path == null ? null : createAntStylePattern("(" + path + ")(*)"); //$NON-NLS-1$ //$NON-NLS-2$ - Collection<Pattern> includeRegexp = new ArrayList<Pattern>(); - Collection<Pattern> excludeRegexp = new ArrayList<Pattern>(); - if (includePatterns != null) { - for (String pattern : includePatterns) { - if (pattern != null) { - includeRegexp.add(createAntStylePattern(pattern)); + Collection<Pattern> includeRegexp = new ArrayList<>(); + Collection<Pattern> excludeRegexp = new ArrayList<>(); + if (includePatterns != null) { + for (String pattern : includePatterns) { + if (pattern != null) { + includeRegexp.add(createAntStylePattern(pattern)); + } } } - } - if (excludePatterns != null) { - for (String pattern : excludePatterns) { - if (pattern != null) { - excludeRegexp.add(createAntStylePattern(pattern)); + if (excludePatterns != null) { + for (String pattern : excludePatterns) { + if (pattern != null) { + excludeRegexp.add(createAntStylePattern(pattern)); + } } } - } - ArrayList<File> unzippedFiles = new ArrayList<File>(); - do { - String name = ze.getName(); - if (pathRegex == null || pathRegex.matcher(name).matches()) { - boolean unzip = includeRegexp.isEmpty(); - for (Pattern pattern : includeRegexp) { - unzip = pattern.matcher(name).matches(); - if (unzip) - break; - } - if (unzip && !excludeRegexp.isEmpty()) { - for (Pattern pattern : excludeRegexp) { - if (pattern.matcher(name).matches()) { - unzip = false; + ArrayList<File> unzippedFiles = new ArrayList<>(); + do { + String name = ze.getName(); + if (pathRegex == null || pathRegex.matcher(name).matches()) { + boolean unzip = includeRegexp.isEmpty(); + for (Pattern pattern : includeRegexp) { + unzip = pattern.matcher(name).matches(); + if (unzip) break; - } } - } - if (unzip) { - if (pathRegex != null) { - Matcher matcher = pathRegex.matcher(name); - if (matcher.matches()) { - name = matcher.group(2); - if (name.startsWith("/")) //$NON-NLS-1$ - name = name.substring(1); + if (unzip && !excludeRegexp.isEmpty()) { + for (Pattern pattern : excludeRegexp) { + if (pattern.matcher(name).matches()) { + unzip = false; + break; + } } } - File outFile = new File(outputDir, name); - unzippedFiles.add(outFile); - if (ze.isDirectory()) { - outFile.mkdirs(); - } else { - if (outFile.exists()) { - if (store != null) - store.backup(outFile); - else - outFile.delete(); - } else { - outFile.getParentFile().mkdirs(); + if (unzip) { + if (pathRegex != null) { + Matcher matcher = pathRegex.matcher(name); + if (matcher.matches()) { + name = matcher.group(2); + if (name.startsWith("/")) //$NON-NLS-1$ + name = name.substring(1); + } } - try { - copyStream(in, false, new FileOutputStream(outFile), true); - } catch (FileNotFoundException e) { - // TEMP: ignore this for now in case we're trying to replace - // a running eclipse.exe + File outFile = new File(outputDir, name); + unzippedFiles.add(outFile); + if (ze.isDirectory()) { + outFile.mkdirs(); + } else { + if (outFile.exists()) { + if (store != null) + store.backup(outFile); + else + outFile.delete(); + } else { + outFile.getParentFile().mkdirs(); + } + try { + copyStream(in, false, new FileOutputStream(outFile), true); + } catch (FileNotFoundException e) { + // TEMP: ignore this for now in case we're trying to replace + // a running eclipse.exe + } + outFile.setLastModified(ze.getTime()); } - outFile.setLastModified(ze.getTime()); } } - } - in.closeEntry(); - } while ((ze = in.getNextEntry()) != null); - in.close(); + in.closeEntry(); + } while ((ze = in.getNextEntry()) != null); + return unzippedFiles.toArray(new File[unzippedFiles.size()]); + } - return unzippedFiles.toArray(new File[unzippedFiles.size()]); } /** diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java index 2104384cd..a8e5f621c 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 IBM Corporation and others. + * Copyright (c) 2015, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java index 9752de043..94bc4587b 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Rapicorp, Inc. and others. + * Copyright (c) 2014, 2017 Rapicorp, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,7 +35,7 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { if (distro == null || packageName == null || (versionComparator != null && packageVersion == null)) return new Status(IStatus.ERROR, Activator.ID, Messages.Incorrect_Command); - + distro = distro.toLowerCase(); //If we are not running the distro we are provisioning, do nothing and return @@ -48,7 +48,7 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Cannot_Find_status, distro)); try { - List<String> cmd = new ArrayList<String>(4); + List<String> cmd = new ArrayList<>(4); cmd.add(SHELL); cmd.add(scriptToExecute.getAbsolutePath()); cmd.add(packageName); @@ -84,7 +84,7 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { if (scriptToExecute == null) return false; - List<String> cmd = new ArrayList<String>(4); + List<String> cmd = new ArrayList<>(4); cmd.add(SHELL); cmd.add(scriptToExecute.getAbsolutePath()); int exitValue = new ProcessBuilder(cmd).start().waitFor(); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackageWindowsRegistry.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackageWindowsRegistry.java index d2768e030..82c263fe5 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackageWindowsRegistry.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackageWindowsRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 SAP SE and others. + * Copyright (c) 2015, 2017 SAP SE and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -48,7 +48,7 @@ public class CheckAndPromptNativePackageWindowsRegistry extends ProvisioningActi return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Cannot_Find_status, WINDOWS_DISTRO)); try { - List<String> cmd = new ArrayList<String>(6); + List<String> cmd = new ArrayList<>(6); cmd.add(SHELL); cmd.add("/c"); //$NON-NLS-1$ cmd.add(scriptToExecute.getAbsolutePath()); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java index 535e095e1..5c3676147 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/ChmodAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,6 +35,7 @@ public class ChmodAction extends ProvisioningAction { // N Y N incorrect, missing the targetFolder // N N Y Y // N N N + @Override public IStatus execute(Map<String, Object> parameters) { Object absoluteFiles = parameters.get(ActionConstants.PARM_ABSOLUTE_FILES); //String or String[] String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR); @@ -74,7 +75,7 @@ public class ChmodAction extends ProvisioningAction { private void doChmod(String fileToChmod, String permissions, String optionsString) { String options[] = null; if (optionsString != null) { - ArrayList<String> collect = new ArrayList<String>(); + ArrayList<String> collect = new ArrayList<>(); String r = optionsString.trim(); while (r.length() > 0) { int spaceIdx = r.indexOf(' '); @@ -96,6 +97,7 @@ public class ChmodAction extends ProvisioningAction { chmod(fileToChmod, permissions, options); } + @Override public IStatus undo(Map<String, Object> parameters) { //TODO: implement undo ?? return Status.OK_STATUS; @@ -131,19 +133,12 @@ public class ChmodAction extends ProvisioningAction { } private void readOffStream(InputStream inputStream) { - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { while (reader.readLine() != null) { // do nothing } } catch (IOException e) { // ignore - } finally { - try { - reader.close(); - } catch (IOException e) { - // ignore - } } } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupcopyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupcopyAction.java index 1aa038991..3788594d7 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupcopyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupcopyAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,10 +25,12 @@ public class CleanupcopyAction extends ProvisioningAction { public static final String ACTION_CLEANUPCOPY = "cleanupcopy"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { return cleanupcopy(parameters, true); } + @Override public IStatus undo(Map<String, Object> parameters) { return CopyAction.copy(parameters, false); } @@ -57,7 +59,7 @@ public class CleanupcopyAction extends ProvisioningAction { return Status.OK_STATUS; StringTokenizer tokenizer = new StringTokenizer(copied, ActionConstants.PIPE); - List<File> directories = new ArrayList<File>(); + List<File> directories = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { String fileName = tokenizer.nextToken(); File file = new File(fileName); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java index 622c090ea..e20976f1f 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CleanupzipAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2016 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,10 +26,12 @@ public class CleanupzipAction extends ProvisioningAction { private static final String UNZIPPED = "unzipped"; //$NON-NLS-1$ public static final String ACTION_CLEANUPZIP = "cleanupzip"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { return cleanupzip(parameters, true); } + @Override public IStatus undo(Map<String, Object> parameters) { return new UnzipAction().unzip(parameters, false); } @@ -70,7 +72,7 @@ public class CleanupzipAction extends ProvisioningAction { IBackupStore store = restoreable ? (IBackupStore) parameters.get(NativeTouchpoint.PARM_BACKUP) : null; StringTokenizer tokenizer = new StringTokenizer(unzipped, ActionConstants.PIPE); - List<File> directories = new ArrayList<File>(); + List<File> directories = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { String fileName = tokenizer.nextToken(); File file = new File(fileName); @@ -92,23 +94,19 @@ public class CleanupzipAction extends ProvisioningAction { } // sort directories by path length longest path is in top // this will make sure that a sub folder will be removed before its parent - Collections.sort(directories, new Comparator<File>() { - - public int compare(File f1, File f2) { - if (f1 == f2) - return 0; - if (f1 != null && f2 == null) - return -1; - if (f1 == null) - return 1; - try { - return Integer.valueOf(f2.getCanonicalPath().length()).compareTo(f1.getCanonicalPath().length()); - } catch (IOException e) { - // did our best. try an absolute path compare - return Integer.valueOf(f2.getAbsolutePath().length()).compareTo(f1.getAbsolutePath().length()); - } + Collections.sort(directories, (f1, f2) -> { + if (f1 == f2) + return 0; + if (f1 != null && f2 == null) + return -1; + if (f1 == null) + return 1; + try { + return Integer.valueOf(f2.getCanonicalPath().length()).compareTo(f1.getCanonicalPath().length()); + } catch (IOException e) { + // did our best. try an absolute path compare + return Integer.valueOf(f2.getAbsolutePath().length()).compareTo(f1.getAbsolutePath().length()); } - }); for (File directory : directories) { if (store != null) { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java index a205965dc..246d225ed 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CollectAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ public class CollectAction extends ProvisioningAction { public static final String ACTION_COLLECT = "collect"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT); @@ -43,6 +44,7 @@ public class CollectAction extends ProvisioningAction { return Status.OK_STATUS; } + @Override public IStatus undo(Map<String, Object> parameters) { // nothing to do for now return Status.OK_STATUS; diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java index 2983d3512..cb8702cab 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CopyAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,6 +33,7 @@ import org.eclipse.osgi.util.NLS; public class CopyAction extends ProvisioningAction { public static final String ID = "cp"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { return copy(parameters, true); } @@ -86,6 +87,7 @@ public class CopyAction extends ProvisioningAction { return Status.OK_STATUS; } + @Override public IStatus undo(Map<String, Object> parameters) { return CleanupcopyAction.cleanupcopy(parameters, false); } @@ -98,7 +100,7 @@ public class CopyAction extends ProvisioningAction { * @throws IOException */ private static File[] mergeCopy(File source, File target, boolean overwrite, IBackupStore backupStore) throws IOException { - ArrayList<File> copiedFiles = new ArrayList<File>(); + ArrayList<File> copiedFiles = new ArrayList<>(); xcopy(copiedFiles, source, target, overwrite, backupStore); return copiedFiles.toArray(new File[copiedFiles.size()]); } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/LinkAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/LinkAction.java index 03a591f70..d0e56caff 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/LinkAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/LinkAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ public class LinkAction extends ProvisioningAction { public static final String ID = "ln"; //$NON-NLS-1$ private static final boolean WINDOWS = java.io.File.separatorChar == '\\'; + @Override public IStatus execute(Map<String, Object> parameters) { String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR); if (targetDir == null) @@ -46,6 +47,7 @@ public class LinkAction extends ProvisioningAction { return Status.OK_STATUS; } + @Override public IStatus undo(Map<String, Object> parameters) { if (WINDOWS) return Status.OK_STATUS; @@ -96,19 +98,12 @@ public class LinkAction extends ProvisioningAction { } private void readOffStream(InputStream inputStream) { - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { while (reader.readLine() != null) { // do nothing } } catch (IOException e) { // ignore - } finally { - try { - reader.close(); - } catch (IOException e) { - // ignore - } } } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/MkdirAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/MkdirAction.java index b98cfc79c..e7fcde013 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/MkdirAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/MkdirAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import org.eclipse.osgi.util.NLS; public class MkdirAction extends ProvisioningAction { public static final String ID = "mkdir"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { String path = (String) parameters.get(ActionConstants.PARM_PATH); if (path == null) @@ -35,6 +36,7 @@ public class MkdirAction extends ProvisioningAction { return Util.createError(NLS.bind(Messages.mkdir_failed, path, ID)); } + @Override public IStatus undo(Map<String, Object> parameters) { String path = (String) parameters.get(ActionConstants.PARM_PATH); if (path == null) diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RemoveAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RemoveAction.java index 141d52b38..879996313 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RemoveAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RemoveAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Cloudsmith Inc. and others. + * Copyright (c) 2009, 2017 Cloudsmith Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import org.eclipse.osgi.util.NLS; public class RemoveAction extends ProvisioningAction { public static final String ID = "remove"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { String path = (String) parameters.get(ActionConstants.PARM_PATH); if (path == null) @@ -41,6 +42,7 @@ public class RemoveAction extends ProvisioningAction { return Status.OK_STATUS; } + @Override public IStatus undo(Map<String, Object> parameters) { // Does not have to do anything as the backup will restore what was deleted return Status.OK_STATUS; diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RmdirAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RmdirAction.java index d333b6e54..63bd8e7b8 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RmdirAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/RmdirAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import org.eclipse.osgi.util.NLS; public class RmdirAction extends ProvisioningAction { public static final String ID = "rmdir"; //$NON-NLS-1$ + @Override public IStatus execute(Map<String, Object> parameters) { String path = (String) parameters.get(ActionConstants.PARM_PATH); if (path == null) @@ -47,6 +48,7 @@ public class RmdirAction extends ProvisioningAction { return Status.OK_STATUS; } + @Override public IStatus undo(Map<String, Object> parameters) { String path = (String) parameters.get(ActionConstants.PARM_PATH); IBackupStore store = (IBackupStore) parameters.get(NativeTouchpoint.PARM_BACKUP); diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java index 2c93bba32..4b327eca3 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/UnzipAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,10 +28,12 @@ public class UnzipAction extends ProvisioningAction { public static final String ACTION_UNZIP = "unzip"; //$NON-NLS-1$ private Value<String[]> result; + @Override public IStatus execute(Map<String, Object> parameters) { return unzip(parameters, true); } + @Override public IStatus undo(Map<String, Object> parameters) { return CleanupzipAction.cleanupzip(parameters, false); } @@ -75,7 +77,7 @@ public class UnzipAction extends ProvisioningAction { for (int i = 0; i < unzippedFiles.length; i++) { filesAsString[i] = unzippedFiles[i].getAbsolutePath(); } - result = new Value<String[]>(filesAsString); + result = new Value<>(filesAsString); StringBuffer unzippedFileNameBuffer = new StringBuffer(); for (int i = 0; i < unzippedFiles.length; i++) |