You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2011/08/18 18:50:17 UTC
svn commit: r1159310 -
/karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java
Author: jbonofre
Date: Thu Aug 18 16:50:16 2011
New Revision: 1159310
URL: http://svn.apache.org/viewvc?rev=1159310&view=rev
Log:
Use relative URI for repository import.
Modified:
karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java
Modified: karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java
URL: http://svn.apache.org/viewvc/karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java?rev=1159310&r1=1159309&r2=1159310&view=diff
==============================================================================
--- karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java (original)
+++ karaf/sandbox/jbonofre/cave/trunk/server/backend/filesystem/src/main/java/org/apache/karaf/cave/server/backend/impl/CaveRepositoryImpl.java Thu Aug 18 16:50:16 2011
@@ -158,6 +158,29 @@ public class CaveRepositoryImpl implemen
}
/**
+ * Recursive method to traverse all file in the repository.
+ *
+ * @param entry the
+ * @throws Exception
+ */
+ private void scan(File entry) throws Exception {
+ if (entry.isDirectory()) {
+ File[] children = entry.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ scan(children[i]);
+ }
+ } else {
+ // populate the repository
+ try {
+ ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(entry.toURI().toURL());
+ this.addResource(resource);
+ } catch (IllegalArgumentException e) {
+ LOGGER.warn(e.getMessage());
+ }
+ }
+ }
+
+ /**
* Proxy an URL (by adding repository.xml OBR information) in the Karaf Cave repository.
*
* @param url the URL to proxyFilesystem. the URL to proxyFilesystem.
@@ -282,17 +305,16 @@ public class CaveRepositoryImpl implemen
}
} else {
try {
- Resource resource = new DataModelHelperImpl().createResource(filesystem.toURI().toURL());
+ ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(filesystem.toURI().toURL());
if (resource != null) {
// copy the resource
File destination = new File(new File(location), filesystem.getName());
LOGGER.debug("Copy from {} to {}", filesystem.getAbsolutePath(), destination.getAbsolutePath());
FileUtils.copyFile(filesystem, destination);
if (update) {
- resource = new DataModelHelperImpl().createResource(destination.toURI().toURL());
+ resource = (ResourceImpl) new DataModelHelperImpl().createResource(destination.toURI().toURL());
LOGGER.debug("Update the OBR metadata with {}", resource.getId());
- obrRepository.addResource(resource);
- obrRepository.setLastModified(System.currentTimeMillis());
+ this.addResource(resource);
}
}
} catch (IllegalArgumentException e) {
@@ -321,7 +343,7 @@ public class CaveRepositoryImpl implemen
|| entity.getContentType().getValue().equals("application/octet-stream")) {
// I have a jar/binary, potentially a resource
try {
- Resource resource = new DataModelHelperImpl().createResource(new URL(url));
+ ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(new URL(url));
if (resource != null) {
LOGGER.debug("Copy {} into the Karaf Cave repository storage", url);
int index = url.lastIndexOf("/");
@@ -334,10 +356,9 @@ public class CaveRepositoryImpl implemen
outputStream.flush();
outputStream.close();
if (update) {
- resource = new DataModelHelperImpl().createResource(destination.toURI().toURL());
+ resource = (ResourceImpl) new DataModelHelperImpl().createResource(destination.toURI().toURL());
LOGGER.debug("Update OBR metadata with {}", resource.getId());
- obrRepository.addResource(resource);
- obrRepository.setLastModified(System.currentTimeMillis());
+ this.addResource(resource);
}
}
} catch (IllegalArgumentException e) {
@@ -360,29 +381,6 @@ public class CaveRepositoryImpl implemen
}
/**
- * Recursive method to traverse all file in the repository.
- *
- * @param entry the
- * @throws Exception
- */
- private void scan(File entry) throws Exception {
- if (entry.isDirectory()) {
- File[] children = entry.listFiles();
- for (int i = 0; i < children.length; i++) {
- scan(children[i]);
- }
- } else {
- // populate the repository
- try {
- ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(entry.toURI().toURL());
- this.addResource(resource);
- } catch (IllegalArgumentException e) {
- LOGGER.warn(e.getMessage());
- }
- }
- }
-
- /**
* Convert the Resource absolute URI to an URI relative to the repository one.
*
* @param resource the Resource to manipulate.