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/11/12 15:50:14 UTC

svn commit: r1201274 - /karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java

Author: jbonofre
Date: Sat Nov 12 14:50:13 2011
New Revision: 1201274

URL: http://svn.apache.org/viewvc?rev=1201274&view=rev
Log:
[KARAF-882] Cave doesn't parse non jar file anymore

Modified:
    karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java

Modified: karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java
URL: http://svn.apache.org/viewvc/karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java?rev=1201274&r1=1201273&r2=1201274&view=diff
==============================================================================
--- karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java (original)
+++ karaf/cave/trunk/server/storage/src/main/java/org/apache/karaf/cave/server/storage/CaveRepositoryImpl.java Sat Nov 12 14:50:13 2011
@@ -154,8 +154,11 @@ public class CaveRepositoryImpl extends 
         } else {
             // populate the repository
             try {
-                ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(entry.toURI().toURL());
-                this.addResource(resource);
+                URL bundleUrl = entry.toURI().toURL();
+                if (isPotentialBundle(bundleUrl.toString())) {
+                    ResourceImpl resource = (ResourceImpl) new DataModelHelperImpl().createResource(bundleUrl);
+                    this.addResource(resource);
+                }
             } catch (IllegalArgumentException e) {
                 LOGGER.warn(e.getMessage());
             }
@@ -163,6 +166,18 @@ public class CaveRepositoryImpl extends 
     }
 
     /**
+     * Convenience method to filter Maven files with common non-bundle extensions.
+     *
+     * @param bundleUrl the file URL to check.
+     * @return true if the file is a potential bundle, false else.
+     */
+    private boolean isPotentialBundle(String bundleUrl) {
+        return !bundleUrl.matches(".*\\.sha1") && !bundleUrl.matches(".*\\.pom")
+                && !bundleUrl.matches(".*\\.xml") && !bundleUrl.matches(".*\\.repositories")
+                && !bundleUrl.matches(".*\\.properties") && !bundleUrl.matches(".*\\.lastUpdated");
+    }
+
+    /**
      * Proxy an URL (by adding repository.xml OBR information) in the Karaf Cave repository.
      *
      * @param url the URL to proxyFilesystem. the URL to proxyFilesystem.