[exo-jcr-commits] exo-jcr SVN: r1297 - jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 5 10:54:13 EST 2010


Author: nzamosenchuk
Date: 2010-01-05 10:54:13 -0500 (Tue, 05 Jan 2010)
New Revision: 1297

Modified:
   jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
Log:
EXOJCR-340: Added method addNode, with mimetype parameter.

Modified: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java	2010-01-05 14:53:40 UTC (rev 1296)
+++ jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java	2010-01-05 15:54:13 UTC (rev 1297)
@@ -74,6 +74,52 @@
       Put(workspacePath + name, data, headers).getStatusCode();
    }
 
+   /**
+    * Adds node with given mixin types.
+    * 
+    * @param name
+    * @param nodeType
+    * @param mixinTypes
+    * @param data
+    * @return
+    * @throws IOException
+    * @throws ModuleException
+    */
+   public HTTPResponse addNode(String name, String[] mixinTypes, byte[] data) throws IOException, ModuleException
+   {
+      // construct string containing mixins in comma separated format
+      String mixins = mixinTypes.length > 0 ? mixinTypes[0] : "";
+      for (int i = 1; i < mixinTypes.length; i++)
+      {
+         mixins = mixins + ", " + mixinTypes[i];
+      }
+      NVPair[] headers = new NVPair[2];
+      headers[0] = new NVPair(ExtHttpHeaders.CONTENT_MIXINTYPES, mixins);
+      headers[1] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/plain");
+      HTTPResponse response = Put(workspacePath + name, data, headers);
+      response.getStatusCode();
+      return response;
+   }
+
+   /**
+    * Adds node (nt:file) with given mimetype.
+    * 
+    * @param name
+    * @param data
+    * @param mimeType
+    * @return
+    * @throws IOException
+    * @throws ModuleException
+    */
+   public HTTPResponse addNode(String name, byte[] data, String mimeType) throws IOException, ModuleException
+   {
+      NVPair[] headers = new NVPair[1];
+      headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, mimeType);
+      HTTPResponse response = Put(workspacePath + name, data, headers);
+      response.getStatusCode();
+      return response;
+   }
+
    public HTTPResponse addNode(String name, HttpOutputStream stream) throws IOException, ModuleException
    {
       return Put(workspacePath + name, stream);
@@ -286,6 +332,7 @@
    /**
     * Performs SQL query on workspace and returns plain HTTPResponse. It should be returned with status 207 
     * and must contain the XML with node collection. 
+    * 
     * @param query
     * @return
     * @throws IOException



More information about the exo-jcr-commits mailing list