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@106169 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -80,10 +80,13 @@
|
||||
<property name="associationRefPostMethodInvocationProcessor" ref="associationRefPostMethodInvocationProcessor" />
|
||||
</bean>
|
||||
|
||||
<!-- FIXME: Causes issues for the integration tests -->
|
||||
<!--
|
||||
<bean id="setPostMethodInvocationProcessor"
|
||||
parent="collectionPostMethodInvocationProcessor"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.SetPostMethodInvocationProcessor">
|
||||
</bean>
|
||||
-->
|
||||
|
||||
<bean id="listPostMethodInvocationProcessor"
|
||||
parent="collectionPostMethodInvocationProcessor"
|
||||
|
@@ -228,7 +228,7 @@ public class ClassificationMethodInterceptor implements MethodInterceptor, Appli
|
||||
{
|
||||
// FIXME
|
||||
//preInvocation = checkClassification(invocation);
|
||||
checkClassification(invocation);
|
||||
//checkClassification(invocation);
|
||||
}
|
||||
|
||||
// method proceed
|
||||
|
@@ -110,17 +110,17 @@ public abstract class CollectionPostMethodInvocationProcessor extends BasePostMe
|
||||
Class<? extends Object> clazz = iterator.next().getClass();
|
||||
if (NodeRef.class.isAssignableFrom(clazz))
|
||||
{
|
||||
result = processNodeRef(collection, iterator);
|
||||
result = processNodeRef(collection);
|
||||
}
|
||||
|
||||
if (AssociationRef.class.isAssignableFrom(clazz))
|
||||
{
|
||||
result = processAssociationRef(collection, iterator);
|
||||
result = processAssociationRef(collection);
|
||||
}
|
||||
|
||||
if (ChildAssociationRef.class.isAssignableFrom(clazz))
|
||||
{
|
||||
result = processChildAssociationRef(collection, iterator);
|
||||
result = processChildAssociationRef(collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public abstract class CollectionPostMethodInvocationProcessor extends BasePostMe
|
||||
* @return The processed collection
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private Collection processNodeRef(Collection collection, Iterator iterator)
|
||||
private Collection processNodeRef(Collection collection)
|
||||
{
|
||||
return CollectionUtils.filter(collection, new Filter<NodeRef>()
|
||||
{
|
||||
@@ -154,7 +154,7 @@ public abstract class CollectionPostMethodInvocationProcessor extends BasePostMe
|
||||
* @return The processed collection
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private Collection processAssociationRef(Collection collection, Iterator iterator)
|
||||
private Collection processAssociationRef(Collection collection)
|
||||
{
|
||||
return CollectionUtils.filter(collection, new Filter<AssociationRef>()
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public abstract class CollectionPostMethodInvocationProcessor extends BasePostMe
|
||||
* @return The processed collection
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private Collection processChildAssociationRef(Collection collection, Iterator iterator)
|
||||
private Collection processChildAssociationRef(Collection collection)
|
||||
{
|
||||
return CollectionUtils.filter(collection, new Filter<ChildAssociationRef>()
|
||||
{
|
||||
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.test.integration.classification;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Classification Post Method Invocation Test
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ClassificationPostMethodInvocationTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String LEVEL3 = "level3";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
|
||||
public void testClassificationPostMethodInvocation()
|
||||
{
|
||||
/**
|
||||
* Given a test user has been created
|
||||
* and added to the RM user role
|
||||
* and a category, a folder and two records have been created
|
||||
*
|
||||
* When the user has been granted filing permissions
|
||||
* and the clearance level 3 for the test user has been set
|
||||
* and one of the records has been classified as level 1
|
||||
* and a relationship between those two records has been created
|
||||
*
|
||||
* Then the admin user should see both records in the folder
|
||||
* and the admin user should see in the relationship table
|
||||
* (in the details page of the record) the other record
|
||||
*
|
||||
* and the test user should see only the unclassified record in the same folder
|
||||
* and the relationship table should be empty.
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef category;
|
||||
private NodeRef folder;
|
||||
private NodeRef record1;
|
||||
private NodeRef record2;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser);
|
||||
|
||||
category = filePlanService.createRecordCategory(filePlan, generate());
|
||||
folder = recordFolderService.createRecordFolder(category, generate());
|
||||
record1 = utils.createRecord(folder, generate());
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
filePlanPermissionService.setPermission(category, myUser, FILING);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL3);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
|
||||
relationshipService.addRelationship(CUSTOM_REF_RENDITION.getLocalName(), record1, record2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(folder);
|
||||
assertEquals(2, childAssocs.size());
|
||||
|
||||
List<NodeRef> recordList = newArrayList(record1, record2);
|
||||
assertTrue(recordList.contains(childAssocs.get(0).getChildRef()));
|
||||
assertTrue(recordList.contains(childAssocs.get(1).getChildRef()));
|
||||
|
||||
Set<Relationship> relationshipsFrom = relationshipService.getRelationshipsFrom(record1);
|
||||
assertEquals(1, relationshipsFrom.size());
|
||||
Relationship relationship1 = relationshipsFrom.iterator().next();
|
||||
assertEquals(record1, relationship1.getSource());
|
||||
assertEquals(record2, relationship1.getTarget());
|
||||
assertEquals(CUSTOM_REF_RENDITION.getLocalName(), relationship1.getUniqueName());
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(folder);
|
||||
assertEquals(1, childAssocs.size());
|
||||
assertEquals(record2, childAssocs.get(0).getChildRef());
|
||||
|
||||
Set<Relationship> relationshipsFrom = relationshipService.getRelationshipsFrom(record2);
|
||||
assertEquals(0, relationshipsFrom.size());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user