ALF-1973 Handle the case of a discussion post having been created by a user who has subsequently been deleted

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31294 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-10-17 17:06:23 +00:00
parent 483acdc46e
commit 2766c57708
2 changed files with 18 additions and 5 deletions

View File

@@ -3,12 +3,14 @@
<#escape x as jsonUtils.encodeJSONString(x)>
"${fieldName}":
{
<#if person?has_content>
<#if person.assocs["cm:avatar"]??>
"avatarRef": "${person.assocs["cm:avatar"][0].nodeRef?string}",
</#if>
"username": "${person.properties["cm:userName"]}",
"firstName": "${person.properties["cm:firstName"]!""}",
"lastName": "${person.properties["cm:lastName"]!""}"
</#if>
},
</#escape>
</#macro>

View File

@@ -38,6 +38,7 @@ 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.security.AccessStatus;
import org.alfresco.service.cmr.security.NoSuchPersonException;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo;
@@ -272,16 +273,26 @@ public abstract class AbstractDiscussionWebScript extends DeclarativeWebScript
protected Object buildPerson(String username)
{
// Empty string needed if the user can't be found
Object noSuchPersonResponse = "";
if (username == null || username.length() == 0)
{
// Empty string needed
return "";
return noSuchPersonResponse;
}
try
{
// Will turn into a Script Node needed of the person
NodeRef person = personService.getPerson(username);
return person;
}
catch(NoSuchPersonException e)
{
// This is normally caused by the person having been deleted
return noSuchPersonResponse;
}
}
/*
* Was topicpost.lib.js getReplyPostData