Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2019-06-28 13:12:15 +0000
committerAlexander Kurtakov2019-07-01 13:09:05 +0000
commitbb27e7b3fc060a62805281221eac19e21803b40f (patch)
tree8e38f4d2a6c119f777e9d0963e7fc85cb5a06a4a
parent0406e1d0248310054a35232f5840b5c3c50ab5fd (diff)
downloadrt.equinox.p2-bb27e7b3fc060a62805281221eac19e21803b40f.tar.gz
rt.equinox.p2-bb27e7b3fc060a62805281221eac19e21803b40f.tar.xz
rt.equinox.p2-bb27e7b3fc060a62805281221eac19e21803b40f.zip
Convert to the generic IProvisioningAgent.getService()
Change-Id: If595ceb183461e5a9565d58ccd6a432291f2281b Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/OptimizerApplication.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java60
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/XZedSimpleArtifactRepositoryFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java147
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java134
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/ProfileChangeRequest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java14
22 files changed, 303 insertions, 322 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/OptimizerApplication.java b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/OptimizerApplication.java
index 0f6172174..5e1baf9e5 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/OptimizerApplication.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.optimizers/src/org/eclipse/equinox/internal/p2/artifact/optimizers/OptimizerApplication.java
@@ -26,7 +26,7 @@ public abstract class OptimizerApplication implements IApplication {
}
public static IArtifactRepositoryManager getArtifactRepositoryManager() {
- return (IArtifactRepositoryManager) getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return getAgent().getService(IArtifactRepositoryManager.class);
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
index ff0c92368..5080995ed 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.processors/src/org/eclipse/equinox/internal/p2/artifact/processors/AbstractDeltaProcessorStep.java
@@ -47,8 +47,7 @@ public abstract class AbstractDeltaProcessorStep extends AbstractDeltaStep {
private void fetchLocalArtifactRepository(IProvisioningAgent agent) {
if (repository != null)
return;
- IArtifactRepositoryManager repoMgr = (IArtifactRepositoryManager) agent
- .getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager repoMgr = agent.getService(IArtifactRepositoryManager.class);
if (repoMgr == null) {
setStatus(new Status(IStatus.ERROR, Activator.ID, "Could not get artifact repository manager."));
return;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
index c95e3ced2..b3d672410 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
@@ -31,10 +31,11 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory;
/**
* Default implementation of {@link IArtifactRepositoryManager}.
*
- * TODO the current assumption that the "location" is the dir/root limits us to
- * having just one repository in a given URL..
+ * TODO the current assumption that the "location" is the dir/root limits us to
+ * having just one repository in a given URL..
*/
-public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifactKey> implements IArtifactRepositoryManager {
+public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifactKey>
+ implements IArtifactRepositoryManager {
public ArtifactRepositoryManager(IProvisioningAgent agent) {
super(agent);
@@ -45,17 +46,23 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
}
@Override
- public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties) {
- return createMirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties, null);
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination,
+ Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties) {
+ return createMirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties,
+ null);
}
@Override
- public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination, Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties, String downloadStatsParameters) {
- return new MirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties, getTransport(), downloadStatsParameters);
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IArtifactRepository destination,
+ Map<String, String> destinationDescriptorProperties, Map<String, String> destinationRepositoryProperties,
+ String downloadStatsParameters) {
+ return new MirrorRequest(key, destination, destinationDescriptorProperties, destinationRepositoryProperties,
+ getTransport(), downloadStatsParameters);
}
@Override
- public IArtifactRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException {
+ public IArtifactRepository createRepository(URI location, String name, String type, Map<String, String> properties)
+ throws ProvisionException {
return (IArtifactRepository) doCreateRepository(location, name, type, properties);
}
@@ -64,8 +71,10 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
}
@Override
- protected IRepository<IArtifactKey> factoryCreate(URI location, String name, String type, Map<String, String> properties, IExtension extension) throws ProvisionException {
- ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) createExecutableExtension(extension, EL_FACTORY);
+ protected IRepository<IArtifactKey> factoryCreate(URI location, String name, String type,
+ Map<String, String> properties, IExtension extension) throws ProvisionException {
+ ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) createExecutableExtension(extension,
+ EL_FACTORY);
if (factory == null)
return null;
factory.setAgent(agent);
@@ -73,8 +82,10 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
}
@Override
- protected IRepository<IArtifactKey> factoryLoad(URI location, IExtension extension, int flags, SubMonitor monitor) throws ProvisionException {
- ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) createExecutableExtension(extension, EL_FACTORY);
+ protected IRepository<IArtifactKey> factoryLoad(URI location, IExtension extension, int flags, SubMonitor monitor)
+ throws ProvisionException {
+ ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) createExecutableExtension(extension,
+ EL_FACTORY);
if (factory == null)
return null;
factory.setAgent(agent);
@@ -115,7 +126,8 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
}
@Override
- public IArtifactRepository loadRepository(URI location, int flags, IProgressMonitor monitor) throws ProvisionException {
+ public IArtifactRepository loadRepository(URI location, int flags, IProgressMonitor monitor)
+ throws ProvisionException {
return (IArtifactRepository) loadRepository(location, monitor, null, flags);
}
@@ -134,8 +146,9 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
*/
@Override
protected void restoreSpecialRepositories() {
- // TODO while recreating, we may want to have proxies on repo instead of the real repo object to limit what is activated.
- IAgentLocation location = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME);
+ // TODO while recreating, we may want to have proxies on repo instead of the
+ // real repo object to limit what is activated.
+ IAgentLocation location = getAgent().getService(IAgentLocation.class);
if (location == null)
// TODO should do something here since we are failing to restore.
return;
@@ -147,7 +160,8 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager<IArtifa
} catch (ProvisionException e) {
// log but still continue and try to create a new one
if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND)
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Error occurred while loading download cache.", e)); //$NON-NLS-1$
+ LogHelper.log(
+ new Status(IStatus.ERROR, Activator.ID, "Error occurred while loading download cache.", e)); //$NON-NLS-1$
}
try {
Map<String, String> properties = new HashMap<>(1);
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
index aa90ed671..e6716fe09 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java
@@ -60,7 +60,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
public static CompositeArtifactRepository createMemoryComposite(IProvisioningAgent agent) {
if (agent == null)
return null;
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager manager = agent.getService(IArtifactRepositoryManager.class);
if (manager == null)
return null;
try {
@@ -128,7 +128,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
/*
* Add the given object to the specified list if it doesn't already exist
- * in it. Return a boolean value indicating whether or not the object was
+ * in it. Return a boolean value indicating whether or not the object was
* actually added.
*/
private static <T> boolean add(List<T> list, T obj) {
@@ -343,8 +343,8 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
for (ChildInfo current : loadedRepos) {
if (current.isGood()) {
IArtifactDescriptor[] tempResult = current.repo.getArtifactDescriptors(key);
- for (int i = 0; i < tempResult.length; i++)
- add(result, tempResult[i]);
+ for (IArtifactDescriptor element : tempResult)
+ add(result, element);
}
}
return result.toArray(new IArtifactDescriptor[result.size()]);
@@ -424,9 +424,9 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
private IArtifactRequest[] filterUnfetched(IArtifactRequest[] requests) {
ArrayList<IArtifactRequest> filteredRequests = new ArrayList<>();
- for (int i = 0; i < requests.length; i++) {
- if (requests[i].getResult() == null || !requests[i].getResult().isOK()) {
- filteredRequests.add(requests[i]);
+ for (IArtifactRequest request : requests) {
+ if (request.getResult() == null || !request.getResult().isOK()) {
+ filteredRequests.add(request);
}
}
@@ -437,16 +437,16 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository, IArtifactRequest[] requests) {
ArrayList<IArtifactRequest> applicable = new ArrayList<>();
- for (int i = 0; i < requests.length; i++) {
- if (repository.contains(requests[i].getArtifactKey()))
- applicable.add(requests[i]);
+ for (IArtifactRequest request : requests) {
+ if (repository.contains(request.getArtifactKey()))
+ applicable.add(request);
}
return applicable.toArray(new IArtifactRequest[applicable.size()]);
}
/**
* This method is only protected for testing purposes
- *
+ *
* @nooverride This method is not intended to be re-implemented or extended by clients.
* @noreference This method is not intended to be referenced by clients.
*/
@@ -508,7 +508,7 @@ public class CompositeArtifactRepository extends AbstractArtifactRepository impl
// * comparing content using the artifactComparator specified by the comparatorID
// * @param toCheckRepo the repository to check
// * @param comparatorID
- // * @return <code>true</code> if toCheckRepo is consistent, <code>false</code> if toCheckRepo
+ // * @return <code>true</code> if toCheckRepo is consistent, <code>false</code> if toCheckRepo
// * contains an equal descriptor to that of a child and they refer to different artifacts on disk.
// */
// private boolean isSane(IArtifactRepository toCheckRepo, String comparatorID) {
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
index f45a82d28..ef472df43 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
@@ -39,7 +39,7 @@ public class CompositeArtifactRepositoryFactory extends ArtifactRepositoryFactor
private IArtifactRepositoryManager getManager() {
if (getAgent() != null)
- return (IArtifactRepositoryManager) getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
+ return getAgent().getService(IArtifactRepositoryManager.class);
return null;
}
@@ -65,7 +65,7 @@ public class CompositeArtifactRepositoryFactory extends ArtifactRepositoryFactor
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, msg, null));
}
//file is not local, create a cache of the repository metadata
- CacheManager cache = (CacheManager) getAgent().getService(CacheManager.SERVICE_NAME);
+ CacheManager cache = getAgent().getService(CacheManager.class);
if (cache == null)
throw new IllegalArgumentException("Cache manager service not available"); //$NON-NLS-1$
localFile = cache.createCache(location, CompositeArtifactRepository.CONTENT_FILENAME, monitor);
@@ -120,7 +120,7 @@ public class CompositeArtifactRepositoryFactory extends ArtifactRepositoryFactor
CompositeArtifactRepository result = new CompositeArtifactRepository(getManager(), resultState, sub.newChild(200));
if (Tracing.DEBUG_METADATA_PARSING) {
time += System.currentTimeMillis();
- Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
+ Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
}
return result;
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
index c5a972bb0..965277d1c 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorRequest.java
@@ -66,7 +66,7 @@ public class MirrorRequest extends ArtifactRequest {
*/
private static final String PROP_DOWNLOAD_STATS = "download.stats"; //$NON-NLS-1$
/**
- * The additional parameters for downloading statistics
+ * The additional parameters for downloading statistics
*/
private String downloadStatsParamters;
@@ -128,11 +128,11 @@ public class MirrorRequest extends ArtifactRequest {
if (descriptor == null) {
IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(getArtifactKey());
if (descriptors.length > 0) {
- for (int i = 0; i < descriptors.length; i++) {
- if (descriptors[i].getProperty(IArtifactDescriptor.FORMAT) == null)
- canonical = descriptors[i];
- else if (ProcessingStepHandler.canProcess(descriptors[i]))
- optimized = descriptors[i];
+ for (IArtifactDescriptor descriptor2 : descriptors) {
+ if (descriptor2.getProperty(IArtifactDescriptor.FORMAT) == null)
+ canonical = descriptor2;
+ else if (ProcessingStepHandler.canProcess(descriptor2))
+ optimized = descriptor2;
}
boolean chooseCanonical = source.getLocation().getScheme().equals("file"); //$NON-NLS-1$
// If the source repo is local then look for a canonical descriptor so we don't waste processing time.
@@ -153,7 +153,7 @@ public class MirrorRequest extends ArtifactRequest {
IArtifactDescriptor destinationDescriptor = getDestinationDescriptor(descriptor);
IStatus status = transfer(destinationDescriptor, descriptor, monitor);
- // if ok, cancelled or transfer has already been done with the canonical form return with status set
+ // if ok, cancelled or transfer has already been done with the canonical form return with status set
if (status.getSeverity() == IStatus.CANCEL) {
setResult(status);
return;
@@ -177,8 +177,8 @@ public class MirrorRequest extends ArtifactRequest {
}
IStatus canonicalStatus = transfer(getDestinationDescriptor(canonical), canonical, monitor);
- // To prevent the optimized transfer status severity from dominating the canonical, only merge
- // if the canonical severity is equal to or higher than the optimized transfer severity.
+ // To prevent the optimized transfer status severity from dominating the canonical, only merge
+ // if the canonical severity is equal to or higher than the optimized transfer severity.
if (canonicalStatus.getSeverity() < status.getSeverity())
setResult(canonicalStatus);
else
@@ -215,7 +215,7 @@ public class MirrorRequest extends ArtifactRequest {
MultiStatus allResults = new MultiStatus(Activator.ID, 0, NLS.bind(Messages.MirrorRequest_transferFailed, sourceDescriptor), null);
IStatus lastResult = Status.OK_STATUS;
// go until we get one (OK), there are no more mirrors to consider or the operation is cancelled.
- // Put a hard limit of MAX_RETRY_REQUEST so we don't end up in an infinite loop.
+ // Put a hard limit of MAX_RETRY_REQUEST so we don't end up in an infinite loop.
// Really, if you've tried MAX_RETRY_REQUEST times without success, it's time to give up
// TODO Should we log that we gave up because of the retry count?
// TODO this needs to be redone with a much better mirror management scheme.
@@ -229,7 +229,7 @@ public class MirrorRequest extends ArtifactRequest {
throw (Error) lastResult.getException();
}
} while (lastResult.getSeverity() == IStatus.ERROR && lastResult.getCode() == IArtifactRepository.CODE_RETRY && counter++ < MAX_RETRY_REQUEST);
- IProvisioningEventBus bus = (IProvisioningEventBus) source.getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME);
+ IProvisioningEventBus bus = source.getProvisioningAgent().getService(IProvisioningEventBus.class);
if (bus != null)
bus.publishEvent(new MirrorEvent(source, sourceDescriptor, lastResult.isOK() ? lastResult : (allResults.getChildren().length <= 1 ? lastResult : allResults)));
if (lastResult.isOK()) {
@@ -258,7 +258,7 @@ public class MirrorRequest extends ArtifactRequest {
try {
statsURI = new URI(statsURI.getScheme(), statsURI.getUserInfo(), statsURI.getHost(), statsURI.getPort(), statsURI.getPath(), statsURI.getQuery() == null ? downloadStatsParamters : downloadStatsParamters + "&" + statsURI.getQuery(), statsURI.getFragment()); //$NON-NLS-1$
} catch (URISyntaxException e) {
- LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unable to create download statistics due to invalid URL query: " + statsRoot + " suffix: " + statsProperty + " query: " + downloadStatsParamters)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unable to create download statistics due to invalid URL query: " + statsRoot + " suffix: " + statsProperty + " query: " + downloadStatsParamters)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
} catch (URISyntaxException e) {
@@ -320,7 +320,7 @@ public class MirrorRequest extends ArtifactRequest {
}
/**
- * Extract the root cause. The root cause is the first severe non-MultiStatus status
+ * Extract the root cause. The root cause is the first severe non-MultiStatus status
* containing an exception when searching depth first otherwise null.
* @param status
* @return root cause
@@ -335,8 +335,8 @@ public class MirrorRequest extends ArtifactRequest {
if (children == null)
return constraintStatus(status);
- for (int i = 0; i < children.length; i++) {
- IStatus deeper = extractRootCause(children[i]);
+ for (IStatus element : children) {
+ IStatus deeper = extractRootCause(element);
if (deeper != null)
return deeper;
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 6b4e59349..a1a39477b 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -54,7 +54,7 @@ import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
public class SimpleArtifactRepository extends AbstractArtifactRepository implements IFileArtifactRepository, IIndexProvider<IArtifactKey> {
- /**
+ /**
* A boolean property controlling whether mirroring is enabled.
*/
public static final boolean MIRRORS_ENABLED = !"false".equals(Activator.getContext().getProperty("eclipse.p2.mirrors")); //$NON-NLS-1$//$NON-NLS-2$
@@ -85,7 +85,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
public static final String CONTENT_FILENAME = "artifacts"; //$NON-NLS-1$
- /**
+ /**
* The key for a integer property controls the maximum number
* of threads that should be used when optimizing downloads from a remote
* artifact repository.
@@ -152,7 +152,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
delete(file);
if (getStatus().isOK())
throw e;
- // if the stream has already been e.g. canceled, we can return - the status is already set correctly
+ // if the stream has already been e.g. canceled, we can return - the status is already set correctly
return;
}
// if the steps ran ok and there was actual content, write the artifact descriptor
@@ -296,8 +296,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
if (toDelete.isDirectory()) {
File[] children = toDelete.listFiles();
if (children != null) {
- for (int i = 0; i < children.length; i++) {
- delete(children[i]);
+ for (File element : children) {
+ delete(element);
}
}
}
@@ -458,10 +458,10 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
return;
}
- for (int i = 0; i < descriptors.length; i++) {
- if (artifactDescriptors.contains(descriptors[i]))
+ for (IArtifactDescriptor descriptor : descriptors) {
+ if (artifactDescriptors.contains(descriptor))
continue;
- SimpleArtifactDescriptor internalDescriptor = createInternalDescriptor(descriptors[i]);
+ SimpleArtifactDescriptor internalDescriptor = createInternalDescriptor(descriptor);
artifactDescriptors.add(internalDescriptor);
mapDescriptor(internalDescriptor);
}
@@ -520,12 +520,12 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
private String bytesToHexString(byte[] bytes) {
StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < bytes.length; i++) {
+ for (byte b : bytes) {
String hexString;
- if (bytes[i] < 0)
- hexString = Integer.toHexString(256 + bytes[i]);
+ if (b < 0)
+ hexString = Integer.toHexString(256 + b);
else
- hexString = Integer.toHexString(bytes[i]);
+ hexString = Integer.toHexString(b);
if (hexString.length() == 1)
buffer.append("0"); //$NON-NLS-1$
buffer.append(hexString);
@@ -567,7 +567,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
}
- // Otherwise generate a location by creating a UUID, remembering it in the properties
+ // Otherwise generate a location by creating a UUID, remembering it in the properties
// and computing the location
byte[] bytes = new UniversalUniqueIdentifier().toBytes();
descriptor.setProperty(ARTIFACT_UUID, bytesToHexString(bytes));
@@ -678,7 +678,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
* Copy a file to an output stream.
* Optionally close the streams when done.
* Notify the monitor about progress we make
- *
+ *
* @return the number of bytes written.
*/
private IStatus copyFileToStream(File in, OutputStream out, IProgressMonitor monitor) {
@@ -830,10 +830,10 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
if (numberOfJobs <= 1 || (!isForceThreading() && isLocal())) {
SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
try {
- for (int i = 0; i < requests.length; i++) {
+ for (IArtifactRequest request : requests) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
- IStatus result = getArtifact(requests[i], subMonitor.newChild(1));
+ IStatus result = getArtifact(request, subMonitor.newChild(1));
if (!result.isOK())
overallStatus.add(result);
}
@@ -948,7 +948,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
} catch (URISyntaxException e) {
return null;
}
- // in the end there is not enough information so return null
+ // in the end there is not enough information so return null
return null;
}
@@ -999,7 +999,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.no_location, newDescriptor)));
String file = URIUtil.toFile(newLocation).getAbsolutePath();
- // TODO at this point we have to assume that the repository is file-based. Eventually
+ // TODO at this point we have to assume that the repository is file-based. Eventually
// we should end up with writeable URLs...
// Make sure that the file does not exist and that the parents do
File outputFile = new File(file);
@@ -1024,7 +1024,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
target = new FileOutputStream(file);
}
- // finally create and return an output stream suitably wrapped so that when it is
+ // finally create and return an output stream suitably wrapped so that when it is
// closed the repository is updated with the descriptor
return new ArtifactOutputStream(new BufferedOutputStream(target), newDescriptor, outputFile);
} catch (IOException e) {
@@ -1060,7 +1060,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
private Transport getTransport() {
- return (Transport) getProvisioningAgent().getService(Transport.SERVICE_NAME);
+ return getProvisioningAgent().getService(Transport.class);
}
// use this method to setup any transient fields etc after the object has been restored from a stream
@@ -1096,7 +1096,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
private boolean isFolderBased(IArtifactDescriptor descriptor) {
// This is called from createInternalDescriptor, so if we aren't a
- // SimpleArtifactDescriptor then just check the descriptor properties instead
+ // SimpleArtifactDescriptor then just check the descriptor properties instead
// of creating the internal descriptor.
SimpleArtifactDescriptor internalDescriptor = null;
if (descriptor instanceof SimpleArtifactDescriptor)
@@ -1141,8 +1141,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
IArtifactDescriptor[] toRemove = artifactDescriptors.toArray(new IArtifactDescriptor[artifactDescriptors.size()]);
boolean changed = false;
- for (int i = 0; i < toRemove.length; i++)
- changed |= doRemoveArtifact(toRemove[i]);
+ for (IArtifactDescriptor element : toRemove)
+ changed |= doRemoveArtifact(element);
if (changed)
save();
} finally {
@@ -1226,8 +1226,8 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
IArtifactDescriptor[] toRemove = getArtifactDescriptors(key);
boolean changed = false;
- for (int i = 0; i < toRemove.length; i++)
- changed |= doRemoveArtifact(toRemove[i]);
+ for (IArtifactDescriptor element : toRemove)
+ changed |= doRemoveArtifact(element);
if (changed)
save();
} finally {
@@ -1263,7 +1263,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
if (!status.isOK()) {
// Transport pushes its status onto the output stream if the stream implements IStateful, to prevent
- // duplication determine if the Status is present in the ProcessingStep status.
+ // duplication determine if the Status is present in the ProcessingStep status.
boolean found = false;
IStatus[] stepStatusChildren = stepStatus.getChildren();
for (int i = 0; i < stepStatusChildren.length && !found; i++)
@@ -1456,7 +1456,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
/**
* Locks the location and optionally loads the repository.
- *
+ *
* @param ignoreLoad If ignoreLoad is set to true, then the location is locked
* but the repository is not loaded. It is expected
* that the caller will load the repository manually
@@ -1542,7 +1542,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
/**
- * Returns true if this instance of SimpleArtifactRepository holds the lock or
+ * Returns true if this instance of SimpleArtifactRepository holds the lock or
* this repository can't be locked at all due to permission, false otherwise.
*/
private boolean holdsLock() {
@@ -1568,7 +1568,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
* Loads the repository from disk. This method will do nothing
* if this instance of SimpleArtifactRepository holds the lock
* because it will have loaded the repo when it acquired the lock.
- *
+ *
* @param monitor
*/
private void load(IProgressMonitor monitor) {
@@ -1596,7 +1596,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
* Loads the repository from disk. If the last modified timestamp on the file <=
* to our cache, then this method does nothing. Otherwise the artifact repository
* on disk is loaded, and reconciled with this instance of the artifact repository.
- *
+ *
* @param monitor
*/
private void doLoad(IProgressMonitor monitor) {
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryFactory.java
index 83be3b2d4..d46fb0ff4 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryFactory.java
@@ -62,7 +62,7 @@ public class SimpleArtifactRepositoryFactory extends ArtifactRepositoryFactory {
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, msg, null));
}
// file is not local, create a cache of the repository metadata
- CacheManager cache = (CacheManager) getAgent().getService(CacheManager.SERVICE_NAME);
+ CacheManager cache = getAgent().getService(CacheManager.class);
if (cache == null)
throw new IllegalArgumentException("Cache manager service not available"); //$NON-NLS-1$
localFile = cache.createCache(location, SimpleArtifactRepository.CONTENT_FILENAME, monitor);
@@ -115,7 +115,7 @@ public class SimpleArtifactRepositoryFactory extends ArtifactRepositoryFactory {
return null;
if (Tracing.DEBUG_METADATA_PARSING) {
time += System.currentTimeMillis();
- Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
+ Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
}
return result;
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/XZedSimpleArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/XZedSimpleArtifactRepositoryFactory.java
index d8312b391..945132d19 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/XZedSimpleArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/XZedSimpleArtifactRepositoryFactory.java
@@ -59,7 +59,7 @@ public class XZedSimpleArtifactRepositoryFactory extends ArtifactRepositoryFacto
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, msg, null));
}
// file is not local, create a cache of the repository metadata
- CacheManager cache = (CacheManager) getAgent().getService(CacheManager.SERVICE_NAME);
+ CacheManager cache = getAgent().getService(CacheManager.class);
if (cache == null)
throw new IllegalArgumentException("Cache manager service not available"); //$NON-NLS-1$
localFile = cache.createCacheFromFile(URIUtil.append(location, REPOSITORY_FILENAME), monitor);
@@ -96,7 +96,7 @@ public class XZedSimpleArtifactRepositoryFactory extends ArtifactRepositoryFacto
result.initializeAfterLoad(location);
if (Tracing.DEBUG_METADATA_PARSING) {
time += System.currentTimeMillis();
- Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
+ Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
}
return result;
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
index 8bec88c08..b09f2dfb3 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.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
* Band XI - add more commands
* Composent, Inc. - command additions
@@ -47,27 +47,28 @@ public class ProvCommandProvider implements CommandProvider {
// holds the mapping between command name and command description
private Map<String, String> commandsHelp = null;
- // hold the mappings between command groups and the command names of the commands in the group
+ // hold the mappings between command groups and the command names of the
+ // commands in the group
private Map<String, String[]> commandGroups = null;
private final IProvisioningAgent agent;
- // private Profile profile;
+ // private Profile profile;
public ProvCommandProvider(String profileId, IProvisioningAgent agent) {
this.agent = agent;
// look up the profile we are currently running and use it as the
// default.
// TODO define a way to spec the default profile to manage
- // if (profileId != null) {
- // profile = registry.getProfile(profileId);
- // if (profile != null)
- // return;
- // }
- // // A default was not defined so manage the first profile we can find
- // Profile[] profiles = registry.getProfiles();
- // if (profiles.length > 0)
- // profile = profiles[0];
+ // if (profileId != null) {
+ // profile = registry.getProfile(profileId);
+ // if (profile != null)
+ // return;
+ // }
+ // // A default was not defined so manage the first profile we can find
+ // Profile[] profiles = registry.getProfiles();
+ // if (profiles.length > 0)
+ // profile = profiles[0];
}
/**
@@ -243,7 +244,7 @@ public class ProvCommandProvider implements CommandProvider {
/**
* Lists the installable units that match the given URL, id, and/or version.
- *
+ *
* @param interpreter
*/
public void _provliu(CommandInterpreter interpreter) {
@@ -253,16 +254,18 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURL = null;
if (urlString != null && !urlString.equals(WILDCARD_ANY))
repoURL = toURI(interpreter, urlString);
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL,
+ QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
/**
* Lists the installable units that match the given URL and query. A third
- * boolean argument can be provided where <code>true</code> means &quot;full query&quot;
- * and <code>false</code> means &quote;match query&quote;. The default is <code>false</code>.
- *
+ * boolean argument can be provided where <code>true</code> means &quot;full
+ * query&quot; and <code>false</code> means &quote;match query&quote;. The
+ * default is <code>false</code>.
+ *
* @param interpreter
*/
public void _provlquery(CommandInterpreter interpreter) {
@@ -277,7 +280,8 @@ public class ProvCommandProvider implements CommandProvider {
if (urlString != null && !urlString.equals(WILDCARD_ANY))
repoURL = toURI(interpreter, urlString);
- IQuery<IInstallableUnit> query = useFull ? QueryUtil.createQuery(expression) : QueryUtil.createMatchQuery(expression);
+ IQuery<IInstallableUnit> query = useFull ? QueryUtil.createQuery(expression)
+ : QueryUtil.createMatchQuery(expression);
IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, query, null));
// Now print out results
if (units.length == 0)
@@ -289,9 +293,9 @@ public class ProvCommandProvider implements CommandProvider {
}
/**
- * Lists the known metadata repositories, or the contents of a given
- * metadata repository.
- *
+ * Lists the known metadata repositories, or the contents of a given metadata
+ * repository.
+ *
* @param interpreter
*/
public void _provlr(CommandInterpreter interpreter) {
@@ -308,7 +312,8 @@ public class ProvCommandProvider implements CommandProvider {
URI repoLocation = toURI(interpreter, urlString);
if (repoLocation == null)
return;
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation,
+ QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
@@ -316,14 +321,14 @@ public class ProvCommandProvider implements CommandProvider {
/**
* Lists the group IUs in all known metadata repositories, or in the given
* metadata repository.
- *
+ *
* @param interpreter
*/
public void _provlg(CommandInterpreter interpreter) {
String urlString = processArgument(interpreter.nextArgument());
IQueryable<IInstallableUnit> queryable = null;
if (urlString == null) {
- queryable = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ queryable = agent.getService(IMetadataRepositoryManager.class);
if (queryable == null)
return;
} else {
@@ -340,9 +345,9 @@ public class ProvCommandProvider implements CommandProvider {
}
/**
- * Lists the known artifact repositories, or the contents of a given
- * artifact repository.
- *
+ * Lists the known artifact repositories, or the contents of a given artifact
+ * repository.
+ *
* @param interpreter
*/
public void _provlar(CommandInterpreter interpreter) {
@@ -386,8 +391,8 @@ public class ProvCommandProvider implements CommandProvider {
}
/**
- * Returns the given string as an URL, or <code>null</code> if the string
- * could not be interpreted as an URL.
+ * Returns the given string as an URL, or <code>null</code> if the string could
+ * not be interpreted as an URL.
*/
private URI toURI(CommandInterpreter interpreter, String urlString) {
try {
@@ -407,7 +412,7 @@ public class ProvCommandProvider implements CommandProvider {
/**
* Lists the known profiles, or the contents of a given profile.
- *
+ *
* @param interpreter
*/
public void _provlp(CommandInterpreter interpreter) {
@@ -445,9 +450,9 @@ public class ProvCommandProvider implements CommandProvider {
}
/**
- * Lists the profile timestamps for a given profile id, if no profile id, the default profile
- * is used.
- *
+ * Lists the profile timestamps for a given profile id, if no profile id, the
+ * default profile is used.
+ *
* @param interpreter
*/
public void _provlpts(CommandInterpreter interpreter) {
@@ -481,14 +486,16 @@ public class ProvCommandProvider implements CommandProvider {
public void _provrevert(CommandInterpreter interpreter) {
String timestamp = interpreter.nextArgument();
if (timestamp == null) {
- interpreter.println("Valid timestamp must be provided. Timestamps can be retrieved via 'provlpts' command.");
+ interpreter
+ .println("Valid timestamp must be provided. Timestamps can be retrieved via 'provlpts' command.");
return;
}
Long ts = null;
try {
ts = Long.valueOf(timestamp);
} catch (NumberFormatException e) {
- interpreter.println("Timestamp " + timestamp + " not valid. Timestamps can be retrieved via 'provlpts' command.");
+ interpreter.println(
+ "Timestamp " + timestamp + " not valid. Timestamps can be retrieved via 'provlpts' command.");
return;
}
String profileId = interpreter.nextArgument();
@@ -547,11 +554,12 @@ public class ProvCommandProvider implements CommandProvider {
}
/**
- * Lists the installable units that match the given profile id and query. The id can be
- * &quot;this&quot; to denote the self profile. A third boolean argument can be provided
- * where <code>true</code> means &quot;full query&quot; and <code>false</code> means
- * &quote;match query&quote;. The default is <code>false</code>.
- *
+ * Lists the installable units that match the given profile id and query. The id
+ * can be &quot;this&quot; to denote the self profile. A third boolean argument
+ * can be provided where <code>true</code> means &quot;full query&quot; and
+ * <code>false</code> means &quote;match query&quote;. The default is
+ * <code>false</code>.
+ *
* @param interpreter
*/
public void _provlpquery(CommandInterpreter interpreter) {
@@ -567,7 +575,8 @@ public class ProvCommandProvider implements CommandProvider {
}
boolean useFull = Boolean.parseBoolean(processArgument(interpreter.nextArgument()));
- IQuery<IInstallableUnit> query = useFull ? QueryUtil.createQuery(expression) : QueryUtil.createMatchQuery(expression);
+ IQuery<IInstallableUnit> query = useFull ? QueryUtil.createQuery(expression)
+ : QueryUtil.createMatchQuery(expression);
IProfile profile = ProvisioningHelper.getProfile(agent, profileId);
if (profile == null) {
@@ -628,9 +637,10 @@ public class ProvCommandProvider implements CommandProvider {
/**
* Handles the help command
- *
+ *
* @param intp
- * @return description for a particular command or false if there is no command with the specified name
+ * @return description for a particular command or false if there is no command
+ * with the specified name
*/
public Object _help(CommandInterpreter intp) {
String commandName = intp.nextArgument();
@@ -648,18 +658,18 @@ public class ProvCommandProvider implements CommandProvider {
interpreter.print(",code=" + status.getCode());
String severityString = null;
switch (status.getSeverity()) {
- case IStatus.INFO :
- severityString = "INFO";
- break;
- case IStatus.CANCEL :
- severityString = "CANCEL";
- break;
- case IStatus.WARNING :
- severityString = "WARNING";
- break;
- case IStatus.ERROR :
- severityString = "ERROR";
- break;
+ case IStatus.INFO:
+ severityString = "INFO";
+ break;
+ case IStatus.CANCEL:
+ severityString = "CANCEL";
+ break;
+ case IStatus.WARNING:
+ severityString = "WARNING";
+ break;
+ case IStatus.ERROR:
+ severityString = "ERROR";
+ break;
}
interpreter.print(",severity=" + severityString);
interpreter.print(",bundle=" + status.getPlugin());
@@ -683,8 +693,8 @@ public class ProvCommandProvider implements CommandProvider {
}
/*
- * Returns either the help message for a particular command,
- * or returns the help messages for all commands (if command is not specified)
+ * Returns either the help message for a particular command, or returns the help
+ * messages for all commands (if command is not specified)
*/
private String getHelp(String commandName) {
StringBuffer help = new StringBuffer();
@@ -762,15 +772,18 @@ public class ProvCommandProvider implements CommandProvider {
private void initializeCommandGroups() {
commandGroups = new LinkedHashMap<>();
- commandGroups.put(Messages.Console_help_repository_header, new String[] {"provaddrepo", "provdelrepo", "provaddmetadatarepo", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "provdelmetadatarepo", "provaddartifactrepo", "provdelartifactrepo", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "provlg", "provlr", "provlar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "provliu", "provlquery"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- commandGroups.put(Messages.Console_help_profile_registry_header, new String[] {"provaddprofile", "provdelprofile", //$NON-NLS-1$ //$NON-NLS-2$
- "provlp", "provlgp", "provlpts", "provlpquery"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- commandGroups.put(Messages.Console_help_install_header, new String[] {"provinstall", "provremove", "provrevert"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ commandGroups.put(Messages.Console_help_repository_header,
+ new String[] { "provaddrepo", "provdelrepo", "provaddmetadatarepo", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "provdelmetadatarepo", "provaddartifactrepo", "provdelartifactrepo", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "provlg", "provlr", "provlar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "provliu", "provlquery" }); //$NON-NLS-1$ //$NON-NLS-2$
+
+ commandGroups.put(Messages.Console_help_profile_registry_header,
+ new String[] { "provaddprofile", "provdelprofile", //$NON-NLS-1$ //$NON-NLS-2$
+ "provlp", "provlgp", "provlpts", "provlpquery" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ commandGroups.put(Messages.Console_help_install_header,
+ new String[] { "provinstall", "provremove", "provrevert" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index 5987ac4e3..31a4db978 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.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
@@ -39,7 +39,7 @@ import org.eclipse.osgi.service.environment.EnvironmentInfo;
public class ProvisioningHelper {
static IMetadataRepository addMetadataRepository(IProvisioningAgent agent, URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = agent.getService(IMetadataRepositoryManager.class);
boolean createRepo = "file".equals(location.getScheme()); //$NON-NLS-1$
if (manager == null)
@@ -61,7 +61,7 @@ public class ProvisioningHelper {
}
static IMetadataRepository getMetadataRepository(IProvisioningAgent agent, URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = agent.getService(IMetadataRepositoryManager.class);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found"); //$NON-NLS-1$
try {
@@ -72,14 +72,14 @@ public class ProvisioningHelper {
}
static void removeMetadataRepository(IProvisioningAgent agent, URI location) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = agent.getService(IMetadataRepositoryManager.class);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found"); //$NON-NLS-1$
manager.removeRepository(location);
}
static IArtifactRepository addArtifactRepository(IProvisioningAgent agent, URI location) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager manager = agent.getService(IArtifactRepositoryManager.class);
boolean createRepo = "file".equals(location.getScheme()); //$NON-NLS-1$
if (manager == null)
@@ -102,7 +102,7 @@ public class ProvisioningHelper {
}
static void removeArtifactRepository(IProvisioningAgent agent, URI location) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager manager = agent.getService(IArtifactRepositoryManager.class);
if (manager == null)
// TODO log here
return;
@@ -110,7 +110,7 @@ public class ProvisioningHelper {
}
static IProfile addProfile(IProvisioningAgent agent, String profileId, Map<String, String> properties) throws ProvisionException {
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
return null;
IProfile profile = profileRegistry.getProfile(profileId);
@@ -130,21 +130,21 @@ public class ProvisioningHelper {
}
static void removeProfile(IProvisioningAgent agent, String profileId) {
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
return;
profileRegistry.removeProfile(profileId);
}
static IProfile[] getProfiles(IProvisioningAgent agent) {
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
return new IProfile[0];
return profileRegistry.getProfiles();
}
static IProfile getProfile(IProvisioningAgent agent, String id) {
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
return null;
return profileRegistry.getProfile(id);
@@ -153,7 +153,7 @@ public class ProvisioningHelper {
/**
* Returns the installable units that match the given query
* in the given metadata repository.
- *
+ *
* @param location The location of the metadata repo to search. <code>null</code> indicates
* search all known repos.
* @param query The query to perform
@@ -163,7 +163,7 @@ public class ProvisioningHelper {
static IQueryResult<IInstallableUnit> getInstallableUnits(IProvisioningAgent agent, URI location, IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
IQueryable<IInstallableUnit> queryable = null;
if (location == null) {
- queryable = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ queryable = agent.getService(IMetadataRepositoryManager.class);
} else {
queryable = getMetadataRepository(agent, location);
}
@@ -173,7 +173,7 @@ public class ProvisioningHelper {
}
static URI[] getMetadataRepositories(IProvisioningAgent agent) {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager manager = agent.getService(IMetadataRepositoryManager.class);
if (manager == null)
// TODO log here
return null;
@@ -196,17 +196,17 @@ public class ProvisioningHelper {
error.append("Repositories searched:\n");//$NON-NLS-1$
URI[] repos = getMetadataRepositories(agent);
if (repos != null) {
- for (int i = 0; i < repos.length; i++)
- error.append(repos[i] + "\n");//$NON-NLS-1$
+ for (URI repo : repos)
+ error.append(repo + "\n");//$NON-NLS-1$
}
throw new ProvisionException(error.toString());
}
- IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = agent.getService(IPlanner.class);
if (planner == null)
throw new ProvisionException("No planner service found.");//$NON-NLS-1$
- IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
+ IEngine engine = agent.getService(IEngine.class);
if (engine == null)
throw new ProvisionException("No director service found."); //$NON-NLS-1$
ProvisioningContext context = new ProvisioningContext(agent);
@@ -217,7 +217,7 @@ public class ProvisioningHelper {
}
static URI[] getArtifactRepositories(IProvisioningAgent agent) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager manager = agent.getService(IArtifactRepositoryManager.class);
if (manager == null)
throw new IllegalStateException("No metadata repository manager found"); //$NON-NLS-1$
URI[] repos = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
@@ -227,7 +227,7 @@ public class ProvisioningHelper {
}
static IArtifactRepository getArtifactRepository(IProvisioningAgent agent, URI repoURL) {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ IArtifactRepositoryManager manager = agent.getService(IArtifactRepositoryManager.class);
try {
if (manager != null)
return manager.loadRepository(repoURL, null);
@@ -241,20 +241,20 @@ public class ProvisioningHelper {
if (profileId == null) {
profileId = IProfileRegistry.SELF;
}
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
return null;
return profileRegistry.listProfileTimestamps(profileId);
}
static IStatus revertToPreviousState(IProvisioningAgent agent, IProfile profile, long revertToPreviousState) throws ProvisionException {
- IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
+ IEngine engine = agent.getService(IEngine.class);
if (engine == null)
throw new ProvisionException("No p2 engine found."); //$NON-NLS-1$
- IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = agent.getService(IPlanner.class);
if (planner == null)
throw new ProvisionException("No planner found."); //$NON-NLS-1$
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
throw new ProvisionException("profile registry cannot be null"); //$NON-NLS-1$
// If given profile is null, then get/use the self profile
@@ -295,17 +295,17 @@ public class ProvisioningHelper {
error.append("Repositories searched:\n"); //$NON-NLS-1$
URI[] repos = getMetadataRepositories(agent);
if (repos != null) {
- for (int i = 0; i < repos.length; i++)
- error.append(repos[i] + "\n"); //$NON-NLS-1$
+ for (URI repo : repos)
+ error.append(repo + "\n"); //$NON-NLS-1$
}
throw new ProvisionException(error.toString());
}
- IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ IPlanner planner = agent.getService(IPlanner.class);
if (planner == null)
throw new ProvisionException("No planner service found."); //$NON-NLS-1$
- IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
+ IEngine engine = agent.getService(IEngine.class);
if (engine == null)
throw new ProvisionException("No engine service found."); //$NON-NLS-1$
ProvisioningContext context = new ProvisioningContext(agent);
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java
index b82428a1e..76e092bc5 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.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
*******************************************************************************/
@@ -34,16 +34,17 @@ public class DefaultAgentProvider implements IProvisioningAgentProvider {
ProvisioningAgent result = new ProvisioningAgent();
result.setBundleContext(context);
result.setLocation(location);
- IAgentLocation agentLocation = (IAgentLocation) result.getService(IAgentLocation.SERVICE_NAME);
+ IAgentLocation agentLocation = result.getService(IAgentLocation.class);
Dictionary<String, Object> properties = new Hashtable<>(5);
if (agentLocation != null)
properties.put("locationURI", String.valueOf(agentLocation.getRootLocation())); //$NON-NLS-1$
- //make the currently running system have a higher service ranking
+ // make the currently running system have a higher service ranking
if (location == null) {
properties.put(Constants.SERVICE_RANKING, Integer.valueOf(100));
properties.put(IProvisioningAgent.SERVICE_CURRENT, Boolean.TRUE.toString());
}
- ServiceRegistration<IProvisioningAgent> reg = context.registerService(IProvisioningAgent.class, result, properties);
+ ServiceRegistration<IProvisioningAgent> reg = context.registerService(IProvisioningAgent.class, result,
+ properties);
result.setServiceRegistration(reg);
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java
index 26a106d47..3d65f1b41 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.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
*******************************************************************************/
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index 13d6c8207..efb01fb8c 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -20,45 +20,18 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.director.app;
-import static org.eclipse.core.runtime.IStatus.ERROR;
-import static org.eclipse.core.runtime.IStatus.INFO;
-import static org.eclipse.core.runtime.IStatus.OK;
-import static org.eclipse.core.runtime.IStatus.WARNING;
+import static org.eclipse.core.runtime.IStatus.*;
import static org.eclipse.equinox.internal.p2.director.app.Activator.ID;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
+import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EventObject;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
@@ -70,37 +43,21 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningLis
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.PlanExecutionHelper;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.core.UIServices;
-import org.eclipse.equinox.p2.engine.IEngine;
-import org.eclipse.equinox.p2.engine.IProfile;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.p2.engine.IProvisioningPlan;
-import org.eclipse.equinox.p2.engine.PhaseSetFactory;
-import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.core.*;
+import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IVersionedId;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
-import org.eclipse.equinox.p2.metadata.VersionedId;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
-import org.eclipse.equinox.p2.query.Collector;
-import org.eclipse.equinox.p2.query.IQuery;
-import org.eclipse.equinox.p2.query.IQueryResult;
-import org.eclipse.equinox.p2.query.IQueryable;
-import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
+import org.osgi.framework.*;
public class DirectorApplication implements IApplication, ProvisioningListener {
public static class AvoidTrustPromptService extends UIServices {
@@ -181,7 +138,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private static final CommandLineOption OPTION_HELP = new CommandLineOption(new String[] {"-help", "-h", "-?"}, null, Messages.Help_Prints_this_command_line_help); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final CommandLineOption OPTION_LIST = new CommandLineOption(new String[] {"-list", "-l"}, Messages.Help_lb_lt_comma_separated_list_gt_rb, Messages.Help_List_all_IUs_found_in_repos); //$NON-NLS-1$ //$NON-NLS-2$
private static final CommandLineOption OPTION_LIST_FORMAT = new CommandLineOption(new String[] {"-listFormat", "-lf"}, Messages.Help_lt_list_format_gt, Messages.Help_formats_the_IU_list); //$NON-NLS-1$ //$NON-NLS-2$
- private static final CommandLineOption OPTION_LIST_INSTALLED = new CommandLineOption(new String[] {"-listInstalledRoots", "-lir"}, null, Messages.Help_List_installed_roots); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final CommandLineOption OPTION_LIST_INSTALLED = new CommandLineOption(new String[] {"-listInstalledRoots", "-lir"}, null, Messages.Help_List_installed_roots); //$NON-NLS-1$ //$NON-NLS-2$
private static final CommandLineOption OPTION_INSTALL_IU = new CommandLineOption(new String[] {"-installIU", "-installIUs", "-i"}, Messages.Help_lt_comma_separated_list_gt, Messages.Help_Installs_the_listed_IUs); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final CommandLineOption OPTION_UNINSTALL_IU = new CommandLineOption(new String[] {"-uninstallIU", "-uninstallIUs", "-u"}, Messages.Help_lt_comma_separated_list_gt, Messages.Help_Uninstalls_the_listed_IUs); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final CommandLineOption OPTION_REVERT = new CommandLineOption(new String[] {"-revert"}, Messages.Help_lt_comma_separated_list_gt, Messages.Help_Revert_to_previous_state); //$NON-NLS-1$
@@ -214,7 +171,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
static private final String NO_ARTIFACT_REPOSITORIES_AVAILABLE = "noArtifactRepositoriesAvailable"; //$NON-NLS-1$
private static final String FOLLOW_ARTIFACT_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followArtifactRepositoryReferences"; //$NON-NLS-1$
- private static final String LIST_GROUPS_SHORTCUT = "Q:GROUP"; //$NON-NLS-1$
+ private static final String LIST_GROUPS_SHORTCUT = "Q:GROUP"; //$NON-NLS-1$
private static final String QUERY_SEPARATOR = "Q:"; //$NON-NLS-1$
private static final String QUERY_SEPARATOR_SMALL = "q:"; //$NON-NLS-1$
@@ -224,14 +181,14 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
if (spec == null)
return;
String[] urlSpecs = StringHelper.getArrayFromString(spec, ',');
- for (int i = 0; i < urlSpecs.length; i++) {
+ for (String urlSpec : urlSpecs) {
try {
- uris.add(new URI(urlSpecs[i]));
+ uris.add(new URI(urlSpec));
} catch (URISyntaxException e1) {
try {
- uris.add(URIUtil.fromString(urlSpecs[i]));
+ uris.add(URIUtil.fromString(urlSpec));
} catch (URISyntaxException e) {
- throw new ProvisionException(NLS.bind(Messages.unable_to_parse_0_to_uri_1, urlSpecs[i], e.getMessage()), e);
+ throw new ProvisionException(NLS.bind(Messages.unable_to_parse_0_to_uri_1, urlSpec, e.getMessage()), e);
}
}
@@ -260,19 +217,19 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private static void parseIUsArgument(List<IQuery<IInstallableUnit>> vnames, String arg) {
String[] roots = StringHelper.getArrayFromString(arg, ',');
- for (int i = 0; i < roots.length; ++i) {
- if (roots[i].equalsIgnoreCase(LIST_GROUPS_SHORTCUT)) {
+ for (String root : roots) {
+ if (root.equalsIgnoreCase(LIST_GROUPS_SHORTCUT)) {
vnames.add(new PrettyQuery<>(QueryUtil.createIUGroupQuery(), "All groups")); //$NON-NLS-1$
continue;
}
- if (roots[i].startsWith(QUERY_SEPARATOR) || roots[i].startsWith(QUERY_SEPARATOR_SMALL)) {
- String queryString = roots[i].substring(2);
+ if (root.startsWith(QUERY_SEPARATOR) || root.startsWith(QUERY_SEPARATOR_SMALL)) {
+ String queryString = root.substring(2);
vnames.add(new PrettyQuery<>(QueryUtil.createQuery(queryString, new Object[0]), queryString));
continue;
}
- IVersionedId vId = VersionedId.parse(roots[i]);
+ IVersionedId vId = VersionedId.parse(root);
Version v = vId.getVersion();
- IQuery<IInstallableUnit> query = new PrettyQuery<>(QueryUtil.createIUQuery(vId.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true)), roots[i]);
+ IQuery<IInstallableUnit> query = new PrettyQuery<>(QueryUtil.createIUQuery(vId.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true)), root);
vnames.add(query);
}
}
@@ -378,8 +335,8 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
// keyword is either "key" or "value"
// uniqueNumber is used to group keys and values together
Set<String> alreadyProcessed = new HashSet<>();
- for (Iterator<Object> iter = properties.keySet().iterator(); iter.hasNext();) {
- String line = (String) iter.next();
+ for (Object object : properties.keySet()) {
+ String line = (String) object;
int index = line.lastIndexOf('.');
if (index == -1)
continue;
@@ -425,7 +382,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
// lookup the IU - a null version matches all versions
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, version);
- // if we don't have a version the choose the latest.
+ // if we don't have a version the choose the latest.
if (version == null)
query = QueryUtil.createLatestQuery(query);
IQueryResult<IInstallableUnit> qr = getInstallableUnits(null, query, null);
@@ -500,7 +457,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
}
private IProfile getProfile() {
- IProfileRegistry profileRegistry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = targetAgent.getService(IProfileRegistry.class);
if (profileId == null) {
profileId = IProfileRegistry.SELF;
noProfileId = true;
@@ -530,7 +487,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
props.put(IProfile.PROP_ENVIRONMENTS, env);
if (profileProperties != null)
putProperties(profileProperties, props);
- profile = ((IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME)).addProfile(profileId, props);
+ profile = targetAgent.getService(IProfileRegistry.class).addProfile(profileId, props);
}
return profile;
}
@@ -542,7 +499,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
if (artifactRepositoryLocations == null)
missingArgument("-artifactRepository"); //$NON-NLS-1$
- artifactManager = (IArtifactRepositoryManager) targetAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ artifactManager = targetAgent.getService(IArtifactRepositoryManager.class);
if (artifactManager == null)
throw new ProvisionException(Messages.Application_NoManager);
@@ -568,7 +525,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
if (metadataRepositoryLocations == null)
missingArgument("metadataRepository"); //$NON-NLS-1$
- metadataManager = (IMetadataRepositoryManager) targetAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ metadataManager = targetAgent.getService(IMetadataRepositoryManager.class);
if (metadataManager == null)
throw new ProvisionException(Messages.Application_NoManager);
@@ -671,21 +628,21 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
else
targetAgent.unregisterService(PROP_P2_PROFILE, null);
- IDirector director = (IDirector) targetAgent.getService(IDirector.SERVICE_NAME);
+ IDirector director = targetAgent.getService(IDirector.class);
if (director == null)
throw new ProvisionException(Messages.Missing_director);
- planner = (IPlanner) targetAgent.getService(IPlanner.SERVICE_NAME);
+ planner = targetAgent.getService(IPlanner.class);
if (planner == null)
throw new ProvisionException(Messages.Missing_planner);
- engine = (IEngine) targetAgent.getService(IEngine.SERVICE_NAME);
+ engine = targetAgent.getService(IEngine.class);
if (engine == null)
throw new ProvisionException(Messages.Missing_Engine);
targetAgent.registerService(UIServices.SERVICE_NAME, new AvoidTrustPromptService());
- IProvisioningEventBus eventBus = (IProvisioningEventBus) targetAgent.getService(IProvisioningEventBus.SERVICE_NAME);
+ IProvisioningEventBus eventBus = targetAgent.getService(IProvisioningEventBus.class);
if (eventBus == null)
return;
eventBus.addListener(this);
@@ -694,9 +651,9 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener#notify(java.util.EventObject)
- *
+ *
* See bug: https://bugs.eclipse.org/340971
- * Using the event bus to detect whether or not a repository was added in a touchpoint action.
+ * Using the event bus to detect whether or not a repository was added in a touchpoint action.
* If it was, then (if it exists) remove it from our list of repos to remove after we complete our install.
*/
@Override
@@ -837,7 +794,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
}
long newState = result.getProfile().getTimestamp();
- IProfileRegistry registry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = targetAgent.getService(IProfileRegistry.class);
registry.setProfileStateProperty(result.getProfile().getProfileId(), newState, IProfile.STATE_PROP_TAG, tag);
}
@@ -1065,8 +1022,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
*/
private void putProperties(String pairs, Map<String, String> properties) {
String[] propPairs = StringHelper.getArrayFromString(pairs, ',');
- for (int i = 0; i < propPairs.length; ++i) {
- String propPair = propPairs[i];
+ for (String propPair : propPairs) {
int eqIdx = propPair.indexOf('=');
if (eqIdx < 0)
continue;
@@ -1141,7 +1097,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private void purgeRegistry() throws ProvisionException {
if (getProfile() == null)
return;
- IProfileRegistry registry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = targetAgent.getService(IProfileRegistry.class);
long[] allProfiles = registry.listProfileTimestamps(profileId);
for (int i = 0; i < allProfiles.length - 1; i++) {
registry.removeProfile(profileId, allProfiles[i]);
@@ -1150,7 +1106,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private void revertToPreviousState() throws CoreException {
IProfile profile = initializeProfile();
- IProfileRegistry profileRegistry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = targetAgent.getService(IProfileRegistry.class);
IProfile targetProfile = null;
if (revertToPreviousState == REVERT_TO_PREVIOUS) {
long[] profiles = profileRegistry.listProfileTimestamps(profile.getProfileId());
@@ -1226,8 +1182,8 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private void performHelpInfo() {
CommandLineOption[] allOptions = new CommandLineOption[] {OPTION_HELP, OPTION_LIST, OPTION_LIST_INSTALLED, OPTION_LIST_FORMAT, OPTION_INSTALL_IU, OPTION_UNINSTALL_IU, OPTION_REVERT, OPTION_DESTINATION, OPTION_DOWNLOAD_ONLY, OPTION_METADATAREPOS, OPTION_ARTIFACTREPOS, OPTION_REPOSITORIES, OPTION_VERIFY_ONLY, OPTION_TAG, OPTION_LIST_TAGS, OPTION_PROFILE, OPTION_FLAVOR, OPTION_SHARED, OPTION_BUNDLEPOOL, OPTION_PROFILE_PROPS, OPTION_IU_PROFILE_PROPS, OPTION_ROAMING, OPTION_P2_OS, OPTION_P2_WS, OPTION_P2_ARCH, OPTION_P2_NL, OPTION_PURGEHISTORY, OPTION_FOLLOW_REFERENCES};
- for (int i = 0; i < allOptions.length; ++i) {
- allOptions[i].appendHelp(System.out);
+ for (CommandLineOption allOption : allOptions) {
+ allOption.appendHelp(System.out);
}
}
@@ -1291,7 +1247,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
if (request.getProfileProperties().size() == 0)
return;
- // otherwise we have to make a change so set the profile to be non-roaming so the
+ // otherwise we have to make a change so set the profile to be non-roaming so the
// values don't get recalculated to the wrong thing if we are flushed from memory - we
// will set it back later (see bug 269468)
request.setProfileProperty(IProfile.PROP_ROAMING, "false"); //$NON-NLS-1$
@@ -1307,7 +1263,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
@Override
public void stop() {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) targetAgent.getService(IProvisioningEventBus.SERVICE_NAME);
+ IProvisioningEventBus eventBus = (IProvisioningEventBus) targetAgent.getService(IProvisioningEventBus.class);
if (eventBus != null) {
eventBus.removeListener(this);
}
@@ -1331,7 +1287,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
private void performPrintTags() throws CoreException {
IProfile profile = initializeProfile();
- IProfileRegistry registry = (IProfileRegistry) targetAgent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = targetAgent.getService(IProfileRegistry.class);
Map<String, String> tags = registry.getProfileStateProperties(profile.getProfileId(), IProfile.STATE_PROP_TAG);
//Sort the tags from the most recent to the oldest
List<String> timeStamps = new ArrayList<>(tags.keySet());
@@ -1362,7 +1318,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
Throwable cause = status.getException();
if (cause != null) {
// TODO This is very unreliable. It assumes that if the IStatus message is the same as the IStatus cause
- // message the cause exception has no more data to offer. Better to just print it.
+ // message the cause exception has no more data to offer. Better to just print it.
boolean isCauseMsg = msg.equals(cause.getMessage()) || msg.equals(cause.toString());
if (!isCauseMsg) {
log.printErr(prefix + "Caused by: "); //$NON-NLS-1$
@@ -1396,7 +1352,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
}
private boolean canInstallInDestination() {
- //When we are provisioning what we are running. We can always install.
+ //When we are provisioning what we are running. We can always install.
if (targetAgentIsSelfAndUp)
return true;
return canWrite(destination);
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java
index 9294a565a..3014510f2 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/DirectorComponent.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
@@ -23,8 +23,8 @@ public class DirectorComponent implements IAgentServiceFactory {
@Override
public Object createService(IProvisioningAgent agent) {
- IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
- IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ IEngine engine = agent.getService(IEngine.class);
+ IPlanner planner = agent.getService(IPlanner.class);
return new SimpleDirector(engine, planner);
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/ProfileChangeRequest.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/ProfileChangeRequest.java
index 1d5368104..3bf49a105 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/ProfileChangeRequest.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/ProfileChangeRequest.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
@@ -25,7 +25,7 @@ import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
/**
* @noreference This class was unintentionally left in the provisional API package and
- * is intended to be made internal in Eclipse 3.7. Clients should create and manipulate
+ * is intended to be made internal in Eclipse 3.7. Clients should create and manipulate
* profile change requests via the API {@link IPlanner#createChangeRequest(IProfile)}
* and methods on {@link IProfileChangeRequest}.
*/
@@ -41,7 +41,7 @@ public class ProfileChangeRequest implements Cloneable, IProfileChangeRequest {
private ArrayList<IRequirement> additionalRequirements;
public static ProfileChangeRequest createByProfileId(IProvisioningAgent agent, String profileId) {
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null)
throw new IllegalStateException(Messages.Planner_no_profile_registry);
IProfile profile = profileRegistry.getProfile(profileId);
@@ -181,7 +181,7 @@ public class ProfileChangeRequest implements Cloneable, IProfileChangeRequest {
return propertiesToAdd;
}
- // map of iu->list of property keys to be removed for an iu
+ // map of iu->list of property keys to be removed for an iu
public Map<IInstallableUnit, List<String>> getInstallableUnitProfilePropertiesToRemove() {
if (iuPropertiesToRemove == null)
return Collections.emptyMap();
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index 160281a80..e78041838 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -78,8 +78,8 @@ public class SimplePlanner implements IPlanner {
} catch (Throwable e) {
// ignore
}
- for (int i = 0; i < operands.length; i++) {
- Tracing.debug(operands[i].toString());
+ for (Object operand : operands) {
+ Tracing.debug(operand.toString());
}
}
@@ -147,7 +147,7 @@ public class SimplePlanner implements IPlanner {
/**
* Converts a list of {@link Projector#getExplanation(IProgressMonitor) resolver
* explanations} to a human-readable status object
- *
+ *
* @param explanations List of resolver explanations ordered by logical
* causality. I.e. read from start to end should forms
* logical chain of statements as to why resolution failed.
@@ -205,7 +205,7 @@ public class SimplePlanner implements IPlanner {
/**
* TODO Find a way to emit INFO status. The issue is that all
* {@link IStatus#isOK()} calls will fail.
- *
+ *
* @param requestChanges
* @param requestSideEffects
* @return the {@link IStatus}
@@ -260,8 +260,8 @@ public class SimplePlanner implements IPlanner {
// First deal with profile properties to remove.
String[] toRemove = profileChangeRequest.getPropertiesToRemove();
- for (int i = 0; i < toRemove.length; i++) {
- plan.setProfileProperty(toRemove[i], null);
+ for (String element : toRemove) {
+ plan.setProfileProperty(element, null);
}
// Now deal with profile property changes/additions
Map<String, String> propertyChanges = profileChangeRequest.getPropertiesToAdd();
@@ -340,9 +340,9 @@ public class SimplePlanner implements IPlanner {
ProvisioningContext context, IProgressMonitor monitor) {
Map<String, IInstallableUnit> resultsMap = new HashMap<>();
if (additionalSource != null) {
- for (int i = 0; i < additionalSource.length; i++) {
- String key = additionalSource[i].getId() + "_" + additionalSource[i].getVersion().toString(); //$NON-NLS-1$
- resultsMap.put(key, additionalSource[i]);
+ for (IInstallableUnit element : additionalSource) {
+ String key = element.getId() + "_" + element.getVersion().toString(); //$NON-NLS-1$
+ resultsMap.put(key, element);
}
}
if (context == null) {
@@ -357,8 +357,7 @@ public class SimplePlanner implements IPlanner {
IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500));
IQueryResult<IInstallableUnit> matches = queryable.query(QueryUtil.createIUQuery(null, VersionRange.emptyRange),
sub.newChild(500));
- for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
- IInstallableUnit iu = it.next();
+ for (IInstallableUnit iu : matches) {
String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
IInstallableUnit currentIU = resultsMap.get(key);
if (currentIU == null || hasHigherFidelity(iu, currentIU))
@@ -379,8 +378,8 @@ public class SimplePlanner implements IPlanner {
public SimplePlanner(IProvisioningAgent agent) {
Assert.isNotNull(agent);
this.agent = agent;
- this.engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
- this.profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ this.engine = agent.getService(IEngine.class);
+ this.profileRegistry = agent.getService(IProfileRegistry.class);
Assert.isNotNull(engine);
Assert.isNotNull(profileRegistry);
}
@@ -400,11 +399,11 @@ public class SimplePlanner implements IPlanner {
/**
* Performs a provisioning request resolution
- *
+ *
* @param profileChangeRequest The requested change.
* @param context The context for the resolution pass
* @param monitor
- *
+ *
* @return Return a {@link Projector} that captures the complete future state of
* the profile that satisfies the request. If the request can't be
* satisfied return an {@link IProvisioningPlan} where the error is
@@ -606,8 +605,7 @@ public class SimplePlanner implements IPlanner {
allMetaRequirements.addAll(iu.getMetaRequirements());
}
IQueryResult<IInstallableUnit> queryResult = plan.getRemovals().query(QueryUtil.createIUAnyQuery(), null);
- for (Iterator<IInstallableUnit> iterator = queryResult.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = iterator.next();
+ for (IInstallableUnit iu : queryResult) {
allMetaRequirements.addAll(iu.getMetaRequirements());
}
return allMetaRequirements;
@@ -631,8 +629,8 @@ public class SimplePlanner implements IPlanner {
return initialPlan;
}
- IProfile installerProfile = ((IProfileRegistry) ((IProvisioningAgent) agent
- .getService(IProvisioningAgent.INSTALLER_AGENT)).getService(IProfileRegistry.SERVICE_NAME))
+ IProfile installerProfile = ((IProvisioningAgent) agent
+ .getService(IProvisioningAgent.INSTALLER_AGENT)).getService(IProfileRegistry.class)
.getProfile((String) agent.getService(IProvisioningAgent.INSTALLER_PROFILEID));
if (installerProfile == null)
return initialPlan;
@@ -671,8 +669,8 @@ public class SimplePlanner implements IPlanner {
return false;
if (agent1 == agent2)
return true;
- IAgentLocation thisLocation = (IAgentLocation) agent1.getService(IAgentLocation.SERVICE_NAME);
- IAgentLocation otherLocation = (IAgentLocation) agent2.getService(IAgentLocation.SERVICE_NAME);
+ IAgentLocation thisLocation = agent1.getService(IAgentLocation.class);
+ IAgentLocation otherLocation = agent2.getService(IAgentLocation.class);
if (thisLocation == null || otherLocation == null || (thisLocation == null && otherLocation == null))
return false;
return thisLocation.getRootLocation().equals(otherLocation.getRootLocation());
@@ -754,8 +752,8 @@ public class SimplePlanner implements IPlanner {
agentRequest.setProfileProperty(entry.getKey(), entry.getValue());
}
String[] removedProperties = initialRequest.getPropertiesToRemove();
- for (int i = 0; i < removedProperties.length; i++) {
- agentRequest.removeProfileProperty(removedProperties[i]);
+ for (String removedPropertie : removedProperties) {
+ agentRequest.removeProfileProperty(removedPropertie);
}
Map<IInstallableUnit, List<String>> removedIUProperties = initialRequest
.getInstallableUnitProfilePropertiesToRemove();
@@ -948,8 +946,7 @@ public class SimplePlanner implements IPlanner {
}
// Process the IUs that were already there
- for (Iterator<IInstallableUnit> iterator = alreadyInstalled.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = iterator.next();
+ for (IInstallableUnit iu : alreadyInstalled) {
Map<String, String> propertiesForIU = iuPropertiesToAdd.get(iu);
IRequirement profileRequirement = null;
// Test if the value has changed
@@ -1002,8 +999,7 @@ public class SimplePlanner implements IPlanner {
SubMonitor sub = SubMonitor.convert(monitor, 1000);
IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500));
IQueryResult<IInstallableUnit> matches = queryable.query(new UpdateQuery(toUpdate), sub.newChild(500));
- for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
- IInstallableUnit iu = it.next();
+ for (IInstallableUnit iu : matches) {
String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
IInstallableUnit currentIU = resultsMap.get(key);
if (currentIU == null || hasHigherFidelity(iu, currentIU))
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java
index 32603b6d2..4c51ca1a9 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java
@@ -32,7 +32,8 @@ public class PlanExecutionHelper {
return result.getStatus();
if (result.getInstallerPlan() != null) {
- IStatus installerPlanStatus = ((IEngine) result.getInstallerPlan().getProfile().getProvisioningAgent().getService(IEngine.SERVICE_NAME)).perform(result.getInstallerPlan(), phaseSet, progress);
+ IStatus installerPlanStatus = result.getInstallerPlan().getProfile().getProvisioningAgent()
+ .getService(IEngine.class).perform(result.getInstallerPlan(), phaseSet, progress);
if (!installerPlanStatus.isOK())
return installerPlanStatus;
Configurator configChanger = ServiceHelper.getService(DirectorActivator.context, Configurator.class);
diff --git a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Activator.java b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Activator.java
index fe961e4b3..7179fb1bf 100644
--- a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Activator.java
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2008, 2017 IBM Corporation and others.
*
- * This program and the accompanying materials
+ * 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/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Red Hat Inc. - Bug 460967
@@ -62,7 +62,7 @@ public class Activator implements BundleActivator {
}
public static IProfile getCurrentProfile() {
- IProfileRegistry profileRegistry = (IProfileRegistry) getCurrentAgent().getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry profileRegistry = getCurrentAgent().getService(IProfileRegistry.class);
return profileRegistry.getProfile(IProfileRegistry.SELF);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
index 10bf7ecef..e850dd502 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
@@ -31,7 +31,7 @@ import org.eclipse.ui.statushandlers.StatusManager;
/**
* PreloadingRepositoryHandler provides background loading of
* repositories before executing the provisioning handler.
- *
+ *
* @since 3.5
*/
abstract class PreloadingRepositoryHandler extends AbstractHandler {
@@ -56,7 +56,7 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
IProvisioningAgent agent = getProvisioningUI().getSession().getProvisioningAgent();
IProfile profile = null;
if (agent != null) {
- IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
if (registry != null) {
profile = registry.getProfile(profileId);
}
@@ -90,7 +90,7 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
return Status.CANCEL_STATUS;
}
if (shouldAccumulateFailures()) {
- // If we are accumulating failures, don't return a combined status here. By returning OK,
+ // If we are accumulating failures, don't return a combined status here. By returning OK,
// we are indicating that the operation should continue with the repositories that
// did load.
return Status.OK_STATUS;
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
index 1ec670d2a..fae10a27d 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/SimpleLicenseManager.java
@@ -25,10 +25,10 @@ import org.eclipse.equinox.p2.ui.LicenseManager;
import org.osgi.service.prefs.Preferences;
/**
- * SimpleLicenseManager is a license manager that keeps track of
+ * SimpleLicenseManager is a license manager that keeps track of
* IInstallableUnit licenses using their UUID. The licenses ids
* are stored in the profile's preferences.
- *
+ *
* @since 3.6
*/
public class SimpleLicenseManager extends LicenseManager {
@@ -70,7 +70,8 @@ public class SimpleLicenseManager extends LicenseManager {
}
private Preferences getPreferences() {
- IAgentLocation location = (IAgentLocation) ProvSDKUIActivator.getDefault().getProvisioningAgent().getService(IAgentLocation.SERVICE_NAME);
+ IAgentLocation location = ProvSDKUIActivator.getDefault().getProvisioningAgent()
+ .getService(IAgentLocation.class);
return new ProfileScope(location, profileId).getNode(ProvSDKUIActivator.PLUGIN_ID);
}
diff --git a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java
index fcddca437..96e6f36a0 100644
--- a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java
+++ b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.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
@@ -144,13 +144,13 @@ public class UpdateChecker implements IUpdateChecker {
* Returns the list of metadata repositories that are currently available.
*/
private URI[] getAvailableRepositories() {
- IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager repoMgr = agent.getService(IMetadataRepositoryManager.class);
URI[] repositories = repoMgr.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
ArrayList<URI> available = new ArrayList<>();
- for (int i = 0; i < repositories.length; i++) {
+ for (URI repositorie : repositories) {
try {
- repoMgr.loadRepository(repositories[i], null);
- available.add(repositories[i]);
+ repoMgr.loadRepository(repositorie, null);
+ available.add(repositorie);
} catch (ProvisionException e) {
LogHelper.log(e.getStatus());
}
@@ -171,7 +171,7 @@ public class UpdateChecker implements IUpdateChecker {
IPlanner getPlanner() {
if (planner == null) {
- planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME);
+ planner = agent.getService(IPlanner.class);
if (planner == null) {
throw new IllegalStateException("Provisioning system has not been initialized"); //$NON-NLS-1$
}
@@ -181,7 +181,7 @@ public class UpdateChecker implements IUpdateChecker {
IProfileRegistry getProfileRegistry() {
if (profileRegistry == null) {
- profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ profileRegistry = agent.getService(IProfileRegistry.class);
if (profileRegistry == null) {
throw new IllegalStateException("Provisioning system has not been initialized"); //$NON-NLS-1$
}

Back to the top