mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge pull request #1217 from Alfresco/hotfix-3.2/MNT-21818
[MNT-21818] Added cache to records management root, preventing the query from being executed multiple times
This commit is contained in:
@@ -393,10 +393,13 @@
|
||||
|
||||
<bean id="rootContainerCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||
|
||||
<bean id="rootRecordsManagementCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||
|
||||
<bean id="filePlanService"
|
||||
parent="baseService"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
||||
<property name="rootContainerCache" ref="rootContainerCache" />
|
||||
<property name="rootRecordsManagementCache" ref="rootRecordsManagementCache" />
|
||||
</bean>
|
||||
|
||||
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
|
@@ -89,6 +89,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
/** root container cache */
|
||||
private SimpleCache<Pair<NodeRef, String>, NodeRef> rootContainerCache;
|
||||
|
||||
/** root records management cache */
|
||||
private SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> rootRecordsManagementCache;
|
||||
|
||||
/** File plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
@@ -174,6 +177,14 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
this.rootContainerCache = rootContainerCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootRecordsManagementCache root records management node cache
|
||||
*/
|
||||
public void setRootRecordsManagementCache(SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> rootRecordsManagementCache)
|
||||
{
|
||||
this.rootRecordsManagementCache = rootRecordsManagementCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef)
|
||||
*/
|
||||
@@ -185,20 +196,36 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
final Set<NodeRef> results = new HashSet<>();
|
||||
Set<QName> aspects = new HashSet<>(1);
|
||||
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
||||
getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
||||
{
|
||||
@Override
|
||||
public boolean handle(Pair<Long, NodeRef> nodePair)
|
||||
{
|
||||
NodeRef nodeRef = nodePair.getSecond();
|
||||
if (storeRef.equals(nodeRef.getStoreRef()))
|
||||
{
|
||||
results.add(nodeRef);
|
||||
}
|
||||
|
||||
return true;
|
||||
Pair<StoreRef, String> key = new Pair<StoreRef, String>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString());
|
||||
|
||||
if (!rootRecordsManagementCache.contains(key))
|
||||
{
|
||||
getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
||||
{
|
||||
@Override
|
||||
public boolean handle(Pair<Long, NodeRef> nodePair)
|
||||
{
|
||||
NodeRef nodeRef = nodePair.getSecond();
|
||||
if (storeRef.equals(nodeRef.getStoreRef()))
|
||||
{
|
||||
results.add(nodeRef);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (results.size() > 0)
|
||||
{
|
||||
rootRecordsManagementCache.put(key, results);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return rootRecordsManagementCache.get(key);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user