diff options
author | Alexander Kurtakov | 2019-06-28 13:12:15 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-07-01 13:09:05 +0000 |
commit | bb27e7b3fc060a62805281221eac19e21803b40f (patch) | |
tree | 8e38f4d2a6c119f777e9d0963e7fc85cb5a06a4a /bundles/org.eclipse.equinox.p2.artifact.repository/src/org | |
parent | 0406e1d0248310054a35232f5840b5c3c50ab5fd (diff) | |
download | rt.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>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org')
7 files changed, 94 insertions, 80 deletions
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 { |