You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ff...@apache.org on 2010/07/20 10:56:09 UTC
svn commit: r965760 - in /karaf/trunk/features:
command/src/main/java/org/apache/karaf/features/command/
core/src/main/java/org/apache/karaf/features/
core/src/main/java/org/apache/karaf/features/internal/
Author: ffang
Date: Tue Jul 20 08:56:09 2010
New Revision: 965760
URL: http://svn.apache.org/viewvc?rev=965760&view=rev
Log:
[KARAF-130] Allow a repository URL to be added to feature repository URL list even though it is an invalid one
Modified:
karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Repository.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java
Modified: karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java?rev=965760&r1=965759&r2=965760&view=diff
==============================================================================
--- karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java (original)
+++ karaf/trunk/features/command/src/main/java/org/apache/karaf/features/command/ListUrlCommand.java Tue Jul 20 08:56:09 2010
@@ -27,7 +27,8 @@ public class ListUrlCommand extends Feat
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.");
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Repository.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Repository.java?rev=965760&r1=965759&r2=965760&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Repository.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Repository.java Tue Jul 20 08:56:09 2010
@@ -30,5 +30,7 @@ public interface Repository {
URI[] getRepositories() throws Exception;
Feature[] getFeatures() throws Exception;
+
+ boolean isValid();
}
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=965760&r1=965759&r2=965760&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java Tue Jul 20 08:56:09 2010
@@ -165,8 +165,8 @@ public class FeaturesServiceImpl impleme
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 class FeaturesServiceImpl impleme
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 @@ public class FeaturesServiceImpl impleme
}
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()) {
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java?rev=965760&r1=965759&r2=965760&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/RepositoryImpl.java Tue Jul 20 08:56:09 2010
@@ -55,6 +55,7 @@ public class RepositoryImpl implements R
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 class RepositoryImpl implements R
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 class RepositoryImpl implements R
}
}
} 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 @@ public class RepositoryImpl implements R
}
}
+ public boolean isValid() {
+ return this.valid;
+ }
+
}