diff --git a/.classpath b/.classpath index 293c7a7016..5161fb835b 100644 --- a/.classpath +++ b/.classpath @@ -1,270 +1,283 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 3d40ad1a82..084e38104c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ framework/entityext/build/ framework/example/build/ framework/geronimo/build/ framework/guiapp/build/ +framework/jackrabbit/build/ framework/jetty/build/ framework/minilang/build/ framework/security/build/ diff --git a/applications/content/build.xml b/applications/content/build.xml index b295c3356d..4e8286d801 100644 --- a/applications/content/build.xml +++ b/applications/content/build.xml @@ -47,6 +47,7 @@ under the License. + diff --git a/framework/base/config/ofbiz-containers.xml b/framework/base/config/ofbiz-containers.xml index f58461ff15..bf2f53e610 100644 --- a/framework/base/config/ofbiz-containers.xml +++ b/framework/base/config/ofbiz-containers.xml @@ -94,6 +94,14 @@ under the License. + + + + + + + diff --git a/framework/base/config/test-containers.xml b/framework/base/config/test-containers.xml index 7972a90648..d0207d2b90 100644 --- a/framework/base/config/test-containers.xml +++ b/framework/base/config/test-containers.xml @@ -62,6 +62,13 @@ under the License. --> + + + + + + diff --git a/framework/base/lib/commons/commons-io-1.3.1.jar b/framework/base/lib/commons/commons-io-1.3.1.jar deleted file mode 100644 index 7affdefcd2..0000000000 Binary files a/framework/base/lib/commons/commons-io-1.3.1.jar and /dev/null differ diff --git a/framework/base/lib/commons/commons-io-1.4.jar b/framework/base/lib/commons/commons-io-1.4.jar new file mode 100644 index 0000000000..133dc6cb35 Binary files /dev/null and b/framework/base/lib/commons/commons-io-1.4.jar differ diff --git a/framework/base/lib/jcl-over-slf4j-1.6.4.jar b/framework/base/lib/jcl-over-slf4j-1.6.4.jar new file mode 100644 index 0000000000..3ddc1d1b1e Binary files /dev/null and b/framework/base/lib/jcl-over-slf4j-1.6.4.jar differ diff --git a/framework/base/lib/log4j-over-slf4j-1.6.4.jar b/framework/base/lib/log4j-over-slf4j-1.6.4.jar new file mode 100644 index 0000000000..d757d953c4 Binary files /dev/null and b/framework/base/lib/log4j-over-slf4j-1.6.4.jar differ diff --git a/framework/base/lib/slf4j-api-1.6.4.jar b/framework/base/lib/slf4j-api-1.6.4.jar new file mode 100644 index 0000000000..4d23f41d37 Binary files /dev/null and b/framework/base/lib/slf4j-api-1.6.4.jar differ diff --git a/framework/base/lib/slf4j-log4j12-1.6.4.jar b/framework/base/lib/slf4j-log4j12-1.6.4.jar new file mode 100644 index 0000000000..daa3aa1631 Binary files /dev/null and b/framework/base/lib/slf4j-log4j12-1.6.4.jar differ diff --git a/framework/build.xml b/framework/build.xml index 1d84b4920b..9fb30fb58e 100644 --- a/framework/build.xml +++ b/framework/build.xml @@ -25,7 +25,7 @@ under the License. files="start/build.xml,base/build.xml,sql/build.xml, entity/build.xml,geronimo/build.xml, catalina/build.xml,jetty/build.xml, - security/build.xml,service/build.xml,entityext/build.xml, + security/build.xml,service/build.xml,jcr/build.xml,entityext/build.xml, webslinger/build.xml, bi/build.xml,minilang/build.xml, webapp/build.xml,guiapp/build.xml,widget/build.xml, diff --git a/framework/component-load.xml b/framework/component-load.xml index c933c615c2..d7ab330612 100644 --- a/framework/component-load.xml +++ b/framework/component-load.xml @@ -32,6 +32,7 @@ under the License. + diff --git a/framework/example/build.xml b/framework/example/build.xml index 9033b098df..70ec24c15a 100644 --- a/framework/example/build.xml +++ b/framework/example/build.xml @@ -37,6 +37,9 @@ under the License. + + + @@ -47,5 +50,8 @@ under the License. + + + diff --git a/framework/example/config/ExampleUiLabels.xml b/framework/example/config/ExampleUiLabels.xml index c0bad16c77..a0caba83de 100644 --- a/framework/example/config/ExampleUiLabels.xml +++ b/framework/example/config/ExampleUiLabels.xml @@ -19,6 +19,34 @@ under the License. --> + + Datei herunterladen + Download file + + + Content öffnen. + Open content. + + + Datei öffnen + Open file + + + Content löschen. + Remove content. + + + Datei löschen + Remove file + + + Einen neuen Content Eintrag hinzufügen + Add a new content entry + + + Füge einen neuen Node Pfad hinzu, z.B. /Foo/Baa speichert die Datei im Ordner "Baa" + Add a (new) node path like /Foo/Baa will store the file under the folder "Baa" + Ajax Examples Exemples Ajax @@ -40,7 +68,7 @@ Приложение Пример ตัวอย่างโปรแกรมคอมพิวเตอร์ 样例应用 - + Autocomplete Dropdown Liste déroulante à auto complétion @@ -49,6 +77,10 @@ COUNTRY type based example, use Geo.Geoid and Geo.GeoName Entity.fields for completion Exemple sur le type COUNTRY et utilisant Geo.Geoid et Geo.GeoName comme Entité.champs pour la complétion + + Verion des Content Knoten + Version of the base content node + HTML chart report Graphiques HTML @@ -57,15 +89,19 @@ PDF chart report Graphiques PDF - - HTML - Send any format through Mail + + HTML + PDF + + Calendar field (only test purp.) + Calendrier (only test) + OFBiz: Example OFBiz : Exemple @@ -74,11 +110,7 @@ OFBiz: Пример OFBiz: ตัวอย่าง OFBiz: 样例 - - - Calendar field (only test purp.) - Calendrier (only test) - + جزء من عائلة أوفبيز للتطبيقات الحرة للتسيير @@ -239,7 +271,11 @@ - voir la défintion avec la form de nom - vedi la definizione della form con il nome - 参见表单定义,名称为 - + + + Needs some fields to be set, see in FormWidgetExampleScreens.xml (begins with dependentForm) + Nécessite de définir certains champs, voir dans FormWidgetExampleScreens.xml (commence avec dependentForm) + Dependent drop-downs liste déroulante dépendantes @@ -352,10 +388,6 @@ Campi drop down 下拉框数据项 - - Needs some fields to be set, see in FormWidgetExampleScreens.xml (begins with dependentForm) - Nécessite de définir certains champs, voir dans FormWidgetExampleScreens.xml (commence avec dependentForm) - First of all you have to define a drop-down element inside of the field element that you want to render as a drop down field. Pour commencer vous définissez un élément liste déroulante (drop-down) à l'intérieur de l'élément champ (field) que vous voulez créer comme liste déroulante @@ -459,14 +491,6 @@ ตัวอย่างรูปแบบ Widget 表单挂件样例 - - Portlet Attribut need to be define, click here to resolve it - Les attributs de la portlet doivent être definie. Cliquez ici pour résoudre le problème. - - - Go to configured portal page -> - Allez à la page portail configurée -> - Group Gruppo @@ -476,24 +500,64 @@ Fields groups Gruppi campi 数据项组 - - - Long Description - Descrizione lunga - 详细描述 + + + Repository aufräumen + Clean repository + + + Löscht alle Nodes aus dem Repository, die keine Verkünpfung in der Content Tabelle haben. + Removes all nodes which are not linked in the content table. + + + Liste alles Knoten + List Nodes + + + Das Repository kann mit Hilfe der SQL2 oder JQOM Query Language durchsucht werden: z.B. SELECT * FROM [nt:unstructured] gibt alle nodes vom Typ nt:unstructured zurück. + You can search the repository by using SQL2 or JQOM query syntax: i.e. SELECT * FROM [nt:unstructured] gives all nodes with the typ nt:unstructured. + + + Content Schnellauswahl - Content Node auswählen und Sprache bestimmen. + Content quick select - Choose your content node and select a language. + + + (Text) Content anzeigen + Show (text) content + + + Dateien anzeigen + Show uploaded Files + + + Wähle eine Datei und versuche einen Rechtklick + Choose a file and try a 'right click' + + + Eine neue Datei speichern + Upload a new file + + + Verion der gewählten sprache + Version of the choosen language Layered lookup field (only test purp.) Lookup de type layer (only test) - - Lookup Fields - Champs de recherche + + Long Description + Descrizione lunga + 详细描述 Lookup Fields: First of type popup, second layered and showing use of set_values underneath, ie returning not only Id but also another value. Both using also autocomplete Champs de recherche: le premier de type popup, le second de type layer avec usage sous-jacent de set_values qui permet de traiter non seulement une référence mais aussi une autre valeur. Les 2 utilisent aussi l'autocompletion + + Lookup Fields + Champs de recherche + Example Main Page Exemple de page principale @@ -510,14 +574,14 @@ สำหรับท่านที่สนใจสามารถเข้าสู่ระบบได้, โดยใช้ ชื่อผู้ใช้:admin, รหัสผ่าน:ofbiz 如果对某部分感兴趣,请先确信你已登录,可以尝试用 用户名:admin、密码:ofbiz登录。 - - Multiple drop-downs - liste déroulante avec choix multiples - Needs some fields to be set, see in FormWidgetExampleScreens.xml (begins with multipleSelect) Nécessite de définir certains champs, voir dans FormWidgetExampleScreens.xml (commence avec multipleSelect) - + + + Multiple drop-downs + liste déroulante avec choix multiples + New Example Nouvel exemple @@ -565,11 +629,19 @@ Geolocation via address Géolocalisation par l'adresse + + Portlet Attribut need to be define, click here to resolve it + Les attributs de la portlet doivent être definie. Cliquez ici pour résoudre le problème. + Hi, this is a first example of portlet Salve, questo è il primo esempio di portlet 你好,这是第一个Portlet样例 + + Go to configured portal page -> + Allez à la page portail configurée -> + Hi, this is a second example of portlet Salve, questo è il secondo esempio di portlet @@ -595,6 +667,26 @@ Bottone di stampa 打印按钮 + + Datei + File + + + Ordner + Folder + + + Text Nachricht + Text message + + + Knoten + Node + + + Repository Struktur überprüfen + Scan repository structure + Selection boxes Boutons de sélection @@ -730,6 +822,10 @@ แก้ไขสินค้าตัวอย่าง 编辑样例明细 + + Jackrabbit + Jackrabbit + Find Example diff --git a/framework/example/src/org/ofbiz/example/JackrabbitEvents.java b/framework/example/src/org/ofbiz/example/JackrabbitEvents.java new file mode 100644 index 0000000000..9b05608c25 --- /dev/null +++ b/framework/example/src/org/ofbiz/example/JackrabbitEvents.java @@ -0,0 +1,482 @@ +package org.ofbiz.example; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Map; + +import javax.jcr.ItemExistsException; +import javax.jcr.Node; +import javax.jcr.NodeIterator; +import javax.jcr.PathNotFoundException; +import javax.jcr.RepositoryException; +import javax.jcr.Session; +import javax.jcr.ValueFormatException; +import javax.jcr.nodetype.NodeType; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import javolution.util.FastMap; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.apache.commons.io.IOUtils; +import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException; +import org.ofbiz.base.util.Debug; +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.entity.GenericValue; +import org.ofbiz.jcr.access.JcrRepositoryAccessor; +import org.ofbiz.jcr.access.jackrabbit.JackrabbitRepositoryAccessor; +import org.ofbiz.jcr.api.JcrDataHelper; +import org.ofbiz.jcr.api.JcrFileHelper; +import org.ofbiz.jcr.api.jackrabbit.JackrabbitArticleHelper; +import org.ofbiz.jcr.api.jackrabbit.JackrabbitFileHelper; +import org.ofbiz.jcr.orm.OfbizRepositoryMapping; +import org.ofbiz.jcr.orm.jackrabbit.JackrabbitArticle; +import org.ofbiz.jcr.orm.jackrabbit.JackrabbitFile; +import org.ofbiz.jcr.orm.jackrabbit.JackrabbitFolder; +import org.ofbiz.jcr.orm.jackrabbit.JackrabbitHierarchyNode; +import org.ofbiz.jcr.util.jackrabbit.JcrUtilJackrabbit; + +public class JackrabbitEvents { + + public static final String module = JackrabbitEvents.class.getName(); + + /** + * + * @param request + * @param response + * @return + */ + public static String addNewTextMessageToJcrRepository(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + JcrDataHelper articleHelper = new JackrabbitArticleHelper(userLogin); + + String contentPath = request.getParameter("path"); + String language = request.getParameter("msgLocale"); + String title = request.getParameter("title"); + Calendar pubDate = new GregorianCalendar(); // TODO + String content = request.getParameter("message"); + + try { + articleHelper.storeContentInRepository(contentPath, language, title, content, pubDate); + } catch (ObjectContentManagerException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } catch (ItemExistsException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } finally { + articleHelper.closeContentSession(); + } + + return "success"; + } + + /** + * + * @param request + * @param response + * @return + */ + public static String scanRepositoryStructure(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + try { + List> listIt = JcrUtilJackrabbit.getRepositoryNodes(userLogin, ""); + request.setAttribute("listIt", listIt); + } catch (RepositoryException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + + return "success"; + } + + /** + * + * @param request + * @param response + * @return + */ + public static String getNodeContent(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + + String contentPath = request.getParameter("path"); + + String version = request.getParameter("versions"); + String language = request.getParameter("language"); + + if (UtilValidate.isEmpty(contentPath)) { + String msg = "A node path is missing, please pass the path to the node which should be read from the repository."; // TODO + Debug.logError(msg, module); + request.setAttribute("_ERROR_MESSAGE_", msg); + return "error"; + } + + JcrDataHelper articleHelper = new JackrabbitArticleHelper(userLogin); + JackrabbitArticle ormArticle = null; + try { + if (UtilValidate.isEmpty(version)) { + ormArticle = articleHelper.readContentFromRepository(contentPath, language); + } else { + ormArticle = articleHelper.readContentFromRepository(contentPath, language, version); + } + } catch (ClassCastException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } catch (PathNotFoundException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + + request.setAttribute("path", ormArticle.getPath()); + request.setAttribute("language", ormArticle.getLanguage()); + request.setAttribute("title", ormArticle.getTitle()); + request.setAttribute("version", ormArticle.getVersion()); + request.setAttribute("versionList", articleHelper.getVersionListForCurrentArticle()); + request.setAttribute("languageList", articleHelper.getAvailableLanguageList()); + request.setAttribute("createDate", ormArticle.getCreationDate()); + request.setAttribute("content", ormArticle.getContent()); + + return "success"; + } + + /** + * + * @param request + * @param response + * @return + */ + public static String updateRepositoryData(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + + String contentPath = request.getParameter("path"); + JcrDataHelper articleHelper = new JackrabbitArticleHelper(userLogin); + + JackrabbitArticle ormArticle = null; + try { + ormArticle = articleHelper.readContentFromRepository(contentPath); + } catch (ClassCastException e1) { + Debug.logError(e1, module); + request.setAttribute("_ERROR_MESSAGE_", e1.getMessage()); + return "error"; + } catch (PathNotFoundException e1) { + Debug.logError(e1, module); + request.setAttribute("_ERROR_MESSAGE_", e1.getMessage()); + return "error"; + } + + ormArticle.setTitle(request.getParameter("title")); + ormArticle.setContent(request.getParameter("content")); + + 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"; + } + + /** + * + * @param request + * @param response + * @return + */ + public static String removeRepositoryNode(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + + String contentPath = request.getParameter("path"); + + JcrDataHelper helper = new JackrabbitArticleHelper(userLogin); + helper.removeContentObject(contentPath); + + return "success"; + } + + /** + * + * @param request + * @param response + * @return + */ + public static String uploadFileData(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp"))); + List list = null; + Map passedParams = FastMap.newInstance(); + + try { + list = UtilGenerics.checkList(fu.parseRequest(request)); + } catch (FileUploadException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + return "error"; + } + + byte[] file = null; + for (FileItem fi : list) { + String fieldName = fi.getFieldName(); + + if (fi.isFormField()) { + String fieldStr = fi.getString(); + passedParams.put(fieldName, fieldStr); + } else if (fieldName.startsWith("fileData")) { + passedParams.put("completeFileName", fi.getName()); + file = fi.get(); + } + } + + JcrFileHelper fileHelper = new JackrabbitFileHelper(userLogin); + + try { + + fileHelper.storeContentInRepository(file, passedParams.get("completeFileName"), passedParams.get("path")); + + } catch (ObjectContentManagerException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + } catch (ItemExistsException 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 { + fileHelper.closeContentSession(); + } + + 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"); + + JcrRepositoryAccessor repositoryAccess = new JackrabbitRepositoryAccessor(userLogin); + try { + JSONArray fileTree = repositoryAccess.getJsonFileTree(); + request.setAttribute("fileTree", StringUtil.wrapString(fileTree.toString())); + } catch (RepositoryException e) { + Debug.logError(e, module); + request.setAttribute("dataTree", new JSONArray()); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + return "error"; + } finally { + repositoryAccess.closeAccess(); + } + + 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"); + + JackrabbitRepositoryAccessor repositoryAccess = new JackrabbitRepositoryAccessor(userLogin); + try { + JSONArray fileTree = repositoryAccess.getJsonDataTree(); + request.setAttribute("dataTree", StringUtil.wrapString(fileTree.toString())); + } catch (RepositoryException e) { + Debug.logError(e, module); + request.setAttribute("dataTree", new JSONArray()); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + repositoryAccess.closeAccess(); + return "error"; + } + + List contentList = new ArrayList(); + Map> languageList = FastMap.newInstance(); + Session session = repositoryAccess.getSession(); + Node root; + try { + root = session.getRootNode(); + getContentList(root, contentList); + } catch (RepositoryException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.toString()); + repositoryAccess.closeAccess(); + return "error"; + } finally { + } + + try { + for (String path : contentList) { + Node parent = session.getNode(path); + NodeIterator ni = parent.getNodes(); + List language = new ArrayList(); + while (ni.hasNext()) { + Node t = ni.nextNode(); + if (t.hasProperty("localized") && t.getProperty("localized").getBoolean()) { + String l = t.getPath(); + language.add(l.substring(l.lastIndexOf("/") + 1)); + } + } + languageList.put(path, language); + } + } catch (ValueFormatException e) { + Debug.logError(e, module); + } catch (PathNotFoundException e) { + Debug.logError(e, module); + } catch (RepositoryException e) { + Debug.logError(e, module); + } finally { + repositoryAccess.closeAccess(); + } + + request.setAttribute("contentList", contentList); + JSONObject jo = new JSONObject(); + jo.putAll(languageList); + request.setAttribute("languageList", jo); + + return "success"; + } + + public static String getFileFromRepository(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + + String contentPath = request.getParameter("path"); + + if (UtilValidate.isEmpty(contentPath)) { + String msg = "A node path is missing, please pass the path to the node which should be read from the repository."; // TODO + Debug.logError(msg, module); + request.setAttribute("_ERROR_MESSAGE_", msg); + return "error"; + } + + JcrFileHelper fileHelper = new JackrabbitFileHelper(userLogin); + JackrabbitHierarchyNode orm = null; + try { + orm = fileHelper.getRepositoryContent(contentPath); + } catch (ClassCastException e1) { + Debug.logError(e1, module); + request.setAttribute("_ERROR_MESSAGE_", e1.getMessage()); + return "error"; + } catch (PathNotFoundException e1) { + Debug.logError(e1, module); + request.setAttribute("_ERROR_MESSAGE_", e1.getMessage()); + return "error"; + } + + if (fileHelper.isFileContent()) { + JackrabbitFile file = (JackrabbitFile) orm; + InputStream fileStream = file.getResource().getData(); + + 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"; + } + + public static String getFileInformation(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + String contentPath = request.getParameter("path"); + + JcrFileHelper fileHelper = new JackrabbitFileHelper(userLogin); + OfbizRepositoryMapping orm; + try { + orm = fileHelper.getRepositoryContent(contentPath); + } catch (ClassCastException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } catch (PathNotFoundException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + + // Here we can differentiate between a file or folder content + if (fileHelper.isFileContent()) { + JackrabbitFile file = (JackrabbitFile) 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()) { + JackrabbitFolder folder = (JackrabbitFolder) orm; + request.setAttribute("fileName", folder.getPath()); + request.setAttribute("fileCreationDate", folder.getCreationDate().getTime()); + } + + return "success"; + } + + public static String queryRepositoryData(HttpServletRequest request, HttpServletResponse response) { + GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); + + String searchQuery = request.getParameter("queryData"); + + JcrDataHelper helper = new JackrabbitArticleHelper(userLogin); + + try { + request.setAttribute("queryResult", helper.queryData(searchQuery)); + } catch (RepositoryException e) { + Debug.logError(e, module); + request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); + return "error"; + } + + return "success"; + } + + private static void getContentList(Node startNode, List contentList) throws RepositoryException { + NodeIterator ni = startNode.getNodes(); + while (ni.hasNext()) { + Node tmpNode = ni.nextNode(); + if (tmpNode.getPrimaryNodeType().isNodeType(NodeType.NT_UNSTRUCTURED) && (!tmpNode.hasProperty("localized") || !tmpNode.getProperty("localized").getBoolean())) { + contentList.add(tmpNode.getPath()); + if (tmpNode.hasNodes()) { + getContentList(tmpNode, contentList); + } + } + } + } +} \ No newline at end of file diff --git a/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy b/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy new file mode 100644 index 0000000000..b7d9d80399 --- /dev/null +++ b/framework/example/webapp/example/WEB-INF/actions/includes/PrepareLocalesForDropDown.groovy @@ -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 diff --git a/framework/example/webapp/example/WEB-INF/controller.xml b/framework/example/webapp/example/WEB-INF/controller.xml index 5a487295be..4a481fee09 100644 --- a/framework/example/webapp/example/WEB-INF/controller.xml +++ b/framework/example/webapp/example/WEB-INF/controller.xml @@ -28,7 +28,7 @@ under the License. Example Component Site Configuration File - + - + @@ -236,6 +236,95 @@ under the License. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -280,6 +369,18 @@ under the License. + + + + + + + + + + + + +${uiLabelMap.ExampleJackrabbitQuickContentSelect} +
+ + + +
+ + + +
\ No newline at end of file diff --git a/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl b/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl new file mode 100644 index 0000000000..8d2aa7c963 --- /dev/null +++ b/framework/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl @@ -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. +--> + + +
${parameters.dataTree!""}
+ + \ No newline at end of file diff --git a/framework/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl b/framework/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl new file mode 100644 index 0000000000..a0914f74f5 --- /dev/null +++ b/framework/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl @@ -0,0 +1,110 @@ +<#-- +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. +--> + + +
${parameters.fileTree!""}
+ + \ No newline at end of file diff --git a/framework/example/widget/example/CommonScreens.xml b/framework/example/widget/example/CommonScreens.xml index 39ba47d167..1e1b24d4f5 100644 --- a/framework/example/widget/example/CommonScreens.xml +++ b/framework/example/widget/example/CommonScreens.xml @@ -294,6 +294,32 @@ under the License. + +
+ + + + + + + + + + + + +
+ + + +
+
+
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + + + + + +