You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by sa...@apache.org on 2011/09/28 16:13:05 UTC

svn commit: r1176889 - in /ofbiz/branches/jackrabbit20100709: ./ applications/content/src/org/ofbiz/content/jcr/ applications/content/src/org/ofbiz/content/jcr/helper/ framework/example/config/ framework/example/widget/example/ framework/jcr/src/org/of...

Author: sascharodekamp
Date: Wed Sep 28 14:13:05 2011
New Revision: 1176889

URL: http://svn.apache.org/viewvc?rev=1176889&view=rev
Log: (empty)

Added:
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java   (with props)
Modified:
    ofbiz/branches/jackrabbit20100709/.classpath
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/AbstractJcrHelper.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrArticleHelper.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelper.java
    ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml
    ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/RepositoryAccessJackrabbit.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/test/JcrTests.java

Modified: ofbiz/branches/jackrabbit20100709/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/.classpath?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/.classpath (original)
+++ ofbiz/branches/jackrabbit20100709/.classpath Wed Sep 28 14:13:05 2011
@@ -141,12 +141,12 @@
     <classpathentry kind="lib" path="framework/guiapp/lib/XuiCoreSwing-v3.2rc2b.jar"/>
     <classpathentry kind="lib" path="framework/guiapp/lib/XuiOptional-v3.2rc2b.jar"/>
     <classpathentry kind="lib" path="framework/jcr/lib/concurrent-1.3.4.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-api-2.2.7.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-core-2.2.7.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jca-2.2.7.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jcr-commons-2.2.7.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-2.2.7.jar"/>
-    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-commons-2.2.7.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-api-2.2.8.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-core-2.2.8.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jca-2.2.8.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jcr-commons-2.2.8.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-2.2.8.jar"/>
+    <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-commons-2.2.8.jar"/>
     <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-ocm-2.0.jar" sourcepath="/ocm"/>
     <classpathentry kind="lib" path="framework/jcr/lib/jcr-2.0.jar"/>
     <classpathentry kind="lib" path="framework/jcr/lib/pdfbox-1.3.1.jar"/>

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java Wed Sep 28 14:13:05 2011
@@ -24,16 +24,21 @@ import org.apache.jackrabbit.ocm.excepti
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.FileUtil;
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.content.jcr.helper.JcrArticleHelper;
+import org.ofbiz.content.jcr.helper.JcrContentHelper;
 import org.ofbiz.content.jcr.helper.JcrFileHelper;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.jcr.access.RepositoryAccess;
 import org.ofbiz.jcr.access.jackrabbit.RepositoryAccessJackrabbit;
+import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitArticle;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFolder;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitHierarchyNode;
 import org.ofbiz.jcr.util.jackrabbit.JcrUtilJackrabbit;
 
 public class JackrabbitEvents {
@@ -115,9 +120,13 @@ public class JackrabbitEvents {
         }
 
         JcrArticleHelper articleHelper = new JcrArticleHelper(userLogin);
-        OfbizRepositoryMappingJackrabbitArticle ormArticle = articleHelper.readContentFromRepository(contentPath, language);
+        OfbizRepositoryMappingJackrabbitArticle ormArticle = null;
+        if (UtilValidate.isEmpty(version)) {
+            ormArticle = articleHelper.readContentFromRepository(contentPath, language);
+        } else {
+            ormArticle = articleHelper.readContentFromRepository(contentPath, language, version);
+        }
 
-        request.setAttribute("contentObject", ormArticle);
         request.setAttribute("path", ormArticle.getPath());
         request.setAttribute("language", ormArticle.getLanguage());
         request.setAttribute("title", ormArticle.getTitle());
@@ -138,10 +147,10 @@ public class JackrabbitEvents {
     public static String updateRepositoryData(HttpServletRequest request, HttpServletResponse response) {
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
 
-        String path = request.getParameter("path");
+        String contentPath = request.getParameter("path");
+        JcrArticleHelper articleHelper = new JcrArticleHelper(userLogin);
 
-        RepositoryAccess repositoryAccess = new RepositoryAccessJackrabbit(userLogin);
-        OfbizRepositoryMappingJackrabbitArticle ormArticle = (OfbizRepositoryMappingJackrabbitArticle) repositoryAccess.getContentObject(path);
+        OfbizRepositoryMappingJackrabbitArticle ormArticle = articleHelper.readContentFromRepository(contentPath);
 
         // news.setLanguage(request.getParameter("language"));
         ormArticle.setTitle(request.getParameter("title"));
@@ -149,8 +158,17 @@ public class JackrabbitEvents {
         // request.getParameter("pubDate")
         // request.getParameter("createDate")
 
-        repositoryAccess.updateContentObject(ormArticle);
-        repositoryAccess.closeAccess();
+        try {
+            articleHelper.updateContentInRepository(ormArticle);
+        } catch (ObjectContentManagerException e) {
+            Debug.logError(e, module);
+            request.setAttribute("_ERROR_MESSAGE_", e.toString());
+        } catch (RepositoryException e) {
+            Debug.logError(e, module);
+            request.setAttribute("_ERROR_MESSAGE_", e.toString());
+        } finally {
+            articleHelper.closeContentSession();
+        }
 
         return "success";
     }
@@ -164,21 +182,10 @@ public class JackrabbitEvents {
     public static String removeRepositoryNode(HttpServletRequest request, HttpServletResponse response) {
         GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
 
-        String path = request.getParameter("path");
-
-        RepositoryAccess repositoryAccess = new RepositoryAccessJackrabbit(userLogin);
-        repositoryAccess.removeContentObject(path);
-        repositoryAccess.closeAccess();
-        return "success";
-    }
+        String contentPath = request.getParameter("path");
 
-    /**
-     *
-     * @param request
-     * @param response
-     * @return
-     */
-    public static String cleanJcrRepository(HttpServletRequest request, HttpServletResponse response) {
+        JcrContentHelper helper = new JcrContentHelper(userLogin);
+        helper.removeContentObject(contentPath);
 
         return "success";
     }
@@ -296,21 +303,48 @@ public class JackrabbitEvents {
         }
 
         JcrFileHelper fileHelper = new JcrFileHelper(userLogin);
-        OfbizRepositoryMappingJackrabbitFile file = fileHelper.getRepositoryContent(contentPath);
+        OfbizRepositoryMappingJackrabbitHierarchyNode orm = fileHelper.getRepositoryContent(contentPath);
 
-        InputStream fileStream = file.getResource().getData();
+        if (fileHelper.isFileContent()) {
+            OfbizRepositoryMappingJackrabbitFile file = (OfbizRepositoryMappingJackrabbitFile) orm;
+            InputStream fileStream = file.getResource().getData();
+
+            String fileName = file.getPath();
+            if (fileName.indexOf("/") != -1) {
+                fileName = fileName.substring(fileName.indexOf("/") + 1);
+            }
 
-        String fileName = file.getPath();
-        if (fileName.indexOf("/") != -1) {
-            fileName = fileName.substring(fileName.indexOf("/") + 1);
+            try {
+                UtilHttp.streamContentToBrowser(response, IOUtils.toByteArray(fileStream), file.getResource().getMimeType(), fileName);
+            } catch (IOException e) {
+                Debug.logError(e, module);
+                request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+                return "error";
+            }
+        } else {
+            Debug.logWarning("This content is no file content, the content is from the type: " + orm.getClass().getName(), module);
         }
+        return "success";
+    }
 
-        try {
-            UtilHttp.streamContentToBrowser(response, IOUtils.toByteArray(fileStream), file.getResource().getMimeType(), fileName);
-        } catch (IOException e) {
-            Debug.logError(e, module);
-            request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
-            return "error";
+    public static String getFileInformation(HttpServletRequest request, HttpServletResponse response) {
+        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
+        String contentPath = request.getParameter("path");
+
+        JcrFileHelper fileHelper = new JcrFileHelper(userLogin);
+        OfbizRepositoryMapping orm = fileHelper.getRepositoryContent(contentPath);
+
+        // Here we can differentiate between a file or folder content
+        if (fileHelper.isFileContent()) {
+            OfbizRepositoryMappingJackrabbitFile file = (OfbizRepositoryMappingJackrabbitFile) orm;
+            request.setAttribute("fileName", file.getPath());
+            request.setAttribute("fileLastModified", file.getResource().getLastModified().getTime());
+            request.setAttribute("fileMimeType", file.getResource().getMimeType());
+            request.setAttribute("fileCreationDate", file.getCreationDate().getTime());
+        } else if (fileHelper.isFolderContent()) {
+            OfbizRepositoryMappingJackrabbitFolder folder = (OfbizRepositoryMappingJackrabbitFolder) orm;
+            request.setAttribute("fileName", folder.getPath());
+            request.setAttribute("fileCreationDate", folder.getCreationDate().getTime());
         }
 
         return "success";

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/AbstractJcrHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/AbstractJcrHelper.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/AbstractJcrHelper.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/AbstractJcrHelper.java Wed Sep 28 14:13:05 2011
@@ -14,4 +14,13 @@ public abstract class AbstractJcrHelper 
         access.closeAccess();
         access = null;
     }
+
+    /**
+     * Remove the passed node from the content repository.
+     *
+     * @param contentPath
+     */
+    public void removeContentObject(String contentPath) {
+        access.removeContentObject(contentPath);
+    }
 }

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrArticleHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrArticleHelper.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrArticleHelper.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrArticleHelper.java Wed Sep 28 14:13:05 2011
@@ -66,7 +66,7 @@ public class JcrArticleHelper extends Ab
      * @return content article object
      * @throws
      */
-    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath) throws ClassCastException{
+    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath) throws ClassCastException {
         OfbizRepositoryMapping orm = access.getContentObject(contentPath);
 
         if (orm instanceof OfbizRepositoryMappingJackrabbitArticle) {
@@ -88,7 +88,7 @@ public class JcrArticleHelper extends Ab
      * @return content article object
      * @throws
      */
-    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath, String language) throws ClassCastException{
+    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath, String language) throws ClassCastException {
         contentPath = determineContentLanguagePath(contentPath, language);
         return readContentFromRepository(contentPath);
     }
@@ -105,13 +105,14 @@ public class JcrArticleHelper extends Ab
      * @return
      * @throws
      */
-    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath, String language, String version) throws ClassCastException{
+    public OfbizRepositoryMappingJackrabbitArticle readContentFromRepository(String contentPath, String language, String version) throws ClassCastException {
         contentPath = determineContentLanguagePath(contentPath, language);
         OfbizRepositoryMapping orm = access.getContentObject(contentPath, version);
 
         if (orm instanceof OfbizRepositoryMappingJackrabbitArticle) {
             article = (OfbizRepositoryMappingJackrabbitArticle) orm;
             article.setVersion(version);
+            article.setPath(contentPath); // the content path must be manipulated because, the jackrabbit orm returns a full blown path with version information.
             return article;
         } else {
             throw new ClassCastException("The content object for the path: " + contentPath + " is not an article content object. This Helper can only handle content objects with the type: " + OfbizRepositoryMappingJackrabbitArticle.class.getName());
@@ -125,11 +126,11 @@ public class JcrArticleHelper extends Ab
      * @param language
      * @param title
      * @param content
-     * @param pubDate
+     * @param publicationDate
      * @throws ObjectContentManagerException
      * @throws ItemExistsException
      */
-    public void storeContentInRepository(String contentPath, String language, String title, String content, Calendar pubDate) throws ObjectContentManagerException, ItemExistsException {
+    public void storeContentInRepository(String contentPath, String language, String title, String content, Calendar publicationDate) throws ObjectContentManagerException, ItemExistsException {
         if (UtilValidate.isEmpty(language)) {
             language = determindeTheDefaultLanguage();
         }
@@ -145,13 +146,31 @@ public class JcrArticleHelper extends Ab
         }
 
         // construct the content article object
-        article = new OfbizRepositoryMappingJackrabbitArticle(contentPath, language, title, content, pubDate);
+        article = new OfbizRepositoryMappingJackrabbitArticle(contentPath, language, title, content, publicationDate);
 
         access.storeContentObject(article);
 
     }
 
     /**
+     * Update an existing content article object in the repository.
+     *
+     * @param updatedArticle
+     * @throws RepositoryException
+     * @throws ObjectContentManagerException
+     */
+    public void updateContentInRepository(OfbizRepositoryMappingJackrabbitArticle updatedArticle) throws RepositoryException, ObjectContentManagerException {
+        // if the item not already exist create it.
+        if (!access.getSession().itemExists(updatedArticle.getPath())) {
+            Debug.logWarning("This content object with the path: " + updatedArticle.getPath() + " doesn't exist in the repository. It will now created.", module);
+            this.storeContentInRepository(updatedArticle.getPath(), updatedArticle.getLanguage(), updatedArticle.getTitle(), updatedArticle.getContent(), updatedArticle.getPubDate());
+            return;
+        }
+
+        access.updateContentObject(updatedArticle);
+    }
+
+    /**
      * Returns a list of versions which are available for the current article.
      * If no article is loaded before, the list will be empty.
      *

Added: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java?rev=1176889&view=auto
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java (added)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java Wed Sep 28 14:13:05 2011
@@ -0,0 +1,28 @@
+package org.ofbiz.content.jcr.helper;
+
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.jcr.access.jackrabbit.RepositoryAccessJackrabbit;
+
+/**
+ * This Helper class encapsulate the jcr content access. It provide all
+ * attributes and operations which are necessary to work with the content
+ * repository.
+ *
+ * The concrete implementations covers the different content use case related
+ * workflows. I.E. Different behavior for File/Folder or Text content.
+ *
+ * The Helper classes should be build on top of the generic JCR implementation
+ * in the Framework.
+ *
+ */
+public class JcrContentHelper extends AbstractJcrHelper{
+
+    /**
+     * Create a default content helper object.
+     *
+     * @param userLogin
+     */
+    public JcrContentHelper (GenericValue userLogin) {
+        access = new RepositoryAccessJackrabbit(userLogin);
+    }
+}

Propchange: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrContentHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelper.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelper.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelper.java Wed Sep 28 14:13:05 2011
@@ -16,6 +16,7 @@ import org.ofbiz.jcr.access.jackrabbit.R
 import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFolder;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitHierarchyNode;
 import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitResource;
 
 /**
@@ -34,6 +35,8 @@ public class JcrFileHelper extends Abstr
 
     private final static String module = JcrFileHelper.class.getName();
 
+    private OfbizRepositoryMappingJackrabbitHierarchyNode hierarchy = null;
+
     public JcrFileHelper(GenericValue userLogin) {
         access = new RepositoryAccessJackrabbit(userLogin);
     }
@@ -46,11 +49,16 @@ public class JcrFileHelper extends Abstr
      * @return
      * @throws
      */
-    public OfbizRepositoryMappingJackrabbitFile getRepositoryContent(String contentPath) throws ClassCastException {
+    public OfbizRepositoryMappingJackrabbitHierarchyNode getRepositoryContent(String contentPath) throws ClassCastException {
         OfbizRepositoryMapping orm = access.getContentObject(contentPath);
 
         if (orm instanceof OfbizRepositoryMappingJackrabbitFile) {
             OfbizRepositoryMappingJackrabbitFile fileObj = (OfbizRepositoryMappingJackrabbitFile) orm;
+            hierarchy = fileObj;
+            return fileObj;
+        } else if (orm instanceof OfbizRepositoryMappingJackrabbitFolder) {
+            OfbizRepositoryMappingJackrabbitFolder fileObj = (OfbizRepositoryMappingJackrabbitFolder) orm;
+            hierarchy = fileObj;
             return fileObj;
         }
 
@@ -66,11 +74,16 @@ public class JcrFileHelper extends Abstr
      * @return
      * @throws
      */
-    public OfbizRepositoryMappingJackrabbitFile getRepositoryContent(String contentPath, String version) throws ClassCastException {
+    public OfbizRepositoryMappingJackrabbitHierarchyNode getRepositoryContent(String contentPath, String version) throws ClassCastException {
         OfbizRepositoryMapping orm = access.getContentObject(contentPath, version);
 
         if (orm instanceof OfbizRepositoryMappingJackrabbitFile) {
             OfbizRepositoryMappingJackrabbitFile fileObj = (OfbizRepositoryMappingJackrabbitFile) orm;
+            hierarchy = fileObj;
+            return fileObj;
+        } else if (orm instanceof OfbizRepositoryMappingJackrabbitFolder) {
+            OfbizRepositoryMappingJackrabbitFile fileObj = (OfbizRepositoryMappingJackrabbitFile) orm;
+            hierarchy = fileObj;
             return fileObj;
         }
 
@@ -109,6 +122,22 @@ public class JcrFileHelper extends Abstr
         access.storeContentObject(ormFolder);
     }
 
+    /**
+     * Returns TRUE if the current content is a file content (Type: OfbizRepositoryMappingJackrabbitFile)
+     * @return
+     */
+    public boolean isFileContent() {
+        return (hierarchy instanceof OfbizRepositoryMappingJackrabbitFile);
+    }
+
+    /**
+     * Returns TRUE if the current content is a folder content (Type: OfbizRepositoryMappingJackrabbitFolder)
+     * @return
+     */
+    public boolean isFolderContent() {
+        return (hierarchy instanceof OfbizRepositoryMappingJackrabbitFolder);
+    }
+
     private static String getMimeTypeFromInputStream(InputStream is) {
         if (!TikaInputStream.isTikaInputStream(is)) {
             is = TikaInputStream.get(is);

Modified: ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml (original)
+++ ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml Wed Sep 28 14:13:05 2011
@@ -858,8 +858,8 @@
         <value xml:lang="en">Version of the base content node</value>
     </property>
     <property key="ExampelsJackrabbitOpenFile">
-        <value xml:lang="de">Datei Informationen öffnen</value>
-        <value xml:lang="en">Open file information</value>
+        <value xml:lang="de">Informationen öffnen</value>
+        <value xml:lang="en">Open information</value>
     </property>
 
 </resource>

Modified: ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml (original)
+++ ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml Wed Sep 28 14:13:05 2011
@@ -131,13 +131,13 @@ under the License.
         <field name="fileName">
             <display />
         </field>
-        <field name="fileLanguage">
+        <field name="fileMimeType" use-when="parameters.get(&quot;fileMimeType&quot;)!=null">
             <display />
         </field>
-        <field name="fileMimeType">
+        <field name="fileLastModified" use-when="parameters.get(&quot;fileLastModified&quot;)!=null">
             <display />
         </field>
-        <field name="fileDescription">
+        <field name="fileCreationDate">
             <display />
         </field>
     </form>

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=1176889&r1=1176888&r2=1176889&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 Sep 28 14:13:05 2011
@@ -1,6 +1,5 @@
 package org.ofbiz.jcr.access.jackrabbit;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.jcr.ItemExistsException;
@@ -11,8 +10,6 @@ import net.sf.json.JSONArray;
 
 import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
 import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
-import org.apache.jackrabbit.ocm.mapper.Mapper;
-import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.jcr.access.ContentReader;
@@ -20,15 +17,8 @@ import org.ofbiz.jcr.access.ContentWrite
 import org.ofbiz.jcr.access.RepositoryAccess;
 import org.ofbiz.jcr.access.VersioningManager;
 import org.ofbiz.jcr.loader.JCRFactoryUtil;
+import org.ofbiz.jcr.loader.jackrabbit.JCRFactoryImpl;
 import org.ofbiz.jcr.orm.OfbizRepositoryMapping;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitArticle;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitLocalizedContent;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFolder;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitHierarchyNode;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitNews;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitResource;
-import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitUnstructured;
 
 public class RepositoryAccessJackrabbit implements RepositoryAccess {
 
@@ -60,20 +50,7 @@ public class RepositoryAccessJackrabbit 
 
         this.session = session;
 
-        List<Class> classes = new ArrayList<Class>();
-        // put this in an xml configuration file
-        // should the ocm classes be loaded in during the container startup?
-        classes.add(OfbizRepositoryMappingJackrabbitUnstructured.class);
-        classes.add(OfbizRepositoryMappingJackrabbitHierarchyNode.class);
-        classes.add(OfbizRepositoryMappingJackrabbitNews.class);
-        classes.add(OfbizRepositoryMappingJackrabbitFile.class);
-        classes.add(OfbizRepositoryMappingJackrabbitFolder.class);
-        classes.add(OfbizRepositoryMappingJackrabbitResource.class);
-        classes.add(OfbizRepositoryMappingJackrabbitLocalizedContent.class);
-        classes.add(OfbizRepositoryMappingJackrabbitArticle.class);
-
-        Mapper mapper = new AnnotationMapperImpl(classes);
-        this.ocm = new ObjectContentManagerImpl(session, mapper);
+        this.ocm = new ObjectContentManagerImpl(session, JCRFactoryImpl.getMapper());
 
         return;
     }

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/loader/jackrabbit/JCRFactoryImpl.java Wed Sep 28 14:13:05 2011
@@ -22,6 +22,8 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.jcr.Credentials;
 import javax.jcr.Repository;
@@ -37,12 +39,22 @@ import org.apache.jackrabbit.core.nodety
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
 import org.apache.jackrabbit.ocm.nodemanagement.impl.RepositoryUtil;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.jcr.loader.JCRFactory;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitArticle;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFile;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitFolder;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitHierarchyNode;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitLocalizedContent;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitNews;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitResource;
+import org.ofbiz.jcr.orm.jackrabbit.OfbizRepositoryMappingJackrabbitUnstructured;
 import org.w3c.dom.Element;
 
 public class JCRFactoryImpl implements JCRFactory {
@@ -58,6 +70,7 @@ public class JCRFactoryImpl implements J
 
     protected static Repository repository = null;
     protected Session session = null;
+    protected static Mapper mapper = null;
 
     /*
      * (non-Javadoc)
@@ -85,6 +98,20 @@ public class JCRFactoryImpl implements J
         // closed
         repository = new TransientRepository(jackrabbitConfigFile, homeDir);
         createSession();
+
+        List<Class> classes = new ArrayList<Class>();
+        // put this in an xml configuration file
+        // should the ocm classes be loaded in during the container startup?
+        classes.add(OfbizRepositoryMappingJackrabbitUnstructured.class);
+        classes.add(OfbizRepositoryMappingJackrabbitHierarchyNode.class);
+        classes.add(OfbizRepositoryMappingJackrabbitNews.class);
+        classes.add(OfbizRepositoryMappingJackrabbitFile.class);
+        classes.add(OfbizRepositoryMappingJackrabbitFolder.class);
+        classes.add(OfbizRepositoryMappingJackrabbitResource.class);
+        classes.add(OfbizRepositoryMappingJackrabbitLocalizedContent.class);
+        classes.add(OfbizRepositoryMappingJackrabbitArticle.class);
+
+        mapper = new AnnotationMapperImpl(classes);
     }
 
     /*
@@ -157,6 +184,10 @@ public class JCRFactoryImpl implements J
         return repository;
     }
 
+    public static Mapper getMapper() {
+        return mapper;
+    }
+
     /*
      * Register some new node types
      */

Modified: ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/test/JcrTests.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/test/JcrTests.java?rev=1176889&r1=1176888&r2=1176889&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/test/JcrTests.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/test/JcrTests.java Wed Sep 28 14:13:05 2011
@@ -68,7 +68,7 @@ public class JcrTests extends OFBizTestC
     }
 
     public void testReadRepositoryNewsNode() throws Exception {
-        OfbizRepositoryMappingJackrabbitNews orm = (OfbizRepositoryMappingJackrabbitNews) repositoryAccess.getContentObject("/news/today/en");
+        OfbizRepositoryMappingJackrabbitNews orm = (OfbizRepositoryMappingJackrabbitNews) repositoryAccess.getContentObject("/news/today");
         assertNotNull(orm);
 
         assertEquals(orm.getContent(), "Hello World");
@@ -82,6 +82,17 @@ public class JcrTests extends OFBizTestC
         repositoryAccess.updateContentObject(orm);
     }
 
+    public void testVersionning() throws Exception {
+        assertEquals("1.1", repositoryAccess.getBaseVersion("/news/today"));
+
+        OfbizRepositoryMappingJackrabbitNews orm = (OfbizRepositoryMappingJackrabbitNews) repositoryAccess.getContentObject("/news/today");
+        orm.setContent("May the force be with you!");
+        repositoryAccess.updateContentObject(orm);
+
+        orm = (OfbizRepositoryMappingJackrabbitNews) repositoryAccess.getContentObject("/news/today");
+        assertEquals("1.2", repositoryAccess.getBaseVersion("/news/today"));
+    }
+
     public void testRemoveRepositoryNewsNode() throws Exception {
         repositoryAccess.removeContentObject("/news/today");
     }