mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Remove high-level Java PersonService API I initially implemented to support REST Person and Invite APIs (not needed anymore)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10114 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,201 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
||||||
* FLOSS exception. You should have received a copy of the text describing
|
|
||||||
* the FLOSS exception, and it is also available here:
|
|
||||||
* http://www.alfresco.com/legal/licensing"
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.person;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Glen Johnson
|
|
||||||
*/
|
|
||||||
public class PersonDetails
|
|
||||||
{
|
|
||||||
private String userName;
|
|
||||||
private String title;
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
private String organisation;
|
|
||||||
private String jobTitle;
|
|
||||||
private String emailAddress;
|
|
||||||
private String bio;
|
|
||||||
private URL avatarUrl;
|
|
||||||
|
|
||||||
public PersonDetails(String userName, String title, String firstName, String lastName, String organisation,
|
|
||||||
String jobTitle, String emailAddress, String bio, URL avatarUrl)
|
|
||||||
{
|
|
||||||
this.userName = userName;
|
|
||||||
this.title = title;
|
|
||||||
this.firstName = firstName;
|
|
||||||
this.lastName = lastName;
|
|
||||||
this.organisation = organisation;
|
|
||||||
this.jobTitle = jobTitle;
|
|
||||||
this.emailAddress = emailAddress;
|
|
||||||
this.bio = bio;
|
|
||||||
this.avatarUrl = avatarUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the userName
|
|
||||||
*/
|
|
||||||
public String getUserName()
|
|
||||||
{
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param userName the userName to set
|
|
||||||
*/
|
|
||||||
public void setUserName(String userName)
|
|
||||||
{
|
|
||||||
this.userName = userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the title
|
|
||||||
*/
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param title the title to set
|
|
||||||
*/
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the firstName
|
|
||||||
*/
|
|
||||||
public String getFirstName()
|
|
||||||
{
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param firstName the firstName to set
|
|
||||||
*/
|
|
||||||
public void setFirstName(String firstName)
|
|
||||||
{
|
|
||||||
this.firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the lastName
|
|
||||||
*/
|
|
||||||
public String getLastName()
|
|
||||||
{
|
|
||||||
return lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastName the lastName to set
|
|
||||||
*/
|
|
||||||
public void setLastName(String lastName)
|
|
||||||
{
|
|
||||||
this.lastName = lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the organisation
|
|
||||||
*/
|
|
||||||
public String getOrganisation()
|
|
||||||
{
|
|
||||||
return organisation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param organisation the organisation to set
|
|
||||||
*/
|
|
||||||
public void setOrganisation(String organisation)
|
|
||||||
{
|
|
||||||
this.organisation = organisation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the jobTitle
|
|
||||||
*/
|
|
||||||
public String getJobTitle()
|
|
||||||
{
|
|
||||||
return jobTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param jobTitle the jobTitle to set
|
|
||||||
*/
|
|
||||||
public void setJobTitle(String jobTitle)
|
|
||||||
{
|
|
||||||
this.jobTitle = jobTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the emailAddress
|
|
||||||
*/
|
|
||||||
public String getEmailAddress()
|
|
||||||
{
|
|
||||||
return emailAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param emailAddress the emailAddress to set
|
|
||||||
*/
|
|
||||||
public void setEmailAddress(String emailAddress)
|
|
||||||
{
|
|
||||||
this.emailAddress = emailAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the bio
|
|
||||||
*/
|
|
||||||
public String getBio()
|
|
||||||
{
|
|
||||||
return bio;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bio the bio to set
|
|
||||||
*/
|
|
||||||
public void setBio(String bio)
|
|
||||||
{
|
|
||||||
this.bio = bio;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the avatarUrl
|
|
||||||
*/
|
|
||||||
public URL getAvatarUrl()
|
|
||||||
{
|
|
||||||
return avatarUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param avatarUrl the avatarUrl to set
|
|
||||||
*/
|
|
||||||
public void setAvatarUrl(URL avatarUrl)
|
|
||||||
{
|
|
||||||
this.avatarUrl = avatarUrl;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
||||||
* FLOSS exception. You should have received a copy of the text describing
|
|
||||||
* the FLOSS exception, and it is also available here:
|
|
||||||
* http://www.alfresco.com/legal/licensing"
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.person;
|
|
||||||
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Person model constants
|
|
||||||
*
|
|
||||||
* @author Glen Johnson
|
|
||||||
*/
|
|
||||||
public interface PersonModel
|
|
||||||
{
|
|
||||||
// Person Model
|
|
||||||
public static final String PERSON_MODEL_URL = "http://www.alfresco.org/model/person/1.0";
|
|
||||||
public static final String PERSON_MODEL_PREFIX = "pers";
|
|
||||||
|
|
||||||
// Person
|
|
||||||
public static final QName TYPE_PERSON = QName.createQName(PERSON_MODEL_URL, "person");
|
|
||||||
public static final QName PROP_PERSON_USER_NAME = QName.createQName(PERSON_MODEL_URL, "personUserName");
|
|
||||||
public static final QName PROP_PERSON_TITLE = QName.createQName(PERSON_MODEL_URL, "personTitle");
|
|
||||||
public static final QName PROP_PERSON_FIRST_NAME = QName.createQName(PERSON_MODEL_URL, "personFirstName");
|
|
||||||
public static final QName PROP_PERSON_LAST_NAME = QName.createQName(PERSON_MODEL_URL, "personLastName");
|
|
||||||
public static final QName PROP_PERSON_ORGANISATION = QName.createQName(PERSON_MODEL_URL, "personOrganisation");
|
|
||||||
public static final QName PROP_PERSON_JOB_TITLE = QName.createQName(PERSON_MODEL_URL, "personJobTitle");
|
|
||||||
public static final QName PROP_PERSON_EMAIL = QName.createQName(PERSON_MODEL_URL, "personEmail");
|
|
||||||
public static final QName PROP_PERSON_BIO = QName.createQName(PERSON_MODEL_URL, "personBio");
|
|
||||||
public static final QName PROP_PERSON_AVATAR_URL = QName.createQName(PERSON_MODEL_URL, "personAvatarUrl");
|
|
||||||
// TODO glen.johnson@alfresco.com add something here for person filter preset
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
package org.alfresco.repo.person;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Person service API.
|
|
||||||
* <p>
|
|
||||||
* This service API is designed to support the public facing Person API
|
|
||||||
*
|
|
||||||
* @author Glen Johnson
|
|
||||||
*/
|
|
||||||
public interface PersonService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Create a new person.
|
|
||||||
*
|
|
||||||
* @param userName unique identifier for person
|
|
||||||
* @param title person's title
|
|
||||||
* @param firstName person's first name
|
|
||||||
* @param lastName person's last name
|
|
||||||
* @param organisation organisation to whom the person belongs
|
|
||||||
* @param jobTitle person's job title
|
|
||||||
* @param emailAddress person's email address
|
|
||||||
* @param bio person's biography
|
|
||||||
* @param avatarUrl person's avatar URL
|
|
||||||
*/
|
|
||||||
PersonDetails createPerson(String userName, String title, String firstName, String lastName,
|
|
||||||
String organisation, String jobTitle, String emailAddress, String bio, URL avatarUrl);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List the available people. This list can optionally be filtered by User Name and/or preset person filter name.
|
|
||||||
*
|
|
||||||
* @param userNameFilter user name filter
|
|
||||||
* @param personPresetFilter person preset filter
|
|
||||||
* @return List<PersonDetails> list of people
|
|
||||||
*/
|
|
||||||
List<PersonDetails> listPeople(String userNameFilter, String personPresetFilter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets person's details based on User Name.
|
|
||||||
* <p>
|
|
||||||
* Returns null if the User Name cannot be found.
|
|
||||||
*
|
|
||||||
* @param userName the person's User Name
|
|
||||||
* @return details the person's details
|
|
||||||
*/
|
|
||||||
PersonDetails getPerson(String userName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a person's details
|
|
||||||
* <P>
|
|
||||||
* Note that the User Name cannot be updated once the person has been created.
|
|
||||||
*
|
|
||||||
* @param details person's details
|
|
||||||
*/
|
|
||||||
void updatePerson(PersonDetails personDetails);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the person.
|
|
||||||
*
|
|
||||||
* @param userName person's User Name
|
|
||||||
*/
|
|
||||||
void deletePerson(String userName);
|
|
||||||
}
|
|
@@ -1,223 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
|
||||||
* the FLOSS exception, and it is also available here:
|
|
||||||
* http://www.alfresco.com/legal/licensing"
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.person;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.util.ISO9075;
|
|
||||||
import org.alfresco.util.PropertyMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides the implementation for the Person Service
|
|
||||||
*
|
|
||||||
* @author Glen Johnson
|
|
||||||
*/
|
|
||||||
public class PersonServiceImpl implements PersonService
|
|
||||||
{
|
|
||||||
private NodeService nodeService;
|
|
||||||
private SearchService searchService;
|
|
||||||
|
|
||||||
// Random number generator to create random number for User Name
|
|
||||||
private static final Random RANDOMIZER = new Random();
|
|
||||||
|
|
||||||
// Max number for User Name
|
|
||||||
private static final int MAX_USER_NAME_INT = 999999;
|
|
||||||
private static final int USER_NAME_LENGTH = new Integer(MAX_USER_NAME_INT).toString().length();
|
|
||||||
|
|
||||||
public static final StoreRef PERSON_DM_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "PersonStore");
|
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
|
||||||
{
|
|
||||||
this.nodeService = nodeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSearchService(SearchService searchService)
|
|
||||||
{
|
|
||||||
this.searchService = searchService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PersonDetails createPerson(String userName, String title, String firstName, String lastName,
|
|
||||||
String organisation, String jobTitle, String emailAddress, String bio, URL avatarUrl)
|
|
||||||
{
|
|
||||||
// If User Name not specified then create User Name from random integer between 0 and 999999
|
|
||||||
if (userName == null)
|
|
||||||
{
|
|
||||||
userName = new Integer(RANDOMIZER.nextInt(MAX_USER_NAME_INT + 1)).toString();
|
|
||||||
for (int i=userName.length(); i < USER_NAME_LENGTH; i++)
|
|
||||||
{
|
|
||||||
userName = "0" + userName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO glen.johnson@alfresco.com Check that User Name does not already exist
|
|
||||||
|
|
||||||
// TODO glen.johnson@alfresco.com set value for personParent node reference
|
|
||||||
NodeRef personParent = null;
|
|
||||||
|
|
||||||
// TODO glen.johnson@alfresco.com generate password and create account per person
|
|
||||||
|
|
||||||
// Create the person node
|
|
||||||
PropertyMap properties = new PropertyMap(9);
|
|
||||||
properties.put(ContentModel.PROP_NAME, userName);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_TITLE, title);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_FIRST_NAME, firstName);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_LAST_NAME, lastName);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_ORGANISATION, organisation);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_JOB_TITLE, jobTitle);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_EMAIL, emailAddress);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_BIO, bio);
|
|
||||||
properties.put(PersonModel.PROP_PERSON_AVATAR_URL, avatarUrl);
|
|
||||||
NodeRef personNodeRef = this.nodeService.createNode(
|
|
||||||
personParent,
|
|
||||||
ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, userName),
|
|
||||||
PersonModel.TYPE_PERSON,
|
|
||||||
properties).getChildRef();
|
|
||||||
|
|
||||||
// Return created person details
|
|
||||||
PersonDetails personDetails = new PersonDetails(userName, title, firstName, lastName, organisation,
|
|
||||||
jobTitle, emailAddress, bio, avatarUrl);
|
|
||||||
return personDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PersonDetails> listPeople(String userNameFilter, String personPresetFilter)
|
|
||||||
{
|
|
||||||
// TODO glen.johnson@alfresco.com Look into how to do this and implement this method
|
|
||||||
List<PersonDetails> people = new ArrayList<PersonDetails>();
|
|
||||||
return people;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PersonDetails createPersonDetails(NodeRef personNodeRef)
|
|
||||||
{
|
|
||||||
// Get the properties
|
|
||||||
Map<QName, Serializable> properties = this.nodeService.getProperties(personNodeRef);
|
|
||||||
String userName = (String)properties.get(ContentModel.PROP_NAME);
|
|
||||||
String title = (String)properties.get(PersonModel.PROP_PERSON_TITLE);
|
|
||||||
String firstName = (String)properties.get(PersonModel.PROP_PERSON_FIRST_NAME);
|
|
||||||
String lastName = (String)properties.get(PersonModel.PROP_PERSON_LAST_NAME);
|
|
||||||
String organisation = (String)properties.get(PersonModel.PROP_PERSON_ORGANISATION);
|
|
||||||
String jobTitle = (String)properties.get(PersonModel.PROP_PERSON_JOB_TITLE);
|
|
||||||
String emailAddress = (String)properties.get(PersonModel.PROP_PERSON_EMAIL);
|
|
||||||
String bio = (String)properties.get(PersonModel.PROP_PERSON_BIO);
|
|
||||||
URL avatarUrl;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
avatarUrl = new URL((String)properties.get(PersonModel.PROP_PERSON_AVATAR_URL));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
// TODO glen.johnson@alfresco.com Throw this exception with properly defined msg ID
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("MALFORMED_PERSON_AVATAR_URL", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and return the person details
|
|
||||||
PersonDetails personDetails = new PersonDetails(userName, title, firstName, lastName, organisation,
|
|
||||||
jobTitle, emailAddress, bio, avatarUrl);
|
|
||||||
return personDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.repo.person.PersonService#getPerson(java.lang.String)
|
|
||||||
*/
|
|
||||||
public PersonDetails getPerson(String userName)
|
|
||||||
{
|
|
||||||
PersonDetails result = null;
|
|
||||||
|
|
||||||
// Get the person node
|
|
||||||
NodeRef personNodeRef = getPersonNodeRef(userName);
|
|
||||||
if (personNodeRef != null)
|
|
||||||
{
|
|
||||||
// Create the person details
|
|
||||||
result = createPersonDetails(personNodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the person details
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeRef getPersonNodeRef(String userName)
|
|
||||||
{
|
|
||||||
NodeRef result = null;
|
|
||||||
ResultSet resultSet = this.searchService.query(
|
|
||||||
PERSON_DM_STORE, SearchService.LANGUAGE_LUCENE, "PATH:\"cm:people/cm:" + ISO9075.encode(userName) + "\"");
|
|
||||||
if (resultSet.length() == 1)
|
|
||||||
{
|
|
||||||
result = resultSet.getNodeRef(0);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updatePerson(PersonDetails personDetails)
|
|
||||||
{
|
|
||||||
NodeRef personNodeRef = getPersonNodeRef(personDetails.getUserName());
|
|
||||||
if (personNodeRef == null)
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Can not update person " + personDetails.getUserName() + " because he/she does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: the user name cannot be updated
|
|
||||||
|
|
||||||
// Update the properties of the person
|
|
||||||
Map<QName, Serializable> properties = this.nodeService.getProperties(personNodeRef);
|
|
||||||
properties.put(ContentModel.PROP_NAME, personDetails.getUserName());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_TITLE, personDetails.getTitle());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_FIRST_NAME, personDetails.getFirstName());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_LAST_NAME, personDetails.getLastName());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_ORGANISATION, personDetails.getOrganisation());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_JOB_TITLE, personDetails.getJobTitle());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_EMAIL, personDetails.getEmailAddress());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_BIO, personDetails.getBio());
|
|
||||||
properties.put(PersonModel.PROP_PERSON_AVATAR_URL, personDetails.getAvatarUrl());
|
|
||||||
this.nodeService.setProperties(personNodeRef, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.alfresco.repo.person.PersonService#deletePerson(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void deletePerson(String userName)
|
|
||||||
{
|
|
||||||
NodeRef personNodeRef = getPersonNodeRef(userName);
|
|
||||||
if (personNodeRef == null)
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Can not delete person with User Name: " + userName + " because he/she does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.nodeService.deleteNode(personNodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user