Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2019-07-16 04:00:34 -0400
committerAlexander Kurtakov2019-07-16 04:00:34 -0400
commit1139fc56935d12b70b4aa796b3bb1dc4eca459eb (patch)
tree9e83e587f672376a3af83e8f7b798991d8d3d1bb
parent6af6fa3dcf4f338c9e38cd56a6a49af613a78d01 (diff)
downloadrt.equinox.p2-1139fc56935d12b70b4aa796b3bb1dc4eca459eb.tar.gz
rt.equinox.p2-1139fc56935d12b70b4aa796b3bb1dc4eca459eb.tar.xz
rt.equinox.p2-1139fc56935d12b70b4aa796b3bb1dc4eca459eb.zip
Convert to the generic IProvisioningAgent.getService()
Take 3. Change-Id: I1509b415bfda56813884a6410c3b12161ddcf883 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java71
-rw-r--r--bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java61
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativePackageExtractionApplication.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/NativeTouchpoint.java58
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java91
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java95
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java6
-rwxr-xr-xbundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportImpl.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java82
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationPage.java69
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java144
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java89
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java88
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java77
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java308
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java89
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java172
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/artifact/UpdateSiteArtifactRepositoryFactory.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepositoryFactory.java16
36 files changed, 1339 insertions, 902 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
index c752aa214..6bdbd928f 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
@@ -118,7 +118,7 @@ public class Engine implements IEngine {
if (monitor == null)
monitor = new NullProgressMonitor();
- ActionManager actionManager = (ActionManager) agent.getService(ActionManager.SERVICE_NAME);
+ ActionManager actionManager = agent.getService(ActionManager.class);
return phaseSet.validate(actionManager, iprofile, operands, context, monitor);
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index b14e6c758..a4697f17b 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -8,8 +8,8 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
+ *
+ * Contributors:
* IBM Corporation - initial API and implementation
* Ericsson AB - ongoing development
* Red Hat, Inc. - fragments support added, Bug 460967
@@ -59,7 +59,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
protected final IProvisioningAgent agent;
/**
- * Reference to Map of String(Profile id)->Profile.
+ * Reference to Map of String(Profile id)->Profile.
*/
private SoftReference<Map<String, Profile>> profiles;
private Map<String, ProfileLock> profileLocks = new HashMap<>();
@@ -109,7 +109,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
//we are the registry for the currently running system
self = context.getProperty("eclipse.p2.profile"); //$NON-NLS-1$
} else if (agent.getService(IProvisioningAgent.SHARED_CURRENT_AGENT) != null) {
- // In shared mode, _SELF_ is the value of the current running profile for both agents current and shared
+ // In shared mode, _SELF_ is the value of the current running profile for both agents current and shared
if (((IProvisioningAgent) agent.getService(IProvisioningAgent.SHARED_CURRENT_AGENT)).getService(IProvisioningAgent.SHARED_BASE_AGENT) == agent) {
self = context.getProperty("eclipse.p2.profile"); //$NON-NLS-1$
}
@@ -232,12 +232,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
if (!profileDirectory.isDirectory())
return new long[0];
- File[] profileFiles = profileDirectory.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return (pathname.getName().endsWith(PROFILE_EXT) || pathname.getName().endsWith(PROFILE_GZ_EXT)) && pathname.isFile() && !pathname.getName().startsWith("._"); //$NON-NLS-1$
- }
- });
+ File[] profileFiles = profileDirectory.listFiles((FileFilter) pathname -> (pathname.getName().endsWith(PROFILE_EXT) || pathname.getName().endsWith(PROFILE_GZ_EXT)) && pathname.isFile() && !pathname.getName().startsWith("._"));
long[] timestamps = new long[profileFiles.length];
for (int i = 0; i < profileFiles.length; i++) {
@@ -273,7 +268,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
return null;
if (resetProfile) {
- //Now that we created a new profile. Tag it, override the property and register the timestamp in the agent registry for pickup by other
+ //Now that we created a new profile. Tag it, override the property and register the timestamp in the agent registry for pickup by other
internalSetProfileStateProperty(profile, profile.getTimestamp(), IProfile.STATE_PROP_SHARED_INSTALL, IProfile.STATE_SHARED_INSTALL_VALUE_NEW);
internalSetProfileStateProperty(profile, profile.getTimestamp(), SIMPLE_PROFILE_REGISTRY_INTERNAL + getBaseTimestamp(profile.getProfileId()), getBaseTimestamp(id));
//fragments support - remeber the property
@@ -333,7 +328,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
IProvisioningAgent baseAgent = (IProvisioningAgent) agent.getService(IProvisioningAgent.SHARED_BASE_AGENT);
if (baseAgent == null)
return null;
- IProfileRegistry registry = (IProfileRegistry) baseAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = baseAgent.getService(IProfileRegistry.class);
if (registry == null)
return null;
long[] revisions = registry.listProfileTimestamps(id);
@@ -368,7 +363,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
}
/**
- * Returns an initialized map of String(Profile id)->Profile.
+ * Returns an initialized map of String(Profile id)->Profile.
*/
protected Map<String, Profile> getProfileMap() {
if (profiles != null) {
@@ -401,8 +396,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
current.addProperties(profile.getLocalProperties());
IQueryResult<IInstallableUnit> queryResult = profile.query(QueryUtil.createIUAnyQuery(), null);
- for (Iterator<IInstallableUnit> queryResultIt = queryResult.iterator(); queryResultIt.hasNext();) {
- IInstallableUnit iu = queryResultIt.next();
+ for (IInstallableUnit iu : queryResult) {
current.addInstallableUnit(iu);
Map<String, String> iuProperties = profile.getInstallableUnitProperties(iu);
if (iuProperties != null)
@@ -506,7 +500,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
}
FileUtils.deleteAll(profileFile);
// Ignore the return value here. If there was a problem removing the profile state
- // properties we don't want to fail the whole operation since the profile state itself
+ // properties we don't want to fail the whole operation since the profile state itself
// was removed successfully
removeProfileStateProperties(id, timestamp, null);
}
@@ -525,29 +519,24 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
throw new IllegalStateException(NLS.bind(Messages.reg_dir_not_available, store));
Parser parser = new Parser(EngineActivator.getContext(), EngineActivator.ID);
- File[] profileDirectories = store.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return pathname.getName().endsWith(PROFILE_EXT) && pathname.isDirectory();
- }
- });
+ File[] profileDirectories = store.listFiles((FileFilter) pathname -> pathname.getName().endsWith(PROFILE_EXT) && pathname.isDirectory());
// protect against NPE
if (profileDirectories == null) {
parser.getProfileMap();
}
- for (int i = 0; i < profileDirectories.length; i++) {
- String directoryName = profileDirectories[i].getName();
+ for (File profileDirectorie : profileDirectories) {
+ String directoryName = profileDirectorie.getName();
String profileId = unescape(directoryName.substring(0, directoryName.lastIndexOf(PROFILE_EXT)));
ProfileLock lock = profileLocks.get(profileId);
if (lock == null) {
- lock = new ProfileLock(this, profileDirectories[i]);
+ lock = new ProfileLock(this, profileDirectorie);
profileLocks.put(profileId, lock);
}
boolean locked = false;
if (lock.processHoldsLock() || (locked = lock.lock())) {
try {
- File profileFile = findLatestProfileFile(profileDirectories[i]);
+ File profileFile = findLatestProfileFile(profileDirectorie);
if (profileFile != null) {
try {
parser.parse(profileFile);
@@ -570,17 +559,11 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
private File findLatestProfileFile(File profileDirectory) {
File latest = null;
long latestTimestamp = 0;
- File[] profileFiles = profileDirectory.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return (pathname.getName().endsWith(PROFILE_GZ_EXT) || pathname.getName().endsWith(PROFILE_EXT)) && !pathname.isDirectory();
- }
- });
+ File[] profileFiles = profileDirectory.listFiles((FileFilter) pathname -> (pathname.getName().endsWith(PROFILE_GZ_EXT) || pathname.getName().endsWith(PROFILE_EXT)) && !pathname.isDirectory());
// protect against NPE
if (profileFiles == null)
return null;
- for (int i = 0; i < profileFiles.length; i++) {
- File profileFile = profileFiles[i];
+ for (File profileFile : profileFiles) {
String fileName = profileFile.getName();
try {
long timestamp = Long.parseLong(fileName.substring(0, fileName.indexOf(PROFILE_EXT)));
@@ -734,7 +717,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
InputStream is;
if (file.getName().endsWith(PROFILE_GZ_EXT)) {
is = new BufferedInputStream(new GZIPInputStream(new FileInputStream(file)));
- } else { // backward compatibility. SimpleProfileRegistry doesn't write non-gzipped profiles any more.
+ } else { // backward compatibility. SimpleProfileRegistry doesn't write non-gzipped profiles any more.
is = new BufferedInputStream(new FileInputStream(file));
}
parse(is);
@@ -797,8 +780,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
IInstallableUnit[] ius = profileHandler.getInstallableUnits();
if (ius != null) {
- for (int i = 0; i < ius.length; i++) {
- IInstallableUnit iu = ius[i];
+ for (IInstallableUnit iu : ius) {
profile.addInstallableUnit(iu);
Map<String, String> iuProperties = profileHandler.getIUProperties(iu);
if (iuProperties != null) {
@@ -935,12 +917,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
File profileDirectory = getProfileFolder(id);
if (!profileDirectory.isDirectory())
return false;
- File[] profileFiles = profileDirectory.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return (pathname.getName().endsWith(PROFILE_GZ_EXT) || pathname.getName().endsWith(PROFILE_EXT)) && pathname.isFile();
- }
- });
+ File[] profileFiles = profileDirectory.listFiles((FileFilter) pathname -> (pathname.getName().endsWith(PROFILE_GZ_EXT) || pathname.getName().endsWith(PROFILE_EXT)) && pathname.isFile());
return profileFiles.length > 0;
}
@@ -997,7 +974,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
}
}
- // Class representing a particular instance of a profile's state properties.
+ // Class representing a particular instance of a profile's state properties.
// Can be used for caching.
class ProfileStateProperties {
private String id;
@@ -1044,7 +1021,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
if (SELF.equals(id))
id = self;
- // if the last cached value is the one we are interested in and up-to-date
+ // if the last cached value is the one we are interested in and up-to-date
// then don't bother reading from disk
if (lastAccessedProperties != null && id.equals(lastAccessedProperties.getId()) && lastAccessedProperties.isCurrent())
return lastAccessedProperties.getProperties();
@@ -1099,8 +1076,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
Properties result = new Properties();
long[] timestamps = listProfileTimestamps(id);
HashSet<String> timestampsSet = new HashSet<>(timestamps.length);
- for (int i = 0; i < timestamps.length; i++) {
- timestampsSet.add(String.valueOf(timestamps[i]));
+ for (long timestamp : timestamps) {
+ timestampsSet.add(String.valueOf(timestamp));
}
Enumeration<Object> keys = properties.keys();
diff --git a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
index 8595fe4a4..e20476466 100644
--- a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
+++ b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
@@ -197,8 +197,8 @@ public class InstallUpdateProductOperation implements IInstallOperation {
return result;
}
- private Object getService(String name) throws CoreException {
- Object service = agent.getService(name);
+ private <T> T getService(Class<T> name) throws CoreException {
+ T service = agent.getService(name);
if (service == null)
throw fail(Messages.Op_NoServiceImpl + name);
return service;
@@ -240,10 +240,10 @@ public class InstallUpdateProductOperation implements IInstallOperation {
private void preInstall() throws CoreException {
// obtain required services
- director = (IDirector) getService(IDirector.SERVICE_NAME);
- metadataRepoMan = (IMetadataRepositoryManager) getService(IMetadataRepositoryManager.SERVICE_NAME);
- artifactRepoMan = (IArtifactRepositoryManager) getService(IArtifactRepositoryManager.SERVICE_NAME);
- profileRegistry = (IProfileRegistry) getService(IProfileRegistry.SERVICE_NAME);
+ director = getService(IDirector.class);
+ metadataRepoMan = getService(IMetadataRepositoryManager.class);
+ artifactRepoMan = getService(IArtifactRepositoryManager.class);
+ profileRegistry = getService(IProfileRegistry.class);
}
private void prepareArtifactRepositories() throws ProvisionException {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
index 04825d7fc..e2b72c675 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
@@ -24,7 +24,7 @@ import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
public class DirectorUtil {
public static IStatus validateProfile(IProfile profile) {
- IPlanner planner = (IPlanner) profile.getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = profile.getProvisioningAgent().getService(IPlanner.class);
IProfileChangeRequest pcr = planner.createChangeRequest(profile);
ProvisioningContext ctx = new ProvisioningContext(profile.getProvisioningAgent());
ctx.setMetadataRepositories(new URI[0]);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
index df9228b51..4d9ab57c2 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
@@ -49,19 +49,22 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
addRunningBundles(repositoryToGC);
addRunningFeatures(inProfile, repositoryToGC);
}
- return new MarkSet[] {new MarkSet(artifactKeyList.toArray(new IArtifactKey[artifactKeyList.size()]), repositoryToGC)};
+ return new MarkSet[] {
+ new MarkSet(artifactKeyList.toArray(new IArtifactKey[artifactKeyList.size()]), repositoryToGC) };
}
private void addRunningFeatures(IProfile profile, IArtifactRepository repositoryToGC) {
try {
- List<Feature> allFeatures = getAllFeatures(Configuration.load(new File(Util.getConfigurationFolder(profile), "org.eclipse.update/platform.xml"), null)); //$NON-NLS-1$
+ List<Feature> allFeatures = getAllFeatures(Configuration
+ .load(new File(Util.getConfigurationFolder(profile), "org.eclipse.update/platform.xml"), null)); //$NON-NLS-1$
for (Feature f : allFeatures) {
- IArtifactKey match = searchArtifact(f.getId(), Version.create(f.getVersion()), ARTIFACT_CLASSIFIER_FEATURE, repositoryToGC);
+ IArtifactKey match = searchArtifact(f.getId(), Version.create(f.getVersion()),
+ ARTIFACT_CLASSIFIER_FEATURE, repositoryToGC);
if (match != null)
artifactKeyList.add(match);
}
} catch (ProvisionException e) {
- //Ignore the exception
+ // Ignore the exception
}
}
@@ -80,7 +83,7 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
}
private IProfile getCurrentProfile(IProvisioningAgent agent) {
- IProfileRegistry pr = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry pr = agent.getService(IProfileRegistry.class);
if (pr == null)
return null;
return pr.getProfile(IProfileRegistry.SELF);
@@ -104,24 +107,30 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
artifactKeyList.addAll(findCorrespondinArtifacts(new WhatIsRunning().getBundlesBeingRun(), repo));
}
- private IArtifactKey searchArtifact(String searchedId, Version searchedVersion, String classifier, IArtifactRepository repo) {
- //This is somewhat cheating since normally we should get the artifact key from the IUs that were representing the running system (e.g. we could get that info from the rollback repo)
- VersionRange range = searchedVersion != null ? new VersionRange(searchedVersion, true, searchedVersion, true) : null;
+ private IArtifactKey searchArtifact(String searchedId, Version searchedVersion, String classifier,
+ IArtifactRepository repo) {
+ // This is somewhat cheating since normally we should get the artifact key from
+ // the IUs that were representing the running system (e.g. we could get that
+ // info from the rollback repo)
+ VersionRange range = searchedVersion != null ? new VersionRange(searchedVersion, true, searchedVersion, true)
+ : null;
ArtifactKeyQuery query = new ArtifactKeyQuery(classifier, searchedId, range);
- //TODO short-circuit the query when we find one?
+ // TODO short-circuit the query when we find one?
IQueryResult<IArtifactKey> keys = repo.query(query, null);
if (!keys.isEmpty())
return keys.iterator().next();
return null;
}
- //Find for each bundle info a corresponding artifact in repo
+ // Find for each bundle info a corresponding artifact in repo
private List<IArtifactKey> findCorrespondinArtifacts(BundleInfo[] bis, IArtifactRepository repo) {
ArrayList<IArtifactKey> toRetain = new ArrayList<IArtifactKey>();
for (int i = 0; i < bis.length; i++) {
// if version is "0.0.0", we will use null to find all versions, see bug 305710
- Version version = BundleInfo.EMPTY_VERSION.equals(bis[i].getVersion()) ? null : Version.create(bis[i].getVersion());
- IArtifactKey match = searchArtifact(bis[i].getSymbolicName(), version, ARTIFACT_CLASSIFIER_OSGI_BUNDLE, repo);
+ Version version = BundleInfo.EMPTY_VERSION.equals(bis[i].getVersion()) ? null
+ : Version.create(bis[i].getVersion());
+ IArtifactKey match = searchArtifact(bis[i].getSymbolicName(), version, ARTIFACT_CLASSIFIER_OSGI_BUNDLE,
+ repo);
if (match != null)
toRetain.add(match);
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
index 5edba125f..79d7fa4c3 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
@@ -50,20 +50,22 @@ public class Util {
*/
public static final int AGGREGATE_CACHE = 0x01;
/**
- * Bit-mask value representing the shared profile's bundle pool in a shared install
+ * Bit-mask value representing the shared profile's bundle pool in a shared
+ * install
*/
public static final int AGGREGATE_SHARED_CACHE = 0x02;
/**
- * Bit-mask value representing the extension locations, such as the dropins folder.
+ * Bit-mask value representing the extension locations, such as the dropins
+ * folder.
*/
public static final int AGGREGATE_CACHE_EXTENSIONS = 0x04;
public static IAgentLocation getAgentLocation(IProvisioningAgent agent) {
- return (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ return agent.getService(IAgentLocation.class);
}
public static IArtifactRepositoryManager getArtifactRepositoryManager(IProvisioningAgent agent) {
- return (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return agent.getService(IArtifactRepositoryManager.class);
}
public static URI getBundlePoolLocation(IProvisioningAgent agent, IProfile profile) {
@@ -76,7 +78,8 @@ public class Util {
return location.getDataArea(Activator.ID);
}
- public static synchronized IFileArtifactRepository getBundlePoolRepository(IProvisioningAgent agent, IProfile profile) {
+ public static synchronized IFileArtifactRepository getBundlePoolRepository(IProvisioningAgent agent,
+ IProfile profile) {
URI location = getBundlePoolLocation(agent, profile);
if (location == null)
return null;
@@ -89,13 +92,14 @@ public class Util {
// update site repository
return null;
} catch (ProvisionException e) {
- //the repository doesn't exist, so fall through and create a new one
+ // the repository doesn't exist, so fall through and create a new one
}
try {
String repositoryName = Messages.BundlePool;
Map<String, String> properties = new HashMap<>(1);
properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
- return (IFileArtifactRepository) manager.createRepository(location, repositoryName, REPOSITORY_TYPE, properties);
+ return (IFileArtifactRepository) manager.createRepository(location, repositoryName, REPOSITORY_TYPE,
+ properties);
} catch (ProvisionException e) {
LogHelper.log(e);
throw new IllegalArgumentException(NLS.bind(Messages.bundle_pool_not_writeable, location));
@@ -103,13 +107,16 @@ public class Util {
}
public static IFileArtifactRepository getAggregatedBundleRepository(IProvisioningAgent agent, IProfile profile) {
- return getAggregatedBundleRepository(agent, profile, AGGREGATE_CACHE | AGGREGATE_SHARED_CACHE | AGGREGATE_CACHE_EXTENSIONS);
+ return getAggregatedBundleRepository(agent, profile,
+ AGGREGATE_CACHE | AGGREGATE_SHARED_CACHE | AGGREGATE_CACHE_EXTENSIONS);
}
- public static IFileArtifactRepository getAggregatedBundleRepository(IProvisioningAgent agent, IProfile profile, int repoFilter) {
+ public static IFileArtifactRepository getAggregatedBundleRepository(IProvisioningAgent agent, IProfile profile,
+ int repoFilter) {
List<IFileArtifactRepository> bundleRepositories = new ArrayList<IFileArtifactRepository>();
- // we check for a shared bundle pool first as it should be preferred over the user bundle pool in a shared install
+ // we check for a shared bundle pool first as it should be preferred over the
+ // user bundle pool in a shared install
IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
if ((repoFilter & AGGREGATE_SHARED_CACHE) != 0) {
String sharedCache = profile.getProperty(IProfile.PROP_SHARED_CACHE);
@@ -117,10 +124,11 @@ public class Util {
try {
URI repoLocation = new File(sharedCache).toURI();
IArtifactRepository repository = manager.loadRepository(repoLocation, null);
- if (repository != null && repository instanceof IFileArtifactRepository && !bundleRepositories.contains(repository))
+ if (repository != null && repository instanceof IFileArtifactRepository
+ && !bundleRepositories.contains(repository))
bundleRepositories.add((IFileArtifactRepository) repository);
} catch (ProvisionException e) {
- //skip repository if it could not be read
+ // skip repository if it could not be read
}
}
}
@@ -139,14 +147,15 @@ public class Util {
try {
repoLocation = new URI(repo);
} catch (URISyntaxException e) {
- //in 1.0 we wrote unencoded URL strings, so try as an unencoded string
+ // in 1.0 we wrote unencoded URL strings, so try as an unencoded string
repoLocation = URIUtil.fromString(repo);
}
IArtifactRepository repository = manager.loadRepository(repoLocation, null);
- if (repository != null && repository instanceof IFileArtifactRepository && !bundleRepositories.contains(repository))
+ if (repository != null && repository instanceof IFileArtifactRepository
+ && !bundleRepositories.contains(repository))
bundleRepositories.add((IFileArtifactRepository) repository);
} catch (ProvisionException e) {
- //skip repositories that could not be read
+ // skip repositories that could not be read
} catch (URISyntaxException e) {
// unexpected, URLs should be pre-checked
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
@@ -158,17 +167,19 @@ public class Util {
return new AggregatedBundleRepository(agent, bundleRepositories);
}
- private static void getRunnableRepositories(IArtifactRepositoryManager manager, List<IFileArtifactRepository> bundleRepositories) {
+ private static void getRunnableRepositories(IArtifactRepositoryManager manager,
+ List<IFileArtifactRepository> bundleRepositories) {
URI[] localURLs = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
for (int i = 0; i < localURLs.length; i++) {
try {
IArtifactRepository candidate = manager.loadRepository(localURLs[i], new NullProgressMonitor());
if (Boolean.parseBoolean(candidate.getProperty(IArtifactRepository.PROP_RUNNABLE))) {
- if (candidate != null && candidate instanceof IFileArtifactRepository && !bundleRepositories.contains(candidate))
+ if (candidate != null && candidate instanceof IFileArtifactRepository
+ && !bundleRepositories.contains(candidate))
bundleRepositories.add((IFileArtifactRepository) candidate);
}
} catch (ProvisionException e) {
- //skip repositories that could not be read
+ // skip repositories that could not be read
}
}
}
@@ -217,7 +228,8 @@ public class Util {
// Find the actual fully populated BundleInfo used by the runtime.
BundleInfo[] bundles = config.getBundles();
for (BundleInfo bundle : bundles) {
- // Can't use BundleInfol.equals(), because bundleInfo is only partially populated.
+ // Can't use BundleInfol.equals(), because bundleInfo is only partially
+ // populated.
if (bundleInfo.getSymbolicName().equals(bundle.getSymbolicName())
&& bundleInfo.getVersion().equals(bundle.getVersion())) {
return bundle;
@@ -270,11 +282,12 @@ public class Util {
}
/*
- * Helper method to return the eclipse.home location. Return
- * null if it is unavailable.
+ * Helper method to return the eclipse.home location. Return null if it is
+ * unavailable.
*/
public static File getEclipseHome() {
- Location eclipseHome = ServiceHelper.getService(Activator.getContext(), Location.class, Location.ECLIPSE_HOME_FILTER);
+ Location eclipseHome = ServiceHelper.getService(Activator.getContext(), Location.class,
+ Location.ECLIPSE_HOME_FILTER);
if (eclipseHome == null || !eclipseHome.isSet())
return null;
URL url = eclipseHome.getURL();
@@ -284,8 +297,8 @@ public class Util {
}
/**
- * Returns the install folder for the profile, or <code>null</code>
- * if no install folder is defined.
+ * Returns the install folder for the profile, or <code>null</code> if no
+ * install folder is defined.
*/
public static File getInstallFolder(IProfile profile) {
String folder = profile.getProperty(IProfile.PROP_INSTALL_FOLDER);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
index bf74856f5..2b5a6bc56 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
@@ -30,13 +30,15 @@ public class AddRepositoryAction extends RepositoryAction {
public IStatus execute(Map<String, Object> parameters) {
try {
IProvisioningAgent agent = getAgent(parameters);
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
+ IAgentLocation agentLocation = agent.getService(IAgentLocation.class);
final RepositoryEvent event = createEvent(parameters);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
- //if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers.
+ addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(),
+ event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
+ // if provisioning into the current profile, broadcast an event to add this
+ // repository directly to the current repository managers.
if (isSelfProfile(registry, profile))
addToSelf(agent, agentLocation, event);
return Status.OK_STATUS;
@@ -53,13 +55,15 @@ public class AddRepositoryAction extends RepositoryAction {
public IStatus undo(Map<String, Object> parameters) {
try {
IProvisioningAgent agent = getAgent(parameters);
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
+ IAgentLocation agentLocation = agent.getService(IAgentLocation.class);
final RepositoryEvent event = createEvent(parameters);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryType());
- //if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers.
+ removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(),
+ event.getRepositoryType());
+ // if provisioning into the current profile, broadcast an event to add this
+ // repository directly to the current repository managers.
if (isSelfProfile(registry, profile))
removeFromSelf(agent, agentLocation, event);
return Status.OK_STATUS;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
index 59b4c1205..d0ba4bea2 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
@@ -30,13 +30,15 @@ public class RemoveRepositoryAction extends RepositoryAction {
public IStatus execute(Map<String, Object> parameters) {
try {
IProvisioningAgent agent = getAgent(parameters);
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
+ IAgentLocation agentLocation = agent.getService(IAgentLocation.class);
RepositoryEvent event = createEvent(parameters);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryType());
- //if we are provisioning into the self profile, update the current set of repositories in this configuration
+ removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(),
+ event.getRepositoryType());
+ // if we are provisioning into the self profile, update the current set of
+ // repositories in this configuration
if (isSelfProfile(registry, profile))
removeFromSelf(agent, agentLocation, event);
} catch (CoreException e) {
@@ -48,13 +50,15 @@ public class RemoveRepositoryAction extends RepositoryAction {
public IStatus undo(Map<String, Object> parameters) {
try {
IProvisioningAgent agent = getAgent(parameters);
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
+ IAgentLocation agentLocation = agent.getService(IAgentLocation.class);
RepositoryEvent event = createEvent(parameters);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
- //if we are provisioning into the self profile, update the current set of repositories in this configuration
+ addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(),
+ event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
+ // if we are provisioning into the self profile, update the current set of
+ // repositories in this configuration
if (isSelfProfile(registry, profile))
addToSelf(agent, agentLocation, event);
return Status.OK_STATUS;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
index 610812aed..0b6868dae 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
@@ -32,9 +32,10 @@ import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
/**
- * Helper base class for dealing with repositories associated with profiles. Repositories
- * are associated with a profile by encoding the repository locations in a comma-delimited
- * list in a profile property.
+ * Helper base class for dealing with repositories associated with profiles.
+ * Repositories are associated with a profile by encoding the repository
+ * locations in a comma-delimited list in a profile property.
+ *
* @see AddRepositoryAction
* @see RemoveRepositoryAction
*/
@@ -50,23 +51,25 @@ abstract class RepositoryAction extends ProvisioningAction {
private static final String KEY_NICKNAME = "nickname"; //$NON-NLS-1$
/**
- * Returns the repository manager of the given type, or <code>null</code>
- * if not available.
+ * Returns the repository manager of the given type, or <code>null</code> if not
+ * available.
*/
private static IRepositoryManager<?> getRepositoryManager(IProvisioningAgent agent, int type) {
if (type == IRepository.TYPE_METADATA) {
- return (IRepositoryManager<?>) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ return agent.getService(IMetadataRepositoryManager.class);
} else if (type == IRepository.TYPE_ARTIFACT) {
- return (IRepositoryManager<?>) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return agent.getService(IArtifactRepositoryManager.class);
}
return null;
}
/**
- * Associates the repository described by the given event with the given profile.
- * Has no effect if the repository is already associated with this profile.
+ * Associates the repository described by the given event with the given
+ * profile. Has no effect if the repository is already associated with this
+ * profile.
*/
- protected void addRepositoryToProfile(IAgentLocation agentLocation, IProfile profile, URI location, String nickname, int type, boolean enabled) {
+ protected void addRepositoryToProfile(IAgentLocation agentLocation, IProfile profile, URI location, String nickname,
+ int type, boolean enabled) {
Preferences node = getRepositoryPreferenceNode(agentLocation, profile, location, type);
int count = 0;
@@ -85,12 +88,14 @@ abstract class RepositoryAction extends ProvisioningAction {
try {
node.flush();
} catch (BackingStoreException e) {
- // TODO: perhaps an Exception should be passed backwards and associated with State
+ // TODO: perhaps an Exception should be passed backwards and associated with
+ // State
}
}
/**
- * Adds the repository corresponding to the given event to the currently running instance.
+ * Adds the repository corresponding to the given event to the currently running
+ * instance.
*/
protected void addToSelf(IProvisioningAgent agent, IAgentLocation agentLocation, RepositoryEvent event) {
IRepositoryManager<?> manager = getRepositoryManager(agent, event.getRepositoryType());
@@ -120,24 +125,28 @@ abstract class RepositoryAction extends ProvisioningAction {
protected RepositoryEvent createEvent(Map<String, Object> parameters) throws CoreException {
String parm = (String) parameters.get(ActionConstants.PARM_REPOSITORY_LOCATION);
if (parm == null)
- throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_LOCATION, getId())));
+ throw new CoreException(Util.createError(
+ NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_LOCATION, getId())));
URI location = null;
try {
location = new URI(parm);
} catch (URISyntaxException e) {
- throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_LOCATION, getId()), e));
+ throw new CoreException(Util.createError(
+ NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_LOCATION, getId()), e));
}
parm = (String) parameters.get(ActionConstants.PARM_REPOSITORY_TYPE);
if (parm == null)
- throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_TYPE, getId())));
+ throw new CoreException(Util
+ .createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_TYPE, getId())));
int type = 0;
try {
type = Integer.parseInt(parm);
} catch (NumberFormatException e) {
- throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_TYPE, getId()), e));
+ throw new CoreException(Util.createError(
+ NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_TYPE, getId()), e));
}
String name = (String) parameters.get(ActionConstants.PARM_REPOSITORY_NICKNAME);
- //default is to be enabled
+ // default is to be enabled
String enablement = (String) parameters.get(ActionConstants.PARM_REPOSITORY_ENABLEMENT);
boolean enabled = enablement == null ? true : Boolean.parseBoolean(enablement);
return RepositoryEvent.newDiscoveryEvent(location, name, type, enabled);
@@ -149,28 +158,30 @@ abstract class RepositoryAction extends ProvisioningAction {
protected abstract String getId();
/**
- * Return <code>true</code> if the given profile is the currently running profile,
- * and <code>false</code> otherwise.
+ * Return <code>true</code> if the given profile is the currently running
+ * profile, and <code>false</code> otherwise.
*/
protected boolean isSelfProfile(IProfileRegistry registry, IProfile profile) {
- //if we can't determine the current profile, assume we are running on self
+ // if we can't determine the current profile, assume we are running on self
if (profile == null)
return true;
if (registry == null)
return false;
final IProfile selfProfile = registry.getProfile(IProfileRegistry.SELF);
- //if we can't determine the self profile, assume we are running on self
+ // if we can't determine the self profile, assume we are running on self
if (selfProfile == null)
return true;
return profile.getProfileId().equals(selfProfile.getProfileId());
}
/**
- * Removes the repository corresponding to the given event from the currently running instance.
+ * Removes the repository corresponding to the given event from the currently
+ * running instance.
*/
protected void removeFromSelf(IProvisioningAgent agent, IAgentLocation agentLocation, RepositoryEvent event) {
IRepositoryManager<?> manager = getRepositoryManager(agent, event.getRepositoryType());
- Preferences node = getRepositoryPreferenceNode(agentLocation, null, event.getRepositoryLocation(), event.getRepositoryType());
+ Preferences node = getRepositoryPreferenceNode(agentLocation, null, event.getRepositoryLocation(),
+ event.getRepositoryType());
int count = getRepositoryCount(node);
// modify the repository count before (potentially) removing the preference node
setRepositoryCount(node, --count);
@@ -180,8 +191,8 @@ abstract class RepositoryAction extends ProvisioningAction {
/**
* Removes the association between the repository described by the given event
- * and the given profile. Has no effect if the location is not already associated with
- * this profile.
+ * and the given profile. Has no effect if the location is not already
+ * associated with this profile.
*/
protected void removeRepositoryFromProfile(IAgentLocation agentLocation, IProfile profile, URI location, int type) {
Preferences node = getRepositoryPreferenceNode(agentLocation, profile, location, type);
@@ -204,12 +215,13 @@ abstract class RepositoryAction extends ProvisioningAction {
try {
node.flush();
} catch (BackingStoreException e) {
- // TODO: perhaps an Exception should be passed backwards and associated with State
+ // TODO: perhaps an Exception should be passed backwards and associated with
+ // State
}
}
/*
- * Get the counter associated with a repository
+ * Get the counter associated with a repository
*/
protected int getRepositoryCount(Preferences node) {
return node.getInt(REPOSITORY_COUNT, 0);
@@ -235,12 +247,14 @@ abstract class RepositoryAction extends ProvisioningAction {
}
/*
- * Get the preference node associated with profile & location
+ * Get the preference node associated with profile & location
*/
- protected Preferences getRepositoryPreferenceNode(IAgentLocation agentLocation, IProfile profile, URI location, int type) {
+ protected Preferences getRepositoryPreferenceNode(IAgentLocation agentLocation, IProfile profile, URI location,
+ int type) {
String key = type == IRepository.TYPE_METADATA ? METADATA_REPOSITORY : ARTIFACT_REPOSITORY;
String profileId = profile == null ? IProfileRegistry.SELF : profile.getProfileId();
- return new ProfileScope(agentLocation, profileId).getNode(key + '/' + NODE_REPOSITORIES + '/' + getKey(location));
+ return new ProfileScope(agentLocation, profileId)
+ .getNode(key + '/' + NODE_REPOSITORIES + '/' + getKey(location));
}
/*
@@ -248,14 +262,14 @@ abstract class RepositoryAction extends ProvisioningAction {
*/
private String getKey(URI location) {
String key = location.toString().replace('/', '_');
- //remove trailing slash
+ // remove trailing slash
if (key.endsWith("_")) //$NON-NLS-1$
key = key.substring(0, key.length() - 1);
return key;
}
protected IProvisioningAgent getAgent(Map<String, Object> parameters) throws CoreException {
- //We shouldn't really know about the session parameter
+ // We shouldn't really know about the session parameter
IProvisioningAgent agent = (IProvisioningAgent) parameters.get("agent"); //$NON-NLS-1$
if (agent == null)
throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, "agent", getId()))); //$NON-NLS-1$
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 d2f512bd9..78795d43f 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
@@ -31,30 +31,30 @@ import org.eclipse.osgi.util.NLS;
import org.osgi.framework.ServiceReference;
public class NativePackageExtractionApplication implements IApplication {
- //Keys used in the file created by the application
+ // Keys used in the file created by the application
private static final String PROP_LAUNCHER_NAME = "launcherName"; //$NON-NLS-1$
private static final String PROP_ARCH = "arch"; //$NON-NLS-1$
private static final String PROP_DEPENDS = "depends"; //$NON-NLS-1$
- //Internal constants
+ // Internal constants
private static final String DEFAULT_VERSION_CONSTRAINT = "ge"; //$NON-NLS-1$
private static final String _ACTION_ID = "_action_id_"; //$NON-NLS-1$
private static final String PROP_P2_PROFILE = "eclipse.p2.profile"; //$NON-NLS-1$
private static final Integer EXIT_ERROR = 13;
- //Constants for arguments
+ // Constants for arguments
private static final String OPTION_TO_ANALYZE = "-toAnalyze"; //$NON-NLS-1$
private static final String OPTION_RESULT_FILE = "-output"; //$NON-NLS-1$
- //Values provided as a parameter to the application
+ // Values provided as a parameter to the application
private File installation;
private File resultFile;
- //Values derived
+ // Values derived
private IProvisioningAgent targetAgent;
private String profileId;
- //Data collected by the application
+ // Data collected by the application
private Properties extractedData = new Properties();
private Properties installCommandsProperties = new Properties();
@@ -80,7 +80,9 @@ public class NativePackageExtractionApplication implements IApplication {
private void processArguments(String[] args) throws CoreException {
if (args == null || args.length == 0) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.NativePackageExtractionApplication_MissingParameters, OPTION_TO_ANALYZE, OPTION_RESULT_FILE)));
+ throw new CoreException(new Status(IStatus.ERROR, Activator.ID,
+ NLS.bind(Messages.NativePackageExtractionApplication_MissingParameters, OPTION_TO_ANALYZE,
+ OPTION_RESULT_FILE)));
}
for (int i = 0; i < args.length; i++) {
// check for args without parameters (i.e., a flag arg)
@@ -89,7 +91,9 @@ public class NativePackageExtractionApplication implements IApplication {
if (OPTION_TO_ANALYZE.equals(opt)) {
installation = new File(getRequiredArgument(args, ++i));
if (!installation.exists())
- throw new CoreException(new Status(IStatus.ERROR, Activator.ID, Messages.NativePackageExtractionApplication_FolderNotFound + installation.getAbsolutePath()));
+ throw new CoreException(new Status(IStatus.ERROR, Activator.ID,
+ Messages.NativePackageExtractionApplication_FolderNotFound
+ + installation.getAbsolutePath()));
continue;
}
@@ -106,11 +110,12 @@ public class NativePackageExtractionApplication implements IApplication {
if (!arg.startsWith("-")) //$NON-NLS-1$
return arg;
}
- throw new ProvisionException(NLS.bind(Messages.NativePackageExtractionApplication_MissingValue, args[argIdx - 1]));
+ throw new ProvisionException(
+ NLS.bind(Messages.NativePackageExtractionApplication_MissingValue, args[argIdx - 1]));
}
private void collectData() {
- IProfileRegistry registry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = targetAgent.getService(IProfileRegistry.class);
IProfile p = registry.getProfile(profileId);
collectArchitecture(p);
collectLauncherName(p);
@@ -121,7 +126,8 @@ public class NativePackageExtractionApplication implements IApplication {
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));
+ throw new CoreException(new Status(IStatus.ERROR, Activator.ID,
+ Messages.NativePackageExtractionApplication_PersistencePb + resultFile.getAbsolutePath(), e));
}
}
@@ -169,16 +175,20 @@ public class NativePackageExtractionApplication implements IApplication {
StringTokenizer tokenizer = new StringTokenizer(instruction.getBody(), ";"); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
Map<String, String> parsedInstructions = parseInstruction(tokenizer.nextToken());
- if (parsedInstructions != null && parsedInstructions.get(_ACTION_ID).endsWith(CheckAndPromptNativePackage.ID)) {
+ if (parsedInstructions != null
+ && parsedInstructions.get(_ACTION_ID).endsWith(CheckAndPromptNativePackage.ID)) {
if ("debian".equals(parsedInstructions.get(ActionConstants.PARM_LINUX_DISTRO))) { //$NON-NLS-1$
- depends += formatAsDependsEntry(parsedInstructions.get(ActionConstants.PARM_LINUX_PACKAGE_NAME), parsedInstructions.get(ActionConstants.PARM_LINUX_PACKAGE_VERSION), parsedInstructions.get(ActionConstants.PARM_LINUX_VERSION_COMPARATOR)) + ',';
+ depends += formatAsDependsEntry(
+ parsedInstructions.get(ActionConstants.PARM_LINUX_PACKAGE_NAME),
+ parsedInstructions.get(ActionConstants.PARM_LINUX_PACKAGE_VERSION),
+ parsedInstructions.get(ActionConstants.PARM_LINUX_VERSION_COMPARATOR)) + ',';
}
}
}
}
}
}
- //pre-prend a comma, and remove the last one
+ // pre-prend a comma, and remove the last one
if (depends.length() > 0)
depends = ',' + depends.substring(0, depends.length() - 1);
@@ -199,7 +209,7 @@ public class NativePackageExtractionApplication implements IApplication {
return installCommandsProperties.getProperty(comparator, ""); //$NON-NLS-1$
}
- //Code copied from the InstructionParser class
+ // Code copied from the InstructionParser class
private Map<String, String> parseInstruction(String statement) {
Map<String, String> instructions = new HashMap<>();
@@ -227,7 +237,8 @@ public class NativePackageExtractionApplication implements IApplication {
}
private void initializeServices() throws ProvisionException {
- ServiceReference<IProvisioningAgentProvider> agentProviderRef = Activator.getContext().getServiceReference(IProvisioningAgentProvider.class);
+ ServiceReference<IProvisioningAgentProvider> agentProviderRef = Activator.getContext()
+ .getServiceReference(IProvisioningAgentProvider.class);
IProvisioningAgentProvider provider = Activator.getContext().getService(agentProviderRef);
URI p2DataArea = new File(installation, "p2").toURI(); //$NON-NLS-1$
@@ -303,7 +314,7 @@ public class NativePackageExtractionApplication implements IApplication {
@Override
public void stop() {
- //We don't handle application stopping
+ // 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 313db08bd..64d574ccd 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
@@ -62,7 +62,8 @@ public class NativeTouchpoint extends Touchpoint {
}
@Override
- public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map<String, Object> touchpointParameters) {
+ public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId,
+ Map<String, Object> touchpointParameters) {
touchpointParameters.put(PARM_BACKUP, getBackupStore(profile));
return null;
}
@@ -75,7 +76,7 @@ public class NativeTouchpoint extends Touchpoint {
@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
+ // the commit means that the backup is discarded - if that fails it is not a
// terrible problem.
return super.prepare(profile);
}
@@ -93,7 +94,7 @@ public class NativeTouchpoint extends Touchpoint {
if (packagesToInstall.size() == 0)
return;
loadInstallCommandsProperties(installCommandsProperties, distro);
- UIServices serviceUI = (UIServices) agent.getService(UIServices.SERVICE_NAME);
+ UIServices serviceUI = agent.getService(UIServices.class);
String text = Messages.PromptForNative_IntroText;
String downloadLinks = ""; //$NON-NLS-1$
List<NativePackageEntry> entriesWithoutDownloadLink = new ArrayList<>(packagesToInstall.size());
@@ -139,7 +140,7 @@ public class NativeTouchpoint extends Touchpoint {
try (InputStream is = new BufferedInputStream(new FileInputStream(f))) {
properties.load(is);
} catch (IOException e) {
- //fallthrough to return empty string
+ // fallthrough to return empty string
}
}
@@ -170,7 +171,8 @@ public class NativeTouchpoint extends Touchpoint {
}
/**
- * Converts a profile id into a string that can be used as a file name in any file system.
+ * Converts a profile id into a string that can be used as a file name in any
+ * file system.
*/
public static String escape(String toEscape) {
StringBuffer buffer = new StringBuffer();
@@ -178,20 +180,20 @@ public class NativeTouchpoint extends Touchpoint {
for (int i = 0; i < length; ++i) {
char ch = toEscape.charAt(i);
switch (ch) {
- case '\\' :
- case '/' :
- case ':' :
- case '*' :
- case '?' :
- case '"' :
- case '<' :
- case '>' :
- case '|' :
- case '%' :
- buffer.append("%" + (int) ch + ";"); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- default :
- buffer.append(ch);
+ case '\\':
+ case '/':
+ case ':':
+ case '*':
+ case '?':
+ case '"':
+ case '<':
+ case '>':
+ case '|':
+ case '%':
+ buffer.append("%" + (int) ch + ";"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ default:
+ buffer.append(ch);
}
}
return buffer.toString();
@@ -204,25 +206,28 @@ public class NativeTouchpoint extends Touchpoint {
try {
store.restore();
} catch (IOException e) {
- returnStatus = new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.failed_backup_restore, store.getBackupName()), e);
+ returnStatus = new Status(IStatus.ERROR, Activator.ID,
+ NLS.bind(Messages.failed_backup_restore, store.getBackupName()), e);
} catch (ClosedBackupStoreException e) {
- returnStatus = new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.failed_backup_restore, store.getBackupName()), e);
+ returnStatus = new Status(IStatus.ERROR, Activator.ID,
+ NLS.bind(Messages.failed_backup_restore, store.getBackupName()), e);
}
clearProfileState(profile);
return returnStatus;
}
public static File getFileFromBundle(String distro, String file) {
- URL[] installScripts = FileLocator.findEntries(Activator.getContext().getBundle(), new Path(NativeTouchpoint.FOLDER + '/' + distro + '/' + file));
+ URL[] installScripts = FileLocator.findEntries(Activator.getContext().getBundle(),
+ new Path(NativeTouchpoint.FOLDER + '/' + distro + '/' + file));
if (installScripts.length == 0)
return null;
try {
return URIUtil.toFile(URIUtil.toURI(FileLocator.toFileURL(installScripts[0])));
} catch (URISyntaxException e) {
- //Can't happen, the URI is returned by OSGi
+ // Can't happen, the URI is returned by OSGi
} catch (IOException e) {
- //continue to return null
+ // continue to return null
}
return null;
}
@@ -235,8 +240,9 @@ public class NativeTouchpoint extends Touchpoint {
}
/**
- * Gets the transactional state associated with a profile. A transactional state is
- * created if it did not exist.
+ * Gets the transactional state associated with a profile. A transactional state
+ * is created if it did not exist.
+ *
* @param profile
* @return a lazily initialized backup store
*/
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 cc560ebe7..d867d5ada 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
@@ -44,11 +44,11 @@ public class Util {
}
private static IAgentLocation getAgentLocation(IProvisioningAgent agent) {
- return (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ return agent.getService(IAgentLocation.class);
}
public static IArtifactRepositoryManager getArtifactRepositoryManager(IProvisioningAgent agent) {
- return (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return agent.getService(IArtifactRepositoryManager.class);
}
public static IFileArtifactRepository getDownloadCacheRepo(IProvisioningAgent agent) throws ProvisionException {
@@ -66,7 +66,8 @@ public class Util {
String repositoryName = location + " - Agent download cache"; //$NON-NLS-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);
+ repository = manager.createRepository(location, repositoryName,
+ IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
}
IFileArtifactRepository downloadCache = repository.getAdapter(IFileArtifactRepository.class);
@@ -83,22 +84,28 @@ public class Util {
}
/**
- * Unzip from a File to an output directory, with progress indication and backup.
- * monitor and backup store may be null.
+ * Unzip from a File to an output directory, with progress indication and
+ * backup. monitor and backup store may be null.
*/
- public static File[] unzipFile(File zipFile, File outputDir, IBackupStore store, String taskName, IProgressMonitor monitor) throws IOException {
- return unzipFile(zipFile, outputDir, null /*path*/, null /*includes*/, null /*excludes*/, store, taskName, monitor);
+ public static File[] unzipFile(File zipFile, File outputDir, IBackupStore store, String taskName,
+ IProgressMonitor monitor) throws IOException {
+ return unzipFile(zipFile, outputDir, null /* path */, null /* includes */, null /* excludes */, store, taskName,
+ monitor);
}
/**
- * Unzip from a File to an output directory, with progress indication and backup.
- * monitor and backup store may be null.
- * It takes in count exclude/exclude pattern (that can be null, case when everything is unzipped).
- * 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.
+ * Unzip from a File to an output directory, with progress indication and
+ * backup. monitor and backup store may be null. It takes in count
+ * exclude/exclude pattern (that can be null, case when everything is unzipped).
+ * 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 {
+ public static File[] unzipFile(File zipFile, File outputDir, String path, String[] includePatterns,
+ String[] excludePatterns, IBackupStore store, String taskName, IProgressMonitor monitor)
+ throws IOException {
try (InputStream in = new FileInputStream(zipFile)) {
- return unzipStream(in, zipFile.length(), outputDir, path, includePatterns, excludePatterns, store, taskName, monitor);
+ 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()));
@@ -108,21 +115,27 @@ public class Util {
}
/**
- * Unzip from an InputStream to an output directory using backup of overwritten files
- * if backup store is not null.
+ * Unzip from an InputStream to an output directory using backup of overwritten
+ * files if backup store is not null.
*/
- public static File[] unzipStream(InputStream stream, long size, File outputDir, IBackupStore store, String taskName, IProgressMonitor monitor) throws IOException {
- return unzipStream(stream, size, outputDir, null /*path*/, null /*includes*/, null /*excludes*/, store, taskName, monitor);
+ public static File[] unzipStream(InputStream stream, long size, File outputDir, IBackupStore store, String taskName,
+ IProgressMonitor monitor) throws IOException {
+ return unzipStream(stream, size, outputDir, null /* path */, null /* includes */, null /* excludes */, store,
+ taskName, monitor);
}
/**
- * Unzip from an InputStream to an output directory using backup of overwritten files
- * if backup store is not null.
- * It takes in count exclude/exclude pattern (that can be null, case when everything is unzipped).
- * 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.
+ * Unzip from an InputStream to an output directory using backup of overwritten
+ * files if backup store is not null. It takes in count exclude/exclude pattern
+ * (that can be null, case when everything is unzipped). 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[] 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
+ 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
try (ZipInputStream in = new ZipInputStream(new BufferedInputStream(is))) {
ZipEntry ze = in.getNextEntry();
if (ze == null) {
@@ -220,11 +233,11 @@ public class Util {
}
/**
- * Copy an input stream to an output stream.
- * Optionally close the streams when done.
- * Return the number of bytes written.
+ * Copy an input stream to an output stream. Optionally close the streams when
+ * done. Return the number of bytes written.
*/
- public static int copyStream(InputStream in, boolean closeIn, OutputStream out, boolean closeOut) throws IOException {
+ public static int copyStream(InputStream in, boolean closeIn, OutputStream out, boolean closeOut)
+ throws IOException {
try {
int written = 0;
byte[] buffer = new byte[16 * 1024];
@@ -251,18 +264,18 @@ public class Util {
StringBuffer sb = new StringBuffer();
for (int c = 0; c < pattern.length(); c++) {
switch (pattern.charAt(c)) {
- case '.' :
- sb.append("\\."); //$NON-NLS-1$
- break;
- case '*' :
- sb.append(".*"); //$NON-NLS-1$
- break;
- case '?' :
- sb.append(".?"); //$NON-NLS-1$
- break;
- default :
- sb.append(pattern.charAt(c));
- break;
+ case '.':
+ sb.append("\\."); //$NON-NLS-1$
+ break;
+ case '*':
+ sb.append(".*"); //$NON-NLS-1$
+ break;
+ case '?':
+ sb.append(".?"); //$NON-NLS-1$
+ break;
+ default:
+ sb.append(pattern.charAt(c));
+ break;
}
}
String string = sb.toString();
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
index 22c2a4bda..ba13b7fc4 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/RepositoryTransport.java
@@ -35,8 +35,8 @@ import org.eclipse.osgi.util.NLS;
/**
* RepositoryTransport adapts p2 to ECF file download and file browsing.
- * Download is performed by {@link FileReader}, and file browsing is performed by
- * {@link FileInfoReader}.
+ * Download is performed by {@link FileReader}, and file browsing is performed
+ * by {@link FileInfoReader}.
*/
public class RepositoryTransport extends Transport {
@@ -47,12 +47,12 @@ public class RepositoryTransport extends Transport {
/**
* Returns an shared instance of Generic Transport
*/
- // public static synchronized RepositoryTransport getInstance() {
- // if (instance == null) {
- // instance = new RepositoryTransport();
- // }
- // return instance;
- // }
+ // public static synchronized RepositoryTransport getInstance() {
+ // if (instance == null) {
+ // instance = new RepositoryTransport();
+ // }
+ // return instance;
+ // }
public RepositoryTransport() {
this(null);
@@ -60,8 +60,9 @@ public class RepositoryTransport extends Transport {
/**
*
- * @param agent If agent is <code>null</code>, it means client would like to use RepositoryTransport as a download utility,
- * don't want to publish download progress.
+ * @param agent If agent is <code>null</code>, it means client would like to use
+ * RepositoryTransport as a download utility, don't want to publish
+ * download progress.
*/
public RepositoryTransport(IProvisioningAgent agent) {
this.agent = agent;
@@ -77,7 +78,9 @@ public class RepositoryTransport extends Transport {
FileReader reader = null;
try {
loginDetails = Credentials.forLocation(toDownload, promptUser, loginDetails);
- IConnectContext context = (loginDetails == null) ? null : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(), loginDetails.getPassword());
+ IConnectContext context = (loginDetails == null) ? null
+ : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(),
+ loginDetails.getPassword());
// perform the download
reader = new FileReader(agent, context);
@@ -85,14 +88,16 @@ public class RepositoryTransport extends Transport {
IProvisioningEventBus eventBus = null;
try {
if (agent != null) {
- eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ eventBus = agent.getService(IProvisioningEventBus.class);
if (eventBus != null) {
final FileReader fileReader = reader;
listener = event -> {
if (event instanceof DownloadPauseResumeEvent) {
- if (((DownloadPauseResumeEvent) event).getType() == DownloadPauseResumeEvent.TYPE_PAUSE)
+ if (((DownloadPauseResumeEvent) event)
+ .getType() == DownloadPauseResumeEvent.TYPE_PAUSE)
fileReader.pause();
- else if (((DownloadPauseResumeEvent) event).getType() == DownloadPauseResumeEvent.TYPE_RESUME)
+ else if (((DownloadPauseResumeEvent) event)
+ .getType() == DownloadPauseResumeEvent.TYPE_RESUME)
fileReader.resume();
}
};
@@ -110,7 +115,8 @@ public class RepositoryTransport extends Transport {
IStatus result = reader.getResult();
if (result == null) {
String msg = NLS.bind(Messages.RepositoryTransport_failedReadRepo, toDownload);
- DownloadStatus ds = new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, null);
+ DownloadStatus ds = new DownloadStatus(IStatus.ERROR, Activator.ID,
+ ProvisionException.REPOSITORY_FAILED_READ, msg, null);
return statusOn(target, ds, reader);
}
if (result.getSeverity() == IStatus.CANCEL)
@@ -136,7 +142,8 @@ public class RepositoryTransport extends Transport {
} catch (AuthenticationFailedException e) {
promptUser = true;
} catch (Credentials.LoginCanceledException e) {
- DownloadStatus status = new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_AUTHENTICATION, //
+ DownloadStatus status = new DownloadStatus(IStatus.ERROR, Activator.ID,
+ ProvisionException.REPOSITORY_FAILED_AUTHENTICATION, //
NLS.bind(Messages.UnableToRead_0_UserCanceled, toDownload), null);
return statusOn(target, status, null);
} catch (JREHttpClientRequiredException e) {
@@ -148,7 +155,8 @@ public class RepositoryTransport extends Transport {
}
}
// reached maximum number of retries without success
- DownloadStatus status = new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_AUTHENTICATION, //
+ DownloadStatus status = new DownloadStatus(IStatus.ERROR, Activator.ID,
+ ProvisionException.REPOSITORY_FAILED_AUTHENTICATION, //
NLS.bind(Messages.UnableToRead_0_TooManyAttempts, toDownload), null);
return statusOn(target, status, null);
}
@@ -159,7 +167,8 @@ public class RepositoryTransport extends Transport {
}
@Override
- public InputStream stream(URI toDownload, IProgressMonitor monitor) throws FileNotFoundException, CoreException, AuthenticationFailedException {
+ public InputStream stream(URI toDownload, IProgressMonitor monitor)
+ throws FileNotFoundException, CoreException, AuthenticationFailedException {
boolean promptUser = false;
boolean useJREHttp = false;
@@ -168,7 +177,9 @@ public class RepositoryTransport extends Transport {
FileReader reader = null;
try {
loginDetails = Credentials.forLocation(toDownload, promptUser, loginDetails);
- IConnectContext context = (loginDetails == null) ? null : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(), loginDetails.getPassword());
+ IConnectContext context = (loginDetails == null) ? null
+ : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(),
+ loginDetails.getPassword());
// perform the streamed download
reader = new FileReader(agent, context);
@@ -178,7 +189,8 @@ public class RepositoryTransport extends Transport {
} catch (AuthenticationFailedException e) {
promptUser = true;
} catch (CoreException e) {
- // must translate this core exception as it is most likely not informative to a user
+ // must translate this core exception as it is most likely not informative to a
+ // user
if (e.getStatus().getException() == null)
throw new CoreException(RepositoryStatus.forException(e, toDownload));
throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
@@ -197,8 +209,9 @@ public class RepositoryTransport extends Transport {
}
/**
- * Set the status on the output stream if it implements IStateful.
- * Update the DownloadStatus with information from FileReader.
+ * Set the status on the output stream if it implements IStateful. Update the
+ * DownloadStatus with information from FileReader.
+ *
* @param target an OutputStream possibly implementing IStateful
* @param status a DownloadStatus configured with status message, code, etc
* @param reader a FileReade that was used to download (or null if not known).
@@ -220,21 +233,25 @@ public class RepositoryTransport extends Transport {
}
@Override
- public long getLastModified(URI toDownload, IProgressMonitor monitor) throws CoreException, FileNotFoundException, AuthenticationFailedException {
+ public long getLastModified(URI toDownload, IProgressMonitor monitor)
+ throws CoreException, FileNotFoundException, AuthenticationFailedException {
boolean promptUser = false;
boolean useJREHttp = false;
AuthenticationInfo loginDetails = null;
for (int i = RepositoryPreferences.getLoginRetryCount(); i > 0; i--) {
try {
loginDetails = Credentials.forLocation(toDownload, promptUser, loginDetails);
- IConnectContext context = (loginDetails == null) ? null : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(), loginDetails.getPassword());
+ IConnectContext context = (loginDetails == null) ? null
+ : ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(),
+ loginDetails.getPassword());
// get the remote info
FileInfoReader reader = new FileInfoReader(context);
return reader.getLastModified(toDownload, monitor);
} catch (UserCancelledException e) {
throw new OperationCanceledException();
} catch (CoreException e) {
- // must translate this core exception as it is most likely not informative to a user
+ // must translate this core exception as it is most likely not informative to a
+ // user
if (e.getStatus().getException() == null)
throw new CoreException(RepositoryStatus.forException(e, toDownload));
throw new CoreException(RepositoryStatus.forStatus(e.getStatus(), toDownload));
@@ -267,7 +284,8 @@ public class RepositoryTransport extends Transport {
public static DownloadStatus forStatus(IStatus original, URI toDownload) {
Throwable t = original.getException();
if (isForgiveableException(t) && original.getCode() == IArtifactRepository.CODE_RETRY)
- return new DownloadStatus(original.getSeverity(), Activator.ID, original.getCode(), original.getMessage(), t);
+ return new DownloadStatus(original.getSeverity(), Activator.ID, original.getCode(), original.getMessage(),
+ t);
return forException(t, toDownload);
}
@@ -292,7 +310,10 @@ public class RepositoryTransport extends Transport {
}
if (retryCount != null) {
socketExceptionRetry.put(toDownload, retryCount);
- return new DownloadStatus(IStatus.ERROR, Activator.ID, IArtifactRepository.CODE_RETRY, NLS.bind(Messages.connection_to_0_failed_on_1_retry_attempt_2, new String[] {toDownload.toString(), t.getMessage(), retryCount.toString()}), t);
+ return new DownloadStatus(IStatus.ERROR, Activator.ID, IArtifactRepository.CODE_RETRY,
+ NLS.bind(Messages.connection_to_0_failed_on_1_retry_attempt_2, new String[] {
+ toDownload.toString(), t.getMessage(), retryCount.toString() }),
+ t);
}
}
} catch (NumberFormatException e) {
@@ -300,18 +321,23 @@ public class RepositoryTransport extends Transport {
}
}
}
- if (t instanceof FileNotFoundException || (t instanceof IncomingFileTransferException && ((IncomingFileTransferException) t).getErrorCode() == 404))
- return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.ARTIFACT_NOT_FOUND, NLS.bind(Messages.artifact_not_found, toDownload), t);
+ if (t instanceof FileNotFoundException || (t instanceof IncomingFileTransferException
+ && ((IncomingFileTransferException) t).getErrorCode() == 404))
+ return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.ARTIFACT_NOT_FOUND,
+ NLS.bind(Messages.artifact_not_found, toDownload), t);
if (t instanceof ConnectException)
- return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, NLS.bind(Messages.TransportErrorTranslator_UnableToConnectToRepository_0, toDownload), t);
+ return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ,
+ NLS.bind(Messages.TransportErrorTranslator_UnableToConnectToRepository_0, toDownload), t);
if (t instanceof UnknownHostException)
- return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t);
+ return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION,
+ NLS.bind(Messages.TransportErrorTranslator_UnknownHost, toDownload), t);
if (t instanceof IDCreateException) {
IStatus status = ((IDCreateException) t).getStatus();
if (status != null && status.getException() != null)
t = status.getException();
- return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION, NLS.bind(Messages.TransportErrorTranslator_MalformedRemoteFileReference, toDownload), t);
+ return new DownloadStatus(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_INVALID_LOCATION,
+ NLS.bind(Messages.TransportErrorTranslator_MalformedRemoteFileReference, toDownload), t);
}
int code = 0;
@@ -323,8 +349,9 @@ public class RepositoryTransport extends Transport {
else if (t instanceof BrowseFileTransferException)
code = ((BrowseFileTransferException) t).getErrorCode();
- // Switch on error codes in the HTTP error code range.
- // Note that 404 uses ARTIFACT_NOT_FOUND (as opposed to REPOSITORY_NOT_FOUND, which
+ // Switch on error codes in the HTTP error code range.
+ // Note that 404 uses ARTIFACT_NOT_FOUND (as opposed to REPOSITORY_NOT_FOUND,
+ // which
// is determined higher up in the calling chain).
if (code == 401)
provisionCode = ProvisionException.REPOSITORY_FAILED_AUTHENTICATION;
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
index 549f21046..62c44ce32 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvAdminUIActivator.java
@@ -58,11 +58,10 @@ public class ProvAdminUIActivator extends AbstractUIPlugin {
}
/**
- * Returns an image descriptor for the image file at the given plug-in
- * relative path
+ * Returns an image descriptor for the image file at the given plug-in relative
+ * path
*
- * @param path
- * the path
+ * @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
@@ -117,7 +116,8 @@ public class ProvAdminUIActivator extends AbstractUIPlugin {
tracker.setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_ALL);
}
// store in ui prefs
- policy.setShowLatestVersionsOnly(getPreferenceStore().getBoolean(PreferenceConstants.PREF_COLLAPSE_IU_VERSIONS));
+ policy.setShowLatestVersionsOnly(
+ getPreferenceStore().getBoolean(PreferenceConstants.PREF_COLLAPSE_IU_VERSIONS));
policy.setGroupByCategory(getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_CATEGORIES));
}
@@ -137,7 +137,7 @@ public class ProvAdminUIActivator extends AbstractUIPlugin {
public IProfileRegistry getProfileRegistry() {
IProvisioningAgent agent = ServiceHelper.getService(context, IProvisioningAgent.class);
- return (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ return agent.getService(IProfileRegistry.class);
}
public ProvisioningUI getProvisioningUI(String profileId) {
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java
index db50ff488..e93fc9753 100644
--- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java
@@ -37,9 +37,10 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
/**
- * A job that configures a p2 install action for installing one or more {@link CatalogItem
- * connectors}. The bulk of the installation work is done by p2; this class just sets up the p2 repository meta-data and
- * selects the appropriate features to install. After running the job the install action
+ * A job that configures a p2 install action for installing one or more
+ * {@link CatalogItem connectors}. The bulk of the installation work is done by
+ * p2; this class just sets up the p2 repository meta-data and selects the
+ * appropriate features to install. After running the job the install action
* must be run to perform the installation.
*
* @author David Green
@@ -64,23 +65,28 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
@Override
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
- SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.InstallConnectorsJob_task_configuring, 150);
+ SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.InstallConnectorsJob_task_configuring,
+ 150);
try {
final IInstallableUnit[] ius = computeInstallableUnits(monitor.newChild(50));
checkCancelled(monitor);
- final InstallOperation installOperation = resolve(monitor.newChild(50), ius, repositoryLocations.toArray(new URI[0]));
+ final InstallOperation installOperation = resolve(monitor.newChild(50), ius,
+ repositoryLocations.toArray(new URI[0]));
checkCancelled(monitor);
if (installOperation.getResolutionResult().getSeverity() > IStatus.WARNING) {
monitor.setTaskName(ProvUIMessages.ProvisioningOperationWizard_Remediation_Operation);
- final RemediationOperation remediationOperation = new RemediationOperation(provisioningUI.getSession(), installOperation.getProfileChangeRequest());
+ final RemediationOperation remediationOperation = new RemediationOperation(
+ provisioningUI.getSession(), installOperation.getProfileChangeRequest());
remediationOperation.resolveModal(monitor.newChild(50));
- Display.getDefault().asyncExec(() -> provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, remediationOperation, null));
+ Display.getDefault().asyncExec(() -> provisioningUI.openInstallWizard(Arrays.asList(ius),
+ installOperation, remediationOperation, null));
} else {
- Display.getDefault().asyncExec(() -> provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, null));
+ Display.getDefault().asyncExec(
+ () -> provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, null));
}
} finally {
monitor.done();
@@ -114,43 +120,51 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
checkForUnavailable(installableUnits);
return installableUnits.toArray(new IInstallableUnit[installableUnits.size()]);
- // MultiStatus status = new MultiStatus(DiscoveryUi.ID_PLUGIN, 0, Messages.PrepareInstallProfileJob_ok, null);
- // ius = installableUnits.toArray(new IInstallableUnit[installableUnits.size()]);
- // ProfileChangeRequest profileChangeRequest = InstallAction.computeProfileChangeRequest(ius, profileId,
- // status, new SubProgressMonitor(monitor, installableConnectors.size()));
- // if (status.getSeverity() > IStatus.WARNING) {
- // throw new CoreException(status);
- // }
- // if (profileChangeRequest == null) {
- // // failed but no indication as to why
- // throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN,
- // Messages.PrepareInstallProfileJob_computeProfileChangeRequestFailed, null));
- // }
- // PlannerResolutionOperation operation = new PlannerResolutionOperation(
- // Messages.PrepareInstallProfileJob_calculatingRequirements, profileId, profileChangeRequest, null,
- // status, true);
- // IStatus operationStatus = operation.execute(new SubProgressMonitor(monitor, installableConnectors.size()));
- // if (operationStatus.getSeverity() > IStatus.WARNING) {
- // throw new CoreException(operationStatus);
- // }
+ // MultiStatus status = new MultiStatus(DiscoveryUi.ID_PLUGIN, 0,
+ // Messages.PrepareInstallProfileJob_ok, null);
+ // ius = installableUnits.toArray(new
+ // IInstallableUnit[installableUnits.size()]);
+ // ProfileChangeRequest profileChangeRequest =
+ // InstallAction.computeProfileChangeRequest(ius, profileId,
+ // status, new SubProgressMonitor(monitor, installableConnectors.size()));
+ // if (status.getSeverity() > IStatus.WARNING) {
+ // throw new CoreException(status);
+ // }
+ // if (profileChangeRequest == null) {
+ // // failed but no indication as to why
+ // throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN,
+ // Messages.PrepareInstallProfileJob_computeProfileChangeRequestFailed, null));
+ // }
+ // PlannerResolutionOperation operation = new PlannerResolutionOperation(
+ // Messages.PrepareInstallProfileJob_calculatingRequirements, profileId,
+ // profileChangeRequest, null,
+ // status, true);
+ // IStatus operationStatus = operation.execute(new SubProgressMonitor(monitor,
+ // installableConnectors.size()));
+ // if (operationStatus.getSeverity() > IStatus.WARNING) {
+ // throw new CoreException(operationStatus);
+ // }
//
- // plannerResolutionOperation = operation;
+ // plannerResolutionOperation = operation;
} catch (URISyntaxException e) {
// should never happen, since we already validated URLs.
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN, Messages.InstallConnectorsJob_unexpectedError_url, e));
+ throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN,
+ Messages.InstallConnectorsJob_unexpectedError_url, e));
} catch (MalformedURLException e) {
// should never happen, since we already validated URLs.
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN, Messages.InstallConnectorsJob_unexpectedError_url, e));
+ throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN,
+ Messages.InstallConnectorsJob_unexpectedError_url, e));
} finally {
monitor.done();
}
}
/**
- * Verifies that we found what we were looking for: it's possible that we have connector descriptors that are no
- * longer available on their respective sites. In that case we must inform the user. Unfortunately this is the
- * earliest point at which we can know.
+ * Verifies that we found what we were looking for: it's possible that we have
+ * connector descriptors that are no longer available on their respective sites.
+ * In that case we must inform the user. Unfortunately this is the earliest
+ * point at which we can know.
*/
private void checkForUnavailable(final List<IInstallableUnit> installableUnits) throws CoreException {
// at least one selected connector could not be found in a repository
@@ -182,7 +196,8 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
if (detailedMessage.length() > 0) {
detailedMessage += Messages.InstallConnectorsJob_commaSeparator;
}
- detailedMessage += NLS.bind(Messages.PrepareInstallProfileJob_notFoundDescriptorDetail, new Object[] {descriptor.getName(), unavailableIds.toString(), descriptor.getSiteUrl()});
+ detailedMessage += NLS.bind(Messages.PrepareInstallProfileJob_notFoundDescriptorDetail,
+ new Object[] { descriptor.getName(), unavailableIds.toString(), descriptor.getSiteUrl() });
}
}
@@ -190,16 +205,20 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
// instead of aborting here we ask the user if they wish to proceed anyways
final boolean[] okayToProceed = new boolean[1];
final String finalMessage = message;
- Display.getDefault().syncExec(() -> okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.InstallConnectorsJob_questionProceed, NLS.bind(Messages.InstallConnectorsJob_questionProceed_long, new Object[] {finalMessage})));
+ Display.getDefault().syncExec(() -> okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(),
+ Messages.InstallConnectorsJob_questionProceed,
+ NLS.bind(Messages.InstallConnectorsJob_questionProceed_long, new Object[] { finalMessage })));
if (!okayToProceed[0]) {
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN, NLS.bind(Messages.InstallConnectorsJob_connectorsNotAvailable, detailedMessage), null));
+ throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN,
+ NLS.bind(Messages.InstallConnectorsJob_connectorsNotAvailable, detailedMessage), null));
}
}
}
/**
- * Filters those installable units that have a duplicate in the list with a higher version number. it's possible
- * that some repositories will host multiple versions of a particular feature. we assume that the user wants the
+ * Filters those installable units that have a duplicate in the list with a
+ * higher version number. it's possible that some repositories will host
+ * multiple versions of a particular feature. we assume that the user wants the
* highest version.
*/
private void removeOldVersions(final List<IInstallableUnit> installableUnits) {
@@ -221,12 +240,15 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
}
/**
- * Perform a query to get the installable units. This causes p2 to determine what features are available in each
- * repository. We select installable units by matching both the feature id and the repository; it is possible though
- * unlikely that the same feature id is available from more than one of the selected repositories, and we must
- * ensure that the user gets the one that they asked for.
+ * Perform a query to get the installable units. This causes p2 to determine
+ * what features are available in each repository. We select installable units
+ * by matching both the feature id and the repository; it is possible though
+ * unlikely that the same feature id is available from more than one of the
+ * selected repositories, and we must ensure that the user gets the one that
+ * they asked for.
*/
- private List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException {
+ private List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories)
+ throws URISyntaxException {
final List<IInstallableUnit> installableUnits = new ArrayList<>();
monitor.setWorkRemaining(repositories.size());
@@ -248,7 +270,8 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
return QueryUtil.createIUGroupQuery();
}
- private List<IMetadataRepository> addRepositories(SubMonitor monitor) throws MalformedURLException, URISyntaxException, ProvisionException {
+ private List<IMetadataRepository> addRepositories(SubMonitor monitor)
+ throws MalformedURLException, URISyntaxException, ProvisionException {
// tell p2 that it's okay to use these repositories
ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
RepositoryTracker repositoryTracker = ProvisioningUI.getDefaultUI().getRepositoryTracker();
@@ -259,9 +282,9 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
if (repositoryLocations.add(uri)) {
checkCancelled(monitor);
repositoryTracker.addRepository(uri, null, session);
- // ProvisioningUtil.addMetaDataRepository(url.toURI(), true);
- // ProvisioningUtil.addArtifactRepository(url.toURI(), true);
- // ProvisioningUtil.setColocatedRepositoryEnablement(url.toURI(), true);
+ // ProvisioningUtil.addMetaDataRepository(url.toURI(), true);
+ // ProvisioningUtil.addArtifactRepository(url.toURI(), true);
+ // ProvisioningUtil.setColocatedRepositoryEnablement(url.toURI(), true);
}
monitor.worked(1);
}
@@ -269,7 +292,8 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress {
// fetch meta-data for these repositories
ArrayList<IMetadataRepository> repositories = new ArrayList<>();
monitor.setWorkRemaining(repositories.size());
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = session.getProvisioningAgent()
+ .getService(IMetadataRepositoryManager.class);
for (URI uri : repositoryLocations) {
checkCancelled(monitor);
IMetadataRepository repository = manager.loadRepository(uri, monitor.newChild(1));
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java
index 18e2504e8..51ade4115 100644
--- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java
+++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java
@@ -110,7 +110,8 @@ public class RepositoryDiscoveryStrategy extends AbstractDiscoveryStrategy {
// fetch meta-data for these repositories
ArrayList<IMetadataRepository> repositories = new ArrayList<>();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = session.getProvisioningAgent()
+ .getService(IMetadataRepositoryManager.class);
for (URI uri : locations) {
IMetadataRepository repository = manager.loadRepository(uri, monitor.newChild(1));
repositories.add(repository);
@@ -130,7 +131,8 @@ public class RepositoryDiscoveryStrategy extends AbstractDiscoveryStrategy {
checkCancelled(monitor);
IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery(//
"id ~= /*.feature.group/ " + // //$NON-NLS-1$
- "? providedCapabilities.exists(p | p.namespace == 'org.eclipse.equinox.p2.iu' && p.name ~= /*.feature.group/) " + // //$NON-NLS-1$
+ "? providedCapabilities.exists(p | p.namespace == 'org.eclipse.equinox.p2.iu' && p.name ~= /*.feature.group/) " //$NON-NLS-1$
+ + //
": properties['org.eclipse.equinox.p2.type.category'] == true"); //$NON-NLS-1$
IQueryResult<IInstallableUnit> result = repository.query(query, monitor.newChild(1));
for (Iterator<IInstallableUnit> iter = result.iterator(); iter.hasNext();) {
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportImpl.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportImpl.java
index 89f98be40..1b4a54c51 100755
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportImpl.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/ImportExportImpl.java
@@ -51,24 +51,28 @@ public class ImportExportImpl implements P2ImportExport {
@Override
public List<IUDetail> importP2F(InputStream input) throws IOException {
- P2FParser parser = new P2FParser(Platform.getBundle(Constants.Bundle_ID).getBundleContext(), Constants.Bundle_ID);
+ P2FParser parser = new P2FParser(Platform.getBundle(Constants.Bundle_ID).getBundleContext(),
+ Constants.Bundle_ID);
parser.parse(input);
return parser.getIUs();
}
@Override
- public IStatus exportP2F(OutputStream output, IInstallableUnit[] ius, boolean allowEntriesWithoutRepo, IProgressMonitor monitor) {
+ public IStatus exportP2F(OutputStream output, IInstallableUnit[] ius, boolean allowEntriesWithoutRepo,
+ IProgressMonitor monitor) {
if (monitor == null)
monitor = new NullProgressMonitor();
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.Replicator_ExportJobName, 1000);
- //Collect repos where the IUs are going to be searched
- IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- URI[] uris = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_LOCAL | IRepositoryManager.REPOSITORIES_NON_SYSTEM);
+ // Collect repos where the IUs are going to be searched
+ IMetadataRepositoryManager repoManager = agent.getService(IMetadataRepositoryManager.class);
+ URI[] uris = repoManager.getKnownRepositories(
+ IRepositoryManager.REPOSITORIES_NON_LOCAL | IRepositoryManager.REPOSITORIES_NON_SYSTEM);
List<IMetadataRepository> repos = new ArrayList<>(uris.length);
for (URI uri : uris) {
try {
- IMetadataRepository repo = repoManager.loadRepository(uri, subMonitor.newChild(500 / uris.length, SubMonitor.SUPPRESS_ALL_LABELS));
+ IMetadataRepository repo = repoManager.loadRepository(uri,
+ subMonitor.newChild(500 / uris.length, SubMonitor.SUPPRESS_ALL_LABELS));
repos.add(repo);
} catch (ProvisionException e) {
// ignore
@@ -86,40 +90,54 @@ public class ImportExportImpl implements P2ImportExport {
SubMonitor sub3 = sub2.newChild(100);
sub3.setWorkRemaining(repos.size() * 100);
- //Search for repo matching the given IU
+ // Search for repo matching the given IU
for (IMetadataRepository repo : repos) {
- IQueryResult<IInstallableUnit> result = repo.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, true)), sub3.newChild(100));
+ IQueryResult<IInstallableUnit> result = repo.query(
+ QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, true)),
+ sub3.newChild(100));
if (!result.isEmpty())
referredRepos.add(repo.getLocation());
}
sub3.setWorkRemaining(1).worked(1);
- //Create object representing given IU
+ // Create object representing given IU
if (referredRepos.size() != 0 || (referredRepos.size() == 0 && allowEntriesWithoutRepo)) {
IUDetail iuToExport = new IUDetail(iu, referredRepos);
rootsToExport.add(iuToExport);
} else {
if (isContainedInLocalRepo(iu))
- queryRepoResult.add(new Status(IStatus.INFO, Constants.Bundle_ID, IGNORE_LOCAL_REPOSITORY, NLS.bind(Messages.Replicator_InstallFromLocal, iu.getProperty(IInstallableUnit.PROP_NAME, Locale.getDefault().toString())), null));
+ queryRepoResult
+ .add(new Status(IStatus.INFO, Constants.Bundle_ID, IGNORE_LOCAL_REPOSITORY,
+ NLS.bind(Messages.Replicator_InstallFromLocal,
+ iu.getProperty(IInstallableUnit.PROP_NAME, Locale.getDefault().toString())),
+ null));
else
- queryRepoResult.add(new Status(IStatus.WARNING, Constants.Bundle_ID, CANNOT_FIND_REPOSITORY, NLS.bind(Messages.Replicator_NotFoundInRepository, iu.getProperty(IInstallableUnit.PROP_NAME, Locale.getDefault().toString())), null));
+ queryRepoResult
+ .add(new Status(IStatus.WARNING, Constants.Bundle_ID, CANNOT_FIND_REPOSITORY,
+ NLS.bind(Messages.Replicator_NotFoundInRepository,
+ iu.getProperty(IInstallableUnit.PROP_NAME, Locale.getDefault().toString())),
+ null));
}
}
subMonitor.setWorkRemaining(50);
- //Serialize
+ // Serialize
IStatus status = exportP2F(output, rootsToExport, subMonitor);
if (status.isOK() && queryRepoResult.isOK())
return status;
- return new MultiStatus(Constants.Bundle_ID, 0, new IStatus[] {queryRepoResult, status}, null, null);
+ return new MultiStatus(Constants.Bundle_ID, 0, new IStatus[] { queryRepoResult, status }, null, null);
}
private boolean isContainedInLocalRepo(IInstallableUnit iu) {
- IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- URI[] uris = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL | IRepositoryManager.REPOSITORIES_NON_SYSTEM);
+ IMetadataRepositoryManager repoManager = agent.getService(IMetadataRepositoryManager.class);
+ URI[] uris = repoManager.getKnownRepositories(
+ IRepositoryManager.REPOSITORIES_LOCAL | IRepositoryManager.REPOSITORIES_NON_SYSTEM);
for (URI uri : uris) {
try {
IMetadataRepository repo = repoManager.loadRepository(uri, null);
- if (!repo.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, true)), null).isEmpty())
+ if (!repo
+ .query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, true)),
+ null)
+ .isEmpty())
return true;
} catch (ProvisionException e) {
// ignore
@@ -136,7 +154,8 @@ public class ImportExportImpl implements P2ImportExport {
if (sub.isCanceled())
throw new OperationCanceledException();
try {
- P2FWriter writer = new P2FWriter(output, new ProcessingInstruction[] {ProcessingInstruction.makeTargetVersionInstruction(P2FConstants.P2F_ELEMENT, P2FConstants.CURRENT_VERSION)});
+ P2FWriter writer = new P2FWriter(output, new ProcessingInstruction[] { ProcessingInstruction
+ .makeTargetVersionInstruction(P2FConstants.P2F_ELEMENT, P2FConstants.CURRENT_VERSION) });
writer.write(ius);
return Status.OK_STATUS;
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
index c2859b3c9..24f25a349 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java
@@ -72,10 +72,11 @@ public abstract class AbstractPage extends WizardPage implements Listener {
protected static final int COMBO_HISTORY_LENGTH = 5;
/**
- * {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the check state,
- * the methods {@link DeferredTreeContentManager}'s runClearPlaceholderJob and
- * DelayedFilterCheckboxTree.doCreateRefreshJob().new JobChangeAdapter() {...}.done(IJobChangeEvent) has timing issue,
- * I can't find a way to guarantee the first job is executed firstly
+ * {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the
+ * check state, the methods {@link DeferredTreeContentManager}'s
+ * runClearPlaceholderJob and DelayedFilterCheckboxTree.doCreateRefreshJob().new
+ * JobChangeAdapter() {...}.done(IJobChangeEvent) has timing issue, I can't find
+ * a way to guarantee the first job is executed firstly
*
*/
final class ImportExportFilteredTree extends FilteredTree {
@@ -183,8 +184,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
/**
- * @param sortColumn
- * The sortColumn to set.
+ * @param sortColumn The sortColumn to set.
*/
public void setSortColumn(int sortColumn) {
if (this.sortColumn != sortColumn) {
@@ -202,8 +202,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
/**
- * @param ascending
- * The ascending to set.
+ * @param ascending The ascending to set.
*/
public void setAscending(boolean ascending) {
this.ascending = ascending;
@@ -212,12 +211,13 @@ public abstract class AbstractPage extends WizardPage implements Listener {
static {
BundleContext context = Platform.getBundle(Constants.Bundle_ID).getBundleContext();
- ServiceTracker<IProvisioningAgent, IProvisioningAgent> tracker = new ServiceTracker<>(context, IProvisioningAgent.class, null);
+ ServiceTracker<IProvisioningAgent, IProvisioningAgent> tracker = new ServiceTracker<>(context,
+ IProvisioningAgent.class, null);
tracker.open();
agent = tracker.getService();
tracker.close();
if (agent != null)
- profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ profileRegistry = agent.getService(IProfileRegistry.class);
}
public AbstractPage(String pageName) {
@@ -239,7 +239,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
private void createColumns(TreeViewer treeViewer) {
- String[] titles = {Messages.Column_Name, Messages.Column_Version, Messages.Column_Id};
+ String[] titles = { Messages.Column_Name, Messages.Column_Version, Messages.Column_Id };
for (int i = 0; i < titles.length; i++) {
TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.NONE);
column.getColumn().setText(titles[i]);
@@ -248,7 +248,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
if (Messages.Column_Name.equals(titles[i]))
updateTableSorting(i);
final int columnIndex = i;
- column.getColumn().addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> updateTableSorting(columnIndex)));
+ column.getColumn().addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(event -> updateTableSorting(columnIndex)));
}
}
@@ -304,7 +305,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
restoreWidgetValues();
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
destinationNameField.setLayoutData(data);
- destinationNameField.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> handleDestinationChanged(getDestinationValue())));
+ destinationNameField.addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(event -> handleDestinationChanged(getDestinationValue())));
destinationNameField.addKeyListener(KeyListener.keyPressedAdapter(e -> {
if (e.character == SWT.CR) {
entryChanged = false;
@@ -314,7 +316,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}));
destinationNameField.addModifyListener(e -> entryChanged = true);
destinationNameField.addFocusListener(FocusListener.focusLostAdapter(e -> {
- //Clear the flag to prevent constant update
+ // Clear the flag to prevent constant update
if (entryChanged) {
entryChanged = false;
handleDestinationChanged(getDestinationValue());
@@ -338,11 +340,18 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
private boolean allowExportWithoutRepositoryReference() {
- return Platform.getPreferencesService().getBoolean(Constants.Bundle_ID, Constants.PREF_IU_WITHOUT_REPO, false, new IScopeContext[] {DefaultScope.INSTANCE});
+ return Platform.getPreferencesService().getBoolean(Constants.Bundle_ID, Constants.PREF_IU_WITHOUT_REPO, false,
+ new IScopeContext[] { DefaultScope.INSTANCE });
}
protected IUColumnConfig[] getColumnConfig() {
- return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME, ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION, ILayoutConstants.DEFAULT_SMALL_COLUMN_WIDTH), new IUColumnConfig(ProvUIMessages.ProvUI_IdColumnTitle, IUColumnConfig.COLUMN_ID, ILayoutConstants.DEFAULT_COLUMN_WIDTH)};
+ return new IUColumnConfig[] {
+ new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME,
+ ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH),
+ new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION,
+ ILayoutConstants.DEFAULT_SMALL_COLUMN_WIDTH),
+ new IUColumnConfig(ProvUIMessages.ProvUI_IdColumnTitle, IUColumnConfig.COLUMN_ID,
+ ILayoutConstants.DEFAULT_COLUMN_WIDTH) };
}
protected void createInstallationTable(final Composite parent) {
@@ -353,7 +362,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
group.setLayout(new GridLayout(1, false));
PatternFilter filter = getPatternFilter();
filter.setIncludeLeadingWildcard(true);
- final ImportExportFilteredTree filteredTree = new ImportExportFilteredTree(group, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true);
+ final ImportExportFilteredTree filteredTree = new ImportExportFilteredTree(group,
+ SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true);
viewer = (CheckboxTreeViewer) filteredTree.getViewer();
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
@@ -367,7 +377,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
viewer.addCheckStateListener(event -> {
if (!event.getChecked() && filteredTree.checkState != null) {
ArrayList<Object> toRemove = new ArrayList<>(1);
- // See bug 258117. Ideally we would get check state changes
+ // See bug 258117. Ideally we would get check state changes
// for children when the parent state changed, but we aren't, so
// we need to remove all children from the additive check state
// cache.
@@ -388,8 +398,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
for (Object element : filteredTree.checkState) {
if (viewer.getComparer().equals(element, event.getElement())) {
toRemove.add(element);
- // Do not break out of the loop. We may have duplicate equal
- // elements in the cache. Since the cache is additive, we want
+ // Do not break out of the loop. We may have duplicate equal
+ // elements in the cache. Since the cache is additive, we want
// to be sure we've gotten everything.
}
}
@@ -398,7 +408,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
});
parent.addControlListener(new ControlAdapter() {
- private final int[] columnRate = new int[] {6, 2, 2};
+ private final int[] columnRate = new int[] { 6, 2, 2 };
@Override
public void controlResized(ControlEvent e) {
@@ -416,7 +426,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
TreeColumn[] columns = tree.getColumns();
int hasUsed = 0, i = 0;
if (oldSize.x > area.width) {
- // table is getting smaller so make the columns
+ // table is getting smaller so make the columns
// smaller first and then resize the table to
// match the client area width
for (; i < columns.length - 1; i++) {
@@ -426,7 +436,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
columns[columns.length - 1].setWidth(width - hasUsed);
tree.setSize(area.width, area.height);
} else {
- // table is getting bigger so make the table
+ // table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
tree.setSize(area.width, area.height);
@@ -508,7 +518,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
protected boolean determinePageCompletion() {
currentMessage = null;
- // validate groups in order of priority so error message is the most important one
+ // validate groups in order of priority so error message is the most important
+ // one
boolean complete = validateDestinationGroup() && validateOptionsGroup();
// Avoid draw flicker by not clearing the error
@@ -530,6 +541,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
/**
* returns the destination label
+ *
* @return non null string
*/
protected abstract String getDestinationLabel();
@@ -545,6 +557,7 @@ public abstract class AbstractPage extends WizardPage implements Listener {
/**
* return the title of dialog
+ *
* @return non null string
*/
protected abstract String getDialogTitle();
@@ -560,15 +573,15 @@ public abstract class AbstractPage extends WizardPage implements Listener {
protected abstract void giveFocusToDestination();
/**
- * Open an appropriate destination browser so that the user can specify a
- * source to import from
+ * Open an appropriate destination browser so that the user can specify a source
+ * to import from
*/
protected void handleDestinationBrowseButtonPressed() {
FileDialog dialog = new FileDialog(getContainer().getShell(), getBrowseDialogStyle() | SWT.SHEET);
dialog.setText(getDialogTitle());
dialog.setFilterPath(getDestinationValue());
- dialog.setFilterExtensions(new String[] {Messages.EXTENSION_p2F, Messages.EXTENSION_ALL});
- dialog.setFilterNames(new String[] {Messages.EXTENSION_p2F_NAME, Messages.EXTENSION_ALL_NAME});
+ dialog.setFilterExtensions(new String[] { Messages.EXTENSION_p2F, Messages.EXTENSION_ALL });
+ dialog.setFilterNames(new String[] { Messages.EXTENSION_p2F_NAME, Messages.EXTENSION_ALL_NAME });
String selectedFileName = dialog.open();
if (selectedFileName != null) {
@@ -594,7 +607,8 @@ public abstract class AbstractPage extends WizardPage implements Listener {
}
protected void initializeService() {
- ServiceTracker<P2ImportExport, P2ImportExport> tracker = new ServiceTracker<>(Platform.getBundle(Constants.Bundle_ID).getBundleContext(), P2ImportExport.class.getName(), null);
+ ServiceTracker<P2ImportExport, P2ImportExport> tracker = new ServiceTracker<>(
+ Platform.getBundle(Constants.Bundle_ID).getBundleContext(), P2ImportExport.class.getName(), null);
tracker.open();
importexportService = tracker.getService();
tracker.close();
@@ -619,8 +633,9 @@ public abstract class AbstractPage extends WizardPage implements Listener {
/**
* Validate the destination group.
- * @return <code>true</code> if the group is valid. If
- * not set the error message and return <code>false</code>.
+ *
+ * @return <code>true</code> if the group is valid. If not set the error message
+ * and return <code>false</code>.
*/
protected boolean validateDestinationGroup() {
if (!validDestination()) {
@@ -703,15 +718,14 @@ public abstract class AbstractPage extends WizardPage implements Listener {
/**
* Add the passed value to self's destination widget's history
*
- * @param value
- * java.lang.String
+ * @param value java.lang.String
*/
protected void addDestinationItem(String value) {
destinationNameField.add(value);
}
void modifyDestinationValue(String destinationValue) {
- //Do nothing
+ // Do nothing
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationPage.java
index 9a2690e85..103c9e35a 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportFromInstallationPage.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 WindRiver Corporation and others.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -98,7 +98,8 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
private IProvisioningAgentProvider getAgentProvider() {
if (agentProvider == null) {
- ServiceTracker<IProvisioningAgentProvider, IProvisioningAgentProvider> tracker = new ServiceTracker<>(Platform.getBundle(Constants.Bundle_ID).getBundleContext(), IProvisioningAgentProvider.class, null);
+ ServiceTracker<IProvisioningAgentProvider, IProvisioningAgentProvider> tracker = new ServiceTracker<>(
+ Platform.getBundle(Constants.Bundle_ID).getBundleContext(), IProvisioningAgentProvider.class, null);
tracker.open();
agentProvider = tracker.getService();
tracker.close();
@@ -116,7 +117,8 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
@Override
public Boolean call() throws Exception {
- Display.getDefault().syncExec(() -> validated = ImportFromInstallationPage.super.validateDestinationGroup());
+ Display.getDefault()
+ .syncExec(() -> validated = ImportFromInstallationPage.super.validateDestinationGroup());
return validated;
}
};
@@ -177,15 +179,18 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
final String FILE_PROTOCOL = "file:"; //$NON-NLS-1$
if (url.startsWith(CONFIG_DIR))
url = FILE_PROTOCOL + url.substring(CONFIG_DIR.length());
- p2DataArea = new File(URIUtil.makeAbsolute(URIUtil.fromString(new File(url.substring(FILE_PROTOCOL.length())).isAbsolute() ? url : url.substring(FILE_PROTOCOL.length())), configArea));
+ p2DataArea = new File(URIUtil.makeAbsolute(URIUtil
+ .fromString(new File(url.substring(FILE_PROTOCOL.length())).isAbsolute() ? url
+ : url.substring(FILE_PROTOCOL.length())),
+ configArea));
}
} catch (IOException ioe) {
- //ignore
+ // ignore
} finally {
try {
is.close();
} catch (IOException ioe) {
- //ignore
+ // ignore
}
is = null;
}
@@ -206,21 +211,23 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
otherInstanceAgent = getAgentProvider().createAgent(p2DataArea.toURI());
ArtifactRepositoryFactory factory = new ExtensionLocationArtifactRepositoryFactory();
factory.setAgent(agent);
- IArtifactRepository artiRepo = factory.load(new File(destination).toURI(), 0, progress.newChild(50));
- artiURIs = new URI[] {artiRepo.getLocation()};
+ IArtifactRepository artiRepo = factory.load(new File(destination).toURI(), 0,
+ progress.newChild(50));
+ artiURIs = new URI[] { artiRepo.getLocation() };
MetadataRepositoryFactory metaFatory = new ExtensionLocationMetadataRepositoryFactory();
metaFatory.setAgent(agent);
- IMetadataRepository metaRepo = metaFatory.load(new File(destination).toURI(), 0, progress.newChild(50));
- metaURIs = new URI[] {metaRepo.getLocation()};
+ IMetadataRepository metaRepo = metaFatory.load(new File(destination).toURI(), 0,
+ progress.newChild(50));
+ metaURIs = new URI[] { metaRepo.getLocation() };
} else
throw new FileNotFoundException();
} catch (ProvisionException e) {
if (otherInstanceAgent != null) {
toBeImportedProfile = null;
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- IProfileRegistry registry = (IProfileRegistry) otherInstanceAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IMetadataRepositoryManager manager = agent.getService(IMetadataRepositoryManager.class);
+ IArtifactRepositoryManager artifactManager = agent.getService(IArtifactRepositoryManager.class);
+ IProfileRegistry registry = otherInstanceAgent.getService(IProfileRegistry.class);
if (toBeImportedProfileId != null)
toBeImportedProfile = registry.getProfile(toBeImportedProfileId);
if (toBeImportedProfile == null) {
@@ -231,18 +238,30 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
for (IProfile existingProfile : existingProfiles) {
if (toBeImportedProfile == null)
toBeImportedProfile = existingProfile;
- else if ((toBeImportedProfile.getTimestamp() < existingProfile.getTimestamp())) // assuming last modified one is we are looking for
+ else if ((toBeImportedProfile.getTimestamp() < existingProfile.getTimestamp())) // assuming
+ // last
+ // modified
+ // one
+ // is
+ // we
+ // are
+ // looking
+ // for
toBeImportedProfile = existingProfile;
}
}
}
- IAgentLocation location = (IAgentLocation) otherInstanceAgent.getService(IAgentLocation.SERVICE_NAME);
+ IAgentLocation location = otherInstanceAgent.getService(IAgentLocation.class);
URI engineDataArea = location.getDataArea("org.eclipse.equinox.p2.engine"); //$NON-NLS-1$
progress.setWorkRemaining(50);
- IMetadataRepository metaRepo = manager.loadRepository(engineDataArea.resolve("profileRegistry/" + toBeImportedProfile.getProfileId() + ".profile"), progress.newChild(25)); //$NON-NLS-1$//$NON-NLS-2$
- metaURIs = new URI[] {metaRepo.getLocation()};
- IArtifactRepository artiRepo = artifactManager.loadRepository(new File(destination).toURI(), progress.newChild(25));
- artiURIs = new URI[] {artiRepo.getLocation()};
+ IMetadataRepository metaRepo = manager.loadRepository(
+ engineDataArea
+ .resolve("profileRegistry/" + toBeImportedProfile.getProfileId() + ".profile"), //$NON-NLS-1$//$NON-NLS-2$
+ progress.newChild(25));
+ metaURIs = new URI[] { metaRepo.getLocation() };
+ IArtifactRepository artiRepo = artifactManager.loadRepository(new File(destination).toURI(),
+ progress.newChild(25));
+ artiURIs = new URI[] { artiRepo.getLocation() };
} else
throw new Exception();
}
@@ -313,8 +332,8 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
@Override
void modifyDestinationValue(String selectedFileName) {
/*
- * If the destination file is a Mac app bundle, modify the destination
- * to *.app/Contents/Eclipse if the path exists.
+ * If the destination file is a Mac app bundle, modify the destination to
+ * *.app/Contents/Eclipse if the path exists.
*/
if ("cocoa".equals(SWT.getPlatform())) { //$NON-NLS-1$
Path nPath = new Path(selectedFileName);
@@ -377,10 +396,10 @@ public class ImportFromInstallationPage extends AbstractImportPage implements IS
public void cleanLocalRepository() {
if (metaURIs != null && metaURIs.length > 0) {
IProvisioningAgent runningAgent = getProvisioningUI().getSession().getProvisioningAgent();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) runningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = runningAgent.getService(IMetadataRepositoryManager.class);
for (URI uri : metaURIs)
manager.removeRepository(uri);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) runningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager artifactManager = runningAgent.getService(IArtifactRepositoryManager.class);
for (URI uri : artiURIs)
artifactManager.removeRepository(uri);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
index f3da7126d..ccaf7553a 100644
--- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2011, 2017 WindRiver Corporation and others.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
@@ -95,14 +95,14 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
public String getColumnText(Object element, int columnIndex) {
IInstallableUnit iu = ((IUDetail) element).getIU();
switch (columnIndex) {
- case 0 :
- return getIUNameWithDetail(iu);
- case 1 :
- return iu.getVersion().toString();
- case 2 :
- return iu.getId();
- default :
- throw new RuntimeException("Should not happen"); //$NON-NLS-1$
+ case 0:
+ return getIUNameWithDetail(iu);
+ case 1:
+ return iu.getVersion().toString();
+ case 2:
+ return iu.getId();
+ default:
+ throw new RuntimeException("Should not happen"); //$NON-NLS-1$
}
}
@@ -126,7 +126,7 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
String patternString;
/**
- * Create a new instance of a AvailableIUPatternFilter
+ * Create a new instance of a AvailableIUPatternFilter
*/
public P2ImportIUPatternFilter(IUColumnConfig[] columnConfig) {
super();
@@ -148,9 +148,9 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
}
/*
- * Overridden to remember the pattern string for an optimization
- * in isParentMatch
- * (non-Javadoc)
+ * Overridden to remember the pattern string for an optimization in
+ * isParentMatch (non-Javadoc)
+ *
* @see org.eclipse.ui.dialogs.PatternFilter#setPattern(java.lang.String)
*/
@Override
@@ -160,10 +160,12 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
}
/*
- * Overridden to avoid getting children unless there is actually
- * a filter.
+ * Overridden to avoid getting children unless there is actually a filter.
* (non-Javadoc)
- * @see org.eclipse.ui.dialogs.PatternFilter#isParentMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object)
+ *
+ * @see
+ * org.eclipse.ui.dialogs.PatternFilter#isParentMatch(org.eclipse.jface.viewers.
+ * Viewer, java.lang.Object)
*/
@Override
protected boolean isParentMatch(Viewer viewer1, Object element) {
@@ -420,8 +422,8 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
public void recompute(IProgressMonitor monitor) throws InterruptedException {
SubMonitor sub = SubMonitor.convert(monitor, Messages.ImportPage_QueryFeaturesJob, 1000);
if (agent != null) {
- IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metaManager = agent.getService(IMetadataRepositoryManager.class);
+ IArtifactRepositoryManager artifactManager = agent.getService(IArtifactRepositoryManager.class);
Object[] checked = getChecked();
sub.setWorkRemaining(100 * checked.length);
for (Object item : checked) {
@@ -455,7 +457,12 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage
// don't suppress this warning as it will cause build-time warning
// see bug 423628. Find a way to change the code to not produce
// the warning.
- Set<IInstallableUnit> result = new CompoundQueryable<IInstallableUnit>(repos.toArray(new IRepository[repos.size()])).query(QueryUtil.createIUQuery(feature.getIU().getId(), new VersionRange(feature.getIU().getVersion(), true, null, false)), sub2.newChild(100)).toSet();
+ Set<IInstallableUnit> result = new CompoundQueryable<IInstallableUnit>(
+ repos.toArray(new IRepository[repos.size()]))
+ .query(QueryUtil.createIUQuery(feature.getIU().getId(),
+ new VersionRange(feature.getIU().getVersion(), true, null, false)),
+ sub2.newChild(100))
+ .toSet();
List<IUDetail> existingFeatures = new ArrayList<>(result.size());
for (IInstallableUnit iu : result) {
existingFeatures.add(new IUDetail(iu, feature.getReferencedRepositories()));
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
index 530bc7d72..12aba4601 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
@@ -45,7 +45,8 @@ public class AutomaticUpdateScheduler implements IStartup {
public static final String P_FUZZY_RECURRENCE = "fuzzy_recurrence"; //$NON-NLS-1$
- public static final String[] FUZZY_RECURRENCE = {AutomaticUpdateMessages.SchedulerStartup_OnceADay, AutomaticUpdateMessages.SchedulerStartup_OnceAWeek, AutomaticUpdateMessages.SchedulerStartup_OnceAMonth};
+ public static final String[] FUZZY_RECURRENCE = { AutomaticUpdateMessages.SchedulerStartup_OnceADay,
+ AutomaticUpdateMessages.SchedulerStartup_OnceAWeek, AutomaticUpdateMessages.SchedulerStartup_OnceAMonth };
private static final int ONE_HOUR_IN_MS = 60 * 60 * 1000;
private static final int ONE_DAY_IN_MS = 24 * ONE_HOUR_IN_MS;
@@ -59,11 +60,13 @@ public class AutomaticUpdateScheduler implements IStartup {
*/
public AutomaticUpdateScheduler() {
AutomaticUpdatePlugin.getDefault().setScheduler(this);
- IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- checker = (IUpdateChecker) agent.getService(IUpdateChecker.SERVICE_NAME);
+ IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(),
+ IProvisioningAgent.class);
+ checker = agent.getService(IUpdateChecker.class);
if (checker == null) {
// Something did not initialize properly
- IStatus status = new Status(IStatus.ERROR, AutomaticUpdatePlugin.PLUGIN_ID, AutomaticUpdateMessages.AutomaticUpdateScheduler_UpdateNotInitialized);
+ IStatus status = new Status(IStatus.ERROR, AutomaticUpdatePlugin.PLUGIN_ID,
+ AutomaticUpdateMessages.AutomaticUpdateScheduler_UpdateNotInitialized);
StatusManager.getManager().handle(status, StatusManager.LOG);
return;
}
@@ -72,8 +75,9 @@ public class AutomaticUpdateScheduler implements IStartup {
@Override
public void earlyStartup() {
- IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(),
+ IProvisioningAgent.class);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
IProfile currentProfile = registry.getProfile(profileId);
if (currentProfile != null && new MigrationSupport().performMigration(agent, registry, currentProfile))
return;
@@ -90,15 +94,16 @@ public class AutomaticUpdateScheduler implements IStartup {
// Nothing to do if we don't know what profile we are checking
if (profileId == null)
return;
- //check if gc is enabled
+ // check if gc is enabled
IPreferenceStore pref = AutomaticUpdatePlugin.getDefault().getPreferenceStore();
if (!pref.getBoolean(PreferenceConstants.PREF_GC_ON_STARTUP))
return;
- IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- GarbageCollector collector = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME);
+ IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(),
+ IProvisioningAgent.class);
+ GarbageCollector collector = agent.getService(GarbageCollector.class);
if (collector == null)
return;
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
if (registry == null)
return;
IProfile profile = registry.getProfile(profileId);
@@ -115,7 +120,7 @@ public class AutomaticUpdateScheduler implements IStartup {
removeUpdateListener();
IPreferenceStore pref = AutomaticUpdatePlugin.getDefault().getPreferenceStore();
String schedule = pref.getString(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE);
- // See if we have a scheduled check or startup only. If it is
+ // See if we have a scheduled check or startup only. If it is
// startup only, there is nothing more to do now, a listener will
// be created on the next startup.
if (schedule.equals(PreferenceConstants.PREF_UPDATE_ON_STARTUP)) {
@@ -161,7 +166,8 @@ public class AutomaticUpdateScheduler implements IStartup {
}
private IQuery<IInstallableUnit> getProfileQuery() {
- // We specifically avoid using the default policy's root property so that we don't load all the
+ // We specifically avoid using the default policy's root property so that we
+ // don't load all the
// p2 UI classes in doing so.
return new IUProfilePropertyQuery(IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
}
@@ -169,7 +175,8 @@ public class AutomaticUpdateScheduler implements IStartup {
private static long computeFuzzyDelay(IPreferenceStore pref) {
Date nowDate = java.util.Calendar.getInstance().getTime();
long now = nowDate.getTime();
- long lastCheckForUpdateSinceEpoch = new LastAutoCheckForUpdateMemo(AutomaticUpdatePlugin.getDefault().getAgentLocation()).readAndStoreIfAbsent(nowDate).getTime();
+ long lastCheckForUpdateSinceEpoch = new LastAutoCheckForUpdateMemo(
+ AutomaticUpdatePlugin.getDefault().getAgentLocation()).readAndStoreIfAbsent(nowDate).getTime();
long poll = computeFuzzyPoll(pref);
if (now - lastCheckForUpdateSinceEpoch >= poll + getMaxDelay(pref)) {
// Last check for update has exceeded the max delay we allow,
@@ -177,7 +184,8 @@ public class AutomaticUpdateScheduler implements IStartup {
return new Random().nextInt(ONE_HOUR_IN_MS);
}
long delay = now - lastCheckForUpdateSinceEpoch;
- // We do delay the next check sometime in the 8 hours after the computed schedule
+ // We do delay the next check sometime in the 8 hours after the computed
+ // schedule
return poll - delay + new Random().nextInt(8 * ONE_HOUR_IN_MS);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
index a5150327d..d375e77a0 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
@@ -93,7 +93,8 @@ public class AutomaticUpdater implements IUpdateListener {
@Override
public void checkingForUpdates() {
- new LastAutoCheckForUpdateMemo(AutomaticUpdatePlugin.getDefault().getAgentLocation()).store(Calendar.getInstance().getTime());
+ new LastAutoCheckForUpdateMemo(AutomaticUpdatePlugin.getDefault().getAgentLocation())
+ .store(Calendar.getInstance().getTime());
}
void updatesAvailable(final UpdateEvent event, final boolean notifyWithPopup) {
@@ -120,8 +121,11 @@ public class AutomaticUpdater implements IUpdateListener {
// preference dictates.
if (download) {
- ProfileModificationJob job = new ProfileModificationJob(AutomaticUpdateMessages.AutomaticUpdater_AutomaticDownloadOperationName, getSession(), event.getProfileId(), operation.getProvisioningPlan(), new ProvisioningContext(getSession().getProvisioningAgent()));
- job.setPhaseSet(PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_COLLECT}));
+ ProfileModificationJob job = new ProfileModificationJob(
+ AutomaticUpdateMessages.AutomaticUpdater_AutomaticDownloadOperationName, getSession(),
+ event.getProfileId(), operation.getProvisioningPlan(),
+ new ProvisioningContext(getSession().getProvisioningAgent()));
+ job.setPhaseSet(PhaseSetFactory.createPhaseSetIncluding(new String[] { PhaseSetFactory.PHASE_COLLECT }));
job.setUser(false);
job.setSystem(true);
job.addJobChangeListener(new JobChangeAdapter() {
@@ -130,7 +134,9 @@ public class AutomaticUpdater implements IUpdateListener {
IStatus jobStatus = jobEvent.getResult();
if (jobStatus.isOK()) {
alreadyDownloaded = true;
- PlatformUI.getWorkbench().getDisplay().asyncExec(() -> notifyUserOfUpdates(operation.getResolutionResult().isOK(), notifyWithPopup, showUpdateWizard));
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> notifyUserOfUpdates(operation.getResolutionResult().isOK(),
+ notifyWithPopup, showUpdateWizard));
} else if (jobStatus.getSeverity() != IStatus.CANCEL) {
StatusManager.getManager().handle(jobStatus, StatusManager.LOG);
}
@@ -138,7 +144,9 @@ public class AutomaticUpdater implements IUpdateListener {
});
job.schedule();
} else {
- PlatformUI.getWorkbench().getDisplay().asyncExec(() -> notifyUserOfUpdates(operation.getResolutionResult().isOK(), notifyWithPopup, showUpdateWizard));
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> notifyUserOfUpdates(operation.getResolutionResult().isOK(), notifyWithPopup,
+ showUpdateWizard));
}
}
@@ -148,16 +156,17 @@ public class AutomaticUpdater implements IUpdateListener {
}
/*
- * Use with caution, as this still start the whole UI bundle. Shouldn't be used
- * in any of the update checking code, only the code that presents updates when notified.
+ * Use with caution, as this still start the whole UI bundle. Shouldn't be used
+ * in any of the update checking code, only the code that presents updates when
+ * notified.
*/
ProvisioningUI getProvisioningUI() {
return ProvisioningUI.getDefaultUI();
}
/*
- * Filter out the ius that aren't visible to the user or are
- * locked for updating.
+ * Filter out the ius that aren't visible to the user or are locked for
+ * updating.
*/
void validateIusToUpdate() {
@@ -269,10 +278,12 @@ public class AutomaticUpdater implements IUpdateListener {
openUpdatePopup();
}
updateAffordance.setTooltip(AutomaticUpdateMessages.AutomaticUpdater_ClickToReviewUpdates);
- updateAffordance.setImage(AutomaticUpdatePlugin.getDefault().getImageRegistry().get((AutomaticUpdatePlugin.IMG_TOOL_UPDATE)));
+ updateAffordance.setImage(
+ AutomaticUpdatePlugin.getDefault().getImageRegistry().get((AutomaticUpdatePlugin.IMG_TOOL_UPDATE)));
} else {
updateAffordance.setTooltip(AutomaticUpdateMessages.AutomaticUpdater_ClickToReviewUpdatesWithProblems);
- updateAffordance.setImage(AutomaticUpdatePlugin.getDefault().getImageRegistry().get((AutomaticUpdatePlugin.IMG_TOOL_UPDATE_PROBLEMS)));
+ updateAffordance.setImage(AutomaticUpdatePlugin.getDefault().getImageRegistry()
+ .get((AutomaticUpdatePlugin.IMG_TOOL_UPDATE_PROBLEMS)));
}
IStatusLineManager manager = getStatusLineManager();
if (manager != null) {
@@ -323,9 +334,8 @@ public class AutomaticUpdater implements IUpdateListener {
}
/*
- * The profile has changed. Make sure our toUpdate list is still valid and
- * if there is nothing to update, get rid of the update popup and
- * affordance.
+ * The profile has changed. Make sure our toUpdate list is still valid and if
+ * there is nothing to update, get rid of the update popup and affordance.
*/
void triggerNewUpdateNotification() {
Job notifyJob = new Job("Update validate job") { //$NON-NLS-1$
@@ -333,7 +343,7 @@ public class AutomaticUpdater implements IUpdateListener {
public IStatus run(IProgressMonitor monitor) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
- // notify that updates are available for all roots. We don't know for sure that
+ // notify that updates are available for all roots. We don't know for sure that
// there are any, but this will cause everything to be rechecked. Don't trigger
// a popup, just update the affordance and internal state.
updatesAvailable(new UpdateEvent(profileId, getInstalledIUs()));
@@ -350,9 +360,10 @@ public class AutomaticUpdater implements IUpdateListener {
* Get the IInstallable units for the specified profile
*
* @param profileId the profile in question
+ *
* @param all <code>true</code> if all IInstallableUnits in the profile should
- * be returned, <code>false</code> only those IInstallableUnits marked as (user visible) roots
- * should be returned.
+ * be returned, <code>false</code> only those IInstallableUnits marked as (user
+ * visible) roots should be returned.
*
* @return an array of IInstallableUnits installed in the profile.
*/
@@ -374,11 +385,11 @@ public class AutomaticUpdater implements IUpdateListener {
}
IProfileRegistry getProfileRegistry() {
- return (IProfileRegistry) getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ return getSession().getProvisioningAgent().getService(IProfileRegistry.class);
}
IProvisioningEventBus getProvisioningEventBus() {
- return (IProvisioningEventBus) getSession().getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME);
+ return getSession().getProvisioningAgent().getService(IProvisioningEventBus.class);
}
IPreferenceStore getPreferenceStore() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
index eb17b9330..263fd5b2d 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
@@ -60,7 +60,7 @@ import org.osgi.util.tracker.ServiceTracker;
public class MigrationPage extends WizardPage implements ISelectableIUsPage, Listener {
protected String currentMessage;
- // protected Button destinationBrowseButton;
+ // protected Button destinationBrowseButton;
protected CheckboxTreeViewer viewer = null;
protected Exception finishException;
protected boolean entryChanged = false;
@@ -77,17 +77,19 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
protected IProvisioningAgent otherInstanceAgent = null;
private Collection<IInstallableUnit> unitsToMigrate;
- private Set<IInstallableUnit> selectedUnitsToMigrate; // selected units to be migrated, initially contains all units not installed in current profile.
+ private Set<IInstallableUnit> selectedUnitsToMigrate; // selected units to be migrated, initially contains all units
+ // not installed in current profile.
private IProfile toImportFrom = null;
- // private File instancePath = null;
+ // private File instancePath = null;
private URI[] metaURIs = null;
private URI[] artiURIs = null;
/**
- * {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the check state,
- * the methods {@link DeferredTreeContentManager}'s runClearPlaceholderJob and
- * DelayedFilterCheckboxTree.doCreateRefreshJob().new JobChangeAdapter() {...}.done(IJobChangeEvent) has timing issue,
- * I can't find a way to guarantee the first job is executed firstly
+ * {@link DelayedFilterCheckboxTree} has a timing bug to prevent restoring the
+ * check state, the methods {@link DeferredTreeContentManager}'s
+ * runClearPlaceholderJob and DelayedFilterCheckboxTree.doCreateRefreshJob().new
+ * JobChangeAdapter() {...}.done(IJobChangeEvent) has timing issue, I can't find
+ * a way to guarantee the first job is executed firstly
*
*/
final class ImportExportFilteredTree extends FilteredTree {
@@ -195,8 +197,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
/**
- * @param sortColumn
- * The sortColumn to set.
+ * @param sortColumn The sortColumn to set.
*/
public void setSortColumn(int sortColumn) {
if (this.sortColumn != sortColumn) {
@@ -214,8 +215,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
/**
- * @param ascending
- * The ascending to set.
+ * @param ascending The ascending to set.
*/
public void setAscending(boolean ascending) {
this.ascending = ascending;
@@ -224,26 +224,29 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
static {
BundleContext context = Platform.getBundle(ProvUIActivator.PLUGIN_ID).getBundleContext();
- ServiceTracker<IProvisioningAgent, IProvisioningAgent> tracker = new ServiceTracker<>(context, IProvisioningAgent.class, null);
+ ServiceTracker<IProvisioningAgent, IProvisioningAgent> tracker = new ServiceTracker<>(context,
+ IProvisioningAgent.class, null);
tracker.open();
agent = tracker.getService();
tracker.close();
if (agent != null)
- profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ profileRegistry = agent.getService(IProfileRegistry.class);
}
public MigrationPage(String pageName) {
super(pageName);
}
- public MigrationPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IProfile toImportFrom, Collection<IInstallableUnit> unitsToMigrate, boolean firstTime) {
+ public MigrationPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IProfile toImportFrom,
+ Collection<IInstallableUnit> unitsToMigrate, boolean firstTime) {
super("MigrationPageInstance"); //$NON-NLS-1$
this.wizard = wizard;
this.ui = ui;
profile = getSelfProfile();
this.toImportFrom = toImportFrom;
this.unitsToMigrate = unitsToMigrate;
- setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.MigrationPage_DIALOG_TITLE);
+ setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN
+ : ProvUIMessages.MigrationPage_DIALOG_TITLE);
setDescription(NLS.bind(ProvUIMessages.MigrationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
}
@@ -251,7 +254,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
super("importfrominstancepage"); //$NON-NLS-1$
this.wizard = wizard;
this.ui = ui;
- setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN : ProvUIMessages.MigrationPage_DIALOG_TITLE);
+ setTitle(firstTime ? ProvUIMessages.MigrationPage_DIALOG_TITLE_FIRSTRUN
+ : ProvUIMessages.MigrationPage_DIALOG_TITLE);
setDescription(NLS.bind(ProvUIMessages.MigrationPage_DIALOG_DESCRIPTION, Platform.getProduct().getName()));
}
@@ -266,7 +270,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
private void createColumns(TreeViewer treeViewer) {
- String[] titles = {ProvUIMessages.Column_Name, ProvUIMessages.Column_Version, ProvUIMessages.Column_Id};
+ String[] titles = { ProvUIMessages.Column_Name, ProvUIMessages.Column_Version, ProvUIMessages.Column_Id };
for (int i = 0; i < titles.length; i++) {
TreeViewerColumn column = new TreeViewerColumn(treeViewer, SWT.NONE);
column.getColumn().setText(titles[i]);
@@ -280,7 +284,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
final int columnIndex = i;
- column.getColumn().addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateTableSorting(columnIndex)));
+ column.getColumn().addSelectionListener(
+ SelectionListener.widgetSelectedAdapter(e -> updateTableSorting(columnIndex)));
}
}
@@ -299,7 +304,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
- // initializeService();
+ // initializeService();
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(1, true);
layout.horizontalSpacing = 0;
@@ -316,12 +321,18 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
setControl(composite);
- // giveFocusToDestination();
+ // giveFocusToDestination();
Dialog.applyDialogFont(composite);
}
protected IUColumnConfig[] getColumnConfig() {
- return new IUColumnConfig[] {new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME, ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH), new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION, ILayoutConstants.DEFAULT_SMALL_COLUMN_WIDTH), new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_IdColumnTitle, IUColumnConfig.COLUMN_ID, ILayoutConstants.DEFAULT_COLUMN_WIDTH)};
+ return new IUColumnConfig[] {
+ new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_NameColumnTitle,
+ IUColumnConfig.COLUMN_NAME, ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH),
+ new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_VersionColumnTitle,
+ IUColumnConfig.COLUMN_VERSION, ILayoutConstants.DEFAULT_SMALL_COLUMN_WIDTH),
+ new IUColumnConfig(org.eclipse.equinox.internal.p2.ui.ProvUIMessages.ProvUI_IdColumnTitle,
+ IUColumnConfig.COLUMN_ID, ILayoutConstants.DEFAULT_COLUMN_WIDTH) };
}
protected void createContents(Composite composite) {
@@ -344,7 +355,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
PatternFilter filter = getPatternFilter();
filter.setIncludeLeadingWildcard(true);
- final ImportExportFilteredTree filteredTree = new ImportExportFilteredTree(sashComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true);
+ final ImportExportFilteredTree filteredTree = new ImportExportFilteredTree(sashComposite,
+ SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filter, true);
viewer = (CheckboxTreeViewer) filteredTree.getViewer();
final Tree tree = viewer.getTree();
tree.setHeaderVisible(true);
@@ -363,7 +375,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
viewer.addCheckStateListener(event -> {
if (!event.getChecked() && filteredTree.checkState != null) {
ArrayList<Object> toRemove = new ArrayList<>(1);
- // See bug 258117. Ideally we would get check state changes
+ // See bug 258117. Ideally we would get check state changes
// for children when the parent state changed, but we aren't, so
// we need to remove all children from the additive check state
// cache.
@@ -384,8 +396,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
for (Object element : filteredTree.checkState) {
if (viewer.getComparer().equals(element, event.getElement())) {
toRemove.add(element);
- // Do not break out of the loop. We may have duplicate equal
- // elements in the cache. Since the cache is additive, we want
+ // Do not break out of the loop. We may have duplicate equal
+ // elements in the cache. Since the cache is additive, we want
// to be sure we've gotten everything.
}
}
@@ -394,7 +406,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
});
parent.addControlListener(new ControlAdapter() {
- private final int[] columnRate = new int[] {4, 2, 2};
+ private final int[] columnRate = new int[] { 4, 2, 2 };
@Override
public void controlResized(ControlEvent e) {
@@ -502,7 +514,9 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
Set<IInstallableUnit> ius = new HashSet<>();
if (profile != null) {
for (IInstallableUnit iu : unitsToMigrate) {
- IQueryResult<IInstallableUnit> collector = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), new NullProgressMonitor());
+ IQueryResult<IInstallableUnit> collector = profile.query(
+ QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)),
+ new NullProgressMonitor());
if (collector.isEmpty()) {
ius.add(iu);
}
@@ -570,7 +584,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
protected boolean determinePageCompletion() {
currentMessage = null;
- // validate groups in order of priority so error message is the most important one
+ // validate groups in order of priority so error message is the most important
+ // one
boolean complete = validateOptionsGroup();
// Avoid draw flicker by not clearing the error
@@ -588,15 +603,15 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
return SWT.OPEN;
}
- //TODO remove the implementation of Listener
+ // TODO remove the implementation of Listener
@Override
public void handleEvent(Event event) {
- // Widget source = event.widget;
+ // Widget source = event.widget;
//
- // if (source == destinationBrowseButton) {
- // handleDestinationBrowseButtonPressed();
- // }
- // updatePageCompletion();
+ // if (source == destinationBrowseButton) {
+ // handleDestinationBrowseButtonPressed();
+ // }
+ // updatePageCompletion();
}
/**
@@ -627,12 +642,14 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
public boolean hasInstalled(IInstallableUnit iu) {
- IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
+ IQueryResult<IInstallableUnit> results = profile
+ .query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
return !results.isEmpty();
}
public String getIUNameWithDetail(IInstallableUnit iu) {
- IQueryResult<IInstallableUnit> results = profile.query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
+ IQueryResult<IInstallableUnit> results = profile
+ .query(QueryUtil.createIUQuery(iu.getId(), new VersionRange(iu.getVersion(), true, null, false)), null);
String text = iu.getProperty(IProfile.PROP_NAME, null);
text = (text != null) ? text : iu.getId();
if (!results.isEmpty()) {
@@ -679,7 +696,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
protected String getInvalidDestinationMessage() {
- return "";//ProvUIMessages.ImportFromInstallationPage_INVALID_DESTINATION; //$NON-NLS-1$
+ return "";// ProvUIMessages.ImportFromInstallationPage_INVALID_DESTINATION; //$NON-NLS-1$
}
protected String getNoOptionsMessage() {
@@ -725,17 +742,19 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
public void cleanLocalRepository() {
if (metaURIs != null && metaURIs.length > 0) {
IProvisioningAgent runningAgent = getProvisioningUI().getSession().getProvisioningAgent();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) runningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = runningAgent.getService(IMetadataRepositoryManager.class);
for (URI uri : metaURIs)
manager.removeRepository(uri);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) runningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager artifactManager = runningAgent.getService(IArtifactRepositoryManager.class);
for (URI uri : artiURIs)
artifactManager.removeRepository(uri);
}
}
- // Both checkedElements and checkedElementsUpdates and the logic inside the getCheckedIUElements method
- // are used to prevent unnecessary call to getUpdates method due to computational cost.
+ // Both checkedElements and checkedElementsUpdates and the logic inside the
+ // getCheckedIUElements method
+ // are used to prevent unnecessary call to getUpdates method due to
+ // computational cost.
@SuppressWarnings("rawtypes")
private Set checkedElements;
@SuppressWarnings("rawtypes")
@@ -749,7 +768,9 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
Object[] latestUpdates = getLatestVersionOfCheckedElements();
- // If the getUpdades operation is cancelled, then set checkedElements and checkedElementsUpdates to null to force the lookup for updates again. Thereafter throw OperationCanceledException.
+ // If the getUpdades operation is cancelled, then set checkedElements and
+ // checkedElementsUpdates to null to force the lookup for updates again.
+ // Thereafter throw OperationCanceledException.
if (getUpdatesCanceled) {
this.checkedElements = null;
@@ -761,7 +782,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
return viewer.getCheckedElements();
}
- @SuppressWarnings({"rawtypes", "unchecked"})
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private Object[] getLatestVersionOfCheckedElements() {
Object[] checkedArray = viewer.getCheckedElements();
@@ -772,7 +793,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
} else {
Set checkedElementsNow = new HashSet(Arrays.asList(checkedArray));
- if (checkedElementsNow.size() != this.checkedElements.size() || (!checkedElementsNow.containsAll(checkedElements))) {
+ if (checkedElementsNow.size() != this.checkedElements.size()
+ || (!checkedElementsNow.containsAll(checkedElements))) {
// only if the set of checkedElements has changed get the update for them
this.checkedElements = checkedElementsNow; //
this.checkedElementsUpdates = new HashSet(Arrays.asList(getUpdates(checkedArray)));
@@ -793,7 +815,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
new UnsupportedOperationException();
}
- // Look for update of the current selected installation units and replace the old ons with the updated version
+ // Look for update of the current selected installation units and replace the
+ // old ons with the updated version
private Object[] getUpdates(final Object[] _checkedElements) {
final Collection<IInstallableUnit> toInstall = new ArrayList<>();
@@ -801,7 +824,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
try {
getContainer().run(false, true, monitor -> {
SubMonitor sub = SubMonitor.convert(monitor, _checkedElements.length);
- ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
+ ProvisioningContext context = new ProvisioningContext(
+ getProvisioningUI().getSession().getProvisioningAgent());
for (Object iu : _checkedElements) {
@@ -814,7 +838,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
if (iu instanceof AvailableIUElement) {
IInstallableUnit unit = ((AvailableIUElement) iu).getIU();
- IuUpdateAndPatches updateAndPatches = filterToInstall(unit, updatesFor(unit, context, sub.newChild(1)));
+ IuUpdateAndPatches updateAndPatches = filterToInstall(unit,
+ updatesFor(unit, context, sub.newChild(1)));
if (updateAndPatches.update != null) {
toInstall.add(updateAndPatches.update);
} else {
@@ -849,14 +874,17 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
private static boolean hasHigherFidelity(IInstallableUnit iu, IInstallableUnit currentIU) {
- if (Boolean.parseBoolean(currentIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU)) && !Boolean.parseBoolean(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)))
+ if (Boolean.parseBoolean(currentIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU))
+ && !Boolean.parseBoolean(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)))
return true;
return false;
}
- public Collection<IInstallableUnit> updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor) {
- // IPlanner planner = (IPlanner) getProvisioningUI().getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
- // return planner.updatesFor(toUpdate, context, monitor).toSet();
+ public Collection<IInstallableUnit> updatesFor(IInstallableUnit toUpdate, ProvisioningContext context,
+ IProgressMonitor monitor) {
+ // IPlanner planner = (IPlanner)
+ // getProvisioningUI().getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ // return planner.updatesFor(toUpdate, context, monitor).toSet();
Map<String, IInstallableUnit> resultsMap = new HashMap<>();
@@ -888,9 +916,10 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
/**
*
- * @param iu original unit.
+ * @param iu original unit.
* @param updates list of updates: patches or true updates.
- * @return a structure holding the original unit, its most recent update and any available patches.
+ * @return a structure holding the original unit, its most recent update and any
+ * available patches.
*/
private IuUpdateAndPatches filterToInstall(IInstallableUnit iu, Collection<IInstallableUnit> updates) {
@@ -901,7 +930,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
if (QueryUtil.isPatch(update)) {
updateAndPatches.patches.add(update);
} else {
- if (updateAndPatches.update == null || updateAndPatches.update.getVersion().compareTo(update.getVersion()) < 0) {
+ if (updateAndPatches.update == null
+ || updateAndPatches.update.getVersion().compareTo(update.getVersion()) < 0) {
updateAndPatches.update = update;
}
}
@@ -911,8 +941,10 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
}
public static boolean loadCustomizedSetting() {
- IScopeContext[] contexts = new IScopeContext[] {InstanceScope.INSTANCE, DefaultScope.INSTANCE, BundleDefaultsScope.INSTANCE, ConfigurationScope.INSTANCE};
- boolean updateToLatest = Platform.getPreferencesService().getBoolean(AutomaticUpdatePlugin.PLUGIN_ID, "updateToLatest", false, contexts);
+ IScopeContext[] contexts = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE,
+ BundleDefaultsScope.INSTANCE, ConfigurationScope.INSTANCE };
+ boolean updateToLatest = Platform.getPreferencesService().getBoolean(AutomaticUpdatePlugin.PLUGIN_ID,
+ "updateToLatest", false, contexts);
return updateToLatest;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
index caf15c75f..8d67ce498 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java
@@ -48,28 +48,33 @@ public class MigrationSupport {
private static final String ECLIPSE_P2_SKIP_MIGRATION_WIZARD = "eclipse.p2.skipMigrationWizard"; //$NON-NLS-1$
private static final String ECLIPSE_P2_SKIP_MOVED_INSTALL_DETECTION = "eclipse.p2.skipMovedInstallDetection"; //$NON-NLS-1$
- //The return value indicates if the migration dialog has been shown or not. It does not indicate whether the migration has completed.
+ // The return value indicates if the migration dialog has been shown or not. It
+ // does not indicate whether the migration has completed.
public boolean performMigration(IProvisioningAgent agent, IProfileRegistry registry, IProfile currentProfile) {
- boolean skipWizard = Boolean.TRUE.toString().equalsIgnoreCase(System.getProperty(ECLIPSE_P2_SKIP_MIGRATION_WIZARD));
+ boolean skipWizard = Boolean.TRUE.toString()
+ .equalsIgnoreCase(System.getProperty(ECLIPSE_P2_SKIP_MIGRATION_WIZARD));
if (skipWizard)
return false;
IProfile previousProfile = null;
URI[] reposToMigrate = null;
- if (!skipFirstTimeMigration() && !configurationSpecifiedManually() && isFirstTimeRunningThisSharedInstance(agent, registry, currentProfile)) {
+ if (!skipFirstTimeMigration() && !configurationSpecifiedManually()
+ && isFirstTimeRunningThisSharedInstance(agent, registry, currentProfile)) {
File searchRoot = getSearchLocation();
if (searchRoot == null)
return false;
- IProvisioningAgent otherConfigAgent = new PreviousConfigurationFinder(getConfigurationLocation().getParentFile()).findPreviousInstalls(searchRoot, getInstallFolder());
+ IProvisioningAgent otherConfigAgent = new PreviousConfigurationFinder(
+ getConfigurationLocation().getParentFile()).findPreviousInstalls(searchRoot, getInstallFolder());
if (otherConfigAgent == null) {
return false;
}
- previousProfile = ((IProfileRegistry) otherConfigAgent.getService(IProfileRegistry.SERVICE_NAME)).getProfile(IProfileRegistry.SELF);
+ previousProfile = otherConfigAgent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF);
if (previousProfile == null)
return false;
- reposToMigrate = ((IMetadataRepositoryManager) otherConfigAgent.getService(IMetadataRepositoryManager.SERVICE_NAME)).getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
+ reposToMigrate = otherConfigAgent.getService(IMetadataRepositoryManager.class)
+ .getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM);
reposToMigrate = copyOf(reposToMigrate, reposToMigrate.length + 1);
reposToMigrate[reposToMigrate.length - 1] = getURIForProfile(otherConfigAgent, previousProfile);
}
@@ -84,7 +89,7 @@ public class MigrationSupport {
if (!unitsToMigrate.isEmpty()) {
openMigrationWizard(previousProfile, unitsToMigrate, reposToMigrate);
} else {
- //There is nothing to migrate, so we mark the migration complete
+ // There is nothing to migrate, so we mark the migration complete
rememberMigrationCompleted();
}
return true;
@@ -98,16 +103,18 @@ public class MigrationSupport {
}
private URI getURIForProfile(IProvisioningAgent agent, IProfile profile) {
- IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
- return URIUtil.append(agentLocation.getRootLocation(), "org.eclipse.equinox.p2.engine/profileRegistry/" + profile.getProfileId() + ".profile"); //$NON-NLS-1$ //$NON-NLS-2$
+ IAgentLocation agentLocation = agent.getService(IAgentLocation.class);
+ return URIUtil.append(agentLocation.getRootLocation(),
+ "org.eclipse.equinox.p2.engine/profileRegistry/" + profile.getProfileId() + ".profile"); //$NON-NLS-1$ //$NON-NLS-2$
}
private File getInstallFolder() {
- Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class, Location.INSTALL_FILTER);
+ Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class,
+ Location.INSTALL_FILTER);
return new File(configurationLocation.getURL().getPath());
}
- //The search location is two level up from the configuration location.
+ // The search location is two level up from the configuration location.
private File getSearchLocation() {
File parent = getConfigurationLocation().getParentFile();
if (parent == null)
@@ -116,12 +123,13 @@ public class MigrationSupport {
}
private File getConfigurationLocation() {
- Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class, Location.CONFIGURATION_FILTER);
+ Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class,
+ Location.CONFIGURATION_FILTER);
File configurationFolder = new File(configurationLocation.getURL().getPath());
return configurationFolder;
}
- //Check if the user has explicitly specified -configuration on the command line
+ // Check if the user has explicitly specified -configuration on the command line
private boolean configurationSpecifiedManually() {
String commandLine = System.getProperty("eclipse.commands"); //$NON-NLS-1$
if (commandLine == null)
@@ -133,14 +141,18 @@ public class MigrationSupport {
return Boolean.TRUE.toString().equalsIgnoreCase(System.getProperty(ECLIPSE_P2_SKIP_MOVED_INSTALL_DETECTION));
}
- private boolean isFirstTimeRunningThisSharedInstance(IProvisioningAgent agent, IProfileRegistry registry, IProfile currentProfile) {
+ private boolean isFirstTimeRunningThisSharedInstance(IProvisioningAgent agent, IProfileRegistry registry,
+ IProfile currentProfile) {
long[] history = registry.listProfileTimestamps(currentProfile.getProfileId());
- boolean isInitial = IProfile.STATE_SHARED_INSTALL_VALUE_INITIAL.equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0]).get(IProfile.STATE_PROP_SHARED_INSTALL));
+ boolean isInitial = IProfile.STATE_SHARED_INSTALL_VALUE_INITIAL
+ .equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0])
+ .get(IProfile.STATE_PROP_SHARED_INSTALL));
if (isInitial) {
if (getLastMigration() >= history[0])
return false;
- //This detect the case where the user has not done any migration.
- Map<String, String> sharedRelatedValues = registry.getProfileStateProperties(currentProfile.getProfileId(), IProfile.STATE_PROP_SHARED_INSTALL);
+ // This detect the case where the user has not done any migration.
+ Map<String, String> sharedRelatedValues = registry.getProfileStateProperties(currentProfile.getProfileId(),
+ IProfile.STATE_PROP_SHARED_INSTALL);
if (sharedRelatedValues.containsValue(IProfile.STATE_SHARED_INSTALL_VALUE_NEW))
return false;
return true;
@@ -150,23 +162,26 @@ public class MigrationSupport {
/**
* @param previousProfile is the profile used previous to the current one
- * @param currentProfile is the current profile used by eclipse.
- * @return true if set difference between previousProfile units and currentProfile units not empty, otherwise false
+ * @param currentProfile is the current profile used by eclipse.
+ * @return true if set difference between previousProfile units and
+ * currentProfile units not empty, otherwise false
*/
protected Collection<IInstallableUnit> findUnitstoMigrate(IProfile previousProfile, IProfile currentProfile) {
- //First, try the case of inclusion
+ // First, try the case of inclusion
Set<IInstallableUnit> previousProfileUnits = getUserRoots(previousProfile);
Set<IInstallableUnit> currentProfileUnits = currentProfile.available(new UserVisibleRootQuery(), null).toSet();
previousProfileUnits.removeAll(currentProfileUnits);
- //For the IUs left in the previous profile, look for those that could be in the base but not as roots
+ // For the IUs left in the previous profile, look for those that could be in the
+ // base but not as roots
Iterator<IInstallableUnit> previousProfileIterator = previousProfileUnits.iterator();
while (previousProfileIterator.hasNext()) {
if (!currentProfile.available(QueryUtil.createIUQuery(previousProfileIterator.next()), null).isEmpty())
previousProfileIterator.remove();
}
- //For the IUs left in the previous profile, look for those that could be available in the root but as higher versions (they could be root or not)
+ // For the IUs left in the previous profile, look for those that could be
+ // available in the root but as higher versions (they could be root or not)
previousProfileIterator = previousProfileUnits.iterator();
while (previousProfileIterator.hasNext()) {
if (!currentProfile.available(new UpdateQuery(previousProfileIterator.next()), null).isEmpty())
@@ -178,33 +193,40 @@ public class MigrationSupport {
private Set<IInstallableUnit> getUserRoots(IProfile previousProfile) {
IQueryResult<IInstallableUnit> allRoots = previousProfile.query(new UserVisibleRootQuery(), null);
- Set<IInstallableUnit> rootsFromTheBase = previousProfile.query(new IUProfilePropertyQuery("org.eclipse.equinox.p2.base", "true"), null).toUnmodifiableSet();
+ Set<IInstallableUnit> rootsFromTheBase = previousProfile
+ .query(new IUProfilePropertyQuery("org.eclipse.equinox.p2.base", "true"), null).toUnmodifiableSet();
Set<IInstallableUnit> userRoots = allRoots.toSet();
userRoots.removeAll(rootsFromTheBase);
return userRoots;
}
- protected void openMigrationWizard(final IProfile inputProfile, final Collection<IInstallableUnit> unitsToMigrate, final URI[] reposToMigrate) {
+ protected void openMigrationWizard(final IProfile inputProfile, final Collection<IInstallableUnit> unitsToMigrate,
+ final URI[] reposToMigrate) {
Display d = Display.getDefault();
d.asyncExec(() -> {
- WizardDialog migrateWizard = new MigrationWizardDialog(getWorkbenchWindowShell(), new MigrationWizard(inputProfile, unitsToMigrate, reposToMigrate, reposToMigrate != null));
+ WizardDialog migrateWizard = new MigrationWizardDialog(getWorkbenchWindowShell(),
+ new MigrationWizard(inputProfile, unitsToMigrate, reposToMigrate, reposToMigrate != null));
migrateWizard.create();
migrateWizard.open();
});
}
- private boolean baseChangedSinceLastPresentationOfWizard(IProvisioningAgent agent, IProfileRegistry registry, IProfile profile) {
+ private boolean baseChangedSinceLastPresentationOfWizard(IProvisioningAgent agent, IProfileRegistry registry,
+ IProfile profile) {
long lastProfileMigrated = getLastMigration();
long lastResetTimestamp = findMostRecentResetTimestamp(registry, profile);
return lastProfileMigrated <= lastResetTimestamp;
}
- //The timestamp from which we migrated or -1
+ // The timestamp from which we migrated or -1
private long findMostRecentResetTimestamp(IProfileRegistry registry, IProfile profile) {
long[] history = registry.listProfileTimestamps(profile.getProfileId());
int index = history.length - 1;
boolean found = false;
- while (!(found = IProfile.STATE_SHARED_INSTALL_VALUE_BEFOREFLUSH.equals(registry.getProfileStateProperties(profile.getProfileId(), history[index]).get(IProfile.STATE_PROP_SHARED_INSTALL))) && index > 0) {
+ while (!(found = IProfile.STATE_SHARED_INSTALL_VALUE_BEFOREFLUSH
+ .equals(registry.getProfileStateProperties(profile.getProfileId(), history[index])
+ .get(IProfile.STATE_PROP_SHARED_INSTALL)))
+ && index > 0) {
index--;
}
if (!found)
@@ -225,14 +247,17 @@ public class MigrationSupport {
}
public void rememberMigrationCompleted() {
- IProfileRegistry registry = (IProfileRegistry) ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent()
+ .getService(IProfileRegistry.class);
long[] history = registry.listProfileTimestamps(ProvisioningUI.getDefaultUI().getProfileId());
- AutomaticUpdatePlugin.getDefault().getPreferenceStore().setValue(AutomaticUpdateScheduler.MIGRATION_DIALOG_SHOWN, history[history.length - 1]);
+ AutomaticUpdatePlugin.getDefault().getPreferenceStore()
+ .setValue(AutomaticUpdateScheduler.MIGRATION_DIALOG_SHOWN, history[history.length - 1]);
AutomaticUpdatePlugin.getDefault().savePreferences();
}
- //Get the timestamp that we migrated from. O if we have not migrated.
+ // Get the timestamp that we migrated from. O if we have not migrated.
public long getLastMigration() {
- return AutomaticUpdatePlugin.getDefault().getPreferenceStore().getLong(AutomaticUpdateScheduler.MIGRATION_DIALOG_SHOWN);
+ return AutomaticUpdatePlugin.getDefault().getPreferenceStore()
+ .getLong(AutomaticUpdateScheduler.MIGRATION_DIALOG_SHOWN);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java
index 95a6e05cb..23555547b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java
@@ -57,7 +57,8 @@ public class MigrationWizard extends InstallWizard implements IImportWizard {
this(ProvisioningUI.getDefaultUI(), null, null, null);
}
- public MigrationWizard(IProfile toImportFrom, Collection<IInstallableUnit> unitsToMigrate, URI[] reposToMigrate, boolean firstTime) {
+ public MigrationWizard(IProfile toImportFrom, Collection<IInstallableUnit> unitsToMigrate, URI[] reposToMigrate,
+ boolean firstTime) {
this(ProvisioningUI.getDefaultUI(), null, null, null);
this.toImportFrom = toImportFrom;
this.unitsToMigrate = unitsToMigrate;
@@ -66,14 +67,17 @@ public class MigrationWizard extends InstallWizard implements IImportWizard {
addRepos();
}
- public MigrationWizard(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
+ public MigrationWizard(ProvisioningUI ui, InstallOperation operation,
+ Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob) {
super(ui, operation, initialSelections, preloadJob);
}
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- setWindowTitle(firstTime ? ProvUIMessages.MigrationWizard_WINDOWTITLE_FIRSTRUN : ProvUIMessages.MigrationWizard_WINDOWTITLE);
- setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(Platform.getBundle(ProvUIActivator.PLUGIN_ID).getEntry("icons/install_wiz.png"))); //$NON-NLS-1$
+ setWindowTitle(firstTime ? ProvUIMessages.MigrationWizard_WINDOWTITLE_FIRSTRUN
+ : ProvUIMessages.MigrationWizard_WINDOWTITLE);
+ setDefaultPageImageDescriptor(ImageDescriptor
+ .createFromURL(Platform.getBundle(ProvUIActivator.PLUGIN_ID).getEntry("icons/install_wiz.png"))); //$NON-NLS-1$
setNeedsProgressMonitor(true);
}
@@ -100,10 +104,12 @@ public class MigrationWizard extends InstallWizard implements IImportWizard {
}
private void addRepos() {
- IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- List<URI> currentMetaRepos = Arrays.asList(metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL));
+ IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(),
+ IProvisioningAgent.class);
+ IMetadataRepositoryManager metaManager = agent.getService(IMetadataRepositoryManager.class);
+ IArtifactRepositoryManager artifactManager = agent.getService(IArtifactRepositoryManager.class);
+ List<URI> currentMetaRepos = Arrays
+ .asList(metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL));
if (reposToMigrate != null && metaManager != null && artifactManager != null) {
for (int i = 0; i < reposToMigrate.length; i++) {
@@ -117,9 +123,10 @@ public class MigrationWizard extends InstallWizard implements IImportWizard {
}
private void removeRepos() {
- IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(),
+ IProvisioningAgent.class);
+ IMetadataRepositoryManager metaManager = agent.getService(IMetadataRepositoryManager.class);
+ IArtifactRepositoryManager artifactManager = agent.getService(IArtifactRepositoryManager.class);
if (metaManager != null && artifactManager != null) {
for (int i = 0; i < addedRepos.size(); i++) {
@@ -129,52 +136,55 @@ public class MigrationWizard extends InstallWizard implements IImportWizard {
}
}
- //Remember that we completed the migration
+ // Remember that we completed the migration
private void rememberMigrationCompleted() {
new MigrationSupport().rememberMigrationCompleted();
}
- //Purge the profile registry from all the entries that are no longer relevant
- //We keep the base we import from on purpose to help with debugging
+ // Purge the profile registry from all the entries that are no longer relevant
+ // We keep the base we import from on purpose to help with debugging
private void cleanupProfileRegistry() {
- IProfileRegistry registry = (IProfileRegistry) ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent()
+ .getService(IProfileRegistry.class);
long[] history = registry.listProfileTimestamps(toImportFrom.getProfileId());
for (int i = 0; i < history.length; i++) {
if (history[i] < toImportFrom.getTimestamp())
try {
registry.removeProfile(toImportFrom.getProfileId(), history[i]);
} catch (ProvisionException e) {
- //Can't happen
+ // Can't happen
}
}
}
@Override
public boolean performCancel() {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, ProvUIMessages.MigrationPage_LATER_BUTTON, IDialogConstants.NO_LABEL};
- MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.MigrationPage_CONFIRMATION_TITLE, null, ProvUIMessages.MigrationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);
+ String[] buttons = new String[] { IDialogConstants.YES_LABEL, ProvUIMessages.MigrationPage_LATER_BUTTON,
+ IDialogConstants.NO_LABEL };
+ MessageDialog dialog = new MessageDialog(getShell(), ProvUIMessages.MigrationPage_CONFIRMATION_TITLE, null,
+ ProvUIMessages.MigrationPage_CONFIRMATION_DIALOG, MessageDialog.QUESTION, buttons, 2);
return rememberCancellationDecision(dialog.open());
}
- //Method public for test
+ // Method public for test
public boolean rememberCancellationDecision(int answer) {
boolean result = false;
switch (answer) {
- case -1 : // if the user closes the dialog without clicking any button.
- break;
- case 0 :
- result = true;
- removeRepos();
- rememberMigrationCompleted();
- break;
- case 1 :
- result = true;
- removeRepos();
- break;
- case 2 :
- result = false;
- break;
+ case -1: // if the user closes the dialog without clicking any button.
+ break;
+ case 0:
+ result = true;
+ removeRepos();
+ rememberMigrationCompleted();
+ break;
+ case 1:
+ result = true;
+ removeRepos();
+ break;
+ case 2:
+ result = false;
+ break;
}
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
index 051c3a3c6..7b122b233 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Ericsson AB (Hamdan Msheik) - Bug 396420 - Control Install dialog through preference customization
@@ -45,7 +45,7 @@ import org.eclipse.ui.statushandlers.StatusManager;
/**
* Generic provisioning UI utility and policy methods.
- *
+ *
* @since 3.4
*/
public class ProvUI {
@@ -61,14 +61,13 @@ public class ProvUI {
public static final String REVERT_COMMAND_TOOLTIP = ProvUIMessages.RevertIUCommandTooltip;
/**
- * A constant indicating that there was nothing to size (there
- * was no valid plan that could be used to compute
- * size).
+ * A constant indicating that there was nothing to size (there was no valid plan
+ * that could be used to compute size).
*/
public static final long SIZE_NOTAPPLICABLE = -3L;
/**
- * Indicates that the size is unavailable (an
- * attempt was made to compute size but it failed)
+ * Indicates that the size is unavailable (an attempt was made to compute size
+ * but it failed)
*/
public static final long SIZE_UNAVAILABLE = -2L;
/**
@@ -78,9 +77,10 @@ public class ProvUI {
private static IUColumnConfig[] columnConfig;
- // These values rely on the command markup in org.eclipse.ui.ide that defines the update commands
+ // These values rely on the command markup in org.eclipse.ui.ide that defines
+ // the update commands
private static final String UPDATE_MANAGER_FIND_AND_INSTALL = "org.eclipse.ui.update.findAndInstallUpdates"; //$NON-NLS-1$
- // This value relies on the command markup in org.eclipse.ui
+ // This value relies on the command markup in org.eclipse.ui
private static final String INSTALLATION_DIALOG = "org.eclipse.ui.help.installationDialog"; //$NON-NLS-1$
public static IStatus handleException(Throwable t, String message, int style) {
@@ -95,13 +95,17 @@ public class ProvUI {
public static void reportStatus(IStatus status, int style) {
// workaround for
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=211933
- // Note we'd rather have a proper looking dialog than get the
+ // Note we'd rather have a proper looking dialog than get the
// blocking right.
- if ((style & StatusManager.BLOCK) == StatusManager.BLOCK || (style & StatusManager.SHOW) == StatusManager.SHOW) {
+ if ((style & StatusManager.BLOCK) == StatusManager.BLOCK
+ || (style & StatusManager.SHOW) == StatusManager.SHOW) {
if (status.getSeverity() == IStatus.INFO) {
- final MessageDialogWithLink dialog = new MessageDialogWithLink(ProvUI.getDefaultParentShell(), ProvUIMessages.ProvUI_InformationTitle, null, status.getMessage(), MessageDialog.INFORMATION, 0, IDialogConstants.OK_LABEL);
+ final MessageDialogWithLink dialog = new MessageDialogWithLink(ProvUI.getDefaultParentShell(),
+ ProvUIMessages.ProvUI_InformationTitle, null, status.getMessage(), MessageDialog.INFORMATION, 0,
+ IDialogConstants.OK_LABEL);
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
- dialog.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> ProvisioningUI.getDefaultUI().manipulateRepositories(dialog.getShell())));
+ dialog.addSelectionListener(SelectionListener.widgetSelectedAdapter(
+ e -> ProvisioningUI.getDefaultUI().manipulateRepositories(dialog.getShell())));
}
dialog.open();
// unset the dialog bits
@@ -113,7 +117,8 @@ public class ProvUI {
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE)
style = 0;
} else if (status.getSeverity() == IStatus.WARNING) {
- MessageDialog.openWarning(ProvUI.getDefaultParentShell(), ProvUIMessages.ProvUI_WarningTitle, status.getMessage());
+ MessageDialog.openWarning(ProvUI.getDefaultParentShell(), ProvUIMessages.ProvUI_WarningTitle,
+ status.getMessage());
// unset the dialog bits
style = style & ~StatusManager.BLOCK;
style = style & ~StatusManager.SHOW;
@@ -125,18 +130,25 @@ public class ProvUI {
public static IUColumnConfig[] getIUColumnConfig() {
if (columnConfig == null)
- columnConfig = new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME, ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION, ILayoutConstants.DEFAULT_COLUMN_WIDTH)};
+ columnConfig = new IUColumnConfig[] {
+ new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME,
+ ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH),
+ new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION,
+ ILayoutConstants.DEFAULT_COLUMN_WIDTH) };
return columnConfig;
}
- //Factory method returning a new instance of a IUViewQueryContext
+ // Factory method returning a new instance of a IUViewQueryContext
public static IUViewQueryContext getQueryContext(Policy policy) {
- IUViewQueryContext queryContext = new IUViewQueryContext(policy.getGroupByCategory() ? IUViewQueryContext.AVAILABLE_VIEW_BY_CATEGORY : IUViewQueryContext.AVAILABLE_VIEW_FLAT);
+ IUViewQueryContext queryContext = new IUViewQueryContext(
+ policy.getGroupByCategory() ? IUViewQueryContext.AVAILABLE_VIEW_BY_CATEGORY
+ : IUViewQueryContext.AVAILABLE_VIEW_FLAT);
queryContext.setShowInstallChildren(policy.getShowDrilldownRequirements());
queryContext.setShowProvisioningPlanChildren(policy.getShowDrilldownRequirements());
- //among other things the 4 calls below are used to control the available software dialog (AvailableIUPage)
+ // among other things the 4 calls below are used to control the available
+ // software dialog (AvailableIUPage)
queryContext.setShowLatestVersionsOnly(policy.getShowLatestVersionsOnly());
queryContext.setHideAlreadyInstalled(policy.getHideAlreadyInstalled());
queryContext.setUseCategories(policy.getGroupByCategory());
@@ -158,15 +170,15 @@ public class ProvUI {
}
/**
- * Returns a shell that is appropriate to use as the parent
- * for a modal dialog.
+ * Returns a shell that is appropriate to use as the parent for a modal dialog.
*/
public static Shell getDefaultParentShell() {
return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
}
public static void openUpdateManagerInstaller(Event event) {
- runCommand(UPDATE_MANAGER_FIND_AND_INSTALL, ProvUIMessages.UpdateManagerCompatibility_UnableToOpenFindAndInstall, event);
+ runCommand(UPDATE_MANAGER_FIND_AND_INSTALL,
+ ProvUIMessages.UpdateManagerCompatibility_UnableToOpenFindAndInstall, event);
}
public static void openInstallationDialog(Event event) {
@@ -210,19 +222,21 @@ public class ProvUI {
/**
* Get sizing information about the specified plan.
- *
- * @param engine the engine
- * @param plan the provisioning plan
+ *
+ * @param engine the engine
+ * @param plan the provisioning plan
* @param context the provisioning context to be used for the sizing
* @param monitor the progress monitor
- *
- * @return a long integer describing the disk size required for the provisioning plan.
- *
+ *
+ * @return a long integer describing the disk size required for the provisioning
+ * plan.
+ *
* @see #SIZE_UNKNOWN
* @see #SIZE_UNAVAILABLE
* @see #SIZE_NOTAPPLICABLE
*/
- public static long getSize(IEngine engine, IProvisioningPlan plan, ProvisioningContext context, IProgressMonitor monitor) {
+ public static long getSize(IEngine engine, IProvisioningPlan plan, ProvisioningContext context,
+ IProgressMonitor monitor) {
// If there is nothing to size, return 0
if (plan == null)
return SIZE_NOTAPPLICABLE;
@@ -246,47 +260,53 @@ public class ProvUI {
}
private static int countPlanElements(IProvisioningPlan plan) {
- return QueryUtil.compoundQueryable(plan.getAdditions(), plan.getRemovals()).query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet().size();
+ return QueryUtil.compoundQueryable(plan.getAdditions(), plan.getRemovals())
+ .query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet().size();
}
/**
* Return the artifact repository manager for the given session
+ *
* @return the repository manager
*/
public static IArtifactRepositoryManager getArtifactRepositoryManager(ProvisioningSession session) {
- return (IArtifactRepositoryManager) session.getProvisioningAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return session.getProvisioningAgent().getService(IArtifactRepositoryManager.class);
}
/**
* Return the metadata repository manager for the given session
+ *
* @return the repository manager
*/
public static IMetadataRepositoryManager getMetadataRepositoryManager(ProvisioningSession session) {
- return (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
+ return session.getProvisioningAgent().getService(IMetadataRepositoryManager.class);
}
/**
* Return the profile registry for the given session
+ *
* @return the profile registry
*/
public static IProfileRegistry getProfileRegistry(ProvisioningSession session) {
- return (IProfileRegistry) session.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ return session.getProvisioningAgent().getService(IProfileRegistry.class);
}
/**
* Return the provisioning engine for the given session
+ *
* @return the provisioning engine
*/
public static IEngine getEngine(ProvisioningSession session) {
- return (IEngine) session.getProvisioningAgent().getService(IEngine.SERVICE_NAME);
+ return session.getProvisioningAgent().getService(IEngine.class);
}
/**
* Return the provisioning event bus used for dispatching events.
+ *
* @return the event bus
*/
public static IProvisioningEventBus getProvisioningEventBus(ProvisioningSession session) {
- return (IProvisioningEventBus) session.getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME);
+ return session.getProvisioningAgent().getService(IProvisioningEventBus.class);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java
index 641b476cf..bcc152da8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryTrackerComponent.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* EclipseSource Inc. - initial API and implementation
*******************************************************************************/
@@ -26,7 +26,7 @@ public class RepositoryTrackerComponent implements IAgentServiceFactory {
@Override
public Object createService(IProvisioningAgent agent) {
- ProvisioningUI ui = (ProvisioningUI) agent.getService(ProvisioningUI.class.getName());
+ ProvisioningUI ui = agent.getService(ProvisioningUI.class);
if (ui == null)
return null;
return new ColocatedRepositoryTracker(ui);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
index 512ffb9df..1b0ded316 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
@@ -40,9 +40,9 @@ public class UpdateWizard extends WizardWithLicenses {
public static Collection<IInstallableUnit> getIUsToReplace(Object[] elements) {
Set<IInstallableUnit> iusToReplace = new HashSet<>();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof AvailableUpdateElement) {
- iusToReplace.add(((AvailableUpdateElement) elements[i]).getIUToBeUpdated());
+ for (Object element : elements) {
+ if (element instanceof AvailableUpdateElement) {
+ iusToReplace.add(((AvailableUpdateElement) element).getIUToBeUpdated());
}
}
return iusToReplace;
@@ -50,9 +50,9 @@ public class UpdateWizard extends WizardWithLicenses {
public static IInstallableUnit[] getReplacementIUs(Object[] elements) {
Set<IInstallableUnit> replacements = new HashSet<>();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof AvailableUpdateElement) {
- replacements.add(((AvailableUpdateElement) elements[i]).getIU());
+ for (Object element : elements) {
+ if (element instanceof AvailableUpdateElement) {
+ replacements.add(((AvailableUpdateElement) element).getIU());
}
}
return replacements.toArray(new IInstallableUnit[replacements.size()]);
@@ -60,24 +60,26 @@ public class UpdateWizard extends WizardWithLicenses {
public static Update[] makeUpdatesFromElements(Object[] elements) {
Set<Update> updates = new HashSet<>();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof AvailableUpdateElement) {
- updates.add(((AvailableUpdateElement) elements[i]).getUpdate());
+ for (Object element : elements) {
+ if (element instanceof AvailableUpdateElement) {
+ updates.add(((AvailableUpdateElement) element).getUpdate());
}
}
return updates.toArray(new Update[updates.size()]);
}
/**
- * Open an update wizard. For update wizards, the operation must have been resolved in advanced.
- * This prevents searching for updates in the UI thread.
- *
- * @param ui the provisioning UI
- * @param operation the update operation. Must already be resolved!
+ * Open an update wizard. For update wizards, the operation must have been
+ * resolved in advanced. This prevents searching for updates in the UI thread.
+ *
+ * @param ui the provisioning UI
+ * @param operation the update operation. Must already be resolved!
* @param initialSelections initial selections for the wizard (can be null)
- * @param preloadJob a job that has been used to preload metadata repositories (can be null)
+ * @param preloadJob a job that has been used to preload metadata
+ * repositories (can be null)
*/
- public UpdateWizard(ProvisioningUI ui, UpdateOperation operation, Object[] initialSelections, LoadMetadataRepositoryJob preloadJob) {
+ public UpdateWizard(ProvisioningUI ui, UpdateOperation operation, Object[] initialSelections,
+ LoadMetadataRepositoryJob preloadJob) {
super(ui, operation, initialSelections, preloadJob);
this.initialSelections = (Update[]) initialSelections;
Assert.isLegal(operation.hasResolved(), "Cannot create an update wizard on an unresolved operation"); //$NON-NLS-1$
@@ -90,13 +92,13 @@ public class UpdateWizard extends WizardWithLicenses {
}
public void deselectLockedIUs() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ui.getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = ui.getSession().getProvisioningAgent().getService(IProfileRegistry.class);
IProfile profile = profileRegistry.getProfile(ui.getProfileId());
ArrayList<Update> newSelection = new ArrayList<>(initialSelections.length);
- for (int i = 0; i < initialSelections.length; i++) {
- if (!isLocked(profile, initialSelections[i].toUpdate)) {
- newSelection.add(initialSelections[i]);
+ for (Update initialSelection : initialSelections) {
+ if (!isLocked(profile, initialSelection.toUpdate)) {
+ newSelection.add(initialSelection);
}
}
@@ -124,21 +126,24 @@ public class UpdateWizard extends WizardWithLicenses {
return;
root = new IUElementListRoot(ui);
if (operation instanceof RemediationOperation) {
- AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy(), false);
+ AvailableIUElement[] elements = ElementUtils
+ .requestToElement(((RemediationOperation) operation).getCurrentRemedy(), false);
root.setChildren(elements);
- //planSelections = elements;
+ // planSelections = elements;
} else {
ArrayList<AvailableUpdateElement> list = new ArrayList<>(selectedElements.length);
ArrayList<AvailableUpdateElement> selected = new ArrayList<>(selectedElements.length);
- for (int i = 0; i < selectedElements.length; i++) {
- if (selectedElements[i] instanceof AvailableUpdateElement) {
- AvailableUpdateElement element = (AvailableUpdateElement) selectedElements[i];
- AvailableUpdateElement newElement = new AvailableUpdateElement(root, element.getIU(), element.getIUToBeUpdated(), getProfileId(), shouldShowProvisioningPlanChildren());
+ for (Object selectedElement : selectedElements) {
+ if (selectedElement instanceof AvailableUpdateElement) {
+ AvailableUpdateElement element = (AvailableUpdateElement) selectedElement;
+ AvailableUpdateElement newElement = new AvailableUpdateElement(root, element.getIU(),
+ element.getIUToBeUpdated(), getProfileId(), shouldShowProvisioningPlanChildren());
list.add(newElement);
selected.add(newElement);
- } else if (selectedElements[i] instanceof Update) {
- Update update = (Update) selectedElements[i];
- AvailableUpdateElement newElement = new AvailableUpdateElement(root, update.replacement, update.toUpdate, getProfileId(), shouldShowProvisioningPlanChildren());
+ } else if (selectedElement instanceof Update) {
+ Update update = (Update) selectedElement;
+ AvailableUpdateElement newElement = new AvailableUpdateElement(root, update.replacement,
+ update.toUpdate, getProfileId(), shouldShowProvisioningPlanChildren());
list.add(newElement);
selected.add(newElement);
}
@@ -168,15 +173,18 @@ public class UpdateWizard extends WizardWithLicenses {
return mainPage;
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#getProfileChangeOperation(java.lang.Object[])
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#
+ * getProfileChangeOperation(java.lang.Object[])
*/
@Override
protected ProfileChangeOperation getProfileChangeOperation(Object[] elements) {
if (operation == null) {
operation = new UpdateOperation(ui.getSession(), getIUsToReplace(elements));
operation.setProfileId(getProfileId());
- // operation.setRootMarkerKey(getRootMarkerKey());
+ // operation.setRootMarkerKey(getRootMarkerKey());
} else {
((UpdateOperation) operation).setSelectedUpdates(makeUpdatesFromElements(elements));
}
@@ -194,8 +202,9 @@ public class UpdateWizard extends WizardWithLicenses {
updates = ((UpdateOperation) operation).getPossibleUpdates();
}
ArrayList<AvailableUpdateElement> allPossible = new ArrayList<>(updates.length);
- for (int i = 0; i < updates.length; i++) {
- AvailableUpdateElement newElement = new AvailableUpdateElement(firstPageRoot, updates[i].replacement, updates[i].toUpdate, getProfileId(), shouldShowProvisioningPlanChildren());
+ for (Update update : updates) {
+ AvailableUpdateElement newElement = new AvailableUpdateElement(firstPageRoot, update.replacement,
+ update.toUpdate, getProfileId(), shouldShowProvisioningPlanChildren());
allPossible.add(newElement);
}
firstPageRoot.setChildren(allPossible.toArray());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
index 0e3492780..5b004785b 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sonatype, Inc. - ongoing development
@@ -30,10 +30,10 @@ import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
import org.eclipse.equinox.p2.repository.IRepository;
/**
- * Element wrapper class for IU's that are available for installation.
- * Used instead of the plain IU when additional information such as sizing
- * info is necessary.
- *
+ * Element wrapper class for IU's that are available for installation. Used
+ * instead of the plain IU when additional information such as sizing info is
+ * necessary.
+ *
* @since 3.4
*/
public class AvailableIUElement extends QueriedElement implements IIUElement {
@@ -69,8 +69,10 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
/*
* (non-Javadoc)
- *
- * @see org.eclipse.equinox.internal.provisional.p2.ui.model.ProvElement#getImageID(java.lang.Object)
+ *
+ * @see
+ * org.eclipse.equinox.internal.provisional.p2.ui.model.ProvElement#getImageID(
+ * java.lang.Object)
*/
@Override
protected String getImageId(Object obj) {
@@ -133,7 +135,8 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
protected IProvisioningPlan getSizingPlan(IProgressMonitor monitor) {
IPlanner planner = getPlanner();
- IProfileChangeRequest request = ProfileChangeRequest.createByProfileId(getProvisioningUI().getSession().getProvisioningAgent(), profileID);
+ IProfileChangeRequest request = ProfileChangeRequest
+ .createByProfileId(getProvisioningUI().getSession().getProvisioningAgent(), profileID);
request.add(getIU());
return planner.getProvisioningPlan(request, getProvisioningContext(), monitor);
}
@@ -143,7 +146,7 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
}
IPlanner getPlanner() {
- return (IPlanner) getProvisioningUI().getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ return getProvisioningUI().getSession().getProvisioningAgent().getService(IPlanner.class);
}
IProfileRegistry getProfileRegistry() {
@@ -165,15 +168,20 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
return true;
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.model.QueriedElement#getDefaultQueryType()
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.equinox.internal.p2.ui.model.QueriedElement#getDefaultQueryType()
*/
@Override
protected int getDefaultQueryType() {
return QueryProvider.AVAILABLE_IUS;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.equinox.internal.p2.ui.model.IUElement#getRequirements()
*/
@Override
@@ -181,7 +189,9 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
return iu.getRequirements();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.equinox.internal.p2.ui.model.IIUElement#shouldShowChildren()
*/
@Override
@@ -252,7 +262,7 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
private ProvisioningContext getProvisioningContext() {
ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
if (hasQueryable() && getQueryable() instanceof IRepository<?>) {
- context.setMetadataRepositories(new URI[] {((IRepository<?>) getQueryable()).getLocation()});
+ context.setMetadataRepositories(new URI[] { ((IRepository<?>) getQueryable()).getLocation() });
}
return context;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
index 43ce10fae..dadef258d 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Sonatype, Inc. - ongoing development
@@ -24,10 +24,10 @@ import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
/**
- * Element wrapper class for IU's that are available for installation.
- * Used instead of the plain IU when additional information such as sizing
- * info is necessary.
- *
+ * Element wrapper class for IU's that are available for installation. Used
+ * instead of the plain IU when additional information such as sizing info is
+ * necessary.
+ *
* @since 3.4
*/
public class AvailableUpdateElement extends AvailableIUElement {
@@ -35,7 +35,8 @@ public class AvailableUpdateElement extends AvailableIUElement {
IInstallableUnit iuToBeUpdated;
boolean isLockedForUpdate = false;
- public AvailableUpdateElement(Object parent, IInstallableUnit iu, IInstallableUnit iuToBeUpdated, String profileID, boolean shouldShowChildren) {
+ public AvailableUpdateElement(Object parent, IInstallableUnit iu, IInstallableUnit iuToBeUpdated, String profileID,
+ boolean shouldShowChildren) {
super(parent, iu, profileID, shouldShowChildren);
setIsInstalled(false);
this.iuToBeUpdated = iuToBeUpdated;
@@ -44,7 +45,8 @@ public class AvailableUpdateElement extends AvailableIUElement {
}
private void init() {
- IProfileRegistry profileRegistry = (IProfileRegistry) getProvisioningUI().getSession().getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = getProvisioningUI().getSession().getProvisioningAgent()
+ .getService(IProfileRegistry.class);
IProfile profile = profileRegistry.getProfile(profileID);
String property = profile.getInstallableUnitProperty(iuToBeUpdated, IProfile.PROP_PROFILE_LOCKED_IU);
try {
@@ -65,11 +67,13 @@ public class AvailableUpdateElement extends AvailableIUElement {
@Override
protected IProvisioningPlan getSizingPlan(IProgressMonitor monitor) {
IPlanner planner = getPlanner();
- IProfileChangeRequest request = ProfileChangeRequest.createByProfileId(getProvisioningUI().getSession().getProvisioningAgent(), profileID);
+ IProfileChangeRequest request = ProfileChangeRequest
+ .createByProfileId(getProvisioningUI().getSession().getProvisioningAgent(), profileID);
if (iuToBeUpdated.getId().equals(getIU().getId()))
request.remove(iuToBeUpdated);
request.add(getIU());
- return planner.getProvisioningPlan(request, new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent()), monitor);
+ return planner.getProvisioningPlan(request,
+ new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent()), monitor);
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
index cc5f7962f..fbab6b672 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* EclipseSource - ongoing development
@@ -44,13 +44,15 @@ public class QueryableUpdates implements IQueryable<IInstallableUnit> {
monitor = new NullProgressMonitor();
int totalWork = 2000;
monitor.beginTask(ProvUIMessages.QueryableUpdates_UpdateListProgress, totalWork);
- IPlanner planner = (IPlanner) ui.getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = ui.getSession().getProvisioningAgent().getService(IPlanner.class);
try {
Set<IInstallableUnit> allUpdates = new HashSet<>();
for (IInstallableUnit unit : iusToUpdate) {
if (monitor.isCanceled())
return Collector.emptyCollector();
- IQueryResult<IInstallableUnit> updates = planner.updatesFor(unit, new ProvisioningContext(ui.getSession().getProvisioningAgent()), SubMonitor.convert(monitor, totalWork / 2 / iusToUpdate.length));
+ IQueryResult<IInstallableUnit> updates = planner.updatesFor(unit,
+ new ProvisioningContext(ui.getSession().getProvisioningAgent()),
+ SubMonitor.convert(monitor, totalWork / 2 / iusToUpdate.length));
allUpdates.addAll(updates.toUnmodifiableSet());
}
return query.perform(allUpdates.iterator());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
index 1d61b96b2..3827456a1 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
@@ -44,16 +44,16 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
/**
- * ProvisioningUI defines the provisioning session, UI policy, and related services for a
- * provisioning UI.
- *
+ * ProvisioningUI defines the provisioning session, UI policy, and related
+ * services for a provisioning UI.
+ *
* @since 2.0
*/
public class ProvisioningUI {
/**
- * Return the default ProvisioningUI.
- *
+ * Return the default ProvisioningUI.
+ *
* @return the default Provisioning UI.
*/
public static ProvisioningUI getDefaultUI() {
@@ -67,10 +67,10 @@ public class ProvisioningUI {
/**
* Creates a new instance of the provisioning user interface.
- *
- * @param session The current provisioning session
+ *
+ * @param session The current provisioning session
* @param profileId The profile that this user interface is operating on
- * @param policy The user interface policy settings to use
+ * @param policy The user interface policy settings to use
*/
public ProvisioningUI(ProvisioningSession session, String profileId, Policy policy) {
this.policy = policy;
@@ -79,13 +79,14 @@ public class ProvisioningUI {
this.profileId = IProfileRegistry.SELF;
this.session = session;
this.runner = new ProvisioningOperationRunner(this);
- // register this UI with the agent so other UI related agent services can find it
+ // register this UI with the agent so other UI related agent services can find
+ // it
session.getProvisioningAgent().registerService(ProvisioningUI.class.getName(), this);
}
/**
* Return the UI policy used for this instance of the UI.
- *
+ *
* @return the UI policy, must not be <code>null</code>
*/
public Policy getPolicy() {
@@ -93,9 +94,9 @@ public class ProvisioningUI {
}
/**
- * Return the provisioning session that should be used to obtain
- * provisioning services.
- *
+ * Return the provisioning session that should be used to obtain provisioning
+ * services.
+ *
* @return the provisioning session, must not be <code>null</code>
*/
public ProvisioningSession getSession() {
@@ -103,31 +104,32 @@ public class ProvisioningUI {
}
/**
- * Return the license manager that should be used to remember
- * accepted user licenses.
- * @return the license manager. May be <code>null</code> if licenses are not
- * to be remembered.
+ * Return the license manager that should be used to remember accepted user
+ * licenses.
+ *
+ * @return the license manager. May be <code>null</code> if licenses are not to
+ * be remembered.
*/
public LicenseManager getLicenseManager() {
return ServiceHelper.getService(ProvUIActivator.getContext(), LicenseManager.class);
}
/**
- * Return the repository tracker that should be used to add, remove, and track the
- * statuses of known repositories.
- *
+ * Return the repository tracker that should be used to add, remove, and track
+ * the statuses of known repositories.
+ *
* @return the repository tracker, must not be <code>null</code>
*/
public RepositoryTracker getRepositoryTracker() {
- return (RepositoryTracker) session.getProvisioningAgent().getService(RepositoryTracker.class.getName());
+ return session.getProvisioningAgent().getService(RepositoryTracker.class);
}
/**
- * Return the profile id that should be assumed for this ProvisioningUI if no other
- * id is otherwise specified. Some UI classes are assigned a profile id, while others
- * are not. For those classes that are not assigned a current profile id, this id can
- * be used to obtain one.
- *
+ * Return the profile id that should be assumed for this ProvisioningUI if no
+ * other id is otherwise specified. Some UI classes are assigned a profile id,
+ * while others are not. For those classes that are not assigned a current
+ * profile id, this id can be used to obtain one.
+ *
* @return a profile id
*/
public String getProfileId() {
@@ -135,9 +137,9 @@ public class ProvisioningUI {
}
/**
- * Return an install operation that describes installing the specified IInstallableUnits from the
- * provided list of repositories.
- *
+ * Return an install operation that describes installing the specified
+ * IInstallableUnits from the provided list of repositories.
+ *
* @param iusToInstall the IInstallableUnits to be installed
* @param repositories the repositories to use for the operation
* @return the install operation
@@ -150,10 +152,10 @@ public class ProvisioningUI {
}
/**
- * Return an update operation that describes updating the specified IInstallableUnits from the
- * provided list of repositories.
- *
- * @param iusToUpdate the IInstallableUnits to be updated
+ * Return an update operation that describes updating the specified
+ * IInstallableUnits from the provided list of repositories.
+ *
+ * @param iusToUpdate the IInstallableUnits to be updated
* @param repositories the repositories to use for the operation
* @return the update operation
*/
@@ -165,11 +167,12 @@ public class ProvisioningUI {
}
/**
- * Return an uninstall operation that describes uninstalling the specified IInstallableUnits, using
- * the supplied repositories to replace any metadata that must be retrieved for the uninstall.
- *
+ * Return an uninstall operation that describes uninstalling the specified
+ * IInstallableUnits, using the supplied repositories to replace any metadata
+ * that must be retrieved for the uninstall.
+ *
* @param iusToUninstall the IInstallableUnits to be installed
- * @param repositories the repositories to use for the operation
+ * @param repositories the repositories to use for the operation
* @return the uninstall operation
*/
public UninstallOperation getUninstallOperation(Collection<IInstallableUnit> iusToUninstall, URI[] repositories) {
@@ -192,36 +195,52 @@ public class ProvisioningUI {
/**
* Open an install wizard for installing the specified IInstallableUnits
- *
- * @param initialSelections the IInstallableUnits that should be selected when the wizard opens. May be <code>null</code>.
- * @param operation the operation describing the proposed install. If this operation is not <code>null</code>, then a wizard showing
- * only the IInstallableUnits described in the operation will be shown. If the operation is <code>null</code>, then a
- * wizard allowing the user to browse the repositories will be opened.
- * @param job a repository load job that is loading or has already loaded the repositories. Can be used to pass along
- * an in-memory repository reference to the wizard.
- *
+ *
+ * @param initialSelections the IInstallableUnits that should be selected when
+ * the wizard opens. May be <code>null</code>.
+ * @param operation the operation describing the proposed install. If
+ * this operation is not <code>null</code>, then a
+ * wizard showing only the IInstallableUnits described
+ * in the operation will be shown. If the operation is
+ * <code>null</code>, then a wizard allowing the user
+ * to browse the repositories will be opened.
+ * @param job a repository load job that is loading or has already
+ * loaded the repositories. Can be used to pass along
+ * an in-memory repository reference to the wizard.
+ *
* @return the wizard return code
*/
- public int openInstallWizard(Collection<IInstallableUnit> initialSelections, InstallOperation operation, LoadMetadataRepositoryJob job) {
+ public int openInstallWizard(Collection<IInstallableUnit> initialSelections, InstallOperation operation,
+ LoadMetadataRepositoryJob job) {
return openInstallWizard(initialSelections, operation, null, job);
}
/**
- * Open an install wizard for installing the specified IInstallableUnits and remediationOperation.
- *
- * @param initialSelections the IInstallableUnits that should be selected when the wizard opens. May be <code>null</code>.
- * @param operation the operation describing the proposed install. If this operation is not <code>null</code>, then a wizard showing
- * only the IInstallableUnits described in the operation will be shown. If the operation is <code>null</code>, then a
- * wizard allowing the user to browse the repositories will be opened.
- * @param remediationOperation the alternate operations if the proposed update failed. May be <code>null</code>.
- * @param job a repository load job that is loading or has already loaded the repositories. Can be used to pass along
- * an in-memory repository reference to the wizard.
- *
+ * Open an install wizard for installing the specified IInstallableUnits and
+ * remediationOperation.
+ *
+ * @param initialSelections the IInstallableUnits that should be selected
+ * when the wizard opens. May be <code>null</code>.
+ * @param operation the operation describing the proposed install. If
+ * this operation is not <code>null</code>, then a
+ * wizard showing only the IInstallableUnits
+ * described in the operation will be shown. If the
+ * operation is <code>null</code>, then a wizard
+ * allowing the user to browse the repositories will
+ * be opened.
+ * @param remediationOperation the alternate operations if the proposed update
+ * failed. May be <code>null</code>.
+ * @param job a repository load job that is loading or has
+ * already loaded the repositories. Can be used to
+ * pass along an in-memory repository reference to
+ * the wizard.
+ *
* @return the wizard return code
* @see RemediationOperation
* @since 2.3
*/
- public int openInstallWizard(Collection<IInstallableUnit> initialSelections, InstallOperation operation, RemediationOperation remediationOperation, LoadMetadataRepositoryJob job) {
+ public int openInstallWizard(Collection<IInstallableUnit> initialSelections, InstallOperation operation,
+ RemediationOperation remediationOperation, LoadMetadataRepositoryJob job) {
if (operation == null) {
InstallWizard wizard = new InstallWizard(this, operation, initialSelections, job);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
@@ -239,13 +258,18 @@ public class ProvisioningUI {
/**
* Open an update wizard for the specified update operation.
- *
- * @param skipSelectionsPage <code>true</code> if the selection page should be skipped so that the user is
- * viewing the resolution results. <code>false</code> if the update selection page should be shown first.
- * @param operation the operation describing the proposed update. Must not be <code>null</code>.
- * @param job a repository load job that is loading or has already loaded the repositories. Can be used to pass along
- * an in-memory repository reference to the wizard.
- *
+ *
+ * @param skipSelectionsPage <code>true</code> if the selection page should be
+ * skipped so that the user is viewing the resolution
+ * results. <code>false</code> if the update selection
+ * page should be shown first.
+ * @param operation the operation describing the proposed update. Must
+ * not be <code>null</code>.
+ * @param job a repository load job that is loading or has
+ * already loaded the repositories. Can be used to
+ * pass along an in-memory repository reference to the
+ * wizard.
+ *
* @return the wizard return code
*/
public int openUpdateWizard(boolean skipSelectionsPage, UpdateOperation operation, LoadMetadataRepositoryJob job) {
@@ -254,24 +278,34 @@ public class ProvisioningUI {
}
/**
- * Open an update wizard for the specified update operation and remediationOperation.
- *
- * @param skipSelectionsPage <code>true</code> if the selection page should be skipped so that the user is
- * viewing the resolution results. <code>false</code> if the update selection page should be shown first.
- * @param operation the operation describing the proposed update. Must not be <code>null</code>.
- * @param remediationOperation the alternate operations if the proposed update failed. May be <code>null</code>.
- * @param job a repository load job that is loading or has already loaded the repositories. Can be used to pass along
- * an in-memory repository reference to the wizard.
- *
+ * Open an update wizard for the specified update operation and
+ * remediationOperation.
+ *
+ * @param skipSelectionsPage <code>true</code> if the selection page should be
+ * skipped so that the user is viewing the
+ * resolution results. <code>false</code> if the
+ * update selection page should be shown first.
+ * @param operation the operation describing the proposed update.
+ * Must not be <code>null</code>.
+ * @param remediationOperation the alternate operations if the proposed update
+ * failed. May be <code>null</code>.
+ * @param job a repository load job that is loading or has
+ * already loaded the repositories. Can be used to
+ * pass along an in-memory repository reference to
+ * the wizard.
+ *
* @return the wizard return code
* @since 2.3
*/
- public int openUpdateWizard(boolean skipSelectionsPage, UpdateOperation operation, RemediationOperation remediationOperation, LoadMetadataRepositoryJob job) {
- if (getPolicy().getUpdateWizardStyle() == Policy.UPDATE_STYLE_SINGLE_IUS && UpdateSingleIUWizard.validFor(operation)) {
+ public int openUpdateWizard(boolean skipSelectionsPage, UpdateOperation operation,
+ RemediationOperation remediationOperation, LoadMetadataRepositoryJob job) {
+ if (getPolicy().getUpdateWizardStyle() == Policy.UPDATE_STYLE_SINGLE_IUS
+ && UpdateSingleIUWizard.validFor(operation)) {
UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(this, operation);
WizardDialog dialog = new WizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.create();
- // TODO do we need a hook for providing custom help? Or would this just be shown in the update browser?
+ // TODO do we need a hook for providing custom help? Or would this just be shown
+ // in the update browser?
return dialog.open();
}
UpdateWizard wizard = new UpdateWizard(this, operation, operation.getSelectedUpdates(), job);
@@ -280,7 +314,8 @@ public class ProvisioningUI {
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.create();
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IProvHelpContextIds.UPDATE_WIZARD);
- if (wizard.getCurrentStatus().getSeverity() == IStatus.ERROR && remediationOperation != null && remediationOperation.getResolutionResult() != Status.OK_STATUS) {
+ if (wizard.getCurrentStatus().getSeverity() == IStatus.ERROR && remediationOperation != null
+ && remediationOperation.getResolutionResult() != Status.OK_STATUS) {
wizard.deselectLockedIUs();
}
return dialog.open();
@@ -289,15 +324,19 @@ public class ProvisioningUI {
/**
* Open an uninstall wizard for the specified uninstall operation.
- *
- * @param initialSelections the IInstallableUnits that should be selected when the wizard opens. May be <code>null</code>.
- * @param operation the operation describing the proposed uninstall. Must not be <code>null</code>.
- * @param job a repository load job that is loading or has already loaded the repositories. Can be used to pass along
- * an in-memory repository reference to the wizard.
- *
+ *
+ * @param initialSelections the IInstallableUnits that should be selected when
+ * the wizard opens. May be <code>null</code>.
+ * @param operation the operation describing the proposed uninstall.
+ * Must not be <code>null</code>.
+ * @param job a repository load job that is loading or has already
+ * loaded the repositories. Can be used to pass along
+ * an in-memory repository reference to the wizard.
+ *
* @return the wizard return code
*/
- public int openUninstallWizard(Collection<IInstallableUnit> initialSelections, UninstallOperation operation, LoadMetadataRepositoryJob job) {
+ public int openUninstallWizard(Collection<IInstallableUnit> initialSelections, UninstallOperation operation,
+ LoadMetadataRepositoryJob job) {
UninstallWizard wizard = new UninstallWizard(this, operation, initialSelections, job);
WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
dialog.create();
@@ -307,11 +346,13 @@ public class ProvisioningUI {
/**
* Open a UI that allows the user to manipulate the repositories.
+ *
* @param shell the shell that should parent the UI
*/
public void manipulateRepositories(Shell shell) {
if (policy.getRepositoryPreferencePageId() != null) {
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, policy.getRepositoryPreferencePageId(), null, null);
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell,
+ policy.getRepositoryPreferencePageId(), null, null);
dialog.open();
} else {
TitleAreaDialog dialog = new TitleAreaDialog(shell) {
@@ -354,8 +395,8 @@ public class ProvisioningUI {
/**
* Schedule a job to execute the supplied ProvisioningOperation.
- *
- * @param job The operation to execute
+ *
+ * @param job The operation to execute
* @param errorStyle the flags passed to the StatusManager for error reporting
*/
public void schedule(final ProvisioningJob job, final int errorStyle) {
@@ -364,16 +405,17 @@ public class ProvisioningUI {
}
/**
- * Manage the supplied job as a provisioning operation. This will allow
- * the ProvisioningUI to be aware that a provisioning job is running, as well
- * as manage the restart behavior for the job.
- *
- * @param job the job to be managed
- * @param jobRestartPolicy an integer constant specifying whether the
- * supplied job should cause a restart of the system. The UI Policy's
- * restart policy is used in conjunction with this constant to determine
- * what actually occurs when a job completes.
- *
+ * Manage the supplied job as a provisioning operation. This will allow the
+ * ProvisioningUI to be aware that a provisioning job is running, as well as
+ * manage the restart behavior for the job.
+ *
+ * @param job the job to be managed
+ * @param jobRestartPolicy an integer constant specifying whether the supplied
+ * job should cause a restart of the system. The UI
+ * Policy's restart policy is used in conjunction with
+ * this constant to determine what actually occurs when
+ * a job completes.
+ *
* @see ProvisioningJob#RESTART_NONE
* @see ProvisioningJob#RESTART_ONLY
* @see ProvisioningJob#RESTART_OR_APPLY
@@ -385,9 +427,9 @@ public class ProvisioningUI {
/**
* Return a boolean indicating whether the receiver has scheduled any operations
* for the profile under management.
- *
- * @return <code>true</code> if other provisioning operations have been scheduled,
- * <code>false</code> if there are no operations scheduled.
+ *
+ * @return <code>true</code> if other provisioning operations have been
+ * scheduled, <code>false</code> if there are no operations scheduled.
*/
public boolean hasScheduledOperations() {
return getSession().hasScheduledOperationsFor(profileId);
@@ -395,7 +437,9 @@ public class ProvisioningUI {
/**
* This method is for automated testing only.
- * @return the provisioning operation that can suppress restart for automated testing.
+ *
+ * @return the provisioning operation that can suppress restart for automated
+ * testing.
* @noreference This method is not intended to be referenced by clients.
*/
public ProvisioningOperationRunner getOperationRunner() {
@@ -403,9 +447,10 @@ public class ProvisioningUI {
}
/**
- * Signal that a repository operation is about to begin. This allows clients to ignore intermediate
- * events until the operation is completed. Callers are responsible for ensuring that
- * a corresponding operation ending event is signaled.
+ * Signal that a repository operation is about to begin. This allows clients to
+ * ignore intermediate events until the operation is completed. Callers are
+ * responsible for ensuring that a corresponding operation ending event is
+ * signaled.
*/
public void signalRepositoryOperationStart() {
runner.eventBatchCount++;
@@ -416,36 +461,43 @@ public class ProvisioningUI {
/**
* Signal that a repository operation has completed.
- *
- * @param event a {@link RepositoryEvent} that describes the overall operation. May be <code>null</code>, which
- * indicates that there was no single event that can describe the operation.
- * @param update <code>true</code> if the event should be reflected in the UI, false if it should be ignored.
+ *
+ * @param event a {@link RepositoryEvent} that describes the overall operation.
+ * May be <code>null</code>, which indicates that there was no
+ * single event that can describe the operation.
+ * @param update <code>true</code> if the event should be reflected in the UI,
+ * false if it should be ignored.
*/
public void signalRepositoryOperationComplete(RepositoryEvent event, boolean update) {
runner.eventBatchCount--;
if (Tracing.DEBUG_EVENTS_CLIENT)
Tracing.debug("Batch Count Decremented to: " + Integer.toString(runner.eventBatchCount)); //$NON-NLS-1$
- ProvUI.getProvisioningEventBus(getSession()).publishEvent(new RepositoryOperationEndingEvent(this, update, event));
+ ProvUI.getProvisioningEventBus(getSession())
+ .publishEvent(new RepositoryOperationEndingEvent(this, update, event));
}
/**
- * Load the specified metadata repository, signaling a repository operation start event
- * before loading, and a repository operation complete event after loading.
- *
+ * Load the specified metadata repository, signaling a repository operation
+ * start event before loading, and a repository operation complete event after
+ * loading.
+ *
* @param location the location of the repository
- * @param notify <code>true</code> if the UI should be updated as a result of the load, <code>false</code> if it should not
- * @param monitor the progress monitor to be used
+ * @param notify <code>true</code> if the UI should be updated as a result of
+ * the load, <code>false</code> if it should not
+ * @param monitor the progress monitor to be used
* @return the repository
* @throws ProvisionException if the repository could not be loaded
*/
- public IMetadataRepository loadMetadataRepository(URI location, boolean notify, IProgressMonitor monitor) throws ProvisionException {
+ public IMetadataRepository loadMetadataRepository(URI location, boolean notify, IProgressMonitor monitor)
+ throws ProvisionException {
IMetadataRepository repo = null;
try {
signalRepositoryOperationStart();
IMetadataRepositoryManager manager = ProvUI.getMetadataRepositoryManager(getSession());
repo = manager.loadRepository(location, monitor);
- // If there is no user nickname assigned to this repo but there is a provider name, then set the nickname.
+ // If there is no user nickname assigned to this repo but there is a provider
+ // name, then set the nickname.
// This will keep the name in the manager even when the repo is not loaded
String name = manager.getRepositoryProperty(location, IRepository.PROP_NICKNAME);
if (name == null || name.isEmpty()) {
@@ -456,30 +508,35 @@ public class ProvisioningUI {
} catch (ProvisionException e) {
getRepositoryTracker().reportLoadFailure(location, e);
} finally {
- // We have no idea how many repos may have been touched as a result of loading this one.
+ // We have no idea how many repos may have been touched as a result of loading
+ // this one.
signalRepositoryOperationComplete(null, notify);
}
return repo;
}
/**
- * Load the specified artifact repository, signaling a repository operation start event
- * before loading, and a repository operation complete event after loading.
- *
+ * Load the specified artifact repository, signaling a repository operation
+ * start event before loading, and a repository operation complete event after
+ * loading.
+ *
* @param location the location of the repository
- * @param update <code>true</code> if the UI should be updated as a result of the load, <code>false</code> if it should not
- * @param monitor the progress monitor to be used
+ * @param update <code>true</code> if the UI should be updated as a result of
+ * the load, <code>false</code> if it should not
+ * @param monitor the progress monitor to be used
* @return the repository
* @throws ProvisionException if the repository could not be loaded
*/
- public IArtifactRepository loadArtifactRepository(URI location, boolean update, IProgressMonitor monitor) throws ProvisionException {
+ public IArtifactRepository loadArtifactRepository(URI location, boolean update, IProgressMonitor monitor)
+ throws ProvisionException {
IArtifactRepository repo;
signalRepositoryOperationStart();
try {
IArtifactRepositoryManager manager = ProvUI.getArtifactRepositoryManager(getSession());
repo = manager.loadRepository(location, monitor);
- // If there is no user nickname assigned to this repo but there is a provider name, then set the nickname.
+ // If there is no user nickname assigned to this repo but there is a provider
+ // name, then set the nickname.
// This will keep the name in the manager even when the repo is not loaded
String name = manager.getRepositoryProperty(location, IRepository.PROP_NICKNAME);
if (name == null) {
@@ -488,7 +545,8 @@ public class ProvisioningUI {
manager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
}
} finally {
- // We have no idea how many repos may have been touched as a result of loading this one,
+ // We have no idea how many repos may have been touched as a result of loading
+ // this one,
// so we do not use a specific repository event to represent it.
signalRepositoryOperationComplete(null, update);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index eea5fdb7b..0031d5ad2 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -46,12 +46,12 @@ import org.eclipse.ui.menus.AbstractContributionFactory;
import org.eclipse.ui.statushandlers.StatusManager;
/**
- * RevertProfilePage displays a profile's configuration history in
- * an Installation Page. Clients can use this class as the implementation
- * class for an installationPages extension.
- *
+ * RevertProfilePage displays a profile's configuration history in an
+ * Installation Page. Clients can use this class as the implementation class for
+ * an installationPages extension.
+ *
* @see InstallationPage
- *
+ *
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
* @since 2.0
@@ -94,7 +94,9 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
@Override
protected Object getValue(Object element) {
if (element instanceof RollbackProfileElement) {
- return ((RollbackProfileElement) element).getProfileTag() != null ? ((RollbackProfileElement) element).getProfileTag() : ""; //$NON-NLS-1$
+ return ((RollbackProfileElement) element).getProfileTag() != null
+ ? ((RollbackProfileElement) element).getProfileTag()
+ : ""; //$NON-NLS-1$
}
return null;
}
@@ -109,9 +111,11 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
if (registry != null) {
IStatus status;
if (((String) value).length() > 0) {
- status = registry.setProfileStateProperty(ele.getProfileId(), ele.getTimestamp(), IProfile.STATE_PROP_TAG, (String) value);
+ status = registry.setProfileStateProperty(ele.getProfileId(), ele.getTimestamp(),
+ IProfile.STATE_PROP_TAG, (String) value);
} else {
- status = registry.removeProfileStateProperties(ele.getProfileId(), ele.getTimestamp(), Collections.singleton(IProfile.STATE_PROP_TAG));
+ status = registry.removeProfileStateProperties(ele.getProfileId(), ele.getTimestamp(),
+ Collections.singleton(IProfile.STATE_PROP_TAG));
}
if (!status.isOK()) {
StatusManager.getManager().handle(status);
@@ -160,7 +164,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
createContentsSection(sashForm);
setControl(sashForm);
- // prime the selection. The selection accesses the
+ // prime the selection. The selection accesses the
// revert action, so create it also.
createRevertAction();
}
@@ -176,7 +180,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
Label label = new Label(composite, SWT.NONE);
label.setText(ProvUIMessages.RevertDialog_ConfigsLabel);
- configsViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
+ configsViewer = new TableViewer(composite,
+ SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ProvElementContentProvider provider = new ProvElementContentProvider() {
@Override
protected void finishedFetchingElements(Object o) {
@@ -192,7 +197,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
configsViewer.setContentProvider(provider);
configsViewer.setLabelProvider(new ProvElementLabelProvider());
configsViewer.setComparator(new ViewerComparator() {
- // We override the ViewerComparator so that we don't get the labels of the elements
+ // We override the ViewerComparator so that we don't get the labels of the
+ // elements
// for comparison, but rather get the timestamps and compare them.
// Reverse sorting is used so that newest is first.
@Override
@@ -244,7 +250,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
Label label = new Label(composite, SWT.NONE);
label.setText(ProvUIMessages.RevertDialog_ConfigContentsLabel);
- configContentsViewer = new TreeViewer(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ configContentsViewer = new TreeViewer(composite,
+ SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
IUComparator comparator = new IUComparator(IUComparator.IU_NAME);
comparator.useColumnConfig(ProvUI.getIUColumnConfig());
configContentsViewer.setComparator(comparator);
@@ -265,7 +272,9 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
revertAction = new Action() {
@Override
public void run() {
- int result = MessageDialog.open(MessageDialog.QUESTION, getShell(), ProvUIMessages.RevertDialog_Title, ProvUIMessages.RevertDialog_ConfirmRestartMessage, SWT.NONE, ProvUIMessages.RevertProfilePage_RevertLabel, ProvUIMessages.RevertDialog_CancelButtonLabel);
+ int result = MessageDialog.open(MessageDialog.QUESTION, getShell(), ProvUIMessages.RevertDialog_Title,
+ ProvUIMessages.RevertDialog_ConfirmRestartMessage, SWT.NONE,
+ ProvUIMessages.RevertProfilePage_RevertLabel, ProvUIMessages.RevertDialog_CancelButtonLabel);
if (result != Window.OK)
return;
boolean finish = revert();
@@ -286,12 +295,12 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
@Override
protected void buttonPressed(int buttonId) {
switch (buttonId) {
- case REVERT_ID :
- revertAction.run();
- break;
- case DELETE_ID :
- deleteSelectedSnapshots();
- break;
+ case REVERT_ID:
+ revertAction.run();
+ break;
+ case DELETE_ID:
+ deleteSelectedSnapshots();
+ break;
}
}
@@ -339,8 +348,10 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
Iterator<?> iter = configsViewer.getStructuredSelection().iterator();
while (iter.hasNext()) {
Object selected = iter.next();
- // If it's not a recognized element or if it is the current profile, we can't delete. Stop iterating.
- if (!(selected instanceof RollbackProfileElement) || ((RollbackProfileElement) selected).isCurrentProfile()) {
+ // If it's not a recognized element or if it is the current profile, we can't
+ // delete. Stop iterating.
+ if (!(selected instanceof RollbackProfileElement)
+ || ((RollbackProfileElement) selected).isCurrentProfile()) {
okToDelete = false;
break;
}
@@ -375,7 +386,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
IRunnableWithProgress runnable = monitor -> {
IProfile currentProfile;
IProfileRegistry registry = ProvUI.getProfileRegistry(getSession());
- IPlanner planner = (IPlanner) getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = getSession().getProvisioningAgent().getService(IPlanner.class);
currentProfile = registry.getProfile(profileId);
plan[0] = planner.getDiffPlan(currentProfile, snapshot, monitor);
};
@@ -397,7 +408,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
if (plan[0].getStatus().isOK()) {
// We use a default provisioning context (all repos) because we have no other
// way currently to figure out which sites the user wants to contact
- ProfileModificationJob op = new ProfileModificationJob(ProvUIMessages.RevertDialog_RevertOperationLabel, getSession(), profileId, plan[0], new ProvisioningContext(getSession().getProvisioningAgent()));
+ ProfileModificationJob op = new ProfileModificationJob(ProvUIMessages.RevertDialog_RevertOperationLabel,
+ getSession(), profileId, plan[0], new ProvisioningContext(getSession().getProvisioningAgent()));
// we want to force a restart (not allow apply changes)
op.setRestartPolicy(ProvisioningJob.RESTART_ONLY);
getProvisioningUI().schedule(op, StatusManager.SHOW | StatusManager.LOG);
@@ -405,7 +417,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
} else if (plan[0].getStatus().getSeverity() != IStatus.CANCEL) {
ProvUI.reportStatus(plan[0].getStatus(), StatusManager.LOG | StatusManager.SHOW);
// This message has no effect in an installation dialog
- // setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, IMessageProvider.ERROR);
+ // setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError,
+ // IMessageProvider.ERROR);
}
}
return reverted;
@@ -415,7 +428,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
public void copyToClipboard(Control activeControl) {
String text = ""; //$NON-NLS-1$
if (activeControl == configContentsViewer.getControl()) {
- text = CopyUtils.getIndentedClipboardText(configContentsViewer.getStructuredSelection().toArray(), labelProvider);
+ text = CopyUtils.getIndentedClipboardText(configContentsViewer.getStructuredSelection().toArray(),
+ labelProvider);
} else if (activeControl == configsViewer.getControl()) {
Object[] elements = configsViewer.getStructuredSelection().toArray();
StringBuilder buffer = new StringBuilder();
@@ -432,7 +446,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
if (text.isEmpty())
return;
Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
- clipboard.setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
+ clipboard.setContents(new Object[] { text }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
@@ -440,14 +454,20 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
IStructuredSelection selection = configsViewer.getStructuredSelection();
if (selection.isEmpty())
return;
- String title = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_DeleteSingleConfigurationTitle : ProvUIMessages.RevertProfilePage_DeleteMultipleConfigurationsTitle;
- String confirmMessage = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_ConfirmDeleteSingleConfig : ProvUIMessages.RevertProfilePage_ConfirmDeleteMultipleConfigs;
- if (Window.OK == MessageDialog.open(MessageDialog.QUESTION, configsViewer.getControl().getShell(), title, confirmMessage, SWT.NONE, ProvUIMessages.RevertProfilePage_Delete, ProvUIMessages.RevertProfilePage_CancelButtonLabel)) {
+ String title = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_DeleteSingleConfigurationTitle
+ : ProvUIMessages.RevertProfilePage_DeleteMultipleConfigurationsTitle;
+ String confirmMessage = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_ConfirmDeleteSingleConfig
+ : ProvUIMessages.RevertProfilePage_ConfirmDeleteMultipleConfigs;
+ if (Window.OK == MessageDialog.open(MessageDialog.QUESTION, configsViewer.getControl().getShell(), title,
+ confirmMessage, SWT.NONE, ProvUIMessages.RevertProfilePage_Delete,
+ ProvUIMessages.RevertProfilePage_CancelButtonLabel)) {
Iterator<?> iter = selection.iterator();
while (iter.hasNext()) {
Object selected = iter.next();
- // If it is a recognized element and it is not the current profile, then it can be deleted.
- if (selected instanceof RollbackProfileElement && !((RollbackProfileElement) selected).isCurrentProfile()) {
+ // If it is a recognized element and it is not the current profile, then it can
+ // be deleted.
+ if (selected instanceof RollbackProfileElement
+ && !((RollbackProfileElement) selected).isCurrentProfile()) {
RollbackProfileElement snapshot = (RollbackProfileElement) selected;
IProfileRegistry registry = ProvUI.getProfileRegistry(getSession());
if (registry != null) {
@@ -468,7 +488,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
}
ProvisioningUI getProvisioningUI() {
- // if a UI has not been set then assume that the current default UI is the right thing
+ // if a UI has not been set then assume that the current default UI is the right
+ // thing
if (ui == null)
return ui = ProvisioningUI.getDefaultUI();
return ui;
@@ -480,7 +501,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
/**
* Set the provisioning UI to use with this page
- *
+ *
* @param value the provisioning ui to use
* @since 2.1
*/
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index c8d7a884c..97e5c8ee3 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -43,8 +43,9 @@ import org.eclipse.equinox.spi.p2.publisher.LocalizationHelper;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
/**
- * Action which processes a site.xml and generates categories. The categorization process
- * relies on IUs for the various features to have already been generated.
+ * Action which processes a site.xml and generates categories. The
+ * categorization process relies on IUs for the various features to have already
+ * been generated.
*/
public class SiteXMLAction extends AbstractPublisherAction {
static final private String QUALIFIER = "qualifier"; //$NON-NLS-1$
@@ -59,11 +60,14 @@ public class SiteXMLAction extends AbstractPublisherAction {
private Version categoryVersion = null;
/**
- * Creates a SiteXMLAction from a Location (URI) with an optional qualifier to use for category names
- * @param location The location of the update site
- * @param categoryQualifier The qualifier to prepend to categories. This qualifier is used
- * to ensure that the category IDs are unique between update sites. If <b>null</b> a default
- * qualifier will be generated
+ * Creates a SiteXMLAction from a Location (URI) with an optional qualifier to
+ * use for category names
+ *
+ * @param location The location of the update site
+ * @param categoryQualifier The qualifier to prepend to categories. This
+ * qualifier is used to ensure that the category IDs
+ * are unique between update sites. If <b>null</b> a
+ * default qualifier will be generated
*/
public SiteXMLAction(URI location, String categoryQualifier) {
this.location = location;
@@ -71,11 +75,14 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Creates a SiteXMLAction from an Update site with an optional qualifier to use for category names
- * @param updateSite The update site
- * @param categoryQualifier The qualifier to prepend to categories. This qualifier is used
- * to ensure that the category IDs are unique between update sites. If <b>null</b> a default
- * qualifier will be generated
+ * Creates a SiteXMLAction from an Update site with an optional qualifier to use
+ * for category names
+ *
+ * @param updateSite The update site
+ * @param categoryQualifier The qualifier to prepend to categories. This
+ * qualifier is used to ensure that the category IDs
+ * are unique between update sites. If <b>null</b> a
+ * default qualifier will be generated
*/
public SiteXMLAction(UpdateSite updateSite, String categoryQualifier) {
this.updateSite = updateSite;
@@ -101,7 +108,9 @@ public class SiteXMLAction extends AbstractPublisherAction {
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
if (updateSite == null) {
try {
- updateSite = UpdateSite.load(location, (Transport) publisherInfo.getMetadataRepository().getProvisioningAgent().getService(Transport.SERVICE_NAME), monitor);
+ updateSite = UpdateSite.load(location,
+ publisherInfo.getMetadataRepository().getProvisioningAgent().getService(Transport.class),
+ monitor);
} catch (ProvisionException e) {
return new Status(IStatus.ERROR, Activator.ID, Messages.Error_generating_siteXML, e);
} catch (OperationCanceledException e) {
@@ -117,7 +126,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
return markingStats;
}
- private IStatus markStatsArtifacts(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
+ private IStatus markStatsArtifacts(IPublisherInfo publisherInfo, IPublisherResult results,
+ IProgressMonitor monitor) {
IArtifactRepository artifactRepo = publisherInfo.getArtifactRepository();
SiteModel site = updateSite.getSite();
// process all features listed and mark artifacts
@@ -129,7 +139,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
Collection<IInstallableUnit> ius = getFeatureIU(feature, publisherInfo, results);
if (ius != null) {
for (IInstallableUnit iu : ius) {
- IArtifactKey key = FeaturesAction.createFeatureArtifactKey(feature.getFeatureIdentifier(), iu.getVersion().toString());
+ IArtifactKey key = FeaturesAction.createFeatureArtifactKey(feature.getFeatureIdentifier(),
+ iu.getVersion().toString());
IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key);
if (descriptors.length > 0 && descriptors[0] instanceof ArtifactDescriptor) {
HashMap<String, String> map = new HashMap<>();
@@ -149,7 +160,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
Collection<IInstallableUnit> ius = getBundleIU(bundle, publisherInfo, results);
if (ius != null) {
for (IInstallableUnit iu : ius) {
- IArtifactKey key = BundlesAction.createBundleArtifactKey(iu.getId(), iu.getVersion().toString());
+ IArtifactKey key = BundlesAction.createBundleArtifactKey(iu.getId(),
+ iu.getVersion().toString());
IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key);
if (descriptors.length > 0 && descriptors[0] instanceof ArtifactDescriptor) {
HashMap<String, String> map = new HashMap<>();
@@ -160,17 +172,20 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
}
}
- // If there was no artifact repository available and stats were to be tracked, issue
+ // If there was no artifact repository available and stats were to be tracked,
+ // issue
// a warning.
boolean markingBundles = bundles != null && bundles.length > 0;
boolean markingFeatures = features != null && features.length > 0;
if (artifactRepo == null && (markingBundles || markingFeatures))
- return new Status(IStatus.WARNING, Activator.ID, "Artifact repository was not specified so stats properties could not be published."); //$NON-NLS-1$
+ return new Status(IStatus.WARNING, Activator.ID,
+ "Artifact repository was not specified so stats properties could not be published."); //$NON-NLS-1$
return Status.OK_STATUS;
}
- private IStatus generateCategories(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
+ private IStatus generateCategories(IPublisherInfo publisherInfo, IPublisherResult results,
+ IProgressMonitor monitor) {
Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs = new HashMap<>();
Map<SiteFeature, Set<SiteCategory>> featuresToCategories = getFeatureToCategoryMappings(publisherInfo);
for (SiteFeature feature : featuresToCategories.keySet()) {
@@ -180,7 +195,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
if (ius == null)
continue;
Set<SiteCategory> categories = featuresToCategories.get(feature);
- // if there are no categories for this feature then add it to the default category.
+ // if there are no categories for this feature then add it to the default
+ // category.
if (categories == null || categories.isEmpty())
categories = defaultCategorySet;
for (SiteCategory category : categories) {
@@ -201,7 +217,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
if (ius == null)
continue;
Set<SiteCategory> categories = bundlesToCategories.get(bundle);
- // if there are no categories for this feature then add it to the default category.
+ // if there are no categories for this feature then add it to the default
+ // category.
if (categories == null || categories.isEmpty())
categories = defaultCategorySet;
for (SiteCategory category : categories) {
@@ -219,7 +236,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
return Status.OK_STATUS;
}
- private void addSiteIUsToCategories(Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs, IPublisherInfo publisherInfo, IPublisherResult results) {
+ private void addSiteIUsToCategories(Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs,
+ IPublisherInfo publisherInfo, IPublisherResult results) {
Map<SiteIU, Set<SiteCategory>> iusToCategories = getIUToCategoryMappings(publisherInfo);
SiteModel site = updateSite.getSite();
if (site == null)
@@ -230,7 +248,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
if (ius == null)
continue;
Set<SiteCategory> categories = iusToCategories.get(siteIU);
- // if there are no categories for this feature then add it to the default category.
+ // if there are no categories for this feature then add it to the default
+ // category.
if (categories == null || categories.isEmpty())
categories = defaultCategorySet;
for (SiteCategory category : categories) {
@@ -254,7 +273,7 @@ public class SiteXMLAction extends AbstractPublisherAction {
SiteIU[] ius = site.getIUs();
for (int i = 0; i < ius.length; i++) {
- //add a mapping for each category this feature belongs to
+ // add a mapping for each category this feature belongs to
String[] categoryNames = ius[i].getCategoryNames();
Set<SiteCategory> categories = new HashSet<>();
mappings.put(ius[i], categories);
@@ -297,10 +316,12 @@ public class SiteXMLAction extends AbstractPublisherAction {
private static final IExpression qualifierMatchExpr = ExpressionUtil.parse("id == $0 && version ~= $1"); //$NON-NLS-1$
- private Collection<IInstallableUnit> getFeatureIU(SiteFeature feature, IPublisherInfo publisherInfo, IPublisherResult results) {
+ private Collection<IInstallableUnit> getFeatureIU(SiteFeature feature, IPublisherInfo publisherInfo,
+ IPublisherResult results) {
String id = feature.getFeatureIdentifier() + ".feature.group"; //$NON-NLS-1$
String versionString = feature.getFeatureVersion();
- Version version = versionString != null && versionString.length() > 0 ? Version.create(versionString) : Version.emptyVersion;
+ Version version = versionString != null && versionString.length() > 0 ? Version.create(versionString)
+ : Version.emptyVersion;
IQuery<IInstallableUnit> query = null;
if (version.equals(Version.emptyVersion)) {
query = QueryUtil.createIUQuery(id);
@@ -331,10 +352,12 @@ public class SiteXMLAction extends AbstractPublisherAction {
return null;
}
- private Collection<IInstallableUnit> getBundleIU(SiteBundle bundle, IPublisherInfo publisherInfo, IPublisherResult results) {
+ private Collection<IInstallableUnit> getBundleIU(SiteBundle bundle, IPublisherInfo publisherInfo,
+ IPublisherResult results) {
String id = bundle.getBundleIdentifier();
String versionString = bundle.getBundleVersion();
- Version version = versionString != null && versionString.length() > 0 ? Version.create(versionString) : Version.emptyVersion;
+ Version version = versionString != null && versionString.length() > 0 ? Version.create(versionString)
+ : Version.emptyVersion;
IQuery<IInstallableUnit> query = null;
if (version.equals(Version.emptyVersion)) {
query = QueryUtil.createIUQuery(id);
@@ -378,12 +401,15 @@ public class SiteXMLAction extends AbstractPublisherAction {
Version lower = Version.parseVersion(newVersion);
Version upper = null;
- String newQualifier = VersionSuffixGenerator.incrementQualifier(PublisherHelper.toOSGiVersion(lower).getQualifier());
+ String newQualifier = VersionSuffixGenerator
+ .incrementQualifier(PublisherHelper.toOSGiVersion(lower).getQualifier());
org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(lower);
if (newQualifier == null)
- upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro() + 1);
+ upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(),
+ osgiVersion.getMicro() + 1);
else
- upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro(), newQualifier);
+ upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro(),
+ newQualifier);
range = new VersionRange(lower, true, upper, false);
} else {
range = new VersionRange(Version.parseVersion(versionId), true, Version.parseVersion(versionId), true);
@@ -393,8 +419,9 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Computes the mapping of features to categories as defined in the site.xml,
- * if available. Returns an empty map if there is not site.xml, or no categories.
+ * Computes the mapping of features to categories as defined in the site.xml, if
+ * available. Returns an empty map if there is not site.xml, or no categories.
+ *
* @return A map of SiteFeature -> Set<SiteCategory>.
*/
protected Map<SiteFeature, Set<SiteCategory>> getFeatureToCategoryMappings(IPublisherInfo publisherInfo) {
@@ -407,7 +434,7 @@ public class SiteXMLAction extends AbstractPublisherAction {
SiteFeature[] features = site.getFeatures();
for (int i = 0; i < features.length; i++) {
- //add a mapping for each category this feature belongs to
+ // add a mapping for each category this feature belongs to
String[] categoryNames = features[i].getCategoryNames();
Set<SiteCategory> categories = mappings.get(features[i]);
if (categories == null) {
@@ -424,8 +451,9 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Computes the mapping of bundles to categories as defined in the site.xml,
- * if available. Returns an empty map if there is not site.xml, or no categories.
+ * Computes the mapping of bundles to categories as defined in the site.xml, if
+ * available. Returns an empty map if there is not site.xml, or no categories.
+ *
* @return A map of SiteBundle -> Set<SiteCategory>.
*/
protected Map<SiteBundle, Set<SiteCategory>> getBundleToCategoryMappings(IPublisherInfo publisherInfo) {
@@ -438,7 +466,7 @@ public class SiteXMLAction extends AbstractPublisherAction {
SiteBundle[] bundles = site.getBundles();
for (int i = 0; i < bundles.length; i++) {
- //add a mapping for each category this feature belongs to
+ // add a mapping for each category this feature belongs to
String[] categoryNames = bundles[i].getCategoryNames();
Set<SiteCategory> categories = new HashSet<>();
mappings.put(bundles[i], categories);
@@ -452,25 +480,28 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Initializes new p2 repository attributes such as mirror info, associate sites, localization...
+ * Initializes new p2 repository attributes such as mirror info, associate
+ * sites, localization...
+ *
* @param publisherInfo configuration for output repository
*/
private void initializeRepoFromSite(IPublisherInfo publisherInfo) {
SiteModel site = updateSite.getSite();
- //copy mirror information from update site to p2 repositories
+ // copy mirror information from update site to p2 repositories
String mirrors = site.getMirrorsURI();
if (mirrors != null) {
- //remove site.xml file reference
+ // remove site.xml file reference
int index = mirrors.indexOf("site.xml"); //$NON-NLS-1$
if (index != -1)
mirrors = mirrors.substring(0, index) + mirrors.substring(index + "site.xml".length()); //$NON-NLS-1$
publisherInfo.getMetadataRepository().setProperty(IRepository.PROP_MIRRORS_URL, mirrors);
- // there does not really need to be an artifact repo but if there is, setup its mirrors.
+ // there does not really need to be an artifact repo but if there is, setup its
+ // mirrors.
if (publisherInfo.getArtifactRepository() != null)
publisherInfo.getArtifactRepository().setProperty(IRepository.PROP_MIRRORS_URL, mirrors);
}
- //publish associate sites as repository references
+ // publish associate sites as repository references
URLEntry[] associatedSites = site.getAssociatedSites();
if (associatedSites != null) {
ArrayList<IRepositoryReference> refs = new ArrayList<>(associatedSites.length * 2);
@@ -480,8 +511,10 @@ public class SiteXMLAction extends AbstractPublisherAction {
try {
URI associateLocation = new URI(siteLocation);
String label = associatedSite.getAnnotation();
- refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_METADATA, IRepository.ENABLED));
- refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_ARTIFACT, IRepository.ENABLED));
+ refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_METADATA,
+ IRepository.ENABLED));
+ refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_ARTIFACT,
+ IRepository.ENABLED));
} catch (URISyntaxException e) {
String message = "Invalid site reference: " + siteLocation; //$NON-NLS-1$
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
@@ -490,7 +523,7 @@ public class SiteXMLAction extends AbstractPublisherAction {
publisherInfo.getMetadataRepository().addReferences(refs);
}
- //publish repository references from category file
+ // publish repository references from category file
IRepositoryReference[] refs = site.getRepositoryReferences();
if (refs != null) {
ArrayList<IRepositoryReference> toAdd = new ArrayList<>(Arrays.asList(refs));
@@ -510,20 +543,25 @@ public class SiteXMLAction extends AbstractPublisherAction {
List<String> messageKeys = site.getMessageKeys();
if (siteParent.isDirectory()) {
String[] keyStrings = messageKeys.toArray(new String[messageKeys.size()]);
- site.setLocalizations(LocalizationHelper.getDirPropertyLocalizations(siteParent, "site", null, keyStrings)); //$NON-NLS-1$
+ site.setLocalizations(
+ LocalizationHelper.getDirPropertyLocalizations(siteParent, "site", null, keyStrings)); //$NON-NLS-1$
} else if (siteFile.getName().endsWith(".jar")) { //$NON-NLS-1$
String[] keyStrings = messageKeys.toArray(new String[messageKeys.size()]);
- site.setLocalizations(LocalizationHelper.getJarPropertyLocalizations(siteParent, "site", null, keyStrings)); //$NON-NLS-1$
+ site.setLocalizations(
+ LocalizationHelper.getJarPropertyLocalizations(siteParent, "site", null, keyStrings)); //$NON-NLS-1$
}
}
}
/**
* Generates IUs corresponding to update site categories.
- * @param categoriesToIUs Map of SiteCategory ->Set (Feature IUs in that category).
- * @param result The generator result being built
+ *
+ * @param categoriesToIUs Map of SiteCategory ->Set (Feature IUs in that
+ * category).
+ * @param result The generator result being built
*/
- protected void generateCategoryIUs(Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs, IPublisherResult result) {
+ protected void generateCategoryIUs(Map<SiteCategory, Set<IInstallableUnit>> categoriesToIUs,
+ IPublisherResult result) {
Map<String, SiteCategory> nameToCategory = new HashMap<>();
for (SiteCategory category : this.updateSite.getSite().getCategories()) {
nameToCategory.put(category.getName(), category);
@@ -604,14 +642,19 @@ public class SiteXMLAction extends AbstractPublisherAction {
/**
* Creates an IU corresponding to an update site category
- * @param category The category descriptor
- * @param childrenIUs The IUs of the children that belong to the category (can be bundle, feature or nested categories)
+ *
+ * @param category The category descriptor
+ * @param childrenIUs The IUs of the children that belong to the category
+ * (can be bundle, feature or nested categories)
* @param nestedCategory A nested category (optional)
* @return an IU representing the category
- * @deprecated use {@link IInstallableUnit}{@link #createCategoryIU(SiteCategory, Set)} instead
+ * @deprecated use
+ * {@link IInstallableUnit}{@link #createCategoryIU(SiteCategory, Set)}
+ * instead
*/
@Deprecated
- public IInstallableUnit createCategoryIU(SiteCategory category, Set<IInstallableUnit> childrenIUs, IInstallableUnit nestedCategory) {
+ public IInstallableUnit createCategoryIU(SiteCategory category, Set<IInstallableUnit> childrenIUs,
+ IInstallableUnit nestedCategory) {
Set<IInstallableUnit> allIUs = new HashSet<>();
if (childrenIUs != null) {
allIUs.addAll(childrenIUs);
@@ -624,8 +667,10 @@ public class SiteXMLAction extends AbstractPublisherAction {
/**
* Creates an IU corresponding to an update site category
- * @param category The category descriptor
- * @param childrenIUs The IUs of the children that belong to the category (can be bundle, feature or nested categories)
+ *
+ * @param category The category descriptor
+ * @param childrenIUs The IUs of the children that belong to the category (can
+ * be bundle, feature or nested categories)
* @return an IU representing the category
*/
public IInstallableUnit createCategoryIU(SiteCategory category, Set<IInstallableUnit> childrenIUs) {
@@ -634,7 +679,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
String categoryId = buildCategoryId(category.getName());
cat.setId(categoryId);
if (categoryVersion == null)
- cat.setVersion(Version.createOSGi(1, 0, 0, versionSuffixGenerator.generateSuffix(childrenIUs, Collections.emptyList())));
+ cat.setVersion(Version.createOSGi(1, 0, 0,
+ versionSuffixGenerator.generateSuffix(childrenIUs, Collections.emptyList())));
else {
if (categoryVersion.isOSGiCompatible()) {
org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(categoryVersion);
@@ -642,7 +688,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
if (qualifier.endsWith(QUALIFIER)) {
String suffix = versionSuffixGenerator.generateSuffix(childrenIUs, Collections.emptyList());
qualifier = qualifier.substring(0, qualifier.length() - 9) + suffix;
- categoryVersion = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro(), qualifier);
+ categoryVersion = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(),
+ osgiVersion.getMicro(), qualifier);
}
}
cat.setVersion(categoryVersion);
@@ -655,7 +702,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
ArrayList<IRequirement> reqsConfigurationUnits = new ArrayList<>(childrenIUs.size());
for (IInstallableUnit iu : childrenIUs) {
VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
- reqsConfigurationUnits.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), range, iu.getFilter(), false, false));
+ reqsConfigurationUnits.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(),
+ range, iu.getFilter(), false, false));
}
cat.setRequirements(reqsConfigurationUnits.toArray(new IRequirement[reqsConfigurationUnits.size()]));
@@ -683,8 +731,8 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Creates a qualified category id. This action's qualifier is used if one exists
- * or an existing update site's location is used.
+ * Creates a qualified category id. This action's qualifier is used if one
+ * exists or an existing update site's location is used.
*/
private String buildCategoryId(String categoryName) {
if (categoryQualifier != null) {
@@ -704,6 +752,6 @@ public class SiteXMLAction extends AbstractPublisherAction {
repo = info.getArtifactRepository();
if (repo == null)
throw new IllegalStateException("The transport service can not be found."); //$NON-NLS-1$
- return (Transport) repo.getProvisioningAgent().getService(Transport.SERVICE_NAME);
+ return repo.getProvisioningAgent().getService(Transport.class);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/artifact/UpdateSiteArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/artifact/UpdateSiteArtifactRepositoryFactory.java
index 950e8f146..3879f9ffa 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/artifact/UpdateSiteArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/artifact/UpdateSiteArtifactRepositoryFactory.java
@@ -48,7 +48,7 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
@Override
public IArtifactRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException {
- //return null if the caller wanted a modifiable repo
+ // return null if the caller wanted a modifiable repo
if ((flags & IRepositoryManager.REPOSITORY_HINT_MODIFIABLE) > 0) {
return null;
}
@@ -65,7 +65,8 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
throw (ProvisionException) e;
if (e instanceof OperationCanceledException)
throw (OperationCanceledException) e;
- throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Unexpected_exception, location.toString()), e));
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID,
+ NLS.bind(Messages.Unexpected_exception, location.toString()), e));
}
return new UpdateSiteArtifactRepository(location, repository);
}
@@ -91,14 +92,15 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
try {
return factory.load(localRepositoryURL, 0, monitor);
} catch (ProvisionException e) {
- //fall through and create a new repository
+ // fall through and create a new repository
}
String repositoryName = "update site: " + location; //$NON-NLS-1$
return factory.create(localRepositoryURL, repositoryName, null, null);
}
- public void initializeRepository(IArtifactRepository repository, URI location, IProgressMonitor monitor) throws ProvisionException {
- UpdateSite updateSite = UpdateSite.load(location, (Transport) getAgent().getService(Transport.SERVICE_NAME), monitor);
+ public void initializeRepository(IArtifactRepository repository, URI location, IProgressMonitor monitor)
+ throws ProvisionException {
+ UpdateSite updateSite = UpdateSite.load(location, getAgent().getService(Transport.class), monitor);
String savedChecksum = repository.getProperties().get(PROP_SITE_CHECKSUM);
if (savedChecksum != null && savedChecksum.equals(updateSite.getChecksum()))
return;
@@ -112,7 +114,8 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
generateArtifactDescriptors(updateSite, repository, monitor);
}
- private void generateArtifactDescriptors(UpdateSite updateSite, IArtifactRepository repository, IProgressMonitor monitor) throws ProvisionException {
+ private void generateArtifactDescriptors(UpdateSite updateSite, IArtifactRepository repository,
+ IProgressMonitor monitor) throws ProvisionException {
final String PACK_EXT = ".pack.gz"; //$NON-NLS-1$
Set<IArtifactDescriptor> allSiteArtifacts = new HashSet<>();
boolean packSupported = updateSite.getSite().isPack200Supported();
@@ -120,7 +123,8 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
Feature[] features = updateSite.loadFeatures(monitor);
for (int i = 0; i < features.length; i++) {
Feature feature = features[i];
- IArtifactKey featureKey = FeaturesAction.createFeatureArtifactKey(feature.getId(), feature.getVersion());
+ IArtifactKey featureKey = FeaturesAction.createFeatureArtifactKey(feature.getId(),
+ feature.getVersion());
SimpleArtifactDescriptor featureArtifactDescriptor = new SimpleArtifactDescriptor(featureKey);
URI featureURL = updateSite.getFeatureURI(feature.getId(), feature.getVersion());
featureArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE, featureURL.toString());
@@ -130,10 +134,13 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
// Update site supports pack200, create a packed descriptor
featureArtifactDescriptor = new SimpleArtifactDescriptor(featureKey);
featureURL = updateSite.getFeatureURI(feature.getId(), feature.getVersion());
- featureArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE, featureURL.toString() + PACK_EXT);
- IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$
+ featureArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE,
+ featureURL.toString() + PACK_EXT);
+ IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] { new ProcessingStepDescriptor(
+ "org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true) }; //$NON-NLS-1$
featureArtifactDescriptor.setProcessingSteps(steps);
- featureArtifactDescriptor.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
+ featureArtifactDescriptor.setProperty(IArtifactDescriptor.FORMAT,
+ IArtifactDescriptor.FORMAT_PACKED);
allSiteArtifacts.add(featureArtifactDescriptor);
}
@@ -152,10 +159,14 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
key = BundlesAction.createBundleArtifactKey(entry.getId(), entry.getVersion());
artifactDescriptor = new SimpleArtifactDescriptor(key);
pluginURL = updateSite.getPluginURI(entry);
- artifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE, pluginURL.toString() + PACK_EXT);
- IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$
+ artifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE,
+ pluginURL.toString() + PACK_EXT);
+ IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {
+ new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", //$NON-NLS-1$
+ null, true) };
artifactDescriptor.setProcessingSteps(steps);
- artifactDescriptor.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
+ artifactDescriptor.setProperty(IArtifactDescriptor.FORMAT,
+ IArtifactDescriptor.FORMAT_PACKED);
allSiteArtifacts.add(artifactDescriptor);
}
}
@@ -166,7 +177,8 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
BundleDescription[] bundles = updateSite.loadBundles(monitor);
for (int i = 0; i < bundles.length; i++) {
BundleDescription bundle = bundles[i];
- IArtifactKey bundleKey = BundlesAction.createBundleArtifactKey(bundle.getSymbolicName(), bundle.getVersion().toString());
+ IArtifactKey bundleKey = BundlesAction.createBundleArtifactKey(bundle.getSymbolicName(),
+ bundle.getVersion().toString());
SimpleArtifactDescriptor bundleArtifactDescriptor = new SimpleArtifactDescriptor(bundleKey);
URI bundleURI = updateSite.getBundleURI(bundle.getSymbolicName(), bundle.getVersion().toString());
bundleArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE, bundleURI.toString());
@@ -176,8 +188,10 @@ public class UpdateSiteArtifactRepositoryFactory extends ArtifactRepositoryFacto
// Update site supports pack200, create a packed descriptor
bundleArtifactDescriptor = new SimpleArtifactDescriptor(bundleKey);
bundleURI = updateSite.getBundleURI(bundle.getSymbolicName(), bundle.getVersion().toString());
- bundleArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE, bundleURI.toString() + PACK_EXT);
- IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$
+ bundleArtifactDescriptor.setRepositoryProperty(PROP_ARTIFACT_REFERENCE,
+ bundleURI.toString() + PACK_EXT);
+ IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] { new ProcessingStepDescriptor(
+ "org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true) }; //$NON-NLS-1$
bundleArtifactDescriptor.setProcessingSteps(steps);
bundleArtifactDescriptor.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
allSiteArtifacts.add(bundleArtifactDescriptor);
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepositoryFactory.java
index bb4cbf2bc..815d8baa6 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepositoryFactory.java
@@ -48,7 +48,7 @@ public class UpdateSiteMetadataRepositoryFactory extends MetadataRepositoryFacto
@Override
public IMetadataRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException {
- //return null if the caller wanted a modifiable repo
+ // return null if the caller wanted a modifiable repo
if ((flags & IRepositoryManager.REPOSITORY_HINT_MODIFIABLE) > 0) {
return null;
}
@@ -65,7 +65,8 @@ public class UpdateSiteMetadataRepositoryFactory extends MetadataRepositoryFacto
throw (ProvisionException) e;
if (e instanceof OperationCanceledException)
throw (OperationCanceledException) e;
- throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Unexpected_exception, location.toString()), e));
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID,
+ NLS.bind(Messages.Unexpected_exception, location.toString()), e));
}
return new UpdateSiteMetadataRepository(location, repository);
}
@@ -91,21 +92,22 @@ public class UpdateSiteMetadataRepositoryFactory extends MetadataRepositoryFacto
try {
return factory.load(localRepositoryURL, 0, monitor);
} catch (ProvisionException e) {
- //fall through and create a new repository
+ // fall through and create a new repository
}
String repositoryName = "update site: " + location; //$NON-NLS-1$
return factory.create(localRepositoryURL, repositoryName, null, null);
}
- public void initializeRepository(IMetadataRepository repository, URI location, IProgressMonitor monitor) throws ProvisionException {
- UpdateSite updateSite = UpdateSite.load(location, (Transport) getAgent().getService(Transport.SERVICE_NAME), monitor);
+ public void initializeRepository(IMetadataRepository repository, URI location, IProgressMonitor monitor)
+ throws ProvisionException {
+ UpdateSite updateSite = UpdateSite.load(location, getAgent().getService(Transport.class), monitor);
String savedChecksum = repository.getProperties().get(PROP_SITE_CHECKSUM);
if (savedChecksum != null && savedChecksum.equals(updateSite.getChecksum()))
return;
repository.setProperty(PROP_SITE_CHECKSUM, updateSite.getChecksum());
repository.removeAll();
IStatus status = generateMetadata(updateSite, repository, monitor);
- //site references should be published on load
+ // site references should be published on load
if (repository instanceof LocalMetadataRepository)
((LocalMetadataRepository) repository).publishRepositoryReferences();
if (monitor.isCanceled())
@@ -117,7 +119,7 @@ public class UpdateSiteMetadataRepositoryFactory extends MetadataRepositoryFacto
private IStatus generateMetadata(UpdateSite updateSite, IMetadataRepository repository, IProgressMonitor monitor) {
PublisherInfo info = new PublisherInfo();
info.setMetadataRepository(repository);
- IPublisherAction[] actions = new IPublisherAction[] {new RemoteUpdateSiteAction(updateSite, null)};
+ IPublisherAction[] actions = new IPublisherAction[] { new RemoteUpdateSiteAction(updateSite, null) };
Publisher publisher = new Publisher(info);
return publisher.publish(actions, monitor);
}

Back to the top