svn commit: r1099770 [1/2] - in /ofbiz/branches/jackrabbit20100709: applications/content/src/org/ofbiz/content/jcr/ applications/content/src/org/ofbiz/content/jcr/helper/ applications/content/src/org/ofbiz/content/jcr/orm/ applications/content/src/org/...

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

svn commit: r1099770 [1/2] - in /ofbiz/branches/jackrabbit20100709: applications/content/src/org/ofbiz/content/jcr/ applications/content/src/org/ofbiz/content/jcr/helper/ applications/content/src/org/ofbiz/content/jcr/orm/ applications/content/src/org/...

sascharodekamp
Author: sascharodekamp
Date: Thu May  5 12:32:13 2011
New Revision: 1099770

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

Added:
    ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy
    ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl
Modified:
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/JackrabbitEvents.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelperJackrabbit.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrTextHelperJackrabbit.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/orm/OfbizRepositoryMappingJackrabbit.java
    ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/test/JcrTests.java
    ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml
    ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/controller.xml
    ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitForms.xml
    ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleJackrabbitScreens.xml
    ofbiz/branches/jackrabbit20100709/framework/example/widget/example/ExampleMenus.xml
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/helper/JcrFileHelper.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/helper/JcrHelperAbstract.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/helper/JcrTextHelper.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/helper/JcrTextHelperAbstract.java
    ofbiz/branches/jackrabbit20100709/framework/jcr/src/org/ofbiz/jcr/orm/OfbizRepositoryMapping.java

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=1099770&r1=1099769&r2=1099770&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 Thu May  5 12:32:13 2011
@@ -2,6 +2,8 @@ package org.ofbiz.content.jcr;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -23,6 +25,7 @@ import org.ofbiz.base.util.FileUtil;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.content.jcr.helper.JcrFileHelperJackrabbit;
 import org.ofbiz.content.jcr.helper.JcrTextHelperJackrabbit;
 import org.ofbiz.entity.Delegator;
@@ -43,12 +46,13 @@ public class JackrabbitEvents {
  */
  public static String addNewTextMessageToJcrRepository(HttpServletRequest request, HttpServletResponse response) {
  String message = request.getParameter("message");
+ String language = request.getParameter("msgLocale");
 
  JcrTextHelper jackrabbit = new JcrTextHelperJackrabbit(request);
 
  String newContentId = null;
  try {
- newContentId = jackrabbit.storeNewTextData(message);
+ newContentId = jackrabbit.storeNewTextData(message, language);
 
  if (newContentId == null) {
  request.setAttribute("_ERROR_MESSAGE_", "Couldn't be created, maybe the node already exists. Use another node name to store you're content.");
@@ -66,6 +70,10 @@ public class JackrabbitEvents {
  Debug.logError(e, module);
  request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
  return "error";
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+ return "error";
  } finally {
  jackrabbit.closeSession();
  }
@@ -101,10 +109,27 @@ public class JackrabbitEvents {
  */
  public static String getNodeContent(HttpServletRequest request, HttpServletResponse response) {
  JcrTextHelper jackrabbit = new JcrTextHelperJackrabbit(request);
+ String language = UtilValidate.isNotEmpty(request.getParameter("language")) ? request.getParameter("language") : (String) request.getAttribute("language");
 
  try {
- String textContent = jackrabbit.getTextData();
+ String textContent = null;
+ if (UtilValidate.isEmpty(language)) {
+ textContent = jackrabbit.getTextData();
+ } else {
+ textContent = jackrabbit.getTextData(language);
+ }
  request.setAttribute("message", textContent);
+ List<String> availableLanguages = jackrabbit.getAvailableLanguages();
+ List<Map<String, String>> langMap = new ArrayList<Map<String, String>>();
+ for (String lang : availableLanguages) {
+ Map<String, String> tmp = new HashMap<String, String>();
+ tmp.put("localeId", lang);
+ langMap.add(tmp);
+ }
+
+ request.setAttribute("languageList", langMap);
+ request.setAttribute("selectedLanguage", jackrabbit.getSelctedLanguage());
+
  } catch (PathNotFoundException e) {
  Debug.logError(e, module);
  request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
@@ -128,11 +153,18 @@ public class JackrabbitEvents {
  */
  public static String updateRepositoryData(HttpServletRequest request, HttpServletResponse response) {
  String message = request.getParameter("message");
+ String language = request.getParameter("selectedLanguage");
 
  JcrTextHelper jackrabbit = new JcrTextHelperJackrabbit(request);
 
  try {
- String textContent = jackrabbit.updateTextData(message);
+ String textContent = null;
+ if (UtilValidate.isEmpty(language)) {
+ textContent = jackrabbit.updateTextData(message);
+ } else {
+ textContent = jackrabbit.updateTextData(message, language);
+ request.setAttribute("language", language);
+ }
  request.setAttribute("message", textContent);
  } catch (PathNotFoundException e) {
  Debug.logError(e, module);
@@ -142,6 +174,10 @@ public class JackrabbitEvents {
  Debug.logError(e, module);
  request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
  return "error";
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
+ return "error";
  } finally {
  jackrabbit.closeSession();
  }
@@ -288,6 +324,12 @@ public class JackrabbitEvents {
  return "success";
  }
 
+ /**
+ * Creates the FILE Tree as JSON Object
+ * @param request
+ * @param response
+ * @return
+ */
  public static String getRepositoryFileTree(HttpServletRequest request, HttpServletResponse response) {
  GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
  Delegator delegator = (Delegator) request.getAttribute("delegator");
@@ -308,6 +350,32 @@ public class JackrabbitEvents {
  return "success";
  }
 
+ /**
+ * Creates the DATA (TEXT) Tree as JSON Object
+ * @param request
+ * @param response
+ * @return
+ */
+ public static String getRepositoryDataTree(HttpServletRequest request, HttpServletResponse response) {
+ GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+
+ JcrTextHelper jackrabbit = new JcrTextHelperJackrabbit(userLogin, delegator, null, "/");
+
+ try {
+ JSONArray fileTree = jackrabbit.getJsonDataTree();
+ request.setAttribute("dataTree", StringUtil.wrapString(fileTree.toString()));
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ request.setAttribute("_ERROR_MESSAGE_", e.toString());
+ return "error";
+ } finally {
+ jackrabbit.closeSession();
+ }
+
+ return "success";
+ }
+
  public static String getFileFromRepository(HttpServletRequest request, HttpServletResponse response) {
 
  JcrFileHelper jackrabbit = new JcrFileHelperJackrabbit(request);

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelperJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelperJackrabbit.java?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelperJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrFileHelperJackrabbit.java Thu May  5 12:32:13 2011
@@ -64,7 +64,7 @@ public class JcrFileHelperJackrabbit ext
  repositoryNode = addRepositoryFileHomeNode(repositoryNode);
 
  try {
- super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode);
+ super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode, OfbizRepositoryMappingJackrabbit.NODE_TYPE.FILE);
  } catch (GenericEntityException e) {
  Debug.logError(e, module);
  return;
@@ -115,7 +115,7 @@ public class JcrFileHelperJackrabbit ext
 
  Delegator delegator = (Delegator) request.getAttribute("delegator");
  try {
- super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode);
+ super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode, OfbizRepositoryMappingJackrabbit.NODE_TYPE.FILE);
  } catch (GenericEntityException e) {
  Debug.logError(e, module);
  return;
@@ -191,7 +191,7 @@ public class JcrFileHelperJackrabbit ext
  /*
  * (non-Javadoc)
  *
- * @see org.ofbiz.jcr.helper.JcrFileHelper#getJsonFileTree(java.lang.String)
+ * @see org.ofbiz.jcr.helper.JcrFileHelper#getJsonFileTree()
  */
  @Override
  public JSONArray getJsonFileTree() throws RepositoryException {

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrTextHelperJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrTextHelperJackrabbit.java?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrTextHelperJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/helper/JcrTextHelperJackrabbit.java Thu May  5 12:32:13 2011
@@ -1,10 +1,14 @@
 package org.ofbiz.content.jcr.helper;
 
+import java.util.List;
+
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.servlet.http.HttpServletRequest;
 
+import net.sf.json.JSONArray;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.content.jcr.orm.OfbizRepositoryMappingJackrabbit;
 import org.ofbiz.entity.Delegator;
@@ -16,105 +20,163 @@ import org.ofbiz.jcr.helper.JcrTextHelpe
 
 public class JcrTextHelperJackrabbit extends JcrTextHelperAbstract implements JcrTextHelper {
 
-    public JcrTextHelperJackrabbit(GenericValue userLogin, Delegator delegator, String contentId, String repositoryNode) {
-        super.userLogin = userLogin;
-        if (userLogin == null || delegator == null) {
-            Debug.logError("You pass null for the UserLogin or Delegator, Object can't be created.", module);
-            return;
-        }
-
-        Session session = null;
-        try {
-            session = JackrabbitContainer.getUserSession(userLogin);
-        }
-        catch (RepositoryException re) {
-            Debug.logError(re, module);
-            return;
-        }
-
-        try {
-            super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode);
-        }
-        catch (GenericEntityException e) {
-            Debug.logError(e, module);
-            return;
-        }
-        catch (RepositoryException e) {
-            Debug.logError(e, module);
-            return;
-        }
-    }
-
-    public JcrTextHelperJackrabbit(HttpServletRequest request) {
-        GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
-        super.userLogin = userLogin;
-
-        Session session = null;
-        try {
-            session = JackrabbitContainer.getUserSession(userLogin);
-        }
-        catch (RepositoryException re) {
-            Debug.logError(re, module);
-            return;
-        }
-
-        String contentId = request.getParameter("contentId");
-        String repositoryNode = request.getParameter("repositoryNode");
-
-        Delegator delegator = (Delegator) request.getAttribute("delegator");
-        try {
-            super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode);
-        }
-        catch (GenericEntityException e) {
-            Debug.logError(e, module);
-            return;
-        }
-        catch (RepositoryException e) {
-            Debug.logError(e, module);
-            return;
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.ofbiz.jcr.helper.JcrTextHelper#storeNewTextData(java.lang.String)
-     */
-    @Override
-    public String storeNewTextData(String message) throws RepositoryException {
-        orm.updateOrStoreTextData(message);
-
-        return orm.getContentId();
-    }
-
-    /* (non-Javadoc)
-     * @see org.ofbiz.jcr.helper.JcrTextHelper#getStringContent()
-     */
-    @Override
-    public String getTextData() throws PathNotFoundException, RepositoryException {
-        return orm.getStringContent();
-    }
-
-    /* (non-Javadoc)
-     * @see org.ofbiz.jcr.helper.JcrTextHelper#updateTextData(java.lang.String)
-     */
-    @Override
-    public String updateTextData(String message) throws PathNotFoundException, RepositoryException {
-        orm.updateOrStoreTextData(message);
-
-        return message;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.ofbiz.jcr.helper.JcrTextHelper#addNewNode(java.lang.String)
-     */
-    @Override
-    public JcrTextHelper addNewNode(String newNode) throws RepositoryException, GenericEntityException {
-        if (!newNode.startsWith("/")) {
-            newNode = "/" + newNode;
-        }
-
-        String newAbsoluteNodePath = orm.getNodePath() + newNode;
+ public JcrTextHelperJackrabbit(GenericValue userLogin, Delegator delegator, String contentId, String repositoryNode) {
+ super.userLogin = userLogin;
+ if (userLogin == null || delegator == null) {
+ Debug.logError("You pass null for the UserLogin or Delegator, Object can't be created.", module);
+ return;
+ }
+
+ Session session = null;
+ try {
+ session = JackrabbitContainer.getUserSession(userLogin);
+ } catch (RepositoryException re) {
+ Debug.logError(re, module);
+ return;
+ }
+
+ try {
+ super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode, OfbizRepositoryMappingJackrabbit.NODE_TYPE.DATA);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ return;
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ return;
+ }
+ }
+
+ public JcrTextHelperJackrabbit(HttpServletRequest request) {
+ GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
+ super.userLogin = userLogin;
+
+ Session session = null;
+ try {
+ session = JackrabbitContainer.getUserSession(userLogin);
+ } catch (RepositoryException re) {
+ Debug.logError(re, module);
+ return;
+ }
+
+ String contentId = request.getParameter("contentId");
+ String repositoryNode = request.getParameter("repositoryNode");
+
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+ try {
+ super.orm = new OfbizRepositoryMappingJackrabbit(delegator, session, contentId, repositoryNode, OfbizRepositoryMappingJackrabbit.NODE_TYPE.DATA);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ return;
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ return;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.helper.JcrTextHelper#storeNewTextData(java.lang.String)
+ */
+ @Override
+ public String storeNewTextData(String message) throws RepositoryException, GenericEntityException {
+ return storeNewTextData(message, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.helper.JcrTextHelper#storeNewTextData(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public String storeNewTextData(String message, String language) throws RepositoryException, GenericEntityException {
+ orm.updateOrStoreTextData(message, language);
+
+ return orm.getContentId();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrTextHelper#getStringContent()
+ */
+ @Override
+ public String getTextData() throws PathNotFoundException, RepositoryException {
+ return orm.getStringContent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.helper.JcrTextHelper#getStringContent(java.lang.String)
+ */
+ @Override
+ public String getTextData(String language) throws PathNotFoundException, RepositoryException {
+ return orm.getStringContent(language);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrTextHelper#updateTextData(java.lang.String)
+ */
+ @Override
+ public String updateTextData(String message) throws RepositoryException, GenericEntityException {
+ orm.updateOrStoreTextData(message);
+
+ return message;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrTextHelper#updateTextData(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public String updateTextData(String message, String language) throws RepositoryException, GenericEntityException {
+ orm.updateOrStoreTextData(message, language);
+ return message;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrDataHelper#getJsonDataTree()
+ */
+ @Override
+ public JSONArray getJsonDataTree() throws RepositoryException {
+ return orm.getJsonDataTree();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrTextHelper#addNewNode(java.lang.String)
+ */
+ @Override
+ public JcrTextHelper addNewNode(String newNode) throws RepositoryException, GenericEntityException {
+ if (!newNode.startsWith("/")) {
+ newNode = "/" + newNode;
+ }
+
+ String newAbsoluteNodePath = orm.getNodePath() + newNode;
+
+ return new JcrTextHelperJackrabbit(userLogin, orm.getDelegator(), null, newAbsoluteNodePath);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.helper.JcrTextHelper#getAvailableLanguages();
+ */
+ @Override
+ public List<String> getAvailableLanguages() throws PathNotFoundException, RepositoryException {
+ return orm.getAvailableLanguages();
+ }
 
-        return new JcrTextHelperJackrabbit(userLogin, orm.getDelegator(), null, newAbsoluteNodePath);
-    }
 }

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/orm/OfbizRepositoryMappingJackrabbit.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/orm/OfbizRepositoryMappingJackrabbit.java?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/orm/OfbizRepositoryMappingJackrabbit.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/jcr/orm/OfbizRepositoryMappingJackrabbit.java Thu May  5 12:32:13 2011
@@ -14,15 +14,17 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 import org.apache.tika.Tika;
+import org.apache.tika.io.TikaInputStream;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -32,46 +34,52 @@ import org.ofbiz.jcr.orm.OfbizRepository
 
 public class OfbizRepositoryMappingJackrabbit implements OfbizRepositoryMapping {
 
-    private static String module = OfbizRepositoryMappingJackrabbit.class.getName();
+ private static String module = OfbizRepositoryMappingJackrabbit.class.getName();
 
-    private 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");
+ private 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"), LANGUAGE("mix:language");
 
-        String type = null;
+ String type = null;
 
-        PROPERTY_FIELDS(String type) {
-            this.type = type;
-        }
-
-        String getType() {
-            return this.type;
-        }
-
-    };
-
-    private Delegator delegator = null;
-    private GenericValue content = null;
-    // private GenericValue contentAssoc = null;
-    private Session session = null;
-    private Node node = null;
-
-    /**
-     * The OfbizContentMapping constructor loads the node and related content
-     * data from the DB. You can pass a contentId *OR* a node path. Primary the
-     * constructor will take a contentId, get the content information from the
-     * database and read the related repository node from the database. If you
-     * pass a repository node path, the method will look in the database for a
-     * related content entry.
-     *
-     * @param delegator
-     * @param session
-     * @param contentId
-     * @param repositoryNode
-     * @throws RepositoryException
-     * @throws GenericEntityException
-     */
-    public OfbizRepositoryMappingJackrabbit(Delegator delegator, Session session, String contentId, String repositoryNode) throws RepositoryException,
+ PROPERTY_FIELDS(String type) {
+ this.type = type;
+ }
+
+ String getType() {
+ return this.type;
+ }
+
+ };
+
+ public enum NODE_TYPE {
+ FILE, DATA;
+ };
+
+ private Delegator delegator = null;
+ private GenericValue content = null;
+ // private GenericValue contentAssoc = null;
+ private Session session = null;
+ private Node node = null;
+ private String selectedLanguage = UtilProperties.getPropertyValue("general", "locale.properties.fallback");
+
+ /**
+ * The OfbizContentMapping constructor loads the node and related content
+ * data from the DB. You can pass a contentId *OR* a node path. Primary the
+ * constructor will take a contentId, get the content information from the
+ * database and read the related repository node from the database. If you
+ * pass a repository node path, the method will look in the database for a
+ * related content entry.
+ *
+ * @param delegator
+ * @param session
+ * @param contentId
+ * @param repositoryNode
+ * @param type
+ *            indicates if a file or data content should be added
+ * @throws RepositoryException
+ * @throws GenericEntityException
+ */
+ public OfbizRepositoryMappingJackrabbit(Delegator delegator, Session session, String contentId, String repositoryNode, NODE_TYPE type) throws RepositoryException,
             GenericEntityException {
         if (session == null) {
             Debug.logWarning("A repository session is needed to create an OfbizContentMapping Object.", module);
@@ -84,7 +92,7 @@ public class OfbizRepositoryMappingJackr
         this.delegator = delegator;
         this.session = session;
 
-        // check if the node path is an abolute path
+        // check if the node path is an absolute path
         if (!repositoryNode.startsWith("/")) {
             repositoryNode = "/" + repositoryNode;
         }
@@ -103,7 +111,15 @@ public class OfbizRepositoryMappingJackr
                 this.content = EntityUtil.getFirst(contentList);
                 this.node = getRepositoryNode(repositoryNode);
             } else {
-                Map<String, Object> newRepositoryEntry = createNewRepositoryNode(repositoryNode);
+                // decide if we create a file content or a data content and set the primary node type
+             String primType = null;
+             if (type == NODE_TYPE.FILE) {
+             primType = PROPERTY_FIELDS.FOLDER.getType();
+             } else {
+             primType = PROPERTY_FIELDS.UNSTRUCTURED.getType();
+             }
+
+             Map<String, Object> newRepositoryEntry = createNewRepositoryNode(repositoryNode, primType);
                 this.node = (Node) newRepositoryEntry.get("node");
                 this.content = (GenericValue) newRepositoryEntry.get("content");
                 this.session.save();
@@ -112,593 +128,682 @@ public class OfbizRepositoryMappingJackr
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getDelegator()
-     */
-    @Override
-    public Delegator getDelegator() {
-        return delegator;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#closeSession()
-     */
-    @Override
-    public void closeSession() {
-        if (session != null && session.isLive()) {
-            session.logout();
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.ofbiz.jcr.orm.OfbizContentMapping#updateTextData(java.lang.String)
-     */
-    @Override
-    public void updateOrStoreTextData(String message) throws RepositoryException {
-
-        this.node.setProperty(PROPERTY_FIELDS.MESSAGE.getType(), message);
-        this.session.save();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getContent()
-     */
-    @Override
-    public GenericValue getContentObject() {
-        return content;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNode()
-     */
-    @Override
-    public Node getNode() {
-        return node;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getContentId()
-     */
-    @Override
-    public String getContentId() {
-        if (content != null) {
-            return content.getString("contentId");
-        } else {
-            return new String();
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNodePath()
-     */
-    @Override
-    public String getNodePath() {
-        try {
-            return node.getPath();
-        }
-        catch (RepositoryException e) {
-            return new String();
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#removeRepositoryNode()
-     */
-    @Override
-    public void removeRepositoryNode() throws RepositoryException, GenericEntityException {
-        node.remove();
-        try {
-            GenericValue content = delegator.findOne("Content", false, UtilMisc.toMap("contentId", this.content.getString("contentId")));
-            List<GenericValue> relatedContents = getAllRelatedContents(content);
-            // TODO We should decide if we set a thru date or delete the
-            // resource
-            if (UtilValidate.isNotEmpty(relatedContents)) {
-                delegator.removeAll(relatedContents);
-            }
-            session.save();
-        }
-        catch (GenericEntityException e) {
-            throw new GenericEntityException(e);
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getStringContent()
-     */
-    @Override
-    public String getStringContent() throws PathNotFoundException, RepositoryException {
-        Property property = getNodeContentProperty(PROPERTY_FIELDS.MESSAGE.getType());
-
-        if (property == null || property.getType() != 1) {
-            Debug.logWarning("The content from the node:" + node.getPath() + " is not a String content.", module);
-            return new String();
-        }
-
-        return property.getString();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#uploadFileData()
-     */
-    @Override
-    public void uploadFileData(InputStream file, String fileName) throws PathNotFoundException, RepositoryException, GenericEntityException {
-        try {
-            this.node.setPrimaryType(PROPERTY_FIELDS.FOLDER.getType());
-        }
-        catch (RepositoryException e) {
-            Debug.logError("Appanding a file to a text content is not allowed. Please create a folder which haven't a text node as parent.", module);
-            throw new RepositoryException("Appanding a file to a text content is not allowed. Please create a folder which haven't a text node as parent.", e);
-        }
-
-        Node folder = (Node) createNewRepositoryNode(this.node.getPath() + "/" + fileName, PROPERTY_FIELDS.FILE.getType()).get("node");
-
-        Node resource = (Node) createNewRepositoryNode(folder.getPath() + "/jcr:content", PROPERTY_FIELDS.RESOURCE.getType()).get("node");
-        Binary binary = this.session.getValueFactory().createBinary(file);
-
-        String mimeType = getMimeTypeFromInputStream(file);
-
-        resource.setProperty("jcr:mimeType", mimeType);
-        // resource.setProperty("jcr:encoding", "");
-
-        resource.setProperty(PROPERTY_FIELDS.DATA.getType(), binary);
-        this.session.save();
-
-        return;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileContent()
-     */
-    @Override
-    public InputStream getFileContent(String fileName) throws RepositoryException {
-        if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FOLDER.getType())) {
-            Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FOLDER.getType()
-                             + ". No OutputStream can retunred.", module);
-            return null;
-        }
-
-        if (!this.node.hasNode(fileName)) {
-            throw new RepositoryException("This file does not exists in the folder");
-        }
-
-        Node fileNode = this.node.getNode(fileName);
-
-        Node jcrContent = fileNode.getNode("jcr:content");
-        if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
-            Debug.logWarning("No File Content found in repository node.", module);
-            return null;
-        }
-
-        return jcrContent.getProperty(PROPERTY_FIELDS.DATA.getType()).getBinary().getStream();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileContent()
-     */
-    @Override
-    public InputStream getFileContent() throws RepositoryException {
-        if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
-            Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FILE.getType()
-                             + ". No OutputStream can retunred.", module);
-            return null;
-        }
-
-        Node jcrContent = this.node.getNode("jcr:content");
-        if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
-            Debug.logWarning("No File Content found in repository node.", module);
-            return null;
-        }
-
-        return jcrContent.getProperty(PROPERTY_FIELDS.DATA.getType()).getBinary().getStream();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getJsonFileTree()
-     */
-    @Override
-    public JSONArray getJsonFileTree() throws RepositoryException {
-        return getJsonChildNodes(this.node);
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNodeName()
-     */
-    @Override
-    public String getNodeName() {
-        try {
-            return this.node.getName();
-        }
-        catch (RepositoryException e) {
-            Debug.logError(e, module);
-            return new String();
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileMimeType()
-     */
-    @Override
-    public String getFileMimeType() throws RepositoryException {
-        String mimeType = new String();
-
-        if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
-            Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FILE.getType()
-                             + ". No OutputStream can retunred.", module);
-            return mimeType;
-        }
-
-        Node jcrContent = this.node.getNode("jcr:content");
-        if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
-            Debug.logWarning("No File Content found in repository node.", module);
-            return mimeType;
-        }
-
-        if (jcrContent.hasProperty(PROPERTY_FIELDS.MIMETYPE.getType())) {
-            mimeType = jcrContent.getProperty(PROPERTY_FIELDS.MIMETYPE.getType()).getString();
-        }
-
-        return mimeType;
-    }
-
-    /**
-     * Returns a JSON Array with the repository folder structure. The JSON array
-     * is directly build for the jsTree jQuery plugin.
-     *
-     * @param startNode
-     * @return
-     * @throws RepositoryException
-     */
-    private JSONArray getJsonChildNodes(Node startNode) throws RepositoryException {
-        NodeIterator nodeIterator = startNode.getNodes();
-
-        JSONArray folderStrucutre = new JSONArray();
-        JSONObject attr = new JSONObject();
-
-        while (nodeIterator.hasNext()) {
-            JSONObject folder = new JSONObject();
-            Node node = nodeIterator.nextNode();
-
-            if (node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FOLDER.getType()) || node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.UNSTRUCTURED.getType())) {
-                attr.element("title", node.getName());
-                folder.element("data", attr);
-
-                attr = new JSONObject();
-                attr.element("NodePath", node.getPath());
-                attr.element("NodeType", node.getPrimaryNodeType().getName());
-                folder.element("attr", attr);
-
-                folder.element("children", getJsonChildNodes(node).toString());
-
-                folderStrucutre.element(folder);
-            } else if (node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
-                attr = new JSONObject();
-                attr.element("title", node.getName());
-                folder.element("data", attr);
-
-                attr = new JSONObject();
-                attr.element("NodePath", node.getPath());
-                attr.element("NodeType", node.getPrimaryNodeType().getName());
-                folder.element("attr", attr);
-
-                folderStrucutre.element(folder);
-            }
-
-        }
-
-        return folderStrucutre;
-    }
-
-    /**
-     * Get a property to a node, if this property not exist null will be
-     * returned.
-     *
-     * @return
-     * @throws PathNotFoundException
-     * @throws RepositoryException
-     */
-    private Property getNodeContentProperty(String type) throws PathNotFoundException, RepositoryException {
-        if (!node.hasProperty(type)) {
-            return null;
-        }
-
-        return node.getProperty(type);
-    }
-
-    /**
-     * Create a new node in the repository. The new node will be linked with an
-     * content object. The method can create recursive node structures.
-     * Recursive node associations will be stored in the ContentAssoc table
-     *
-     * @param newNodePath
-     *            - have to be an absolute path
-     * @return returned a map with the last created content and node object. The
-     *         objects are stored with the key "content" and "node"
-     * @throws RepositoryException
-     * @throws GenericEntityException
-     */
-    private Map<String, Object> createNewRepositoryNode(String newNodePath) throws RepositoryException, GenericEntityException {
-        return createNewRepositoryNode(newNodePath, null);
-    }
-
-    /**
-     * Create a new node in the repository. The new node will be linked with an
-     * content object. The method can create recursive node structures.
-     * Recursive node associations will be stored in the ContentAssoc table
-     *
-     * @param newNodePath
-     *            - have to be an absolute path
-     * @param type
-     *            - defines a primary type for the new node
-     * @return returned a map with the last created content and node object. The
-     *         objects are stored with the key "content" and "node"
-     * @throws RepositoryException
-     * @throws GenericEntityException
-     */
-    private Map<String, Object> createNewRepositoryNode(String newNodePath, String type) throws RepositoryException, GenericEntityException {
-        Map<String, Object> returnMap = createNodeStructure(newNodePath, type);
-        return returnMap;
-    }
-
-    /**
-     * Returns a list of all (recursive) related content to the base content.
-     * The return list contains the ContentAssoc Objects as well as the Content
-     * Objects.
-     *
-     * @param content
-     * @return
-     */
-    private List<GenericValue> getAllRelatedContents(GenericValue content) {
-        List<GenericValue> returnList = null;
-
-        try {
-            returnList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", content.getString("contentId")));
-
-            if (UtilValidate.isNotEmpty(returnList)) {
-                List<GenericValue> tmpReturnList = returnList;
-                for (GenericValue c : tmpReturnList) {
-                    returnList.addAll(getAllRelatedContents(delegator.findOne("Content", false, UtilMisc.toMap("contentId", c.getString("contentIdTo")))));
-                }
-            }
-            // find all content assoc links where the current content object is
-            // the child object
-            returnList.addAll(delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", content.getString("contentId"))));
-            returnList.add(content);
-
-        }
-        catch (GenericEntityException e) {
-            Debug.logError(e, module);
-            return null;
-        }
-
-        return returnList;
-    }
-
-    /**
-     * Here we create a new node Structure, if you pass a node path like
-     * "/foo/baa/node" It will create first "/foo" and "/baa" as parent node and
-     * than node.
-     *
-     * @param newNode
-     *            Path
-     * @return returned a map with the last created content and node object. The
-     *         objects are stored with the key "content" and "node"
-     * @throws RepositoryException
-     * @throws GenericEntityException
-     */
-    private Map<String, Object> createNodeStructure(String newNodes, String type) throws RepositoryException, GenericEntityException {
-        Map<String, Object> returnMap = FastMap.newInstance();
-        Node newNodeParent = this.session.getRootNode();
-        String assocContentId = null;
-        String parentContentId = null;
-        String[] nodes = newNodes.split("/");
-        for (String node : nodes) {
-            if (UtilValidate.isEmpty(node)) {
-                continue;
-            } else if (newNodeParent.hasNode(node)) {
-                newNodeParent = newNodeParent.getNode(node);
-                continue;
-            }
-
-            // If the current node is not the root node and has a parent node
-            // search for the parent content id.
-            if (!newNodeParent.getPath().equals("/") && UtilValidate.isEmpty(parentContentId) && UtilValidate.isEmpty(assocContentId)
-                && (newNodeParent.getParent() != null)) {
-                parentContentId = getParentNodeContentId(newNodeParent);
-            }
-
-            if (UtilValidate.isEmpty(type)) {
-                // If the nodeType is empty, add a node with the same node type
-                // as the parent node.
-                // Only when the parent node is the overall repository root
-                // node, we have to create a node without parent type.
-                String parentNodeType = newNodeParent.getPrimaryNodeType().getName();
-                if (!PROPERTY_FIELDS.REPROOT.getType().equals(parentNodeType)) {
-                    newNodeParent = newNodeParent.addNode(node, newNodeParent.getPrimaryNodeType().getName());
-                } else {
-                    newNodeParent = newNodeParent.addNode(node);
-                }
-            } else {
-                newNodeParent = newNodeParent.addNode(node, type);
-            }
-            GenericValue newContent = nodeContentDatabaseConnection(newNodeParent);
-            returnMap.put("content", newContent);
-            assocContentId = newContent.getString("contentId");
-
-            // create the content assoc entry for the new node parent - child
-            // relation
-            if (UtilValidate.isNotEmpty(assocContentId) && UtilValidate.isNotEmpty(parentContentId)) {
-                nodeContentAssoc(assocContentId, parentContentId);
-                parentContentId = assocContentId;
-            }
-
-        }
-
-        // only the last node which is created will be returned
-        returnMap.put("node", newNodeParent);
-        return returnMap;
-    }
-
-    /**
-     * Creates the database relationship between two nodes.
-     *
-     * @param assocContentId
-     * @param parentContentId
-     */
-    private void nodeContentAssoc(String assocContentId, String parentContentId) {
-        GenericValue contentAssoc = delegator.makeValue("ContentAssoc");
-
-        contentAssoc.set("contentId", parentContentId);
-        contentAssoc.set("contentIdTo", assocContentId);
-        contentAssoc.set("contentAssocTypeId", "REPOSITORY");
-        contentAssoc.set("fromDate", UtilDateTime.nowTimestamp());
-
-        try {
-            this.delegator.createOrStore(contentAssoc);
-        }
-        catch (GenericEntityException e) {
-            Debug.logError(e, module);
-        }
-
-    }
-
-    /**
-     * Returns the contentId to a node.
-     *
-     * @param newNodeParent
-     * @return
-     */
-    private String getParentNodeContentId(Node newNodeParent) {
-        List<GenericValue> list = null;
-        String parentNodeContentId = null;
-        try {
-            list = delegator.findByAndCache("Content", UtilMisc.toMap("repositoryNode", newNodeParent.getPath()));
-            if (UtilValidate.isNotEmpty(list)) {
-                parentNodeContentId = EntityUtil.getFirst(list).getString("contentId");
-            }
-        }
-        catch (GenericEntityException e) {
-            Debug.logError(e, module);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getDelegator()
+ */
+ @Override
+ public Delegator getDelegator() {
+ return delegator;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getSelctedLanguage()
+ */
+ @Override
+ public String getSelctedLanguage() {
+ return this.selectedLanguage;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#closeSession()
+ */
+ @Override
+ public void closeSession() {
+ if (session != null && session.isLive()) {
+ session.logout();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.OfbizContentMapping#updateTextData(java.lang.String)
+ */
+ @Override
+ public void updateOrStoreTextData(String message) throws RepositoryException, GenericEntityException {
+ updateOrStoreTextData(message, null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.OfbizContentMapping#updateTextData(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public void updateOrStoreTextData(String message, String language) throws RepositoryException, GenericEntityException {
+ // if no language is passed store the content under the ofbiz default
+ // language
+ if (UtilValidate.isEmpty(language)) {
+ language = UtilProperties.getPropertyValue("general", "locale.properties.fallback");
+ }
+
+ // create a sub node for the language if the current node haven't the
+ // language property
+ Node languageNode = node;
+ if (!node.hasProperty(PROPERTY_FIELDS.LANGUAGE.getType())) {
+ languageNode = (Node) this.createNewRepositoryNode(this.node.getPath() + "/" + language).get("node");
+ languageNode.setProperty(PROPERTY_FIELDS.LANGUAGE.getType(), language);
+ }
+ languageNode.setProperty(PROPERTY_FIELDS.MESSAGE.getType(), message);
+
+ this.session.save();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getContent()
+ */
+ @Override
+ public GenericValue getContentObject() {
+ return content;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNode()
+ */
+ @Override
+ public Node getNode() {
+ return node;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getContentId()
+ */
+ @Override
+ public String getContentId() {
+ if (content != null) {
+ return content.getString("contentId");
+ } else {
+ return new String();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNodePath()
+ */
+ @Override
+ public String getNodePath() {
+ try {
+ return node.getPath();
         }
         catch (RepositoryException e) {
-            Debug.logError(e, module);
-        }
-
-        return parentNodeContentId;
-    }
-
-    /**
-     * Creates a database relation to a repository node. Returns the new
-     * contentId.
-     *
-     * @param newNode
-     * @return
-     * @throws RepositoryException
-     * @throws GenericEntityException
-     */
-    private GenericValue nodeContentDatabaseConnection(Node newNode) throws RepositoryException, GenericEntityException {
-        // create the content database connection
-        GenericValue content = null;
-        content = this.delegator.makeValue("Content");
-        String primaryKey = this.delegator.getNextSeqId("Content");
-        content.set("contentId", primaryKey);
-        content.set("contentTypeId", "REPOSITORY");
-
-        content.set("repositoryNode", newNode.getPath());
-
-        GenericValue newContent = null;
-        try {
-            newContent = this.delegator.createOrStore(content);
-            // only save the session when a new content value is created
+ return new String();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#removeRepositoryNode()
+ */
+ @Override
+ public void removeRepositoryNode() throws RepositoryException, GenericEntityException {
+ node.remove();
+ try {
+ GenericValue content = delegator.findOne("Content", false, UtilMisc.toMap("contentId", this.content.getString("contentId")));
+ List<GenericValue> relatedContents = getAllRelatedContents(content);
+ // TODO We should decide if we set a thru date or delete the
+ // resource
+ if (UtilValidate.isNotEmpty(relatedContents)) {
+ delegator.removeAll(relatedContents);
+ }
+ session.save();
         }
         catch (GenericEntityException e) {
-            throw new GenericEntityException(e);
-        }
-
-        return newContent;
-    }
-
-    /**
-     * Checks if the node is in the repository. An absolute path should be
-     * passed.
-     *
-     * @param absoluteNodePath
-     * @return
-     */
-    private Boolean isNodeInRepository(String absoluteNodePath) {
-        try {
-            if (this.session.nodeExists(absoluteNodePath)) {
-                return Boolean.TRUE;
-            }
-        }
-        catch (RepositoryException e) {
-            Debug.logError(e, module);
-            return Boolean.FALSE;
-        }
-
-        return Boolean.FALSE;
-    }
-
-    /**
-     * Get the node object from the repository. If an exceptions rasises null
-     * will be returned.
-     *
-     * @param nodePath
-     * @return
-     */
-    private Node getRepositoryNode(String nodePath) {
-        try {
-            return session.getNode(nodePath);
-        }
-        catch (PathNotFoundException e) {
-            Debug.logError(e, module);
-            return null;
-        }
-        catch (RepositoryException e) {
-            Debug.logError(e, module);
-            return null;
-        }
-    }
-
-    private String getMimeTypeFromInputStream(InputStream is) {
-        Tika tika = new Tika();
-        try {
-            return tika.detect(is);
-        }
-        catch (IOException e) {
-            Debug.logError(e, module);
-            return new String();
-        }
-    }
+ throw new GenericEntityException(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getStringContent()
+ */
+ @Override
+ public String getStringContent() throws PathNotFoundException, RepositoryException {
+ return getStringContent(UtilProperties.getPropertyValue("general", "locale.properties.fallback"));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ofbiz.jcr.orm.OfbizContentMapping#getStringContent(java.lang.String)
+ */
+ @Override
+ public String getStringContent(String language) throws PathNotFoundException, RepositoryException {
+ Node langNode = null;
+ if (this.node.hasProperty(PROPERTY_FIELDS.LANGUAGE.getType())) {
+ langNode = this.node;
+ } else {
+ // if a language is set check if the content exists in this
+ // language, else take the system default language
+ if (this.node.hasNode(language)) {
+ langNode = this.node.getNode(language);
+ }
+ // only a fall back if no default language exists take the first
+ // child node
+ else {
+ if (this.node.hasNodes()) {
+ langNode = (Node) this.node.getNodes().next();
+ }
+ }
+ }
+
+ // set the current language selection
+ selectedLanguage = langNode.getProperty(PROPERTY_FIELDS.LANGUAGE.getType()).getString();
+
+ Property property = null;
+ if (langNode.hasProperty(PROPERTY_FIELDS.MESSAGE.getType())) {
+ property = langNode.getProperty(PROPERTY_FIELDS.MESSAGE.getType());
+ }
+
+ if (property == null || property.getType() != 1) {
+ Debug.logWarning("The content from the node:" + node.getPath() + " is not a String content.", module);
+ return new String();
+ }
+
+ return property.getString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getLanguage()
+ */
+ @Override
+ public List<String> getAvailableLanguages() throws PathNotFoundException, RepositoryException {
+ List<String> availableLanguages = FastList.newInstance();
+ NodeIterator ni = this.node.getNodes();
+
+ while (ni.hasNext()) {
+ Node subNode = (Node) ni.next();
+ if (subNode.hasProperty(PROPERTY_FIELDS.LANGUAGE.getType())) {
+ availableLanguages.add(subNode.getProperty(PROPERTY_FIELDS.LANGUAGE.getType()).getString());
+ }
+ }
+
+ return availableLanguages;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#uploadFileData()
+ */
+ @Override
+ public void uploadFileData(InputStream file, String fileName) throws PathNotFoundException, RepositoryException, GenericEntityException {
+ try {
+ this.node.setPrimaryType(PROPERTY_FIELDS.FOLDER.getType());
+ } catch (RepositoryException e) {
+ Debug.logError("Appanding a file to a text content is not allowed. Please create a folder which haven't a text node as parent.", module);
+ throw new RepositoryException("Appanding a file to a text content is not allowed. Please create a folder which haven't a text node as parent.", e);
+ }
+
+ Node folder = (Node) createNewRepositoryNode(this.node.getPath() + "/" + fileName, PROPERTY_FIELDS.FILE.getType()).get("node");
+
+ Node resource = (Node) createNewRepositoryNode(folder.getPath() + "/jcr:content", PROPERTY_FIELDS.RESOURCE.getType()).get("node");
+ Binary binary = this.session.getValueFactory().createBinary(file);
+
+ String mimeType = getMimeTypeFromInputStream(file);
+
+ resource.setProperty("jcr:mimeType", mimeType);
+ // resource.setProperty("jcr:encoding", "");
+
+ resource.setProperty(PROPERTY_FIELDS.DATA.getType(), binary);
+ this.session.save();
+
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileContent()
+ */
+ @Override
+ public InputStream getFileContent(String fileName) throws RepositoryException {
+ if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FOLDER.getType())) {
+ Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FOLDER.getType() + ". No OutputStream can retunred.", module);
+ return null;
+ }
+
+ if (!this.node.hasNode(fileName)) {
+ throw new RepositoryException("This file does not exists in the folder");
+ }
+
+ Node fileNode = this.node.getNode(fileName);
+
+ Node jcrContent = fileNode.getNode("jcr:content");
+ if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
+ Debug.logWarning("No File Content found in repository node.", module);
+ return null;
+ }
+
+ return jcrContent.getProperty(PROPERTY_FIELDS.DATA.getType()).getBinary().getStream();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileContent()
+ */
+ @Override
+ public InputStream getFileContent() throws RepositoryException {
+ if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
+ Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FILE.getType() + ". No OutputStream can retunred.", module);
+ return null;
+ }
+
+ Node jcrContent = this.node.getNode("jcr:content");
+ if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
+ Debug.logWarning("No File Content found in repository node.", module);
+ return null;
+ }
+
+ return jcrContent.getProperty(PROPERTY_FIELDS.DATA.getType()).getBinary().getStream();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getJsonFileTree()
+ */
+ @Override
+ public JSONArray getJsonFileTree() throws RepositoryException {
+ return getJsonFileChildNodes(this.node);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getJsonDataTree()
+ */
+ @Override
+ public JSONArray getJsonDataTree() throws RepositoryException{
+ return getJsonDataChildNodes(this.node);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getNodeName()
+ */
+ @Override
+ public String getNodeName() {
+ try {
+ return this.node.getName();
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ return new String();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ofbiz.jcr.orm.OfbizContentMapping#getFileMimeType()
+ */
+ @Override
+ public String getFileMimeType() throws RepositoryException {
+ String mimeType = new String();
+
+ if (!this.node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
+ Debug.logWarning("The Node: " + this.node.getPath() + " is not a node from type: " + PROPERTY_FIELDS.FILE.getType() + ". No OutputStream can retunred.", module);
+ return mimeType;
+ }
+
+ Node jcrContent = this.node.getNode("jcr:content");
+ if (!jcrContent.hasProperty(PROPERTY_FIELDS.DATA.getType())) {
+ Debug.logWarning("No File Content found in repository node.", module);
+ return mimeType;
+ }
+
+ if (jcrContent.hasProperty(PROPERTY_FIELDS.MIMETYPE.getType())) {
+ mimeType = jcrContent.getProperty(PROPERTY_FIELDS.MIMETYPE.getType()).getString();
+ }
+
+ return mimeType;
+ }
+
+ /**
+ * Returns a JSON Array with the repository folder structure. The JSON array
+ * is directly build for the jsTree jQuery plugin.
+ *
+ * @param startNode
+ * @return
+ * @throws RepositoryException
+ */
+ private JSONArray getJsonFileChildNodes(Node startNode) throws RepositoryException {
+ NodeIterator nodeIterator = startNode.getNodes();
+
+ JSONArray folderStrucutre = new JSONArray();
+ JSONObject attr = new JSONObject();
+
+ while (nodeIterator.hasNext()) {
+ JSONObject folder = new JSONObject();
+ Node node = nodeIterator.nextNode();
+
+ if (node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FOLDER.getType()) || node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.UNSTRUCTURED.getType())) {
+ attr.element("title", node.getName());
+ folder.element("data", attr);
+
+ attr = new JSONObject();
+ attr.element("NodePath", node.getPath());
+ attr.element("NodeType", node.getPrimaryNodeType().getName());
+ folder.element("attr", attr);
+
+ folder.element("children", getJsonFileChildNodes(node).toString());
+
+ folderStrucutre.element(folder);
+ } else if (node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.FILE.getType())) {
+ attr = new JSONObject();
+ attr.element("title", node.getName());
+ folder.element("data", attr);
+
+ attr = new JSONObject();
+ attr.element("NodePath", node.getPath());
+ attr.element("NodeType", node.getPrimaryNodeType().getName());
+ folder.element("attr", attr);
+
+ folderStrucutre.element(folder);
+ }
+
+ }
+
+ return folderStrucutre;
+ }
+
+ /**
+ * Returns a JSON Array with the repository text data structure. The JSON
+ * array is directly build for the jsTree jQuery plugin.
+ *
+ * @param startNode
+ * @return
+ * @throws RepositoryException
+ */
+ private JSONArray getJsonDataChildNodes(Node startNode) throws RepositoryException {
+ NodeIterator nodeIterator = startNode.getNodes();
+
+ JSONArray folderStrucutre = new JSONArray();
+ JSONObject attr = new JSONObject();
+
+ while (nodeIterator.hasNext()) {
+ JSONObject folder = new JSONObject();
+ Node node = nodeIterator.nextNode();
+
+ //
+ if (node.getPrimaryNodeType().isNodeType(PROPERTY_FIELDS.UNSTRUCTURED.getType()) && !node.hasProperty(PROPERTY_FIELDS.LANGUAGE.getType())) {
+ attr.element("title", node.getName());
+ folder.element("data", attr);
+
+ attr = new JSONObject();
+ attr.element("NodePath", node.getPath());
+ attr.element("NodeType", node.getPrimaryNodeType().getName());
+ folder.element("attr", attr);
+
+ folder.element("children", getJsonDataChildNodes(node).toString());
+
+ folderStrucutre.element(folder);
+ }
+ }
+
+ return folderStrucutre;
+ }
+
+ /**
+ * Create a new node in the repository. The new node will be linked with an
+ * content object. The method can create recursive node structures.
+ * Recursive node associations will be stored in the ContentAssoc table
+ *
+ * @param newNodePath
+ *            - have to be an absolute path
+ * @return returned a map with the last created content and node object. The
+ *         objects are stored with the key "content" and "node"
+ * @throws RepositoryException
+ * @throws GenericEntityException
+ */
+ private Map<String, Object> createNewRepositoryNode(String newNodePath) throws RepositoryException, GenericEntityException {
+ return createNewRepositoryNode(newNodePath, null);
+ }
+
+ /**
+ * Create a new node in the repository. The new node will be linked with an
+ * content object. The method can create recursive node structures.
+ * Recursive node associations will be stored in the ContentAssoc table
+ *
+ * @param newNodePath
+ *            - have to be an absolute path
+ * @param type
+ *            - defines a primary type for the new node
+ * @return returned a map with the last created content and node object. The
+ *         objects are stored with the key "content" and "node"
+ * @throws RepositoryException
+ * @throws GenericEntityException
+ */
+ private Map<String, Object> createNewRepositoryNode(String newNodePath, String type) throws RepositoryException, GenericEntityException {
+ Map<String, Object> returnMap = createNodeStructure(newNodePath, type);
+ return returnMap;
+ }
+
+ /**
+ * Returns a list of all (recursive) related content to the base content.
+ * The return list contains the ContentAssoc Objects as well as the Content
+ * Objects.
+ *
+ * @param content
+ * @return
+ */
+ private List<GenericValue> getAllRelatedContents(GenericValue content) {
+ List<GenericValue> returnList = null;
+
+ try {
+ returnList = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", content.getString("contentId")));
+
+ if (UtilValidate.isNotEmpty(returnList)) {
+ List<GenericValue> tmpReturnList = returnList;
+ for (GenericValue c : tmpReturnList) {
+ returnList.addAll(getAllRelatedContents(delegator.findOne("Content", false, UtilMisc.toMap("contentId", c.getString("contentIdTo")))));
+ }
+ }
+ // find all content assoc links where the current content object is
+ // the child object
+ returnList.addAll(delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentIdTo", content.getString("contentId"))));
+ returnList.add(content);
+
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ return null;
+ }
+
+ return returnList;
+ }
+
+ /**
+ * Here we create a new node Structure, if you pass a node path like
+ * "/foo/baa/node" It will create first "/foo" and "/baa" as parent node and
+ * than node.
+ *
+ * @param newNode
+ *            Path
+ * @return returned a map with the last created content and node object. The
+ *         objects are stored with the key "content" and "node"
+ * @throws RepositoryException
+ * @throws GenericEntityException
+ */
+ private Map<String, Object> createNodeStructure(String newNodes, String type) throws RepositoryException, GenericEntityException {
+ Map<String, Object> returnMap = FastMap.newInstance();
+ Node newNodeParent = this.session.getRootNode();
+ String assocContentId = null;
+ String parentContentId = null;
+ String[] nodes = newNodes.split("/");
+ for (String node : nodes) {
+ if (UtilValidate.isEmpty(node)) {
+ continue;
+ } else if (newNodeParent.hasNode(node)) {
+ newNodeParent = newNodeParent.getNode(node);
+ continue;
+ }
+
+ // If the current node is not the root node and has a parent node
+ // search for the parent content id.
+ if (!newNodeParent.getPath().equals("/") && UtilValidate.isEmpty(parentContentId) && UtilValidate.isEmpty(assocContentId) && (newNodeParent.getParent() != null)) {
+ parentContentId = getParentNodeContentId(newNodeParent);
+ }
+
+ if (UtilValidate.isEmpty(type)) {
+ // If the nodeType is empty, add a node with the same node type
+ // as the parent node.
+ // Only when the parent node is the overall repository root
+ // node, we have to create a node without parent type.
+ String parentNodeType = newNodeParent.getPrimaryNodeType().getName();
+ if (!PROPERTY_FIELDS.REPROOT.getType().equals(parentNodeType)) {
+ newNodeParent = newNodeParent.addNode(node, newNodeParent.getPrimaryNodeType().getName());
+ } else {
+ newNodeParent = newNodeParent.addNode(node);
+ }
+ } else {
+ newNodeParent = newNodeParent.addNode(node, type);
+ }
+ GenericValue newContent = nodeContentDatabaseConnection(newNodeParent);
+ returnMap.put("content", newContent);
+ assocContentId = newContent.getString("contentId");
+
+ // create the content assoc entry for the new node parent - child
+ // relation
+ if (UtilValidate.isNotEmpty(assocContentId) && UtilValidate.isNotEmpty(parentContentId)) {
+ nodeContentAssoc(assocContentId, parentContentId);
+ parentContentId = assocContentId;
+ }
+
+ }
+
+ // only the last node which is created will be returned
+ returnMap.put("node", newNodeParent);
+ return returnMap;
+ }
+
+ /**
+ * Creates the database relationship between two nodes.
+ *
+ * @param assocContentId
+ * @param parentContentId
+ */
+ private void nodeContentAssoc(String assocContentId, String parentContentId) {
+ GenericValue contentAssoc = delegator.makeValue("ContentAssoc");
+
+ contentAssoc.set("contentId", parentContentId);
+ contentAssoc.set("contentIdTo", assocContentId);
+ contentAssoc.set("contentAssocTypeId", "REPOSITORY");
+ contentAssoc.set("fromDate", UtilDateTime.nowTimestamp());
+
+ try {
+ this.delegator.createOrStore(contentAssoc);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ }
+
+ }
+
+ /**
+ * Returns the contentId to a node.
+ *
+ * @param newNodeParent
+ * @return
+ */
+ private String getParentNodeContentId(Node newNodeParent) {
+ List<GenericValue> list = null;
+ String parentNodeContentId = null;
+ try {
+ list = delegator.findByAndCache("Content", UtilMisc.toMap("repositoryNode", newNodeParent.getPath()));
+ if (UtilValidate.isNotEmpty(list)) {
+ parentNodeContentId = EntityUtil.getFirst(list).getString("contentId");
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ }
+
+ return parentNodeContentId;
+ }
+
+ /**
+ * Creates a database relation to a repository node. Returns the new
+ * contentId.
+ *
+ * @param newNode
+ * @return
+ * @throws RepositoryException
+ * @throws GenericEntityException
+ */
+ private GenericValue nodeContentDatabaseConnection(Node newNode) throws RepositoryException, GenericEntityException {
+ // create the content database connection
+ GenericValue content = null;
+ content = this.delegator.makeValue("Content");
+ String primaryKey = this.delegator.getNextSeqId("Content");
+ content.set("contentId", primaryKey);
+ content.set("contentTypeId", "REPOSITORY");
+
+ content.set("repositoryNode", newNode.getPath());
+
+ GenericValue newContent = null;
+ try {
+ newContent = this.delegator.createOrStore(content);
+ // only save the session when a new content value is created
+ } catch (GenericEntityException e) {
+ throw new GenericEntityException(e);
+ }
+
+ return newContent;
+ }
+
+ /**
+ * Get the node object from the repository. If an exceptions rasises null
+ * will be returned.
+ *
+ * @param nodePath
+ * @return
+ */
+ private Node getRepositoryNode(String nodePath) {
+ try {
+ return session.getNode(nodePath);
+ } catch (PathNotFoundException e) {
+ Debug.logError(e, module);
+ return null;
+ } catch (RepositoryException e) {
+ Debug.logError(e, module);
+ return null;
+ }
+ }
+
+ private String getMimeTypeFromInputStream(InputStream is) {
+ if (!TikaInputStream.isTikaInputStream(is)) {
+ is = TikaInputStream.get(is);
+ }
+ Tika tika = new Tika();
+ try {
+ return tika.detect(is);
+ } catch (IOException e) {
+ Debug.logError(e, module);
+ return "application/octet-stream";
+ }
+ }
 
 }

Modified: ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/test/JcrTests.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/test/JcrTests.java?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/test/JcrTests.java (original)
+++ ofbiz/branches/jackrabbit20100709/applications/content/src/org/ofbiz/content/test/JcrTests.java Thu May  5 12:32:13 2011
@@ -115,16 +115,9 @@ public class JcrTests extends OFBizTestC
         InputStream rs = uf.getFileContent(f.getName());
         assertNotNull(rs);
 
-        uf.removeRepositoryNode();
         uf.closeSession();
     }
 
-    public void testRemoveRepositoryNode() throws Exception {
-        jh.removeRepositoryNode();
-
-        assertNotNull(jh);
-    }
-
     public void testListRepositoryNodes() throws Exception {
         assertNotNull(JackrabbitWorker.getRepositoryNodes(userLogin, null));
     }

Modified: ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml (original)
+++ ofbiz/branches/jackrabbit20100709/framework/example/config/ExampleUiLabels.xml Thu May  5 12:32:13 2011
@@ -40,7 +40,7 @@
         <value xml:lang="ru">Приложение Пример</value>
         <value xml:lang="th">ตัวอย่างโปรแกรมคอมพิวเตอร์</value>
         <value xml:lang="zh">样例应用</value>
-    </property>    
+    </property>
     <property key="ExampleAutocompleteDropdown">
         <value xml:lang="en">Autocomplete Dropdown</value>
         <value xml:lang="fr">Liste déroulante à auto complétion</value>
@@ -74,11 +74,11 @@
         <value xml:lang="ru">OFBiz: Пример</value>
         <value xml:lang="th">OFBiz: ตัวอย่าง</value>
         <value xml:lang="zh">OFBiz: 样例</value>
-    </property>    
+    </property>
     <property key="ExampleCalendarFromLayer">
         <value xml:lang="en">Calendar field (only test purp.)</value>
         <value xml:lang="fr">Calendrier (only test)</value>
-    </property>    
+    </property>
     <property key="ExampleCompanySubtitle">
         <!--value xml:lang="ar">جزء من عائلة أوفبيز للبرمجيات الحرة</value-->
         <value xml:lang="ar">جزء من عائلة أوفبيز للتطبيقات الحرة للتسيير</value>
@@ -239,7 +239,7 @@
         <value xml:lang="fr"> - voir la défintion avec la form de nom </value>
         <value xml:lang="it"> - vedi la definizione della form con il nome</value>
         <value xml:lang="zh"> - 参见表单定义,名称为</value>
-    </property>    
+    </property>
     <property key="ExampleDependentDropDowns">
         <value xml:lang="en">Dependent drop-downs</value>
         <value xml:lang="fr">liste déroulante dépendantes</value>
@@ -476,7 +476,7 @@
         <value xml:lang="en">Fields groups</value>
         <value xml:lang="it">Gruppi campi</value>
         <value xml:lang="zh">数据项组</value>
-    </property>    
+    </property>
     <property key="ExampleLongDescription">
         <value xml:lang="en">Long Description</value>
         <value xml:lang="it">Descrizione lunga</value>
@@ -513,11 +513,11 @@
     <property key="ExampleMultipleDropDowns">
         <value xml:lang="en">Multiple drop-downs</value>
         <value xml:lang="fr">liste déroulante avec choix multiples</value>
-    </property>    
+    </property>
     <property key="ExampleMultipleDropDownTooltip">
         <value xml:lang="en">Needs some fields to be set, see in FormWidgetExampleScreens.xml (begins with multipleSelect)</value>
         <value xml:lang="fr">Nécessite de définir certains champs, voir dans FormWidgetExampleScreens.xml (commence avec multipleSelect)</value>
-    </property>    
+    </property>
     <property key="ExampleNewExample">
         <value xml:lang="en">New Example</value>
         <value xml:lang="fr">Nouvel exemple</value>
@@ -781,6 +781,14 @@
         <value xml:lang="de">Knoten</value>
         <value xml:lang="en">Node</value>
     </property>
+    <property key="ExampleJackrabbitShowContentData">
+        <value xml:lang="de">(Text) Content anzeigen</value>
+        <value xml:lang="en">Show (text) content</value>
+    </property>
+    <property key="ExampleJackrabbitListNodes">
+        <value xml:lang="de">Liste alles Knoten</value>
+        <value xml:lang="en">List Nodes</value>
+    </property>
     <property key="ExampleRepositoryFolder">
         <value xml:lang="de">Ordner</value>
         <value xml:lang="en">Folder</value>
@@ -833,4 +841,12 @@
         <value xml:lang="de">Löscht alle Nodes aus dem Repository, die keine Verkünpfung in der Content Tabelle haben.</value>
         <value xml:lang="en">Removes all nodes which are not linked in the content table.</value>
     </property>
+    <property key="ExampelsJackrabbitRemoveData">
+        <value xml:lang="de">Content löschen.</value>
+        <value xml:lang="en">Remove content.</value>
+    </property>
+    <property key="ExampelsJackrabbitOpenData">
+        <value xml:lang="de">Content öffnen.</value>
+        <value xml:lang="en">Open content.</value>
+    </property>
 </resource>

Added: ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy?rev=1099770&view=auto
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy (added)
+++ ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy Thu May  5 12:32:13 2011
@@ -0,0 +1,22 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+*/
+
+def localeMap = []
+org.ofbiz.base.util.UtilMisc.availableLocales().each { localeMap.add(localeId:it.toString()) };
+parameters.localeList = localeMap;
\ No newline at end of file

Modified: ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/controller.xml?rev=1099770&r1=1099769&r2=1099770&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/controller.xml (original)
+++ ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/WEB-INF/controller.xml Thu May  5 12:32:13 2011
@@ -28,7 +28,7 @@ under the License.
     <include location="component://example/webapp/birt/WEB-INF/controller.xml"/>
 
     <description>Example Component Site Configuration File</description>
-    
+
     <!--
       These can be used to return the reports as views; make sure the classes are compiled and available
         <handler name="datavision" type="view" class="org.ofbiz.webapp.view.DataVisionViewHandler"/>
@@ -50,7 +50,7 @@ under the License.
 
     <!-- Request Mappings -->
     <request-map uri="main"><security https="true" auth="true"/><response name="success" type="view" value="main"/></request-map>
-    
+
     <!-- Example Requests -->
     <request-map uri="FindExample"><security https="true" auth="true"/><response name="success" type="view" value="FindExample"/></request-map>
     <request-map uri="EditExample"><security https="true" auth="true"/><response name="success" type="view" value="EditExample"/></request-map>
@@ -250,7 +250,7 @@ under the License.
     <request-map uri="StoreNewRepositoryData">
         <security auth="true" https="true" />
         <event type="java" path="org.ofbiz.content.jcr.JackrabbitEvents" invoke="addNewTextMessageToJcrRepository"/>
-        <response name="success" type="request" value="ExampleJackrabbit" />
+        <response name="success" type="request" value="ExampleJackrabbitShowContentData" />
         <response name="error" type="view" value="ExampleJackrabbitAddData" />
     </request-map>
     <request-map uri="ExampleJackrabbitScanRepositoryStructure">
@@ -274,8 +274,8 @@ under the License.
     <request-map uri="RemoveRepositoryNode">
         <security auth="true" https="true" />
         <event type="java" path="org.ofbiz.content.jcr.JackrabbitEvents" invoke="removeRepositoryNode"/>
-        <response name="success" type="request" value="ExampleJackrabbit" />
-        <response name="error" type="request" value="ExampleJackrabbit" />
+        <response name="success" type="request" value="ExampleJackrabbitShowContentData" />
+        <response name="error" type="request" value="ExampleJackrabbitShowContentData" />
     </request-map>
     <request-map uri="RemoveRepositoryFile">
         <security auth="true" https="true" />
@@ -312,6 +312,12 @@ under the License.
         <response name="success" type="none" />
         <response name="error" type="none" />
     </request-map>
+    <request-map uri="ExampleJackrabbitShowContentData">
+        <security auth="true" https="true" />
+        <event type="java" path="org.ofbiz.content.jcr.JackrabbitEvents" invoke="getRepositoryDataTree"/>
+        <response name="success" type="view" value="ExampleJackrabbitShowContentData"/>
+        <response name="error" type="view" value="ExampleJackrabbitShowContentData"/>
+    </request-map>
 
     <!-- View Mappings -->
     <view-map name="main" type="screen" page="component://example/widget/example/CommonScreens.xml#main"/>
@@ -364,6 +370,7 @@ under the License.
     <view-map name="ExampleJackrabbitEditRepositoryContent" page="component://example/widget/example/ExampleJackrabbitScreens.xml#ExampleJackrabbitEditRepositoryContent" type="screen" />
     <view-map name="ExampleJackrabbitUploadFileData" page="component://example/widget/example/ExampleJackrabbitScreens.xml#ExampleJackrabbitUploadFileData" type="screen" />
     <view-map name="ExampleJackrabbitShowUploadedFiles" page="component://example/widget/example/ExampleJackrabbitScreens.xml#ExampleJackrabbitShowUploadedFiles" type="screen" />
+    <view-map name="ExampleJackrabbitShowContentData" page="component://example/widget/example/ExampleJackrabbitScreens.xml#ExampleJackrabbitShowContentData" type="screen" />
 
 
     <!-- Supported Content Types -->

Added: ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl?rev=1099770&view=auto
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl (added)
+++ ofbiz/branches/jackrabbit20100709/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl Thu May  5 12:32:13 2011
@@ -0,0 +1,94 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<script language="javascript" type="text/javascript" src="<@ofbizContentUrl>/images/jquery/plugins/jsTree/jquery.jstree.js</@ofbizContentUrl>"></script>
+
+<div id="jackrabbitDataTree">${parameters.dataTree!}</div>
+
+<script type="text/javascript">
+ var rawdata = ${parameters.dataTree!};
+
+    jQuery(function () {
+    jQuery("#jackrabbitDataTree").jstree({
+        "plugins" : [ "themes", "json_data", "ui", "contextmenu"],
+        "json_data" : {
+            "data" : rawdata
+        },
+        'contextmenu': {
+                'items': {
+                    'ccp' : false,
+                    'create' : false,
+                    'rename' : false,
+                    'open' : {
+                        'label' : "${uiLabelMap.ExampelsJackrabbitOpenData}",
+                        'action' : function(obj) {
+                            openDataFromRepository(obj.attr('nodepath'), obj.attr('nodetype'));
+                        }
+                   },
+                    'remove' : {
+                        'label' : "${uiLabelMap.ExampelsJackrabbitRemoveData}",
+                        'action' : function(obj) {
+                            removeDataFromRepository(obj.attr('nodepath'), obj.attr('nodetype'));
+                         }
+                   }
+                 }
+             }
+    });
+    });
+
+    function removeDataFromRepository(nodepath, nodetype) {
+     var parameters = {"repositoryNode" : nodepath};
+     var url = "RemoveRepositoryNode";
+
+     runPostRequest(url, parameters)
+    }
+
+    function openDataFromRepository(nodepath, nodetype) {
+
+     var parameters = {"repositoryNode" : nodepath};
+     var url = "EditRepositoryContent";
+
+     runPostRequest(url, parameters)
+    }
+
+    function runPostRequest(url, parameters) {
+     // create a hidden form
+     var form = jQuery('<form></form>');
+
+    form.attr("method", "POST");
+    form.attr("action", url);
+
+    jQuery.each(parameters, function(key, value) {
+        var field = jQuery('<input></input>');
+
+        field.attr("type", "hidden");
+        field.attr("name", key);
+        field.attr("value", value);
+
+        form.append(field);
+    });
+
+    // The form needs to be apart of the document in
+    // order for us to be able to submit it.
+    jQuery(document.body).append(form);
+    form.submit();
+    form.remove();
+    }
+
+
+</script>
\ No newline at end of file