Author: sascharodekamp
Date: Thu Oct 20 12:30:11 2011
New Revision: 1186761

URL: http://svn.apache.org/viewvc?rev=1186761&view=rev
Log:
Optimize File Handling

Modified:
    
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java
    
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrFileHelper.java
    
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java

Modified: 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java?rev=1186761&r1=1186760&r2=1186761&view=diff
==============================================================================
--- 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java
 (original)
+++ 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java
 Thu Oct 20 12:30:11 2011
@@ -67,6 +67,12 @@ public class ContentWriterJackrabbit imp
             return;
         }
 
+        // Read a primary node type from the mapping annotation class
+        // TODO Check for a better solution because here we have a cross
+        // reference to the Jackrabbit ORM Package.
+        org.apache.jackrabbit.ocm.mapper.impl.annotation.Node annotationNode = 
orm.getClass().getAnnotation(org.apache.jackrabbit.ocm.mapper.impl.annotation.Node.class);
+        String primNodeType = annotationNode.jcrType();
+
         // We loop only over the sub nodes.
         for (int i = 0; i < (nodeStructure.length - 1); i++) {
             String node = nodeStructure[i];
@@ -80,7 +86,8 @@ public class ContentWriterJackrabbit imp
                     
versioningManager.checkOutContentObject(parentNode.getPath());
                 } else {
                     
versioningManager.checkOutContentObject(parentNode.getPath());
-                    Node newNode = parentNode.addNode(node);
+
+                    Node newNode = parentNode.addNode(node, primNodeType);
                     newNode.addMixin(ConstantsJackrabbit.MIXIN_VERSIONING);
                     if 
(!ConstantsJackrabbit.ROOTPATH.equals(parentNode.getPath())) {
                         
newNode.setPrimaryType(parentNode.getPrimaryNodeType().getName());

Modified: 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrFileHelper.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrFileHelper.java?rev=1186761&r1=1186760&r2=1186761&view=diff
==============================================================================
--- 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrFileHelper.java
 (original)
+++ 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrFileHelper.java
 Thu Oct 20 12:30:11 2011
@@ -11,7 +11,9 @@ import org.apache.jackrabbit.ocm.excepti
 import org.apache.tika.Tika;
 import org.apache.tika.io.TikaInputStream;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit;
 import org.ofbiz.jcr.access.jackrabbit.RepositoryAccessJackrabbit;
 import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
@@ -102,6 +104,11 @@ public class JcrFileHelper extends Abstr
      * @throws RepositoryException
      */
     public void storeContentInRepository(byte[] fileData, String fileName, 
String folderPath) throws ObjectContentManagerException, RepositoryException {
+        if (UtilValidate.isEmpty(folderPath)) {
+            throw new ObjectContentManagerException("Please specify a folder 
path, the folder path should not be empty!");
+        } else if (ConstantsJackrabbit.ROOTPATH.equals(folderPath)){
+            throw new ObjectContentManagerException("Please specify a folder, 
a file content can't be stored directly under root.");
+        }
 
         // create an ORM Resource Object
         OfbizRepositoryMappingJackrabbitResource ormResource = new 
OfbizRepositoryMappingJackrabbitResource();

Modified: 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
URL: 
http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java?rev=1186761&r1=1186760&r2=1186761&view=diff
==============================================================================
--- 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
 (original)
+++ 
ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/util/jackrabbit/JcrUtilJackrabbit.java
 Thu Oct 20 12:30:11 2011
@@ -97,7 +97,9 @@ public class JcrUtilJackrabbit implement
      * @return
      */
     public static String createAbsoluteNodePath(String nodePath) {
-        if (!checkIfNodePathIsAbsolute(nodePath)) {
+        if (UtilValidate.isEmpty(nodePath)) {
+            nodePath = ConstantsJackrabbit.ROOTPATH;
+        } else if (!checkIfNodePathIsAbsolute(nodePath)) {
             nodePath = ConstantsJackrabbit.ROOTPATH + nodePath;
         }
 


Reply via email to