mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.1 to HEAD
13262: Additional SiteService scaling improvements to all methods that get individual site noderefs. 13263: Missing from CHK-6460 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13581 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -100,6 +100,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
|||||||
/** Site home ref cache (Tennant aware) */
|
/** Site home ref cache (Tennant aware) */
|
||||||
private Map<String, NodeRef> siteHomeRefs = new ConcurrentHashMap<String, NodeRef>(4);
|
private Map<String, NodeRef> siteHomeRefs = new ConcurrentHashMap<String, NodeRef>(4);
|
||||||
|
|
||||||
|
/** Site node ref cache (Tennant aware) */
|
||||||
|
private Map<String, NodeRef> siteNodeRefs = new ConcurrentHashMap<String, NodeRef>(256);
|
||||||
|
|
||||||
private String sitesXPath;
|
private String sitesXPath;
|
||||||
|
|
||||||
/** Messages */
|
/** Messages */
|
||||||
@@ -493,8 +496,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
|||||||
*/
|
*/
|
||||||
private NodeRef getSiteParent(String shortName)
|
private NodeRef getSiteParent(String shortName)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO: For now just return the site root, later we may build folder
|
||||||
// For now just return the site root, later we may build folder
|
|
||||||
// structure based on the shortname to spread the sites about
|
// structure based on the shortname to spread the sites about
|
||||||
return getSiteRoot();
|
return getSiteRoot();
|
||||||
}
|
}
|
||||||
@@ -760,22 +762,28 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
|||||||
/**
|
/**
|
||||||
* Gets the site's node reference based on its short name
|
* Gets the site's node reference based on its short name
|
||||||
*
|
*
|
||||||
* @param shortName
|
* @param shortName short name
|
||||||
* short name
|
*
|
||||||
* @return NodeRef node reference
|
* @return NodeRef node reference
|
||||||
*/
|
*/
|
||||||
private NodeRef getSiteNodeRef(String shortName)
|
private NodeRef getSiteNodeRef(String shortName)
|
||||||
{
|
{
|
||||||
NodeRef result = null;
|
final String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName;
|
||||||
NodeRef siteRoot = getSiteParent(shortName);
|
NodeRef siteNodeRef = this.siteNodeRefs.get(cacheKey);
|
||||||
List<ChildAssociationRef> assoc = this.nodeService.getChildAssocs(
|
if (siteNodeRef == null)
|
||||||
siteRoot, ContentModel.ASSOC_CONTAINS, QName.createQName(
|
|
||||||
NamespaceService.CONTENT_MODEL_1_0_URI, shortName));
|
|
||||||
if (assoc.size() == 1)
|
|
||||||
{
|
{
|
||||||
result = assoc.get(0).getChildRef();
|
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 result;
|
}
|
||||||
|
return siteNodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -793,7 +801,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
|||||||
Map<QName, Serializable> properties = this.nodeService.getProperties(siteNodeRef);
|
Map<QName, Serializable> properties = this.nodeService.getProperties(siteNodeRef);
|
||||||
|
|
||||||
// Update the properties of the site
|
// Update the properties of the site
|
||||||
// Note: the site preset and short name can not be updated
|
// Note: the site preset and short name should never be updated!
|
||||||
properties.put(ContentModel.PROP_TITLE, siteInfo.getTitle());
|
properties.put(ContentModel.PROP_TITLE, siteInfo.getTitle());
|
||||||
properties.put(ContentModel.PROP_DESCRIPTION, siteInfo.getDescription());
|
properties.put(ContentModel.PROP_DESCRIPTION, siteInfo.getDescription());
|
||||||
|
|
||||||
@@ -843,6 +851,10 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
|||||||
throw new SiteServiceException(MSG_CAN_NOT_DELETE, new Object[]{shortName});
|
throw new SiteServiceException(MSG_CAN_NOT_DELETE, new Object[]{shortName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete the cached reference
|
||||||
|
String cacheKey = this.tenantAdminService.getCurrentUserDomain() + '_' + shortName;
|
||||||
|
this.siteNodeRefs.remove(cacheKey);
|
||||||
|
|
||||||
// Delete the node
|
// Delete the node
|
||||||
this.nodeService.deleteNode(siteNodeRef);
|
this.nodeService.deleteNode(siteNodeRef);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user