From 3fb9505fe01a383efcd2d09282a10fd207d8ec3d Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Mon, 27 Nov 2006 12:07:36 +0000 Subject: [PATCH] =?UTF-8?q?.=20Single=20web-app=20per=20Web=20Project=20ch?= =?UTF-8?q?anges=20implemented=20in=20Sandbox=20browsing=20view=20=20-=20t?= =?UTF-8?q?he=20web-app=20folder=20name=20specified=20at=20Web=20Project?= =?UTF-8?q?=20creation=20time=20is=20created=20by=20default=20and=20is=20t?= =?UTF-8?q?he=20root=20folder=20for=20all=20sandbox=20operations=20=20-=20?= =?UTF-8?q?a=20mechanism=20for=20selecting=20a=20different=20root=20webapp?= =?UTF-8?q?=20(or=20creating=20new=20root=20folders)=20can=20be=20easily?= =?UTF-8?q?=20added=20later=20(when=20there=20is=20time=E2=80=A6!)=20.=20R?= =?UTF-8?q?emoval=20of=20two=20public=20workflow=20actions=20that=20have?= =?UTF-8?q?=20no=20params=20and=20therefore=20don't=20work=20as=20public?= =?UTF-8?q?=20actions=20in=20the=20UI=20.=20Fix=20to=20user=20sandboxes=20?= =?UTF-8?q?component=20to=20allow=20any=20user=20to=20always=20have=20acti?= =?UTF-8?q?on=20to=20delete=20a=20user=20sandbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4445 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 2 +- config/alfresco/web-client-config-actions.xml | 8 +-- .../alfresco/web/bean/wcm/AVMBrowseBean.java | 71 ++++++++++--------- .../alfresco/web/bean/wcm/AVMConstants.java | 15 ++-- .../web/bean/wcm/CreateWebsiteWizard.java | 8 ++- .../web/bean/wcm/ImportWebsiteDialog.java | 14 ++-- .../web/ui/wcm/component/UIUserSandboxes.java | 27 ++++--- source/web/jsp/wcm/browse-website.jsp | 4 +- 8 files changed, 85 insertions(+), 64 deletions(-) diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index a118262766..7dae6a7cca 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -918,7 +918,7 @@ snapshot_preview=Preview # 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. +import_website_content_desc=Use this dialog to import an archive of content into the default webapp for the website. delete_avm_file_info=To remove this file from the sandbox, click OK. delete_avm_file_confirm=Are you sure you want to remove \"{0}\" from the sandbox? delete_folder=Delete Folder diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml index 2d3559591c..b38532c743 100644 --- a/config/alfresco/web-client-config-actions.xml +++ b/config/alfresco/web-client-config-actions.xml @@ -577,7 +577,7 @@ - + - + @@ -609,7 +609,7 @@ false inlineAction - + @@ -617,7 +617,7 @@ - + diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 1a635c9945..82d5f45962 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -511,7 +511,8 @@ public class AVMBrowseBean implements IContextListener { if (this.currentPath == null) { - this.currentPath = AVMConstants.buildAVMStoreRootPath(getSandbox()); + String webapp = (String)getWebsite().getProperties().get(ContentModel.PROP_DEFAULTWEBAPP); + this.currentPath = AVMConstants.buildAVMStoreWebappPath(getSandbox(), webapp); } return this.currentPath; } @@ -532,40 +533,6 @@ public class AVMBrowseBean implements IContextListener UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans(); } - /** - * @return true if the current user has the manager role in the current website - */ - public boolean getIsManagerRole() - { - boolean isManager = false; - - User user = Application.getCurrentUser(FacesContext.getCurrentInstance()); - if (user.isAdmin() == false) - { - String currentUser = user.getUserName(); - Node websiteNode = this.navigator.getCurrentNode(); - List userInfoRefs = this.nodeService.getChildAssocs( - websiteNode.getNodeRef(), ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : userInfoRefs) - { - NodeRef userInfoRef = ref.getChildRef(); - String username = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERNAME); - String userrole = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERROLE); - if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole)) - { - isManager = true; - break; - } - } - } - else - { - isManager = true; - } - - return isManager; - } - /** * @return the AVMNode that represents the current browsing path */ @@ -602,6 +569,40 @@ public class AVMBrowseBean implements IContextListener this.location = location; } + /** + * @return true if the current user has the manager role in the current website + */ + public boolean getIsManagerRole() + { + boolean isManager = false; + + User user = Application.getCurrentUser(FacesContext.getCurrentInstance()); + if (user.isAdmin() == false) + { + String currentUser = user.getUserName(); + Node websiteNode = this.navigator.getCurrentNode(); + List userInfoRefs = this.nodeService.getChildAssocs( + websiteNode.getNodeRef(), ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : userInfoRefs) + { + NodeRef userInfoRef = ref.getChildRef(); + String username = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERNAME); + String userrole = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERROLE); + if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole)) + { + isManager = true; + break; + } + } + } + else + { + isManager = true; + } + + return isManager; + } + /** * @return Map of avm node objects representing the folders with the current website space */ diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index 6ffc782764..ac0ba807fc 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -67,6 +67,11 @@ public final class AVMConstants return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS; } + public static String buildAVMStoreWebappPath(String store, String webapp) + { + return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS + '/' + webapp; + } + public static String buildAVMStoreUrl(String store) { if (store.indexOf(':') != -1) @@ -144,12 +149,10 @@ public final class AVMConstants { return parent; } - + if (path.charAt(0) == '/') { - final Pattern p = Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + - "/[^/]+/[^/]+).*"); - final Matcher m = p.matcher(parent); + final Matcher m = absoluteAVMPath.matcher(parent); if (m.matches()) { parent = m.group(1); @@ -189,4 +192,8 @@ public final class AVMConstants // URLs for preview of sandboxes and assets private final static String PREVIEW_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}"; private final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}{3}"; + + // patter for absolute AVM Path + private final static Pattern absoluteAVMPath = Pattern.compile( + "([^:]+:/" + AVMConstants.DIR_APPBASE + "/[^/]+/[^/]+).*"); } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index 46cd47e27c..973d8776bc 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -181,10 +181,14 @@ public class CreateWebsiteWizard extends BaseWizardBean outcome = wiz.finish(); if (outcome != null) { - // create the AVM stores to represent the newly created location website + // create the AVM staging store to represent the newly created location website SandboxFactory.createStagingSandbox(avmStore, wiz.getManagers()); - // set the property on the node to reference the AVM store + // create the default webapp folder under the hidden system folders + String stagingStore = AVMConstants.buildAVMStagingStoreName(avmStore); + this.avmService.createDirectory(AVMConstants.buildAVMStoreRootPath(stagingStore), webapp); + + // set the property on the node to reference the root AVM store this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, avmStore); // persist the forms, templates, workflows and workflow defaults to the model for this web project diff --git a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java index cb1fc653c2..ab9114c6b4 100644 --- a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java @@ -52,6 +52,7 @@ import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; import org.alfresco.web.bean.FileUploadBean; import org.alfresco.web.bean.NavigationBean; +import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.ui.common.Utils; import org.apache.tools.zip.ZipEntry; @@ -198,15 +199,16 @@ public class ImportWebsiteDialog // TODO: explicit permission check for WRITE on website node for this user // import the content into the appropriate store for the website - String storeRoot = (String)this.navigationBean.getCurrentNode().getProperties().get( - ContentModel.PROP_AVMSTORE); - if (storeRoot != null) + Node website = this.navigationBean.getCurrentNode(); + String storeRoot = (String)website.getProperties().get(ContentModel.PROP_AVMSTORE); + String webapp = (String)website.getProperties().get(ContentModel.PROP_DEFAULTWEBAPP); + if (storeRoot != null && webapp != null) { String store = AVMConstants.buildAVMStagingStoreName(storeRoot); if (this.avmService.getAVMStore(store) != null) { - // get the root path to the webapps import area of the store - String rootPath = AVMConstants.buildAVMStoreRootPath(store); + // get the path to the root webapp import area of the store + String rootPath = AVMConstants.buildAVMStoreWebappPath(store, webapp); // convert the AVM path to a NodeRef so we can use the NodeService to perform import NodeRef importRef = AVMNodeConverter.ToNodeRef(-1, rootPath); @@ -218,7 +220,7 @@ public class ImportWebsiteDialog } else { - // TODO: output an error to indicate we cannot find the store property on the website + throw new IllegalStateException("Unable to find root store/webapp property for website!"); } tx.commit(); 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 5095429841..2e1ee6f11f 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIUserSandboxes.java @@ -50,6 +50,7 @@ import org.alfresco.web.app.Application; import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.bean.repository.User; import org.alfresco.web.bean.wcm.AVMConstants; import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.config.ClientConfigElement; @@ -426,19 +427,23 @@ public class UIUserSandboxes extends SelfRenderingComponent */ private static boolean isManagerRole(FacesContext context, NodeService nodeService, NodeRef websiteRef) { - boolean isManager = false; - String currentUser = Application.getCurrentUser(context).getUserName(); - List userInfoRefs = nodeService.getChildAssocs( - websiteRef, ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef ref : userInfoRefs) + User user = Application.getCurrentUser(context); + boolean isManager = user.isAdmin(); + if (isManager == false) { - NodeRef userInfoRef = ref.getChildRef(); - String username = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERNAME); - String userrole = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERROLE); - if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole)) + String currentUser = user.getUserName(); + List userInfoRefs = nodeService.getChildAssocs( + websiteRef, ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL); + for (ChildAssociationRef ref : userInfoRefs) { - isManager = true; - break; + NodeRef userInfoRef = ref.getChildRef(); + String username = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERNAME); + String userrole = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERROLE); + if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole)) + { + isManager = true; + break; + } } } return isManager; diff --git a/source/web/jsp/wcm/browse-website.jsp b/source/web/jsp/wcm/browse-website.jsp index 82d8b7eccb..c8bdff2897 100644 --- a/source/web/jsp/wcm/browse-website.jsp +++ b/source/web/jsp/wcm/browse-website.jsp @@ -82,12 +82,14 @@ + <%-- Import website content action --%> - + +