- Add Content (upload) action implemented for website browsing screen

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3960 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-28 12:12:00 +00:00
parent 842729f1bc
commit 0f3f56e7d8
9 changed files with 496 additions and 3 deletions

View File

@@ -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_web_content_desc=This wizard helps you to create a new content item for a website.
create_folder=Create Folder create_folder=Create Folder
create_avm_folder_info=Create a new folder in the website. 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 Wizard messages
new_user_title=New User Wizard new_user_title=New User Wizard

View File

@@ -75,6 +75,14 @@
<action>dialog:createAvmFolder</action> <action>dialog:createAvmFolder</action>
</action> </action>
<!-- Upload Content -->
<action id="add_content">
<label-id>add_content</label-id>
<image>/images/icons/add.gif</image>
<action>addAvmContent</action>
<action-listener>#{AddAvmContentDialog.start}</action-listener>
</action>
<!-- Actions for a document in the AVM Browse screen --> <!-- Actions for a document in the AVM Browse screen -->
<action-group id="avm_file_browse"> <action-group id="avm_file_browse">
@@ -117,10 +125,16 @@
<!-- Actions for the Create menu in the sandbox browse screen --> <!-- Actions for the Create menu in the sandbox browse screen -->
<action-group id="avm_create_menu"> <action-group id="avm_create_menu">
<show-link>false</show-link> <show-link>false</show-link>
<action idref="add_content" />
<action idref="create_content" /> <action idref="create_content" />
<action idref="create_folder" /> <action idref="create_folder" />
</action-group> </action-group>
<!-- Actions for the More Actions menu in the sandbox browse screen -->
<action-group id="avm_more_menu">
<show-link>false</show-link>
</action-group>
</actions> </actions>
</config> </config>

View File

@@ -53,7 +53,8 @@ public abstract class BaseContentWizard extends BaseWizardBean
protected List<SelectItem> objectTypes; protected List<SelectItem> objectTypes;
protected ContentService contentService; protected ContentService contentService;
private static Log logger = LogFactory.getLog(BaseContentWizard.class); protected static Log logger = LogFactory.getLog(BaseContentWizard.class);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Wizard implementation // Wizard implementation

View File

@@ -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<QName, Serializable> authorProps = new HashMap<QName, Serializable>(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<QName, Serializable> titledProps = new HashMap<QName, Serializable>(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";
}
}

View File

@@ -329,7 +329,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
// info we need to calculate preview paths for assets // info we need to calculate preview paths for assets
String dns = AVMConstants.lookupStoreDNS(userStorePrefix); String dns = AVMConstants.lookupStoreDNS(userStorePrefix);
int rootPathIndex = AVMConstants.buildAVMStoreRootPath(userStorePrefix).length() + 1; int rootPathIndex = AVMConstants.buildAVMStoreRootPath(userStorePrefix).length();
ClientConfigElement config = Application.getClientConfig(fc); ClientConfigElement config = Application.getClientConfig(fc);
// get the UIActions component responsible for rendering context related user actions // get the UIActions component responsible for rendering context related user actions

View File

@@ -783,6 +783,35 @@
</managed-property> </managed-property>
</managed-bean> </managed-bean>
<managed-bean>
<description>
The bean that backs up the AVM Add Content Dialog
</description>
<managed-bean-name>AddAvmContentDialog</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.wcm.AddAvmContentDialog</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>contentService</property-name>
<value>#{ContentService}</value>
</managed-property>
<managed-property>
<property-name>dictionaryService</property-name>
<value>#{DictionaryService}</value>
</managed-property>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMService}</value>
</managed-property>
<managed-property>
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
</managed-bean>
<managed-bean> <managed-bean>
<description> <description>
The bean that backs up the Set Content Properties Dialog The bean that backs up the Set Content Properties Dialog

View File

@@ -876,6 +876,10 @@
<from-outcome>importContent</from-outcome> <from-outcome>importContent</from-outcome>
<to-view-id>/jsp/wcm/import-content-dialog.jsp</to-view-id> <to-view-id>/jsp/wcm/import-content-dialog.jsp</to-view-id>
</navigation-case> </navigation-case>
<navigation-case>
<from-outcome>addAvmContent</from-outcome>
<to-view-id>/jsp/wcm/add-content-dialog.jsp</to-view-id>
</navigation-case>
<navigation-case> <navigation-case>
<from-outcome>browseSandbox</from-outcome> <from-outcome>browseSandbox</from-outcome>
<to-view-id>/jsp/wcm/browse-sandbox.jsp</to-view-id> <to-view-id>/jsp/wcm/browse-sandbox.jsp</to-view-id>
@@ -896,6 +900,10 @@
<from-outcome>editAvmXmlInline</from-outcome> <from-outcome>editAvmXmlInline</from-outcome>
<to-view-id>/jsp/wcm/edit-xml-inline.jsp</to-view-id> <to-view-id>/jsp/wcm/edit-xml-inline.jsp</to-view-id>
</navigation-case> </navigation-case>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/jsp/wcm/browse-sandbox.jsp</to-view-id>
</navigation-case>
</navigation-rule> </navigation-rule>
</faces-config> </faces-config>

View File

@@ -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;
}
%>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/validation.js"> </script>
<r:page titleId="title_add_content">
<f:view>
<%-- load a bundle of properties with I18N strings --%>
<f:loadBundle basename="alfresco.messages.webclient" var="msg"/>
<h:form acceptCharset="UTF-8" id="add-content-upload-start">
<%-- Main outer table --%>
<table cellspacing="0" cellpadding="2">
<%-- Title bar --%>
<tr>
<td colspan="2">
<%@ include file="../parts/titlebar.jsp" %>
</td>
</tr>
<%-- Main area --%>
<tr valign="top">
<%-- Shelf --%>
<td>
<%@ include file="../parts/shelf.jsp" %>
</td>
<%-- Work Area --%>
<td width="100%">
<table cellspacing="0" cellpadding="0" width="100%">
<%-- Breadcrumb --%>
<%@ include file="../parts/breadcrumb.jsp" %>
<%-- Status and Actions --%>
<tr>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_4.gif)" width="4"></td>
<td bgcolor="#EEEEEE">
<%-- Status and Actions inner contents table --%>
<%-- Generally this consists of an icon, textual summary and actions for the current object --%>
<table cellspacing="4" cellpadding="0" width="100%">
<tr>
<td width="32">
<h:graphicImage id="dialog-logo" url="/images/icons/add_content_large.gif" />
</td>
<td>
<div class="mainTitle"><h:outputText value="#{msg.add_content_dialog_title}" /></div>
<div class="mainSubText"><h:outputText value="#{msg.add_avm_content_dialog_desc}" /></div>
</td>
</tr>
</table>
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_6.gif)" width="4"></td>
</tr>
<%-- separator row with gradient shadow --%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_7.gif" width="4" height="9"></td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_9.gif" width="4" height="9"></td>
</tr>
</h:form>
<%-- Details --%>
<tr valign=top>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width="4"></td>
<td>
<table cellspacing="0" cellpadding="3" border="0" width="100%">
<tr>
<td width="100%" valign="top">
<a:errors message="#{msg.error_dialog}" styleClass="errorMessage" />
<%
if (fileUploaded)
{
PanelGenerator.generatePanelStart(out, request.getContextPath(), "yellowInner", "#ffffcc");
out.write("<img alt='' align='absmiddle' src='");
out.write(request.getContextPath());
out.write("/images/icons/info_icon.gif' />&nbsp;&nbsp;");
out.write(dialog.getFileUploadSuccessMsg());
PanelGenerator.generatePanelEnd(out, request.getContextPath(), "yellowInner");
out.write("<div style='padding:2px;'></div>");
}
%>
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<% if (fileUploaded == false) { %>
<tr>
<td colspan="3" class="wizardSectionHeading"><h:outputText value="#{msg.upload_content}"/></td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td class="mainSubText" colspan="3">
<h:outputText id="text1" value="1. #{msg.locate_content}"/>
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
<r:uploadForm>
<tr>
<td colspan="3">
<input style="margin-left:12px;" type="file" size="75" name="alfFileInput"/>
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td class="mainSubText" colspan="3">
2. <%=Application.getMessage(FacesContext.getCurrentInstance(), "click_upload")%>
</td>
</tr>
<tr>
<td colspan="3">
<input style="margin-left:12px;" type="submit" value="<%=Application.getMessage(FacesContext.getCurrentInstance(), "upload")%>" />
</td>
</tr>
</r:uploadForm>
<% } %>
<h:form acceptCharset="UTF-8" id="add-content-upload-end" onsubmit="return validate();">
<% if (fileUploaded) { %>
<tr>
<td colspan="3">
<table border="0" cellspacing="2" cellpadding="2" class="selectedItems">
<tr>
<td colspan="2" class="selectedItemsHeader">
<h:outputText id="text2" value="#{msg.uploaded_content}" />
</th>
</tr>
<tr>
<td class="selectedItemsRow">
<h:outputText id="text3" value="#{AddAvmContentDialog.fileName}" />
</td>
<td>
<a:actionLink image="/images/icons/delete.gif" value="#{msg.remove}"
action="#{AddAvmContentDialog.removeUploadedFile}"
showLink="false" id="link1" />
</td>
</tr>
</table>
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td colspan="3" class="wizardSectionHeading">
&nbsp;<h:outputText id="text4" value="#{msg.general_properties}" />
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td align="middle">
<h:graphicImage value="/images/icons/required_field.gif" alt="Required Field" />
</td>
<td>
<h:outputText id="text5" value="#{msg.name}:" />
</td>
<td width="85%">
<h:inputText id="file-name" value="#{AddAvmContentDialog.fileName}"
maxlength="1024" size="35"
onkeyup="checkButtonState();"
onchange="checkButtonState();" />
</td>
</tr>
<tr>
<td></td>
<td>
<h:outputText id="text7" value="#{msg.content_type}:" />
</td>
<td>
<r:mimeTypeSelector id="mime-type" value="#{AddAvmContentDialog.mimeType}" />
</td>
</tr>
<% } %>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>
</td>
<td valign="top">
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %>
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="center">
<h:commandButton id="finish-button" styleClass="wizardButton"
value="#{msg.ok}"
action="#{AddAvmContentDialog.finish}"
disabled="#{AddAvmContentDialog.finishButtonDisabled}" />
</td>
</tr>
<tr>
<td align="center">
<h:commandButton id="cancel-button" styleClass="wizardButton"
value="#{msg.cancel}"
action="#{AddAvmContentDialog.cancel}" />
</td>
</tr>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>
</td>
</tr>
</table>
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_6.gif)" width="4"></td>
</tr>
<%-- separator row with bottom panel graphics --%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_7.gif" width="4" height="4"></td>
<td width="100%" align="center" style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_9.gif" width="4" height="4"></td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
var finishButtonPressed = false;
window.onload = pageLoaded;
function pageLoaded()
{
document.getElementById("add-content-upload-end:finish-button").onclick = function() {finishButtonPressed = true; clear_add_2Dcontent_2Dupload_2Dend();}
}
function checkButtonState()
{
if (document.getElementById("add-content-upload-end:file-name").value.length == 0 )
{
document.getElementById("add-content-upload-end:finish-button").disabled = true;
}
else
{
document.getElementById("add-content-upload-end:finish-button").disabled = false;
}
}
function validate()
{
if (finishButtonPressed)
{
finishButtonPressed = false;
return validateName(document.getElementById("add-content-upload-end:file-name"),
'<a:outputText id="text11" value="#{msg.validation_invalid_character}" />', true);
}
else
{
return true;
}
}
</script>
</h:form>
</f:view>
</r:page>

View File

@@ -77,12 +77,18 @@
<td align=right> <td align=right>
<a:actionLink value="#{msg.sandbox_preview}" image="/images/icons/preview_website.gif" href="#{AVMBrowseBean.sandboxPreviewUrl}" target="new" /> <a:actionLink value="#{msg.sandbox_preview}" image="/images/icons/preview_website.gif" href="#{AVMBrowseBean.sandboxPreviewUrl}" target="new" />
</td> </td>
<td width=80 style="padding-left:4px"> <td style="padding-left:4px" width=52>
<%-- Create actions menu --%> <%-- Create actions menu --%>
<a:menu id="createMenu" itemSpacing="4" label="#{msg.create_options}" image="/images/icons/menu.gif" menuStyleClass="moreActionsMenu" style="white-space:nowrap"> <a:menu id="createMenu" itemSpacing="4" label="#{msg.create_options}" image="/images/icons/menu.gif" menuStyleClass="moreActionsMenu" style="white-space:nowrap">
<r:actions id="acts_create" value="avm_create_menu" context="#{AVMBrowseBean.avmNode}" /> <r:actions id="acts_create" value="avm_create_menu" context="#{AVMBrowseBean.avmNode}" />
</a:menu> </a:menu>
</td> </td>
<td style="padding-left:4px" width=80>
<%-- More actions menu --%>
<a:menu id="actionsMenu" itemSpacing="4" label="#{msg.more_actions}" image="/images/icons/menu.gif" menuStyleClass="moreActionsMenu" style="white-space:nowrap">
<r:actions id="acts_more" value="avm_more_menu" context="#{AVMBrowseBean.avmNode}" />
</a:menu>
</td>
</tr> </tr>
</table> </table>