mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2130 (Check classification after method execution, filtering results where appropriate)
+review RM-94 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@107363 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,8 +66,6 @@
|
||||
<bean id="classificationMethodInterceptorPostProcessor"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.classification.interceptor.ClassificationMethodInterceptorPostProcessor" />
|
||||
|
||||
<bean id="basePostMethodInvocationProcessorCache" class="org.alfresco.repo.cache.DefaultSimpleCache" />
|
||||
|
||||
<!-- Classification service DAO -->
|
||||
|
||||
<bean id="classificationServiceDAO" class="org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceDAO">
|
||||
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract Post Method Invocation Processor
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class AbstractPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* Abstract method to process a single element
|
||||
*
|
||||
* @param object The element to process
|
||||
* @return Processed element
|
||||
*/
|
||||
protected abstract <T> T processSingleElement(T object);
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
result = processSingleElement(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
|
||||
|
||||
import static java.lang.reflect.Array.newInstance;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
@@ -52,9 +51,10 @@ public class ArrayPostMethodInvocationProcessor extends BasePostMethodInvocation
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
mandatory("object", object);
|
||||
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
T[] objects = (T[]) result;
|
||||
T obj = objects[0];
|
||||
|
||||
@@ -83,8 +83,8 @@ public class ArrayPostMethodInvocationProcessor extends BasePostMethodInvocation
|
||||
|
||||
result = (T) objs;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 3.0
|
||||
*/
|
||||
@Component
|
||||
public class AssociationRefPostMethodInvocationProcessor extends AbstractPostMethodInvocationProcessor
|
||||
public class AssociationRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
@@ -41,12 +41,16 @@ public class AssociationRefPostMethodInvocationProcessor extends AbstractPostMet
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AbstractPostMethodInvocationProcessor#processSingleElement(java.lang.Object)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected <T> T processSingleElement(T object)
|
||||
public <T> T process(T object)
|
||||
{
|
||||
AssociationRef associationRef = getClassName().cast(object);
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
AssociationRef associationRef = getClassName().cast(result);
|
||||
|
||||
NodeRef sourceRef = associationRef.getSourceRef();
|
||||
NodeRef filteredSource = filter(sourceRef);
|
||||
@@ -54,6 +58,12 @@ public class AssociationRefPostMethodInvocationProcessor extends AbstractPostMet
|
||||
NodeRef targetRef = associationRef.getTargetRef();
|
||||
NodeRef filteredTarget = filter(targetRef);
|
||||
|
||||
return (filteredSource == null || filteredTarget == null) ? null : object;
|
||||
if (filteredSource == null || filteredTarget == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -24,11 +24,9 @@ import javax.annotation.PostConstruct;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -59,10 +57,6 @@ public abstract class BasePostMethodInvocationProcessor
|
||||
@Autowired
|
||||
private PostMethodInvocationProcessor postMethodInvocationProcessor;
|
||||
|
||||
/** Cache to hold the filtered node information */
|
||||
@Autowired
|
||||
private SimpleCache<Pair<String, NodeRef>, Pair<Boolean, NodeRef>> basePostMethodInvocationProcessorCache;
|
||||
|
||||
/**
|
||||
* @return the nodeService
|
||||
*/
|
||||
@@ -103,14 +97,6 @@ public abstract class BasePostMethodInvocationProcessor
|
||||
return this.postMethodInvocationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cache
|
||||
*/
|
||||
protected SimpleCache<Pair<String, NodeRef>, Pair<Boolean, NodeRef>> getCache()
|
||||
{
|
||||
return this.basePostMethodInvocationProcessorCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService the nodeService to set
|
||||
*/
|
||||
@@ -152,11 +138,12 @@ public abstract class BasePostMethodInvocationProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cache the cache to set
|
||||
* Registers the post method invocation processors
|
||||
*/
|
||||
public void setCache(SimpleCache<Pair<String, NodeRef>, Pair<Boolean, NodeRef>> cache)
|
||||
@PostConstruct
|
||||
public void register()
|
||||
{
|
||||
this.basePostMethodInvocationProcessorCache = cache;
|
||||
getPostMethodInvocationProcessor().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,16 +159,7 @@ public abstract class BasePostMethodInvocationProcessor
|
||||
* @param object The object to check
|
||||
* @return The given object
|
||||
*/
|
||||
public abstract <T extends Object> T process(T object);
|
||||
|
||||
/**
|
||||
* Registers the post method invocation processors
|
||||
*/
|
||||
@PostConstruct
|
||||
public void register()
|
||||
{
|
||||
getPostMethodInvocationProcessor().register(this);
|
||||
}
|
||||
protected abstract <T extends Object> T process(T object);
|
||||
|
||||
/**
|
||||
* Filters the node if the give node reference exist and it is a
|
||||
@@ -202,29 +180,6 @@ public abstract class BasePostMethodInvocationProcessor
|
||||
filter = null;
|
||||
}
|
||||
|
||||
// if (filter != null)
|
||||
// {
|
||||
// String uniqueCacheKey = getFullyAuthenticatedUser() /*+ userClearance?*/;
|
||||
//
|
||||
// Pair<String, NodeRef> cacheKey = new Pair<String, NodeRef>(uniqueCacheKey, filter);
|
||||
// Pair<Boolean, NodeRef> cacheValue = getCache().get(cacheKey);
|
||||
//
|
||||
// if (cacheValue == null || !cacheValue.getFirst().booleanValue())
|
||||
// {
|
||||
// if (getNodeService().exists(nodeRef) &&
|
||||
// getDictionaryService().isSubClass(getNodeService().getType(nodeRef), TYPE_CONTENT) &&
|
||||
// !getContentClassificationService().hasClearance(nodeRef))
|
||||
// {
|
||||
// filter = null;
|
||||
// }
|
||||
// getCache().put(new Pair<String, NodeRef>(uniqueCacheKey, nodeRef), new Pair<Boolean, NodeRef>(true, filter));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// filter = getCache().get(cacheKey).getSecond();
|
||||
// }
|
||||
// }
|
||||
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 3.0
|
||||
*/
|
||||
@Component
|
||||
public class ChildAssociationRefPostMethodInvocationProcessor extends AbstractPostMethodInvocationProcessor
|
||||
public class ChildAssociationRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
@@ -41,28 +41,34 @@ public class ChildAssociationRefPostMethodInvocationProcessor extends AbstractPo
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AbstractPostMethodInvocationProcessor#processSingleElement(java.lang.Object)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected <T> T processSingleElement(T object)
|
||||
public <T> T process(T object)
|
||||
{
|
||||
T result;
|
||||
T result = object;
|
||||
|
||||
ChildAssociationRef childAssociationRef = getClassName().cast(object);
|
||||
if (result != null)
|
||||
{
|
||||
ChildAssociationRef childAssociationRef = getClassName().cast(result);
|
||||
|
||||
NodeRef childRef = childAssociationRef.getChildRef();
|
||||
NodeRef filteredChildRef = filter(childRef);
|
||||
|
||||
NodeRef parentRef = childAssociationRef.getParentRef();
|
||||
NodeRef filteredParentRef;
|
||||
if (parentRef == null)
|
||||
if (parentRef == null && filteredChildRef == null)
|
||||
{
|
||||
result = filteredChildRef == null ? null : object;
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
filteredParentRef = filter(parentRef);
|
||||
result = (filteredChildRef == null || filteredParentRef == null) ? null : object;
|
||||
if (filteredChildRef == null || filteredParentRef == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@@ -28,7 +28,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 3.0
|
||||
*/
|
||||
@Component
|
||||
public class NodeRefPostMethodInvocationProcessor extends AbstractPostMethodInvocationProcessor
|
||||
public class NodeRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
@@ -40,12 +40,22 @@ public class NodeRefPostMethodInvocationProcessor extends AbstractPostMethodInvo
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AbstractPostMethodInvocationProcessor#processSingleElement(java.lang.Object)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected <T> T processSingleElement(T object)
|
||||
public <T> T process(T object)
|
||||
{
|
||||
NodeRef nodeRef = getClassName().cast(object);
|
||||
return filter(nodeRef) == null ? null : object;
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
NodeRef nodeRef = getClassName().cast(result);
|
||||
if (filter(nodeRef) == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -50,11 +50,15 @@ public class PagingResultsPostMethodInvocationProcessor extends BasePostMethodIn
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
final PagingResults pagingResults = getClassName().cast(object);
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
final PagingResults pagingResults = getClassName().cast(result);
|
||||
List page = pagingResults.getPage();
|
||||
final List processedPage = getPostMethodInvocationProcessor().process(page);
|
||||
|
||||
return (T) new PagingResults<T>()
|
||||
result = (T) new PagingResults<T>()
|
||||
{
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
@@ -69,7 +73,7 @@ public class PagingResultsPostMethodInvocationProcessor extends BasePostMethodIn
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
// FIXME: hasMoreItems might not be correct
|
||||
// hasMoreItems might not be correct. Cannot determine the correct value as request details are needed.
|
||||
return pagingResults.hasMoreItems();
|
||||
}
|
||||
@Override
|
||||
@@ -80,4 +84,7 @@ public class PagingResultsPostMethodInvocationProcessor extends BasePostMethodIn
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 3.0
|
||||
*/
|
||||
@Component
|
||||
public class PermissionCheckValuePostMethodInvocationProcessor extends AbstractPostMethodInvocationProcessor
|
||||
public class PermissionCheckValuePostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
@@ -41,13 +41,23 @@ public class PermissionCheckValuePostMethodInvocationProcessor extends AbstractP
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AbstractPostMethodInvocationProcessor#processSingleElement(java.lang.Object)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected <T> T processSingleElement(T object)
|
||||
public <T> T process(T object)
|
||||
{
|
||||
PermissionCheckValue permissionCheckValue = getClassName().cast(object);
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
PermissionCheckValue permissionCheckValue = getClassName().cast(result);
|
||||
NodeRef nodeRef = permissionCheckValue.getNodeRef();
|
||||
return filter(nodeRef) == null ? null : object;
|
||||
if (filter(nodeRef) == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,11 @@ public class QueryEngineResultsPostMethodInvocationProcessor extends BasePostMet
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
QueryEngineResults queryEngineResults = getClassName().cast(object);
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
QueryEngineResults queryEngineResults = getClassName().cast(result);
|
||||
Map<Set<String>, ResultSet> resultsMap = queryEngineResults.getResults();
|
||||
Map<Set<String>, ResultSet> returnMap = new HashMap<>();
|
||||
BasePostMethodInvocationProcessor processor = null;
|
||||
@@ -72,6 +76,9 @@ public class QueryEngineResultsPostMethodInvocationProcessor extends BasePostMet
|
||||
}
|
||||
}
|
||||
|
||||
return (T) new QueryEngineResults(returnMap);
|
||||
result = (T) new QueryEngineResults(returnMap);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ public class ResultSetPostMethodInvocationProcessor extends BasePostMethodInvoca
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
ResultSet returnedObject = getClassName().cast(object);
|
||||
ResultSet returnedObject = getClassName().cast(result);
|
||||
|
||||
BitSet inclusionMask = new BitSet(returnedObject.length());
|
||||
FilteringResultSet filteringResultSet = new FilteringResultSet(returnedObject, inclusionMask);
|
||||
|
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 3.0
|
||||
*/
|
||||
@Component
|
||||
public class StoreRefPostMethodInvocationProcessor extends AbstractPostMethodInvocationProcessor
|
||||
public class StoreRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
@@ -44,10 +44,20 @@ public class StoreRefPostMethodInvocationProcessor extends AbstractPostMethodInv
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AbstractPostMethodInvocationProcessor#processSingleElement(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected <T> T processSingleElement(T object)
|
||||
public <T> T process(T object)
|
||||
{
|
||||
StoreRef storeRef = getClassName().cast(object);
|
||||
T result = object;
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
StoreRef storeRef = getClassName().cast(result);
|
||||
NodeRef nodeRef = getNodeService().getRootNode(storeRef);
|
||||
return filter(nodeRef) == null ? null : object;
|
||||
if (filter(nodeRef) == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user