Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent d6f9f50c39
commit dead3c3825
265 changed files with 44099 additions and 44099 deletions

View File

@@ -1,70 +1,70 @@
package org.alfresco.web.bean.users;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ChangeMyPasswordDialog extends UsersDialog
{
private static final long serialVersionUID = 1965846039555088108L;
private static final String MSG_FINISH_BUTTON = "finish_button";
private static final String MSG_ERROR_INCORRECT_OLD_PASSWORD = "error_incorrect_old_password";
@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(Application.getMessage(FacesContext.getCurrentInstance(),
MSG_ERROR_INCORRECT_OLD_PASSWORD));
ReportedException.throwIfNecessary(e);
}
}
else
{
outcome = null;
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
}
return outcome;
}
}
package org.alfresco.web.bean.users;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ChangeMyPasswordDialog extends UsersDialog
{
private static final long serialVersionUID = 1965846039555088108L;
private static final String MSG_FINISH_BUTTON = "finish_button";
private static final String MSG_ERROR_INCORRECT_OLD_PASSWORD = "error_incorrect_old_password";
@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(Application.getMessage(FacesContext.getCurrentInstance(),
MSG_ERROR_INCORRECT_OLD_PASSWORD));
ReportedException.throwIfNecessary(e);
}
}
else
{
outcome = null;
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
}
return outcome;
}
}

View File

@@ -1,70 +1,70 @@
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ChangePasswordDialog extends UsersDialog
{
private static final long serialVersionUID = -1570967895811499123L;
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);
ReportedException.throwIfNecessary(e);
}
}
else
{
outcome = null;
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
}
return outcome;
}
}
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
public class ChangePasswordDialog extends UsersDialog
{
private static final long serialVersionUID = -1570967895811499123L;
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);
ReportedException.throwIfNecessary(e);
}
}
else
{
outcome = null;
Utils.addErrorMessage(Application.getMessage(newContext, ERROR_PASSWORD_MATCH));
}
return outcome;
}
}

View File

@@ -1,65 +1,65 @@
package org.alfresco.web.bean.users;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Concrete implementation providing access to users of the current content/document.
*
* @author gavinc
*/
public class ContentUsersBean extends UserMembersBean
{
private static final long serialVersionUID = 5206400236997654181L;
private final static String MSG_MANAGE_CONTENT_USERS = "manage_content_users";
private final static String MSG_CONTENT_OWNER = "content_owner";
private final static String MSG_CLOSE= "close";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
/**
* @return The space to work against
*/
public Node getNode()
{
return this.browseBean.getDocument();
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public Object getActionsContext()
{
return getNode();
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MANAGE_CONTENT_USERS) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ browseBean.getDocument().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
String pattern = Application.getMessage(FacesContext.getCurrentInstance(), MSG_CONTENT_OWNER);
return MessageFormat.format(pattern, getOwner());
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
}
package org.alfresco.web.bean.users;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Concrete implementation providing access to users of the current content/document.
*
* @author gavinc
*/
public class ContentUsersBean extends UserMembersBean
{
private static final long serialVersionUID = 5206400236997654181L;
private final static String MSG_MANAGE_CONTENT_USERS = "manage_content_users";
private final static String MSG_CONTENT_OWNER = "content_owner";
private final static String MSG_CLOSE= "close";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
/**
* @return The space to work against
*/
public Node getNode()
{
return this.browseBean.getDocument();
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public Object getActionsContext()
{
return getNode();
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MANAGE_CONTENT_USERS) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ browseBean.getDocument().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
String pattern = Application.getMessage(FacesContext.getCurrentInstance(), MSG_CONTENT_OWNER);
return MessageFormat.format(pattern, getOwner());
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,279 +1,279 @@
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.model.ContentModel;
import org.alfresco.query.PagingRequest;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ISO9075;
import org.alfresco.util.Pair;
import org.alfresco.web.app.Application;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DeleteUserDialog extends BaseDialogBean
{
private static final long serialVersionUID = -4977064287365766306L;
private static Log logger = LogFactory.getLog(DeleteUserDialog.class);
private static final String ERROR_DELETE = "error_delete_user";
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 final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
transient private AuthenticationService authenticationService;
private List<Node> users = Collections.<Node> emptyList();
transient 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");
// delete the associated Person
getPersonService().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);
ReportedException.throwIfNecessary(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);
List<Pair<QName,String>> filter = Utils.generatePersonFilter(search);
if (logger.isDebugEnabled())
{
logger.debug("Query filter: " + filter);
}
List<PersonInfo> persons = getPersonService().getPeople(
filter,
true,
Utils.generatePersonSort(),
new PagingRequest(Utils.getPersonMaxResults(), null)
).getPage();
if (logger.isDebugEnabled())
{
logger.debug("Found " + persons.size() + " users");
}
this.users = new ArrayList<Node>(persons.size());
for (PersonInfo person : persons)
{
// create our Node representation
MapNode node = new MapNode(person.getNodeRef());
// 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);
}
}
/**
*@return authenticationService
*/
public AuthenticationService getAuthenticationService()
{
//check for null for cluster environment
if (authenticationService == null)
{
authenticationService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAuthenticationService();
}
return authenticationService;
}
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
public PersonService getPersonService()
{
if (personService == null)
{
personService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_TITLE_DELETE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ getPerson().getProperties().get("userName") + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}
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.model.ContentModel;
import org.alfresco.query.PagingRequest;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ISO9075;
import org.alfresco.util.Pair;
import org.alfresco.web.app.Application;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DeleteUserDialog extends BaseDialogBean
{
private static final long serialVersionUID = -4977064287365766306L;
private static Log logger = LogFactory.getLog(DeleteUserDialog.class);
private static final String ERROR_DELETE = "error_delete_user";
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 final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
transient private AuthenticationService authenticationService;
private List<Node> users = Collections.<Node> emptyList();
transient 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");
// delete the associated Person
getPersonService().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);
ReportedException.throwIfNecessary(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);
List<Pair<QName,String>> filter = Utils.generatePersonFilter(search);
if (logger.isDebugEnabled())
{
logger.debug("Query filter: " + filter);
}
List<PersonInfo> persons = getPersonService().getPeople(
filter,
true,
Utils.generatePersonSort(),
new PagingRequest(Utils.getPersonMaxResults(), null)
).getPage();
if (logger.isDebugEnabled())
{
logger.debug("Found " + persons.size() + " users");
}
this.users = new ArrayList<Node>(persons.size());
for (PersonInfo person : persons)
{
// create our Node representation
MapNode node = new MapNode(person.getNodeRef());
// 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);
}
}
/**
*@return authenticationService
*/
public AuthenticationService getAuthenticationService()
{
//check for null for cluster environment
if (authenticationService == null)
{
authenticationService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAuthenticationService();
}
return authenticationService;
}
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
public PersonService getPersonService()
{
if (personService == null)
{
personService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_TITLE_DELETE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ getPerson().getProperties().get("userName") + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}

View File

@@ -1,57 +1,57 @@
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
{
private static final long serialVersionUID = -1690749440382024258L;
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();
}
}
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
{
private static final long serialVersionUID = -1690749440382024258L;
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();
}
}

View File

@@ -1,19 +1,19 @@
package org.alfresco.web.bean.users;
import javax.faces.context.FacesContext;
import org.alfresco.web.bean.dialog.BaseDialogBean;
public class EditFileDialog extends BaseDialogBean
{
private static final long serialVersionUID = -4237199472024493269L;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// TODO Auto-generated method stub
return null;
}
}
package org.alfresco.web.bean.users;
import javax.faces.context.FacesContext;
import org.alfresco.web.bean.dialog.BaseDialogBean;
public class EditFileDialog extends BaseDialogBean
{
private static final long serialVersionUID = -4237199472024493269L;
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -1,193 +1,193 @@
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
/**
* @author YanO
*
*/
public class EditUserDetailsDialog extends BaseDialogBean
{
private static final long serialVersionUID = 8663254425262484L;
private Node person;
protected UsersBeanProperties properties;
private NodeRef photoRef;
private String personDescription;
/**
* @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);
this.person = this.properties.getPerson();
this.photoRef = null;
this.personDescription = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
try
{
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
DictionaryService dd = services.getDictionaryService();
Map<QName, Serializable> props = getNodeService().getProperties(getPerson().getNodeRef());
for (String key : getPerson().getProperties().keySet())
{
QName propQName = QName.createQName(key);
if (dd.getProperty(propQName) == null || dd.getProperty(propQName).isProtected() == false)
{
props.put(propQName, (Serializable)getPerson().getProperties().get(key));
}
}
// persist all property changes
NodeRef personRef = getPerson().getNodeRef();
this.getNodeService().setProperties(personRef, props);
// save person description content field
if (this.personDescription != null)
{
ContentService cs = services.getContentService();
ContentWriter writer = cs.getWriter(personRef, ContentModel.PROP_PERSONDESC, true);
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
writer.putContent(this.personDescription);
}
// setup user avatar association
if (this.photoRef != null)
{
List<AssociationRef> refs = this.getNodeService().getTargetAssocs(personRef, ContentModel.ASSOC_AVATAR);
// remove old association if it exists
if (refs.size() == 1)
{
NodeRef existingRef = refs.get(0).getTargetRef();
this.getNodeService().removeAssociation(
personRef, existingRef, ContentModel.ASSOC_AVATAR);
}
// setup new association
this.getNodeService().createAssociation(personRef, this.photoRef, ContentModel.ASSOC_AVATAR);
}
// if the above calls were 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;
ReportedException.throwIfNecessary(err);
}
return outcome;
}
public Node getPerson()
{
return person;
}
public String getEmail()
{
Object value = person.getProperties().get(ContentModel.PROP_EMAIL);
return value == null ? null : value.toString();
}
public void setEmail(String email)
{
person.getProperties().put(ContentModel.PROP_EMAIL.toString(), email);
}
public String getFirstName()
{
Object value = person.getProperties().get(ContentModel.PROP_FIRSTNAME);
return value == null ? null : value.toString();
}
public void setFirstName(String firstName)
{
person.getProperties().put(ContentModel.PROP_FIRSTNAME.toString(), firstName);
}
public String getLastName()
{
Object value = person.getProperties().get(ContentModel.PROP_LASTNAME);
return value == null ? null : value.toString();
}
public String getPersonDescription()
{
if (personDescription == null)
{
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(this.person.getNodeRef(), ContentModel.PROP_PERSONDESC);
if (reader != null && reader.exists())
{
personDescription = reader.getContentString();
}
}
return personDescription;
}
public void setPersonDescription(String s)
{
this.personDescription = s;
}
public void setLastName(String lastName)
{
person.getProperties().put(ContentModel.PROP_LASTNAME.toString(), lastName);
}
public Map<String, Object> getPersonProperties()
{
return person.getProperties();
}
public NodeRef getPersonPhotoRef()
{
if (this.photoRef == null)
{
List<AssociationRef> refs = this.getNodeService().getTargetAssocs(person.getNodeRef(), ContentModel.ASSOC_AVATAR);
if (refs.size() == 1)
{
this.photoRef = refs.get(0).getTargetRef();
}
}
return this.photoRef;
}
public void setPersonPhotoRef(NodeRef ref)
{
this.photoRef = ref;
}
}
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
/**
* @author YanO
*
*/
public class EditUserDetailsDialog extends BaseDialogBean
{
private static final long serialVersionUID = 8663254425262484L;
private Node person;
protected UsersBeanProperties properties;
private NodeRef photoRef;
private String personDescription;
/**
* @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);
this.person = this.properties.getPerson();
this.photoRef = null;
this.personDescription = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
try
{
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
DictionaryService dd = services.getDictionaryService();
Map<QName, Serializable> props = getNodeService().getProperties(getPerson().getNodeRef());
for (String key : getPerson().getProperties().keySet())
{
QName propQName = QName.createQName(key);
if (dd.getProperty(propQName) == null || dd.getProperty(propQName).isProtected() == false)
{
props.put(propQName, (Serializable)getPerson().getProperties().get(key));
}
}
// persist all property changes
NodeRef personRef = getPerson().getNodeRef();
this.getNodeService().setProperties(personRef, props);
// save person description content field
if (this.personDescription != null)
{
ContentService cs = services.getContentService();
ContentWriter writer = cs.getWriter(personRef, ContentModel.PROP_PERSONDESC, true);
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
writer.putContent(this.personDescription);
}
// setup user avatar association
if (this.photoRef != null)
{
List<AssociationRef> refs = this.getNodeService().getTargetAssocs(personRef, ContentModel.ASSOC_AVATAR);
// remove old association if it exists
if (refs.size() == 1)
{
NodeRef existingRef = refs.get(0).getTargetRef();
this.getNodeService().removeAssociation(
personRef, existingRef, ContentModel.ASSOC_AVATAR);
}
// setup new association
this.getNodeService().createAssociation(personRef, this.photoRef, ContentModel.ASSOC_AVATAR);
}
// if the above calls were 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;
ReportedException.throwIfNecessary(err);
}
return outcome;
}
public Node getPerson()
{
return person;
}
public String getEmail()
{
Object value = person.getProperties().get(ContentModel.PROP_EMAIL);
return value == null ? null : value.toString();
}
public void setEmail(String email)
{
person.getProperties().put(ContentModel.PROP_EMAIL.toString(), email);
}
public String getFirstName()
{
Object value = person.getProperties().get(ContentModel.PROP_FIRSTNAME);
return value == null ? null : value.toString();
}
public void setFirstName(String firstName)
{
person.getProperties().put(ContentModel.PROP_FIRSTNAME.toString(), firstName);
}
public String getLastName()
{
Object value = person.getProperties().get(ContentModel.PROP_LASTNAME);
return value == null ? null : value.toString();
}
public String getPersonDescription()
{
if (personDescription == null)
{
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(this.person.getNodeRef(), ContentModel.PROP_PERSONDESC);
if (reader != null && reader.exists())
{
personDescription = reader.getContentString();
}
}
return personDescription;
}
public void setPersonDescription(String s)
{
this.personDescription = s;
}
public void setLastName(String lastName)
{
person.getProperties().put(ContentModel.PROP_LASTNAME.toString(), lastName);
}
public Map<String, Object> getPersonProperties()
{
return person.getProperties();
}
public NodeRef getPersonPhotoRef()
{
if (this.photoRef == null)
{
List<AssociationRef> refs = this.getNodeService().getTargetAssocs(person.getNodeRef(), ContentModel.ASSOC_AVATAR);
if (refs.size() == 1)
{
this.photoRef = refs.get(0).getTargetRef();
}
}
return this.photoRef;
}
public void setPersonPhotoRef(NodeRef ref)
{
this.photoRef = ref;
}
}

View File

@@ -1,62 +1,62 @@
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 long serialVersionUID = 614541023231055676L;
private static final String MSG_MODIFY_USER_ROLE = "modify_user_roles";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MODIFY_USER_ROLE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ spaceUsersBean.getPersonName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}
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 long serialVersionUID = 614541023231055676L;
private static final String MSG_MODIFY_USER_ROLE = "modify_user_roles";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MODIFY_USER_ROLE) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ spaceUsersBean.getPersonName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}

View File

@@ -1,153 +1,153 @@
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.util.Pair;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author YanO
*
*/
public class EditUserWizard extends CreateUserWizard
{
private static final long serialVersionUID = 7529989488476324511L;
private static Log logger = LogFactory.getLog(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");
this.organisation = (String) props.get("organization");
this.jobtitle = (String) props.get("jobtitle");
this.location = (String) props.get("location");
this.presenceProvider = (String) props.get("presenceProvider");
this.presenceUsername = (String) props.get("presenceUsername");
this.sizeQuota = (Long) props.get("sizeQuota");
if (this.sizeQuota != null && this.sizeQuota == -1L)
{
this.sizeQuota = null;
}
if (this.sizeQuota != null)
{
Pair<Long, String> size = convertFromBytes(this.sizeQuota);
this.sizeQuota = size.getFirst();
this.sizeQuotaUnits = size.getSecond();
}
// 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 (homeFolderRef != null && this.getNodeService().exists(homeFolderRef) == true)
{
ChildAssociationRef childAssocRef = this.getNodeService().getPrimaryParent(homeFolderRef);
NodeRef parentRef = childAssocRef.getParentRef();
if (this.getNodeService().getRootNode(Repository.getStoreRef()).equals(parentRef) == false)
{
this.homeSpaceLocation = parentRef;
this.homeSpaceName = Repository.getNameForNode(getNodeService(), 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();
// Note: The previous approach was to try a move the home folder if changed,
// but this was problematic as other users that shared the same folder
// moved too. We cannot tell if it is shared. Decided it is better to just
// create a new folder or reuse the folder pointed to just like the initial
// creation in CreateUserWizard. It is always possible to move the contents
// of the old home folder by hand later.
Map<QName, Serializable> props = this.getNodeService().getProperties(nodeRef);
NodeRef oldHomeFolderRef = (NodeRef) this.getNodeService().getProperty(nodeRef, ContentModel.PROP_HOMEFOLDER);
if (oldHomeFolderRef != null && getNodeService().exists(oldHomeFolderRef) == false)
{
oldHomeFolderRef = null;
}
setPersonPropertiesAndCreateHomeSpaceIfNeeded(props, oldHomeFolderRef, context);
// update the node that represents the Person
this.getNodeService().setProperties(nodeRef, props);
// TODO: RESET HomeSpace Ref found in top-level navigation bar!
// NOTE: not need cos only admin can do this?
if ((this.sizeQuota != null) && (this.sizeQuota < 0L))
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, UsersDialog.ERROR_NEGATIVE_QUOTA), this.sizeQuota));
outcome = null;
}
else
{
putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits);
}
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
outcome = null;
ReportedException.throwIfNecessary(e);
}
if (outcome == null)
{
this.isFinished = false;
}
return outcome;
}
@Override
public Map getPersonPropertiesImmutability()
{
return this.properties.getImmutability();
}
}
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.util.Pair;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author YanO
*
*/
public class EditUserWizard extends CreateUserWizard
{
private static final long serialVersionUID = 7529989488476324511L;
private static Log logger = LogFactory.getLog(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");
this.organisation = (String) props.get("organization");
this.jobtitle = (String) props.get("jobtitle");
this.location = (String) props.get("location");
this.presenceProvider = (String) props.get("presenceProvider");
this.presenceUsername = (String) props.get("presenceUsername");
this.sizeQuota = (Long) props.get("sizeQuota");
if (this.sizeQuota != null && this.sizeQuota == -1L)
{
this.sizeQuota = null;
}
if (this.sizeQuota != null)
{
Pair<Long, String> size = convertFromBytes(this.sizeQuota);
this.sizeQuota = size.getFirst();
this.sizeQuotaUnits = size.getSecond();
}
// 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 (homeFolderRef != null && this.getNodeService().exists(homeFolderRef) == true)
{
ChildAssociationRef childAssocRef = this.getNodeService().getPrimaryParent(homeFolderRef);
NodeRef parentRef = childAssocRef.getParentRef();
if (this.getNodeService().getRootNode(Repository.getStoreRef()).equals(parentRef) == false)
{
this.homeSpaceLocation = parentRef;
this.homeSpaceName = Repository.getNameForNode(getNodeService(), 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();
// Note: The previous approach was to try a move the home folder if changed,
// but this was problematic as other users that shared the same folder
// moved too. We cannot tell if it is shared. Decided it is better to just
// create a new folder or reuse the folder pointed to just like the initial
// creation in CreateUserWizard. It is always possible to move the contents
// of the old home folder by hand later.
Map<QName, Serializable> props = this.getNodeService().getProperties(nodeRef);
NodeRef oldHomeFolderRef = (NodeRef) this.getNodeService().getProperty(nodeRef, ContentModel.PROP_HOMEFOLDER);
if (oldHomeFolderRef != null && getNodeService().exists(oldHomeFolderRef) == false)
{
oldHomeFolderRef = null;
}
setPersonPropertiesAndCreateHomeSpaceIfNeeded(props, oldHomeFolderRef, context);
// update the node that represents the Person
this.getNodeService().setProperties(nodeRef, props);
// TODO: RESET HomeSpace Ref found in top-level navigation bar!
// NOTE: not need cos only admin can do this?
if ((this.sizeQuota != null) && (this.sizeQuota < 0L))
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(context, UsersDialog.ERROR_NEGATIVE_QUOTA), this.sizeQuota));
outcome = null;
}
else
{
putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits);
}
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
outcome = null;
ReportedException.throwIfNecessary(e);
}
if (outcome == null)
{
this.isFinished = false;
}
return outcome;
}
@Override
public Map getPersonPropertiesImmutability()
{
return this.properties.getImmutability();
}
}

View File

@@ -1,76 +1,76 @@
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;
/**
* Implementation of remove content user dialog.
*
* @author gavinc
*/
public class RemoveContentUserDialog extends BaseDialogBean
{
private static final long serialVersionUID = -3090054828215666084L;
private static final String MSG_REMOVE_USER = "remove_user";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private ContentUsersBean contentUsersBean;
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
contentUsersBean.removeOK();
return outcome;
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_REMOVE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ this.getPersonName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
return this.browseBean.getDocument().getName();
}
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;
}
}
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;
/**
* Implementation of remove content user dialog.
*
* @author gavinc
*/
public class RemoveContentUserDialog extends BaseDialogBean
{
private static final long serialVersionUID = -3090054828215666084L;
private static final String MSG_REMOVE_USER = "remove_user";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private ContentUsersBean contentUsersBean;
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
contentUsersBean.removeOK();
return outcome;
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_REMOVE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ this.getPersonName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
return this.browseBean.getDocument().getName();
}
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;
}
}

View File

@@ -1,80 +1,80 @@
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 long serialVersionUID = -7457234588814115434L;
private static final String BUTTON_NO = "no";
private static final String BUTTON_YES = "yes";
private static final String MSG_REMOVE_USER = "remove_user";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private SpaceUsersBean spaceUsersBean;
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return spaceUsersBean.removeOK();
}
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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_REMOVE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + spaceUsersBean.getPersonName()
+ Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}
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 long serialVersionUID = -7457234588814115434L;
private static final String BUTTON_NO = "no";
private static final String BUTTON_YES = "yes";
private static final String MSG_REMOVE_USER = "remove_user";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
private SpaceUsersBean spaceUsersBean;
@Override
public boolean getFinishButtonDisabled()
{
return false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return spaceUsersBean.removeOK();
}
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()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_REMOVE_USER) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE) + spaceUsersBean.getPersonName()
+ Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
}

View File

@@ -1,65 +1,65 @@
package org.alfresco.web.bean.users;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Concrete implementation providing access to users of the current space.
*
* @author gavinc
*/
public class SpaceUsersBean extends UserMembersBean
{
private static final long serialVersionUID = -4847219834289259559L;
private final static String MSG_MANAGE_INVITED_USERS = "manage_invited_users";
private final static String MSG_SPACE_OWNER = "space_owner";
private final static String MSG_CLOSE= "close";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
/**
* @return The space to work against
*/
public Node getNode()
{
return this.browseBean.getActionSpace();
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public Object getActionsContext()
{
return getNode();
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MANAGE_INVITED_USERS) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ browseBean.getActionSpace().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
String pattern = Application.getMessage(FacesContext.getCurrentInstance(), MSG_SPACE_OWNER);
return MessageFormat.format(pattern, getOwner());
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
}
package org.alfresco.web.bean.users;
import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
/**
* Concrete implementation providing access to users of the current space.
*
* @author gavinc
*/
public class SpaceUsersBean extends UserMembersBean
{
private static final long serialVersionUID = -4847219834289259559L;
private final static String MSG_MANAGE_INVITED_USERS = "manage_invited_users";
private final static String MSG_SPACE_OWNER = "space_owner";
private final static String MSG_CLOSE= "close";
private final static String MSG_LEFT_QUOTE = "left_qoute";
private final static String MSG_RIGHT_QUOTE = "right_quote";
/**
* @return The space to work against
*/
public Node getNode()
{
return this.browseBean.getActionSpace();
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public Object getActionsContext()
{
return getNode();
}
@Override
public String getContainerTitle()
{
FacesContext fc = FacesContext.getCurrentInstance();
return Application.getMessage(fc, MSG_MANAGE_INVITED_USERS) + " " + Application.getMessage(fc, MSG_LEFT_QUOTE)
+ browseBean.getActionSpace().getName() + Application.getMessage(fc, MSG_RIGHT_QUOTE);
}
@Override
public String getContainerSubTitle()
{
String pattern = Application.getMessage(FacesContext.getCurrentInstance(), MSG_SPACE_OWNER);
return MessageFormat.format(pattern, getOwner());
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
}

View File

@@ -1,25 +1,25 @@
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 long serialVersionUID = -217662039833342921L;
private static final String MSG_CLOSE = "close";
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
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 long serialVersionUID = -217662039833342921L;
private static final String MSG_CLOSE = "close";
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
@Override
public String getCancelButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CLOSE);
}
}

View File

@@ -1,394 +1,394 @@
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.PreferencesService;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.config.LanguagesConfigElement;
import org.springframework.extensions.config.Config;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Simple bean backing the user preferences settings.
*
* @author Kevin Roast
*/
public class UserPreferencesBean implements Serializable
{
private static final long serialVersionUID = -1262481849503163054L;
public static final String PREF_INTERFACELANGUAGE = "interface-language";
private static final String PREF_STARTLOCATION = "start-location";
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
private static final String PREF_DOWNLOADAUTOMATICALLY = "download-automatically";
/**
* Remplacement message for set the filter at 'all languages'.
* Must be considered as a null value.
*/
public static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
/** content language locale selection */
private String contentFilterLanguage = null;
/** the injected MultilingualContentService */
transient private MultilingualContentService multilingualContentService;
/** the injected ContentFilterLanguagesService */
transient private ContentFilterLanguagesService contentFilterLanguagesService;
/** the injected NodeService */
transient private NodeService nodeService;
/**
* @return the list of available languages
*/
public SelectItem[] getLanguages()
{
// Get the item selection list for the list of languages
return getLanguageItems();
}
/**
* @return Returns the language selection for the current user session.
*/
public String getLanguage()
{
return Application.getLanguage(FacesContext.getCurrentInstance()).toString();
}
/**
* @param language The language selection to set.
*/
public void setLanguage(String language)
{
// set the language for the current session
Application.setLanguage(FacesContext.getCurrentInstance(), language);
// save user preference
if (Application.getCurrentUser(FacesContext.getCurrentInstance()) != null)
{
PreferencesService.getPreferences().setValue(PREF_INTERFACELANGUAGE, language);
}
}
/**
* @return current content filter language, or <tt>null</tt> if all languages was selected
*/
public String getContentFilterLanguage()
{
if (this.contentFilterLanguage == null)
{
Locale locale = (Locale) PreferencesService.getPreferences().getValue(PREF_CONTENTFILTERLANGUAGE);
// Null means All Languages
if (locale == null)
{
this.contentFilterLanguage = null;
}
else
{
this.contentFilterLanguage = locale.toString();
}
}
// set the content filter locale on the core
I18NUtil.setContentLocale(I18NUtil.parseLocale(this.contentFilterLanguage));
return this.contentFilterLanguage;
}
/**
* @param contentFilterLanguage A valid locale string or {@link #MSG_CONTENTALLLANGUAGES}
*/
public void setContentFilterLanguage(String contentFilterLanguage)
{
this.contentFilterLanguage = contentFilterLanguage;
Locale language = null;
if (contentFilterLanguage.equals(MSG_CONTENTALLLANGUAGES))
{
// The generic "All Languages" was selected - persist this as a null
this.contentFilterLanguage = null;
}
else
{
// It should be a proper locale string
language = I18NUtil.parseLocale(contentFilterLanguage);
}
PreferencesService.getPreferences().setValue(PREF_CONTENTFILTERLANGUAGE, language);
// set the content filter locale on the core
I18NUtil.setContentLocale(language);
// Ensure a refresh
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
}
/**
* @return list of items for the content filtering language selection include the label 'all langaguages'
*/
public SelectItem[] getContentFilterLanguages()
{
// Get the item selection list
return getContentFilterLanguages(true);
}
/**
* @param includeAllLanguages if true, the list must include the label 'all languages'
* @return list of items for the content filtering language selection
*/
public SelectItem[] getContentFilterLanguages(boolean includeAllLanguages)
{
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle msg = Application.getBundle(fc);
// get the list of filter languages
List<String> languages = getContentFilterLanguagesService().getFilterLanguages();
// set the item selection list
SelectItem[] items = new SelectItem[(includeAllLanguages) ? languages.size() + 1 : languages.size()];
int idx = 0;
// include the <All Languages> item if needed
if (includeAllLanguages)
{
String allLanguagesStr = msg.getString(MSG_CONTENTALLLANGUAGES);
items[idx] = new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr);
idx++;
}
for (String lang : languages)
{
String label = getContentFilterLanguagesService().getLabelByCode(lang);
items[idx] = new SelectItem(lang, label);
idx++;
}
return items;
}
/**
* return the list of languages in which the given node hasn't be translated yet.
*
* @param translation the translatable node ref
* @param returnTranslationLanguage if true, return the language of the given translation.
* @return the list of languages
*/
public SelectItem[] getAvailablesContentFilterLanguages(NodeRef translation, boolean returnTranslationLanguage)
{
// get the list of missing translation of this node
List<Locale> missingLocales = getMultilingualContentService().getMissingTranslations(translation, returnTranslationLanguage);
// set the item selection list
SelectItem[] items = new SelectItem[missingLocales.size()];
int idx = 0;
for(Locale locale : missingLocales)
{
String label = getContentFilterLanguagesService().getLabelByCode(locale.getLanguage());
items[idx] = new SelectItem(
locale.toString(),
label);
idx++;
}
return items;
}
/**
* Helper to return the available language items
*
* @return Array of SelectItem objects
*/
private static SelectItem[] getLanguageItems()
{
FacesContext fc = FacesContext.getCurrentInstance();
Config config = Application.getConfigService(fc).getConfig("Languages");
LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement(
LanguagesConfigElement.CONFIG_ELEMENT_ID);
List<String> languages = langConfig.getLanguages();
List<SelectItem> items = new ArrayList<SelectItem>(10);
for (String locale : languages)
{
// get label associated to the locale
String label = langConfig.getLabelForLanguage(locale);
items.add(new SelectItem(locale, label));
}
return items.toArray(new SelectItem[items.size()]);
}
/**
* @return the start location for this user (@see NavigationBean)
*/
public String getStartLocation()
{
String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION);
if (location == null)
{
// default to value from client config
location = Application.getClientConfig(FacesContext.getCurrentInstance()).getInitialLocation();
}
return location;
}
/**
* @param location The current start location for this user (@see NavigationBean)
*/
public void setStartLocation(String location)
{
PreferencesService.getPreferences().setValue(PREF_STARTLOCATION, location);
}
/**
* @return the list of available start locations
*/
public SelectItem[] getStartLocations()
{
FacesContext fc = FacesContext.getCurrentInstance();
NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, "NavigationBean");
ResourceBundle msg = Application.getBundle(fc);
List<SelectItem> locations = new ArrayList<SelectItem>(4);
// add My Alfresco location
locations.add(new SelectItem(
NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO)));
// add My Home location
locations.add(new SelectItem(
NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME)));
// add Company Home location if visible
if (navigator.getCompanyHomeVisible())
{
locations.add(new SelectItem(
NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME)));
}
// add Guest Home location if visible
if (navigator.getGuestHomeVisible())
{
locations.add(new SelectItem(
NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME)));
}
return locations.toArray(new SelectItem[locations.size()]);
}
/**
* @return true if the Guest user is allowed to configure the user preferences
*/
public boolean getAllowGuestConfig()
{
return Application.getClientConfig(FacesContext.getCurrentInstance()).getAllowGuestConfig();
}
/**
* @return the multilingualContentService
*/
public MultilingualContentService getMultilingualContentService()
{
if (multilingualContentService == null)
{
multilingualContentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getMultilingualContentService();
}
return multilingualContentService;
}
/**
* @param multilingualContentService the multilingualContentService to set
*/
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
/**
* @return the nodeService
*/
public NodeService getNodeService()
{
if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}
return nodeService;
}
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param contentFilterLanguagesService the contentFilterLanguagesService to set
*/
public void setContentFilterLanguagesService(
ContentFilterLanguagesService contentFilterLanguagesService)
{
this.contentFilterLanguagesService = contentFilterLanguagesService;
}
/**
* @return the contentFilterLanguagesService
*/
ContentFilterLanguagesService getContentFilterLanguagesService()
{
if (contentFilterLanguagesService == null)
{
contentFilterLanguagesService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentFilterLanguagesService();
}
return contentFilterLanguagesService;
}
/**
* @return download files automatically for offline editing or not
*/
public boolean isDownloadAutomatically()
{
Boolean downloadAutomatically = (Boolean) PreferencesService.getPreferences().getValue(PREF_DOWNLOADAUTOMATICALLY);
if (downloadAutomatically == null)
{
return true;
}
else
{
return downloadAutomatically.booleanValue();
}
}
/**
* @param downloadAutomatically the boolean value to set
*/
public void setDownloadAutomatically(boolean downloadAutomatically)
{
PreferencesService.getPreferences().setValue(PREF_DOWNLOADAUTOMATICALLY, downloadAutomatically);
}
}
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.PreferencesService;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.config.LanguagesConfigElement;
import org.springframework.extensions.config.Config;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Simple bean backing the user preferences settings.
*
* @author Kevin Roast
*/
public class UserPreferencesBean implements Serializable
{
private static final long serialVersionUID = -1262481849503163054L;
public static final String PREF_INTERFACELANGUAGE = "interface-language";
private static final String PREF_STARTLOCATION = "start-location";
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
private static final String PREF_DOWNLOADAUTOMATICALLY = "download-automatically";
/**
* Remplacement message for set the filter at 'all languages'.
* Must be considered as a null value.
*/
public static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
/** content language locale selection */
private String contentFilterLanguage = null;
/** the injected MultilingualContentService */
transient private MultilingualContentService multilingualContentService;
/** the injected ContentFilterLanguagesService */
transient private ContentFilterLanguagesService contentFilterLanguagesService;
/** the injected NodeService */
transient private NodeService nodeService;
/**
* @return the list of available languages
*/
public SelectItem[] getLanguages()
{
// Get the item selection list for the list of languages
return getLanguageItems();
}
/**
* @return Returns the language selection for the current user session.
*/
public String getLanguage()
{
return Application.getLanguage(FacesContext.getCurrentInstance()).toString();
}
/**
* @param language The language selection to set.
*/
public void setLanguage(String language)
{
// set the language for the current session
Application.setLanguage(FacesContext.getCurrentInstance(), language);
// save user preference
if (Application.getCurrentUser(FacesContext.getCurrentInstance()) != null)
{
PreferencesService.getPreferences().setValue(PREF_INTERFACELANGUAGE, language);
}
}
/**
* @return current content filter language, or <tt>null</tt> if all languages was selected
*/
public String getContentFilterLanguage()
{
if (this.contentFilterLanguage == null)
{
Locale locale = (Locale) PreferencesService.getPreferences().getValue(PREF_CONTENTFILTERLANGUAGE);
// Null means All Languages
if (locale == null)
{
this.contentFilterLanguage = null;
}
else
{
this.contentFilterLanguage = locale.toString();
}
}
// set the content filter locale on the core
I18NUtil.setContentLocale(I18NUtil.parseLocale(this.contentFilterLanguage));
return this.contentFilterLanguage;
}
/**
* @param contentFilterLanguage A valid locale string or {@link #MSG_CONTENTALLLANGUAGES}
*/
public void setContentFilterLanguage(String contentFilterLanguage)
{
this.contentFilterLanguage = contentFilterLanguage;
Locale language = null;
if (contentFilterLanguage.equals(MSG_CONTENTALLLANGUAGES))
{
// The generic "All Languages" was selected - persist this as a null
this.contentFilterLanguage = null;
}
else
{
// It should be a proper locale string
language = I18NUtil.parseLocale(contentFilterLanguage);
}
PreferencesService.getPreferences().setValue(PREF_CONTENTFILTERLANGUAGE, language);
// set the content filter locale on the core
I18NUtil.setContentLocale(language);
// Ensure a refresh
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
}
/**
* @return list of items for the content filtering language selection include the label 'all langaguages'
*/
public SelectItem[] getContentFilterLanguages()
{
// Get the item selection list
return getContentFilterLanguages(true);
}
/**
* @param includeAllLanguages if true, the list must include the label 'all languages'
* @return list of items for the content filtering language selection
*/
public SelectItem[] getContentFilterLanguages(boolean includeAllLanguages)
{
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle msg = Application.getBundle(fc);
// get the list of filter languages
List<String> languages = getContentFilterLanguagesService().getFilterLanguages();
// set the item selection list
SelectItem[] items = new SelectItem[(includeAllLanguages) ? languages.size() + 1 : languages.size()];
int idx = 0;
// include the <All Languages> item if needed
if (includeAllLanguages)
{
String allLanguagesStr = msg.getString(MSG_CONTENTALLLANGUAGES);
items[idx] = new SelectItem(MSG_CONTENTALLLANGUAGES, allLanguagesStr);
idx++;
}
for (String lang : languages)
{
String label = getContentFilterLanguagesService().getLabelByCode(lang);
items[idx] = new SelectItem(lang, label);
idx++;
}
return items;
}
/**
* return the list of languages in which the given node hasn't be translated yet.
*
* @param translation the translatable node ref
* @param returnTranslationLanguage if true, return the language of the given translation.
* @return the list of languages
*/
public SelectItem[] getAvailablesContentFilterLanguages(NodeRef translation, boolean returnTranslationLanguage)
{
// get the list of missing translation of this node
List<Locale> missingLocales = getMultilingualContentService().getMissingTranslations(translation, returnTranslationLanguage);
// set the item selection list
SelectItem[] items = new SelectItem[missingLocales.size()];
int idx = 0;
for(Locale locale : missingLocales)
{
String label = getContentFilterLanguagesService().getLabelByCode(locale.getLanguage());
items[idx] = new SelectItem(
locale.toString(),
label);
idx++;
}
return items;
}
/**
* Helper to return the available language items
*
* @return Array of SelectItem objects
*/
private static SelectItem[] getLanguageItems()
{
FacesContext fc = FacesContext.getCurrentInstance();
Config config = Application.getConfigService(fc).getConfig("Languages");
LanguagesConfigElement langConfig = (LanguagesConfigElement)config.getConfigElement(
LanguagesConfigElement.CONFIG_ELEMENT_ID);
List<String> languages = langConfig.getLanguages();
List<SelectItem> items = new ArrayList<SelectItem>(10);
for (String locale : languages)
{
// get label associated to the locale
String label = langConfig.getLabelForLanguage(locale);
items.add(new SelectItem(locale, label));
}
return items.toArray(new SelectItem[items.size()]);
}
/**
* @return the start location for this user (@see NavigationBean)
*/
public String getStartLocation()
{
String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION);
if (location == null)
{
// default to value from client config
location = Application.getClientConfig(FacesContext.getCurrentInstance()).getInitialLocation();
}
return location;
}
/**
* @param location The current start location for this user (@see NavigationBean)
*/
public void setStartLocation(String location)
{
PreferencesService.getPreferences().setValue(PREF_STARTLOCATION, location);
}
/**
* @return the list of available start locations
*/
public SelectItem[] getStartLocations()
{
FacesContext fc = FacesContext.getCurrentInstance();
NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, "NavigationBean");
ResourceBundle msg = Application.getBundle(fc);
List<SelectItem> locations = new ArrayList<SelectItem>(4);
// add My Alfresco location
locations.add(new SelectItem(
NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO)));
// add My Home location
locations.add(new SelectItem(
NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME)));
// add Company Home location if visible
if (navigator.getCompanyHomeVisible())
{
locations.add(new SelectItem(
NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME)));
}
// add Guest Home location if visible
if (navigator.getGuestHomeVisible())
{
locations.add(new SelectItem(
NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME)));
}
return locations.toArray(new SelectItem[locations.size()]);
}
/**
* @return true if the Guest user is allowed to configure the user preferences
*/
public boolean getAllowGuestConfig()
{
return Application.getClientConfig(FacesContext.getCurrentInstance()).getAllowGuestConfig();
}
/**
* @return the multilingualContentService
*/
public MultilingualContentService getMultilingualContentService()
{
if (multilingualContentService == null)
{
multilingualContentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getMultilingualContentService();
}
return multilingualContentService;
}
/**
* @param multilingualContentService the multilingualContentService to set
*/
public void setMultilingualContentService(
MultilingualContentService multilingualContentService)
{
this.multilingualContentService = multilingualContentService;
}
/**
* @return the nodeService
*/
public NodeService getNodeService()
{
if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}
return nodeService;
}
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param contentFilterLanguagesService the contentFilterLanguagesService to set
*/
public void setContentFilterLanguagesService(
ContentFilterLanguagesService contentFilterLanguagesService)
{
this.contentFilterLanguagesService = contentFilterLanguagesService;
}
/**
* @return the contentFilterLanguagesService
*/
ContentFilterLanguagesService getContentFilterLanguagesService()
{
if (contentFilterLanguagesService == null)
{
contentFilterLanguagesService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentFilterLanguagesService();
}
return contentFilterLanguagesService;
}
/**
* @return download files automatically for offline editing or not
*/
public boolean isDownloadAutomatically()
{
Boolean downloadAutomatically = (Boolean) PreferencesService.getPreferences().getValue(PREF_DOWNLOADAUTOMATICALLY);
if (downloadAutomatically == null)
{
return true;
}
else
{
return downloadAutomatically.booleanValue();
}
}
/**
* @param downloadAutomatically the boolean value to set
*/
public void setDownloadAutomatically(boolean downloadAutomatically)
{
PreferencesService.getPreferences().setValue(PREF_DOWNLOADAUTOMATICALLY, downloadAutomatically);
}
}

View File

@@ -1,470 +1,470 @@
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.sync.UserRegistrySynchronizer;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.usage.ContentUsageService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.servlet.DownloadContentServlet;
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.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.data.UIRichList;
import org.springframework.web.jsf.FacesContextUtils;
/**
* Bean holding the properties for a Person node.
*
* Used by the Create/EditUserWizard, UsersDialog and EditUserDetailsDetails to maitain user state during dialog.
*
* Also provides access to a map of the properties to mutability which is used to disable appropriate controls on edit
* dialogs if properties are externally mapped to LDAP or similar.
*/
public class UsersBeanProperties implements Serializable
{
private static final long serialVersionUID = 8874192805959149144L;
/** NodeService bean reference */
transient private NodeService nodeService;
/** SearchService bean reference */
transient private SearchService searchService;
/** AuthenticationService bean reference */
transient private MutableAuthenticationService authenticationService;
/** PersonService bean reference */
transient private PersonService personService;
/** ContentUsageService bean reference */
transient private ContentUsageService contentUsageService;
/** userRegistrySynchronizer bean reference */
transient private UserRegistrySynchronizer userRegistrySynchronizer;
/** 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;
private String userName = null;
private Map<String, Boolean> immutabilty = null;
// ------------------------------------------------------------------------------
// Bean property getters and setters
/**
* @return the nodeService
*/
public NodeService getNodeService()
{
if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}
return nodeService;
}
/**
* @return the searchService
*/
public SearchService getSearchService()
{
if (searchService == null)
{
searchService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSearchService();
}
return searchService;
}
/**
* @return the authenticationService
*/
public MutableAuthenticationService getAuthenticationService()
{
if (authenticationService == null)
{
authenticationService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAuthenticationService();
}
return authenticationService;
}
/**
* @return the personService
*/
public PersonService getPersonService()
{
if (personService == null)
{
personService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPersonService();
}
return personService;
}
/**
* @return contentUsageService
*/
public ContentUsageService getContentUsageService()
{
if (contentUsageService == null)
{
contentUsageService = (ContentUsageService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "ContentUsageService");
}
return contentUsageService;
}
/**
* @return userRegistrySynchronizer
*/
public UserRegistrySynchronizer getUserRegistrySynchronizer()
{
if (userRegistrySynchronizer == null)
{
userRegistrySynchronizer = (UserRegistrySynchronizer)FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance()).getBean("userRegistrySynchronizer");
}
return userRegistrySynchronizer;
}
/**
* @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(MutableAuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
/**
* @param personService The PersonService to set.
*/
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
/**
* @param contentUsageService The ContentUsageService to set.
*/
public void setContentUsageService(ContentUsageService contentUsageService)
{
this.contentUsageService = contentUsageService;
}
/**
* @param userRegistrySynchronizer UserRegistrySynchronizer
*/
public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
{
this.userRegistrySynchronizer = userRegistrySynchronizer;
}
/**
* @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 p The person context to set.
*/
public void setPerson(final Node p)
{
// perform the set in a txn as certain bean calls require it
FacesContext context = FacesContext.getCurrentInstance();
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public Object execute() throws Throwable
{
person = p;
userName = (String)person.getProperties().get(ContentModel.PROP_USERNAME);
// rebuild the property immutability map helper object
immutabilty = new PropertyImmutabilityMap(
getUserRegistrySynchronizer().getPersonMappedProperties(userName));
return null;
}
};
try
{
txnHelper.doInTransaction(callback, false);
}
catch (Throwable e)
{
// reset the flag so we can re-attempt the operation
if (e instanceof ReportedException == false)
{
Utils.addErrorMessage(e.getMessage(), e);
}
ReportedException.throwIfNecessary(e);
}
}
public Long getUserUsage(String userName)
{
long usage = getContentUsageService().getUserUsage(userName);
return (usage == -1 ? null : usage);
}
public Long getUserUsage()
{
long usage = getContentUsageService().getUserUsage(this.userName);
return (usage == -1 ? null : usage);
}
public Long getUserQuota()
{
long quota = getContentUsageService().getUserQuota(this.userName);
return (quota == -1 ? null : quota);
}
public boolean getUsagesEnabled()
{
return getContentUsageService().getEnabled();
}
public String getPersonDescription()
{
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(this.person.getNodeRef(), ContentModel.PROP_PERSONDESC);
if (reader != null && reader.exists())
{
return Utils.stripUnsafeHTMLTags(reader.getContentString()).replace("\r\n", "<p>");
}
else
{
return null;
}
}
public String getAvatarUrl()
{
String avatarUrl = null;
List<AssociationRef> refs = getNodeService().getTargetAssocs(this.person.getNodeRef(), ContentModel.ASSOC_AVATAR);
if (refs.size() == 1)
{
NodeRef photoRef = refs.get(0).getTargetRef();
String name = (String) getNodeService().getProperty(photoRef, ContentModel.PROP_NAME);
avatarUrl = DownloadContentServlet.generateBrowserURL(photoRef, name);
}
return avatarUrl;
}
public Map<String, Boolean> getImmutability()
{
return this.immutabilty;
}
/**
* Map of person property to immutability
* The Map interface is implemented to allow JSF expressions such as
* #{DialogBean.bean.properties.immutability.propertyname}
*/
public class PropertyImmutabilityMap implements Map<String, Boolean>, Serializable
{
final private Set<QName> props;
PropertyImmutabilityMap(Set<QName> props)
{
this.props = props;
}
public void clear()
{
}
public boolean containsKey(Object k)
{
boolean contains = false;
if (k instanceof String && ((String)k).length() != 0)
{
String s = (String)k;
if (s.charAt(0) == '{' && s.indexOf('}') != -1)
{
contains = this.props.contains(k);
}
else
{
// simple property name - assume and apply CM namespace
contains = this.props.contains(QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, s));
}
}
return contains;
}
public boolean containsValue(Object v)
{
return false;
}
public Set<Entry<String, Boolean>> entrySet()
{
return null;
}
public Boolean get(Object k)
{
return containsKey(k);
}
public boolean isEmpty()
{
return this.props.size() != 0;
}
public Set<String> keySet()
{
return null;
}
public Boolean put(String k, Boolean v)
{
return null;
}
public void putAll(Map<? extends String, ? extends Boolean> m)
{
}
public Boolean remove(Object k)
{
return null;
}
public int size()
{
return this.props.size();
}
public Collection<Boolean> values()
{
return null;
}
}
}
package org.alfresco.web.bean.users;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.sync.UserRegistrySynchronizer;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.usage.ContentUsageService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.servlet.DownloadContentServlet;
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.ui.common.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.data.UIRichList;
import org.springframework.web.jsf.FacesContextUtils;
/**
* Bean holding the properties for a Person node.
*
* Used by the Create/EditUserWizard, UsersDialog and EditUserDetailsDetails to maitain user state during dialog.
*
* Also provides access to a map of the properties to mutability which is used to disable appropriate controls on edit
* dialogs if properties are externally mapped to LDAP or similar.
*/
public class UsersBeanProperties implements Serializable
{
private static final long serialVersionUID = 8874192805959149144L;
/** NodeService bean reference */
transient private NodeService nodeService;
/** SearchService bean reference */
transient private SearchService searchService;
/** AuthenticationService bean reference */
transient private MutableAuthenticationService authenticationService;
/** PersonService bean reference */
transient private PersonService personService;
/** ContentUsageService bean reference */
transient private ContentUsageService contentUsageService;
/** userRegistrySynchronizer bean reference */
transient private UserRegistrySynchronizer userRegistrySynchronizer;
/** 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;
private String userName = null;
private Map<String, Boolean> immutabilty = null;
// ------------------------------------------------------------------------------
// Bean property getters and setters
/**
* @return the nodeService
*/
public NodeService getNodeService()
{
if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}
return nodeService;
}
/**
* @return the searchService
*/
public SearchService getSearchService()
{
if (searchService == null)
{
searchService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSearchService();
}
return searchService;
}
/**
* @return the authenticationService
*/
public MutableAuthenticationService getAuthenticationService()
{
if (authenticationService == null)
{
authenticationService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAuthenticationService();
}
return authenticationService;
}
/**
* @return the personService
*/
public PersonService getPersonService()
{
if (personService == null)
{
personService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPersonService();
}
return personService;
}
/**
* @return contentUsageService
*/
public ContentUsageService getContentUsageService()
{
if (contentUsageService == null)
{
contentUsageService = (ContentUsageService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "ContentUsageService");
}
return contentUsageService;
}
/**
* @return userRegistrySynchronizer
*/
public UserRegistrySynchronizer getUserRegistrySynchronizer()
{
if (userRegistrySynchronizer == null)
{
userRegistrySynchronizer = (UserRegistrySynchronizer)FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance()).getBean("userRegistrySynchronizer");
}
return userRegistrySynchronizer;
}
/**
* @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(MutableAuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
/**
* @param personService The PersonService to set.
*/
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
/**
* @param contentUsageService The ContentUsageService to set.
*/
public void setContentUsageService(ContentUsageService contentUsageService)
{
this.contentUsageService = contentUsageService;
}
/**
* @param userRegistrySynchronizer UserRegistrySynchronizer
*/
public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
{
this.userRegistrySynchronizer = userRegistrySynchronizer;
}
/**
* @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 p The person context to set.
*/
public void setPerson(final Node p)
{
// perform the set in a txn as certain bean calls require it
FacesContext context = FacesContext.getCurrentInstance();
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public Object execute() throws Throwable
{
person = p;
userName = (String)person.getProperties().get(ContentModel.PROP_USERNAME);
// rebuild the property immutability map helper object
immutabilty = new PropertyImmutabilityMap(
getUserRegistrySynchronizer().getPersonMappedProperties(userName));
return null;
}
};
try
{
txnHelper.doInTransaction(callback, false);
}
catch (Throwable e)
{
// reset the flag so we can re-attempt the operation
if (e instanceof ReportedException == false)
{
Utils.addErrorMessage(e.getMessage(), e);
}
ReportedException.throwIfNecessary(e);
}
}
public Long getUserUsage(String userName)
{
long usage = getContentUsageService().getUserUsage(userName);
return (usage == -1 ? null : usage);
}
public Long getUserUsage()
{
long usage = getContentUsageService().getUserUsage(this.userName);
return (usage == -1 ? null : usage);
}
public Long getUserQuota()
{
long quota = getContentUsageService().getUserQuota(this.userName);
return (quota == -1 ? null : quota);
}
public boolean getUsagesEnabled()
{
return getContentUsageService().getEnabled();
}
public String getPersonDescription()
{
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(this.person.getNodeRef(), ContentModel.PROP_PERSONDESC);
if (reader != null && reader.exists())
{
return Utils.stripUnsafeHTMLTags(reader.getContentString()).replace("\r\n", "<p>");
}
else
{
return null;
}
}
public String getAvatarUrl()
{
String avatarUrl = null;
List<AssociationRef> refs = getNodeService().getTargetAssocs(this.person.getNodeRef(), ContentModel.ASSOC_AVATAR);
if (refs.size() == 1)
{
NodeRef photoRef = refs.get(0).getTargetRef();
String name = (String) getNodeService().getProperty(photoRef, ContentModel.PROP_NAME);
avatarUrl = DownloadContentServlet.generateBrowserURL(photoRef, name);
}
return avatarUrl;
}
public Map<String, Boolean> getImmutability()
{
return this.immutabilty;
}
/**
* Map of person property to immutability
* The Map interface is implemented to allow JSF expressions such as
* #{DialogBean.bean.properties.immutability.propertyname}
*/
public class PropertyImmutabilityMap implements Map<String, Boolean>, Serializable
{
final private Set<QName> props;
PropertyImmutabilityMap(Set<QName> props)
{
this.props = props;
}
public void clear()
{
}
public boolean containsKey(Object k)
{
boolean contains = false;
if (k instanceof String && ((String)k).length() != 0)
{
String s = (String)k;
if (s.charAt(0) == '{' && s.indexOf('}') != -1)
{
contains = this.props.contains(k);
}
else
{
// simple property name - assume and apply CM namespace
contains = this.props.contains(QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, s));
}
}
return contains;
}
public boolean containsValue(Object v)
{
return false;
}
public Set<Entry<String, Boolean>> entrySet()
{
return null;
}
public Boolean get(Object k)
{
return containsKey(k);
}
public boolean isEmpty()
{
return this.props.size() != 0;
}
public Set<String> keySet()
{
return null;
}
public Boolean put(String k, Boolean v)
{
return null;
}
public void putAll(Map<? extends String, ? extends Boolean> m)
{
}
public Boolean remove(Object k)
{
return null;
}
public int size()
{
return this.props.size();
}
public Collection<Boolean> values()
{
return null;
}
}
}