diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties
index b3ef6c7375..a36e0cd2e2 100644
--- a/config/alfresco/messages/webclient.properties
+++ b/config/alfresco/messages/webclient.properties
@@ -851,6 +851,18 @@ create_website_step5_desc=Notify the invited users.
create_website_finish_instruction=To close this wizard and create your web project space click Finish. To review or change your selections click Back.
create_website_summary_users=Users and Roles
+# Invite web users wizard messages
+manage_invited_users=Manage Website Users
+invite_website_users=Invite Website Users
+invite_webusers_title=Invite Website Users
+invite_webusers_desc=Invite new users and create sandboxes for the web project.
+invite_webusers_step1_title=Step One - Invite Users
+invite_webusers_step1_desc=Select users and their roles.
+invite_webusers_step2_title=Step Two - Notify Users
+invite_webusers_step2_desc=Notify the invited users.
+invite_webusers_finish_instruction=To close the wizard and create the user sandboxes click Finish. To review or change your selections click Back.
+invite_webusers_summary_users=Users and Roles
+
# Delete Website Dialog messages
delete_website=Delete Web Project
delete_website_info=To remove this web project and all associated user sandboxes, click OK.
diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml
index 66559320ca..905e9074d1 100644
--- a/config/alfresco/web-client-config-wcm-actions.xml
+++ b/config/alfresco/web-client-config-wcm-actions.xml
@@ -187,6 +187,21 @@
+
+
+
+ ChangePermissions
+
+ invite_website_users
+ /images/icons/invite.gif
+ wizard:inviteWebUsers
+
+ #{BrowseBean.setupSpaceAction}
+
+ #{actionContext.id}
+
+
+
@@ -269,6 +284,7 @@
+
@@ -276,7 +292,7 @@
diff --git a/config/alfresco/web-client-config-wizards.xml b/config/alfresco/web-client-config-wizards.xml
index c4925a3a2f..c8d83ce3e3 100644
--- a/config/alfresco/web-client-config-wizards.xml
+++ b/config/alfresco/web-client-config-wizards.xml
@@ -1,12 +1,12 @@
-
+
/jsp/wizard/container.jsp
-
-
-
+
@@ -47,7 +47,31 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -238,30 +262,27 @@
-
-
+
+ title-id="create_form_configure_rendering_engine_templates_title"
+ description-id="create_form_configure_rendering_engine_templates_desc">
+ title-id="create_form_select_default_workflow_title"
+ description-id="create_form_select_default_workflow_desc">
managers = new ArrayList(4);
- boolean foundCurrentUser = false;
- List invitedUserRoles = (List)wiz.getUserRolesDataModel().getWrappedData();
- String currentUser = Application.getCurrentUser(context).getUserName();
- for (UserGroupRole userRole : invitedUserRoles)
- {
- String authority = userRole.getAuthority();
- if (currentUser.equals(authority))
- {
- foundCurrentUser = true;
- }
- if (ROLE_CONTENT_MANAGER.equals(userRole.getRole()))
- {
- managers.add(authority);
- }
- }
- if (foundCurrentUser == false)
- {
- invitedUserRoles.add(new UserGroupRole(currentUser, ROLE_CONTENT_MANAGER, null));
- managers.add(currentUser);
- }
-
- // build the sandboxes now we have the manager list and complete user list
- for (UserGroupRole userRole : invitedUserRoles)
- {
- createUserSandbox(avmStore, managers, userRole.getAuthority(), userRole.getRole());
- }
-
// create the AVM stores to represent the newly created location website
- createStagingSandbox(avmStore, managers);
-
- // save the list of invited users against the store
- for (UserGroupRole userRole : invitedUserRoles)
- {
- // create an app:webuser instance for each authority and assoc to the website node
- Map props = new HashMap(2, 1.0f);
- props.put(ContentModel.PROP_WEBUSERNAME, userRole.getAuthority());
- props.put(ContentModel.PROP_WEBUSERROLE, userRole.getRole());
- this.nodeService.createNode(nodeRef,
- ContentModel.ASSOC_WEBUSER,
- ContentModel.ASSOC_WEBUSER,
- ContentModel.TYPE_WEBUSER,
- props);
- }
+ SandboxFactory.createStagingSandbox(avmStore, wiz.getManagers());
// set the property on the node to reference the AVM store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, avmStore);
@@ -383,14 +337,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.avmService = avmService;
}
- /**
- * @param permissionService The permissionService to set.
- */
- public void setPermissionService(PermissionService permissionService)
- {
- this.permissionService = permissionService;
- }
-
/**
* @param workflowService The WorkflowService to set.
*/
@@ -508,7 +454,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
}
if (foundCurrentUser == false)
{
- buf.append(getInviteUsersWizard().buildLabelForUserAuthorityRole(currentUser, ROLE_CONTENT_MANAGER));
+ buf.append(getInviteUsersWizard().buildLabelForUserAuthorityRole(
+ currentUser, SandboxFactory.ROLE_CONTENT_MANAGER));
}
return buildSummary(
@@ -686,7 +633,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
for (WorkflowDefinition workflowDef : workflowDefs)
{
UIListItem item = new UIListItem();
- item.setValue(workflowDef.id);
+ item.setValue(workflowDef);
item.setLabel(workflowDef.title);
item.setDescription(workflowDef.description);
item.setImage(WebResources.IMAGE_WORKFLOW_32);
@@ -705,8 +652,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
int index = selectList.getRowIndex();
if (index != -1)
{
- String workflow = (String)this.workflowsList.get(index).getValue();
- this.workflows.add(this.new WorkflowWrapper(workflow));
+ WorkflowDefinition workflow = (WorkflowDefinition)this.workflowsList.get(index).getValue();
+ this.workflows.add(new WorkflowWrapper(workflow.getId(), workflow.getTitle()));
}
}
@@ -770,237 +717,6 @@ public class CreateWebsiteWizard extends BaseWizardBean
return this.websitesFolderId;
}
- /**
- * Create the staging sandbox for the named store.
- *
- * A staging sandbox is comprised of two stores, the first named 'storename-staging' with a
- * preview store named 'storename-preview' layered over the staging store.
- *
- * Various store meta-data properties are set including:
- * Identifier for store-types: .sandbox.staging.main and .sandbox.staging.preview
- * Store-id: .sandbox-id. (unique across all stores in the sandbox)
- * DNS: .dns. =
- * Website Name: .website.name = website name
- *
- * @param name The store name to create the sandbox for
- * @param managers The list of authorities who have ContentManager role in the website
- */
- private void createStagingSandbox(String name, List managers)
- {
- // create the 'staging' store for the website
- String stagingStore = AVMConstants.buildAVMStagingStoreName(name);
- this.avmService.createAVMStore(stagingStore);
- if (logger.isDebugEnabled())
- logger.debug("Created staging sandbox store: " + stagingStore);
-
- // create the system directories 'appBase' and 'avm_webapps'
- String path = stagingStore + ":/";
- //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
- this.avmService.createDirectory(path, AVMConstants.DIR_APPBASE);
- NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
- for (String manager : managers)
- {
- this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
- }
- path += AVMConstants.DIR_APPBASE;
- //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_WEBAPPS, ContentModel.TYPE_AVM_PLAIN_FOLDER);
- this.avmService.createDirectory(path, AVMConstants.DIR_WEBAPPS);
-
- // tag the store with the store type
- this.avmService.setStoreProperty(stagingStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_MAIN),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with the DNS name property
- tagStoreDNSPath(stagingStore, name, "staging");
-
- // snapshot the store
- this.avmService.createSnapshot(stagingStore, null, null);
-
-
- // create the 'preview' store for the website
- String previewStore = AVMConstants.buildAVMStagingPreviewStoreName(name);
- this.avmService.createAVMStore(previewStore);
- if (logger.isDebugEnabled())
- logger.debug("Created staging sandbox store: " + previewStore);
-
- // create a layered directory pointing to 'appBase' in the staging area
- path = previewStore + ":/";
- String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
- //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
- this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
- dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
- for (String manager : managers)
- {
- this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
- }
-
- // tag the store with the store type
- this.avmService.setStoreProperty(previewStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_PREVIEW),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with the DNS name property
- tagStoreDNSPath(previewStore, name, "preview");
-
- // snapshot the store
- this.avmService.createSnapshot(previewStore, null, null);
-
-
- // tag all related stores to indicate that they are part of a single sandbox
- String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
- this.avmService.setStoreProperty(stagingStore,
- QName.createQName(null, sandboxIdProp),
- new PropertyValue(DataTypeDefinition.TEXT, null));
- this.avmService.setStoreProperty(previewStore,
- QName.createQName(null, sandboxIdProp),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- if (logger.isDebugEnabled())
- {
- dumpStoreProperties(stagingStore);
- dumpStoreProperties(previewStore);
- }
- }
-
- /**
- * Create a user sandbox for the named store.
- *
- * A user sandbox is comprised of two stores, the first named 'storename-username-main' layered
- * over the staging store with a preview store named 'storename-username-preview' layered over
- * the main store.
- *
- * Various store meta-data properties are set including:
- * Identifier for store-types: .sandbox.author.main and .sandbox.author.preview
- * Store-id: .sandbox-id. (unique across all stores in the sandbox)
- * DNS: .dns. =
- * Website Name: .website.name = website name
- *
- * @param name The store name to create the sandbox for
- * @param managers The list of authorities who have ContentManager role in the website
- * @param username Username of the user to create the sandbox for
- * @param role Role permission for the user
- */
- private void createUserSandbox(String name, List managers, String username, String role)
- {
- // create the user 'main' store
- String userStore = AVMConstants.buildAVMUserMainStoreName(name, username);
- this.avmService.createAVMStore(userStore);
- if (logger.isDebugEnabled())
- logger.debug("Created staging sandbox store: " + userStore);
-
- // create a layered directory pointing to 'appBase' in the staging area
- String path = userStore + ":/";
- String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
- this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
- NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
- this.permissionService.setPermission(dirRef, username, role, true);
- for (String manager : managers)
- {
- this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
- }
-
- // tag the store with the store type
- this.avmService.setStoreProperty(userStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with the base name of the website so that corresponding
- // staging areas can be found.
- this.avmService.setStoreProperty(userStore,
- QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
- new PropertyValue(DataTypeDefinition.TEXT, name));
-
- // tag the store, oddly enough, with its own store name for querying.
- // when will the madness end.
- this.avmService.setStoreProperty(userStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + userStore),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with the DNS name property
- tagStoreDNSPath(userStore, name, username);
-
- // snapshot the store
- this.avmService.createSnapshot(userStore, null, null);
-
-
- // create the user 'preview' store
- String previewStore = AVMConstants.buildAVMUserPreviewStoreName(name, username);
- this.avmService.createAVMStore(previewStore);
- if (logger.isDebugEnabled())
- logger.debug("Created staging sandbox store: " + previewStore);
-
- // create a layered directory pointing to 'appBase' in the user 'main' store
- path = previewStore + ":/";
- targetPath = userStore + ":/" + AVMConstants.DIR_APPBASE;
- this.avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
- dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
- this.permissionService.setPermission(dirRef, username, role, true);
- for (String manager : managers)
- {
- this.permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
- }
-
- // tag the store with the store type
- this.avmService.setStoreProperty(previewStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with its own store name for querying.
- this.avmService.setStoreProperty(previewStore,
- QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + previewStore),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- // tag the store with the DNS name property
- tagStoreDNSPath(previewStore, name, username, "preview");
-
- // snapshot the store
- this.avmService.createSnapshot(previewStore, null, null);
-
-
- // tag all related stores to indicate that they are part of a single sandbox
- String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
- this.avmService.setStoreProperty(userStore, QName.createQName(null, sandboxIdProp),
- new PropertyValue(DataTypeDefinition.TEXT, null));
- this.avmService.setStoreProperty(previewStore, QName.createQName(null, sandboxIdProp),
- new PropertyValue(DataTypeDefinition.TEXT, null));
-
- if (logger.isDebugEnabled())
- {
- dumpStoreProperties(userStore);
- dumpStoreProperties(previewStore);
- }
- }
-
- /**
- * Tag a named store with a DNS path meta-data attribute.
- * The DNS meta-data attribute is set to the system path 'store:/appBase/avm_webapps'
- *
- * @param store Name of the store to tag
- */
- private void tagStoreDNSPath(String store, String... components)
- {
- String path = store + ":/" + AVMConstants.DIR_APPBASE + '/' + AVMConstants.DIR_WEBAPPS;
- // DNS name mangle the property name - can only contain value DNS characters!
- String dnsProp = AVMConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components);
- this.avmService.setStoreProperty(store, QName.createQName(null, dnsProp),
- new PropertyValue(DataTypeDefinition.TEXT, path));
- }
-
- /**
- * Debug helper method to dump the properties of a store
- *
- * @param store Store name to dump properties for
- */
- private void dumpStoreProperties(String store)
- {
- Map props = avmService.getStoreProperties(store);
- for (QName name : props.keySet())
- {
- logger.debug(" " + name + ": " + props.get(name));
- }
- }
-
// ------------------------------------------------------------------------------
// Inner classes
@@ -1061,7 +777,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
WorkflowDefinition wf = this.form.getDefaultWorkflow();
if (this.workflow == null && wf != null)
{
- this.workflow = CreateWebsiteWizard.this.new WorkflowWrapper(wf.getId());
+ this.workflow = new WorkflowWrapper(wf.id, wf.getTitle());
}
return this.workflow;
}
@@ -1126,9 +842,9 @@ public class CreateWebsiteWizard extends BaseWizardBean
{
String none = '<' + Application.getMessage(FacesContext.getCurrentInstance(), MSG_NONE) + '>';
return MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_FORM_SUMMARY),
- getWorkflow() != null ? this.workflow.getName() : none,
- getFilenamePattern() != null ? this.filenamePattern : none,
- getTemplates() != null ? this.templates.size() : 0);
+ getWorkflow() != null ? this.workflow.title : none,
+ getFilenamePattern() != null ? this.filenamePattern : none,
+ getTemplates() != null ? this.templates.size() : 0);
}
}
@@ -1197,24 +913,21 @@ public class CreateWebsiteWizard extends BaseWizardBean
}
}
- public WorkflowWrapper getWorkflowWrapper(String id)
- {
- return this.new WorkflowWrapper(id);
- }
-
/**
* Class to represent a single configured Workflow instance
*/
- public class WorkflowWrapper
+ public static class WorkflowWrapper
{
private String id;
+ private String title;
private String filenamePattern;
private QName type;
private Map params;
- public WorkflowWrapper(String id)
+ public WorkflowWrapper(String id, String title)
{
this.id = id;
+ this.title = title;
this.filenamePattern = filenamePattern;
}
@@ -1229,9 +942,17 @@ public class CreateWebsiteWizard extends BaseWizardBean
/**
* @return Returns the name of the workflow.
*/
- public String getName()
+ //public String getName()
+ //{
+ // return workflowService.getDefinitionById(this.getId()).getName();
+ //}
+
+ /**
+ * @return the display label of the workflow.
+ */
+ public String getTitle()
{
- return workflowService.getDefinitionById(this.getId()).getName();
+ return this.title;
}
/**
diff --git a/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java b/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java
index ed4c290204..186bc774d1 100644
--- a/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/FormDetailsDialog.java
@@ -231,7 +231,8 @@ public class FormDetailsDialog extends BaseDialogBean
}
if (this.workflowSelectedValue != null && this.workflowSelectedValue.length != 0)
{
- form.setWorkflow(websiteWizard.getWorkflowWrapper(this.workflowSelectedValue[0]));
+ WorkflowDefinition def = this.workflowService.getDefinitionById(this.workflowSelectedValue[0]);
+ form.setWorkflow(new CreateWebsiteWizard.WorkflowWrapper(def.getId(), def.getTitle()));
}
return outcome;
}
diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
index ef99cf45bc..4bf3115d27 100644
--- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
@@ -1,64 +1,191 @@
package org.alfresco.web.bean.wcm;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.wizard.InviteUsersWizard;
+import org.alfresco.web.bean.wizard.InviteUsersWizard.UserGroupRole;
/**
- * Concrete implementation providing the ability to invite users to a space.
+ * Bean providing the ability to invite users to a web project space.
*
- * @author gavinc
+ * @author kevinr
*/
public class InviteWebsiteUsersWizard extends InviteUsersWizard
{
- private static final String WIZARD_TITLE_ID = "invite_title";
- private static final String WIZARD_DESC_ID = "invite_desc";
- private static final String STEP1_DESCRIPTION_ID = "invite_step1_desc";
+ private static final String MSG_USERROLES = "invite_webusers_summary_users";
/** Cache of available folder permissions */
Set folderPermissions = null;
+ /** the node representing the website */
private Node website;
+ /** list of authorities with the Content Manager role */
+ private List managers;
+
+ /** root AVM store the users are invited into */
+ private String avmStore;
+
+ /** assume we are launching the wizard standalone */
+ private boolean standalone = true;
+
/**
- * @see org.alfresco.web.bean.wizard.InviteUsersWizard#init()
+ * @see org.alfresco.web.bean.wizard.InviteUsersWizard#init(java.util.Map)
*/
@Override
- public void init()
+ public void init(Map parameters)
{
- super.init();
+ super.init(parameters);
// only allow one selection per authority
- allowDuplicateAuthorities = false;
+ this.allowDuplicateAuthorities = false;
+ this.website = null;
+ this.managers = null;
+ this.avmStore = null;
+ this.standalone = true;
}
/**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
+ * @see org.alfresco.web.bean.wizard.InviteUsersWizard#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
- public String getWizardDescription()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
- */
- public String getWizardTitle()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
- }
-
@Override
- protected String getStep1DescriptionText()
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
{
- return STEP1_DESCRIPTION_ID;
+ super.finishImpl(context, outcome);
+
+ // create a sandbox for each user appropriately with permissions based on role
+ // build a list of managers who will have full permissions on ALL staging areas
+ this.managers = new ArrayList(4);
+ Set excludeUsers = new HashSet(4);
+ if (isStandalone() == false)
+ {
+ // no website created yet - so we need to build the list of managers from the
+ // invited users and the power user who is executing the create web project wizard
+ boolean foundCurrentUser = false;
+ String currentUser = Application.getCurrentUser(context).getUserName();
+ for (UserGroupRole userRole : this.userGroupRoles)
+ {
+ String authority = userRole.getAuthority();
+ if (currentUser.equals(authority))
+ {
+ foundCurrentUser = true;
+ }
+ if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole()))
+ {
+ this.managers.add(authority);
+ }
+ }
+ if (foundCurrentUser == false)
+ {
+ this.userGroupRoles.add(new UserGroupRole(currentUser, SandboxFactory.ROLE_CONTENT_MANAGER, null));
+ this.managers.add(currentUser);
+ }
+ }
+ else
+ {
+ // website already exists - we are only adding to the existing sandboxes
+ // so retrieve the list of managers from the existing users and the selected invitees
+ for (UserGroupRole userRole : this.userGroupRoles)
+ {
+ if (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userRole.getRole()))
+ {
+ this.managers.add(userRole.getAuthority());
+ }
+ }
+ List userInfoRefs = this.nodeService.getChildAssocs(
+ getNode().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 (SandboxFactory.ROLE_CONTENT_MANAGER.equals(userrole) &&
+ this.managers.contains(username) == false)
+ {
+ this.managers.add(username);
+ }
+ // add each existing user to the exclude this - we cannot add them more than once!
+ excludeUsers.add(username);
+ }
+ }
+
+ // build the sandboxes now we have the manager list and complete user list
+ for (UserGroupRole userRole : this.userGroupRoles)
+ {
+ String authority = userRole.getAuthority();
+ if (excludeUsers.contains(authority) == false)
+ {
+ SandboxFactory.createUserSandbox(
+ getAvmStore(), this.managers, userRole.getAuthority(), userRole.getRole());
+ }
+ }
+
+ // save the list of invited users against the store
+ for (UserGroupRole userRole : this.userGroupRoles)
+ {
+ String authority = userRole.getAuthority();
+ if (excludeUsers.contains(authority) == false)
+ {
+ // create an app:webuser instance for each authority and assoc to the website node
+ Map props = new HashMap(2, 1.0f);
+ props.put(ContentModel.PROP_WEBUSERNAME, authority);
+ props.put(ContentModel.PROP_WEBUSERROLE, userRole.getRole());
+ this.nodeService.createNode(getNode().getNodeRef(),
+ ContentModel.ASSOC_WEBUSER,
+ ContentModel.ASSOC_WEBUSER,
+ ContentModel.TYPE_WEBUSER,
+ props);
+ }
+ }
+ return outcome;
}
+ /**
+ * @return summary text for the wizard
+ */
+ public String getSummary()
+ {
+ FacesContext fc = FacesContext.getCurrentInstance();
+
+ // build a summary section to list the invited users and there roles
+ StringBuilder buf = new StringBuilder(128);
+ String currentUser = Application.getCurrentUser(fc).getUserName();
+ boolean foundCurrentUser = false;
+ for (UserGroupRole userRole : this.userGroupRoles)
+ {
+ if (currentUser.equals(userRole.getAuthority()))
+ {
+ foundCurrentUser = true;
+ }
+ buf.append(userRole.getLabel());
+ buf.append("
");
+ }
+ if (foundCurrentUser == false)
+ {
+ buf.append(buildLabelForUserAuthorityRole(
+ currentUser, SandboxFactory.ROLE_CONTENT_MANAGER));
+ }
+
+ return buildSummary(
+ new String[] {Application.getMessage(fc, MSG_USERROLES)},
+ new String[] {buf.toString()});
+ }
+
@Override
protected Set getPermissionsForType()
{
@@ -79,6 +206,57 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard
@Override
protected Node getNode()
{
- return this.website;
+ if (this.website != null)
+ {
+ return this.website;
+ }
+ else
+ {
+ return this.browseBean.getActionSpace();
+ }
+ }
+
+ /**
+ * @return List of authorities with the Content Manager role
+ */
+ public List getManagers()
+ {
+ return this.managers;
+ }
+
+ /**
+ * @return Returns the root AVM store.
+ */
+ public String getAvmStore()
+ {
+ if (this.avmStore == null)
+ {
+ this.avmStore = (String)getNode().getProperties().get(ContentModel.PROP_AVMSTORE);
+ }
+ return this.avmStore;
+ }
+
+ /**
+ * @param avmStore The root AVM store to set.
+ */
+ public void setAvmStore(String avmStore)
+ {
+ this.avmStore = avmStore;
+ }
+
+ /**
+ * @return Returns the edit mode.
+ */
+ public boolean isStandalone()
+ {
+ return this.standalone;
+ }
+
+ /**
+ * @param editMode The edit mode to set.
+ */
+ public void setStandalone(boolean editMode)
+ {
+ this.standalone = editMode;
}
}
diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java
new file mode 100644
index 0000000000..19b09d0370
--- /dev/null
+++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java
@@ -0,0 +1,300 @@
+/*
+ * 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.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.avm.AVMService;
+import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.GUID;
+import org.alfresco.web.bean.repository.Repository;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper factory to create AVM sandbox structures.
+ *
+ * @author Kevin Roast
+ */
+public final class SandboxFactory
+{
+ private static Log logger = LogFactory.getLog(SandboxFactory.class);
+
+ public static final String ROLE_CONTENT_MANAGER = "ContentManager";
+
+ /**
+ * Private constructor
+ */
+ private SandboxFactory()
+ {
+ }
+
+ /**
+ * Create the staging sandbox for the named store.
+ *
+ * A staging sandbox is comprised of two stores, the first named 'storename-staging' with a
+ * preview store named 'storename-preview' layered over the staging store.
+ *
+ * Various store meta-data properties are set including:
+ * Identifier for store-types: .sandbox.staging.main and .sandbox.staging.preview
+ * Store-id: .sandbox-id. (unique across all stores in the sandbox)
+ * DNS: .dns. =
+ * Website Name: .website.name = website name
+ *
+ * @param name The store name to create the sandbox for
+ * @param managers The list of authorities who have ContentManager role in the website
+ */
+ public static void createStagingSandbox(String name, List managers)
+ {
+ ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
+ AVMService avmService = services.getAVMService();
+ PermissionService permissionService = services.getPermissionService();
+
+ // create the 'staging' store for the website
+ String stagingStore = AVMConstants.buildAVMStagingStoreName(name);
+ avmService.createAVMStore(stagingStore);
+ if (logger.isDebugEnabled())
+ logger.debug("Created staging sandbox store: " + stagingStore);
+
+ // create the system directories 'appBase' and 'avm_webapps'
+ String path = stagingStore + ":/";
+ //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
+ avmService.createDirectory(path, AVMConstants.DIR_APPBASE);
+ NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
+ for (String manager : managers)
+ {
+ permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
+ }
+ path += AVMConstants.DIR_APPBASE;
+ //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_WEBAPPS, ContentModel.TYPE_AVM_PLAIN_FOLDER);
+ avmService.createDirectory(path, AVMConstants.DIR_WEBAPPS);
+
+ // tag the store with the store type
+ avmService.setStoreProperty(stagingStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_MAIN),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with the DNS name property
+ tagStoreDNSPath(avmService, stagingStore, name, "staging");
+
+ // snapshot the store
+ avmService.createSnapshot(stagingStore, null, null);
+
+
+ // create the 'preview' store for the website
+ String previewStore = AVMConstants.buildAVMStagingPreviewStoreName(name);
+ avmService.createAVMStore(previewStore);
+ if (logger.isDebugEnabled())
+ logger.debug("Created staging sandbox store: " + previewStore);
+
+ // create a layered directory pointing to 'appBase' in the staging area
+ path = previewStore + ":/";
+ String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
+ //this.fileFolderService.create(AVMNodeConverter.ToNodeRef(-1, path), AVMConstants.DIR_APPBASE, ContentModel.TYPE_AVM_PLAIN_FOLDER);
+ avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
+ dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
+ for (String manager : managers)
+ {
+ permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
+ }
+
+ // tag the store with the store type
+ avmService.setStoreProperty(previewStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_PREVIEW),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with the DNS name property
+ tagStoreDNSPath(avmService, previewStore, name, "preview");
+
+ // snapshot the store
+ avmService.createSnapshot(previewStore, null, null);
+
+
+ // tag all related stores to indicate that they are part of a single sandbox
+ String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
+ avmService.setStoreProperty(stagingStore,
+ QName.createQName(null, sandboxIdProp),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+ avmService.setStoreProperty(previewStore,
+ QName.createQName(null, sandboxIdProp),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ if (logger.isDebugEnabled())
+ {
+ dumpStoreProperties(avmService, stagingStore);
+ dumpStoreProperties(avmService, previewStore);
+ }
+ }
+
+ /**
+ * Create a user sandbox for the named store.
+ *
+ * A user sandbox is comprised of two stores, the first named 'storename-username-main' layered
+ * over the staging store with a preview store named 'storename-username-preview' layered over
+ * the main store.
+ *
+ * Various store meta-data properties are set including:
+ * Identifier for store-types: .sandbox.author.main and .sandbox.author.preview
+ * Store-id: .sandbox-id. (unique across all stores in the sandbox)
+ * DNS: .dns. =
+ * Website Name: .website.name = website name
+ *
+ * @param name The store name to create the sandbox for
+ * @param managers The list of authorities who have ContentManager role in the website
+ * @param username Username of the user to create the sandbox for
+ * @param role Role permission for the user
+ */
+ public static void createUserSandbox(String name, List managers, String username, String role)
+ {
+ ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
+ AVMService avmService = services.getAVMService();
+ PermissionService permissionService = services.getPermissionService();
+
+ // create the user 'main' store
+ String userStore = AVMConstants.buildAVMUserMainStoreName(name, username);
+ if (avmService.getAVMStore(userStore) == null)
+ {
+ avmService.createAVMStore(userStore);
+ if (logger.isDebugEnabled())
+ logger.debug("Created user sandbox store: " + userStore);
+
+ // create a layered directory pointing to 'appBase' in the staging area
+ String path = userStore + ":/";
+ String targetPath = name + AVMConstants.STORE_STAGING + ":/" + AVMConstants.DIR_APPBASE;
+ avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
+ NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
+ permissionService.setPermission(dirRef, username, role, true);
+ for (String manager : managers)
+ {
+ permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
+ }
+
+ // tag the store with the store type
+ avmService.setStoreProperty(userStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with the base name of the website so that corresponding
+ // staging areas can be found.
+ avmService.setStoreProperty(userStore,
+ QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
+ new PropertyValue(DataTypeDefinition.TEXT, name));
+
+ // tag the store, oddly enough, with its own store name for querying.
+ // when will the madness end.
+ avmService.setStoreProperty(userStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + userStore),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with the DNS name property
+ tagStoreDNSPath(avmService, userStore, name, username);
+
+ // snapshot the store
+ avmService.createSnapshot(userStore, null, null);
+
+
+ // create the user 'preview' store
+ String previewStore = AVMConstants.buildAVMUserPreviewStoreName(name, username);
+ avmService.createAVMStore(previewStore);
+ if (logger.isDebugEnabled())
+ logger.debug("Created user sandbox store: " + previewStore);
+
+ // create a layered directory pointing to 'appBase' in the user 'main' store
+ path = previewStore + ":/";
+ targetPath = userStore + ":/" + AVMConstants.DIR_APPBASE;
+ avmService.createLayeredDirectory(targetPath, path, AVMConstants.DIR_APPBASE);
+ dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
+ permissionService.setPermission(dirRef, username, role, true);
+ for (String manager : managers)
+ {
+ permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
+ }
+
+ // tag the store with the store type
+ avmService.setStoreProperty(previewStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with its own store name for querying.
+ avmService.setStoreProperty(previewStore,
+ QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + previewStore),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ // tag the store with the DNS name property
+ tagStoreDNSPath(avmService, previewStore, name, username, "preview");
+
+ // snapshot the store
+ avmService.createSnapshot(previewStore, null, null);
+
+
+ // tag all related stores to indicate that they are part of a single sandbox
+ String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
+ avmService.setStoreProperty(userStore, QName.createQName(null, sandboxIdProp),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+ avmService.setStoreProperty(previewStore, QName.createQName(null, sandboxIdProp),
+ new PropertyValue(DataTypeDefinition.TEXT, null));
+
+ if (logger.isDebugEnabled())
+ {
+ dumpStoreProperties(avmService, userStore);
+ dumpStoreProperties(avmService, previewStore);
+ }
+ }
+ else if (logger.isDebugEnabled())
+ {
+ logger.debug("Not creating as store already exists: " + userStore);
+ }
+ }
+
+ /**
+ * Tag a named store with a DNS path meta-data attribute.
+ * The DNS meta-data attribute is set to the system path 'store:/appBase/avm_webapps'
+ *
+ * @param store Name of the store to tag
+ */
+ private static void tagStoreDNSPath(AVMService avmService, String store, String... components)
+ {
+ String path = store + ":/" + AVMConstants.DIR_APPBASE + '/' + AVMConstants.DIR_WEBAPPS;
+ // DNS name mangle the property name - can only contain value DNS characters!
+ String dnsProp = AVMConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components);
+ avmService.setStoreProperty(store, QName.createQName(null, dnsProp),
+ new PropertyValue(DataTypeDefinition.TEXT, path));
+ }
+
+ /**
+ * Debug helper method to dump the properties of a store
+ *
+ * @param store Store name to dump properties for
+ */
+ private static void dumpStoreProperties(AVMService avmService, String store)
+ {
+ Map props = avmService.getStoreProperties(store);
+ for (QName name : props.keySet())
+ {
+ logger.debug(" " + name + ": " + props.get(name));
+ }
+ }
+}
diff --git a/source/java/org/alfresco/web/bean/wizard/InviteContentUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/InviteContentUsersWizard.java
index ec7f0b9f53..9aded881f8 100644
--- a/source/java/org/alfresco/web/bean/wizard/InviteContentUsersWizard.java
+++ b/source/java/org/alfresco/web/bean/wizard/InviteContentUsersWizard.java
@@ -2,10 +2,7 @@ package org.alfresco.web.bean.wizard;
import java.util.Set;
-import javax.faces.context.FacesContext;
-
import org.alfresco.model.ContentModel;
-import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
@@ -15,35 +12,9 @@ import org.alfresco.web.bean.repository.Node;
*/
public class InviteContentUsersWizard extends InviteUsersWizard
{
- private static final String WIZARD_TITLE_ID = "invite_content_title";
- private static final String WIZARD_DESC_ID = "invite_content_desc";
- private static final String STEP1_DESCRIPTION_ID = "invite_content_step1_desc";
-
/** Cache of available content permissions */
Set contentPermissions = null;
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
- */
- public String getWizardDescription()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
- */
- public String getWizardTitle()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
- }
-
- @Override
- protected String getStep1DescriptionText()
- {
- return STEP1_DESCRIPTION_ID;
- }
-
@Override
protected Set getPermissionsForType()
{
diff --git a/source/java/org/alfresco/web/bean/wizard/InviteSpaceUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/InviteSpaceUsersWizard.java
index 1acb0bc0bf..90b72d9fcd 100644
--- a/source/java/org/alfresco/web/bean/wizard/InviteSpaceUsersWizard.java
+++ b/source/java/org/alfresco/web/bean/wizard/InviteSpaceUsersWizard.java
@@ -2,10 +2,7 @@ package org.alfresco.web.bean.wizard;
import java.util.Set;
-import javax.faces.context.FacesContext;
-
import org.alfresco.model.ContentModel;
-import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
@@ -15,35 +12,9 @@ import org.alfresco.web.bean.repository.Node;
*/
public class InviteSpaceUsersWizard extends InviteUsersWizard
{
- private static final String WIZARD_TITLE_ID = "invite_title";
- private static final String WIZARD_DESC_ID = "invite_desc";
- private static final String STEP1_DESCRIPTION_ID = "invite_step1_desc";
-
/** Cache of available folder permissions */
Set folderPermissions = null;
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
- */
- public String getWizardDescription()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
- */
- public String getWizardTitle()
- {
- return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
- }
-
- @Override
- protected String getStep1DescriptionText()
- {
- return STEP1_DESCRIPTION_ID;
- }
-
@Override
protected Set getPermissionsForType()
{
diff --git a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java
index 39fd4ab008..5d09d852a6 100644
--- a/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java
+++ b/source/java/org/alfresco/web/bean/wizard/InviteUsersWizard.java
@@ -20,6 +20,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
@@ -39,7 +40,6 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.Application;
-import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.TemplateMailHelperBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
@@ -52,9 +52,11 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.mail.javamail.JavaMailSender;
/**
+ * Backing bean for the Invite Users wizard(s)
+ *
* @author Kevin Roast
*/
-public abstract class InviteUsersWizard extends AbstractWizardBean
+public abstract class InviteUsersWizard extends BaseWizardBean
{
private static Log logger = LogFactory.getLog(InviteUsersWizard.class);
@@ -63,10 +65,6 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
private static final String MSG_GROUPS = "groups";
private static final String MSG_INVITED_TO = "invited_to";
private static final String MSG_INVITED_ROLE = "invite_role";
- private static final String STEP1_TITLE_ID = "invite_step1_title";
- private static final String STEP2_TITLE_ID = "invite_step2_title";
- private static final String STEP2_DESCRIPTION_ID = "invite_step2_desc";
- private static final String FINISH_INSTRUCTION_ID = "invite_finish_instruction";
private static final String NOTIFY_YES = "yes";
@@ -89,10 +87,10 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
protected TemplateMailHelperBean mailHelper;
/** datamodel for table of roles for users */
- private DataModel userRolesDataModel = null;
+ protected DataModel userRolesDataModel = null;
/** list of user/group role wrapper objects */
- private List userGroupRoles = null;
+ protected List userGroupRoles = null;
/** True to allow duplicate authorities (with a different role) */
protected boolean allowDuplicateAuthorities = true;
@@ -110,11 +108,6 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
*/
protected abstract Node getNode();
- /**
- * @return The text to use for the description of step 1 (depends on the type being dealt with)
- */
- protected abstract String getStep1DescriptionText();
-
/**
* @param namespaceService The NamespaceService to set.
*/
@@ -158,9 +151,10 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
/**
* Initialises the wizard
*/
- public void init()
+ @Override
+ public void init(Map parameters)
{
- super.init();
+ super.init(parameters);
notify = NOTIFY_YES;
userGroupRoles = new ArrayList(8);
@@ -170,94 +164,70 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
}
/**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#finish()
+ * @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
- public String finish()
+ @Override
+ protected String finishImpl(FacesContext context, String outcome) throws Exception
{
- String outcome = FINISH_OUTCOME;
-
- UserTransaction tx = null;
-
- try
+ User user = Application.getCurrentUser(context);
+ String from = (String)this.nodeService.getProperty(user.getPerson(), ContentModel.PROP_EMAIL);
+ if (from == null || from.length() == 0)
{
- FacesContext context = FacesContext.getCurrentInstance();
+ // if the user does not have an email address get the default one from the config service
+ from = Application.getClientConfig(context).getFromEmailAddress();
+ }
+
+ // get the Space to apply changes too
+ NodeRef nodeRef = this.getNode().getNodeRef();
+
+ // set permissions for each user and send them a mail
+ for (int i=0; i perms = getPermissionsForType();
+ for (String permission : perms)
{
- // if the user does not have an email address get the default one from the config service
- from = Application.getClientConfig(context).getFromEmailAddress();
+ if (userGroupRole.getRole().equals(permission))
+ {
+ this.permissionService.setPermission(
+ nodeRef,
+ authority,
+ permission,
+ true);
+ break;
+ }
}
- // get the Space to apply changes too
- NodeRef nodeRef = this.getNode().getNodeRef();
-
- // set permissions for each user and send them a mail
- for (int i=0; i perms = getPermissionsForType();
- for (String permission : perms)
+ // if User, email then, else if Group get all members and email them
+ AuthorityType authType = AuthorityType.getAuthorityType(authority);
+ if (authType.equals(AuthorityType.USER))
{
- if (userGroupRole.getRole().equals(permission))
+ if (this.personService.personExists(authority) == true)
{
- this.permissionService.setPermission(
- nodeRef,
- authority,
- permission,
- true);
- break;
+ this.mailHelper.notifyUser(
+ this.personService.getPerson(authority), nodeRef, from, userGroupRole.getRole());
}
}
-
- // Create the mail message for sending to each User
- if (NOTIFY_YES.equals(this.notify))
+ else if (authType.equals(AuthorityType.GROUP))
{
- // if User, email then, else if Group get all members and email them
- AuthorityType authType = AuthorityType.getAuthorityType(authority);
- if (authType.equals(AuthorityType.USER))
+ // else notify all members of the group
+ Set users = this.authorityService.getContainedAuthorities(AuthorityType.USER, authority, false);
+ for (String userAuth : users)
{
- if (this.personService.personExists(authority) == true)
+ if (this.personService.personExists(userAuth) == true)
{
this.mailHelper.notifyUser(
- this.personService.getPerson(authority), nodeRef, from, userGroupRole.getRole());
- }
- }
- else if (authType.equals(AuthorityType.GROUP))
- {
- // else notify all members of the group
- Set users = this.authorityService.getContainedAuthorities(AuthorityType.USER, authority, false);
- for (String userAuth : users)
- {
- if (this.personService.personExists(userAuth) == true)
- {
- this.mailHelper.notifyUser(
- this.personService.getPerson(userAuth), nodeRef, from, userGroupRole.getRole());
- }
+ this.personService.getPerson(userAuth), nodeRef, from, userGroupRole.getRole());
}
}
}
}
-
- // commit the transaction
- tx.commit();
-
- UIContextService.getInstance(context).notifyBeans();
- }
- 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);
- outcome = null;
}
return outcome;
@@ -486,100 +456,19 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
this.notify = notify;
}
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
- */
- public String getStepDescription()
- {
- String stepDesc = null;
-
- switch (this.currentStep)
- {
- case 1:
- {
- stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), getStep1DescriptionText());
- break;
- }
- case 2:
- {
- stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_DESCRIPTION_ID);
- break;
- }
- default:
- {
- stepDesc = "";
- }
- }
-
- return stepDesc;
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
- */
- public String getStepTitle()
- {
- String stepTitle = null;
-
- switch (this.currentStep)
- {
- case 1:
- {
- stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
- break;
- }
- case 2:
- {
- stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
- break;
- }
- default:
- {
- stepTitle = "";
- }
- }
-
- return stepTitle;
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
- */
- public String getStepInstructions()
- {
- String stepInstruction = null;
-
- switch (this.currentStep)
- {
- case 2:
- {
- stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
- break;
- }
- default:
- {
- stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
- }
- }
-
- return stepInstruction;
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#next()
- */
+ @Override
public String next()
{
- String outcome = super.next();
+ String stepName = Application.getWizardManager().getCurrentStepName();
- if (outcome.equals("notify"))
+ if (stepName.equals("notify"))
{
FacesContext context = FacesContext.getCurrentInstance();
// prepare automatic text for email and display
StringBuilder buf = new StringBuilder(256);
- String personName = Application.getCurrentUser(context).getFullName(getNodeService());
+ String personName = Application.getCurrentUser(context).getFullName(this.nodeService);
String msgInvitedTo = Application.getMessage(context, MSG_INVITED_TO);
Node node = this.getNode();
String path = this.nodeService.getPath(node.getNodeRef()).toDisplayPath(this.nodeService);
@@ -612,35 +501,7 @@ public abstract class InviteUsersWizard extends AbstractWizardBean
this.mailHelper.setBody(this.mailHelper.getAutomaticText());
}
- return outcome;
- }
-
- /**
- * @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
- */
- protected String determineOutcomeForStep(int step)
- {
- String outcome = null;
-
- switch(step)
- {
- case 1:
- {
- outcome = "invite";
- break;
- }
- case 2:
- {
- outcome = "notify";
- break;
- }
- default:
- {
- outcome = CANCEL_OUTCOME;
- }
- }
-
- return outcome;
+ return null;
}
/**
diff --git a/source/java/org/alfresco/web/bean/wizard/WizardManager.java b/source/java/org/alfresco/web/bean/wizard/WizardManager.java
index 6d705ab83f..050dee6257 100644
--- a/source/java/org/alfresco/web/bean/wizard/WizardManager.java
+++ b/source/java/org/alfresco/web/bean/wizard/WizardManager.java
@@ -33,6 +33,16 @@ public final class WizardManager
private WizardState currentWizardState;
private Map paramsToApply;
+ /**
+ * Action handler used to setup parameters for the wizard being launched
+ *
+ * @param params The parameters
+ */
+ public void setupParameters(Map params)
+ {
+ this.paramsToApply = params;
+ }
+
/**
* Action handler used to setup parameters for the wizard being launched
*
@@ -45,7 +55,7 @@ public final class WizardManager
if (component instanceof UIActionLink)
{
// store the parameters
- this.paramsToApply = ((UIActionLink)component).getParameterMap();
+ setupParameters( ((UIActionLink)component).getParameterMap() );
}
}
diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml
index 2a75c28b26..b932cb7971 100644
--- a/source/web/WEB-INF/faces-config-beans.xml
+++ b/source/web/WEB-INF/faces-config-beans.xml
@@ -2156,10 +2156,6 @@
avmService
#{AVMService}
-
- permissionService
- #{PermissionService}
-
workflowService
#{WorkflowService}
diff --git a/source/web/jsp/wcm/create-website-wizard/settings.jsp b/source/web/jsp/wcm/create-website-wizard/settings.jsp
index 2c7aa8c1fd..ea6e719693 100644
--- a/source/web/jsp/wcm/create-website-wizard/settings.jsp
+++ b/source/web/jsp/wcm/create-website-wizard/settings.jsp
@@ -46,7 +46,7 @@
-
+