diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index a34cc2fc72..3c0f76b7ac 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -845,6 +845,7 @@ create_web_content_title=Create Web Content Wizard create_web_content_desc=This wizard helps you to create a new content item for a website. create_folder=Create Folder create_avm_folder_info=Create a new folder in the website. +add_avm_content_dialog_desc=This dialog helps you to add content to a folder. # New User Wizard messages new_user_title=New User Wizard diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index b76762dc66..19eab743a0 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -75,6 +75,14 @@ dialog:createAvmFolder + + + add_content + /images/icons/add.gif + addAvmContent + #{AddAvmContentDialog.start} + + @@ -117,10 +125,16 @@ false + + + + false + + diff --git a/source/java/org/alfresco/web/bean/content/BaseContentWizard.java b/source/java/org/alfresco/web/bean/content/BaseContentWizard.java index 426462f1c1..3f2e003940 100644 --- a/source/java/org/alfresco/web/bean/content/BaseContentWizard.java +++ b/source/java/org/alfresco/web/bean/content/BaseContentWizard.java @@ -53,7 +53,8 @@ public abstract class BaseContentWizard extends BaseWizardBean protected List objectTypes; protected ContentService contentService; - private static Log logger = LogFactory.getLog(BaseContentWizard.class); + protected static Log logger = LogFactory.getLog(BaseContentWizard.class); + // ------------------------------------------------------------------------------ // Wizard implementation diff --git a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java new file mode 100644 index 0000000000..d51a0b4fa9 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * 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. + */ +package org.alfresco.web.bean.wcm; + +import java.io.File; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.faces.context.FacesContext; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.repository.ContentWriter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.web.app.AlfrescoNavigationHandler; +import org.alfresco.web.bean.content.AddContentDialog; + +/** + * Add/upload content dialog for AVM browse screens. + * + * @author Kevin Roast + */ +public class AddAvmContentDialog extends AddContentDialog +{ + /** The AVMService bean reference */ + protected AVMService avmService; + + /** AVM Browse Bean reference */ + protected AVMBrowseBean avmBrowseBean; + + + /** + * @param avmService The AVMService to set. + */ + public void setAvmService(AVMService avmService) + { + this.avmService = avmService; + } + + /** + * @param avmBrowseBean The AVMBrowseBean to set. + */ + public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + /** + * Save the specified content using the currently set wizard attributes + * + * @param fileContent File content to save + * @param strContent String content to save + */ + protected void saveContent(File fileContent, String strContent) throws Exception + { + // get the AVM path that will contain the content + String parent = this.avmBrowseBean.getCurrentPath(); + + // create the file + this.avmService.createFile(parent, this.fileName); + String path = parent + '/' + this.fileName; + NodeRef fileNodeRef = AVMNodeConverter.ToNodeRef(-1, path); + + if (logger.isDebugEnabled()) + logger.debug("Created AVM file: " + path); + + // set the author aspect + Map authorProps = new HashMap(1, 1.0f); + authorProps.put(ContentModel.PROP_AUTHOR, this.author); + this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_AUTHOR, authorProps); + + // apply the titled aspect - title and description + Map titledProps = new HashMap(2, 1.0f); + titledProps.put(ContentModel.PROP_TITLE, this.title); + titledProps.put(ContentModel.PROP_DESCRIPTION, this.description); + this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_TITLED, titledProps); + + // get a writer for the content and put the file + ContentWriter writer = contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); + writer.setMimetype(this.mimeType); + writer.setEncoding("UTF-8"); + if (fileContent != null) + { + writer.putContent(fileContent); + } + else + { + writer.putContent(strContent == null ? "" : strContent); + } + + // remember the created node now + this.createdNode = fileNodeRef; + } + + /** + * @see org.alfresco.web.bean.content.AddContentDialog#doPostCommitProcessing(javax.faces.context.FacesContext, java.lang.String) + */ + @Override + protected String doPostCommitProcessing(FacesContext context, String outcome) + { + clearUpload(); + + return outcome; + } + + /** + * @see org.alfresco.web.bean.content.AddContentDialog#getDefaultFinishOutcome() + */ + @Override + protected String getDefaultFinishOutcome() + { + return "cancel"; + } +} diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java index 350a8d1e52..a760e436e5 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -329,7 +329,7 @@ public class UIUserSandboxes extends SelfRenderingComponent // info we need to calculate preview paths for assets String dns = AVMConstants.lookupStoreDNS(userStorePrefix); - int rootPathIndex = AVMConstants.buildAVMStoreRootPath(userStorePrefix).length() + 1; + int rootPathIndex = AVMConstants.buildAVMStoreRootPath(userStorePrefix).length(); ClientConfigElement config = Application.getClientConfig(fc); // get the UIActions component responsible for rendering context related user actions diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 3b8b864840..afbcb8a6c8 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -783,6 +783,35 @@ + + + The bean that backs up the AVM Add Content Dialog + + AddAvmContentDialog + org.alfresco.web.bean.wcm.AddAvmContentDialog + session + + nodeService + #{NodeService} + + + contentService + #{ContentService} + + + dictionaryService + #{DictionaryService} + + + avmService + #{AVMService} + + + avmBrowseBean + #{AVMBrowseBean} + + + The bean that backs up the Set Content Properties Dialog diff --git a/source/web/WEB-INF/faces-config-navigation.xml b/source/web/WEB-INF/faces-config-navigation.xml index fbdea1e6b5..27c336f612 100644 --- a/source/web/WEB-INF/faces-config-navigation.xml +++ b/source/web/WEB-INF/faces-config-navigation.xml @@ -876,6 +876,10 @@ importContent /jsp/wcm/import-content-dialog.jsp + + addAvmContent + /jsp/wcm/add-content-dialog.jsp + browseSandbox /jsp/wcm/browse-sandbox.jsp @@ -896,6 +900,10 @@ editAvmXmlInline /jsp/wcm/edit-xml-inline.jsp + + cancel + /jsp/wcm/browse-sandbox.jsp + diff --git a/source/web/jsp/wcm/add-content-dialog.jsp b/source/web/jsp/wcm/add-content-dialog.jsp new file mode 100644 index 0000000000..7de39f4395 --- /dev/null +++ b/source/web/jsp/wcm/add-content-dialog.jsp @@ -0,0 +1,303 @@ +<%-- + Copyright (C) 2005 Alfresco, Inc. + + Licensed under the Mozilla Public License version 1.1 + with a permitted attribution clause. You may obtain a + copy of the License at + + http://www.alfresco.org/legal/license.txt + + 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. +--%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + +<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %> +<%@ page isELIgnored="false" %> +<%@ page import="javax.faces.context.FacesContext" %> +<%@ page import="org.alfresco.web.app.Application" %> +<%@ page import="org.alfresco.web.bean.wcm.AddAvmContentDialog" %> +<%@ page import="org.alfresco.web.app.servlet.FacesHelper" %> +<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> + +<% +boolean fileUploaded = false; + +AddAvmContentDialog dialog = (AddAvmContentDialog)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddAvmContentDialog"); +if (dialog != null && dialog.getFileName() != null) +{ + fileUploaded = true; +} +%> + + + + + + + + <%-- load a bundle of properties with I18N strings --%> + + + + + <%-- Main outer table --%> + + + <%-- Title bar --%> + + + <%@ include file="../parts/titlebar.jsp" %> + + + + <%-- Main area --%> + + <%-- Shelf --%> + + <%@ include file="../parts/shelf.jsp" %> + + + <%-- Work Area --%> + + + <%-- Breadcrumb --%> + <%@ include file="../parts/breadcrumb.jsp" %> + + <%-- Status and Actions --%> + + + + + <%-- Status and Actions inner contents table --%> + <%-- Generally this consists of an icon, textual summary and actions for the current object --%> + + + + + + + + + + + + + + + + + <%-- separator row with gradient shadow --%> + + + + + + + + + <%-- Details --%> + + + + + + + + + + <% + if (fileUploaded) + { + PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc"); + out.write(" "); + out.write(dialog.getFileUploadSuccessMsg()); + PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner"); + out.write(""); + } + %> + + <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %> + + + <% if (fileUploaded == false) { %> + + + + + + + + + + + + + + + + + + + + + 2. <%=Application.getMessage(FacesContext.getCurrentInstance(), "click_upload")%> + + + + + " /> + + + + <% } %> + + + <% if (fileUploaded) { %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% } %> + + + <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %> + + + + <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> + + + + + + + + + + + + + <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> + + + + + + + + <%-- separator row with bottom panel graphics --%> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/web/jsp/wcm/browse-sandbox.jsp b/source/web/jsp/wcm/browse-sandbox.jsp index cad6d528cb..b99bc0f883 100644 --- a/source/web/jsp/wcm/browse-sandbox.jsp +++ b/source/web/jsp/wcm/browse-sandbox.jsp @@ -77,12 +77,18 @@ - + <%-- Create actions menu --%> + + <%-- More actions menu --%> + + + +