From 42a2cd165ad03a24d07cdf6eeb64d37a38e8ff68 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Sat, 18 Feb 2006 10:54:09 +0000 Subject: [PATCH] Beefed up javadocs around automatic person creation Added specialized PersonException for when the user could not be automatically created git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2439 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/person/PersonServiceImpl.java | 3 +- .../cmr/security/NoSuchPersonException.java | 42 +++++++++++++++++++ .../service/cmr/security/PersonService.java | 17 +++++--- 3 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 source/java/org/alfresco/service/cmr/security/NoSuchPersonException.java diff --git a/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java b/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java index 84e57ed845..0c3a147262 100644 --- a/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java +++ b/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java @@ -37,6 +37,7 @@ import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.NoSuchPersonException; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespacePrefixResolver; import org.alfresco.service.namespace.QName; @@ -111,7 +112,7 @@ public class PersonServiceImpl implements PersonService } else { - throw new PersonException("No person found for user name " + userName); + throw new NoSuchPersonException(userName); } } diff --git a/source/java/org/alfresco/service/cmr/security/NoSuchPersonException.java b/source/java/org/alfresco/service/cmr/security/NoSuchPersonException.java new file mode 100644 index 0000000000..4efa85dddf --- /dev/null +++ b/source/java/org/alfresco/service/cmr/security/NoSuchPersonException.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.service.cmr.security; + +import org.alfresco.repo.security.person.PersonException; + +/** + * Thrown when a person doesn't exist and can't be created. + * + * @author Derek Hulley + */ +public class NoSuchPersonException extends PersonException +{ + private static final long serialVersionUID = -8514361120995433997L; + + private final String userName; + + public NoSuchPersonException(String userName) + { + super(String.format("User does not exist and could not be created: %s", userName)); + this.userName = userName; + } + + public String getUserName() + { + return userName; + } +} diff --git a/source/java/org/alfresco/service/cmr/security/PersonService.java b/source/java/org/alfresco/service/cmr/security/PersonService.java index a029fad416..b41d39623d 100644 --- a/source/java/org/alfresco/service/cmr/security/PersonService.java +++ b/source/java/org/alfresco/service/cmr/security/PersonService.java @@ -39,18 +39,23 @@ public interface PersonService { /** * Get a person by userName. The person is store in the repository. The - * person may be created as a side effect of this call. + * person may be created as a side effect of this call, depending on + * the setting to {@link #setCreateMissingPeople(boolean) create missing people or not}. * * @param userName - the userName key to find the person - * @return + * @return Returns the person node, either existing or new + * @throws NoSuchPersonException if the user doesn't exist and could not be created automatically + * + * @see #setCreateMissingPeople(boolean) + * @see #createMissingPeople() */ public NodeRef getPerson(String userName); /** * Check if a person exists. * - * @param userName - * @return + * @param userName the user name + * @return Returns true if the user exists, otherwise false */ public boolean personExists(String userName); @@ -65,7 +70,9 @@ public interface PersonService /** * Set if missing people should be created. * - * @param createMissing + * @param createMissing set to true to create people + * + * @see #getPerson(String) */ public void setCreateMissingPeople(boolean createMissing);