jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r804296 - in /jackrabbit/trunk: jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jc...
Date Fri, 14 Aug 2009 16:58:47 GMT
Author: angela
Date: Fri Aug 14 16:58:47 2009
New Revision: 804296

URL: http://svn.apache.org/viewvc?rev=804296&view=rev
Log:
JCR-2256: JSR 283 Repository Descriptors

Modified:
    jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
    jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
    jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
Fri Aug 14 16:58:47 2009
@@ -162,7 +162,7 @@
             return null;
         }
 
-        public Map getRepositoryDescriptors() throws RepositoryException {
+        public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
             return null;
         }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
Fri Aug 14 16:58:47 2009
@@ -29,6 +29,9 @@
 import org.w3c.dom.Element;
 
 import javax.jcr.Repository;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
 
 /**
  * <code>RepositoryDescriptorsReport</code> allows to retrieve the repository
@@ -96,11 +99,22 @@
     public Element toXml(Document document) {
         Repository repository = getRepositorySession().getRepository();
         Element report = DomUtil.createElement(document, "repositorydescriptors-report",
NAMESPACE);
-        String[] keys = repository.getDescriptorKeys();
-        for (int i = 0; i < keys.length; i++) {
+        for (String key : repository.getDescriptorKeys()) {
             Element elem = DomUtil.addChildElement(report, XML_DESCRIPTOR, NAMESPACE);
-            DomUtil.addChildElement(elem, XML_DESCRIPTORKEY, NAMESPACE, keys[i]);
-            DomUtil.addChildElement(elem, XML_DESCRIPTORVALUE, NAMESPACE, repository.getDescriptor(keys[i]));
+            DomUtil.addChildElement(elem, XML_DESCRIPTORKEY, NAMESPACE, key);
+            for (Value v : repository.getDescriptorValues(key)) {
+                String value;
+                try {
+                    value = v.getString();
+                } catch (RepositoryException e) {
+                    log.error("Internal error while reading descriptor value: ", e);
+                    value = repository.getDescriptor(key);
+                }
+                Element child = DomUtil.addChildElement(elem, XML_DESCRIPTORVALUE, NAMESPACE,
value);
+                if (PropertyType.STRING != v.getType()) {
+                    child.setAttribute(ATTR_VALUE_TYPE, PropertyType.nameFromValue(v.getType()));
+                }
+            }
         }
         return report;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
Fri Aug 14 16:58:47 2009
@@ -19,6 +19,7 @@
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.HashMap;
 
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
@@ -27,6 +28,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.NamespaceException;
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
@@ -40,20 +43,52 @@
 import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.XASessionInfo;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.value.ValueFactoryImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>RepositoryImpl</code>...
  */
 public class RepositoryImpl extends AbstractRepository implements Referenceable {
 
+    private static Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
+
     // configuration of the repository
     private final RepositoryConfig config;
-    private final Map descriptors;
+    private final Map<String, Value[]> descriptors;
     private Reference reference = null;
 
     private RepositoryImpl(RepositoryConfig config) throws RepositoryException {
         this.config = config;
-        descriptors = config.getRepositoryService().getRepositoryDescriptors();
+
+        // dummy value factory and dummy resolver as descriptors are not
+        // expected contain Name or Path values.
+        ValueFactory vf = ValueFactoryImpl.getInstance(); 
+        NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {
+            public String getURI(String prefix) throws NamespaceException {
+                return prefix;
+            }
+            public String getPrefix(String uri) throws NamespaceException {
+                return uri;
+            }
+        });
+
+        Map<String, QValue[]> descr = config.getRepositoryService().getRepositoryDescriptors();
      
+        descriptors = new HashMap(descr.size());
+        for (String key : descr.keySet()) {
+            QValue[] qvs = descr.get(key);
+            Value[] vs = new Value[qvs.length];
+            for (int i = 0; i < qvs.length; i++) {
+                vs[i] = ValueFormat.getJCRValue(qvs[i], resolver, vf);
+            }
+            descriptors.put(key, vs);
+        }
     }
 
     public static Repository create(RepositoryConfig config) throws RepositoryException {
@@ -65,39 +100,39 @@
      * @see Repository#getDescriptorKeys()
      */
     public String[] getDescriptorKeys() {
-        String[] keys = (String[]) descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
-        return keys;
+        return descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
     }
 
     /**
      * @see Repository#getDescriptor(String)
      */
-    public String getDescriptor(String descriptorKey) {
-        return (String) descriptors.get(descriptorKey);
+    public String getDescriptor(String key) {
+        Value v = getDescriptorValue(key);
+        try {
+            return (v == null) ? null : v.getString();
+        } catch (RepositoryException e) {
+            log.error("corrupt descriptor value: " + key, e);
+            return null;
+        }
     }
 
     /**
      * @see Repository#getDescriptorValue(String)
      */
     public Value getDescriptorValue(String key) {
-        String value = getDescriptor(key);
-        if (value != null) {
-            // TODO implementation missing
-            throw new UnsupportedOperationException("not implemented yet - see JCR-2062");
-        } else {
-            return null;
-        }
+        Value[] vs = getDescriptorValues(key);
+        return (vs == null || vs.length != 1) ? null : vs[0];
     }
 
     /**
      * @see Repository#getDescriptorValues(String)
      */
     public Value[] getDescriptorValues(String key) {
-        Value value = getDescriptorValue(key);
-        if (value != null) {
-            return new Value[] { value };
-        } else {
+        if (!descriptors.containsKey(key)) {
             return null;
+        } else {
+            return descriptors.get(key);
+
         }
     }
 
@@ -105,7 +140,8 @@
      * @see Repository#isSingleValueDescriptor(String)
      */
     public boolean isSingleValueDescriptor(String key) {
-        return descriptors.containsKey(key);
+        Value[] vs = descriptors.get(key);
+        return (vs != null && vs.length == 1);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java
Fri Aug 14 16:58:47 2009
@@ -32,6 +32,7 @@
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.PropertyType;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import junit.framework.TestCase;
@@ -63,6 +64,7 @@
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.Subscription;
 import org.apache.jackrabbit.spi.commons.AbstractReadableRepositoryService;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.compact.ParseException;
 
 /**
@@ -148,19 +150,22 @@
         return Collections.emptyMap();
     }
 
-    protected Map<String, String> getDescriptors() {
-        Map<String, String> descriptorKeys = new HashMap<String, String>();
+    protected Map<String, QValue[]> getDescriptors() throws RepositoryException {
+        Map<String, QValue[]> descriptorKeys = new HashMap<String, QValue[]>();
 
-        descriptorKeys.put(Repository.OPTION_LOCKING_SUPPORTED, Boolean.FALSE.toString());
-        descriptorKeys.put(Repository.OPTION_OBSERVATION_SUPPORTED, Boolean.FALSE.toString());
-        descriptorKeys.put(Repository.OPTION_TRANSACTIONS_SUPPORTED, Boolean.FALSE.toString());
-        descriptorKeys.put(Repository.OPTION_VERSIONING_SUPPORTED, Boolean.FALSE.toString());
-        descriptorKeys.put(Repository.REP_NAME_DESC, "Mock Repository");
-        descriptorKeys.put(Repository.REP_VENDOR_DESC, "Apache Software Foundation");
-        descriptorKeys.put(Repository.REP_VENDOR_URL_DESC, "http://www.apache.org/");
-        descriptorKeys.put(Repository.REP_VERSION_DESC, "1.0");
-        descriptorKeys.put(Repository.SPEC_NAME_DESC, "Content Repository API for Java(TM)
Technology Specification");
-        descriptorKeys.put(Repository.SPEC_VERSION_DESC, "1.0");
+        QValueFactory qvf = QValueFactoryImpl.getInstance();
+        QValue[] vFalse = new QValue[] {qvf.create(false)};
+
+        descriptorKeys.put(Repository.OPTION_LOCKING_SUPPORTED, vFalse);
+        descriptorKeys.put(Repository.OPTION_OBSERVATION_SUPPORTED, vFalse);
+        descriptorKeys.put(Repository.OPTION_TRANSACTIONS_SUPPORTED, vFalse);
+        descriptorKeys.put(Repository.OPTION_VERSIONING_SUPPORTED, vFalse);
+        descriptorKeys.put(Repository.REP_NAME_DESC, new QValue[] {qvf.create("Mock Repository",
PropertyType.STRING)});
+        descriptorKeys.put(Repository.REP_VENDOR_DESC, new QValue[] {qvf.create("Apache Software
Foundation", PropertyType.STRING)});
+        descriptorKeys.put(Repository.REP_VENDOR_URL_DESC, new QValue[] {qvf.create("http://www.apache.org/",
PropertyType.STRING)});
+        descriptorKeys.put(Repository.REP_VERSION_DESC, new QValue[] {qvf.create("2.0", PropertyType.STRING)});
+        descriptorKeys.put(Repository.SPEC_NAME_DESC, new QValue[] {qvf.create("Content Repository
API for Java(TM) Technology Specification", PropertyType.STRING)});
+        descriptorKeys.put(Repository.SPEC_VERSION_DESC, new QValue[] {qvf.create("2.0",
PropertyType.STRING)});
 
         return descriptorKeys;
     }
@@ -203,7 +208,7 @@
         return repositoryService.getQValueFactory();
     }
 
-    public Map<String, String> getRepositoryDescriptors() throws RepositoryException
{
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
         return repositoryService.getRepositoryDescriptors();
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
Fri Aug 14 16:58:47 2009
@@ -86,7 +86,7 @@
     /**
      * The repository descriptors.
      */
-    protected final Map<String, String> descriptors;
+    protected final Map<String, QValue[]> descriptors;
 
     /**
      * The fixed set of namespaces known to the repository service.
@@ -120,12 +120,12 @@
      * @throws RepositoryException if the namespace mappings are invalid.
      * @throws ParseException      if an error occurs while parsing the CND.
      */
-    public AbstractReadableRepositoryService(Map<String, String> descriptors,
+    public AbstractReadableRepositoryService(Map<String, QValue[]> descriptors,
                                              Map<String, String> namespaces,
                                              Reader cnd,
                                              List<String> wspNames)
             throws RepositoryException, ParseException {
-        this.descriptors = Collections.unmodifiableMap(new HashMap<String, String>(descriptors));
+        this.descriptors = Collections.unmodifiableMap(new HashMap<String, QValue[]>(descriptors));
         for (Map.Entry<String, String> entry : namespaces.entrySet()) {
             this.namespaces.setMapping(entry.getKey(), entry.getValue());
         }
@@ -273,7 +273,7 @@
      * This default implementation returns the descriptors that were passed
      * to the constructor of this repository service.
      */
-    public Map<String, String> getRepositoryDescriptors() throws RepositoryException
{
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
         return descriptors;
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java
Fri Aug 14 16:58:47 2009
@@ -109,8 +109,8 @@
         }, "getQValueFactory()", new Object[]{});
     }
 
-    public Map<String, String> getRepositoryDescriptors() throws RepositoryException
{
-        return (Map<String, String>) execute(new Callable() {
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
+        return (Map<String, QValue[]>) execute(new Callable() {
             public Object call() throws RepositoryException {
                 return service.getRepositoryDescriptors();
             }

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Fri Aug 14 16:58:47 2009
@@ -121,7 +121,7 @@
      * @see javax.jcr.Repository#getDescriptorKeys()
      * @see javax.jcr.Repository#getDescriptor(String)
      */
-    public Map<String, String> getRepositoryDescriptors() throws RepositoryException;
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException;
 
     //-----------------------------------< SessionInfo creation and release >---
     /**

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Fri Aug 14 16:58:47 2009
@@ -229,7 +229,7 @@
 
     private final Map nodeTypeDefinitions = new HashMap();
 
-    private Map descriptors;
+    private Map<String, QValue[]> descriptors;
 
     public RepositoryServiceImpl(String uri, IdFactory idFactory,
                                  NameFactory nameFactory,
@@ -497,7 +497,7 @@
     /**
      * @see RepositoryService#getRepositoryDescriptors()
      */
-    public Map getRepositoryDescriptors() throws RepositoryException {
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
         if (descriptors == null) {
             ReportInfo info = new ReportInfo(RepositoryDescriptorsReport.REPOSITORY_DESCRIPTORS_REPORT,
DEPTH_0);
             ReportMethod method = null;
@@ -514,12 +514,21 @@
                     while (nsElems.hasNext()) {
                         Element elem = nsElems.nextElement();
                         String key = DomUtil.getChildText(elem, ItemResourceConstants.XML_DESCRIPTORKEY,
ItemResourceConstants.NAMESPACE);
-                        String descriptor = DomUtil.getChildText(elem, ItemResourceConstants.XML_DESCRIPTORVALUE,
ItemResourceConstants.NAMESPACE);
-                        if (key != null && descriptor != null) {
-                            descriptors.put(key, descriptor);
-                        } else {
-                            log.error("Invalid descriptor key / value pair: " + key + " ->
" + descriptor);
+                        ElementIterator it = DomUtil.getChildren(elem, ItemResourceConstants.XML_DESCRIPTORVALUE,
ItemResourceConstants.NAMESPACE);
+                        List<QValue> vs = new ArrayList();
+                        while (it.hasNext()) {
+                            Element dv = it.nextElement();
+                            String descriptor = DomUtil.getText(dv);
+                            if (key != null && descriptor != null) {
+                                String typeStr = (DomUtil.getAttribute(dv, ItemResourceConstants.ATTR_VALUE_TYPE,
null));
+                                int type = (typeStr == null) ? PropertyType.STRING : PropertyType.valueFromName(typeStr);
+                                vs.add(getQValueFactory().create(descriptor, type));
+                            } else {
+                                log.error("Invalid descriptor key / value pair: " + key +
" -> " + descriptor);
+                            }
+
                         }
+                        descriptors.put(key, vs.toArray(new QValue[vs.size()]));
                     }
                 }
             } catch (IOException e) {
@@ -1109,8 +1118,7 @@
                 throw new ItemNotFoundException("Unable to retrieve the property with id
" + saveGetIdString(propertyId, resolver));
             }
 
-            PropertyInfo pInfo = new PropertyInfoImpl(propertyId, path, type, isMultiValued,
values);
-            return pInfo;
+            return new PropertyInfoImpl(propertyId, path, type, isMultiValued, values);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/pom.xml Fri Aug 14 16:58:47 2009
@@ -75,8 +75,6 @@
                 org.apache.jackrabbit.test.api.version.ActivitiesTest#testActivitiesRelation
                 org.apache.jackrabbit.test.api.version.ConfigurationsTest#testCreateConfigWithBaseline
                 org.apache.jackrabbit.test.api.LifecycleTest
-                org.apache.jackrabbit.test.api.RepositoryDescriptorTest#testRequiredDescriptors
-                org.apache.jackrabbit.test.api.RepositoryDescriptorTest#testGetDescriptorValues
               </value>
             </property>
           </systemProperties>

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=804296&r1=804295&r2=804296&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Fri Aug 14 16:58:47 2009
@@ -42,6 +42,7 @@
 import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.spi.commons.EventFilterImpl;
 import org.apache.jackrabbit.spi.commons.EventBundleImpl;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
@@ -50,6 +51,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
@@ -206,14 +208,29 @@
     /**
      * {@inheritDoc}
      */
-    public Map getRepositoryDescriptors() throws RepositoryException {
-        Map descriptors = new HashMap();
-        String[] keys = repository.getDescriptorKeys();
-        for (int i = 0; i < keys.length; i++) {
-            if (keys[i].equals(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
-                descriptors.put(keys[i], "false");
+    public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
+        Map<String, QValue[]> descriptors = new HashMap();
+        for (String key : repository.getDescriptorKeys()) {
+            if (key.equals(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
+                descriptors.put(key, new QValue[] {qValueFactory.create(false)});
             } else {
-                descriptors.put(keys[i], repository.getDescriptor(keys[i]));
+                Value[] vs = repository.getDescriptorValues(key);
+                QValue[] qvs = new QValue[vs.length];
+                for (int i = 0; i < vs.length; i++) {
+                    // Name and path resolver that uses a dummy namespace resolver
+                    // as Name/Path values are not expected to occur in the
+                    // descriptors. TODO: check again.
+                    NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver()
{
+                        public String getURI(String prefix) throws NamespaceException {
+                            return prefix;
+                        }
+                        public String getPrefix(String uri) throws NamespaceException {
+                            return uri;
+                        }
+                    });
+                    qvs[i] = ValueFormat.getQValue(vs[i], resolver, qValueFactory);
+                }
+                descriptors.put(key, qvs);
             }
         }
         return descriptors;



Mime
View raw message