diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 1e58fd5de7..11c8dada07 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -90,6 +90,7 @@ select_destination_prompt=Click here to select the destination select_web_project_folder=Click here to select a Web Project folder add_new=Add New change=Change +select=Select set=Set no_categories_applied=This document does not yet have any categories applied. has_following_categories=This document has the following categories applied... @@ -1544,5 +1545,6 @@ idle=Idle loading=Loading eg=e.g. click_to_edit=click to edit + # File Picker go_up=Go up diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java index 6ebe8dbe0f..cfe4cb802b 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java @@ -98,7 +98,9 @@ public class AVMEditBean /** The NodeService bean reference */ protected NodeService nodeService; - + + /** The FilePickerBean reference */ + protected FilePickerBean filePickerBean; // ------------------------------------------------------------------------------ // Bean property getters and setters @@ -106,7 +108,7 @@ public class AVMEditBean /** * @param avmService The AVMService to set. */ - public void setAvmService(AVMService avmService) + public void setAvmService(final AVMService avmService) { this.avmService = avmService; } @@ -114,7 +116,7 @@ public class AVMEditBean /** * @param avmSyncService The AVMSyncService to set. */ - public void setAvmSyncService(AVMSyncService avmSyncService) + public void setAvmSyncService(final AVMSyncService avmSyncService) { this.avmSyncService = avmSyncService; } @@ -122,15 +124,23 @@ public class AVMEditBean /** * @param avmBrowseBean The AVMBrowseBean to set. */ - public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) + public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean) { this.avmBrowseBean = avmBrowseBean; } + /** + * @param filePickerBean The FilePickerBean to set. + */ + public void setFilePickerBean(final FilePickerBean filePickerBean) + { + this.filePickerBean = filePickerBean; + } + /** * @param contentService The ContentService to set. */ - public void setContentService(ContentService contentService) + public void setContentService(final ContentService contentService) { this.contentService = contentService; } @@ -138,7 +148,7 @@ public class AVMEditBean /** * @param nodeService The nodeService to set. */ - public void setNodeService(NodeService nodeService) + public void setNodeService(final NodeService nodeService) { this.nodeService = nodeService; } @@ -364,6 +374,8 @@ public class AVMEditBean this.avmSyncService.resetLayer(path); } + this.filePickerBean.clearUploadedFiles(); + if (LOGGER.isDebugEnabled()) LOGGER.debug("Editing AVM node: " + avmPath); @@ -453,26 +465,26 @@ public class AVMEditBean if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) { this.regenerateRenditions(); - final NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles(); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("updating " + uploadedFiles.length + " uploaded files"); - - final List diffList = new ArrayList(uploadedFiles.length); - for (NodeRef uploadedFile : uploadedFiles) - { - final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); - diffList.add(new AVMDifference(-1, path, - -1, AVMUtil.getCorrespondingPathInMainStore(path), - AVMDifference.NEWER)); - } - this.avmSyncService.update(diffList, null, true, true, true, true, null, null); } + final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles(); + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("updating " + uploadedFiles.length + " uploaded files"); + + final List diffList = new ArrayList(uploadedFiles.length); + for (NodeRef uploadedFile : uploadedFiles) + { + final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); + diffList.add(new AVMDifference(-1, path, + -1, AVMUtil.getCorrespondingPathInMainStore(path), + AVMDifference.NEWER)); + } + this.avmSyncService.update(diffList, null, true, true, true, true, null, null); // Possibly notify virt server AVMUtil.updateVServerWebapp(avmNode.getPath(), false); - resetState(); + this.resetState(); return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; } @@ -559,6 +571,7 @@ public class AVMEditBean this.setFormProcessorSession(null); this.instanceDataDocument = null; this.form = null; + this.filePickerBean.clearUploadedFiles(); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index c92dd66048..fa060238ca 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -118,6 +118,9 @@ public class CreateWebContentWizard extends BaseContentWizard /** Workflow service bean reference */ protected WorkflowService workflowService; + + /** The FilePickerBean reference */ + protected FilePickerBean filePickerBean; /** * @param avmService The AVMService to set. @@ -159,6 +162,14 @@ public class CreateWebContentWizard extends BaseContentWizard { this.avmBrowseBean = avmBrowseBean; } + + /** + * @param filePickerBean The FilePickerBean to set. + */ + public void setFilePickerBean(final FilePickerBean filePickerBean) + { + this.filePickerBean = filePickerBean; + } // ------------------------------------------------------------------------------ @@ -185,7 +196,8 @@ public class CreateWebContentWizard extends BaseContentWizard this.formSelectDisabled = false; this.createMimeTypes = null; this.formChoices = null; - + this.filePickerBean.clearUploadedFiles(); + // check for a form ID being passed in as a parameter if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null) { @@ -279,9 +291,7 @@ public class CreateWebContentWizard extends BaseContentWizard protected String finishImpl(final FacesContext context, final String outcome) throws Exception { - final NodeRef[] uploadedFiles = (this.formProcessorSession != null - ? this.formProcessorSession.getUploadedFiles() - : new NodeRef[0]); + final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles(); final List diffList = new ArrayList(1 + this.renditions.size() + uploadedFiles.length); diffList.add(new AVMDifference(-1, this.createdPath, @@ -415,6 +425,7 @@ public class CreateWebContentWizard extends BaseContentWizard { this.formProcessorSession.destroy(); } + this.filePickerBean.clearUploadedFiles(); // return the default outcome return outcome; @@ -741,7 +752,7 @@ public class CreateWebContentWizard extends BaseContentWizard return Collections.EMPTY_LIST; } - NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles(); + final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles(); final List result = new ArrayList(uploadedFiles.length); diff --git a/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java b/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java new file mode 100644 index 0000000000..5fdc926fa7 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/FilePickerBean.java @@ -0,0 +1,289 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.bean.wcm; + +import java.io.*; +import java.util.*; + +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.TempFileProvider; +import org.alfresco.web.app.Application; +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.app.servlet.ajax.InvokeCommand; +import org.alfresco.web.bean.FileUploadBean; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.forms.*; +import org.alfresco.web.ui.common.Utils; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.apache.commons.fileupload.servlet.ServletRequestContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.util.FileCopyUtils; + +import org.w3c.dom.*; +import org.w3c.dom.bootstrap.DOMImplementationRegistry; +import org.w3c.dom.events.Event; +import org.w3c.dom.events.EventListener; +import org.w3c.dom.events.EventTarget; +import org.w3c.dom.ls.*; +import org.xml.sax.SAXException; + +/** + * Bean for interacting with the file picker widget using ajax requests. + */ +public class FilePickerBean +{ + private static final Log LOGGER = LogFactory.getLog(FilePickerBean.class); + private final Set uploads = new HashSet(); + + private AVMBrowseBean avmBrowseBean; + private AVMService avmService; + + public FilePickerBean() + { + } + + public void clearUploadedFiles() + { + this.uploads.clear(); + } + + public NodeRef[] getUploadedFiles() + { + return (NodeRef[])this.uploads.toArray(new NodeRef[this.uploads.size()]); + } + + /** + * @param avmBrowseBean the avmBrowseBean to set. + */ + public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + /** + * @param avmService the avmService to set. + */ + public void setAvmService(final AVMService avmService) + { + this.avmService = avmService; + } + + /** + * Provides data for a file picker widget. + */ + @InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_XML) + public void getFilePickerData() + throws Exception + { + final FacesContext facesContext = FacesContext.getCurrentInstance(); + final ExternalContext externalContext = facesContext.getExternalContext(); + + final Map requestParameters = externalContext.getRequestParameterMap(); + String currentPath = (String)requestParameters.get("currentPath"); + if (currentPath == null) + { + currentPath = this.getCurrentAVMPath(); + } + else + { + final String previewStorePath = + AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); + currentPath = AVMUtil.buildPath(previewStorePath, + currentPath, + AVMUtil.PathRelation.WEBAPP_RELATIVE); + } + LOGGER.debug(this + ".getFilePickerData(" + currentPath + ")"); + + final Document result = XMLUtil.newDocument(); + final Element filePickerDataElement = result.createElement("file-picker-data"); + result.appendChild(filePickerDataElement); + + + final AVMNodeDescriptor currentNode = this.avmService.lookup(-1, currentPath); + if (currentNode == null) + { + final Element errorElement = result.createElement("error"); + errorElement.appendChild(result.createTextNode("Path " + currentPath + " not found")); + filePickerDataElement.appendChild(errorElement); + currentPath = this.getCurrentAVMPath(); + } + else if (! currentNode.isDirectory()) + { + currentPath = AVMNodeConverter.SplitBase(currentPath)[0]; + } + + Element e = result.createElement("current-node"); + e.setAttribute("avmPath", currentPath); + e.setAttribute("webappRelativePath", + AVMUtil.getWebappRelativePath(currentPath)); + e.setAttribute("type", "directory"); + e.setAttribute("image", "/images/icons/space_small.gif"); + filePickerDataElement.appendChild(e); + + for (Map.Entry entry : + this.avmService.getDirectoryListing(-1, currentPath).entrySet()) + { + e = result.createElement("child-node"); + e.setAttribute("avmPath", entry.getValue().getPath()); + e.setAttribute("webappRelativePath", + AVMUtil.getWebappRelativePath(entry.getValue().getPath())); + e.setAttribute("type", entry.getValue().isDirectory() ? "directory" : "file"); + e.setAttribute("image", (entry.getValue().isDirectory() + ? "/images/icons/space_small.gif" + : Utils.getFileTypeImage(facesContext, + entry.getValue().getName(), + true))); + filePickerDataElement.appendChild(e); + } + + final ResponseWriter out = facesContext.getResponseWriter(); + XMLUtil.print(result, out); + out.close(); + } + + @InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML) + public void uploadFile() + throws Exception + { + LOGGER.debug(this + ".uploadFile()"); + final FacesContext facesContext = FacesContext.getCurrentInstance(); + final ExternalContext externalContext = facesContext.getExternalContext(); + final HttpServletRequest request = (HttpServletRequest) + externalContext.getRequest(); + + final ServletFileUpload upload = + new ServletFileUpload(new DiskFileItemFactory()); + upload.setHeaderEncoding("UTF-8"); + final List fileItems = upload.parseRequest(request); + final FileUploadBean bean = new FileUploadBean(); + String uploadId = null; + String currentPath = null; + String filename = null; + String returnPage = null; + InputStream fileInputStream = null; + for (FileItem item : fileItems) + { + LOGGER.debug("item = " + item); + if (item.isFormField() && item.getFieldName().equals("upload-id")) + { + uploadId = item.getString(); + LOGGER.debug("uploadId is " + uploadId); + } + if (item.isFormField() && item.getFieldName().equals("return-page")) + { + returnPage = item.getString(); + LOGGER.debug("returnPage is " + returnPage); + } + else if (item.isFormField() && item.getFieldName().equals("currentPath")) + { + final String previewStorePath = + AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); + currentPath = AVMUtil.buildPath(previewStorePath, + item.getString(), + AVMUtil.PathRelation.WEBAPP_RELATIVE); + LOGGER.debug("currentPath is " + currentPath); + } + else + { + filename = FilenameUtils.getName(item.getName()); + fileInputStream = item.getInputStream(); + LOGGER.debug("uploading file " + filename); + } + } + + LOGGER.debug("saving file " + filename + " to " + currentPath); + + try + { + FileCopyUtils.copy(fileInputStream, + this.avmService.createFile(currentPath, filename)); + final Map props = new HashMap(1, 1.0f); + props.put(ContentModel.PROP_TITLE, new PropertyValue(DataTypeDefinition.TEXT, filename)); +// props.put(ContentModel.PROP_DESCRIPTION, +// new PropertyValue(DataTypeDefinition.TEXT, +// "Uploaded for form " + this.xformsSession.getForm().getName())); + this.avmService.setNodeProperties(currentPath + "/" + filename, props); + this.avmService.addAspect(currentPath + "/" + filename, ContentModel.ASPECT_TITLED); + + this.uploads.add(AVMNodeConverter.ToNodeRef(-1, currentPath + "/" + filename)); + returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}", + Utils.getFileTypeImage(facesContext, filename, true)); + } + catch (Exception e) + { + LOGGER.debug(e.getMessage(), e); + returnPage = returnPage.replace("${_UPLOAD_ERROR}", e.getMessage()); + } + + LOGGER.debug("upload complete. sending response: " + returnPage); + final Document result = XMLUtil.newDocument(); + final Element htmlEl = result.createElement("html"); + result.appendChild(htmlEl); + final Element bodyEl = result.createElement("body"); + htmlEl.appendChild(bodyEl); + + final Element scriptEl = result.createElement("script"); + bodyEl.appendChild(scriptEl); + scriptEl.setAttribute("type", "text/javascript"); + final Node scriptText = result.createTextNode(returnPage); + scriptEl.appendChild(scriptText); + + final ResponseWriter out = facesContext.getResponseWriter(); + XMLUtil.print(result, out); + out.close(); + } + + private String getCurrentAVMPath() + { + AVMNode node = this.avmBrowseBean.getAvmActionNode(); + if (node == null) + { + return this.avmBrowseBean.getCurrentPath(); + } + + final String result = node.getPath(); + return node.isDirectory() ? result : AVMNodeConverter.SplitBase(result)[0]; + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/web/forms/FormProcessor.java b/source/java/org/alfresco/web/forms/FormProcessor.java index 38528bcc5b..17f4a01228 100644 --- a/source/java/org/alfresco/web/forms/FormProcessor.java +++ b/source/java/org/alfresco/web/forms/FormProcessor.java @@ -19,7 +19,8 @@ * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" */ + * http://www.alfresco.com/legal/licensing" + */ package org.alfresco.web.forms; import java.io.Serializable; @@ -45,7 +46,7 @@ public interface FormProcessor { /** Returns the set of file uploaded during the session. */ - public NodeRef[] getUploadedFiles(); +// public NodeRef[] getUploadedFiles(); /** Destroys the session and releases all resources used by it */ public void destroy(); diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java index 7aa9a976db..32aa3a38ed 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java @@ -19,7 +19,8 @@ * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" */ + * http://www.alfresco.com/legal/licensing" + */ package org.alfresco.web.forms.xforms; import java.io.*; @@ -108,7 +109,7 @@ public class XFormsBean private ChibaBean chibaBean; private final Schema2XForms schema2XForms; - private final Set uploads = new HashSet(); +// private final Set uploads = new HashSet(); private final List eventLog = new LinkedList(); public XFormsSession(final Document formInstanceData, @@ -124,19 +125,8 @@ public class XFormsBean baseUrl); } - public void addUpload(final NodeRef nr) - { - this.uploads.add(nr); - } - - public NodeRef[] getUploadedFiles() - { - return (NodeRef[])this.uploads.toArray(new NodeRef[0]); - } - public void destroy() { - this.uploads.clear(); try { this.chibaBean.shutdown(); @@ -171,7 +161,6 @@ public class XFormsBean private Schema2XFormsProperties schema2XFormsProperties; private AVMBrowseBean avmBrowseBean; private AVMService avmService; - private NodeService nodeService; public XFormsBean() { @@ -443,171 +432,6 @@ public class XFormsBean out.close(); } - /** - * Provides data for a file picker widget. - */ - @InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_XML) - public void getFilePickerData() - throws Exception - { - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final ExternalContext externalContext = facesContext.getExternalContext(); - - final Map requestParameters = externalContext.getRequestParameterMap(); - String currentPath = (String)requestParameters.get("currentPath"); - if (currentPath == null) - { - currentPath = this.getCurrentAVMPath(); - } - else - { - final String previewStorePath = - AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); - currentPath = AVMUtil.buildPath(previewStorePath, - currentPath, - AVMUtil.PathRelation.WEBAPP_RELATIVE); - } - LOGGER.debug(this + ".getFilePickerData(" + currentPath + ")"); - - final Document result = XMLUtil.newDocument(); - final Element filePickerDataElement = result.createElement("file-picker-data"); - result.appendChild(filePickerDataElement); - - - final AVMNodeDescriptor currentNode = this.avmService.lookup(-1, currentPath); - if (currentNode == null) - { - final Element errorElement = result.createElement("error"); - errorElement.appendChild(result.createTextNode("Path " + currentPath + " not found")); - filePickerDataElement.appendChild(errorElement); - currentPath = this.getCurrentAVMPath(); - } - else if (! currentNode.isDirectory()) - { - currentPath = AVMNodeConverter.SplitBase(currentPath)[0]; - } - - Element e = result.createElement("current-node"); - e.setAttribute("avmPath", currentPath); - e.setAttribute("webappRelativePath", - AVMUtil.getWebappRelativePath(currentPath)); - e.setAttribute("type", "directory"); - e.setAttribute("image", "/images/icons/space_small.gif"); - filePickerDataElement.appendChild(e); - - for (Map.Entry entry : - this.avmService.getDirectoryListing(-1, currentPath).entrySet()) - { - e = result.createElement("child-node"); - e.setAttribute("avmPath", entry.getValue().getPath()); - e.setAttribute("webappRelativePath", - AVMUtil.getWebappRelativePath(entry.getValue().getPath())); - e.setAttribute("type", entry.getValue().isDirectory() ? "directory" : "file"); - e.setAttribute("image", (entry.getValue().isDirectory() - ? "/images/icons/space_small.gif" - : Utils.getFileTypeImage(facesContext, - entry.getValue().getName(), - true))); - filePickerDataElement.appendChild(e); - } - - final ResponseWriter out = facesContext.getResponseWriter(); - XMLUtil.print(result, out); - out.close(); - } - - @InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML) - public void uploadFile() - throws Exception - { - LOGGER.debug(this + ".uploadFile()"); - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final ExternalContext externalContext = facesContext.getExternalContext(); - final HttpServletRequest request = (HttpServletRequest) - externalContext.getRequest(); - - final ServletFileUpload upload = - new ServletFileUpload(new DiskFileItemFactory()); - upload.setHeaderEncoding("UTF-8"); - final List fileItems = upload.parseRequest(request); - final FileUploadBean bean = new FileUploadBean(); - String uploadId = null; - String currentPath = null; - String filename = null; - String returnPage = null; - InputStream fileInputStream = null; - for (FileItem item : fileItems) - { - LOGGER.debug("item = " + item); - if (item.isFormField() && item.getFieldName().equals("upload-id")) - { - uploadId = item.getString(); - LOGGER.debug("uploadId is " + uploadId); - } - if (item.isFormField() && item.getFieldName().equals("return-page")) - { - returnPage = item.getString(); - LOGGER.debug("returnPage is " + returnPage); - } - else if (item.isFormField() && item.getFieldName().equals("currentPath")) - { - final String previewStorePath = - AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); - currentPath = AVMUtil.buildPath(previewStorePath, - item.getString(), - AVMUtil.PathRelation.WEBAPP_RELATIVE); - LOGGER.debug("currentPath is " + currentPath); - } - else - { - filename = FilenameUtils.getName(item.getName()); - fileInputStream = item.getInputStream(); - LOGGER.debug("uploading file " + filename); - } - } - - LOGGER.debug("saving file " + filename + " to " + currentPath); - - try - { - FileCopyUtils.copy(fileInputStream, - this.avmService.createFile(currentPath, filename)); - final Map props = new HashMap(2, 1.0f); - props.put(ContentModel.PROP_TITLE, new PropertyValue(DataTypeDefinition.TEXT, filename)); - props.put(ContentModel.PROP_DESCRIPTION, - new PropertyValue(DataTypeDefinition.TEXT, - "Uploaded for form " + this.xformsSession.getForm().getName())); - this.avmService.setNodeProperties(currentPath + "/" + filename, props); - this.avmService.addAspect(currentPath + "/" + filename, ContentModel.ASPECT_TITLED); - - this.xformsSession.addUpload(AVMNodeConverter.ToNodeRef(-1, currentPath + "/" + filename)); - returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}", - Utils.getFileTypeImage(facesContext, filename, true)); - } - catch (Exception e) - { - LOGGER.debug(e.getMessage(), e); - returnPage = returnPage.replace("${_UPLOAD_ERROR}", e.getMessage()); - } - - LOGGER.debug("upload complete. sending response: " + returnPage); - final Document result = XMLUtil.newDocument(); - final Element htmlEl = result.createElement("html"); - result.appendChild(htmlEl); - final Element bodyEl = result.createElement("body"); - htmlEl.appendChild(bodyEl); - - final Element scriptEl = result.createElement("script"); - bodyEl.appendChild(scriptEl); - scriptEl.setAttribute("type", "text/javascript"); - final Node scriptText = result.createTextNode(returnPage); - scriptEl.appendChild(scriptText); - - final ResponseWriter out = facesContext.getResponseWriter(); - XMLUtil.print(result, out); - out.close(); - } - private void swapRepeatItems(final RepeatItem from, final RepeatItem to) throws XFormsException diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java index a70f0a72e6..3b5147afc9 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java @@ -67,6 +67,7 @@ public class XFormsProcessor "/scripts/ajax/dojo/" + (LOGGER.isDebugEnabled() ? "dojo.js.uncompressed.js" : "dojo.js"), + "/scripts/ajax/common.js", "/scripts/ajax/ajax_helper.js", "/scripts/ajax/tiny_mce_wcm_extensions.js", "/scripts/ajax/xforms.js", @@ -79,12 +80,14 @@ public class XFormsProcessor { "add_content", "cancel", + "change", "click_to_edit", "eg", "go_up", "idle", "loading", "path", + "select", "upload", "validation_provide_values_for_required_fields" }; diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 36ad1c4caa..0b725ca936 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -2238,6 +2238,10 @@ avmBrowseBean #{AVMBrowseBean} + + filePickerBean + #{FilePickerBean} + @@ -2456,6 +2460,10 @@ nodeService #{NodeService} + + filePickerBean + #{FilePickerBean} + @@ -3297,6 +3305,23 @@ #{Schema2XFormsProperties} + + + + Bean that returns information on a node + + FilePickerBean + org.alfresco.web.bean.wcm.FilePickerBean + session + + avmService + #{AVMService} + + + avmBrowseBean + #{AVMBrowseBean} + + diff --git a/source/web/css/xforms.css b/source/web/css/xforms.css index 65287c417b..0a150c21d6 100644 --- a/source/web/css/xforms.css +++ b/source/web/css/xforms.css @@ -219,6 +219,7 @@ .xformsFilePickerFileList { + position: relative; overflow-y: auto; background-color: white; border-left: 1px solid #67a4e6; diff --git a/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp b/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp index 63d6488322..71d2dfd39c 100644 --- a/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp +++ b/source/web/jsp/wcm/create-web-content-wizard/create-html.jsp @@ -35,21 +35,17 @@ - - - - - - + + +
diff --git a/source/web/jsp/wcm/create-web-content-wizard/details.jsp b/source/web/jsp/wcm/create-web-content-wizard/details.jsp index f9745c111e..99d081c6ac 100644 --- a/source/web/jsp/wcm/create-web-content-wizard/details.jsp +++ b/source/web/jsp/wcm/create-web-content-wizard/details.jsp @@ -20,7 +20,7 @@ * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" + * http://www.alfresco.com/legal/licensing --%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> @@ -71,6 +71,10 @@ } } + function mimeTypeChanged(event) + { + alert(event.target.id); + } @@ -96,7 +100,8 @@ + valueChangeListener="#{WizardManager.bean.createContentChanged}" + onchange="mimeTypeChanged"> diff --git a/source/web/jsp/wcm/tiny_mce_image_dialog.jsp b/source/web/jsp/wcm/tiny_mce_image_dialog.jsp index d081e7fd30..5739a72549 100644 --- a/source/web/jsp/wcm/tiny_mce_image_dialog.jsp +++ b/source/web/jsp/wcm/tiny_mce_image_dialog.jsp @@ -36,49 +36,71 @@ - {$lang_insert_image_title} - - - - -   + {$lang_insert_image_title} +   + + + + + + + + + + - + setTimeout("loadPicker();", 500); + - +
    @@ -91,29 +113,17 @@ - + diff --git a/source/web/jsp/wcm/tiny_mce_link_dialog.jsp b/source/web/jsp/wcm/tiny_mce_link_dialog.jsp index 1344c0d137..9d7ee47a85 100644 --- a/source/web/jsp/wcm/tiny_mce_link_dialog.jsp +++ b/source/web/jsp/wcm/tiny_mce_link_dialog.jsp @@ -37,50 +37,68 @@ {$lang_insert_link_title} - - - - - - - -   +   + + + + + + + + + + - +
      @@ -93,24 +111,11 @@
    - - - - - - - - - -
    - - - -  
    -
    -
    +
    + +
    - +
    - - - - - - - - - -
    - - - -  
    -
    -
    +
    + +