[MNT-21818] applied code formatter

This commit is contained in:
tiagos
2020-09-15 17:17:10 +01:00
parent c4e8addf5d
commit 276fa8f868

View File

@@ -45,14 +45,15 @@ import org.alfresco.util.Pair;
*/ */
public class RMContainerCacheManager implements RecordsManagementModel public class RMContainerCacheManager implements RecordsManagementModel
{ {
/** node service */ /** node service */
private NodeService nodeService; private NodeService nodeService;
/** root records management cache */ /** root records management cache */
private SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> cache; private SimpleCache<Pair<StoreRef, String>, Set<NodeRef>> cache;
/** /**
* @param nodeService node service * @param nodeService
* node service
*/ */
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
@@ -67,91 +68,91 @@ public class RMContainerCacheManager implements RecordsManagementModel
this.cache = cache; this.cache = cache;
} }
/** /**
* Verifies if there is cached nodes for supplied storeRef * Verifies if there is cached nodes for supplied storeRef
* @param storeRef *
* @return true if there are cached nodes, false otherwise * @param storeRef
*/ * @return true if there are cached nodes, false otherwise
public boolean isCached(StoreRef storeRef) */
{ public boolean isCached(StoreRef storeRef)
Pair<StoreRef, String> key = new Pair<StoreRef, String>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); {
return cache.contains(key); return cache.contains(getKey(storeRef));
} }
/** /**
* Obtains the cached nodes for supplied storeRef * Obtains the cached nodes for supplied storeRef
* *
* @param storeRef * @param storeRef
* @return a set containing the cached nodes * @return a set containing the cached nodes
*/ */
public Set<NodeRef> get(StoreRef storeRef) public Set<NodeRef> get(StoreRef storeRef)
{ {
return cache.get(getKey(storeRef)); return cache.get(getKey(storeRef));
} }
/** /**
* Caches the supplied node * Caches the supplied node
* *
* @param nodeRef * @param nodeRef
*/ */
public void add(NodeRef nodeRef) public void add(NodeRef nodeRef)
{ {
if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT))
{ {
Set<NodeRef> entries; Set<NodeRef> entries;
Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef()); Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef());
if (cache.contains(key)) if (cache.contains(key))
{ {
entries = this.cache.get(key); entries = this.cache.get(key);
} }
else else
{ {
entries = new HashSet<>(); entries = new HashSet<>();
} }
if (!entries.contains(nodeRef)) if (!entries.contains(nodeRef))
{ {
entries.add(nodeRef); entries.add(nodeRef);
} }
cache.put(key, entries); cache.put(key, entries);
} }
} }
/** /**
* Removes the supplied entry from the cache * Removes the supplied entry from the cache
* *
* @param nodeRef * @param nodeRef
*/ */
public void remove(NodeRef nodeRef) public void remove(NodeRef nodeRef)
{ {
if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT))
{ {
Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef()); Pair<StoreRef, String> key = getKey(nodeRef.getStoreRef());
if (cache.contains(key)) if (cache.contains(key))
{ {
cache.get(key).remove(nodeRef); cache.get(key).remove(nodeRef);
} }
} }
} }
/** /**
* Resets the cache entries * Resets the cache entries
*/ */
public void reset() public void reset()
{ {
this.cache.clear(); this.cache.clear();
} }
/** /**
* Builds the cache key using the supplied storeRef * Builds the cache key using the supplied storeRef
* *
* @param storeRef * @param storeRef
* @return a pair corresponding to the cache key * @return a pair corresponding to the cache key
*/ */
private Pair<StoreRef, String> getKey(StoreRef storeRef) private Pair<StoreRef, String> getKey(StoreRef storeRef)
{ {
return new Pair<StoreRef, String>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); return new Pair<StoreRef, String>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString());
} }
} }