incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r966986 - in /sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl: FolderNameFilter.java JcrInstaller.java
Date Fri, 23 Jul 2010 06:35:21 GMT
Author: cziegeler
Date: Fri Jul 23 06:35:21 2010
New Revision: 966986

URL: http://svn.apache.org/viewvc?rev=966986&view=rev
Log:
Fix path handling

Modified:
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java?rev=966986&r1=966985&r2=966986&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/FolderNameFilter.java
Fri Jul 23 06:35:21 2010
@@ -40,7 +40,7 @@ class FolderNameFilter {
     private final String regexp;
     private final RunMode runMode;
     private final String [] rootPaths;
-    private Map<String, Integer> rootPriorities = new HashMap<String, Integer>();
+    private final Map<String, Integer> rootPriorities = new HashMap<String, Integer>();
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     /** getPriority computes priorities as follows: each root gets its own base priority,
@@ -50,7 +50,7 @@ class FolderNameFilter {
     public static final int RUNMODE_PRIORITY_BOOST = 1;
     public static final int DEFAULT_ROOT_PRIORITY = 99;
 
-    FolderNameFilter(String [] rootsConfig, String regexp, RunMode runMode) {
+    FolderNameFilter(final String [] rootsConfig, final String regexp, final RunMode runMode)
{
         this.regexp = regexp;
         this.pattern = Pattern.compile(regexp);
         this.runMode = runMode;
@@ -77,7 +77,7 @@ class FolderNameFilter {
 
     /**
      * Return the list of root paths.
-     * Every entry in the list ends with a slash
+     * Every entry in the list starts with a slash
      */
     String [] getRootPaths() {
     	return rootPaths;
@@ -85,10 +85,10 @@ class FolderNameFilter {
 
     static String cleanupRootPath(final String str) {
     	String result = str.trim();
-    	if(!result.startsWith("/")) {
+    	if (!result.startsWith("/")) {
     		result = "/" + result;
     	}
-    	if(result.endsWith("/")) {
+    	if (result.endsWith("/")) {
     		result = result.substring(0, result.length() - 1);
     	}
     	return result;

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java?rev=966986&r1=966985&r2=966986&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
Fri Jul 23 06:35:21 2010
@@ -205,8 +205,8 @@ public class JcrInstaller implements Eve
     	}
 
     	// Setup folder filtering and watching
-    	final String [] rootsConfig = OsgiUtil.toStringArray(context.getProperties().get(PROP_SEARCH_PATH),
DEFAULT_SEARCH_PATH);
-        folderNameFilter = new FolderNameFilter(rootsConfig, folderNameRegexp, runMode);
+        folderNameFilter = new FolderNameFilter(OsgiUtil.toStringArray(context.getProperties().get(PROP_SEARCH_PATH),
DEFAULT_SEARCH_PATH),
+                folderNameRegexp, runMode);
         roots = folderNameFilter.getRootPaths();
         for (String path : roots) {
             listeners.add(new RootFolderListener(session, folderNameFilter, path, updateFoldersListTimer));
@@ -291,16 +291,16 @@ public class JcrInstaller implements Eve
 
     /** Find the paths to watch under rootPath, according to our folderNameFilter,
      * 	and add them to result */
-    void findPathsToWatch(String rootPath, List<WatchedFolder> result) throws RepositoryException
{
+    void findPathsToWatch(final String rootPath, final List<WatchedFolder> result)
throws RepositoryException {
         Session s = null;
 
         try {
             s = repository.loginAdministrative(repository.getDefaultWorkspace());
-            if (!s.getRootNode().hasNode(rootPath)) {
+            if (!s.itemExists(rootPath) || !s.getItem(rootPath).isNode() ) {
                 log.info("Bundles root node {} not found, ignored", rootPath);
             } else {
                 log.debug("Bundles root node {} found, looking for bundle folders inside
it", rootPath);
-                final Node n = s.getRootNode().getNode(rootPath);
+                final Node n = (Node)s.getItem(rootPath);
                 findPathsUnderNode(n, result);
             }
         } finally {
@@ -314,8 +314,7 @@ public class JcrInstaller implements Eve
      * Add n to result if it is a folder that we must watch, and recurse into its children
      * to do the same.
      */
-    void findPathsUnderNode(Node n, List<WatchedFolder> result) throws RepositoryException
-    {
+    void findPathsUnderNode(final Node n, final List<WatchedFolder> result) throws
RepositoryException {
         final String path = n.getPath();
         final int priority = folderNameFilter.getPriority(path);
         if (priority > 0) {
@@ -332,16 +331,6 @@ public class JcrInstaller implements Eve
         }
     }
 
-    /**
-     * Return the relative path for supplied path
-     */
-    static String relPath(String path) {
-        if (path.startsWith("/")) {
-            return path.substring(1);
-        }
-        return path;
-    }
-
     /** Add WatchedFolder to our list if it doesn't exist yet */
     private void addWatchedFolder(WatchedFolder toAdd) {
         WatchedFolder existing = null;



Mime
View raw message