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="rootContainerCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||||
|
|
||||||
|
<bean id="rootRecordsManagementCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||||
|
|
||||||
<bean id="filePlanService"
|
<bean id="filePlanService"
|
||||||
parent="baseService"
|
parent="baseService"
|
||||||
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
|
||||||
<property name="rootContainerCache" ref="rootContainerCache" />
|
<property name="rootContainerCache" ref="rootContainerCache" />
|
||||||
|
<property name="rootRecordsManagementCache" ref="rootRecordsManagementCache" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="FilePlanService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
|
@@ -89,6 +89,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
/** root container cache */
|
/** root container cache */
|
||||||
private SimpleCache<Pair<NodeRef, String>, NodeRef> rootContainerCache;
|
private SimpleCache<Pair<NodeRef, String>, NodeRef> rootContainerCache;
|
||||||
|
|
||||||
|
/** root records management cache */
|
||||||
|
private SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> rootRecordsManagementCache;
|
||||||
|
|
||||||
/** File plan role service */
|
/** File plan role service */
|
||||||
private FilePlanRoleService filePlanRoleService;
|
private FilePlanRoleService filePlanRoleService;
|
||||||
|
|
||||||
@@ -174,6 +177,14 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
this.rootContainerCache = rootContainerCache;
|
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)
|
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef)
|
||||||
*/
|
*/
|
||||||
@@ -185,6 +196,11 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
final Set<NodeRef> results = new HashSet<>();
|
final Set<NodeRef> results = new HashSet<>();
|
||||||
Set<QName> aspects = new HashSet<>(1);
|
Set<QName> aspects = new HashSet<>(1);
|
||||||
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT);
|
||||||
|
|
||||||
|
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()
|
getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -199,6 +215,17 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (results.size() > 0)
|
||||||
|
{
|
||||||
|
rootRecordsManagementCache.put(key, results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return rootRecordsManagementCache.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user