Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

91561: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud)
      91503: Fix for MNT-12875 - Tags list in Repository view does not work when overridden repository root node using xpath syntax is used.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 11:33:50 +00:00
parent 36ec97b170
commit af849d4521
5 changed files with 199 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2013 Alfresco Software Limited.
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -64,10 +64,12 @@ public class Repository implements ApplicationContextAware
// company home
private StoreRef companyHomeStore; // ie. workspace://SpaceStore
private String companyHomePath; // ie. /app:company_home
private String sharedHomePath; // ie. /app:shared
// note: cache is tenant-aware (if using EhCacheAdapter shared cache)
private SimpleCache<String, NodeRef> singletonCache; // eg. for companyHomeNodeRef
private final String KEY_COMPANYHOME_NODEREF = "key.companyhome.noderef";
private final String KEY_SHAREDHOME_NODEREF = "key.sharedhome.noderef";
/**
@@ -90,6 +92,16 @@ public class Repository implements ApplicationContextAware
this.companyHomePath = companyHomePath;
}
/**
* Sets the Shared Home Path
*
* @param sharedHomePath
*/
public void setSharedHomePath(String sharedHomePath)
{
this.sharedHomePath = sharedHomePath;
}
public void setSingletonCache(SimpleCache<String, NodeRef> singletonCache)
{
this.singletonCache = singletonCache;
@@ -212,17 +224,51 @@ public class Repository implements ApplicationContextAware
if (refs.size() != 1)
{
throw new IllegalStateException("Invalid company home path: " + companyHomePath + " - found: " + refs.size());
}
return refs.get(0);
}
}, true);
}
}, AuthenticationUtil.getSystemUserName());
return refs.get(0);
}
}, true);
}
}, AuthenticationUtil.getSystemUserName());
singletonCache.put(KEY_COMPANYHOME_NODEREF, companyHomeRef);
}
return companyHomeRef;
}
/**
* Gets the Shared Home. Note this is tenant-aware if the correct Cache is supplied.
*
* @return shared home node ref
*/
public NodeRef getSharedHome()
{
NodeRef sharedHomeRef = singletonCache.get(KEY_SHAREDHOME_NODEREF);
if (sharedHomeRef == null)
{
sharedHomeRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Exception
{
List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(companyHomeStore), sharedHomePath, null, namespaceService, false);
if (refs.size() != 1)
{
throw new IllegalStateException("Invalid shared home path: " + sharedHomePath + " - found: " + refs.size());
}
return refs.get(0);
}
}, true);
}
}, AuthenticationUtil.getSystemUserName());
singletonCache.put(KEY_SHAREDHOME_NODEREF, sharedHomeRef);
}
return sharedHomeRef;
}
/**
* Gets the currently authenticated person