Author: bdelacretaz
Date: Wed Nov  5 14:59:24 2008
New Revision: 711732

URL: http://svn.apache.org/viewvc?rev=711732&view=rev
Log:
SLING-719 - consider only sling:OsgiConfig nodes for configuration

Added:
    incubator/sling/trunk/extensions/jcrinstall/src/main/resources/
    incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/
    
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/
    
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd
   (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/ConfigNodeConverter.java
    
incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java

Modified: incubator/sling/trunk/extensions/jcrinstall/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/pom.xml?rev=711732&r1=711731&r2=711732&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/pom.xml (original)
+++ incubator/sling/trunk/extensions/jcrinstall/pom.xml Wed Nov  5 14:59:24 2008
@@ -60,7 +60,9 @@
                org.apache.sling.jcr.jcrinstall.jcr
             </Export-Package>
             
<Private-Package>org.apache.sling.jcr.jcrinstall.*</Private-Package>
-          </instructions>
+                       
<Sling-Nodetypes>SLING-INF/nodetypes/osgiconfig.cnd</Sling-Nodetypes>
+                       
<Sling-Namespaces>sling=http://sling.apache.org/jcr/sling/1.0</Sling-Namespaces>
+                 </instructions>
         </configuration>
       </plugin>
     </plugins>

Modified: 
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=711732&r1=711731&r2=711732&view=diff
==============================================================================
--- 
incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java
 (original)
+++ 
incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ConfigNodeConverter.java
 Wed Nov  5 14:59:24 2008
@@ -44,6 +44,8 @@
        
        private final Logger log = LoggerFactory.getLogger(getClass());
        
+       public static final String CONFIG_NODE_TYPE = "sling:OsgiConfig";
+       
        /**     TODO making this dynamic and optional would be better, but
         *      that would probably create issues at startup 
         *      @scr.reference 
@@ -55,12 +57,14 @@
         */
        public InstallableData convertNode(Node n) throws Exception {
                InstallableData result = null;
-               
-               // TODO use a mixin to identify these nodes?
-               if(n.isNodeType("nt:unstructured")) {
+
+               // We only consider CONFIG_NODE_TYPE nodes
+               if(n.isNodeType(CONFIG_NODE_TYPE)) {
                        final Dictionary<String, Object> config = load(n);
                        result = new ConfigInstallableData(config);
                        log.debug("Converted node {} to {}", n.getPath(), 
result);
+               } else {
+                       log.debug("Node is not a {} node, ignored:{}", 
CONFIG_NODE_TYPE, n.getPath());
                }
                return result;
        }

Added: 
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd?rev=711732&view=auto
==============================================================================
--- 
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd
 (added)
+++ 
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd
 Wed Nov  5 14:59:24 2008
@@ -0,0 +1,23 @@
+//
+//  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.
+//
+
+<sling = 'http://sling.apache.org/jcr/sling/1.0'>
+
+// A jcrinstall configuration node
+[sling:OsgiConfig] > nt:unstructured
\ No newline at end of file

Propchange: 
incubator/sling/trunk/extensions/jcrinstall/src/main/resources/SLING-INF/nodetypes/osgiconfig.cnd
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java?rev=711732&r1=711731&r2=711732&view=diff
==============================================================================
--- 
incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
 (original)
+++ 
incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java
 Wed Nov  5 14:59:24 2008
@@ -27,6 +27,8 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.sling.commons.testing.jcr.RepositoryTestBase;
@@ -68,6 +70,14 @@
         contentHelper = new ContentHelper(session);
         contentHelper.cleanupContent();
         
+        // Need the sling namespace for testing
+        final NamespaceRegistry r = 
session.getWorkspace().getNamespaceRegistry();
+        try {
+               r.registerNamespace("sling", 
"http://sling.apache.org/jcr/sling/1.0";);
+        } catch(RepositoryException ignore) {
+               // don't fail if already registered
+        }
+        
         mockery = new Mockery();
         sequence = mockery.sequence(getClass().getSimpleName());
     }


Reply via email to