Permalink
Browse files

[KARAF-130] Allow a repository URL to be added to feature repository …

…URL list even though it is an invalid one

git-svn-id: https://svn.apache.org/repos/asf/karaf/trunk@965760 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 1503057 commit dc5add27ca91ccbce427147edc46a4bbdc6a0c96 @ffang ffang committed Jul 20, 2010
View
3 features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java
@@ -27,7 +27,8 @@ protected void doExecute(FeaturesService admin) throws Exception {
Repository[] repos = admin.listRepositories();
if ((repos != null) && (repos.length > 0)) {
for (int i = 0; i < repos.length; i++) {
- System.out.println(repos[i].getURI());
+ String status = repos[i].isValid() ? " valid" : " invalid";
+ System.out.println(repos[i].getURI().toString() + status);
}
} else {
System.out.println("No repository URLs are set.");
View
2 features/core/src/main/java/org/apache/karaf/features/Repository.java
@@ -30,5 +30,7 @@
URI[] getRepositories() throws Exception;
Feature[] getFeatures() throws Exception;
+
+ boolean isValid();
}
View
10 features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
@@ -165,8 +165,8 @@ public void addRepository(URI uri) throws Exception {
protected RepositoryImpl internalAddRepository(URI uri) throws Exception {
RepositoryImpl repo = null;
repo = new RepositoryImpl(uri);
- repo.load();
repositories.put(uri, repo);
+ repo.load();
callListeners(new RepositoryEvent(repo, RepositoryEvent.EventType.RepositoryAdded, false));
features = null;
return repo;
@@ -732,7 +732,7 @@ public void start() throws Exception {
if (uris != null) {
for (URI uri : uris) {
try {
- internalAddRepository(uri);
+ internalAddRepository(uri);
} catch (Exception e) {
LOGGER.warn(format("Unable to add features repository %s at startup", uri), e);
}
@@ -851,7 +851,11 @@ protected boolean loadState() {
}
Set<URI> repositories = loadSet(props, "repositories.");
for (URI repo : repositories) {
- internalAddRepository(repo);
+ try {
+ internalAddRepository(repo);
+ } catch (Exception e) {
+ LOGGER.warn(format("Unable to add features repository %s at startup", repo), e);
+ }
}
installed = loadMap(props, "features.");
for (Feature f : installed.keySet()) {
View
16 features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java
@@ -55,6 +55,7 @@
private URI uri;
private List<Feature> features;
private List<URI> repositories;
+ private boolean valid;
public RepositoryImpl(URI uri) {
this.uri = uri;
@@ -84,6 +85,7 @@ public URI getURI() {
public void load() throws IOException {
try {
+ valid = true;
repositories = new ArrayList<URI>();
features = new ArrayList<Feature>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -182,13 +184,17 @@ public void load() throws IOException {
}
}
} catch (SAXException e) {
+ valid = false;
throw (IOException) new IOException().initCause(e);
} catch (ParserConfigurationException e) {
- throw (IOException) new IOException().initCause(e);
+ valid = false;
+ throw (IOException) new IOException().initCause(e);
} catch (IllegalArgumentException e) {
- throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
+ valid = false;
+ throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
} catch (Exception e) {
- throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
+ valid = false;
+ throw (IOException) new IOException(e.getMessage() + " : " + uri).initCause(e);
}
}
@@ -208,4 +214,8 @@ protected void interpolation(Properties properties) {
}
}
+ public boolean isValid() {
+ return this.valid;
+ }
+
}

0 comments on commit dc5add2

Please sign in to comment.