Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManagerComponent.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java74
4 files changed, 63 insertions, 64 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManagerComponent.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManagerComponent.java
index 44b1a307f..81c4128d4 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManagerComponent.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManagerComponent.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
@@ -22,8 +22,9 @@ public class CacheManagerComponent implements IAgentServiceFactory {
@Override
public Object createService(IProvisioningAgent agent) {
- final IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
- CacheManager cache = new CacheManager((IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME), (Transport) agent.getService(Transport.SERVICE_NAME));
+ final IProvisioningEventBus eventBus = agent.getService(IProvisioningEventBus.class);
+ CacheManager cache = new CacheManager(agent.getService(IAgentLocation.class),
+ agent.getService(Transport.class));
cache.setEventBus(eventBus);
return cache;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java
index 48ecf1201..cae79e971 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/Credentials.java
@@ -28,7 +28,7 @@ import org.eclipse.equinox.security.storage.*;
/**
* Credentials handles AuthenticationInfo that can be used to established an
* ECF connection context. An AuthenticationInfo is obtained for a URI buy looking
- * in a store, if none is provided the user is optionally prompted for the information.
+ * in a store, if none is provided the user is optionally prompted for the information.
*/
public class Credentials {
public static class LoginCanceledException extends Exception {
@@ -36,7 +36,7 @@ public class Credentials {
}
- /**
+ /**
* Cache of auth information that is not persisted, and modified auth info.
*/
private static final Map<String, UIServices.AuthenticationInfo> savedAuthInfo = Collections.synchronizedMap(new HashMap<String, UIServices.AuthenticationInfo>());
@@ -47,16 +47,16 @@ public class Credentials {
*/
private static Map<String, HostEntry> remembered;
- /**
- * Serializes pop up of login/password prompt
+ /**
+ * Serializes pop up of login/password prompt
*/
private static final Object promptLock = new Object();
/**
* Returns the AuthenticationInfo for the given URI. This may prompt the
* user for user name and password as required.
- *
- * If the URI is opaque, the entire URI is used as the key. For non opaque URIs,
+ *
+ * If the URI is opaque, the entire URI is used as the key. For non opaque URIs,
* the key is based on the host name, using a host name of "localhost" if host name is
* missing.
*
@@ -75,14 +75,14 @@ public class Credentials {
/**
* Returns the AuthenticationInfo for the given URI. This may prompt the
* user for user name and password as required.
- *
- * If the URI is opaque, the entire URI is used as the key. For non opaque URIs,
+ *
+ * If the URI is opaque, the entire URI is used as the key. For non opaque URIs,
* the key is based on the host name, using a host name of "localhost" if host name is
* missing.
- *
+ *
* This method allows passing a previously used AuthenticationInfo. If set, the user interface
* may present the information "on file" to the user for editing.
- *
+ *
* @param location - the location for which to obtain authentication information
* @param prompt - if true, user will be prompted for information
* @param lastUsed - optional information used in an previous attempt to login
@@ -98,7 +98,7 @@ public class Credentials {
} catch (UnsupportedEncodingException e2) {
// fall back to default platform encoding
try {
- // Uses getProperty "file.encoding" instead of using deprecated URLEncoder.encode(String location)
+ // Uses getProperty "file.encoding" instead of using deprecated URLEncoder.encode(String location)
// which does the same, but throws NPE on missing property.
String enc = System.getProperty("file.encoding");//$NON-NLS-1$
if (enc == null)
@@ -207,7 +207,7 @@ public class Credentials {
if (getPromptCount(host) >= RepositoryPreferences.getLoginRetryCount()) {
if (lastUsed == null && latest == null)
DebugHelper.debug("Credentials", "forLocation:NO INFO - SYNTHETIC CANCEL", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
return latest == null ? lastUsed : latest; // keep client failing on the latest known
}
DebugHelper.debug("Credentials", "forLocation:LATER INFO AVAILABLE - RETURNING IT", // //$NON-NLS-1$ //$NON-NLS-2$
@@ -220,14 +220,14 @@ public class Credentials {
return latest == null ? lastUsed : latest; // keep client failing on the latest known
}
IProvisioningAgent agent = ServiceHelper.getService(Activator.getContext(), IProvisioningAgent.class);
- UIServices adminUIService = (UIServices) agent.getService(UIServices.SERVICE_NAME);
+ UIServices adminUIService = agent.getService(UIServices.class);
if (adminUIService != null)
synchronized (promptLock) {
try {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
DebugHelper.debug("Credentials", "forLocation:PROMPTLOCK OBTAINED", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
// serialize the popping of the dialog itself
@@ -236,7 +236,7 @@ public class Credentials {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
if (loginDetails == UIServices.AUTHENTICATION_PROMPT_CANCELED)
DebugHelper.debug("Credentials", "forLocation:PROMPTED - USER CANCELED (PROMPT LOCK RELEASED)", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
if (loginDetails == UIServices.AUTHENTICATION_PROMPT_CANCELED) {
rememberCancel(host);
@@ -248,7 +248,7 @@ public class Credentials {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
if (loginDetails.saveResult())
DebugHelper.debug("Credentials", "forLocation:SAVING RESULT", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
if (loginDetails.saveResult()) {
@@ -268,7 +268,7 @@ public class Credentials {
if (securePreferences.nodeExists(nodeName)) {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
DebugHelper.debug("Credentials", "forLocation:REMOVING PREVIOUSLY SAVED INFO", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
prefNode = securePreferences.node(nodeName);
@@ -284,7 +284,7 @@ public class Credentials {
} finally {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
DebugHelper.debug("Credentials", "forLocation:PROMPTLOCK RELEASED", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
}
}
@@ -292,7 +292,7 @@ public class Credentials {
} finally {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
DebugHelper.debug("Credentials", "forLocation:HOSTLOCK RELEASED", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", location}); //$NON-NLS-1$
+ new Object[] {"host", location}); //$NON-NLS-1$
}
}
@@ -359,7 +359,7 @@ public class Credentials {
if (((HostEntry) x).isCanceled()) {
if (DebugHelper.DEBUG_REPOSITORY_CREDENTIALS) {
DebugHelper.debug("Credentials", "checkRememberCancel:PREVIOUSLY CANCELED", // //$NON-NLS-1$ //$NON-NLS-2$
- new Object[] {"host", host}); //$NON-NLS-1$
+ new Object[] {"host", host}); //$NON-NLS-1$
}
throw new LoginCanceledException();
@@ -430,7 +430,7 @@ public class Credentials {
/**
* Clears the cached information for host about prompts for login/password and
- * canceled logins.
+ * canceled logins.
* @param host a host as returned from uriToHost for a location
*/
public static synchronized void clearPromptCache(String host) {
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
index 0c8e37530..3ca4f8b8a 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/ProgressStatistics.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Cloudsmith Inc - initial API and implementation
* IBM Corporation - ongoing development
@@ -50,7 +50,7 @@ public class ProgressStatistics {
private void publishEvent(DownloadProgressEvent event) {
if (m_agent != null) {
- IProvisioningEventBus eventBus = (IProvisioningEventBus) m_agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ IProvisioningEventBus eventBus = m_agent.getService(IProvisioningEventBus.class);
if (eventBus != null) {
eventBus.publishEvent(event);
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
index c2001ef91..32ce41d39 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.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
* Wind River - fix for bug 299227
@@ -102,8 +102,8 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
protected AbstractRepositoryManager(IProvisioningAgent agent) {
super();
this.agent = agent;
- agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
- eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
+ agentLocation = agent.getService(IAgentLocation.class);
+ eventBus = agent.getService(IProvisioningEventBus.class);
eventBus.addListener(this);
}
@@ -149,11 +149,11 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
/**
- * Adds the repository to the list of known repositories.
+ * Adds the repository to the list of known repositories.
* @param location The repository location
* @param isEnabled Whether the repository should be enabled
* @param signalAdd Whether a repository add event should be broadcast
- * @return <code>true</code> if the repository was actually added, and
+ * @return <code>true</code> if the repository was actually added, and
* <code>false</code> otherwise.
*/
private boolean addRepository(URI location, boolean isEnabled, boolean signalAdd) {
@@ -303,10 +303,10 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
*/
protected Object createExecutableExtension(IExtension extension, String element) {
IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals(element)) {
+ for (IConfigurationElement element2 : elements) {
+ if (element2.getName().equals(element)) {
try {
- return elements[i].createExecutableExtension("class"); //$NON-NLS-1$
+ return element2.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException e) {
log("Error loading repository extension: " + extension.getUniqueIdentifier(), e); //$NON-NLS-1$
return null;
@@ -321,10 +321,10 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
* Obtains an exclusive right to load a repository at the given location. Blocks
* if another thread is currently loading at that location. Invocation of this
* method must be followed by a subsequent call to {@link #exitLoad(URI)}.
- *
+ *
* To avoid deadlock between the loadLock and repositoryLock, this method
* must not be called when repositoryLock is held.
- *
+ *
* @param location The location to lock
*/
private void enterLoad(URI location, IProgressMonitor monitor) {
@@ -415,9 +415,9 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
}
IExtension[] results = new IExtension[count];
- for (int i = 0; i < elt.length; i++) {
- if (elt[i] != null)
- results[--count] = elt[i].getDeclaringExtension();
+ for (IConfigurationElement element : elt) {
+ if (element != null)
+ results[--count] = element.getDeclaringExtension();
}
return results;
}
@@ -431,9 +431,9 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
IConfigurationElement[] elements = registry.getConfigurationElementsFor(getRepositoryProviderExtensionPointId());
ArrayList<String> result = new ArrayList<>(elements.length);
result.add(getDefaultSuffix());
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals(EL_FILTER)) {
- String suffix = elements[i].getAttribute(ATTR_SUFFIX);
+ for (IConfigurationElement element : elements) {
+ if (element.getName().equals(EL_FILTER)) {
+ String suffix = element.getAttribute(ATTR_SUFFIX);
if (!result.contains(suffix))
result.add(suffix);
}
@@ -667,17 +667,17 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
sub = SubMonitor.convert(sub, NLS.bind(Messages.repoMan_adding, location), suffixes.length * 100);
ProvisionException failure = null;
try {
- for (int i = 0; i < suffixes.length; i++) {
+ for (String suffixe : suffixes) {
if (sub.isCanceled())
throw new OperationCanceledException();
try {
- result = loadRepository(location, suffixes[i], type, flags, sub.newChild(100));
+ result = loadRepository(location, suffixe, type, flags, sub.newChild(100));
} catch (ProvisionException e) {
failure = e;
break;
}
if (result != null) {
- addRepository(result, false, suffixes[i]);
+ addRepository(result, false, suffixe);
break;
}
}
@@ -768,9 +768,9 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
IExtension[] providers = findMatchingRepositoryExtensions(suffix, type);
// Loop over the candidates and return the first one that successfully loads
monitor.beginTask(null, providers.length * 10);
- for (int i = 0; i < providers.length; i++)
+ for (IExtension provider : providers)
try {
- IRepository<T> repo = factoryLoad(location, providers[i], flags, monitor);
+ IRepository<T> repo = factoryLoad(location, provider, flags, monitor);
if (repo != null)
return repo;
} catch (ProvisionException e) {
@@ -781,10 +781,10 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
throw e;
} catch (Exception e) {
//catch and log unexpected errors and move onto the next factory
- log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$
+ log("Unexpected error loading extension: " + provider.getUniqueIdentifier(), e); //$NON-NLS-1$
} catch (LinkageError e) {
//catch and log unexpected errors and move onto the next factory
- log("Unexpected error loading extension: " + providers[i].getUniqueIdentifier(), e); //$NON-NLS-1$
+ log("Unexpected error loading extension: " + provider.getUniqueIdentifier(), e); //$NON-NLS-1$
}
return null;
}
@@ -872,7 +872,7 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
/**
* Writes the state of the repository information into the appropriate preference node.
- *
+ *
* @param info The info to write to the preference node
* @param flush <code>true</code> if the preference node should be flushed to
* disk, and <code>false</code> otherwise
@@ -969,8 +969,8 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
log("Error restoring repositories from preferences", e); //$NON-NLS-1$
return;
}
- for (int i = 0; i < children.length; i++) {
- Preferences child = node.node(children[i]);
+ for (String element : children) {
+ Preferences child = node.node(element);
URI location = getRepositoryLocation(child);
if (location == null) {
try {
@@ -1084,7 +1084,7 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
/**
- * Optimize the order in which repository suffixes are searched by trying
+ * Optimize the order in which repository suffixes are searched by trying
* the last successfully loaded suffix first.
* @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.
@@ -1111,8 +1111,7 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
// Now make sure that anything in the "preferredOrder" is at the top
if (preferredOrder != null) {
int priority = 0;
- for (int i = 0; i < preferredOrder.length; i++) {
- String currentSuffix = preferredOrder[i];
+ for (String currentSuffix : preferredOrder) {
if (LocationProperties.END.equals(currentSuffix.trim())) {
// All suffixes from here on should be ignored
String[] tmp = new String[priority];
@@ -1136,8 +1135,8 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
/**
- * Performs a query against the contents of each known
- * repository, accumulating any objects that satisfy the query in the
+ * Performs a query against the contents of each known
+ * repository, accumulating any objects that satisfy the query in the
* provided collector.
* <p>
* Note that using this method can be quite expensive, as every known
@@ -1147,8 +1146,8 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
* loaded and then query each of the returned repositories.
* <p>
* This method is long-running; progress and cancellation are provided
- * by the given progress monitor.
- *
+ * by the given progress monitor.
+ *
* @param query The query to perform against each element in each known repository
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
@@ -1159,11 +1158,11 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
URI[] locations = getKnownRepositories(REPOSITORIES_ALL);
List<IRepository<T>> queryables = new ArrayList<>(locations.length); // use a list since we don't know exactly how many will load
SubMonitor sub = SubMonitor.convert(monitor, locations.length * 10);
- for (int i = 0; i < locations.length; i++) {
+ for (URI location : locations) {
try {
if (sub.isCanceled())
throw new OperationCanceledException();
- queryables.add(loadRepository(locations[i], sub.newChild(9), null, 0));
+ queryables.add(loadRepository(location, sub.newChild(9), null, 0));
} catch (ProvisionException e) {
//ignore this repository for this query
}
@@ -1185,15 +1184,14 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
}
protected Transport getTransport() {
- return (Transport) agent.getService(Transport.SERVICE_NAME);
+ return agent.getService(Transport.class);
}
public void flushCache() {
synchronized (repositoryLock) {
if (repositories != null) {
Collection<RepositoryInfo<T>> repos = repositories.values();
- for (Iterator<RepositoryInfo<T>> iterator = repos.iterator(); iterator.hasNext();) {
- RepositoryInfo<T> repositoryInfo = iterator.next();
+ for (RepositoryInfo<T> repositoryInfo : repos) {
repositoryInfo.repository = null;
}
}

Back to the top