mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge of converted wizards and dialogs done by usethelink
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6828 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
public class ChangeMyPasswordDialog extends UsersDialog
|
||||
{
|
||||
|
||||
private static final String MSG_FINISH_BUTTON = "finish_button";
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
String result = changeMyPasswordOK(outcome, context);
|
||||
if (result == null)
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_FINISH_BUTTON);
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called for OK button press on Change My Password screen For this screen the user is required to enter their old password - effectively login.
|
||||
*/
|
||||
public String changeMyPasswordOK(String newOutcome, FacesContext newContext)
|
||||
{
|
||||
String outcome = newOutcome;
|
||||
|
||||
if (properties.getPassword() != null && properties.getConfirm() != null && properties.getPassword().equals(properties.getConfirm()))
|
||||
{
|
||||
try
|
||||
{
|
||||
String userName = (String) properties.getPerson().getProperties().get(ContentModel.PROP_USERNAME);
|
||||
properties.getAuthenticationService().updateAuthentication(userName, properties.getOldPassword().toCharArray(), properties.getPassword().toCharArray());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(newContext, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
public class ChangePasswordDialog extends UsersDialog
|
||||
{
|
||||
|
||||
private static final String MSG_FINISH_BUTTON = "finish_button";
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
String result = changePasswordOK(outcome, context);
|
||||
if (result == null)
|
||||
{
|
||||
isFinished = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_FINISH_BUTTON);
|
||||
}
|
||||
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called for OK button press on Change Password screen
|
||||
*/
|
||||
public String changePasswordOK(String newOutcome, FacesContext newContext)
|
||||
{
|
||||
String outcome = newOutcome;
|
||||
|
||||
if (properties.getPassword() != null && properties.getConfirm() != null && properties.getPassword().equals(properties.getConfirm()))
|
||||
{
|
||||
try
|
||||
{
|
||||
String userName = (String) properties.getPerson().getProperties().get(ContentModel.PROP_USERNAME);
|
||||
properties.getAuthenticationService().setAuthentication(userName, properties.getPassword().toCharArray());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(newContext, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
}
|
596
source/java/org/alfresco/web/bean/users/CreateUserWizard.java
Normal file
596
source/java/org/alfresco/web/bean/users/CreateUserWizard.java
Normal file
@@ -0,0 +1,596 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.validator.ValidatorException;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.spaces.CreateSpaceWizard;
|
||||
import org.alfresco.web.bean.wizard.BaseWizardBean;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class CreateUserWizard extends BaseWizardBean
|
||||
{
|
||||
private static Logger logger = Logger.getLogger(CreateUserWizard.class);
|
||||
protected static final String ERROR = "error_person";
|
||||
|
||||
/** form variables */
|
||||
protected String firstName = null;
|
||||
protected String lastName = null;
|
||||
protected String userName = null;
|
||||
protected String password = null;
|
||||
protected String confirm = null;
|
||||
protected String email = null;
|
||||
protected String companyId = null;
|
||||
protected String homeSpaceName = "";
|
||||
protected NodeRef homeSpaceLocation = null;
|
||||
|
||||
/** AuthenticationService bean reference */
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
/** PersonService bean reference */
|
||||
private PersonService personService;
|
||||
|
||||
/** PermissionService bean reference */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/** OwnableService bean reference */
|
||||
private OwnableService ownableService;
|
||||
|
||||
/** ref to the company home space folder */
|
||||
private NodeRef companyHomeSpaceRef = null;
|
||||
|
||||
/** ref to the default home location */
|
||||
private NodeRef defaultHomeSpaceRef;
|
||||
|
||||
/**
|
||||
* @param authenticationService The AuthenticationService to set.
|
||||
*/
|
||||
public void setAuthenticationService(AuthenticationService authenticationService)
|
||||
{
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param personService The person service.
|
||||
*/
|
||||
public void setPersonService(PersonService personService)
|
||||
{
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService The PermissionService to set.
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownableService The ownableService to set.
|
||||
*/
|
||||
public void setOwnableService(OwnableService ownableService)
|
||||
{
|
||||
this.ownableService = ownableService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
@Override
|
||||
public void init(Map<String, String> arg0)
|
||||
{
|
||||
super.init(arg0);
|
||||
|
||||
// reset all variables
|
||||
this.firstName = "";
|
||||
this.lastName = "";
|
||||
this.userName = "";
|
||||
this.password = "";
|
||||
this.confirm = "";
|
||||
this.email = "";
|
||||
this.companyId = "";
|
||||
this.homeSpaceName = "";
|
||||
this.homeSpaceLocation = getDefaultHomeSpace();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
String homeSpaceLabel = this.homeSpaceName;
|
||||
if (this.homeSpaceName.length() == 0 && this.homeSpaceLocation != null)
|
||||
{
|
||||
homeSpaceLabel = Repository.getNameForNode(this.nodeService, this.homeSpaceLocation);
|
||||
}
|
||||
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
return buildSummary(new String[] { bundle.getString("name"), bundle.getString("username"), bundle.getString("password"), bundle.getString("homespace") }, new String[] {
|
||||
this.firstName + " " + this.lastName, this.userName, "********", homeSpaceLabel });
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the users screen
|
||||
*/
|
||||
public void setupUsers(ActionEvent event)
|
||||
{
|
||||
invalidateUserList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the companyId.
|
||||
*/
|
||||
public String getCompanyId()
|
||||
{
|
||||
return this.companyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param companyId The companyId to set.
|
||||
*/
|
||||
public void setCompanyId(String companyId)
|
||||
{
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the email.
|
||||
*/
|
||||
public String getEmail()
|
||||
{
|
||||
return this.email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param email The email to set.
|
||||
*/
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the firstName.
|
||||
*/
|
||||
public String getFirstName()
|
||||
{
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param firstName The firstName to set.
|
||||
*/
|
||||
public void setFirstName(String firstName)
|
||||
{
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the homeSpaceLocation.
|
||||
*/
|
||||
public NodeRef getHomeSpaceLocation()
|
||||
{
|
||||
return this.homeSpaceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param homeSpaceLocation The homeSpaceLocation to set.
|
||||
*/
|
||||
public void setHomeSpaceLocation(NodeRef homeSpaceLocation)
|
||||
{
|
||||
this.homeSpaceLocation = homeSpaceLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the homeSpaceName.
|
||||
*/
|
||||
public String getHomeSpaceName()
|
||||
{
|
||||
return this.homeSpaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param homeSpaceName The homeSpaceName to set.
|
||||
*/
|
||||
public void setHomeSpaceName(String homeSpaceName)
|
||||
{
|
||||
this.homeSpaceName = homeSpaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the lastName.
|
||||
*/
|
||||
public String getLastName()
|
||||
{
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastName The lastName to set.
|
||||
*/
|
||||
public void setLastName(String lastName)
|
||||
{
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the userName.
|
||||
*/
|
||||
public String getUserName()
|
||||
{
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userName The userName to set.
|
||||
*/
|
||||
public void setUserName(String userName)
|
||||
{
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the password.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password The password to set.
|
||||
*/
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the confirm password.
|
||||
*/
|
||||
public String getConfirm()
|
||||
{
|
||||
return this.confirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param confirm The confirm password to set.
|
||||
*/
|
||||
public void setConfirm(String confirm)
|
||||
{
|
||||
this.confirm = confirm;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Validator methods
|
||||
|
||||
/**
|
||||
* Validate password field data is acceptable
|
||||
*/
|
||||
public void validatePassword(FacesContext context, UIComponent component, Object value) throws ValidatorException
|
||||
{
|
||||
String pass = (String) value;
|
||||
if (pass.length() < 5 || pass.length() > 12)
|
||||
{
|
||||
String err = "Password must be between 5 and 12 characters in length.";
|
||||
throw new ValidatorException(new FacesMessage(err));
|
||||
}
|
||||
|
||||
for (int i = 0; i < pass.length(); i++)
|
||||
{
|
||||
if (Character.isLetterOrDigit(pass.charAt(i)) == false)
|
||||
{
|
||||
String err = "Password can only contain characters or digits.";
|
||||
throw new ValidatorException(new FacesMessage(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Username field data is acceptable
|
||||
*/
|
||||
public void validateUsername(FacesContext context, UIComponent component, Object value) throws ValidatorException
|
||||
{
|
||||
String pass = (String) value;
|
||||
if (pass.length() < 5 || pass.length() > 12)
|
||||
{
|
||||
String err = "Username must be between 5 and 12 characters in length.";
|
||||
throw new ValidatorException(new FacesMessage(err));
|
||||
}
|
||||
|
||||
for (int i = 0; i < pass.length(); i++)
|
||||
{
|
||||
if (Character.isLetterOrDigit(pass.charAt(i)) == false)
|
||||
{
|
||||
String err = "Username can only contain characters or digits.";
|
||||
throw new ValidatorException(new FacesMessage(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
/**
|
||||
* Helper to return the company home space
|
||||
*
|
||||
* @return company home space NodeRef
|
||||
*/
|
||||
protected NodeRef getCompanyHomeSpace()
|
||||
{
|
||||
if (this.companyHomeSpaceRef == null)
|
||||
{
|
||||
String companyXPath = Application.getRootPath(FacesContext.getCurrentInstance());
|
||||
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> nodes = this.searchService.selectNodes(rootNodeRef, companyXPath, null, this.namespaceService, false);
|
||||
|
||||
if (nodes.size() == 0)
|
||||
{
|
||||
throw new IllegalStateException("Unable to find company home space path: " + companyXPath);
|
||||
}
|
||||
|
||||
this.companyHomeSpaceRef = nodes.get(0);
|
||||
}
|
||||
|
||||
return this.companyHomeSpaceRef;
|
||||
}
|
||||
|
||||
protected NodeRef getDefaultHomeSpace()
|
||||
{
|
||||
if ((this.defaultHomeSpaceRef == null) || !nodeService.exists(this.defaultHomeSpaceRef))
|
||||
{
|
||||
String defaultHomeSpacePath = Application.getClientConfig(FacesContext.getCurrentInstance()).getDefaultHomeSpacePath();
|
||||
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> nodes = this.searchService.selectNodes(rootNodeRef, defaultHomeSpacePath, null, this.namespaceService, false);
|
||||
|
||||
if (nodes.size() == 0)
|
||||
{
|
||||
return getCompanyHomeSpace();
|
||||
}
|
||||
|
||||
this.defaultHomeSpaceRef = nodes.get(0);
|
||||
}
|
||||
|
||||
return this.defaultHomeSpaceRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the specified home space if it does not exist, and return the ID
|
||||
*
|
||||
* @param locationId Parent location
|
||||
* @param spaceName Home space to create, can be null to simply return the parent
|
||||
* @param error True to throw an error if the space already exists, else ignore and return
|
||||
* @return ID of the home space
|
||||
*/
|
||||
protected NodeRef createHomeSpace(String locationId, String spaceName, boolean error)
|
||||
{
|
||||
NodeRef homeSpaceNodeRef = null;
|
||||
if (spaceName != null && spaceName.length() != 0)
|
||||
{
|
||||
NodeRef parentRef = new NodeRef(Repository.getStoreRef(), locationId);
|
||||
|
||||
// check for existance of home space with same name - return immediately
|
||||
// if it exists or throw an exception an give user chance to enter another name
|
||||
// TODO: this might be better replaced with an XPath query!
|
||||
List<ChildAssociationRef> children = this.nodeService.getChildAssocs(parentRef);
|
||||
for (ChildAssociationRef ref : children)
|
||||
{
|
||||
String childNodeName = (String) this.nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME);
|
||||
if (spaceName.equals(childNodeName))
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("A Home Space with the same name already exists.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ref.getChildRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// space does not exist already, create a new Space under it with
|
||||
// the specified name
|
||||
String qname = QName.createValidLocalName(spaceName);
|
||||
ChildAssociationRef assocRef = this.nodeService.createNode(parentRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, qname),
|
||||
ContentModel.TYPE_FOLDER);
|
||||
|
||||
NodeRef nodeRef = assocRef.getChildRef();
|
||||
|
||||
// set the name property on the node
|
||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, spaceName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created Home Space for with name: " + spaceName);
|
||||
|
||||
// apply the uifacets aspect - icon, title and description props
|
||||
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(3);
|
||||
uiFacetsProps.put(ApplicationModel.PROP_ICON, CreateSpaceWizard.DEFAULT_SPACE_ICON_NAME);
|
||||
uiFacetsProps.put(ContentModel.PROP_TITLE, spaceName);
|
||||
this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
|
||||
|
||||
setupHomeSpacePermissions(nodeRef);
|
||||
|
||||
// return the ID of the created space
|
||||
homeSpaceNodeRef = nodeRef;
|
||||
}
|
||||
|
||||
return homeSpaceNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the default permissions for this and other users on the Home Space
|
||||
*
|
||||
* @param homeSpaceRef Home Space reference
|
||||
*/
|
||||
private void setupHomeSpacePermissions(NodeRef homeSpaceRef)
|
||||
{
|
||||
// Admin Authority has full permissions by default (automatic - set in the permission config)
|
||||
// give full permissions to the new user
|
||||
this.permissionService.setPermission(homeSpaceRef, this.userName, permissionService.getAllPermission(), true);
|
||||
|
||||
// by default other users will only have GUEST access to the space contents
|
||||
// or whatever is configured as the default in the web-client-xml config
|
||||
String permission = getDefaultPermission();
|
||||
if (permission != null && permission.length() != 0)
|
||||
{
|
||||
this.permissionService.setPermission(homeSpaceRef, permissionService.getAllAuthorities(), permission, true);
|
||||
}
|
||||
|
||||
// the new user is the OWNER of their own space and always has full permissions
|
||||
this.ownableService.setOwner(homeSpaceRef, this.userName);
|
||||
this.permissionService.setPermission(homeSpaceRef, permissionService.getOwnerAuthority(), permissionService.getAllPermission(), true);
|
||||
|
||||
// now detach (if we did this first we could not set any permissions!)
|
||||
this.permissionService.setInheritParentPermissions(homeSpaceRef, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return default permission string to set for other users for a new Home Space
|
||||
*/
|
||||
private String getDefaultPermission()
|
||||
{
|
||||
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
|
||||
return config.getHomeSpacePermission();
|
||||
}
|
||||
|
||||
private void invalidateUserList()
|
||||
{
|
||||
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// TODO: implement create new Person object from specified details
|
||||
try
|
||||
{
|
||||
if (this.password.equals(this.confirm))
|
||||
{
|
||||
// create properties for Person type from submitted Form data
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(7, 1.0f);
|
||||
props.put(ContentModel.PROP_USERNAME, this.userName);
|
||||
props.put(ContentModel.PROP_FIRSTNAME, this.firstName);
|
||||
props.put(ContentModel.PROP_LASTNAME, this.lastName);
|
||||
NodeRef homeSpaceNodeRef;
|
||||
if (this.homeSpaceLocation != null && this.homeSpaceName.length() != 0)
|
||||
{
|
||||
// create new
|
||||
homeSpaceNodeRef = createHomeSpace(this.homeSpaceLocation.getId(), this.homeSpaceName, true);
|
||||
}
|
||||
else if (this.homeSpaceLocation != null)
|
||||
{
|
||||
// set to existing
|
||||
homeSpaceNodeRef = homeSpaceLocation;
|
||||
setupHomeSpacePermissions(homeSpaceNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default to Company Home
|
||||
homeSpaceNodeRef = getCompanyHomeSpace();
|
||||
}
|
||||
props.put(ContentModel.PROP_HOMEFOLDER, homeSpaceNodeRef);
|
||||
props.put(ContentModel.PROP_EMAIL, this.email);
|
||||
props.put(ContentModel.PROP_ORGID, this.companyId);
|
||||
|
||||
// create the node to represent the Person
|
||||
NodeRef newPerson = this.personService.createPerson(props);
|
||||
|
||||
// ensure the user can access their own Person object
|
||||
this.permissionService.setPermission(newPerson, this.userName, permissionService.getAllPermission(), true);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created Person node for username: " + this.userName);
|
||||
|
||||
// create the ACEGI Authentication instance for the new user
|
||||
this.authenticationService.createAuthentication(this.userName, this.password.toCharArray());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created User Authentication instance for username: " + this.userName);
|
||||
}
|
||||
else
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(Application.getMessage(context, UsersDialog.ERROR_PASSWORD_MATCH));
|
||||
}
|
||||
invalidateUserList();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
|
||||
outcome = null;
|
||||
}
|
||||
|
||||
if (outcome == null) {
|
||||
this.isFinished = false;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
if (this.firstName != null && this.lastName != null && this.email != null && this.firstName.length() > 0 && this.lastName.length() > 0 && this.email.length() > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
258
source/java/org/alfresco/web/bean/users/DeleteUserDialog.java
Normal file
258
source/java/org/alfresco/web/bean/users/DeleteUserDialog.java
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.LoginBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.MapNode;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class DeleteUserDialog extends BaseDialogBean {
|
||||
|
||||
private static Logger logger = Logger.getLogger(DeleteUserDialog.class);
|
||||
|
||||
private static final String ERROR_DELETE = "error_delete_user";
|
||||
|
||||
private static final String ERROR_USER_DELETE = "error_delete_user_object";
|
||||
|
||||
private static final String BUTTON_YES = "yes";
|
||||
|
||||
private static final String MSG_TITLE_DELETE_USER = "title_delete_user";
|
||||
|
||||
private static final String BUTTON_NO = "no";
|
||||
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
private List<Node> users = Collections.<Node> emptyList();
|
||||
|
||||
private PersonService personService;
|
||||
|
||||
private Node person = null;
|
||||
|
||||
private String searchCriteria = null;
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception {
|
||||
try {
|
||||
String userName = (String) getPerson().getProperties().get("userName");
|
||||
|
||||
// we only delete the user auth if Alfresco is managing the authentication
|
||||
Map session = context.getExternalContext().getSessionMap();
|
||||
if (session.get(LoginBean.LOGIN_EXTERNAL_AUTH) == null) {
|
||||
// delete the User authentication
|
||||
try {
|
||||
authenticationService.deleteAuthentication(userName);
|
||||
} catch (AuthenticationException authErr) {
|
||||
Utils.addErrorMessage(Application.getMessage(context, ERROR_USER_DELETE));
|
||||
}
|
||||
}
|
||||
|
||||
// delete the associated Person
|
||||
this.personService.deletePerson(userName);
|
||||
|
||||
// re-do the search to refresh the list
|
||||
search();
|
||||
} catch (Throwable e) {
|
||||
// rollback the transaction
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, ERROR_DELETE), e.getMessage()),
|
||||
e);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public String search() {
|
||||
|
||||
if (this.searchCriteria == null || this.searchCriteria.length() == 0) {
|
||||
this.users = Collections.<Node> emptyList();
|
||||
} else {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
UserTransaction tx = null;
|
||||
|
||||
try {
|
||||
tx = Repository.getUserTransaction(context, true);
|
||||
tx.begin();
|
||||
|
||||
// define the query to find people by their first or last name
|
||||
String search = ISO9075.encode(this.searchCriteria);
|
||||
String query = "( TYPE:\"{http://www.alfresco.org/model/content/1.0}person\") AND "
|
||||
+ "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:" + search
|
||||
+ "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:" + search
|
||||
+ "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + search + "*)))";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Query: " + query);
|
||||
|
||||
// define the search parameters
|
||||
SearchParameters params = new SearchParameters();
|
||||
params.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
params.addStore(Repository.getStoreRef());
|
||||
params.setQuery(query);
|
||||
|
||||
List<NodeRef> people = this.searchService.query(params).getNodeRefs();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found " + people.size() + " users");
|
||||
|
||||
this.users = new ArrayList<Node>(people.size());
|
||||
|
||||
for (NodeRef nodeRef : people) {
|
||||
// create our Node representation
|
||||
MapNode node = new MapNode(nodeRef);
|
||||
|
||||
// set data binding properties
|
||||
// this will also force initialisation of the props now during the UserTransaction
|
||||
// it is much better for performance to do this now rather than during page bind
|
||||
Map<String, Object> props = node.getProperties();
|
||||
props.put("fullName", ((String) props.get("firstName")) + ' ' + ((String) props.get("lastName")));
|
||||
NodeRef homeFolderNodeRef = (NodeRef) props.get("homeFolder");
|
||||
if (homeFolderNodeRef != null) {
|
||||
props.put("homeSpace", homeFolderNodeRef);
|
||||
}
|
||||
|
||||
this.users.add(node);
|
||||
}
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
} catch (InvalidNodeRefException refErr) {
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_NODEREF),
|
||||
new Object[] { "root" }));
|
||||
this.users = Collections.<Node> emptyList();
|
||||
try {
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
} catch (Exception tex) {
|
||||
}
|
||||
} catch (Exception err) {
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_GENERIC),
|
||||
err.getMessage()), err);
|
||||
this.users = Collections.<Node> emptyList();
|
||||
try {
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
} catch (Exception tex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return null to stay on the same page
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setupUserAction(ActionEvent event) {
|
||||
UIActionLink link = (UIActionLink) event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String id = params.get("id");
|
||||
if (id != null && id.length() != 0) {
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Setup for action, setting current Person to: " + id);
|
||||
|
||||
try {
|
||||
// create the node ref, then our node representation
|
||||
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
|
||||
Node node = new Node(ref);
|
||||
|
||||
// remember the Person node
|
||||
setPerson(node);
|
||||
} catch (InvalidNodeRefException refErr) {
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
Repository.ERROR_NODEREF), new Object[] { id }));
|
||||
}
|
||||
} else {
|
||||
setPerson(null);
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationService getAuthenticationService() {
|
||||
return authenticationService;
|
||||
}
|
||||
|
||||
public void setAuthenticationService(AuthenticationService authenticationService) {
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
public PersonService getPersonService() {
|
||||
return personService;
|
||||
}
|
||||
|
||||
public void setPersonService(PersonService personService) {
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
public Node getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public void setPerson(Node person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), BUTTON_NO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), BUTTON_YES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_TITLE_DELETE_USER) + " '"
|
||||
+ getPerson().getProperties().get("userName") + "'";
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class EditContentUserRolesDialog extends BaseDialogBean
|
||||
{
|
||||
ContentUsersBean contentUsersBean;
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public ContentUsersBean getContentUsersBean()
|
||||
{
|
||||
return contentUsersBean;
|
||||
}
|
||||
|
||||
public void setContentUsersBean(ContentUsersBean contentUsersBean)
|
||||
{
|
||||
this.contentUsersBean = contentUsersBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
contentUsersBean.finishOK();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public void addRole(ActionEvent event)
|
||||
{
|
||||
contentUsersBean.addRole(event);
|
||||
}
|
||||
|
||||
public void setupUserAction(ActionEvent event)
|
||||
{
|
||||
contentUsersBean.setupUserAction(event);
|
||||
}
|
||||
|
||||
public void removeRole(ActionEvent event)
|
||||
{
|
||||
contentUsersBean.removeRole(event);
|
||||
}
|
||||
|
||||
public DataModel getPersonRolesDataModel()
|
||||
{
|
||||
return contentUsersBean.getPersonRolesDataModel();
|
||||
}
|
||||
|
||||
}
|
41
source/java/org/alfresco/web/bean/users/EditFileDialog.java
Normal file
41
source/java/org/alfresco/web/bean/users/EditFileDialog.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class EditFileDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* @author YanO
|
||||
*
|
||||
*/
|
||||
public class EditUserDetailsDialog extends BaseDialogBean
|
||||
{
|
||||
private Node person;
|
||||
protected UsersBeanProperties properties;
|
||||
|
||||
/**
|
||||
* @param properties the properties to set
|
||||
*/
|
||||
public void setProperties(UsersBeanProperties properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
person = properties.getPerson();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(getPerson().getNodeRef());
|
||||
props.put(ContentModel.PROP_FIRSTNAME, getFirstName());
|
||||
props.put(ContentModel.PROP_LASTNAME, getLastName());
|
||||
props.put(ContentModel.PROP_EMAIL, getEmail());
|
||||
|
||||
// persist changes
|
||||
this.nodeService.setProperties(getPerson().getNodeRef(), props);
|
||||
|
||||
// if the above call was successful, then reset Person Node in the session
|
||||
Application.getCurrentUser(context).reset();
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, Repository.ERROR_GENERIC), err.getMessage()), err);
|
||||
outcome = null;
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
private Node getPerson()
|
||||
{
|
||||
return person;
|
||||
}
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return person.getProperties().get(ContentModel.PROP_EMAIL).toString();
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
person.getProperties().put(ContentModel.PROP_EMAIL.toString(), email);
|
||||
}
|
||||
|
||||
public String getFirstName()
|
||||
{
|
||||
return person.getProperties().get(ContentModel.PROP_FIRSTNAME).toString();
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName)
|
||||
{
|
||||
person.getProperties().put(ContentModel.PROP_FIRSTNAME.toString(), firstName);
|
||||
}
|
||||
|
||||
public String getLastName()
|
||||
{
|
||||
return person.getProperties().get(ContentModel.PROP_LASTNAME).toString();
|
||||
}
|
||||
|
||||
public void setLastName(String lastName)
|
||||
{
|
||||
person.getProperties().put(ContentModel.PROP_LASTNAME.toString(), lastName);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.model.DataModel;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class EditUserRolesDialog extends BaseDialogBean {
|
||||
|
||||
private static final String MSG_MODIFY_USER_ROLE = "modify_user_roles";
|
||||
|
||||
SpaceUsersBean spaceUsersBean;
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SpaceUsersBean getSpaceUsersBean() {
|
||||
return spaceUsersBean;
|
||||
}
|
||||
|
||||
public void setSpaceUsersBean(SpaceUsersBean spaceUsersBean) {
|
||||
this.spaceUsersBean = spaceUsersBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception {
|
||||
spaceUsersBean.finishOK();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public void addRole(ActionEvent event) {
|
||||
spaceUsersBean.addRole(event);
|
||||
}
|
||||
|
||||
public void setupUserAction(ActionEvent event) {
|
||||
spaceUsersBean.setupUserAction(event);
|
||||
}
|
||||
|
||||
public void removeRole(ActionEvent event) {
|
||||
spaceUsersBean.removeRole(event);
|
||||
}
|
||||
|
||||
public DataModel getPersonRolesDataModel() {
|
||||
return spaceUsersBean.getPersonRolesDataModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_MODIFY_USER_ROLE) + " '" + spaceUsersBean.getPersonName() + "'";
|
||||
}
|
||||
}
|
192
source/java/org/alfresco/web/bean/users/EditUserWizard.java
Normal file
192
source/java/org/alfresco/web/bean/users/EditUserWizard.java
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
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.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author YanO
|
||||
*
|
||||
*/
|
||||
public class EditUserWizard extends CreateUserWizard
|
||||
{
|
||||
private static Logger logger = Logger.getLogger(EditUserWizard.class);
|
||||
|
||||
protected UsersBeanProperties properties;
|
||||
|
||||
/**
|
||||
* @param properties the properties to set
|
||||
*/
|
||||
public void setProperties(UsersBeanProperties properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> arg0)
|
||||
{
|
||||
super.init(arg0);
|
||||
|
||||
// set values for edit mode
|
||||
Map<String, Object> props = properties.getPerson().getProperties();
|
||||
|
||||
this.firstName = (String) props.get("firstName");
|
||||
this.lastName = (String) props.get("lastName");
|
||||
this.userName = (String) props.get("userName");
|
||||
this.email = (String) props.get("email");
|
||||
this.companyId = (String) props.get("organizationId");
|
||||
|
||||
// calculate home space name and parent space Id from homeFolderId
|
||||
this.homeSpaceLocation = null; // default to Company root space
|
||||
NodeRef homeFolderRef = (NodeRef) props.get("homeFolder");
|
||||
if (this.nodeService.exists(homeFolderRef) == true)
|
||||
{
|
||||
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(homeFolderRef);
|
||||
NodeRef parentRef = childAssocRef.getParentRef();
|
||||
if (this.nodeService.getRootNode(Repository.getStoreRef()).equals(parentRef) == false)
|
||||
{
|
||||
this.homeSpaceLocation = parentRef;
|
||||
this.homeSpaceName = Repository.getNameForNode(nodeService, homeFolderRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.homeSpaceLocation = homeFolderRef;
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Edit user home space location: " + homeSpaceLocation + " home space name: " + homeSpaceName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
// update the existing node in the repository
|
||||
NodeRef nodeRef = properties.getPerson().getNodeRef();
|
||||
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(nodeRef);
|
||||
props.put(ContentModel.PROP_USERNAME, this.userName);
|
||||
props.put(ContentModel.PROP_FIRSTNAME, this.firstName);
|
||||
props.put(ContentModel.PROP_LASTNAME, this.lastName);
|
||||
|
||||
// calculate whether we need to move the old home space or create new
|
||||
NodeRef newHomeFolderRef;
|
||||
NodeRef oldHomeFolderRef = (NodeRef) this.nodeService.getProperty(nodeRef, ContentModel.PROP_HOMEFOLDER);
|
||||
boolean moveHomeSpace = false;
|
||||
boolean renameHomeSpace = false;
|
||||
if (oldHomeFolderRef != null && this.nodeService.exists(oldHomeFolderRef) == true)
|
||||
{
|
||||
// the original home folder ref exists so may need moving if it has been changed
|
||||
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(oldHomeFolderRef);
|
||||
NodeRef currentHomeSpaceLocation = childAssocRef.getParentRef();
|
||||
if (this.homeSpaceName.length() != 0)
|
||||
{
|
||||
if (currentHomeSpaceLocation.equals(this.homeSpaceLocation) == false && oldHomeFolderRef.equals(this.homeSpaceLocation) == false
|
||||
&& currentHomeSpaceLocation.equals(getCompanyHomeSpace()) == false && currentHomeSpaceLocation.equals(getDefaultHomeSpace()) == false)
|
||||
{
|
||||
moveHomeSpace = true;
|
||||
}
|
||||
|
||||
String oldHomeSpaceName = Repository.getNameForNode(nodeService, oldHomeFolderRef);
|
||||
if (oldHomeSpaceName.equals(this.homeSpaceName) == false && oldHomeFolderRef.equals(this.homeSpaceLocation) == false)
|
||||
{
|
||||
renameHomeSpace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Moving space: " + moveHomeSpace + " and renaming space: " + renameHomeSpace);
|
||||
|
||||
if (moveHomeSpace == false && renameHomeSpace == false)
|
||||
{
|
||||
if (this.homeSpaceLocation != null && this.homeSpaceName.length() != 0)
|
||||
{
|
||||
newHomeFolderRef = createHomeSpace(this.homeSpaceLocation.getId(), this.homeSpaceName, false);
|
||||
}
|
||||
else if (this.homeSpaceLocation != null)
|
||||
{
|
||||
// location selected but no home space name entered,
|
||||
// so the home ref should be set to the newly selected space
|
||||
newHomeFolderRef = this.homeSpaceLocation;
|
||||
|
||||
// set the permissions for this space so the user can access it
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// nothing selected - use Company Home by default
|
||||
newHomeFolderRef = getCompanyHomeSpace();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// either move, rename or both required
|
||||
if (moveHomeSpace == true)
|
||||
{
|
||||
this.nodeService
|
||||
.moveNode(oldHomeFolderRef, this.homeSpaceLocation, ContentModel.ASSOC_CONTAINS, this.nodeService.getPrimaryParent(oldHomeFolderRef).getQName());
|
||||
}
|
||||
newHomeFolderRef = oldHomeFolderRef; // ref ID doesn't change
|
||||
|
||||
if (renameHomeSpace == true)
|
||||
{
|
||||
// change HomeSpace node name
|
||||
this.nodeService.setProperty(newHomeFolderRef, ContentModel.PROP_NAME, this.homeSpaceName);
|
||||
}
|
||||
}
|
||||
|
||||
props.put(ContentModel.PROP_HOMEFOLDER, newHomeFolderRef);
|
||||
props.put(ContentModel.PROP_EMAIL, this.email);
|
||||
props.put(ContentModel.PROP_ORGID, this.companyId);
|
||||
this.nodeService.setProperties(nodeRef, props);
|
||||
|
||||
// TODO: RESET HomeSpace Ref found in top-level navigation bar!
|
||||
// NOTE: not need cos only admin can do this?
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
|
||||
outcome = null;
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class RemoveContentUserDialog extends BaseDialogBean
|
||||
{
|
||||
private ContentUsersBean contentUsersBean;
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
contentUsersBean.removeOK();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public void setupUserAction(ActionEvent event)
|
||||
{
|
||||
this.contentUsersBean.setupUserAction(event);
|
||||
}
|
||||
|
||||
public String getPersonName()
|
||||
{
|
||||
return this.contentUsersBean.getPersonName();
|
||||
}
|
||||
|
||||
public void setPersonName(String personName)
|
||||
{
|
||||
this.contentUsersBean.setPersonName(personName);
|
||||
}
|
||||
|
||||
public ContentUsersBean getContentUsersBean()
|
||||
{
|
||||
return contentUsersBean;
|
||||
}
|
||||
|
||||
public void setContentUsersBean(ContentUsersBean contentUsersBean)
|
||||
{
|
||||
this.contentUsersBean = contentUsersBean;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class RemoveInvitedUserDialog extends BaseDialogBean {
|
||||
|
||||
private static final String BUTTON_NO = "no";
|
||||
|
||||
private static final String BUTTON_YES = "yes";
|
||||
|
||||
private static final String MSG_REMOVE_USER = "remove_user";
|
||||
|
||||
private SpaceUsersBean spaceUsersBean;
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception {
|
||||
spaceUsersBean.removeOK();
|
||||
return outcome;
|
||||
}
|
||||
|
||||
public void setupUserAction(ActionEvent event) {
|
||||
spaceUsersBean.setupUserAction(event);
|
||||
}
|
||||
|
||||
public String getPersonName() {
|
||||
return spaceUsersBean.getPersonName();
|
||||
}
|
||||
|
||||
public void setPersonName(String personName) {
|
||||
this.spaceUsersBean.setPersonName(personName);
|
||||
}
|
||||
|
||||
public SpaceUsersBean getSpaceUsersBean() {
|
||||
return spaceUsersBean;
|
||||
}
|
||||
|
||||
public void setSpaceUsersBean(SpaceUsersBean spaceUsersBean) {
|
||||
this.spaceUsersBean = spaceUsersBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), BUTTON_NO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), BUTTON_YES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle() {
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_REMOVE_USER) + " '"
|
||||
+ spaceUsersBean.getPersonName() + "'";
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
|
||||
public class UserConsoleDialog extends BaseDialogBean
|
||||
{
|
||||
|
||||
private static final String BUTTON_CLOSE = "close";
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), BUTTON_CLOSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
|
||||
super.cancel();
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
}
|
228
source/java/org/alfresco/web/bean/users/UsersBeanProperties.java
Normal file
228
source/java/org/alfresco/web/bean/users/UsersBeanProperties.java
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.component.data.UIRichList;
|
||||
|
||||
public class UsersBeanProperties
|
||||
{
|
||||
/** NodeService bean reference */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** SearchService bean reference */
|
||||
private SearchService searchService;
|
||||
|
||||
/** AuthenticationService bean reference */
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
/** PersonService bean reference */
|
||||
private PersonService personService;
|
||||
|
||||
/** Component reference for Users RichList control */
|
||||
private UIRichList usersRichList;
|
||||
|
||||
/** action context */
|
||||
private Node person = null;
|
||||
|
||||
|
||||
|
||||
private String password = null;
|
||||
private String oldPassword = null;
|
||||
private String confirm = null;
|
||||
private String searchCriteria = null;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @return the nodeService
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the searchService
|
||||
*/
|
||||
public SearchService getSearchService()
|
||||
{
|
||||
return searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the authenticationService
|
||||
*/
|
||||
public AuthenticationService getAuthenticationService()
|
||||
{
|
||||
return authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the personService
|
||||
*/
|
||||
public PersonService getPersonService()
|
||||
{
|
||||
return personService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService The NodeService to set.
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchService the search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authenticationService The AuthenticationService to set.
|
||||
*/
|
||||
public void setAuthenticationService(AuthenticationService authenticationService)
|
||||
{
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param personService The PersonService to set.
|
||||
*/
|
||||
public void setPersonService(PersonService personService)
|
||||
{
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the usersRichList.
|
||||
*/
|
||||
public UIRichList getUsersRichList()
|
||||
{
|
||||
return this.usersRichList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param usersRichList The usersRichList to set.
|
||||
*/
|
||||
public void setUsersRichList(UIRichList usersRichList)
|
||||
{
|
||||
this.usersRichList = usersRichList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the search criteria
|
||||
*/
|
||||
public String getSearchCriteria()
|
||||
{
|
||||
return searchCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchCriteria The search criteria to select
|
||||
*/
|
||||
public void setSearchCriteria(String searchCriteria)
|
||||
{
|
||||
this.searchCriteria = searchCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the confirm password.
|
||||
*/
|
||||
public String getConfirm()
|
||||
{
|
||||
return this.confirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param confirm The confirm password to set.
|
||||
*/
|
||||
public void setConfirm(String confirm)
|
||||
{
|
||||
this.confirm = confirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the password.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password The password to set.
|
||||
*/
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the old password.
|
||||
*/
|
||||
public String getOldPassword()
|
||||
{
|
||||
return this.oldPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oldPassword The old password to set.
|
||||
*/
|
||||
public void setOldPassword(String oldPassword)
|
||||
{
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the person context.
|
||||
*/
|
||||
public Node getPerson()
|
||||
{
|
||||
return this.person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param person The person context to set.
|
||||
*/
|
||||
public void setPerson(Node person)
|
||||
{
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -41,31 +41,28 @@ import org.alfresco.repo.search.impl.lucene.QueryParser;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
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;
|
||||
import org.alfresco.web.bean.LoginBean;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.MapNode;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
import org.alfresco.web.ui.common.component.data.UIRichList;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class UsersBean implements IContextListener
|
||||
public class UsersDialog extends BaseDialogBean implements IContextListener
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(UsersBean.class);
|
||||
private static Log logger = LogFactory.getLog(UsersDialog.class);
|
||||
|
||||
public static final String ERROR_PASSWORD_MATCH = "error_password_match";
|
||||
private static final String ERROR_DELETE = "error_delete_user";
|
||||
@@ -74,31 +71,9 @@ public class UsersBean implements IContextListener
|
||||
private static final String DEFAULT_OUTCOME = "manageUsers";
|
||||
private static final String DIALOG_CLOSE = "dialog:close";
|
||||
|
||||
/** NodeService bean reference */
|
||||
protected NodeService nodeService;
|
||||
|
||||
/** SearchService bean reference */
|
||||
protected SearchService searchService;
|
||||
|
||||
/** AuthenticationService bean reference */
|
||||
protected AuthenticationService authenticationService;
|
||||
|
||||
/** PersonService bean reference */
|
||||
protected PersonService personService;
|
||||
|
||||
/** Component reference for Users RichList control */
|
||||
protected UIRichList usersRichList;
|
||||
|
||||
/** action context */
|
||||
private Node person = null;
|
||||
|
||||
protected UsersBeanProperties properties;
|
||||
private List<Node> users = Collections.<Node>emptyList();
|
||||
|
||||
private String password = null;
|
||||
private String oldPassword = null;
|
||||
private String confirm = null;
|
||||
private String searchCriteria = null;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Construction
|
||||
@@ -106,7 +81,7 @@ public class UsersBean implements IContextListener
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
public UsersBean()
|
||||
public UsersDialog()
|
||||
{
|
||||
UIContextService.getInstance(FacesContext.getCurrentInstance()).registerBean(this);
|
||||
}
|
||||
@@ -116,51 +91,11 @@ public class UsersBean implements IContextListener
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @param nodeService The NodeService to set.
|
||||
* @param properties the properties to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
public void setProperties(UsersBeanProperties properties)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchService the search service
|
||||
*/
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authenticationService The AuthenticationService to set.
|
||||
*/
|
||||
public void setAuthenticationService(AuthenticationService authenticationService)
|
||||
{
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param personService The PersonService to set.
|
||||
*/
|
||||
public void setPersonService(PersonService personService)
|
||||
{
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the usersRichList.
|
||||
*/
|
||||
public UIRichList getUsersRichList()
|
||||
{
|
||||
return this.usersRichList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param usersRichList The usersRichList to set.
|
||||
*/
|
||||
public void setUsersRichList(UIRichList usersRichList)
|
||||
{
|
||||
this.usersRichList = usersRichList;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,91 +111,11 @@ public class UsersBean implements IContextListener
|
||||
return this.users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the search criteria
|
||||
*/
|
||||
public String getSearchCriteria()
|
||||
{
|
||||
return searchCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param searchCriteria The search criteria to select
|
||||
*/
|
||||
public void setSearchCriteria(String searchCriteria)
|
||||
{
|
||||
this.searchCriteria = searchCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the confirm password.
|
||||
*/
|
||||
public String getConfirm()
|
||||
{
|
||||
return this.confirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param confirm The confirm password to set.
|
||||
*/
|
||||
public void setConfirm(String confirm)
|
||||
{
|
||||
this.confirm = confirm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the password.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password The password to set.
|
||||
*/
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the old password.
|
||||
*/
|
||||
public String getOldPassword()
|
||||
{
|
||||
return this.oldPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oldPassword The old password to set.
|
||||
*/
|
||||
public void setOldPassword(String oldPassword)
|
||||
{
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the person context.
|
||||
*/
|
||||
public Node getPerson()
|
||||
{
|
||||
return this.person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param person The person context to set.
|
||||
*/
|
||||
public void setPerson(Node person)
|
||||
{
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action event called by all actions that need to setup a Person context on
|
||||
* the Users bean before an action page is called. The context will be a
|
||||
* Person Node in setPerson() which can be retrieved on the action page from
|
||||
* UsersBean.getPerson().
|
||||
* UsersDialog.getPerson().
|
||||
*/
|
||||
public void setupUserAction(ActionEvent event)
|
||||
{
|
||||
@@ -279,7 +134,7 @@ public class UsersBean implements IContextListener
|
||||
Node node = new Node(ref);
|
||||
|
||||
// remember the Person node
|
||||
setPerson(node);
|
||||
properties.setPerson(node);
|
||||
|
||||
// clear the UI state in preparation for finishing the action
|
||||
// and returning to the main page
|
||||
@@ -293,7 +148,7 @@ public class UsersBean implements IContextListener
|
||||
}
|
||||
else
|
||||
{
|
||||
setPerson(null);
|
||||
properties.setPerson(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +160,7 @@ public class UsersBean implements IContextListener
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
try
|
||||
{
|
||||
String userName = (String)getPerson().getProperties().get("userName");
|
||||
String userName = (String) properties.getPerson().getProperties().get("userName");
|
||||
|
||||
// we only delete the user auth if Alfresco is managing the authentication
|
||||
Map session = context.getExternalContext().getSessionMap();
|
||||
@@ -314,7 +169,7 @@ public class UsersBean implements IContextListener
|
||||
// delete the User authentication
|
||||
try
|
||||
{
|
||||
authenticationService.deleteAuthentication(userName);
|
||||
properties.getAuthenticationService().deleteAuthentication(userName);
|
||||
}
|
||||
catch (AuthenticationException authErr)
|
||||
{
|
||||
@@ -323,7 +178,7 @@ public class UsersBean implements IContextListener
|
||||
}
|
||||
|
||||
// delete the associated Person
|
||||
this.personService.deletePerson(userName);
|
||||
properties.getPersonService().deletePerson(userName);
|
||||
|
||||
// re-do the search to refresh the list
|
||||
search();
|
||||
@@ -339,70 +194,7 @@ public class UsersBean implements IContextListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called for OK button press on Change Password screen
|
||||
*/
|
||||
public String changePasswordOK()
|
||||
{
|
||||
String outcome = DIALOG_CLOSE;
|
||||
|
||||
if (this.password != null && this.confirm != null && this.password.equals(this.confirm))
|
||||
{
|
||||
try
|
||||
{
|
||||
String userName = (String)this.person.getProperties().get(ContentModel.PROP_USERNAME);
|
||||
this.authenticationService.setAuthentication(userName, this.password.toCharArray());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext
|
||||
.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
ERROR_PASSWORD_MATCH));
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called for OK button press on Change My Password screen
|
||||
* For this screen the user is required to enter their old password - effectively login.
|
||||
*/
|
||||
public String changeMyPasswordOK()
|
||||
{
|
||||
String outcome = DIALOG_CLOSE;
|
||||
|
||||
if (this.password != null && this.confirm != null && this.password.equals(this.confirm))
|
||||
{
|
||||
try
|
||||
{
|
||||
String userName = (String)this.person.getProperties().get(ContentModel.PROP_USERNAME);
|
||||
this.authenticationService.updateAuthentication(userName, this.oldPassword.toCharArray(), this.password.toCharArray());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext
|
||||
.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outcome = null;
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
ERROR_PASSWORD_MATCH));
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called for the OK button press
|
||||
* Action handler called for the OK button press
|
||||
*/
|
||||
public String changeUserDetails()
|
||||
{
|
||||
@@ -411,16 +203,16 @@ public class UsersBean implements IContextListener
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(getPerson().getNodeRef());
|
||||
Map<QName, Serializable> props = properties.getNodeService().getProperties(properties.getPerson().getNodeRef());
|
||||
props.put(ContentModel.PROP_FIRSTNAME,
|
||||
(String)getPerson().getProperties().get(ContentModel.PROP_FIRSTNAME));
|
||||
(String) properties.getPerson().getProperties().get(ContentModel.PROP_FIRSTNAME));
|
||||
props.put(ContentModel.PROP_LASTNAME,
|
||||
(String)getPerson().getProperties().get(ContentModel.PROP_LASTNAME));
|
||||
(String) properties.getPerson().getProperties().get(ContentModel.PROP_LASTNAME));
|
||||
props.put(ContentModel.PROP_EMAIL,
|
||||
(String)getPerson().getProperties().get(ContentModel.PROP_EMAIL));
|
||||
(String) properties.getPerson().getProperties().get(ContentModel.PROP_EMAIL));
|
||||
|
||||
// persist changes
|
||||
this.nodeService.setProperties(getPerson().getNodeRef(), props);
|
||||
properties.getNodeService().setProperties(properties.getPerson().getNodeRef(), props);
|
||||
|
||||
// if the above call was successful, then reset Person Node in the session
|
||||
Application.getCurrentUser(context).reset();
|
||||
@@ -441,9 +233,9 @@ public class UsersBean implements IContextListener
|
||||
*/
|
||||
public String search()
|
||||
{
|
||||
this.usersRichList.setValue(null);
|
||||
properties.getUsersRichList().setValue(null);
|
||||
|
||||
if (this.searchCriteria == null || this.searchCriteria.trim().length() == 0)
|
||||
if (properties.getSearchCriteria() == null || properties.getSearchCriteria().trim().length() == 0)
|
||||
{
|
||||
this.users = Collections.<Node>emptyList();
|
||||
}
|
||||
@@ -458,7 +250,7 @@ public class UsersBean implements IContextListener
|
||||
tx.begin();
|
||||
|
||||
// define the query to find people by their first or last name
|
||||
String search = this.searchCriteria.trim();
|
||||
String search = properties.getSearchCriteria().trim();
|
||||
StringBuilder query = new StringBuilder(256);
|
||||
query.append("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\" AND (");
|
||||
for (StringTokenizer t = new StringTokenizer(search, " "); t.hasMoreTokens(); /**/)
|
||||
@@ -483,7 +275,7 @@ public class UsersBean implements IContextListener
|
||||
params.addStore(Repository.getStoreRef());
|
||||
params.setQuery(query.toString());
|
||||
|
||||
List<NodeRef> people = this.searchService.query(params).getNodeRefs();
|
||||
List<NodeRef> people = properties.getSearchService().query(params).getNodeRefs();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found " + people.size() + " users");
|
||||
@@ -539,15 +331,20 @@ public class UsersBean implements IContextListener
|
||||
*/
|
||||
public String showAll()
|
||||
{
|
||||
this.usersRichList.setValue(null);
|
||||
properties.getUsersRichList().setValue(null);
|
||||
|
||||
this.users = Repository.getUsers(FacesContext.getCurrentInstance(),
|
||||
this.nodeService, this.searchService);
|
||||
properties.getNodeService(), properties.getSearchService());
|
||||
|
||||
// return null to stay on the same page
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// IContextListener implementation
|
||||
@@ -557,9 +354,9 @@ public class UsersBean implements IContextListener
|
||||
*/
|
||||
public void contextUpdated()
|
||||
{
|
||||
if (this.usersRichList != null)
|
||||
if (properties.getUsersRichList() != null)
|
||||
{
|
||||
this.usersRichList.setValue(null);
|
||||
properties.getUsersRichList().setValue(null);
|
||||
this.users = null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user