- You can now invite and notify multiple users when creating a new website
 - Each user has a sandbox area to play in
 - Each sandbox is layered over the staging area sandbox

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3876 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-21 18:05:17 +00:00
parent 83fcb2064c
commit 6bd9a2e4e0
10 changed files with 336 additions and 33 deletions

View File

@@ -37,6 +37,7 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService;
@@ -212,8 +213,8 @@ public class AVMBrowseBean implements IContextListener
AVMStoreDescriptor store = this.avmService.getAVMStore(stagingStore);
if (store != null)
{
// TODO: count user stores!
int users = 1;
// TODO: count user stores with correct query
int users = avmService.queryStoresPropertyKeys(QName.createQName(null, storeRoot + "-%" + AVMConstants.STORE_MAIN)).size();
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
.append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
.append("<p>");

View File

@@ -49,7 +49,7 @@ public class AVMNode implements Map<String, Object>
public AVMNode(AVMNodeDescriptor avmRef)
{
this.avmRef = avmRef;
this.version = -1; // TODO: always 1 for now...
this.version = -1; // TODO: always -1 for now...
this.path = avmRef.getPath();
getProperties();

View File

@@ -36,9 +36,13 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.BaseWizardBean;
import org.alfresco.web.bean.wizard.InviteUsersWizard.UserGroupRole;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,6 +75,11 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.name = null;
this.title = null;
this.description = null;
// init the dependant bean we are using for the invite users pages
InviteWebsiteUsersWizard wiz = (InviteWebsiteUsersWizard)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "InviteWebsiteUsersWizard");
wiz.init();
}
/**
@@ -97,29 +106,41 @@ public class CreateWebsiteWizard extends BaseWizardBean
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description);
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, uiFacetsProps);
// TODO: invite users with appropriate permissions into this folder
// create the AVM stores (layers) to represent the newly created location website
createStagingSandbox(this.name);
// create a sandbox for each user - TODO: based on role?
List<String> invitedUsers = getInvitedUsernames();
invitedUsers.add(Application.getCurrentUser(context).getUserName());
for (String username : invitedUsers)
{
createUserSandbox(this.name, username);
// invite users with appropriate permissions into this folder
InviteWebsiteUsersWizard wiz = (InviteWebsiteUsersWizard)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "InviteWebsiteUsersWizard");
wiz.setNode(new Node(nodeRef));
outcome = wiz.finish();
if (outcome != null)
{
// create the AVM stores (layers) to represent the newly created location website
createStagingSandbox(this.name);
// create a sandbox for each user
// TODO: create sandbox appropriately based on role
List<String> invitedUsers = getInvitedUsernames(wiz);
String currentUser = Application.getCurrentUser(context).getUserName();
if (invitedUsers.contains(currentUser) == false)
{
invitedUsers.add(Application.getCurrentUser(context).getUserName());
}
for (String username : invitedUsers)
{
createUserSandbox(this.name, username);
}
// save the list of invited users against the store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_USERSANDBOXES, (Serializable)invitedUsers);
// set the property on the node to reference the AVM store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, this.name);
// navigate to the Websites folder so we can see the newly created folder
this.navigator.setCurrentNodeId(websiteParentId);
outcome = AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
}
// save the list of invited users against the store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_USERSANDBOXES, (Serializable)invitedUsers);
// set the property on the node to reference the AVM store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, this.name);
// navigate to the Websites folder so we can see the newly created folder
this.navigator.setCurrentNodeId(websiteParentId);
return "browse";
return outcome;
}
/**
@@ -303,6 +324,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
* Identifier for store-types: .sandbox.author.main and .sandbox.author.preview
* Store-id: .sandbox-id.<guid> (unique across all stores in the sandbox)
* DNS: .dns.<store> = <path-to-webapps-root>
* Website Name: .website.name = website name
*
* @param name The store name to create the sandbox for
* @param username Username of the user to create the sandbox for
@@ -381,9 +403,15 @@ public class CreateWebsiteWizard extends BaseWizardBean
/**
* @return The list of invited usernames
*/
private List<String> getInvitedUsernames()
private List<String> getInvitedUsernames(InviteWebsiteUsersWizard wizard)
{
// TODO: add the list of invited users here
return new ArrayList<String>(1);
// add the list of invited users here
List<UserGroupRole> users = (List<UserGroupRole>)wizard.getUserRolesDataModel().getWrappedData();
List<String> invited = new ArrayList<String>(users.size());
for (UserGroupRole u : users)
{
invited.add(u.getAuthority());
}
return invited;
}
}

View File

@@ -0,0 +1,72 @@
package org.alfresco.web.bean.wcm;
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;
import org.alfresco.web.bean.wizard.InviteUsersWizard;
/**
* Concrete implementation providing the ability to invite users to a space.
*
* @author gavinc
*/
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";
/** Cache of available folder permissions */
Set<String> folderPermissions = null;
private Node website;
/**
* @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<String> getPermissionsForType()
{
if (this.folderPermissions == null)
{
// TODO: get permissions for a website folder type
this.folderPermissions = this.permissionService.getSettablePermissions(ContentModel.TYPE_FOLDER);
}
return this.folderPermissions;
}
protected void setNode(Node node)
{
this.website = node;
}
@Override
protected Node getNode()
{
return this.website;
}
}

View File

@@ -303,6 +303,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
String stagingStore = AVMConstants.buildAVMStagingStoreName(storeRoot) + ":/";
// get the UIActions component responsible for rendering context related user actions
// TODO: we may need a component per user instance
UIActions uiFileActions = aquireUIActions(ACTIONS_FILE);
UIActions uiFolderActions = aquireUIActions(ACTIONS_FOLDER);
@@ -504,7 +505,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
private UIActionLink aquireAction(FacesContext fc, String store, String username,
String name, String icon, String actionListener, String outcome)
{
UIActionLink action = findAction(name);
UIActionLink action = findAction(name, username);
if (action == null)
{
action = createAction(fc, store, username, name, icon, actionListener, outcome);
@@ -515,14 +516,15 @@ public class UIUserSandboxes extends SelfRenderingComponent
/**
* Locate a child UIActionLink component by name.
*
* @param name Of the action component to find
* @param name Of the action component to find
* @param username Username of the user owner of the action
*
* @return UIActionLink component if found, else null if not created yet
*/
private UIActionLink findAction(String name)
private UIActionLink findAction(String name, String username)
{
UIActionLink action = null;
String actionId = getId() + name;
String actionId = getId() + name + username;
for (UIComponent component : (List<UIComponent>)getChildren())
{
if (actionId.equals(component.getId()))
@@ -554,7 +556,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
UIActionLink control = (UIActionLink)facesApp.createComponent(UIActions.COMPONENT_ACTIONLINK);
control.setRendererType(UIActions.RENDERER_ACTIONLINK);
control.setId(getId() + name);
control.setId(getId() + name + username);
control.setValue(Application.getMessage(fc, name));
control.setShowLink(false);
control.setImage(icon);