incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r711260 - in /incubator/sling/trunk/extensions/jcrinstall: ./ src/main/java/org/apache/sling/jcr/jcrinstall/jcr/ src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ src/main/java/org/apache/sling/jcr/jcrinstall/osgi/ src/main/java/org/a...
Date Tue, 04 Nov 2008 14:20:59 GMT
Author: bdelacretaz
Date: Tue Nov  4 06:20:58 2008
New Revision: 711260

URL: http://svn.apache.org/viewvc?rev=711260&view=rev
Log:
SLING-719 - support node-based configs

Added:
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java   (with props)
Modified:
    incubator/sling/trunk/extensions/jcrinstall/pom.xml
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RegexpFilter.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java

Modified: incubator/sling/trunk/extensions/jcrinstall/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/pom.xml?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/pom.xml (original)
+++ incubator/sling/trunk/extensions/jcrinstall/pom.xml Tue Nov  4 06:20:58 2008
@@ -55,6 +55,10 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Export-Package>
+            	org.apache.sling.jcr.jcrinstall.osgi,
+            	org.apache.sling.jcr.jcrinstall.jcr
+            </Export-Package>
             <Private-Package>org.apache.sling.jcr.jcrinstall.*</Private-Package>
           </instructions>
         </configuration>
@@ -103,6 +107,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.runmode</artifactId>
+      <version>2.0.3-incubator-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.jmock</groupId>
       <artifactId>jmock-junit4</artifactId>
       <scope>test</scope>

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.jcr;
+
+import javax.jcr.Node;
+
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
+
+/** Convert a Node to InstallableData */
+public interface NodeConverter {
+	InstallableData convertNode(Node n) throws Exception;
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/NodeConverter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.jcr.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.util.Dictionary;
+
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
+
+/** InstallableData that wraps a Dictionary */
+class ConfigInstallableData implements InstallableData {
+
+	private final Dictionary<String, Object> data;
+	private final String digest;
+	
+	ConfigInstallableData(Dictionary<String, Object> data) throws Exception {
+		this.data = data;
+		digest = computeDigest(data);
+	}
+	
+	@Override
+	public String toString() {
+		return getClass().getSimpleName() + ", digest=" + digest;
+	}
+	
+	@SuppressWarnings("unchecked")
+	public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+		if(type.equals(Dictionary.class)) {
+			return (AdapterType)data;
+		}
+		return null;
+	}
+
+	public String getDigest() {
+		return digest;
+	}
+	
+	/** Digest is needed to detect changes in data */
+	static String computeDigest(Dictionary<String, Object> data) throws Exception {
+		final String digestType = "MD5";
+		final MessageDigest d = MessageDigest.getInstance(digestType);
+		final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		final ObjectOutputStream oos = new ObjectOutputStream(bos);
+		oos.writeObject(data);
+		bos.flush();
+		d.update(bos.toByteArray());
+		// convert to readable string (http://www.javalobby.org/java/forums/t84420.html)
+		final BigInteger bigInt = new BigInteger(1, d.digest());
+		return new String(bigInt.toString(16));
+	}
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigInstallableData.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.jcr.impl;
+
+import java.lang.reflect.Array;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.sling.jcr.jcrinstall.jcr.NodeConverter;
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
+import org.apache.sling.runmode.RunMode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Converts configuration nodes to InstallableData, taking
+ * 	RunMode into account.
+ */
+class ConfigNodeConverter implements NodeConverter {
+	
+	private final Logger log = LoggerFactory.getLogger(getClass());
+	
+	/**	TODO making this dynamic and optional would be better, but
+	 * 	that would probably create issues at startup 
+	 * 	@scr.reference 
+	 */
+	private RunMode runMode;
+	
+	/** Convert n to an InstallableData, or return null
+	 * 	if we don't know how to convert it.
+	 */
+	public InstallableData convertNode(Node n) throws Exception {
+		InstallableData result = null;
+		
+		// TODO use a mixin to identify these nodes?
+		if(n.isNodeType("nt:unstructured")) {
+			final Dictionary<String, Object> config = load(n);
+			result = new ConfigInstallableData(config);
+			log.debug("Converted node {} to {}", n.getPath(), result);
+		}
+		return result;
+	}
+	
+    /** Load config from node n */
+    protected Dictionary<String, Object> load(Node n) throws RepositoryException {
+        Dictionary<String, Object> result = new Hashtable<String, Object>();
+        
+        log.debug("Loading config from Node {}", n.getPath());
+        
+        // load default values from node itself
+        log.debug("Loading {} properties", n.getPath());
+        loadProperties(result, n);
+        
+        if(runMode != null) {
+            final String [] modeStr = runMode.getCurrentRunModes();
+            final SortedSet<String> modes = new TreeSet<String>();
+            for(String s : modeStr) {
+                modes.add(s);
+            }
+            for(String mode : modes) {
+                if(n.hasNode(mode)) {
+                    log.debug(
+                            "Loading {}/{} properties for current run mode, overriding previous values", 
+                            n.getPath(), mode);
+                    loadProperties(result, n.getNode(mode));
+                }
+            }
+        }
+        
+        return result;
+    }
+    
+    /** Load properties of n into d */
+    protected void loadProperties(Dictionary<String, Object> d, Node n) throws RepositoryException {
+        final PropertyIterator pi = n.getProperties();
+        while(pi.hasNext()) {
+            final Property p = pi.nextProperty();
+            final String name = p.getName();
+            
+            // ignore jcr: and similar properties
+            if(name.contains(":")) {
+                continue;
+            }
+            if(p.getDefinition().isMultiple()) {
+                Object [] data = null;
+                final Value [] values = p.getValues();
+                int i = 0;
+                for(Value v : values) {
+                    Object o = convertValue(v);
+                    if(i == 0) {
+                        data = (Object[])Array.newInstance(o.getClass(), values.length);
+                    }
+                    data[i++] = o;
+                }
+                d.put(name, data);
+                
+            } else {
+                final Object o = convertValue(p.getValue());
+                if(o != null) {
+                    d.put(name, o);
+                }
+            }
+        }
+    }
+
+    /** Convert v according to its type */
+    protected Object convertValue(Value v) throws RepositoryException {
+        switch(v.getType()) {
+        case PropertyType.STRING:
+            return v.getString();
+        case PropertyType.DATE:
+            return v.getDate();
+        case PropertyType.DOUBLE:
+            return v.getDouble();
+        case PropertyType.LONG:
+            return v.getLong();
+        case PropertyType.BOOLEAN:
+            return v.getBoolean();
+        }
+        log.debug("Value of type {} ignored", v.getType());
+        return null;
+    }
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.jcrinstall.jcr.impl;
+
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
+
+/** Provides data (InputStream, last modified data) about
+ * 	JCR nodes which are files.
+ */
+class FileInstallableData implements InstallableData {
+    /**
+     * The relative path of the data and last modified date of an nt:file node
+     */
+    public static final String JCR_CONTENT = "jcr:content";
+    public static final String JCR_CONTENT_DATA = JCR_CONTENT + "/jcr:data";
+    public static final String JCR_LAST_MODIFIED = "jcr:lastModified";
+    public static final String JCR_CONTENT_LAST_MODIFIED = JCR_CONTENT + "/" + JCR_LAST_MODIFIED;
+    
+    private final InputStream inputStream;
+    private final String digest;
+    private final String path;
+    
+    @Override
+    public String toString() {
+    	return getClass().getSimpleName() + ": " + path;
+    }
+    
+	FileInstallableData(Node n) throws RepositoryException {
+		this.path = n.getPath();
+        if (n.hasProperty(JCR_CONTENT_LAST_MODIFIED)) {
+        	digest = String.valueOf(n.getProperty(JCR_CONTENT_LAST_MODIFIED).getDate().getTimeInMillis());
+        } else {
+        	digest = null;
+	    }
+	    
+        if(n.hasProperty(JCR_CONTENT_DATA)) {
+        	inputStream = n.getProperty(JCR_CONTENT_DATA).getStream();
+        } else {
+        	inputStream = null;
+        }
+	}
+	
+	InputStream getInputStream() {
+		return inputStream;
+	}
+
+    @SuppressWarnings("unchecked")
+	public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+		if(type.equals(InputStream.class)) {
+			return (AdapterType)inputStream;
+		}
+		return null;
+	}
+
+	public String getDigest() {
+		return digest;
+	}
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileInstallableData.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,33 @@
+package org.apache.sling.jcr.jcrinstall.jcr.impl;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.jcr.jcrinstall.jcr.NodeConverter;
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Convert a Node that is a file to a FileInstallableData */ 
+ public class FileNodeConverter implements NodeConverter {
+    // regexp for filenames that we accept
+    public static final String FILENAME_REGEXP = "[a-zA-Z0-9].*\\.[a-zA-Z][a-zA-Z][a-zA-Z]?";
+    
+    private final RegexpFilter filenameFilter = new RegexpFilter(FILENAME_REGEXP);
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+	public InstallableData convertNode(Node n) throws RepositoryException {
+		InstallableData result = null;
+		if(n.hasProperty(FileInstallableData.JCR_CONTENT_DATA) && n.hasProperty(FileInstallableData.JCR_CONTENT_LAST_MODIFIED)) {
+			if(filenameFilter.accept(n.getName())) {
+				result = new FileInstallableData(n);
+			} else {
+				log.debug("Node {} ignored due to {}", n.getPath(), filenameFilter);
+			}
+			return result;
+		}
+		log.debug("Node {} has no {} properties, ignored", n.getPath(), 
+				FileInstallableData.JCR_CONTENT_DATA + " or " + FileInstallableData.JCR_CONTENT_LAST_MODIFIED);
+		return null;
+	}
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RegexpFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RegexpFilter.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RegexpFilter.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RegexpFilter.java Tue Nov  4 06:20:58 2008
@@ -35,6 +35,11 @@
         return pattern.matcher(path).matches();
     }
     
+    @Override 
+    public String toString() {
+    	return getClass().getSimpleName() + " (" + regexp + ")";
+    }
+    
     String getRegexp() {
         return regexp;
     }

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java Tue Nov  4 06:20:58 2008
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -38,11 +39,10 @@
 import javax.jcr.observation.Event;
 
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.jcrinstall.jcr.NodeConverter;
 import org.apache.sling.jcr.jcrinstall.osgi.OsgiController;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,14 +80,15 @@
     private File serviceDataFile;
     private long lastBundleEvent;
     
+    private final List<NodeConverter> converters = new ArrayList<NodeConverter>();
+    
     private List<WatchedFolderCreationListener> listeners = new LinkedList<WatchedFolderCreationListener>();
     
     /** Default set of root folders to watch */
     public static String[] DEFAULT_ROOTS = {"/libs", "/apps"};
     
-    /** Default regexp for watched folders and filenames */
+    /** Default regexp for watched folders */
     public static final String DEFAULT_FOLDER_NAME_REGEXP = ".*/install$";
-    public static final String DEFAULT_FILENAME_REGEXP = "[a-zA-Z0-9].*\\.[a-zA-Z][a-zA-Z][a-zA-Z]?";
     
     /** ComponentContext property that overrides the folder name regepx */
     public static final String FOLDER_NAME_REGEXP_PROPERTY = "sling.jcrinstall.folder.name.regexp";
@@ -111,8 +112,14 @@
         lastBundleEvent = System.currentTimeMillis();
         
     	// TODO make this more configurable?
-    	final String [] roots = DEFAULT_ROOTS; 
-    	filenameFilter = new RegexpFilter(DEFAULT_FILENAME_REGEXP);
+    	final String [] roots = DEFAULT_ROOTS;
+
+    	/** NodeConverters setup
+         *	Using services and a whiteboard pattern for these would be nice,
+         * 	but that could be problematic at startup due to async loading
+         */
+    	converters.add(new FileNodeConverter());
+    	converters.add(new ConfigNodeConverter());
     	
     	String folderNameRegexp = getPropertyValue(context, FOLDER_NAME_REGEXP_PROPERTY);
     	if(folderNameRegexp == null) {
@@ -345,10 +352,11 @@
     
     /** Let our WatchedFolders run their scanning cycles */ 
     void runOneCycle() throws Exception {
+    	boolean forceScan = false;
         addNewWatchedFolders();
     	for(WatchedFolder wf : folders) {
-    		wf.scanIfNeeded();
-    	}
+    		wf.scanIfNeeded(converters);
+        }
     }
     
     Properties loadProperties(File f) {

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/WatchedFolder.java Tue Nov  4 06:20:58 2008
@@ -19,7 +19,7 @@
 package org.apache.sling.jcr.jcrinstall.jcr.impl;
 
 import java.io.IOException;
-import java.io.InputStream;
+import java.util.Collection;
 import java.util.Set;
 
 import javax.jcr.Item;
@@ -32,6 +32,8 @@
 import javax.jcr.observation.EventListener;
 
 import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.jcrinstall.jcr.NodeConverter;
+import org.apache.sling.jcr.jcrinstall.osgi.InstallableData;
 import org.apache.sling.jcr.jcrinstall.osgi.JcrInstallException;
 import org.apache.sling.jcr.jcrinstall.osgi.OsgiController;
 import org.slf4j.Logger;
@@ -46,8 +48,7 @@
     private final OsgiController controller;
     private long nextScan;
     private final Session session;
-    private final RegexpFilter filenameFilter;
-    protected static final Logger log = LoggerFactory.getLogger(WatchedFolder.class);
+    protected final Logger log = LoggerFactory.getLogger(getClass());
     
     /**
      * After receiving JCR events, we wait for this many msec before
@@ -59,8 +60,8 @@
             RegexpFilter filenameFilter, long scanDelayMsec) throws RepositoryException {
         this.path = path;
         this.controller = ctrl;
-        this.filenameFilter = filenameFilter;
         this.scanDelayMsec = scanDelayMsec;
+        
         session = repository.loginAdministrative(repository.getDefaultWorkspace());
         
         // observe any changes in our folder (and under it, as changes to properties
@@ -119,15 +120,15 @@
      * 	If our timer allows it, scan our folder Node for updates
      * 	and deletes.
      */
-    void scanIfNeeded() throws Exception {
+    void scanIfNeeded(Collection<NodeConverter> converters) throws Exception {
         if (nextScan != -1 && System.currentTimeMillis() > nextScan) {
             nextScan = -1;
-            scan();
+            scan(converters);
         }
     }
     
     /** Scan our folder and inform OsgiController of any changes */
-    protected void scan() throws Exception {
+    protected void scan(Collection<NodeConverter> converters) throws Exception {
         log.debug("Scanning {}", path);
         
         checkDeletions(controller.getInstalledUris());
@@ -145,23 +146,21 @@
         	return;
         }
         
-        // Check adds and updates, for all child nodes that are files
+        // Check adds and updates, for all child nodes for which we have a NodeConverter
         final NodeIterator it = folder.getNodes();
         while(it.hasNext()) {
         	final Node n = it.nextNode();
-        	final FileDataProvider dp = new FileDataProvider(n);
-        	if(!dp.isFile()) {
-        		log.debug("Node {} does not seem to be a file, ignored", n.getPath());
-        	} else if(!filenameFilter.accept(n.getName())) {
-        	    if(log.isDebugEnabled()) {
-                    log.debug("Node " + n.getPath() + " with name " + n.getName() + " ignored due to " + filenameFilter);
-        	    }
-        	} else {
-        		// a single failure must not block the whole thing (SLING-655)
-        		try {
-        			installOrUpdate(n.getPath(), dp);
-        		} catch(JcrInstallException jie) {
-        			log.warn("Failed to install resource " + n.getPath(), jie);
+        	for(NodeConverter nc : converters) {
+        		final InstallableData d = nc.convertNode(n);
+        		if(d != null) {
+        			log.debug("Installing or updating {}", d);
+            		// a single failure must not block the whole thing (SLING-655)
+            		try {
+            			installOrUpdate(n.getPath(), d);
+            		} catch(JcrInstallException jie) {
+            			log.warn("Failed to install resource " + n.getPath(), jie);
+            		}
+            		break;
         		}
         	}
         }
@@ -186,7 +185,7 @@
     }
     
     /** Install or update the given resource, as needed */ 
-    protected void installOrUpdate(String path, FileDataProvider fdp) throws IOException, JcrInstallException {
+    protected void installOrUpdate(String path, InstallableData fdp) throws IOException, JcrInstallException {
     	final String digest = controller.getDigest(path);
     	if(digest == null) {
     		log.info("Resource {} was not installed yet, installing in OsgiController", path);

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java Tue Nov  4 06:20:58 2008
@@ -26,8 +26,8 @@
  */
 public interface OsgiResourceProcessor {
     
-    /** True if this processor can process the given uri */
-    boolean canProcess(String uri);
+    /** True if this processor can process the given data */
+    boolean canProcess(String uri, InstallableData data);
     
     /** Install or update supplied resource 
      *  @param uri Unique identifier for the resource

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java Tue Nov  4 06:20:58 2008
@@ -135,49 +135,57 @@
     	}
     	
         // Update if we already have a bundle id, else install
-        Bundle b = null;
-        boolean updated = false;
-
-        // check whether we know the bundle and it exists
-        final Long longId = (Long) attributes.get(KEY_BUNDLE_ID);
-        if (longId != null) {
-            b = ctx.getBundle(longId);
-        }
-
-        // either we don't know the bundle yet or it does not exist,
-        // so check whether the bundle can be found by its symbolic name
-        if (b == null) {
-            // ensure we can mark and reset to read the manifest
-            if (!data.markSupported()) {
-                data = new BufferedInputStream(data);
-            }
-            final BundleInfo info = getMatchingBundle(data);
-            if (info != null) {
-                final Version availableVersion = new Version(
-                    (String) info.bundle.getHeaders().get(
-                        Constants.BUNDLE_VERSION));
-                final Version newVersion = new Version(info.newVersion);
-                if (newVersion.compareTo(availableVersion) > 0) {
-                    b = info.bundle;
-                } else {
-                    log.debug(
-                        "Ignore update of bundle {} from {} as the installed version is equal or higher.",
-                        info.bundle.getSymbolicName(), uri);
-                    return IGNORED;
-                }
-            }
-        }
-
-        if (b != null) {
-            b.stop();
-            b.update(data);
-            updated = true;
-            needsRefresh = true;
-        } else {
-            uri = OsgiControllerImpl.getResourceLocation(uri);
-            log.debug("No matching Bundle for uri {}, installing", uri);
-            b = ctx.installBundle(uri, data);
-        }
+		Bundle b;
+		boolean updated;
+		try {
+			b = null;
+			updated = false;
+
+			// check whether we know the bundle and it exists
+			final Long longId = (Long) attributes.get(KEY_BUNDLE_ID);
+			if (longId != null) {
+			    b = ctx.getBundle(longId);
+			}
+
+			// either we don't know the bundle yet or it does not exist,
+			// so check whether the bundle can be found by its symbolic name
+			if (b == null) {
+			    // ensure we can mark and reset to read the manifest
+			    if (!data.markSupported()) {
+			        data = new BufferedInputStream(data);
+			    }
+			    final BundleInfo info = getMatchingBundle(data);
+			    if (info != null) {
+			        final Version availableVersion = new Version(
+			            (String) info.bundle.getHeaders().get(
+			                Constants.BUNDLE_VERSION));
+			        final Version newVersion = new Version(info.newVersion);
+			        if (newVersion.compareTo(availableVersion) > 0) {
+			            b = info.bundle;
+			        } else {
+			            log.debug(
+			                "Ignore update of bundle {} from {} as the installed version is equal or higher.",
+			                info.bundle.getSymbolicName(), uri);
+			            return IGNORED;
+			        }
+			    }
+			}
+
+			if (b != null) {
+			    b.stop();
+			    b.update(data);
+			    updated = true;
+			    needsRefresh = true;
+			} else {
+			    uri = OsgiControllerImpl.getResourceLocation(uri);
+			    log.debug("No matching Bundle for uri {}, installing", uri);
+			    b = ctx.installBundle(uri, data);
+			}
+		} finally {
+			if(data != null) {
+				data.close();
+			}
+		}
 
         // ensure the bundle id in the attributes, this may be overkill
         // in simple update situations, but is required for installations
@@ -220,7 +228,7 @@
     /**
      * @see org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor#canProcess(java.lang.String)
      */
-    public boolean canProcess(String uri) {
+    public boolean canProcess(String uri, InstallableData data) {
         return uri.endsWith(BUNDLE_EXTENSION);
     }
 

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ConfigResourceProcessor.java Tue Nov  4 06:20:58 2008
@@ -52,8 +52,9 @@
         // nothing to do
     }
     
-    public boolean canProcess(String uri) {
-        return uri.endsWith(CONFIG_EXTENSION);
+    public boolean canProcess(String uri, InstallableData data) {
+    	final boolean isDict = data == null ? false : data.adaptTo(Dictionary.class) != null; 
+        return uri.endsWith(CONFIG_EXTENSION) || isDict;
     }
 
     @SuppressWarnings("unchecked")
@@ -67,7 +68,13 @@
 	    	if(data == null) {
 	    		throw new IOException("InstallableData does not adapt to an InputStream: " + uri);
 	    	}
-	    	dict = reader.load(data);
+	    	try {
+	    		dict = reader.load(data);
+	    	} finally {
+	    		if(data != null) {
+	    			data.close();
+	    		}
+	    	}
     	}
     	
     	if(dict == null) {

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java Tue Nov  4 06:20:58 2008
@@ -21,7 +21,6 @@
 import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.IGNORED;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -31,12 +30,7 @@
 import org.apache.sling.jcr.jcrinstall.osgi.JcrInstallException;
 import org.apache.sling.jcr.jcrinstall.osgi.OsgiController;
 import org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentContext;
@@ -116,7 +110,7 @@
     
     public int installOrUpdate(String uri, InstallableData data) throws IOException, JcrInstallException {
         int result = IGNORED;
-        final OsgiResourceProcessor p = getProcessor(uri);
+        final OsgiResourceProcessor p = getProcessor(uri, data);
         if (p != null) {
             try {
                 final Map<String, Object> map = storage.getMap(uri);
@@ -128,21 +122,21 @@
             } catch(IOException ioe) {
                 throw ioe;
             } catch(Exception e) {
-                throw new JcrInstallException("Exception in installOrUpdate", e);
+                throw new JcrInstallException("Exception in installOrUpdate (" + uri + ")", e);
             }
         }
         return result;
     }
 
     public void uninstall(String uri) throws JcrInstallException {
-        final OsgiResourceProcessor p = getProcessor(uri);
+        final OsgiResourceProcessor p = getProcessor(uri, null);
         if(p != null) {
             try {
                 p.uninstall(uri, storage.getMap(uri));
                 storage.remove(uri);
                 storage.saveToFile();
             } catch(Exception e) {
-                throw new JcrInstallException("Exception in uninstall", e);
+                throw new JcrInstallException("Exception in uninstall (" + uri + ")", e);
             }
         }
     }
@@ -169,7 +163,7 @@
     }
 
     /** Return the first processor that accepts given uri, null if not found */
-    OsgiResourceProcessor getProcessor(String uri) {
+    OsgiResourceProcessor getProcessor(String uri, InstallableData data) {
         OsgiResourceProcessor result = null;
 
         if(processors == null) {
@@ -177,7 +171,7 @@
         }
 
         for(OsgiResourceProcessor p : processors) {
-            if(p.canProcess(uri)) {
+            if(p.canProcess(uri, data)) {
                 result = p;
                 break;
             }

Modified: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java Tue Nov  4 06:20:58 2008
@@ -98,14 +98,15 @@
             f = session.getRootNode().getNode(relPath);
             res = f.getNode(JCR_CONTENT);
         } else {
-            f = session.getRootNode().addNode(relPath);
-            res = f.addNode(JCR_CONTENT);
+            f = session.getRootNode().addNode(relPath,NT_FILE);
+            res = f.addNode(JCR_CONTENT,NT_RESOURCE);
         }
         
         final Calendar c = Calendar.getInstance();
         c.setTimeInMillis(lastModified);
         res.setProperty(JCR_LASTMODIFIED, c);
         res.setProperty(JCR_DATA, data);
+        res.setProperty(JCR_MIMETYPE, "");
         
         f.getParent().save();
     }

Added: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java?rev=711260&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java Tue Nov  4 06:20:58 2008
@@ -0,0 +1,70 @@
+package org.apache.sling.jcr.jcrinstall.jcr.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+public class DigestTest {
+	private void setTestData(Hashtable<String, Object> d) {
+		d.put("str", "value");
+		d.put("long", new Long(12));
+		d.put("array", new String[] { "a", "b"});
+	}
+	
+	private String testDigestChanged(Dictionary<String, Object> d, 
+			String oldDigest, int step, boolean shouldChange) throws Exception {
+		final String newDigest = ConfigInstallableData.computeDigest(d);
+		if(shouldChange) {
+			assertTrue("Digest (" + newDigest + ") should have changed at step " + step, !newDigest.equals(oldDigest));
+		} else {
+			assertTrue("Digest (" + newDigest + ") should NOT have changed at step " + step, newDigest.equals(oldDigest));
+		}
+		return newDigest;
+	}
+	
+	@org.junit.Test public void testDictionaryDigestSameData() throws Exception {
+		final Hashtable<String, Object> d1 = new Hashtable<String, Object>();
+		final Hashtable<String, Object> d2 = new Hashtable<String, Object>();
+		
+		setTestData(d1);
+		setTestData(d2);
+		
+		assertEquals(
+				"Two dictionary with same values have the same key", 
+				ConfigInstallableData.computeDigest(d1),
+				ConfigInstallableData.computeDigest(d2)
+		);
+	}
+	
+	@org.junit.Test public void testDictionaryDigestChanges() throws Exception {
+		String digest = "";
+		int step = 1;
+		
+		final Dictionary<String, Object> d = new Hashtable<String, Object>();
+		digest = testDigestChanged(d, digest, step, true);
+		digest = testDigestChanged(d, digest, step, false);
+		
+		d.put("key", "value");
+		digest = testDigestChanged(d, digest, step, true);
+		d.put("key", "value");
+		digest = testDigestChanged(d, digest, step, false);
+		
+		d.put("int", new Integer(12));
+		digest = testDigestChanged(d, digest, step, true);
+		d.put("int", new Integer(12));
+		digest = testDigestChanged(d, digest, step, false);
+		d.put("int", new Integer(13));
+		digest = testDigestChanged(d, digest, step, true);
+		
+		d.put("array", new String [] { "a", "b", "c"});
+		digest = testDigestChanged(d, digest, step, true);
+		d.put("array", new String [] { "a", "b", "c"});
+		digest = testDigestChanged(d, digest, step, false);
+		d.put("array", new String [] { "a", "b", "D"});
+		digest = testDigestChanged(d, digest, step, true);
+		d.put("another", new String [] { "a", "b", "D"});
+		digest = testDigestChanged(d, digest, step, true);
+	}
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/DigestTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java?rev=711260&r1=711259&r2=711260&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java (original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java Tue Nov  4 06:20:58 2008
@@ -35,8 +35,8 @@
     @org.junit.Test public void testNoProcessors() throws Exception {
         final OsgiControllerImpl c = new OsgiControllerImpl();
         Utilities.setProcessors(c);
-        assertNull("Controller must return null processor for null uri", c.getProcessor(null));
-        assertNull("Controller must return null processor for TEST uri", c.getProcessor("TEST"));
+        assertNull("Controller must return null processor for null uri", c.getProcessor(null, null));
+        assertNull("Controller must return null processor for TEST uri", c.getProcessor("TEST", null));
     }
     
     @org.junit.Test public void testTwoProcessors() throws Exception {
@@ -46,13 +46,13 @@
         Utilities.setProcessors(c, p1, p2);
         
         mockery.checking(new Expectations() {{
-            allowing(p1).canProcess("foo") ; will(returnValue(true));
-            allowing(p1).canProcess("bar") ; will(returnValue(false));
-            allowing(p2).canProcess("foo") ; will(returnValue(false));
-            allowing(p2).canProcess("bar") ; will(returnValue(true));
+            allowing(p1).canProcess("foo", null) ; will(returnValue(true));
+            allowing(p1).canProcess("bar", null) ; will(returnValue(false));
+            allowing(p2).canProcess("foo", null) ; will(returnValue(false));
+            allowing(p2).canProcess("bar", null) ; will(returnValue(true));
         }});
         
-        assertEquals("foo extension must return processor p1", p1, c.getProcessor("foo"));
-        assertEquals("bar extension must return processor p2", p2, c.getProcessor("bar"));
+        assertEquals("foo extension must return processor p1", p1, c.getProcessor("foo", null));
+        assertEquals("bar extension must return processor p2", p2, c.getProcessor("bar", null));
     }
 }



Mime
View raw message