diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml
index aeb2f39e64..cf15c1b485 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml
@@ -37,6 +37,14 @@
+
+
+
+
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessor.java
new file mode 100644
index 0000000000..672958aab9
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessor.java
@@ -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 .
+ */
+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 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 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;
+ }
+
+}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PostMethodInvocationProcessor.java
index 3c1a81ac07..775d03a169 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PostMethodInvocationProcessor.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PostMethodInvocationProcessor.java
@@ -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, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
- for (Map.Entry, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
+ if (clazz.isArray())
{
- if (processorEntry.getKey().isAssignableFrom(clazz))
+ result = getProcessors().get(Array.class);
+ }
+
+ if (result == null)
+ {
+ Set, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
+ for (Map.Entry, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
{
- result = processorEntry.getValue();
- break;
+ if (processorEntry.getKey().isAssignableFrom(clazz))
+ {
+ result = processorEntry.getValue();
+ break;
+ }
}
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PreMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PreMethodInvocationProcessor.java
index d19bc5b1f8..85585653be 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PreMethodInvocationProcessor.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PreMethodInvocationProcessor.java
@@ -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()
+ return /*getTransactionService().*/getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
{
@SuppressWarnings("rawtypes")
public Boolean execute() throws Throwable
diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessorUnitTest.java
new file mode 100644
index 0000000000..a9c44c4601
--- /dev/null
+++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessorUnitTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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 .
+ */
+package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.apache.commons.lang3.ArrayUtils;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+
+/**
+ * Array Post Method Invocation Processor Unit Test
+ *
+ * @author Tuna Aksoy
+ * @since 3.0
+ */
+public class ArrayPostMethodInvocationProcessorUnitTest extends BaseUnitTest
+{
+ @InjectMocks ArrayPostMethodInvocationProcessor arrayPostMethodInvocationProcessor;
+ @Mock private ContentClassificationService mockedContentClassificationService;
+ @Mock private PostMethodInvocationProcessor mockedPostMethodInvocationProcessor;
+
+ @Test
+ public void testArrayPostMethodInvocationProcessor()
+ {
+ NodeRefPostMethodInvocationProcessor processor = new NodeRefPostMethodInvocationProcessor();
+ processor.setNodeService(mockedNodeService);
+ processor.setDictionaryService(mockedDictionaryService);
+ processor.setContentClassificationService(mockedContentClassificationService);
+
+ NodeRef nodeRef1 = generateNodeRef();
+ NodeRef nodeRef2 = generateNodeRef();
+ NodeRef nodeRef3 = generateNodeRef();
+ NodeRef nodeRef4 = generateNodeRef();
+
+ when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(true);
+ when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
+ when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef3), TYPE_CONTENT)).thenReturn(true);
+ when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef4), TYPE_CONTENT)).thenReturn(true);
+ when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
+ when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(false);
+ when(mockedContentClassificationService.hasClearance(nodeRef3)).thenReturn(true);
+ when(mockedContentClassificationService.hasClearance(nodeRef4)).thenReturn(false);
+ when(mockedPostMethodInvocationProcessor.getProcessor(Mockito.any())).thenReturn(processor);
+
+ NodeRef[] nodes = new NodeRef[] { nodeRef1, nodeRef2, nodeRef3, nodeRef4 };
+ NodeRef[] processedNodes = arrayPostMethodInvocationProcessor.process(nodes);
+
+ assertEquals(2, processedNodes.length);
+ assertTrue(ArrayUtils.contains(processedNodes, nodeRef1));
+ assertTrue(ArrayUtils.contains(processedNodes, nodeRef3));
+ }
+}