svn commit: r1186187 - in /ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr: access/jackrabbit/ api/ orm/jackrabbit/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1186187 - in /ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr: access/jackrabbit/ api/ orm/jackrabbit/

sascharodekamp
Author: sascharodekamp
Date: Wed Oct 19 13:06:33 2011
New Revision: 1186187

URL: http://svn.apache.org/viewvc?rev=1186187&view=rev
Log:
Refactoring Jackrabbit Constant class

Modified:
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ConstantsJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentReaderJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentWriterJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrArticleHelper.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitLocalizedContent.java

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ConstantsJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ConstantsJackrabbit.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ConstantsJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ConstantsJackrabbit.java Wed Oct 19 13:06:33 2011
@@ -5,22 +5,20 @@ import javax.jcr.nodetype.NodeType;
 import org.ofbiz.jcr.access.Constants;
 
 public class ConstantsJackrabbit implements Constants {
-    protected enum PROPERTY_FIELDS {
-        MESSAGE("jcr:message"), FILE(NodeType.NT_FILE), FOLDER(NodeType.NT_FOLDER), RESOURCE(NodeType.NT_RESOURCE), DATA("jcr:data"), UNSTRUCTURED(NodeType.NT_UNSTRUCTURED), MIMETYPE("jcr:mimeType"), REPROOT("rep:root"), mixInLANGUAGE("mix:language"), mixInVERSIONING(
-                "mix:versionable"), mixInTITLE("mix:title"), LANGUAGE("jcr:language"), TITLE("jcr:title"), DESCRIPTION("jcr:description");
-
-        String type = null;
-
-        PROPERTY_FIELDS(String type) {
-            this.type = type;
-        }
-
-        String getType() {
-            return this.type;
-        }
-
-    };
+    // JCR Variables
+    public static String MESSAGE = "jcr:message";
+    public static String FILE = NodeType.NT_FILE;
+    public static String FOLDER = NodeType.NT_FOLDER;
+    public static String RESOURCE = NodeType.NT_RESOURCE;
+    public static String DATA = "jcr:data";
+    public static String UNSTRUCTURED = NodeType.NT_UNSTRUCTURED;
+    public static String MIMETYPE = "jcr:mimeType";
+    public static String MIXIN_LANGUAGE = "mix:language";
+    public static String MIXIN_VERSIONING = "mix:versionable";
+    public static String ROOTVERSION = "jcr:rootVersion";
 
+    //
     public static String ROOTPATH = "/";
     public static String FILEROOT = ROOTPATH + "fileHome";
+    public static String NODEPATHDELIMITER = "/";
 }

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentReaderJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentReaderJackrabbit.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentReaderJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/ContentReaderJackrabbit.java Wed Oct 19 13:06:33 2011
@@ -101,7 +101,7 @@ public class ContentReaderJackrabbit imp
             JSONObject folder = new JSONObject();
             Node node = nodeIterator.nextNode();
 
-            if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.PROPERTY_FIELDS.FOLDER.getType())) {
+            if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.FOLDER)) {
                 attr.element("title", node.getName());
                 folder.element("data", attr);
 
@@ -113,7 +113,7 @@ public class ContentReaderJackrabbit imp
                 folder.element("children", getJsonFileChildNodes(node).toString());
 
                 folderStrucutre.element(folder);
-            } else if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.PROPERTY_FIELDS.FILE.getType())) {
+            } else if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.FILE)) {
                 attr = new JSONObject();
                 attr.element("title", node.getName());
                 folder.element("data", attr);
@@ -150,7 +150,7 @@ public class ContentReaderJackrabbit imp
             Node node = nodeIterator.nextNode();
 
             //
-            if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.PROPERTY_FIELDS.UNSTRUCTURED.getType()) && !node.hasProperty(ConstantsJackrabbit.PROPERTY_FIELDS.mixInLANGUAGE.getType())) {
+            if (node.getPrimaryNodeType().isNodeType(ConstantsJackrabbit.UNSTRUCTURED) && !node.hasProperty(ConstantsJackrabbit.MIXIN_LANGUAGE)) {
                 attr.element("title", node.getName());
                 folder.element("data", attr);
 

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=1186187&r1=1186186&r2=1186187&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 Wed Oct 19 13:06:33 2011
@@ -11,7 +11,6 @@ import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.jcr.access.ContentWriter;
 import org.ofbiz.jcr.access.VersioningManager;
-import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit.PROPERTY_FIELDS;
 import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
 
 public class ContentWriterJackrabbit implements ContentWriter {
@@ -59,7 +58,7 @@ public class ContentWriterJackrabbit imp
         // We have to check if the node structure (the sub nodes of the passed
         // ORM Object) exist, otherwise they will be created.
         String path = orm.getPath();
-        String[] nodeStructure = path.split("/");
+        String[] nodeStructure = path.split(ConstantsJackrabbit.NODEPATHDELIMITER);
         Node parentNode = null;
         try {
             parentNode = this.ocm.getSession().getRootNode();
@@ -82,7 +81,7 @@ public class ContentWriterJackrabbit imp
                 } else {
                     versioningManager.checkOutContentObject(parentNode.getPath());
                     Node newNode = parentNode.addNode(node);
-                    newNode.addMixin(PROPERTY_FIELDS.mixInVERSIONING.getType());
+                    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/access/jackrabbit/RepositoryAccessJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java Wed Oct 19 13:06:33 2011
@@ -113,8 +113,6 @@ public class RepositoryAccessJackrabbit
     public void storeContentObject(OfbizRepositoryMapping orm) throws ObjectContentManagerException, ItemExistsException {
         ContentWriter contentWriter = new ContentWriterJackrabbit(this.ocm);
         contentWriter.storeContentObject(orm);
-
-        return;
     }
 
     /*

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java Wed Oct 19 13:06:33 2011
@@ -25,6 +25,7 @@ public class VersioningManagerJackrabbit
     ObjectContentManager ocm = null;
 
     private Set<String> checkedOutNodeStore = Collections.synchronizedSet(new HashSet<String>());
+    private static String NOVERSION = "-0.0";
 
     VersioningManagerJackrabbit(ObjectContentManager ocm) {
         this.ocm = ocm;
@@ -53,7 +54,7 @@ public class VersioningManagerJackrabbit
             Version version = (Version) versionIterator.next();
             // filter the root version string, because it's not needed each node
             // starts with the version number 1.0
-            if (!"jcr:rootVersion".equals(version.getName())) {
+            if (!ConstantsJackrabbit.ROOTVERSION.equals(version.getName())) {
                 result.add(version.getName());
             }
         }
@@ -63,7 +64,10 @@ public class VersioningManagerJackrabbit
 
     /*
      * (non-Javadoc)
-     * @see org.ofbiz.jcr.access.VersioningManager#checkIfVersionExist(java.lang.String, java.lang.String)
+     *
+     * @see
+     * org.ofbiz.jcr.access.VersioningManager#checkIfVersionExist(java.lang.
+     * String, java.lang.String)
      */
     @Override
     public boolean checkIfVersionExist(String nodePath, String version) {
@@ -165,7 +169,7 @@ public class VersioningManagerJackrabbit
             return ocm.getBaseVersion(nodePath).getName();
         } catch (VersionException e) {
             Debug.logError(e, module);
-            return "0.0";
+            return NOVERSION;
         }
     }
 
@@ -180,7 +184,7 @@ public class VersioningManagerJackrabbit
             return ocm.getRootVersion(nodePath).getName();
         } catch (VersionException e) {
             Debug.logError(e, module);
-            return "0.0";
+            return NOVERSION;
         }
     }
 

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrArticleHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrArticleHelper.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrArticleHelper.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/api/JcrArticleHelper.java Wed Oct 19 13:06:33 2011
@@ -197,7 +197,7 @@ public class JcrArticleHelper extends Ab
                     // only use nodes which have the language mix in
                     if (tmpNode.hasProperty("localized") && tmpNode.getProperty("localized").getBoolean()) {
                         String l = tmpNode.getPath();
-                        languages.add(l.substring(l.lastIndexOf("/") + 1));
+                        languages.add(l.substring(l.lastIndexOf(ConstantsJackrabbit.NODEPATHDELIMITER) + 1));
                     }
                 }
 
@@ -237,23 +237,23 @@ public class JcrArticleHelper extends Ab
         // equal to the passed language
 
         // we split the path string in chunks
-        String[] path = contentPath.split("/");
+        String[] path = contentPath.split(ConstantsJackrabbit.NODEPATHDELIMITER);
 
         // chunk if the last chunk contains a language flag
-        StringBuffer canonicalizedContentPath = new StringBuffer("/");
+        StringBuffer canonicalizedContentPath = new StringBuffer(ConstantsJackrabbit.NODEPATHDELIMITER);
         if (possibleLocales.contains(path[path.length - 1])) {
             if (UtilValidate.isEmpty(language)) {
                 language = path[path.length - 1];
             }
             for (int i = 0; i < path.length - 1; i++) {
                 if (UtilValidate.isNotEmpty(path[i])) {
-                    canonicalizedContentPath.append(path[i]).append("/");
+                    canonicalizedContentPath.append(path[i]).append(ConstantsJackrabbit.NODEPATHDELIMITER);
                 }
             }
         } else {
             for (String p : path) {
                 if (UtilValidate.isNotEmpty(p)) {
-                    canonicalizedContentPath.append(p).append("/");
+                    canonicalizedContentPath.append(p).append(ConstantsJackrabbit.NODEPATHDELIMITER);
                 }
             }
         }

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitFile.java Wed Oct 19 13:06:33 2011
@@ -21,12 +21,12 @@ public class OfbizRepositoryMappingJackr
     public void setPath(String nodePath) {
         // check that the path don't end with a /
         if (nodePath.endsWith(ConstantsJackrabbit.ROOTPATH)) {
-            nodePath = nodePath.substring(0, nodePath.indexOf("/"));
+            nodePath = nodePath.substring(0, nodePath.indexOf(ConstantsJackrabbit.NODEPATHDELIMITER));
         }
 
         // check that it is a relative path
-        if (nodePath.indexOf("/") != -1) {
-            nodePath = nodePath.substring(nodePath.lastIndexOf("/") + 1);
+        if (nodePath.indexOf(ConstantsJackrabbit.NODEPATHDELIMITER) != -1) {
+            nodePath = nodePath.substring(nodePath.lastIndexOf(ConstantsJackrabbit.NODEPATHDELIMITER) + 1);
         }
 
         super.path = nodePath;

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitLocalizedContent.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitLocalizedContent.java?rev=1186187&r1=1186186&r2=1186187&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitLocalizedContent.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/jackrabbit/OfbizRepositoryMappingJackrabbitLocalizedContent.java Wed Oct 19 13:06:33 2011
@@ -4,6 +4,7 @@ import java.util.GregorianCalendar;
 
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.ofbiz.jcr.access.jackrabbit.ConstantsJackrabbit;
 
 @Node(isAbstract = true, extend = OfbizRepositoryMappingJackrabbitUnstructured.class)
 public abstract class OfbizRepositoryMappingJackrabbitLocalizedContent extends OfbizRepositoryMappingJackrabbitUnstructured {
@@ -44,10 +45,10 @@ public abstract class OfbizRepositoryMap
     private String createLanguagePath(String contentPath) {
         // the content path should contain the language information
         // TODO this have to be a little bit more intelligent in the future
-        if (contentPath.endsWith("/")) {
+        if (contentPath.endsWith(ConstantsJackrabbit.NODEPATHDELIMITER)) {
             contentPath = contentPath + language;
         } else {
-            contentPath = contentPath + "/" + language;
+            contentPath = contentPath + ConstantsJackrabbit.NODEPATHDELIMITER + language;
         }
 
         return contentPath;