From c9f6f177562bc022ebe1afcc73e32a90ee4377ae Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Mon, 25 Sep 2006 12:57:19 +0000 Subject: [PATCH] . WCM UI - Preview Staging area action added - Preview User Sandbox action added - Generates the virtualisation server URLs to an AVM sandboxes for the - possible to preview the entire website with transparent overlays for each user. - Fix to generation of mangled DNS name for a user store to remove the "main" part (implicit) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3918 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/web/bean/wcm/AVMBrowseBean.java | 14 +++++++- .../alfresco/web/bean/wcm/AVMConstants.java | 33 +++++++++++++++++++ .../web/bean/wcm/CreateWebsiteWizard.java | 2 +- .../web/ui/wcm/component/UIUserSandboxes.java | 28 ++++++++++------ source/web/jsp/wcm/browse-website.jsp | 2 +- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 80ab12bf20..22b78100c3 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -225,6 +225,13 @@ public class AVMBrowseBean implements IContextListener { this.actionService = actionService; } + + public String getStagingStore() + { + Node websiteNode = this.navigator.getCurrentNode(); + String storeRoot = (String)websiteNode.getProperties().get(ContentModel.PROP_AVMSTORE); + return AVMConstants.buildAVMStagingStoreName(storeRoot); + } /** * Summary text for the staging store: @@ -242,7 +249,7 @@ public class AVMBrowseBean implements IContextListener ResourceBundle msg = Application.getBundle(fc); Node websiteNode = this.navigator.getCurrentNode(); String storeRoot = (String)websiteNode.getProperties().get(ContentModel.PROP_AVMSTORE); - String stagingStore = AVMConstants.buildAVMStagingStoreName(storeRoot); + String stagingStore = getStagingStore(); AVMStoreDescriptor store = this.avmService.getAVMStore(stagingStore); if (store != null) { @@ -261,6 +268,11 @@ public class AVMBrowseBean implements IContextListener return summary.toString(); } + public String getPreviewUrl() + { + return AVMConstants.buildAVMStoreUrl(getStagingStore()); + } + /** * @param foldersRichList The foldersRichList to set. */ diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index 9f06f564ca..7a23b20c31 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -16,6 +16,18 @@ */ package org.alfresco.web.bean.wcm; +import java.text.MessageFormat; +import java.util.Map; + +import javax.faces.context.FacesContext; + +import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.namespace.QName; +import org.alfresco.web.app.Application; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.config.ClientConfigElement; + /** * @author Kevin Roast */ @@ -53,6 +65,23 @@ public final class AVMConstants return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS; } + public static String buildAVMStoreUrl(String store) + { + String url = null;; + + FacesContext fc = FacesContext.getCurrentInstance(); + AVMService avmService = Repository.getServiceRegistry(fc).getAVMService(); + ClientConfigElement config = Application.getClientConfig(fc); + Map props = avmService.queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%')); + if (props.size() == 1) + { + String dns = props.entrySet().iterator().next().getKey().getLocalName().substring(PROP_DNS.length()); + url = MessageFormat.format(PREVIEW_SANDBOX_URL, dns, config.getWCMDomain(), config.getWCMPort()); + } + + return url; + } + // names of the stores representing the layers for an AVM website public final static String STORE_STAGING = "-staging"; public final static String STORE_MAIN = "-main"; @@ -72,4 +101,8 @@ public final class AVMConstants public final static String PROP_WEBSITE_NAME = ".website.name"; public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store."; public final static String SPACE_ICON_WEBSITE = "space-icon-website"; + + // URLs for preview of sandboxes and assets + public final static String PREVIEW_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}"; + public final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}/{3}"; } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index d04dbde837..dad327b48e 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -359,7 +359,7 @@ public class CreateWebsiteWizard extends BaseWizardBean new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property - tagStoreDNSPath(userStore, name, username, "main"); + tagStoreDNSPath(userStore, name, username); // create the user 'preview' store 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 84ac311853..15890e6111 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -213,7 +213,7 @@ public class UIUserSandboxes extends SelfRenderingComponent // this is currently identical to the sandbox_browse action as below Utils.encodeRecursive(context, aquireAction( context, mainStore, username, "sandbox_icon", WebResources.IMAGE_USERSANDBOX_32, - "#{AVMBrowseBean.setupSandboxAction}", "browseSandbox")); + "#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null)); out.write(""); out.write(""); out.write(bundle.getString(MSG_USERNAME)); @@ -222,24 +222,25 @@ public class UIUserSandboxes extends SelfRenderingComponent out.write(""); // direct actions for a sandbox + String sandboxUrl = AVMConstants.buildAVMStoreUrl(mainStore); Utils.encodeRecursive(context, aquireAction( context, mainStore, username, "sandbox_preview", "/images/icons/preview_website.gif", - null, null)); + null, null, sandboxUrl)); out.write(" "); Utils.encodeRecursive(context, aquireAction( context, mainStore, username, "sandbox_create", "/images/icons/new_content.gif", - "#{AVMBrowseBean.setupSandboxAction}", "wizard:createWebContent")); + "#{AVMBrowseBean.setupSandboxAction}", "wizard:createWebContent", null)); out.write(" "); Utils.encodeRecursive(context, aquireAction( context, mainStore, username, "sandbox_submitall", "/images/icons/submit.gif", - "#{AVMBrowseBean.submitAll}", null)); + "#{AVMBrowseBean.submitAll}", null, null)); out.write(" "); Utils.encodeRecursive(context, aquireAction( context, mainStore, username, "sandbox_browse", "/images/icons/space_small.gif", - "#{AVMBrowseBean.setupSandboxAction}", "browseSandbox")); + "#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null)); out.write(""); // modified items panel @@ -505,19 +506,20 @@ public class UIUserSandboxes extends SelfRenderingComponent * @param store Root store name for the user sandbox * @param username Username of the user for the action * @param name Action name - will be used for I18N message lookup - * @param icon Icon to display for the actio n + * @param icon Icon to display for the action * @param actionListener Actionlistener for the action * @param outcome Navigation outcome for the action + * @param url HREF URL for the action * * @return UIActionLink component */ private UIActionLink aquireAction(FacesContext fc, String store, String username, - String name, String icon, String actionListener, String outcome) + String name, String icon, String actionListener, String outcome, String url) { UIActionLink action = findAction(name, username); if (action == null) { - action = createAction(fc, store, username, name, icon, actionListener, outcome); + action = createAction(fc, store, username, name, icon, actionListener, outcome, url); } return action; } @@ -555,11 +557,12 @@ public class UIUserSandboxes extends SelfRenderingComponent * @param icon Icon to display for the actio n * @param actionListener Actionlistener for the action * @param outcome Navigation outcome for the action + * @param url HREF URL for the action * * @return UIActionLink child component */ private UIActionLink createAction(FacesContext fc, String store, String username, - String name, String icon, String actionListener, String outcome) + String name, String icon, String actionListener, String outcome, String url) { javax.faces.application.Application facesApp = fc.getApplication(); UIActionLink control = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK); @@ -574,7 +577,7 @@ public class UIUserSandboxes extends SelfRenderingComponent { control.setActionListener(facesApp.createMethodBinding( actionListener, UIActions.ACTION_CLASS_ARGS)); - + UIParameter param = (UIParameter)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PARAMETER); param.setName("store"); param.setValue(store); @@ -588,6 +591,11 @@ public class UIUserSandboxes extends SelfRenderingComponent { control.setAction(new ConstantMethodBinding(outcome)); } + if (url != null) + { + control.setHref(url); + control.setTarget("new"); + } this.getChildren().add(control); diff --git a/source/web/jsp/wcm/browse-website.jsp b/source/web/jsp/wcm/browse-website.jsp index d616e9211f..9f9fb734ae 100644 --- a/source/web/jsp/wcm/browse-website.jsp +++ b/source/web/jsp/wcm/browse-website.jsp @@ -105,7 +105,7 @@ - +