diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java index 9f910cddf..0ff870c37 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.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 - Bug 400011 - [shared] Cleanup the SurrogateProfileHandler code @@ -60,8 +60,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { "profileProperties[$0] == 'true' || (touchpointType != null && touchpointType.id == $1)", //$NON-NLS-1$ IProfile.PROP_PROFILE_ROOT_IU, NATIVE_TOUCHPOINT_TYPE); IQueryResult<IInstallableUnit> rootIUs = sharedProfile.query(rootIUQuery, null); - for (Iterator<IInstallableUnit> iterator = rootIUs.iterator(); iterator.hasNext();) { - IInstallableUnit iu = iterator.next(); + for (IInstallableUnit iu : rootIUs) { userProfile.addInstallableUnit(iu); userProfile.addInstallableUnitProperties(iu, sharedProfile.getInstallableUnitProperties(iu)); userProfile.setInstallableUnitProperty(iu, IProfile.PROP_PROFILE_LOCKED_IU, IU_LOCKED); @@ -86,8 +85,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { ArrayList<IRequirement> iuRequirements = new ArrayList<>(); IQueryResult<IInstallableUnit> allIUs = sharedProfile.query(QueryUtil.createIUAnyQuery(), null); - for (Iterator<IInstallableUnit> iterator = allIUs.iterator(); iterator.hasNext();) { - IInstallableUnit iu = iterator.next(); + for (IInstallableUnit iu : allIUs) { IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse("id == $0 && version == $1"), iu.getId(), iu.getVersion()); //$NON-NLS-1$ iuRequirements.add(MetadataFactory.createRequirement(iuMatcher, null, 0, 1, true)); } @@ -116,7 +114,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { File configurationFolder = new File(configurationLocation.getURL().getPath()); userProfile.setProperty(IProfile.PROP_CONFIGURATION_FOLDER, configurationFolder.getAbsolutePath()); - // We need to check that the configuration folder is not a file system root. + // We need to check that the configuration folder is not a file system root. // some of the profiles resources are stored as siblings to the configuration folder. // also see bug 230384 if (configurationFolder.getParentFile() == null) @@ -181,7 +179,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { */ private void setUpRepos() { //clean old junk - IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metaManager = agent.getService(IMetadataRepositoryManager.class); URI[] knownRepositories = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL); for (URI uri : knownRepositories) { if ("true".equals(metaManager.getRepositoryProperty(uri, EngineActivator.P2_FRAGMENT_PROPERTY))) { //$NON-NLS-1$ @@ -189,7 +187,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { } } - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); + IArtifactRepositoryManager artifactManager = agent.getService(IArtifactRepositoryManager.class); knownRepositories = artifactManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL); for (URI uri : knownRepositories) { if ("true".equals(artifactManager.getRepositoryProperty(uri, EngineActivator.P2_FRAGMENT_PROPERTY))) { //$NON-NLS-1$ @@ -226,7 +224,7 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler { Set<IInstallableUnit> added = new HashSet<>(); for (File extension : extensionLocations) { try { - IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metaManager = agent.getService(IMetadataRepositoryManager.class); IMetadataRepository repo = metaManager.loadRepository(extension.toURI(), new NullProgressMonitor()); Set<IInstallableUnit> installableUnits = repo.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).toUnmodifiableSet(); for (IInstallableUnit unit : installableUnits) { |