Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2008-05-15 23:48:55 +0000
committerSusan Franklin2008-05-15 23:48:55 +0000
commitdb0c65f8e3cefc6f4036157e9d19ffece57f6df8 (patch)
treefca0c0e0f1f29b3df917d68e7fadc77b7084fd51
parent02129e8f3ea933d777c6b78569c28cc919dcff9f (diff)
downloadrt.equinox.p2-db0c65f8e3cefc6f4036157e9d19ffece57f6df8.tar.gz
rt.equinox.p2-db0c65f8e3cefc6f4036157e9d19ffece57f6df8.tar.xz
rt.equinox.p2-db0c65f8e3cefc6f4036157e9d19ffece57f6df8.zip
Bug 229403 - [ui] Repository not found was never reported via dialogv20080515-2020
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositoryElement.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueryableMetadataRepositoryManager.java48
5 files changed, 65 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
index 7bbd10a85..ab334da0b 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
@@ -65,6 +65,7 @@ public class ProvUIMessages extends NLS {
public static String ProvisioningUtil_NoPlannerFound;
public static String ProvisioningUtil_NoDirectorFound;
public static String ProvisioningUtil_NoEngineFound;
+ public static String ProvisioningUtil_RepositoryNotFound;
// viewer support
public static String ProvDropAdapter_InvalidDropTarget;
@@ -124,6 +125,7 @@ public class ProvUIMessages extends NLS {
public static String DeferredFetchFilteredTree_RetrievingList;
public static String Label_Profiles;
public static String Label_Repositories;
+ public static String MetadataRepositoryElement_NotFound;
public static String MetadataRepositoryElement_RepositoryLoadError;
public static String UpdateAction_UpdatesAvailableMessage;
public static String UpdateAction_UpdatesAvailableTitle;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
index 88bea7e6b..c1d18d21e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
@@ -20,6 +20,7 @@ ProvisioningUtil_NoProfileRegistryFound=No profile registry was found
ProvisioningUtil_NoPlannerFound=No provisioning planner was found
ProvisioningUtil_NoDirectorFound=No provisioning director was found
ProvisioningUtil_NoEngineFound=No provisioning engine was found
+ProvisioningUtil_RepositoryNotFound={0} could not be found.
ProvisioningOperation_ExecuteErrorTitle=Error while executing the "{0}" operation
ProvisioningOperation_RedoErrorTitle=Error while redoing the "{0}" operation
@@ -140,6 +141,7 @@ AvailableIUGroup_ViewByToolTipText=View by
DeferredFetchFilteredTree_RetrievingList=Retrieving List
Label_Profiles=All Software Profiles
Label_Repositories=Known Repositories
+MetadataRepositoryElement_NotFound=This repository is currently not available.
MetadataRepositoryElement_RepositoryLoadError=Error loading repository {0}
QueryableArtifactRepositoryManager_RepositoryQueryProgress=Getting artifact repositories
QueryableMetadataRepositoryManager_RepositoryQueryProgress=Getting repositories
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositoryElement.java
index ebc6e63f5..0cee548a7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositoryElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/model/MetadataRepositoryElement.java
@@ -18,10 +18,12 @@ import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
+import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUIImages;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IQueryProvider;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.statushandlers.StatusManager;
/**
* Element wrapper class for a metadata repository that gets its
@@ -33,6 +35,7 @@ public class MetadataRepositoryElement extends RemoteQueriedElement implements I
URL url;
boolean isEnabled;
+ boolean alreadyReportedNotFound = false;
public MetadataRepositoryElement(URL url) {
this(url, true);
@@ -87,7 +90,19 @@ public class MetadataRepositoryElement extends RemoteQueriedElement implements I
try {
queryable = ProvisioningUtil.loadMetadataRepository(url, monitor);
} catch (ProvisionException e) {
- handleException(e, NLS.bind(ProvUIMessages.MetadataRepositoryElement_RepositoryLoadError, url));
+ // If repository could not be found, report to the user, but only once.
+ // If the user refreshes the repositories, new elements will be created and
+ // then a failure would be reported again on the next try.
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND) {
+ if (!alreadyReportedNotFound) {
+ // report the status, not the exception, to the user because we
+ // do not want to show them stack trace and exception detail.
+ ProvUI.reportStatus(e.getStatus(), StatusManager.SHOW);
+ alreadyReportedNotFound = true;
+ }
+ } else
+ // handle other exceptions the normal way
+ handleException(e, NLS.bind(ProvUIMessages.MetadataRepositoryElement_RepositoryLoadError, url));
}
return (IMetadataRepository) queryable;
@@ -130,6 +145,8 @@ public class MetadataRepositoryElement extends RemoteQueriedElement implements I
* @see org.eclipse.equinox.internal.provisional.p2.ui.model.RepositoryElement#getDescription()
*/
public String getDescription() {
+ if (alreadyReportedNotFound)
+ return ProvUIMessages.MetadataRepositoryElement_NotFound;
try {
String description = ProvisioningUtil.getMetadataRepositoryProperty(url, IRepository.PROP_DESCRIPTION);
if (description == null)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
index 9ca421416..6dddcbd67 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
@@ -68,11 +68,7 @@ public class ProvisioningUtil {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null)
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
- IMetadataRepository repo = manager.loadRepository(location, monitor);
- if (repo == null) {
- throw new ProvisionException(NLS.bind(ProvUIMessages.ProvisioningUtil_LoadRepositoryFailure, location.toExternalForm()));
- }
- return repo;
+ return manager.loadRepository(location, monitor);
}
public static IStatus validateMetadataRepositoryLocation(URL location, IProgressMonitor monitor) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueryableMetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueryableMetadataRepositoryManager.java
index 23c1a693d..2d172ddff 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueryableMetadataRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/query/QueryableMetadataRepositoryManager.java
@@ -36,6 +36,8 @@ import org.eclipse.ui.statushandlers.StatusManager;
*/
public class QueryableMetadataRepositoryManager implements IQueryable {
private MetadataRepositories repositories;
+ private ArrayList notFound = new ArrayList();
+ private MultiStatus accumulatedNotFound = null;
public QueryableMetadataRepositoryManager(MetadataRepositories repositories) {
this.repositories = repositories;
@@ -77,14 +79,18 @@ public class QueryableMetadataRepositoryManager implements IQueryable {
result.accept(repoURLs.get(i));
sub.worked(2);
} else {
+ URL url = (URL) repoURLs.get(i);
try {
- IMetadataRepository repo = manager.loadRepository((URL) repoURLs.get(i), sub.newChild(1));
+ IMetadataRepository repo = manager.loadRepository(url, sub.newChild(1));
repo.query(query, result, sub.newChild(1));
} catch (ProvisionException e) {
- //ignore unavailable repositories
- if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND)
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ handleNotFound(e, url);
+ else
ProvUI.handleException(e, NLS.bind(ProvUIMessages.ProvisioningUtil_LoadRepositoryFailure, repoURLs.get(i)), StatusManager.LOG);
}
+ reportAccumulatedStatus();
+
}
}
return result;
@@ -107,14 +113,17 @@ public class QueryableMetadataRepositoryManager implements IQueryable {
for (int i = 0; i < repoURLs.size(); i++) {
if (sub.isCanceled())
return;
+ URL url = (URL) repoURLs.get(i);
try {
- manager.loadRepository((URL) repoURLs.get(i), sub.newChild(1));
+ manager.loadRepository(url, sub.newChild(1));
} catch (ProvisionException e) {
- //ignore unavailable repositories
- if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND)
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ handleNotFound(e, url);
+ else
ProvUI.handleException(e, NLS.bind(ProvUIMessages.ProvisioningUtil_LoadRepositoryFailure, repoURLs.get(i)), StatusManager.LOG);
}
}
+ reportAccumulatedStatus();
}
@@ -130,4 +139,31 @@ public class QueryableMetadataRepositoryManager implements IQueryable {
}
return locations;
}
+
+ private void handleNotFound(ProvisionException e, URL missingRepo) {
+ // If we've already reported a URL is not found, don't report again.
+ if (notFound.contains(missingRepo.toExternalForm()))
+ return;
+ notFound.add(missingRepo.toExternalForm());
+ if (accumulatedNotFound == null) {
+ accumulatedNotFound = new MultiStatus(ProvUIActivator.PLUGIN_ID, ProvisionException.REPOSITORY_NOT_FOUND, NLS.bind(ProvUIMessages.ProvisioningUtil_RepositoryNotFound, missingRepo.toExternalForm()), null);
+ }
+ accumulatedNotFound.add(e.getStatus());
+ }
+
+ private void reportAccumulatedStatus() {
+ // If we've discovered not found repos we didn't know about, report them
+ if (accumulatedNotFound != null) {
+ // If we didn't find several repos in one pass, use a more generic top level message.
+ if (accumulatedNotFound.getChildren().length > 1) {
+ MultiStatus multiples = new MultiStatus(ProvUIActivator.PLUGIN_ID, ProvisionException.REPOSITORY_NOT_FOUND, "Some repositories could not be found. Check the details.", null);
+ multiples.addAll(accumulatedNotFound);
+ accumulatedNotFound = multiples;
+
+ }
+ ProvUI.reportStatus(accumulatedNotFound, StatusManager.SHOW);
+ }
+ // Reset the accumulated status so that next time we only report the newly not found repos.
+ accumulatedNotFound = null;
+ }
}

Back to the top