. Single web-app per Web Project changes implemented in Sandbox browsing view

- the web-app folder name specified at Web Project creation time is created by default and is the root folder for all sandbox operations
 - a mechanism for selecting a different root webapp (or creating new root folders) can be easily added later (when there is time…!)
. Removal of two public workflow actions that have no params and therefore don't work as public actions in the UI
. Fix to user sandboxes component to allow any user to always have action to delete a user sandbox

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4445 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-11-27 12:07:36 +00:00
parent 0f6efbd751
commit 3fb9505fe0
8 changed files with 85 additions and 64 deletions

View File

@@ -918,7 +918,7 @@ snapshot_preview=Preview
# Website actions and dialog messages # Website actions and dialog messages
title_import_content=Import Content into Website title_import_content=Import Content into Website
import_website_content_title=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_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_avm_file_confirm=Are you sure you want to remove \"{0}\" from the sandbox?
delete_folder=Delete Folder delete_folder=Delete Folder

View File

@@ -577,7 +577,7 @@
<action idref="checkout_doc" /> <action idref="checkout_doc" />
<action idref="checkin_doc" /> <action idref="checkin_doc" />
<action idref="details_doc" /> <action idref="details_doc" />
<action idref="preview_doc" /> <action idref="delete_doc" />
<!-- Example action defined in-line rather than by reference <!-- Example action defined in-line rather than by reference
<action id="example2_checkout_doc"> <action id="example2_checkout_doc">
@@ -595,7 +595,7 @@
<!-- Actions Menu for a document in the Browse screen --> <!-- Actions Menu for a document in the Browse screen -->
<action-group id="document_browse_menu"> <action-group id="document_browse_menu">
<action idref="delete_doc" /> <action idref="preview_doc" />
<action idref="update_doc" /> <action idref="update_doc" />
<action idref="cancelcheckout_doc" /> <action idref="cancelcheckout_doc" />
<action idref="approve_doc" /> <action idref="approve_doc" />
@@ -609,7 +609,7 @@
<show-link>false</show-link> <show-link>false</show-link>
<style-class>inlineAction</style-class> <style-class>inlineAction</style-class>
<action idref="preview_space" /> <action idref="delete_space" />
<action idref="cut_node" /> <action idref="cut_node" />
<action idref="copy_node" /> <action idref="copy_node" />
<action idref="details_space" /> <action idref="details_space" />
@@ -617,7 +617,7 @@
<!-- Actions Menu for a space in the Browse screen --> <!-- Actions Menu for a space in the Browse screen -->
<action-group id="space_browse_menu"> <action-group id="space_browse_menu">
<action idref="delete_space" /> <action idref="preview_space" />
<action idref="approve_space" /> <action idref="approve_space" />
<action idref="reject_space" /> <action idref="reject_space" />
</action-group> </action-group>

View File

@@ -511,7 +511,8 @@ public class AVMBrowseBean implements IContextListener
{ {
if (this.currentPath == null) 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; return this.currentPath;
} }
@@ -532,40 +533,6 @@ public class AVMBrowseBean implements IContextListener
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans(); 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<ChildAssociationRef> 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 * @return the AVMNode that represents the current browsing path
*/ */
@@ -602,6 +569,40 @@ public class AVMBrowseBean implements IContextListener
this.location = location; 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<ChildAssociationRef> 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 * @return Map of avm node objects representing the folders with the current website space
*/ */

View File

@@ -67,6 +67,11 @@ public final class AVMConstants
return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS; 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) public static String buildAVMStoreUrl(String store)
{ {
if (store.indexOf(':') != -1) if (store.indexOf(':') != -1)
@@ -144,12 +149,10 @@ public final class AVMConstants
{ {
return parent; return parent;
} }
if (path.charAt(0) == '/') if (path.charAt(0) == '/')
{ {
final Pattern p = Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + final Matcher m = absoluteAVMPath.matcher(parent);
"/[^/]+/[^/]+).*");
final Matcher m = p.matcher(parent);
if (m.matches()) if (m.matches())
{ {
parent = m.group(1); parent = m.group(1);
@@ -189,4 +192,8 @@ public final class AVMConstants
// URLs for preview of sandboxes and assets // 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_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}";
private final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}{3}"; 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 + "/[^/]+/[^/]+).*");
} }

View File

@@ -181,10 +181,14 @@ public class CreateWebsiteWizard extends BaseWizardBean
outcome = wiz.finish(); outcome = wiz.finish();
if (outcome != null) 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()); 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); this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, avmStore);
// persist the forms, templates, workflows and workflow defaults to the model for this web project // persist the forms, templates, workflows and workflow defaults to the model for this web project

View File

@@ -52,6 +52,7 @@ import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.FileUploadBean; import org.alfresco.web.bean.FileUploadBean;
import org.alfresco.web.bean.NavigationBean; import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.apache.tools.zip.ZipEntry; 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 // TODO: explicit permission check for WRITE on website node for this user
// import the content into the appropriate store for the website // import the content into the appropriate store for the website
String storeRoot = (String)this.navigationBean.getCurrentNode().getProperties().get( Node website = this.navigationBean.getCurrentNode();
ContentModel.PROP_AVMSTORE); String storeRoot = (String)website.getProperties().get(ContentModel.PROP_AVMSTORE);
if (storeRoot != null) String webapp = (String)website.getProperties().get(ContentModel.PROP_DEFAULTWEBAPP);
if (storeRoot != null && webapp != null)
{ {
String store = AVMConstants.buildAVMStagingStoreName(storeRoot); String store = AVMConstants.buildAVMStagingStoreName(storeRoot);
if (this.avmService.getAVMStore(store) != null) if (this.avmService.getAVMStore(store) != null)
{ {
// get the root path to the webapps import area of the store // get the path to the root webapp import area of the store
String rootPath = AVMConstants.buildAVMStoreRootPath(store); String rootPath = AVMConstants.buildAVMStoreWebappPath(store, webapp);
// convert the AVM path to a NodeRef so we can use the NodeService to perform import // convert the AVM path to a NodeRef so we can use the NodeService to perform import
NodeRef importRef = AVMNodeConverter.ToNodeRef(-1, rootPath); NodeRef importRef = AVMNodeConverter.ToNodeRef(-1, rootPath);
@@ -218,7 +220,7 @@ public class ImportWebsiteDialog
} }
else 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(); tx.commit();

View File

@@ -50,6 +50,7 @@ import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.repository.Repository; 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.AVMConstants;
import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.bean.wcm.AVMNode;
import org.alfresco.web.config.ClientConfigElement; 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) private static boolean isManagerRole(FacesContext context, NodeService nodeService, NodeRef websiteRef)
{ {
boolean isManager = false; User user = Application.getCurrentUser(context);
String currentUser = Application.getCurrentUser(context).getUserName(); boolean isManager = user.isAdmin();
List<ChildAssociationRef> userInfoRefs = nodeService.getChildAssocs( if (isManager == false)
websiteRef, ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{ {
NodeRef userInfoRef = ref.getChildRef(); String currentUser = user.getUserName();
String username = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERNAME); List<ChildAssociationRef> userInfoRefs = nodeService.getChildAssocs(
String userrole = (String)nodeService.getProperty(userInfoRef, ContentModel.PROP_WEBUSERROLE); websiteRef, ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
if (currentUser.equals(username) && ROLE_CONTENT_MANAGER.equals(userrole)) for (ChildAssociationRef ref : userInfoRefs)
{ {
isManager = true; NodeRef userInfoRef = ref.getChildRef();
break; 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; return isManager;

View File

@@ -82,12 +82,14 @@
</a:menu> </a:menu>
</nobr> </nobr>
</td> </td>
<a:panel id="import-panel" rendered="#{AVMBrowseBean.isManagerRole}">
<td align=right width=170> <td align=right width=170>
<nobr> <nobr>
<%-- Import website content action --%> <%-- Import website content action --%>
<a:actionLink value="#{msg.import_website_content}" rendered="#{AVMBrowseBean.isManagerRole}" image="/images/icons/import_website.gif" padding="2" action="dialog:importContent" actionListener="#{ImportWebsiteDialog.start}" /> <a:actionLink value="#{msg.import_website_content}" image="/images/icons/import_website.gif" padding="2" action="dialog:importContent" actionListener="#{ImportWebsiteDialog.start}" />
</nobr> </nobr>
</td> </td>
</a:panel>
</tr> </tr>
</table> </table>