From e2626e2cb334da47eb061ef4c3f5130f5554b47f Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Wed, 14 Oct 2009 09:55:04 +0000 Subject: [PATCH] Merged V3.2 to HEAD 16700: Fix for ETHREEOH-2509 - Leaving a private site breaks All Sites search for any term found in documents user created in that site. 16703: Fix for ETHREEOH-2775 - "Show all" fails for user if permissions of folder that item was deleted from are changed to exclude them. 16705: Fixes to Site Links dashlet component. 16707: Fixed ETHREEOH-619 "User who is already a member of the site (or invite is pending) can be added to the invite list" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16899 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/site/SiteServiceImpl.java | 79 ++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java index fc6406b70f..8a2fb129df 100644 --- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java +++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java @@ -322,20 +322,13 @@ public class SiteServiceImpl implements SiteService, SiteModel /** * Check that the site does not already exist */ - AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() - { - public String doWork() throws Exception - { - // Check to see if we already have a site of this name - NodeRef existingSite = getSiteNodeRef(shortName); - if (existingSite != null) - { - // Throw an exception since we have a duplicate site name - throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName}); - } - return null; - } - }, AuthenticationUtil.getSystemUserName()); + // Check to see if we already have a site of this name + NodeRef existingSite = getSiteNodeRef(shortName); + if (existingSite != null) + { + // Throw an exception since we have a duplicate site name + throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName}); + } // Get the site parent node reference NodeRef siteParent = getSiteParent(shortName); @@ -375,7 +368,6 @@ public class SiteServiceImpl implements SiteService, SiteModel shareZones.add(AuthorityService.ZONE_APP_SHARE); shareZones.add(AuthorityService.ZONE_AUTH_ALFRESCO); - // Create the site's groups String siteGroup = authorityService .createAuthority(AuthorityType.GROUP, getSiteGroup(shortName, false), shortName, shareZones); @@ -513,7 +505,7 @@ public class SiteServiceImpl implements SiteService, SiteModel } /** - * Gets a sites parent folder based on it's short name ] + * Gets a sites parent folder based on it's short name * * @param shortName site short name * @return NodeRef the site's parent @@ -739,19 +731,25 @@ public class SiteServiceImpl implements SiteService, SiteModel */ private SiteInfo createSiteInfo(NodeRef siteNodeRef) { - // Get the properties - Map properties = this.nodeService.getProperties(siteNodeRef); - String shortName = (String) properties.get(ContentModel.PROP_NAME); - String sitePreset = (String) properties.get(PROP_SITE_PRESET); - String title = (String) properties.get(ContentModel.PROP_TITLE); - String description = (String) properties.get(ContentModel.PROP_DESCRIPTION); - - // Get the visibility of the site - SiteVisibility visibility = getSiteVisibility(siteNodeRef); + SiteInfo siteInfo = null; + + if (this.permissionService.hasPermission(siteNodeRef, PermissionService.READ_PROPERTIES).equals(AccessStatus.ALLOWED)) + { + // Get the properties + Map properties = this.nodeService.getProperties(siteNodeRef); + String shortName = (String) properties.get(ContentModel.PROP_NAME); + String sitePreset = (String) properties.get(PROP_SITE_PRESET); + String title = (String) properties.get(ContentModel.PROP_TITLE); + String description = (String) properties.get(ContentModel.PROP_DESCRIPTION); + + // Get the visibility of the site + SiteVisibility visibility = getSiteVisibility(siteNodeRef); + + // Create and return the site information + Map customProperties = getSiteCustomProperties(properties); + siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef); + } - // Create and return the site information - Map customProperties = getSiteCustomProperties(properties); - SiteInfo siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef); return siteInfo; } @@ -843,7 +841,7 @@ public class SiteServiceImpl implements SiteService, SiteModel * * @return NodeRef node reference */ - private NodeRef getSiteNodeRef(String shortName) + private NodeRef getSiteNodeRef(final String shortName) { final String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName; NodeRef siteNodeRef = this.siteNodeRefs.get(cacheKey); @@ -859,16 +857,23 @@ public class SiteServiceImpl implements SiteService, SiteModel else { // not in cache - find and store - NodeRef siteRoot = getSiteParent(shortName); + final 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) + siteNodeRef = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { - this.siteNodeRefs.put(cacheKey, siteNodeRef); - } + public NodeRef doWork() throws Exception + { + // the site "short name" directly maps to the cm:name property + NodeRef siteNodeRef = nodeService.getChildByName(siteRoot, ContentModel.ASSOC_CONTAINS, shortName); + + // cache the result if found - null results will be required to ensure new sites are found later + if (siteNodeRef != null) + { + siteNodeRefs.put(cacheKey, siteNodeRef); + } + return siteNodeRef; + } + }, AuthenticationUtil.getSystemUserName()); } return siteNodeRef; }