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 5c8d015a25..868d68578d 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
@@ -39,26 +39,17 @@
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml
index b2d874242c..45629a6076 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/extended-repository-context.xml
@@ -26,6 +26,7 @@
+
@@ -34,6 +35,7 @@
+
org.alfresco.repo.security.permissions.impl.ExtendedPermissionService
@@ -51,6 +53,7 @@
+
@@ -77,11 +80,11 @@
+
-
-
+
@@ -92,48 +95,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${security.anyDenyDenies}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -142,13 +122,14 @@
-
-
-
+
+
+
+
+
-
diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml
index 6c0d892a66..f75a9ff12d 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml
@@ -24,9 +24,8 @@
-
-
+
+
+
+
+
+
+
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java
index 5ce3db65c3..3462c5028c 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java
@@ -35,10 +35,11 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import net.sf.acegisecurity.AccessDeniedException;
+
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic;
-import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.AccessDeniedException;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.content.ContentServicePolicies;
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java
index a25fe1ae1e..4f56eccd7f 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java
@@ -212,9 +212,14 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl
@Override
public boolean hasClearance(NodeRef nodeRef)
{
- // Get the node's current classification
- ClassificationLevel currentClassification = getCurrentClassification(nodeRef);
- return securityClearanceService.isCurrentUserClearedForClassification(currentClassification.getId());
+ boolean result = true;
+ if (nodeService.exists(nodeRef))
+ {
+ // Get the node's current classification
+ ClassificationLevel currentClassification = getCurrentClassification(nodeRef);
+ result = securityClearanceService.isCurrentUserClearedForClassification(currentClassification.getId());
+ }
+ return result;
}
/**
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptor.java
deleted file mode 100644
index 468174eb57..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptor.java
+++ /dev/null
@@ -1,122 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor;
-
-import static org.alfresco.repo.security.authentication.AuthenticationUtil.getFullyAuthenticatedUser;
-import static org.alfresco.repo.security.authentication.AuthenticationUtil.isRunAsUserTheSystemUser;
-import static org.alfresco.util.ParameterCheck.mandatory;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
-
-import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.PostMethodInvocationProcessor;
-import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.PreMethodInvocationProcessor;
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-
-/**
- * Classification method interceptor
- *
- * @author Roy Wetherall
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-public class ClassificationMethodInterceptor implements MethodInterceptor
-{
- /** Pre method invocation processor */
- private PreMethodInvocationProcessor preMethodInvocationProcessor;
-
- /** Post method invocation processor */
- private PostMethodInvocationProcessor postMethodInvocationProcessor;
-
- /**
- * @return the preMethodInvocationProcessor
- */
- protected PreMethodInvocationProcessor getPreMethodInvocationProcessor()
- {
- return this.preMethodInvocationProcessor;
- }
-
- /**
- * @return the postMethodInvocationProcessor
- */
- protected PostMethodInvocationProcessor getPostMethodInvocationProcessor()
- {
- return this.postMethodInvocationProcessor;
- }
-
- /**
- * @param postMethodInvocationProcessor the postMethodInvocationProcessor to set
- */
- public void setPostMethodInvocationProcessor(PostMethodInvocationProcessor postMethodInvocationProcessor)
- {
- this.postMethodInvocationProcessor = postMethodInvocationProcessor;
- }
-
- /**
- * @param preMethodInvocationProcessor the preMethodInvocationProcessor to set
- */
- public void setPreMethodInvocationProcessor(PreMethodInvocationProcessor preMethodInvocationProcessor)
- {
- this.preMethodInvocationProcessor = preMethodInvocationProcessor;
- }
-
- /**
- * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
- */
- @Override
- public Object invoke(MethodInvocation invocation) throws Throwable
- {
- mandatory("invocation", invocation);
-
- boolean isUserValid = isUserValid();
-
- // Pre method invocation processing
- if (isUserValid)
- {
- getPreMethodInvocationProcessor().process(invocation);
- }
-
- // Method invocation
- Object result = invocation.proceed();
-
- // Post method invocation processing
- if (isUserValid && result != null)
- {
- result = getPostMethodInvocationProcessor().process(result);
- }
-
- return result;
- }
-
- /**
- * Checks if we have an authenticated user and that they aren't "System"
- *
- * @return true if we have an authenticated user and that they aren't "System", false otherwise.
- */
- private boolean isUserValid()
- {
- boolean result = false;
-
- if (isNotBlank(getFullyAuthenticatedUser()) && !isRunAsUserTheSystemUser())
- {
- result = true;
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptorPostProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptorPostProcessor.java
deleted file mode 100644
index dc81660d32..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/ClassificationMethodInterceptorPostProcessor.java
+++ /dev/null
@@ -1,83 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.RuntimeBeanNameReference;
-import org.springframework.beans.factory.support.ManagedList;
-
-/**
- * Classification method interceptor bean factory post processor.
- *
- * Bean factory post processor that inspects available beans and adds the classification method interceptor
- * to all public services.
- *
- * @author Roy Wetherall
- * @since 3.0.a
- */
-public class ClassificationMethodInterceptorPostProcessor implements BeanFactoryPostProcessor
-{
- private static final String PROP_INTERCEPTOR_NAMES = "interceptorNames";
- private static final String TYPE_PROXY_FACTORY_BEAN = "ProxyFactoryBean";
- private static final String POSTFIX_SERVICE = "Service";
- private static final String BEAN_NAME_CLASSIFICATION_METHOD_INTERCEPTOR = "classificationMethodInterceptor";
-
- /**
- * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
- */
- @SuppressWarnings("unchecked")
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
- {
- // get all bean definition names
- String beans[] = beanFactory.getBeanDefinitionNames();
- for (String bean : beans)
- {
- // get bean definition
- BeanDefinition beanDefinition = beanFactory.getBeanDefinition(bean);
-
- // only modify proxy factory beans that follow the public service naming postfix convention
- if (beanDefinition.getBeanClassName() != null &&
- beanDefinition.getBeanClassName().endsWith(TYPE_PROXY_FACTORY_BEAN) &&
- bean.endsWith(POSTFIX_SERVICE) &&
- Character.isUpperCase(bean.charAt(0)))
- {
- // get the property values for the bean definition
- MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
- if (propertyValues.contains(PROP_INTERCEPTOR_NAMES))
- {
- // get the current list of interceptor names
- PropertyValue value = propertyValues.getPropertyValue(PROP_INTERCEPTOR_NAMES);
- ManagedList list = (ManagedList)value.getValue();
- if (!list.isEmpty())
- {
- // add reference to classification method interceptor
- RuntimeBeanNameReference beanReference = new RuntimeBeanNameReference(BEAN_NAME_CLASSIFICATION_METHOD_INTERCEPTOR);
- list.add(beanReference);
- }
- }
- }
- }
- }
-}
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
deleted file mode 100644
index 5ef3cfaefc..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ArrayPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,90 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import static java.lang.reflect.Array.newInstance;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.stereotype.Component;
-
-/**
- * Array Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-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
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- 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/AssociationRefPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/AssociationRefPostMethodInvocationProcessor.java
deleted file mode 100644
index 11b768b52f..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/AssociationRefPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,69 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.springframework.stereotype.Component;
-
-/**
- * AssociationRef Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class AssociationRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return AssociationRef.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- AssociationRef associationRef = getClassName().cast(result);
-
- NodeRef sourceRef = associationRef.getSourceRef();
- NodeRef filteredSource = filter(sourceRef);
-
- NodeRef targetRef = associationRef.getTargetRef();
- NodeRef filteredTarget = filter(targetRef);
-
- if (filteredSource == null || filteredTarget == null)
- {
- result = null;
- }
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/BasePostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/BasePostMethodInvocationProcessor.java
deleted file mode 100644
index b2ddcb4906..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/BasePostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,159 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import static org.alfresco.model.ContentModel.TYPE_CONTENT;
-
-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.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Base class for post method invocation processors
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-public abstract class BasePostMethodInvocationProcessor
-{
- /** Node service */
- @Autowired
- private NodeService nodeService;
-
- /** Dictionary service */
- @Autowired
- private DictionaryService dictionaryService;
-
- /** Content classification service */
- @Autowired
- private ContentClassificationService contentClassificationService;
-
- /** Security Clearance Service */
- @Autowired
- private SecurityClearanceService securityClearanceService;
-
- /** Post method invocation processor */
- @Autowired
- private PostMethodInvocationProcessor postMethodInvocationProcessor;
-
- /** Pre method invocation processor */
- @Autowired
- private PreMethodInvocationProcessor preMethodInvocationProcessor;
-
- /**
- * @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;
- }
-
- /**
- * @return the securityClearanceService
- */
- protected SecurityClearanceService getSecurityClearanceService()
- {
- return this.securityClearanceService;
- }
-
- /**
- * @return the postMethodInvocationProcessor
- */
- protected PostMethodInvocationProcessor getPostMethodInvocationProcessor()
- {
- return this.postMethodInvocationProcessor;
- }
-
- /**
- * Registers the post method invocation processors
- */
- @PostConstruct
- private void register()
- {
- getPostMethodInvocationProcessor().register(this);
- }
-
- /**
- * Gets the class name
- *
- * @return The class name
- */
- protected abstract Class> getClassName();
-
- /**
- * Performs checks on the given object and throws exception if not all checks pass
- *
- * @param object The object to check
- * @return The given object
- */
- protected abstract T process(T object);
-
- /**
- * Filters the node if the give node reference exist and it is a
- * content but the logged in user is not cleared to see the it.
- *
- * @param nodeRef Node reference
- * @return null if the give node reference has been
- * filtered, the node reference itself otherwise
- */
- protected NodeRef filter(NodeRef nodeRef)
- {
- NodeRef filter = nodeRef;
-
- // disable pre-method invocation processor
- preMethodInvocationProcessor.disable();
- try
- {
- if (getNodeService().exists(nodeRef) &&
- getDictionaryService().isSubClass(getNodeService().getType(nodeRef), TYPE_CONTENT) &&
- !getContentClassificationService().hasClearance(nodeRef))
- {
- filter = null;
- }
- }
- finally
- {
- // re-enable pre-method invocation processor
- preMethodInvocationProcessor.enable();
- }
-
- return filter;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ChildAssociationRefPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ChildAssociationRefPostMethodInvocationProcessor.java
deleted file mode 100644
index a92354a375..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ChildAssociationRefPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,80 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.springframework.stereotype.Component;
-
-/**
- * ChildAssociationRef Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class ChildAssociationRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return ChildAssociationRef.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @Override
- protected T process(T object)
- {
- T result = 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 (filteredChildRef == null)
- {
- result = null;
- }
- }
- else
- {
- filteredParentRef = filter(parentRef);
- if (filteredChildRef == null || filteredParentRef == null)
- {
- result = null;
- }
- }
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/CollectionPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/CollectionPostMethodInvocationProcessor.java
deleted file mode 100644
index 07bdc2f642..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/CollectionPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,84 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.springframework.stereotype.Component;
-
-/**
- * Collection Post Method Invocation Processor.
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class CollectionPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @SuppressWarnings("rawtypes")
- @Override
- protected Class getClassName()
- {
- return Collection.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- BasePostMethodInvocationProcessor processor = null;
- Collection collection = getClassName().cast(object);
- Iterator iterator = collection.iterator();
-
- while (iterator.hasNext())
- {
- Object element = iterator.next();
- if (processor == null)
- {
- processor = getPostMethodInvocationProcessor().getProcessor(element);
- if (processor == null)
- {
- break;
- }
- }
-
- Object processedElement = processor.process(element);
- if (processedElement == null)
- {
- iterator.remove();
- }
- }
-
- result = (T) collection;
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessor.java
deleted file mode 100644
index 262d6a266c..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,61 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.springframework.stereotype.Component;
-
-/**
- * NodeRef Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class NodeRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return NodeRef.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- NodeRef nodeRef = getClassName().cast(result);
- if (filter(nodeRef) == null)
- {
- result = null;
- }
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PagingResultsPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PagingResultsPostMethodInvocationProcessor.java
deleted file mode 100644
index 35c30de23d..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PagingResultsPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,94 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import java.util.List;
-
-import org.alfresco.query.PagingResults;
-import org.alfresco.util.Pair;
-import org.springframework.stereotype.Component;
-
-/**
- * PagingResults Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class PagingResultsPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @SuppressWarnings("rawtypes")
- @Override
- protected Class getClassName()
- {
- return PagingResults.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- final PagingResults pagingResults = getClassName().cast(result);
- List page = pagingResults.getPage();
- int originalPageSize = page.size();
- final List processedPage = getPostMethodInvocationProcessor().process(page);
-
- if (processedPage != null && processedPage.size() != originalPageSize)
- {
- result = (T) new PagingResults()
- {
- @Override
- public String getQueryExecutionId()
- {
- return pagingResults.getQueryExecutionId();
- }
- @Override
- public List getPage()
- {
- return processedPage;
- }
- @Override
- public boolean hasMoreItems()
- {
- // hasMoreItems might not be correct. Cannot determine the correct value as request details are needed.
- return pagingResults.hasMoreItems();
- }
- @Override
- public Pair getTotalResultCount()
- {
- int size = processedPage.size();
- return new Pair(size, size);
- }
- };
- }
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PermissionCheckValuePostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PermissionCheckValuePostMethodInvocationProcessor.java
deleted file mode 100644
index 78e13e36bf..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PermissionCheckValuePostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,63 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import org.alfresco.repo.security.permissions.PermissionCheckValue;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.springframework.stereotype.Component;
-
-/**
- * Permission Check Value Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class PermissionCheckValuePostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return PermissionCheckValue.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- PermissionCheckValue permissionCheckValue = getClassName().cast(result);
- NodeRef nodeRef = permissionCheckValue.getNodeRef();
- if (filter(nodeRef) == null)
- {
- result = null;
- }
- }
-
- 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
deleted file mode 100644
index f0a82d8ef2..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,119 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-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;
-import java.util.Set;
-
-/**
- * Registry for post method invocation processors
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-public class PostMethodInvocationProcessor
-{
- /** Post method invocation processors */
- private Map, BasePostMethodInvocationProcessor> processors = new HashMap<>();
-
- /**
- * Registers a post method invocation processor
- *
- * @param Post method invocation processor object
- */
- public void register(BasePostMethodInvocationProcessor object)
- {
- mandatory("object", object);
-
- getProcessors().put(object.getClassName(), object);
- }
-
- /**
- * Gets all the available processors
- *
- * @return the processors Available processors
- */
- private Map, BasePostMethodInvocationProcessor> getProcessors()
- {
- return this.processors;
- }
-
- /**
- * Gets the processor from the available processors
- *
- * @param object The post invocation object
- * @return The suitable processor for the given class
- */
- protected BasePostMethodInvocationProcessor getProcessor(Object object)
- {
- BasePostMethodInvocationProcessor result = null;
-
- if (object != null)
- {
- Class extends Object> clazz = object.getClass();
-
- if (clazz.isArray())
- {
- result = getProcessors().get(Array.class);
- }
-
- if (result == null)
- {
- Set, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
- for (Map.Entry, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
- {
- if (processorEntry.getKey().isAssignableFrom(clazz))
- {
- result = processorEntry.getValue();
- break;
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * Processes the given object
- *
- * @param object The object to process
- * @return The processed object
- */
- public T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- BasePostMethodInvocationProcessor processor = getProcessor(result);
- if (processor != null)
- {
- result = processor.process(result);
- }
- }
-
- return result;
- }
-}
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
deleted file mode 100644
index cf217e50da..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/PreMethodInvocationProcessor.java
+++ /dev/null
@@ -1,235 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import static java.lang.Boolean.TRUE;
-import static org.alfresco.model.ContentModel.TYPE_CONTENT;
-import static org.alfresco.repo.security.authentication.AuthenticationUtil.getFullyAuthenticatedUser;
-import static org.alfresco.util.GUID.generate;
-import static org.alfresco.util.ParameterCheck.mandatory;
-
-import java.lang.reflect.Method;
-
-import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap;
-import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
-import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport;
-import org.alfresco.repo.transaction.RetryingTransactionHelper;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.transaction.TransactionService;
-import org.aopalliance.intercept.MethodInvocation;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Pre method invocation processor
- *
- * @author Roy Wetherall
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-public class PreMethodInvocationProcessor implements ApplicationContextAware
-{
- /** Key to mark the transaction as processing */
- private static final String KEY_PROCESSING = generate();
-
- /** Application context */
- private ApplicationContext applicationContext;
-
- /**
- * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
- */
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- {
- this.applicationContext = applicationContext;
- }
-
- /**
- * Gets the content classification service
- *
- * @return The content classification service
- */
- protected ContentClassificationService getContentClassificationService()
- {
- return (ContentClassificationService) applicationContext.getBean("contentClassificationService");
- }
-
- /**
- * Gets the node service
- *
- * @return The node service
- */
- protected NodeService getNodeService()
- {
- return (NodeService) applicationContext.getBean("dbNodeService");
- }
-
- /**
- * Gets the dictionary service
- *
- * @return The dictionary service
- */
- protected DictionaryService getDictionaryService()
- {
- return (DictionaryService) applicationContext.getBean("dictionaryService");
- }
-
- /**
- * Gets the alfresco transaction support
- *
- * @return The alfresco transaction support
- */
- protected AlfrescoTransactionSupport getAlfrescoTransactionSupport()
- {
- return (AlfrescoTransactionSupport) applicationContext.getBean("rm.alfrescoTransactionSupport");
- }
-
- /**
- * Gets the retrying transaction helper
- *
- * @return The retrying transaction helper
- */
- protected RetryingTransactionHelper getRetryingTransactionHelper()
- {
- return ((TransactionService) applicationContext.getBean("transactionService")).getRetryingTransactionHelper();
- }
-
- /**
- * Gets the classification service bootstrap
- *
- * @return The classification service bootstrap
- */
- protected ClassificationServiceBootstrap getClassificationServiceBootstrap()
- {
- return (ClassificationServiceBootstrap) applicationContext.getBean("classificationServiceBootstrap");
- }
-
- /**
- * is pre-processing enabled?
- *
- * @return boolean true if enabled, false otherwise
- */
- public boolean isEnabled()
- {
- return (getAlfrescoTransactionSupport().getResource(KEY_PROCESSING) == null);
- }
-
- /**
- * disable pre-processing for this transaction
- */
- public void disable()
- {
- // mark the transaction as processing a classification check
- getAlfrescoTransactionSupport().bindResource(KEY_PROCESSING, TRUE);
- }
-
- /**
- * enable pre-processing for this transaction
- */
- public void enable()
- {
- // clear the transaction as processed a classification check
- getAlfrescoTransactionSupport().unbindResource(KEY_PROCESSING);
- }
-
- /**
- * Checks if the current user is cleared to see the items
- * passed as parameters to the current method invocation.
- *
- * @param invocation The current method invocation
- */
- public void process(final MethodInvocation invocation)
- {
- mandatory("invocation", invocation);
-
- // do in transaction
- getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
- {
- @SuppressWarnings("rawtypes")
- public Void execute() throws Throwable
- {
- // ensure classification service has been bootstrapped
- if (getClassificationServiceBootstrap().isInitialised())
- {
- // if pre-processing is enabled
- if (isEnabled())
- {
- Method method = invocation.getMethod();
- Class[] params = method.getParameterTypes();
-
- int position = 0;
- for (Class param : params)
- {
- // if the param is a node reference
- if (NodeRef.class.isAssignableFrom(param))
- {
- // disable pre-processing
- disable();
- try
- {
- // get the value of the parameter
- NodeRef testNodeRef = (NodeRef) invocation.getArguments()[position];
-
- // if node exists then see if the current user has clearance
- isNodeCleared(testNodeRef, method);
- }
- finally
- {
- // re-enable pre-processing
- enable();
- }
- }
-
- position++;
- }
- }
- }
-
- return null;
- }
- }, true);
- }
-
- /**
- * Checks if the given node exists, if it is a content and if
- * the currently logged in user is cleared to see it.
- *
- * @param nodeRef Node reference to check
- * @param method The invoked method
- */
- private void isNodeCleared(NodeRef nodeRef, Method method)
- {
- if (nodeRef != null &&
- getNodeService().exists(nodeRef) &&
- getDictionaryService().isSubClass(getNodeService().getType(nodeRef), TYPE_CONTENT) &&
- !getContentClassificationService().hasClearance(nodeRef))
- {
- String className = method.getDeclaringClass().getSimpleName();
- String methodName = method.getName();
- String name = className + "." + methodName;
-
- throw new AccessDeniedException("Access is denied for the user '" + getFullyAuthenticatedUser()
- + "' to call the method '" + name + "' for the node '" + nodeRef + "'.");
- }
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/QueryEngineResultsPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/QueryEngineResultsPostMethodInvocationProcessor.java
deleted file mode 100644
index 55b5f1a647..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/QueryEngineResultsPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,84 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
-import org.alfresco.service.cmr.search.ResultSet;
-import org.springframework.stereotype.Component;
-
-/**
- * A post method invocation processor for {@link QueryEngineResults}.
- *
- * @author Tom Page
- * @since 3.0.a
- */
-@Component
-public class QueryEngineResultsPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return QueryEngineResults.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @SuppressWarnings("unchecked")
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- QueryEngineResults queryEngineResults = getClassName().cast(result);
- Map, ResultSet> resultsMap = queryEngineResults.getResults();
- Map, ResultSet> returnMap = new HashMap<>();
- BasePostMethodInvocationProcessor processor = null;
-
- for (Entry, ResultSet> entry : resultsMap.entrySet())
- {
- ResultSet value = entry.getValue();
- if (processor == null)
- {
- processor = getPostMethodInvocationProcessor().getProcessor(value);
- }
-
- ResultSet newResultSet = processor.process(value);
- if (newResultSet != null)
- {
- returnMap.put(entry.getKey(), newResultSet);
- }
- }
-
- result = (T) new QueryEngineResults(returnMap);
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ResultSetPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ResultSetPostMethodInvocationProcessor.java
deleted file mode 100644
index 71d0500410..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/ResultSetPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,118 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import static org.alfresco.service.cmr.search.PermissionEvaluationMode.EAGER;
-
-import java.util.BitSet;
-
-import org.alfresco.repo.search.SimpleResultSetMetaData;
-import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.search.ResultSet;
-import org.alfresco.service.cmr.search.ResultSetMetaData;
-import org.alfresco.service.cmr.search.ResultSetRow;
-import org.alfresco.service.cmr.search.SearchParameters;
-import org.springframework.stereotype.Component;
-
-/**
- * ResultSet Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class ResultSetPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return ResultSet.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.CollectionPostMethodInvocationProcessor#process(java.lang.Object)
- */
- @SuppressWarnings({ "unchecked" })
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- ResultSet returnedObject = getClassName().cast(result);
-
- BitSet inclusionMask = new BitSet(returnedObject.length());
- FilteringResultSet filteringResultSet = new FilteringResultSet(returnedObject, inclusionMask);
-
- ResultSetMetaData resultSetMetaData = returnedObject.getResultSetMetaData();
- SearchParameters searchParameters = resultSetMetaData.getSearchParameters();
-
- BasePostMethodInvocationProcessor nodeRefProcessor = null;
- BasePostMethodInvocationProcessor childAssociationRefProcessor = null;
-
- for (int i = 0; i < returnedObject.length(); i++)
- {
- ResultSetRow row = returnedObject.getRow(i);
- NodeRef nodeRef = row.getNodeRef();
-
- if (nodeRefProcessor == null)
- {
- nodeRefProcessor = getPostMethodInvocationProcessor().getProcessor(nodeRef);
- }
-
- NodeRef processedNodeRef = nodeRefProcessor.process(nodeRef);
- if (processedNodeRef == null)
- {
- inclusionMask.set(i, false);
- }
- else
- {
- ChildAssociationRef childAssocRef = row.getChildAssocRef();
-
- if (childAssociationRefProcessor == null)
- {
- childAssociationRefProcessor = getPostMethodInvocationProcessor().getProcessor(childAssocRef);
- }
-
- ChildAssociationRef childAssociationRef = childAssociationRefProcessor.process(childAssocRef);
- if (childAssociationRef == null)
- {
- inclusionMask.set(i, false);
- }
- else
- {
- inclusionMask.set(i, true);
- }
- }
- }
-
- SimpleResultSetMetaData simpleResultSetMetaData = new SimpleResultSetMetaData(resultSetMetaData.getLimitedBy(), EAGER, searchParameters);
- filteringResultSet.setResultSetMetaData(simpleResultSetMetaData);
- result = (T) filteringResultSet;
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/StoreRefPostMethodInvocationProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/StoreRefPostMethodInvocationProcessor.java
deleted file mode 100644
index 610988fdd5..0000000000
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/StoreRefPostMethodInvocationProcessor.java
+++ /dev/null
@@ -1,63 +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 .
- */
-package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
-
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.springframework.stereotype.Component;
-
-/**
- * StoreRef Post Method Invocation Processor
- *
- * @author Tuna Aksoy
- * @since 3.0.a
- */
-@Component
-public class StoreRefPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
-{
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
- */
- @Override
- protected Class getClassName()
- {
- return StoreRef.class;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
- */
- @Override
- protected T process(T object)
- {
- T result = object;
-
- if (result != null)
- {
- StoreRef storeRef = getClassName().cast(result);
- NodeRef nodeRef = getNodeService().getRootNode(storeRef);
- if (filter(nodeRef) == null)
- {
- result = null;
- }
- }
-
- return result;
- }
-}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java
new file mode 100644
index 0000000000..52dc89bec5
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/permission/ClassificationPermissionPreProcessor.java
@@ -0,0 +1,138 @@
+/*
+ * 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.permission;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap;
+import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
+import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
+import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper;
+import org.alfresco.repo.security.permissions.processor.impl.PermissionPreProcessorBaseImpl;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.security.AccessStatus;
+import org.alfresco.util.Triple;
+
+/**
+ * Classification permission pre-processor implementation.
+ *
+ * @author Roy Wetherall
+ * @since 3.0.a
+ */
+public class ClassificationPermissionPreProcessor extends PermissionPreProcessorBaseImpl
+{
+ /** transaction resource keys */
+ /*package*/ static final String KEY_PROCESSING = ClassificationPermissionPreProcessor.class.getName() + ".processing";
+ /*package*/ static final String KEY_CACHE = ClassificationPermissionPreProcessor.class.getName() + ".cache";
+
+ /** content classification service */
+ private ContentClassificationService contentClassificationService;
+
+ /** transaction resource helper */
+ private TransactionalResourceHelper transactionalResourceHelper;
+
+ /** classificaiton service bootstrap */
+ private ClassificationServiceBootstrap classificationServiceBootstrap;
+
+ /** authentication util */
+ private AuthenticationUtil authenticationUtil;
+
+ /**
+ * @param contentClassificationService content classification service
+ */
+ public void setContentClassificationService(ContentClassificationService contentClassificationService)
+ {
+ this.contentClassificationService = contentClassificationService;
+ }
+
+ /**
+ * @param transactionalResourceHelper transaction resource helper
+ */
+ public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper)
+ {
+ this.transactionalResourceHelper = transactionalResourceHelper;
+ }
+
+ /**
+ * @param classificationServiceBootstrap classification service bootstrap
+ */
+ public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap)
+ {
+ this.classificationServiceBootstrap = classificationServiceBootstrap;
+ }
+
+ /**
+ * @param authenticationUtil authentication util
+ */
+ public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
+ {
+ this.authenticationUtil = authenticationUtil;
+ }
+
+ /**
+ * @see org.alfresco.repo.security.permissions.processor.PermissionPreProcessor#process(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
+ */
+ @Override
+ public AccessStatus process(NodeRef nodeRef, String perm)
+ {
+ AccessStatus result = AccessStatus.UNDETERMINED;
+
+ // ensure the classification bootstrap has been initialised
+ if (classificationServiceBootstrap.isInitialised())
+ {
+ // do not process a node that is already being processed
+ Set