diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index cf6bee8e12..b712edd362 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -797,6 +797,15 @@ title_browse_website=Browse Website Sandboxes website_info=Use this view to browse the staging area and user sandboxes for a website. staging_sandbox=Staging Sandbox user_sandboxes=User Sandboxes +sandbox_preview=Preview Website +sandbox_create=Create New Content +sandbox_browse=Browse Website +import_website_content=Import Website Content + +# Website actions and dialog messages +title_import_content=Import Content into Website +import_website_content_title=Import Content into Website +import_website_content_desc=Use this dialog to import an archive of content into the root of the website. # New User Wizard messages new_user_title=New User Wizard diff --git a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java new file mode 100644 index 0000000000..982c28ccdb --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java @@ -0,0 +1,188 @@ +/* + * 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.text.MessageFormat; + +import javax.faces.context.FacesContext; +import javax.faces.event.ActionEvent; +import javax.transaction.UserTransaction; + +import org.alfresco.web.app.AlfrescoNavigationHandler; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.FileUploadBean; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.ui.common.Utils; + +/** + * @author Kevin Roast + */ +public class ImportWebsiteDialog +{ + protected File file; + protected String fileName; + private boolean isFinished = false; + + + /** + * @return Returns the name of the file + */ + public String getFileName() + { + // try and retrieve the file and filename from the file upload bean + // representing the file we previously uploaded. + FacesContext ctx = FacesContext.getCurrentInstance(); + FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap(). + get(FileUploadBean.FILE_UPLOAD_BEAN_NAME); + if (fileBean != null) + { + this.file = fileBean.getFile(); + this.fileName = fileBean.getFileName(); + } + + return this.fileName; + } + + /** + * @param fileName The name of the file + */ + public void setFileName(String fileName) + { + this.fileName = fileName; + + // we also need to keep the file upload bean in sync + FacesContext ctx = FacesContext.getCurrentInstance(); + FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap(). + get(FileUploadBean.FILE_UPLOAD_BEAN_NAME); + if (fileBean != null) + { + fileBean.setFileName(this.fileName); + } + } + + public boolean getFinishButtonDisabled() + { + return (this.fileName == null || this.fileName.length() == 0); + } + + + // ------------------------------------------------------------------------------ + // Action event handlers + + /** + * Action listener called when the add content dialog is called + */ + public void start(ActionEvent event) + { + clearUpload(); + this.fileName = null; + } + + /** + * Action handler called when the Finish button is pressed + */ + public String finish() + { + String outcome = null; + + // check the isFinished flag to stop the finish button + // being pressed multiple times + if (this.isFinished == false) + { + this.isFinished = true; + + UserTransaction tx = null; + + try + { + FacesContext context = FacesContext.getCurrentInstance(); + tx = Repository.getUserTransaction(context); + tx.begin(); + + // + // TODO: import the content + // + + tx.commit(); + + outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; + } + catch (Throwable e) + { + // rollback the transaction + try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + Utils.addErrorMessage(MessageFormat.format( + Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), + e.getMessage(), e)); + } + finally + { + // reset the flag so we can re-attempt the operation + this.isFinished = false; + } + } + + return outcome; + } + + /** + * Action handler called when the user wishes to remove an uploaded file + */ + public String removeUploadedFile() + { + clearUpload(); + + // also clear the file name + this.fileName = null; + + // refresh the current page + return null; + } + + /** + * Action handler called when the dialog is cancelled + */ + public String cancel() + { + clearUpload(); + + return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; + } + + + // ------------------------------------------------------------------------------ + // Helper Methods + + /** + * Deletes the uploaded file and removes the FileUploadBean from the session + */ + protected void clearUpload() + { + // delete the temporary file we uploaded earlier + if (this.file != null) + { + this.file.delete(); + } + + this.file = null; + + // remove the file upload bean from the session + FacesContext ctx = FacesContext.getCurrentInstance(); + ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME); + } +} diff --git a/source/java/org/alfresco/web/ui/repo/component/UIActions.java b/source/java/org/alfresco/web/ui/repo/component/UIActions.java index dcebb9290c..2fa792385a 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIActions.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIActions.java @@ -64,10 +64,11 @@ public class UIActions extends SelfRenderingComponent private static final String ATTR_STYLECLASS = "styleClass"; private static final String ATTR_STYLE = "style"; private static final String ACTION_CONTEXT = "actionContext"; - private static final String RENDERER_ACTIONLINK = "org.alfresco.faces.ActionLinkRenderer"; - private static final String COMPONENT_ACTIONLINK = "org.alfresco.faces.ActionLink"; - private static final String COMPONENT_PERMISSIONEVAL = "org.alfresco.faces.PermissionEvaluator"; - private static final String COMPONENT_ACTIONEVAL = "org.alfresco.faces.ActionInstanceEvaluator"; + + public static final String RENDERER_ACTIONLINK = "org.alfresco.faces.ActionLinkRenderer"; + public static final String COMPONENT_ACTIONLINK = "org.alfresco.faces.ActionLink"; + public static final String COMPONENT_PERMISSIONEVAL = "org.alfresco.faces.PermissionEvaluator"; + public static final String COMPONENT_ACTIONEVAL = "org.alfresco.faces.ActionInstanceEvaluator"; private final static Class ACTION_CLASS_ARGS[] = {javax.faces.event.ActionEvent.class}; 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 32ffefd925..3cb23cce00 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -19,8 +19,10 @@ package org.alfresco.web.ui.wcm.component; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.ResourceBundle; import java.util.Set; import javax.faces.component.NamingContainer; @@ -42,15 +44,23 @@ import org.alfresco.web.bean.wcm.AVMConstants; import org.alfresco.web.ui.common.PanelGenerator; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.SelfRenderingComponent; +import org.alfresco.web.ui.common.component.UIActionLink; +import org.alfresco.web.ui.repo.component.UIActions; import org.alfresco.web.ui.wcm.WebResources; import org.springframework.web.jsf.FacesContextUtils; +import sun.swing.UIAction; + /** * @author Kevin Roast */ public class UIUserSandboxes extends SelfRenderingComponent { private static final String MSG_USERNAME = "username"; + private static final String MSG_NAME = "name"; + private static final String MSG_DESCRIPTION = "description"; + private static final String MSG_MODIFIED = "modified_date"; + private static final String MSG_ACTIONS = "actions"; /** website to show sandboxes for */ private NodeRef value; @@ -87,6 +97,22 @@ public class UIUserSandboxes extends SelfRenderingComponent values[2] = this.expandedPanels; return values; } + + /** + * @see javax.faces.component.UIComponentBase#getRendersChildren() + */ + public boolean getRendersChildren() + { + return true; + } + + /** + * @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext) + */ + public void encodeChildren(FacesContext context) throws IOException + { + // the child components are rendered explicitly during the encodeBegin() + } /** * @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext) @@ -127,11 +153,7 @@ public class UIUserSandboxes extends SelfRenderingComponent ResponseWriter out = context.getResponseWriter(); - if (getChildCount() == 0) - { - // create any sub-component for the first time - } - + ResourceBundle bundle = Application.getBundle(context); AVMService avmService = getAVMService(context); NodeService nodeService = getNodeService(context); UserTransaction tx = null; @@ -153,45 +175,92 @@ public class UIUserSandboxes extends SelfRenderingComponent { String username = users.get(i); + // build the name of the main store for the user String mainStore = storeRoot + '-' + username + AVMConstants.STORE_MAIN; - AVMStoreDescriptor store = avmService.getAVMStore(mainStore); - // for each user sandbox, generate an outer panel table - PanelGenerator.generatePanelStart(out, - context.getExternalContext().getRequestContextPath(), - "white", - "white"); - - // components for the current username, preview, browse and modified items inner list - out.write(""); - // modified items panel - out.write("
"); - out.write(Utils.buildImageTag(context, WebResources.IMAGE_SANDBOX_32, 32, 32, "")); - out.write(""); - out.write(""); - out.write(Application.getMessage(context, MSG_USERNAME)); - out.write(": "); - out.write(username); // TODO: convert to full name - out.write(""); - // direct actions for a sandbox - // TODO: add actions for a sandbox - out.write("(Preview) (Create) (Browse)"); - out.write("
"); - String panelImage = this.expandedPanels.contains(username) ? WebResources.IMAGE_EXPANDED : WebResources.IMAGE_COLLAPSED; - out.write(Utils.buildImageTag(context, panelImage, 11, 11, "", - Utils.generateFormSubmit(context, this, getClientId(context), username))); - out.write(" Modified Items (3)"); - out.write("
"); - - // end the outer panel for this sandbox - PanelGenerator.generatePanelEnd(out, - context.getExternalContext().getRequestContextPath(), - "white"); - - // spacer row - if (i < users.size() - 1) + // check it exists before we render the view + if (avmService.getAVMStore(mainStore) != null) { - out.write("
"); + // for each user sandbox, generate an outer panel table + PanelGenerator.generatePanelStart(out, + context.getExternalContext().getRequestContextPath(), + "white", + "white"); + + // components for the current username, preview, browse and modified items inner list + out.write(""); + + // modified items panel + out.write("
"); + out.write(Utils.buildImageTag(context, WebResources.IMAGE_SANDBOX_32, 32, 32, "")); + out.write(""); + out.write(""); + out.write(bundle.getString(MSG_USERNAME)); + out.write(": "); + out.write(username); // TODO: convert to full name? + out.write(""); + + // direct actions for a sandbox + Utils.encodeRecursive(context, aquireAction( + context, "sandbox_preview", "/images/icons/preview_website.gif")); + out.write("  "); + Utils.encodeRecursive(context, aquireAction( + context, "sandbox_create", "/images/icons/new_content.gif")); + out.write("  "); + Utils.encodeRecursive(context, aquireAction( + context, "sandbox_browse", "/images/icons/space_small.gif")); + out.write("
"); + String panelImage = WebResources.IMAGE_COLLAPSED; + if (this.expandedPanels.contains(username)) + { + panelImage = WebResources.IMAGE_EXPANDED; + } + out.write(Utils.buildImageTag(context, panelImage, 11, 11, "", + Utils.generateFormSubmit(context, this, getClientId(context), username))); + out.write(" Modified Items (3)"); + if (this.expandedPanels.contains(username)) + { + out.write("
"); + out.write(""); + + // header row + out.write(""); + + // row per modified doc item + // TODO: add modified items list for this sandbox user + out.write(""); + + out.write("
"); + out.write(bundle.getString(MSG_NAME)); + out.write(""); + out.write(bundle.getString(MSG_DESCRIPTION)); + out.write(""); + out.write(bundle.getString(MSG_MODIFIED)); + out.write(""); + out.write(bundle.getString(MSG_ACTIONS)); + out.write("
(O)"); + out.write("Some document.html"); + out.write(""); + out.write("A description would go here"); + out.write(""); + out.write("01-01-2006 11:58am"); + out.write(""); + // TODO: add UI actions for this item + out.write("(P) (E) (T) (D)"); + out.write("
"); + } + out.write("
"); + + // end the outer panel for this sandbox + PanelGenerator.generatePanelEnd(out, + context.getExternalContext().getRequestContextPath(), + "white"); + + // spacer row + if (i < users.size() - 1) + { + out.write("
"); + } } } @@ -204,6 +273,47 @@ public class UIUserSandboxes extends SelfRenderingComponent } } + private UIActionLink aquireAction(FacesContext fc, String name, String icon) + { + UIActionLink action = findAction(name); + if (action == null) + { + action = createAction(fc, name, icon); + } + return action; + } + + private UIActionLink findAction(String name) + { + UIActionLink action = null; + String actionId = getId() + name; + for (UIComponent component : (List)getChildren()) + { + if (actionId.equals(component.getId())) + { + action = (UIActionLink)component; + break; + } + } + return action; + } + + private UIActionLink createAction(FacesContext fc, String name, String icon) + { + javax.faces.application.Application facesApp = fc.getApplication(); + UIActionLink control = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); + + control.setRendererType(UIActions.RENDERER_ACTIONLINK); + control.setId(getId() + name); + control.setValue(Application.getMessage(fc, name)); + control.setShowLink(false); + control.setImage(icon); + + this.getChildren().add(control); + + return control; + } + private AVMService getAVMService(FacesContext fc) { return (AVMService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMService"); diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index f5b4cd795f..7445ea38c0 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -563,6 +563,15 @@ + + + The bean that backs up the Create Website Wizard + + ImportWebsiteDialog + org.alfresco.web.bean.wcm.ImportWebsiteDialog + session + + 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 94494c409a..8da01294b3 100644 --- a/source/web/WEB-INF/faces-config-navigation.xml +++ b/source/web/WEB-INF/faces-config-navigation.xml @@ -907,4 +907,12 @@ + + /jsp/wcm/* + + importContent + /jsp/wcm/import-content-dialog.jsp + + + diff --git a/source/web/images/icons/import_website.gif b/source/web/images/icons/import_website.gif new file mode 100644 index 0000000000..79d0c44add Binary files /dev/null and b/source/web/images/icons/import_website.gif differ diff --git a/source/web/images/icons/preview_website.gif b/source/web/images/icons/preview_website.gif new file mode 100644 index 0000000000..8272f113a2 Binary files /dev/null and b/source/web/images/icons/preview_website.gif differ diff --git a/source/web/jsp/wcm/browse-website.jsp b/source/web/jsp/wcm/browse-website.jsp index ecfbf06a10..83e4b6938f 100644 --- a/source/web/jsp/wcm/browse-website.jsp +++ b/source/web/jsp/wcm/browse-website.jsp @@ -74,6 +74,10 @@
+ + <%-- Import website content action --%> + + @@ -96,11 +100,21 @@ <%-- Staging Sandbox Info here --%> <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> - ---STAGING SANDBOX INFO HERE---
- -------------------------------
- Last Updated: 1234
- 12 items currently being modified
- 3 items pending approval + + + + + + + + + + +
(P) (E) (T) (D)
+ Last Updated: 20th September 2006

+ 12 items currently being modified

+ 3 items pending approval +

<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> diff --git a/source/web/jsp/wcm/import-content-dialog.jsp b/source/web/jsp/wcm/import-content-dialog.jsp new file mode 100644 index 0000000000..c2027df4cb --- /dev/null +++ b/source/web/jsp/wcm/import-content-dialog.jsp @@ -0,0 +1,216 @@ +<%-- + 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.ImportWebsiteDialog" %> +<%@ page import="org.alfresco.web.app.servlet.FacesHelper" %> +<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> + + + + + + + <%-- load a bundle of properties with I18N strings --%> + + + + + <%-- Main outer table --%> + + + <%-- Title bar --%> + + + + + <%-- Main area --%> + + <%-- Shelf --%> + + + <%-- Work Area --%> + + +
+ <%@ include file="../parts/titlebar.jsp" %> +
+ <%@ include file="../parts/shelf.jsp" %> + + + <%-- Breadcrumb --%> + <%@ include file="../parts/breadcrumb.jsp" %> + + <%-- Status and Actions --%> + + + + + + + <%-- separator row with gradient shadow --%> + + + + + + + + + <%-- Details --%> + + + + + + + <%-- separator row with bottom panel graphics --%> + + + + + + +
+ + <%-- Status and Actions inner contents table --%> + <%-- Generally this consists of an icon, textual summary and actions for the current object --%> + + + + + +
+ +
+
+
+ +
+ + + + + + +
+ + + + <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %> + + + <% + ImportWebsiteDialog bean = (ImportWebsiteDialog)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "ImportWebsiteDialog"); + boolean foundFile = (bean != null && bean.getFileName() != null); + if (foundFile == false) { + %> + + + + + + + + + + + + + + + + + + + + + + <% } %> + + + <% if (foundFile) { %> + + + + <% } %> + +
+ +
+ +
+ 2. <%=Application.getMessage(FacesContext.getCurrentInstance(), "click_upload")%> +
+ " /> +
+ + + + + + + +
+ + +
+ + + +
+
+ <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %> +
+ <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> + + + + + + + +
+ +
+ +
+ <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> +
+
+
+ +
+ +
+ +
\ No newline at end of file