From 3615b03a742b9ff9cad505de8b5f2fa297d151a4 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 17 Oct 2011 09:30:24 +0000 Subject: [PATCH] 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 --- .../org/alfresco/repo/model/Repository.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/source/java/org/alfresco/repo/model/Repository.java b/source/java/org/alfresco/repo/model/Repository.java index ca4fdf447c..e827085324 100644 --- a/source/java/org/alfresco/repo/model/Repository.java +++ b/source/java/org/alfresco/repo/model/Repository.java @@ -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 - * + *

* 1) Node - {store_type}/{store_id}/{node_id} - * + *
* Resolve to node via its Node Reference. - * + *
* 2) Path - {store_type}/{store_id}/{path} - * + *
* Resolve to node via its display path. - * + *
* 3) AVM Path - {store_id}/{path} - * + *
* Resolve to AVM node via its display path - * + *
* 4) QName - {store_type}/{store_id}/{child_qname_path} TODO: Implement - * + *
* Resolve to node via its child qname path. * * @param referenceType one of node, path, avmpath or qname