jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r169262 - in /incubator/jackrabbit/trunk/contrib/jcr-server: server/ server/src/java/org/apache/jackrabbit/server/simple/dav/lock/ webapp/ webdav/src/java/org/apache/jackrabbit/ webdav/src/java/org/apache/jackrabbit/webdav/jcr/ webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/
Date Mon, 09 May 2005 09:49:28 GMT
Author: dpfister
Date: Mon May  9 02:49:27 2005
New Revision: 169262

URL: http://svn.apache.org/viewcvs?rev=169262&view=rev
Log:
- fix uncomplete sync

Added:
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
  (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml Mon May  9 02:49:27 2005
@@ -66,7 +66,6 @@
         </dependency>
         <dependency>
             <id>jcr-rmi</id>
-<!-- TODO: change to 0.16.4.1 as soon as available -->
             <version>0.16.4</version>
         </dependency>
         <dependency>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/project.xml Mon May  9 02:49:27 2005
@@ -90,7 +90,6 @@
         </dependency>
         <dependency>
             <id>jcr-rmi</id>
-<!-- TODO: change to 0.16.4.1 as soon as available -->
             <version>0.16.4</version>
             <properties>
                 <war.bundle>false</war.bundle>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/JcrConstants.java
Mon May  9 02:49:27 2005
@@ -124,10 +124,6 @@
      */
     public static final String JCR_ONPARENTVERSION = "jcr:onParentVersion";
     /**
-     * jcr:path
-     */
-    public static final String JCR_PATH = "jcr:path";
-    /**
      * jcr:predecessors
      */
     public static final String JCR_PREDECESSORS = "jcr:predecessors";
@@ -203,6 +199,16 @@
      * jcr:versionableUuid
      */
     public static final String JCR_VERSIONABLEUUID = "jcr:versionableUuid";
+
+    /**
+     * Pseudo property jcr:path used with query results
+     */
+    public static final String JCR_PATH = "jcr:path";
+    /**
+     * Pseudo property jcr:score used with query results
+     */
+    public static final String JCR_SCORE = "jcr:score";
+
     /**
      * mix:lockable
      */

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
Mon May  9 02:49:27 2005
@@ -18,10 +18,7 @@
 import org.apache.log4j.Logger;
 import org.apache.jackrabbit.webdav.property.*;
 import org.apache.jackrabbit.webdav.*;
-import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
-import org.apache.jackrabbit.webdav.jcr.version.report.ExportViewReport;
-import org.apache.jackrabbit.webdav.jcr.version.report.LocateByUuidReport;
-import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.*;
 import org.apache.jackrabbit.webdav.transaction.TxLockEntry;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
@@ -237,7 +234,8 @@
                 NodeTypesReport.NODETYPES_REPORT,
                 ExportViewReport.EXPORTVIEW_REPORT,
                 LocateByUuidReport.LOCATE_BY_UUID_REPORT,
-		RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT
+                RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT,
+                RepositoryDescriptorsReport.REPOSITORY_DESCRIPTORS_REPORT
             });
         }
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
Mon May  9 02:49:27 2005
@@ -224,8 +224,16 @@
                     n.addNode(resource.getDisplayName());
                 } else {
                     // MKCOL, which is not allowed for existing resources
+                    if (getTransactionId() == null) {
+                        // if not part of a transaction directely import on workspace
+                        // since changes would be explicitely saved in the
+                        // complete-call.
+                        getRepositorySession().getWorkspace().importXML(getResourcePath(),
in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+                    } else {
+                        // changes will not be persisted unless the tx is completed.
                     getRepositorySession().importXML(getResourcePath(), in, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
                 }
+                }
             } else {
                 if (in == null) {
                     // PUT: not possible
@@ -671,6 +679,9 @@
                 properties.add(new NodeTypeProperty(JCR_MIXINNODETYPES, n.getMixinNodeTypes(),
false));
                 properties.add(new DefaultDavProperty(JCR_INDEX, new Integer(n.getIndex())));
 		addHrefProperty(JCR_REFERENCES, n.getReferences(), false);
+                if (n.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
+                    properties.add(new DefaultDavProperty(JCR_UUID, n.getUUID()));
+                }
             } catch (RepositoryException e) {
                 log.error("Failed to retrieve primary nodetype property: " + e.getMessage());
             }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
Mon May  9 02:49:27 2005
@@ -63,8 +63,13 @@
     // xml elements used to reflect the workspaces ns-registry
     // TODO: to be review...
     public static final String XML_NAMESPACE = "namespace";
-    public static final String XML_NSPREFIX = "nsPrefix";
-    public static final String XML_NSURI = "nsURI";
+    public static final String XML_PREFIX = "prefix";
+    public static final String XML_URI = "uri";
+
+    // xml elements used for repository-descritors report
+    public static final String XML_DESCRIPTOR = "descriptor";
+    public static final String XML_DESCRIPTORKEY = "descriptorkey";
+    public static final String XML_DESCRIPTORVALUE = "descriptorvalue";
 
     /**
      * Extension to the WebDAV 'exclusive' lock, that allows to distinguish
@@ -108,6 +113,7 @@
     public static final DavPropertyName JCR_MIXINNODETYPES = DavPropertyName.create("mixinnodetypes",
NAMESPACE);
     public static final DavPropertyName JCR_INDEX = DavPropertyName.create("index", NAMESPACE);
     public static final DavPropertyName JCR_REFERENCES = DavPropertyName.create("references",
NAMESPACE);
+    public static final DavPropertyName JCR_UUID = DavPropertyName.create("uuid", NAMESPACE);
     public static final DavPropertyName JCR_PRIMARYITEM = DavPropertyName.create("primaryitem",
NAMESPACE);
 
     // property names used for resources representing jcr-properties

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
Mon May  9 02:49:27 2005
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.webdav.*;
 import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 
@@ -177,7 +178,8 @@
             supportedReports = new SupportedReportSetProperty(new ReportType[] {
 	    ReportType.EXPAND_PROPERTY,
 	    NodeTypesReport.NODETYPES_REPORT,
-	    RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT
+                RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT,
+                RepositoryDescriptorsReport.REPOSITORY_DESCRIPTORS_REPORT
             });
         }
     }
@@ -199,4 +201,4 @@
 	}
 	return null;
     }
-}
\ No newline at end of file
+}

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
Mon May  9 02:49:27 2005
@@ -95,8 +95,8 @@
 	    Element[] nsElems = new Element[prefixes.length];
 	    for (int i = 0; i < prefixes.length; i++) {
 		Element elem = new Element(XML_NAMESPACE, NAMESPACE);
-		elem.addContent(new Element(XML_NSPREFIX).setText(prefixes[i]));
-		elem.addContent(new Element(XML_NSURI)).setText(nsReg.getURI(prefixes[i]));
+                elem.addContent(new Element(XML_PREFIX).setText(prefixes[i]));
+                elem.addContent(new Element(XML_URI)).setText(nsReg.getURI(prefixes[i]));
 		nsElems[i] = elem;
 	    }
 	    properties.add(new DefaultDavProperty(ItemResourceConstants.JCR_NAMESPACES, nsElems,
false));

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
Mon May  9 02:49:27 2005
@@ -93,7 +93,7 @@
 
     /**
      * Converts the value of this property to a {@link javax.jcr.Value value array}.
-     * Please note, that the convertion is done by using the {@link org.apache.jackrabbit.core.util.ValueHelper}
+     * Please note, that the convertion is done by using the {@link org.apache.jackrabbit.core.value.ValueHelper}
      * class that is not part of the JSR170 API.
      *
      * @return Array of Value objects

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
Mon May  9 02:49:27 2005
@@ -37,8 +37,8 @@
 /**
  * <code>ExportViewReport</code> handles REPORT requests for the 'exportview'
  * report. The 'exportview' report is used to export
- * {@link Session#exportDocView(String, java.io.OutputStream, boolean, boolean) DocView}
- * and {@link Session#exportSysView(String, java.io.OutputStream, boolean, boolean) SysView}
+ * {@link Session#exportDocumentView(String, java.io.OutputStream, boolean, boolean) DocView}
+ * and {@link Session#exportSystemView(String, java.io.OutputStream, boolean, boolean) SysView}
  * of the {@link javax.jcr.Item item} represented by the requested resource.
  * <p/>
  * The request body must contain a jcr:exportview element:

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
Mon May  9 02:49:27 2005
@@ -112,7 +112,7 @@
             DavResource res = resource.getFactory().createResource(loc, session);
 
             MultiStatus ms = new MultiStatus();
-            ms.addResourceProperties(res, propNameSet, 0);
+            ms.addResourceProperties(res, propNameSet, info.getDepth());
             return ms.toXml();
 
         } catch (RepositoryException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java?rev=169262&r1=169261&r2=169262&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
(original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
Mon May  9 02:49:27 2005
@@ -31,18 +31,23 @@
 import java.util.List;
 
 /**
- * <code>NodeTypesReport</code> allows to retrieve the definition of a single
- * or multiple node types. The request body must be a 'jcr:nodetypes' element:
- * <pre>
- * &lt;!ELEMENT nodetypes ( nodetype+ | all-nodetypes | mixin-nodetypes | primary-nodetypes
) &gt;
+ * <code>RegisteredNamespacesReport</code> let the client retrieve the namespaces
+ * registered on the repository.<p/>
  *
- * &lt;!ELEMENT nodetype ( nodetype-name ) &gt;
- * &lt;!ELEMENT nodetype-name (#PCDATA) &gt;
+ * Request body:
+ * <pre>
+ * &lt;!ELEMENT registerednamespaces EMPTY &gt;
+ * </pre>
  *
- * &lt;!ELEMENT all-nodetypes EMPTY &gt;
- * &lt;!ELEMENT mixin-nodetypes EMPTY &gt;
- * &lt;!ELEMENT primary-nodetypes EMPTY &gt;
+ * Response body:
+ * <pre>
+ * &lt;!ELEMENT registerednamespaces-report (namespace)* &gt;
+ * &lt;!ELEMENT namespace (prefix, uri) &gt;
+ * &lt;!ELEMENT prefix (#PCDATA) &gt;
+ * &lt;!ELEMENT uri (#PCDATA) &gt;
  * </pre>
+ *
+ * @see javax.jcr.Workspace#getNamespaceRegistry() 
  */
 public class RegisteredNamespacesReport implements Report, ItemResourceConstants {
 
@@ -117,8 +122,8 @@
 	    List namespaceList = new ArrayList();
 	    for (int i = 0; i < prefixes.length; i++) {
 		Element elem = new Element(XML_NAMESPACE, NAMESPACE);
-		elem.addContent(new Element(XML_NSPREFIX, NAMESPACE).setText(prefixes[i]));
-		elem.addContent(new Element(XML_NSURI, NAMESPACE).setText(nsReg.getURI(prefixes[i])));
+		elem.addContent(new Element(XML_PREFIX, NAMESPACE).setText(prefixes[i]));
+		elem.addContent(new Element(XML_URI, NAMESPACE).setText(nsReg.getURI(prefixes[i])));
 		namespaceList.add(elem);
 	    }
 	    Element report = new Element("registerednamespaces-report", NAMESPACE).addContent(namespaceList);

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java?rev=169262&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
(added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
Mon May  9 02:49:27 2005
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.jackrabbit.webdav.jcr.version.report;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.version.report.*;
+import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import javax.jcr.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>RepositoryDescriptorsReport</code> allows to retrieve the repository
+ * descriptors. The request body must be an empty 'jcr:repositorydescriptors' element:
+ * <pre>
+ * &lt;!ELEMENT repositorydescriptors EMPTY &gt;
+ * </pre>
+ * <br>
+ * The response body must match the following format
+ *
+ * <pre>
+ * &lt;!ELEMENT repositorydescriptors-report ( descriptor )* &gt;
+ * &lt;!ELEMENT descriptor ( descriptorkey, descriptorvalue ) &gt;
+ * &lt;!ELEMENT descriptorkey (#PCDATA) &gt;
+ * &lt;!ELEMENT descriptorvalue (#PCDATA) &gt;
+ * </pre>
+ *
+ * @see javax.jcr.Repository#getDescriptorKeys()
+ * @see Repository#getDescriptor(String)
+ */
+public class RepositoryDescriptorsReport implements Report, ItemResourceConstants {
+
+    private static Logger log = Logger.getLogger(RepositoryDescriptorsReport.class);
+
+    /**
+     * The registered type of this report.
+     */
+    public static final ReportType REPOSITORY_DESCRIPTORS_REPORT = ReportType.register("registerednamespaces",
ItemResourceConstants.NAMESPACE, RepositoryDescriptorsReport.class);
+
+    private Repository repository;
+
+    /**
+     * Returns {@link #REPOSITORY_DESCRIPTORS_REPORT} type.
+     * @return {@link #REPOSITORY_DESCRIPTORS_REPORT}
+     * @see org.apache.jackrabbit.webdav.version.report.Report#getType()
+     */
+    public ReportType getType() {
+        return REPOSITORY_DESCRIPTORS_REPORT;
+    }
+
+    /**
+     * @param resource
+     * @throws IllegalArgumentException if the resource or the session retrieved
+     * from the specified resource is <code>null</code>
+     * @see org.apache.jackrabbit.webdav.version.report.Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     */
+    public void setResource(DeltaVResource resource) {
+        if (resource == null) {
+            throw new IllegalArgumentException("Resource must not be null.");
+        }
+        DavSession session = resource.getSession();
+        if (session == null || session.getRepositorySession() == null) {
+            throw new IllegalArgumentException("The resource must provide a non-null session
object in order to create the jcr:nodetypes report.");
+        }
+        repository = session.getRepositorySession().getRepository();
+    }
+
+    /**
+     * @param info
+     * @throws IllegalArgumentException if the specified info does not contain
+     * a jcr:nodetypes element.
+     * @see org.apache.jackrabbit.webdav.version.report.Report#setInfo(org.apache.jackrabbit.webdav.version.report.ReportInfo)
+     */
+    public void setInfo(ReportInfo info) {
+        if (info == null || !"repositorydescriptors".equals(info.getReportElement().getName()))
{
+            throw new IllegalArgumentException("jcr:repositorydescriptors element expected.");
+        }
+    }
+
+    /**
+     * Returns a Xml representation of the node type definition(s) according
+     * to the info object.
+     *
+     * @return Xml representation of the node type definition(s)
+     * @throws org.apache.jackrabbit.webdav.DavException if the specified nodetypes are not
known or if another
+     * error occurs while retrieving the nodetype definitions.
+     * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
+     */
+    public Document toXml() throws DavException {
+        String[] keys = repository.getDescriptorKeys();
+        List descList = new ArrayList();
+        for (int i = 0; i < keys.length; i++) {
+            Element elem = new Element(XML_DESCRIPTOR, NAMESPACE);
+            elem.addContent(new Element(XML_DESCRIPTORKEY, NAMESPACE).setText(keys[i]));
+            elem.addContent(new Element(XML_DESCRIPTORVALUE, NAMESPACE).setText(repository.getDescriptor(keys[i])));
+            descList.add(elem);
+        }
+        Element report = new Element("repositorydescriptors-report", NAMESPACE).addContent(descList);
+        Document reportDoc = new Document(report);
+        return reportDoc;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message