mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +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@106657 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static java.lang.reflect.Array.newInstance;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Array Post Method Invocation Processor
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ArrayPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
*/
|
||||
@Override
|
||||
protected Class<Array> getClassName()
|
||||
{
|
||||
return Array.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
mandatory("object", object);
|
||||
|
||||
T result = object;
|
||||
T[] objects = (T[]) result;
|
||||
T obj = objects[0];
|
||||
|
||||
BasePostMethodInvocationProcessor processor = getPostMethodInvocationProcessor().getProcessor(obj);
|
||||
if (processor != null)
|
||||
{
|
||||
int length = objects.length;
|
||||
List processedObjects = new ArrayList();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Object processedObject = processor.process(objects[i]);
|
||||
if (processedObject != null)
|
||||
{
|
||||
processedObjects.add(processedObject);
|
||||
}
|
||||
}
|
||||
|
||||
int size = processedObjects.size();
|
||||
T[] objs = (T[]) newInstance(obj.getClass(), size);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
objs[i] = (T) processedObjects.get(i);
|
||||
}
|
||||
|
||||
result = (T) objs;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.pr
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -76,13 +77,21 @@ public class PostMethodInvocationProcessor
|
||||
BasePostMethodInvocationProcessor result = null;
|
||||
Class<? extends Object> clazz = object.getClass();
|
||||
|
||||
Set<Entry<Class<?>, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
|
||||
for (Map.Entry<Class<?>, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
|
||||
if (clazz.isArray())
|
||||
{
|
||||
if (processorEntry.getKey().isAssignableFrom(clazz))
|
||||
result = getProcessors().get(Array.class);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
Set<Entry<Class<?>, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
|
||||
for (Map.Entry<Class<?>, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
|
||||
{
|
||||
result = processorEntry.getValue();
|
||||
break;
|
||||
if (processorEntry.getKey().isAssignableFrom(clazz))
|
||||
{
|
||||
result = processorEntry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,7 @@ import org.springframework.context.ApplicationContextAware;
|
||||
*/
|
||||
public class PreMethodInvocationProcessor implements ApplicationContextAware
|
||||
{
|
||||
/** Key to mark the transaction as processing */
|
||||
private static final String KEY_PROCESSING = generate();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -88,6 +89,120 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
|
||||
return (DictionaryService)applicationContext.getBean("dictionaryService");
|
||||
}
|
||||
|
||||
// /** Transaction service */
|
||||
// private TransactionService transactionService;
|
||||
//
|
||||
// /** Classification service bootstrap */
|
||||
// private ClassificationServiceBootstrap classificationServiceBootstrap;
|
||||
//
|
||||
// /** Alfresco transaction support */
|
||||
// private AlfrescoTransactionSupport alfrescoTransactionSupport;
|
||||
//
|
||||
// /** Node service */
|
||||
// private NodeService nodeService;
|
||||
//
|
||||
// /** Dictionary service */
|
||||
// private DictionaryService dictionaryService;
|
||||
//
|
||||
// /** Content classification service */
|
||||
// private ContentClassificationService contentClassificationService;
|
||||
//
|
||||
// /**
|
||||
// * @return the transactionService
|
||||
// */
|
||||
// protected TransactionService getTransactionService()
|
||||
// {
|
||||
// return this.transactionService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the classificationServiceBootstrap
|
||||
// */
|
||||
// protected ClassificationServiceBootstrap getClassificationServiceBootstrap()
|
||||
// {
|
||||
// return this.classificationServiceBootstrap;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the alfrescoTransactionSupport
|
||||
// */
|
||||
// protected AlfrescoTransactionSupport getAlfrescoTransactionSupport()
|
||||
// {
|
||||
// return this.alfrescoTransactionSupport;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the nodeService
|
||||
// */
|
||||
// protected NodeService getNodeService()
|
||||
// {
|
||||
// return this.nodeService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the dictionaryService
|
||||
// */
|
||||
// protected DictionaryService getDictionaryService()
|
||||
// {
|
||||
// return this.dictionaryService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the contentClassificationService
|
||||
// */
|
||||
// protected ContentClassificationService getContentClassificationService()
|
||||
// {
|
||||
// return this.contentClassificationService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param transactionService the transactionService to set
|
||||
// */
|
||||
// public void setTransactionService(TransactionService transactionService)
|
||||
// {
|
||||
// this.transactionService = transactionService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param classificationServiceBootstrap the classificationServiceBootstrap to set
|
||||
// */
|
||||
// public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap)
|
||||
// {
|
||||
// this.classificationServiceBootstrap = classificationServiceBootstrap;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param alfrescoTransactionSupport the alfrescoTransactionSupport to set
|
||||
// */
|
||||
// public void setAlfrescoTransactionSupport(AlfrescoTransactionSupport alfrescoTransactionSupport)
|
||||
// {
|
||||
// this.alfrescoTransactionSupport = alfrescoTransactionSupport;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param nodeService the nodeService to set
|
||||
// */
|
||||
// public void setNodeService(NodeService nodeService)
|
||||
// {
|
||||
// this.nodeService = nodeService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param dictionaryService the dictionaryService to set
|
||||
// */
|
||||
// public void setDictionaryService(DictionaryService dictionaryService)
|
||||
// {
|
||||
// this.dictionaryService = dictionaryService;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param contentClassificationService the contentClassificationService to set
|
||||
// */
|
||||
// public void setContentClassificationService(ContentClassificationService contentClassificationService)
|
||||
// {
|
||||
// this.contentClassificationService = contentClassificationService;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Checks if the current user is cleared to see the items
|
||||
* passed as parameters to the current method invocation.
|
||||
@@ -100,7 +215,7 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
|
||||
mandatory("invocation", invocation);
|
||||
|
||||
// do in transaction
|
||||
return getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Boolean>()
|
||||
return /*getTransactionService().*/getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Boolean>()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Boolean execute() throws Throwable
|
||||
|
Reference in New Issue
Block a user