diff --git a/example/build.xml b/example/build.xml index 70ec24c15..8add5d5f5 100644 --- a/example/build.xml +++ b/example/build.xml @@ -51,7 +51,5 @@ under the License. - - diff --git a/example/config/ExampleUiLabels.xml b/example/config/ExampleUiLabels.xml index 321de99bd..262a10211 100644 --- a/example/config/ExampleUiLabels.xml +++ b/example/config/ExampleUiLabels.xml @@ -19,34 +19,6 @@ 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 @@ -505,42 +477,6 @@ Gruppi campi 数据项组 - - 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 @@ -826,10 +762,6 @@ แก้ไขสินค้าตัวอย่าง 编辑样例明细 - - Jackrabbit - Jackrabbit - Find Example diff --git a/example/src/org/ofbiz/example/JackrabbitEvents.java b/example/src/org/ofbiz/example/JackrabbitEvents.java deleted file mode 100644 index 6203e3f93..000000000 --- a/example/src/org/ofbiz/example/JackrabbitEvents.java +++ /dev/null @@ -1,482 +0,0 @@ -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.data.JackrabbitArticle; -import org.ofbiz.jcr.orm.jackrabbit.file.JackrabbitFile; -import org.ofbiz.jcr.orm.jackrabbit.file.JackrabbitFolder; -import org.ofbiz.jcr.orm.jackrabbit.file.JackrabbitHierarchyNode; -import org.ofbiz.jcr.util.jackrabbit.JackrabbitUtils; - -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 = JackrabbitUtils.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/example/webapp/example/WEB-INF/controller.xml b/example/webapp/example/WEB-INF/controller.xml index 4573c7e5c..04cedf421 100644 --- a/example/webapp/example/WEB-INF/controller.xml +++ b/example/webapp/example/WEB-INF/controller.xml @@ -236,95 +236,6 @@ under the License. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -369,18 +280,6 @@ under the License. - - - - - - - - - - - - -${uiLabelMap.ExampleJackrabbitQuickContentSelect} -
- - - -
- - - -
\ No newline at end of file diff --git a/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl b/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl deleted file mode 100644 index 8d2aa7c96..000000000 --- a/example/webapp/example/jackrabbit/JackrabbitDataTree.ftl +++ /dev/null @@ -1,94 +0,0 @@ -<#-- -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/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl b/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl deleted file mode 100644 index a0914f74f..000000000 --- a/example/webapp/example/jackrabbit/JackrabbitFileTree.ftl +++ /dev/null @@ -1,110 +0,0 @@ -<#-- -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/example/widget/example/CommonScreens.xml b/example/widget/example/CommonScreens.xml index 1e1b24d4f..39ba47d16 100644 --- a/example/widget/example/CommonScreens.xml +++ b/example/widget/example/CommonScreens.xml @@ -294,32 +294,6 @@ under the License. - -
- - - - - - - - - - - - -
- - - -
-
-
-
-
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - -
- -
- - - - - - - - - - -