Fixed NPE when using guest user in webscripts (ALF-10841)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31262 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-10-17 09:30:24 +00:00
parent a14c0107da
commit 3615b03a74

View File

@@ -44,7 +44,6 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeansException;
@@ -52,7 +51,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
/**
* Provision of Repository Context
@@ -280,26 +279,33 @@ public class Repository implements ApplicationContextAware, ApplicationListener,
public NodeRef getUserHome(NodeRef person)
{
NodeRef homeFolderRef = (NodeRef)nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER);
return nodeService.exists(homeFolderRef) ? homeFolderRef : null;
if (homeFolderRef != null && nodeService.exists(homeFolderRef))
{
return homeFolderRef;
}
else
{
return null;
}
}
/**
* Helper to convert a Web Script Request URL to a Node Ref
*
* <p/>
* 1) Node - {store_type}/{store_id}/{node_id}
*
* <br/>
* Resolve to node via its Node Reference.
*
* <br/>
* 2) Path - {store_type}/{store_id}/{path}
*
* <br/>
* Resolve to node via its display path.
*
* <br/>
* 3) AVM Path - {store_id}/{path}
*
* <br/>
* Resolve to AVM node via its display path
*
* <br/>
* 4) QName - {store_type}/{store_id}/{child_qname_path} TODO: Implement
*
* <br/>
* Resolve to node via its child qname path.
*
* @param referenceType one of node, path, avmpath or qname