From 5b098b6f10ff497777894c4c9cc9a4db14a39a66 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 12 Mar 2009 11:37:15 +0000 Subject: [PATCH] Merged V3.1 to HEAD 13270: Additional items from CHK-6464 as pointed out by Will. 13271: SiteService Build fix. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13592 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/site/SiteServiceImpl.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java index 5ceec79edc..fd6e1321ff 100644 --- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java +++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java @@ -770,18 +770,28 @@ public class SiteServiceImpl implements SiteService, SiteModel { final String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName; NodeRef siteNodeRef = this.siteNodeRefs.get(cacheKey); - if (siteNodeRef == null) + if (siteNodeRef != null) { - NodeRef siteRoot = getSiteParent(shortName); - - // the site "short name" directly maps to the cm:name property - siteNodeRef = this.nodeService.getChildByName(siteRoot, ContentModel.ASSOC_CONTAINS, shortName); - - // cache the result if found - null results will be requeried to ensure new sites are found later - if (siteNodeRef != null) - { - this.siteNodeRefs.put(cacheKey, siteNodeRef); - } + // test for existance - and remove from cache if no longer exists + if (!this.nodeService.exists(siteNodeRef)) + { + this.siteNodeRefs.remove(cacheKey); + siteNodeRef = null; + } + } + else + { + // not in cache - find and store + NodeRef siteRoot = getSiteParent(shortName); + + // the site "short name" directly maps to the cm:name property + siteNodeRef = this.nodeService.getChildByName(siteRoot, ContentModel.ASSOC_CONTAINS, shortName); + + // cache the result if found - null results will be requeried to ensure new sites are found later + if (siteNodeRef != null) + { + this.siteNodeRefs.put(cacheKey, siteNodeRef); + } } return siteNodeRef; }