RM-581 (A user will receive notification of rejected records)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@46114 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-01-31 18:47:35 +00:00
parent 336ef19c99
commit d08b441438
8 changed files with 177 additions and 149 deletions

View File

@@ -1139,21 +1139,17 @@
</properties> </properties>
</aspect> </aspect>
<!-- Aspect to hold the information about the original location of a record --> <!-- Aspect to hold the originating details of a record -->
<aspect name="rma:originalLocation"> <aspect name="rma:recordOriginatingDetails">
<title>The original location of a record</title> <title>The originating details of a record</title>
<properties> <properties>
<property name="rma:orgLocation"> <property name="rma:recordOrginalLocation">
<type>d:any</type> <type>d:any</type>
</property> </property>
</properties> <property name="rma:recordCreationDate">
</aspect> <type>d:date</type>
</property>
<!-- Aspect to hold the information about reject reason of a record --> <property name="rma:recordUserId">
<aspect name="rma:rejectReasonRecord">
<title>The reject reason of a record</title>
<properties>
<property name="rma:rejectReason">
<type>d:text</type> <type>d:text</type>
</property> </property>
</properties> </properties>

View File

@@ -4,7 +4,7 @@
<beans> <beans>
<!-- Helper beans --> <!-- Helper beans -->
<bean id="baseTransaction" abstract="true" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <bean id="baseTransaction" abstract="true" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager"> <property name="transactionManager">
<ref bean="transactionManager"/> <ref bean="transactionManager"/>
@@ -15,7 +15,7 @@
</props> </props>
</property> </property>
</bean> </bean>
<bean id="baseSecurity" abstract="true" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor"> <bean id="baseSecurity" abstract="true" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor">
<property name="authenticationManager"> <property name="authenticationManager">
<ref bean="authenticationManager"/> <ref bean="authenticationManager"/>
@@ -27,7 +27,7 @@
<ref bean="afterInvocationManager"/> <ref bean="afterInvocationManager"/>
</property> </property>
</bean> </bean>
<bean id="baseService" abstract="true"> <bean id="baseService" abstract="true">
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="dictionaryService" ref="DictionaryService"/> <property name="dictionaryService" ref="DictionaryService"/>
@@ -433,9 +433,9 @@
</value> </value>
</property> </property>
</bean> </bean>
<!-- File Plan Service --> <!-- File Plan Service -->
<bean id="filePlanService" <bean id="filePlanService"
parent="baseService" parent="baseService"
class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl"> class="org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanServiceImpl">
@@ -460,7 +460,7 @@
<bean id="FilePlanService_transaction" parent="baseTransaction" /> <bean id="FilePlanService_transaction" parent="baseTransaction" />
<bean id="FilePlanService_security" parent="baseSecurity"> <bean id="FilePlanService_security" parent="baseSecurity">
<property name="objectDefinitionSource"> <property name="objectDefinitionSource">
<value> <value>
<![CDATA[ <![CDATA[
@@ -474,7 +474,7 @@
</bean> </bean>
<!-- File Plan Permission Service --> <!-- File Plan Permission Service -->
<bean id="filePlanPermissionService" <bean id="filePlanPermissionService"
class="org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionServiceImpl" class="org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionServiceImpl"
init-method="init"> init-method="init">
@@ -541,8 +541,8 @@
<property name="authorityService" ref="AuthorityService"/> <property name="authorityService" ref="AuthorityService"/>
<property name="permissionService" ref="PermissionService"/> <property name="permissionService" ref="PermissionService"/>
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="policyComponent" ref="policyComponent"/> <property name="policyComponent" ref="policyComponent"/>
<property name="filePlanService" ref="FilePlanService" /> <property name="filePlanService" ref="FilePlanService" />
</bean> </bean>
<bean id="FilePlanRoleService" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="FilePlanRoleService" class="org.springframework.aop.framework.ProxyFactoryBean">
@@ -601,7 +601,7 @@
</property> </property>
</bean> </bean>
<!-- Records Management Extended Security Service --> <!-- Records Management Extended Security Service -->
@@ -1080,9 +1080,9 @@
</value> </value>
</property> </property>
</bean> </bean>
<!-- Record Folder Service --> <!-- Record Folder Service -->
<bean id="recordFolderService" class="org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServiceImpl" init-method="init"> <bean id="recordFolderService" class="org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServiceImpl" init-method="init">
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="policyComponent" ref="policyComponent" /> <property name="policyComponent" ref="policyComponent" />
@@ -1101,6 +1101,7 @@
<property name="policyComponent" ref="policyComponent" /> <property name="policyComponent" ref="policyComponent" />
<property name="dispositionService" ref="DispositionService" /> <property name="dispositionService" ref="DispositionService" />
<property name="filePlanService" ref="FilePlanService" /> <property name="filePlanService" ref="FilePlanService" />
<property name="notificationService" ref="NotificationService"/>
</bean> </bean>
<bean id="RecordService" class="org.springframework.aop.framework.ProxyFactoryBean"> <bean id="RecordService" class="org.springframework.aop.framework.ProxyFactoryBean">

View File

@@ -116,7 +116,7 @@ public class HideRecordAction extends ActionExecuterAbstractBase implements Reco
else else
{ {
// remove the child association // remove the child association
NodeRef originalLocation = (NodeRef) nodeService.getProperty(actionedUponNodeRef, PROP_ORIGINAL_LOCATION); NodeRef originalLocation = (NodeRef) nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINAL_LOCATION);
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(actionedUponNodeRef); List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(actionedUponNodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs) for (ChildAssociationRef childAssociationRef : parentAssocs)
{ {

View File

@@ -232,10 +232,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_READERS = QName.createQName(RM_URI, "readers"); public static final QName PROP_READERS = QName.createQName(RM_URI, "readers");
// Original location of a record // Original location of a record
public static final QName ASPECT_ORIGINAL_LOCATION = QName.createQName(RM_URI, "originalLocation"); public static final QName ASPECT_RECORD_ORIGINATING_DETAILS = QName.createQName(RM_URI, "recordOriginatingDetails");
public static final QName PROP_ORIGINAL_LOCATION = QName.createQName(RM_URI, "orgLocation"); public static final QName PROP_RECORD_ORIGINAL_LOCATION = QName.createQName(RM_URI, "recordOrginalLocation");
public static final QName PROP_RECORD_CREATION_DATE = QName.createQName(RM_URI, "recordCreationDate");
// Reject reason of a record public static final QName PROP_RECORD_USER_ID = QName.createQName(RM_URI, "recordUserId");
public static final QName ASPECT_REJECT_REASON_RECORD = QName.createQName(RM_URI, "rejectReasonRecord");
public static final QName PROP_REJECT_REASON = QName.createQName(RM_URI, "rejectReason");
} }

View File

@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.record;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -38,6 +39,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.notification.EMailNotificationProvider;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
@@ -46,6 +48,8 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.notification.NotificationContext;
import org.alfresco.service.cmr.notification.NotificationService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -53,9 +57,11 @@ import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.mail.MailPreparationException;
/** /**
* Record service implementation * Record service implementation
@@ -95,6 +101,9 @@ public class RecordServiceImpl implements RecordService,
/** File plan service */ /** File plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** Notification service */
private NotificationService notificationService;
/** Policy component */ /** Policy component */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
@@ -177,6 +186,14 @@ public class RecordServiceImpl implements RecordService,
this.filePlanService = filePlanService; this.filePlanService = filePlanService;
} }
/**
* @param notificationService notification service
*/
public void setNotificationService(NotificationService notificationService)
{
this.notificationService = notificationService;
}
/** /**
* @param policyComponent policy component * @param policyComponent policy component
*/ */
@@ -290,6 +307,9 @@ public class RecordServiceImpl implements RecordService,
nodeRef.toString()); nodeRef.toString());
} }
// Save the id of the currently logged in user
final String userId = AuthenticationUtil.getRunAsUser();
// do the work of creating the record as the system user // do the work of creating the record as the system user
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{ {
@@ -315,9 +335,11 @@ public class RecordServiceImpl implements RecordService,
nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); nodeService.moveNode(nodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// Add the information about the original location // Add the information about the original location
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1); Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(3);
aspectProperties.put(PROP_ORIGINAL_LOCATION, (Serializable) parentAssoc.getParentRef()); aspectProperties.put(PROP_RECORD_ORIGINAL_LOCATION, (Serializable) parentAssoc.getParentRef());
nodeService.addAspect(nodeRef, ASPECT_ORIGINAL_LOCATION, aspectProperties); aspectProperties.put(PROP_RECORD_USER_ID, userId);
aspectProperties.put(PROP_RECORD_CREATION_DATE, new Date());
nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties);
// make the document a record // make the document a record
makeRecord(nodeRef); makeRecord(nodeRef);
@@ -440,7 +462,7 @@ public class RecordServiceImpl implements RecordService,
public Void doWork() throws Exception public Void doWork() throws Exception
{ {
// first remove the secondary link association // first remove the secondary link association
NodeRef originalLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_ORIGINAL_LOCATION); NodeRef originalLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINAL_LOCATION);
List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef); List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : parentAssocs) for (ChildAssociationRef childAssociationRef : parentAssocs)
{ {
@@ -461,17 +483,31 @@ public class RecordServiceImpl implements RecordService,
// get the records primary parent association // get the records primary parent association
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef);
// save the reject reason
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1);
aspectProperties.put(PROP_REJECT_REASON, reason);
nodeService.addAspect(nodeRef, ASPECT_REJECT_REASON_RECORD, aspectProperties);
// move the record into the collaboration site // move the record into the collaboration site
nodeService.moveNode(nodeRef, originalLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName()); nodeService.moveNode(nodeRef, originalLocation, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// remove all extended readers // remove all extended readers
extendedSecurityService.removeAllExtendedReaders(nodeRef); extendedSecurityService.removeAllExtendedReaders(nodeRef);
// Send an email to the record creator
String recordCreator = (String) nodeService.getProperty(nodeRef, PROP_RECORD_USER_ID);
if (StringUtils.isNotBlank(recordCreator))
{
NotificationContext context = new NotificationContext();
context.addTo(recordCreator);
// FIXME: Subject -> i18n
context.setSubject("Record rejected");
// FIXME: Use email template
context.setBody(reason);
notificationService.sendNotification(EMailNotificationProvider.NAME, context);
}
else
{
throw new MailPreparationException("The id of the record creator cannot be found!");
}
return null; return null;
} }
}); });

View File

@@ -89,7 +89,7 @@ public class HideRecordActionTest extends BaseRMTestCase
assertTrue(recordService.isRecord(doc)); assertTrue(recordService.isRecord(doc));
// The record should have the original location information // The record should have the original location information
assertNotNull(nodeService.getProperty(doc, PROP_ORIGINAL_LOCATION)); assertNotNull(nodeService.getProperty(doc, PROP_RECORD_ORIGINAL_LOCATION));
// Check the parents. In this case the document should have two parents (doclib and fileplan) // Check the parents. In this case the document should have two parents (doclib and fileplan)
assertTrue(nodeService.getParentAssocs(doc).size() == 2); assertTrue(nodeService.getParentAssocs(doc).size() == 2);

View File

@@ -75,7 +75,7 @@ public class RejectActionTest extends BaseRMTestCase
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
// The record should have the original location information // The record should have the original location information
assertNotNull(nodeService.getProperty(dmDocument, PROP_ORIGINAL_LOCATION)); assertNotNull(nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
// Check the parents. In this case the document should have two parents (doclib and fileplan) // Check the parents. In this case the document should have two parents (doclib and fileplan)
assertTrue(nodeService.getParentAssocs(dmDocument).size() == 2); assertTrue(nodeService.getParentAssocs(dmDocument).size() == 2);
@@ -114,9 +114,6 @@ public class RejectActionTest extends BaseRMTestCase
// The "identifier" property should be removed // The "identifier" property should be removed
assertNull(nodeService.getProperty(dmDocument, PROP_IDENTIFIER)); assertNull(nodeService.getProperty(dmDocument, PROP_IDENTIFIER));
// The reject reason should be saved
assertTrue(((String) nodeService.getProperty(dmDocument, PROP_REJECT_REASON)).equals(REJECT_REASON));
// The record should be removed from the file plan // The record should be removed from the file plan
assertTrue(nodeService.getParentAssocs(dmDocument).size() == 1); assertTrue(nodeService.getParentAssocs(dmDocument).size() == 1);

View File

@@ -38,7 +38,7 @@ import org.alfresco.service.namespace.QName;
/** /**
* Records Service Implementation Test * Records Service Implementation Test
* *
* @author Roy Wetherall * @author Roy Wetherall
* @author Tuna Askoy * @author Tuna Askoy
* @since 2.1 * @since 2.1
@@ -47,7 +47,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
{ {
/** Services */ /** Services */
protected ActionService dmActionService; protected ActionService dmActionService;
protected PermissionService dmPermissionService; protected PermissionService dmPermissionService;
protected ExtendedSecurityService extendedSecurityService; protected ExtendedSecurityService extendedSecurityService;
/** /**
@@ -65,7 +65,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
/** /**
* This is a user test * This is a user test
* *
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest() * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isUserTest()
*/ */
@Override @Override
@@ -76,7 +76,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
/** /**
* This is a record test * This is a record test
* *
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest() * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isRecordTest()
*/ */
@Override @Override
@@ -84,7 +84,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
{ {
return true; return true;
} }
/** /**
* This is a collaboration site test * This is a collaboration site test
*/ */
@@ -114,18 +114,18 @@ public class RecordServiceImplTest extends BaseRMTestCase
/** /**
* Helper method for getting a list of record meta data aspects * Helper method for getting a list of record meta data aspects
* *
* @return Record meta data aspects as list * @return Record meta data aspects as list
*/ */
private List<QName> getAspectList() private List<QName> getAspectList()
{ {
QName[] aspects = new QName[] QName[] aspects = new QName[]
{ {
DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD, DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD,
DOD5015Model.ASPECT_PDF_RECORD, DOD5015Model.ASPECT_PDF_RECORD,
DOD5015Model.ASPECT_WEB_RECORD, DOD5015Model.ASPECT_WEB_RECORD,
DOD5015Model.ASPECT_SCANNED_RECORD, DOD5015Model.ASPECT_SCANNED_RECORD,
ASPECT_RECORD_META_DATA ASPECT_RECORD_META_DATA
}; };
return Arrays.asList(aspects); return Arrays.asList(aspects);
@@ -170,7 +170,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
} }
}); });
} }
public void testUnfiled() throws Exception public void testUnfiled() throws Exception
{ {
doTestInTransaction(new VoidTest() doTestInTransaction(new VoidTest()
@@ -184,7 +184,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
assertTrue(recordService.isFiled(recordOne)); assertTrue(recordService.isFiled(recordOne));
assertTrue(recordService.isFiled(recordDeclaredOne)); assertTrue(recordService.isFiled(recordDeclaredOne));
} }
}); });
} }
/** /**
@@ -198,13 +198,13 @@ public class RecordServiceImplTest extends BaseRMTestCase
"Can not create a record from a document if you do not have WRITE permissions.", "Can not create a record from a document if you do not have WRITE permissions.",
AccessDeniedException.class AccessDeniedException.class
) )
{ {
public void run() throws Exception public void run() throws Exception
{ {
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
} }
}, dmConsumer); }, dmConsumer);
// create record from document // create record from document
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
@@ -212,55 +212,55 @@ public class RecordServiceImplTest extends BaseRMTestCase
public Void run() public Void run()
{ {
NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertFalse(recordService.isRecord(dmDocument)); assertFalse(recordService.isRecord(dmDocument));
assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument)); assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument));
checkPermissions(READ_RECORDS, checkPermissions(READ_RECORDS,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
assertEquals(AccessStatus.DENIED, assertEquals(AccessStatus.DENIED,
dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
checkPermissions(FILING, checkPermissions(FILING,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
checkPermissions(READ_RECORDS, checkPermissions(READ_RECORDS,
AccessStatus.ALLOWED, // file plan AccessStatus.ALLOWED, // file plan
AccessStatus.ALLOWED, // unfiled container AccessStatus.ALLOWED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.ALLOWED); // doc/record AccessStatus.ALLOWED); // doc/record
assertEquals(AccessStatus.ALLOWED, assertEquals(AccessStatus.ALLOWED,
dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
checkPermissions(FILING, checkPermissions(FILING,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertTrue(extendedSecurityService.hasExtendedReaders(dmDocument)); assertTrue(extendedSecurityService.hasExtendedReaders(dmDocument));
assertFalse(recordService.isFiled(dmDocument)); assertFalse(recordService.isFiled(dmDocument));
// show that the record has meta-data about it's original location // show that the record has meta-data about it's original location
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_ORIGINAL_LOCATION)); assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS));
assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_ORIGINAL_LOCATION)); assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef());
// show that the record is linked to it's original location // show that the record is linked to it's original location
assertEquals(2, nodeService.getParentAssocs(dmDocument).size()); assertEquals(2, nodeService.getParentAssocs(dmDocument).size());
@@ -268,7 +268,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
} }
}, dmCollaborator); }, dmCollaborator);
} }
public void testCreateRecordNoLink() throws Exception public void testCreateRecordNoLink() throws Exception
{ {
// show that users without WRITE can not create a record from a document // show that users without WRITE can not create a record from a document
@@ -277,13 +277,13 @@ public class RecordServiceImplTest extends BaseRMTestCase
"Can not create a record from a document if you do not have WRITE permissions.", "Can not create a record from a document if you do not have WRITE permissions.",
AccessDeniedException.class AccessDeniedException.class
) )
{ {
public void run() throws Exception public void run() throws Exception
{ {
recordService.createRecord(filePlan, dmDocument, false); recordService.createRecord(filePlan, dmDocument, false);
} }
}, dmConsumer); }, dmConsumer);
// create record from document // create record from document
final NodeRef originalLocation = doTestInTransaction(new Test<NodeRef>() final NodeRef originalLocation = doTestInTransaction(new Test<NodeRef>()
{ {
@@ -291,64 +291,64 @@ public class RecordServiceImplTest extends BaseRMTestCase
public NodeRef run() public NodeRef run()
{ {
NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef(); NodeRef originalLocation = nodeService.getPrimaryParent(dmDocument).getParentRef();
assertFalse(recordService.isRecord(dmDocument)); assertFalse(recordService.isRecord(dmDocument));
assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument)); assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument));
checkPermissions(READ_RECORDS, checkPermissions(READ_RECORDS,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
assertEquals(AccessStatus.DENIED, assertEquals(AccessStatus.DENIED,
dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
checkPermissions(FILING, checkPermissions(FILING,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
recordService.createRecord(filePlan, dmDocument, false); recordService.createRecord(filePlan, dmDocument, false);
checkPermissions(READ_RECORDS, checkPermissions(READ_RECORDS,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
assertEquals(AccessStatus.DENIED, assertEquals(AccessStatus.DENIED,
dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS)); dmPermissionService.hasPermission(filePlan, RMPermissionModel.VIEW_RECORDS));
checkPermissions(FILING, checkPermissions(FILING,
AccessStatus.DENIED, // file plan AccessStatus.DENIED, // file plan
AccessStatus.DENIED, // unfiled container AccessStatus.DENIED, // unfiled container
AccessStatus.DENIED, // record category AccessStatus.DENIED, // record category
AccessStatus.DENIED, // record folder AccessStatus.DENIED, // record folder
AccessStatus.DENIED); // doc/record AccessStatus.DENIED); // doc/record
return originalLocation; return originalLocation;
} }
}, dmCollaborator); }, dmCollaborator);
doTestInTransaction(new Test<Void>() doTestInTransaction(new Test<Void>()
{ {
@Override @Override
public Void run() public Void run()
{ {
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument)); assertFalse(extendedSecurityService.hasExtendedReaders(dmDocument));
assertFalse(recordService.isFiled(dmDocument)); assertFalse(recordService.isFiled(dmDocument));
// show that the record has meta-data about it's original location // show that the record has meta-data about it's original location
assertTrue(nodeService.hasAspect(dmDocument, ASPECT_ORIGINAL_LOCATION)); assertTrue(nodeService.hasAspect(dmDocument, ASPECT_RECORD_ORIGINATING_DETAILS));
assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_ORIGINAL_LOCATION)); assertEquals(originalLocation, nodeService.getProperty(dmDocument, PROP_RECORD_ORIGINAL_LOCATION));
assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef()); assertFalse(originalLocation == nodeService.getPrimaryParent(dmDocument).getParentRef());
// show that the record is linked to it's original location // show that the record is linked to it's original location
assertEquals(1, nodeService.getParentAssocs(dmDocument).size()); assertEquals(1, nodeService.getParentAssocs(dmDocument).size());
@@ -356,7 +356,7 @@ public class RecordServiceImplTest extends BaseRMTestCase
} }
}, rmAdminName); }, rmAdminName);
} }
public void testFileNewContent() throws Exception public void testFileNewContent() throws Exception
{ {
doTestInTransaction(new Test<NodeRef>() doTestInTransaction(new Test<NodeRef>()
@@ -365,26 +365,26 @@ public class RecordServiceImplTest extends BaseRMTestCase
public NodeRef run() public NodeRef run()
{ {
NodeRef record = fileFolderService.create(rmFolder, "test101.txt" , TYPE_CONTENT).getNodeRef(); NodeRef record = fileFolderService.create(rmFolder, "test101.txt" , TYPE_CONTENT).getNodeRef();
ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true); ContentWriter writer = contentService.getWriter(record, PROP_CONTENT, true);
writer.setEncoding("UTF-8"); writer.setEncoding("UTF-8");
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
writer.putContent("hello world this is some test content"); writer.putContent("hello world this is some test content");
return record; return record;
} }
@Override @Override
public void test(NodeRef record) throws Exception public void test(NodeRef record) throws Exception
{ {
assertTrue(recordService.isRecord(record)); assertTrue(recordService.isRecord(record));
assertTrue(recordService.isFiled(record)); assertTrue(recordService.isFiled(record));
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
} }
}); });
} }
public void testFileUnfiledrecord() throws Exception public void testFileUnfiledrecord() throws Exception
{ {
doTestInTransaction(new Test<NodeRef>() doTestInTransaction(new Test<NodeRef>()
@@ -393,28 +393,28 @@ public class RecordServiceImplTest extends BaseRMTestCase
public NodeRef run() throws Exception public NodeRef run() throws Exception
{ {
recordService.createRecord(filePlan, dmDocument); recordService.createRecord(filePlan, dmDocument);
assertTrue(recordService.isRecord(dmDocument)); assertTrue(recordService.isRecord(dmDocument));
assertFalse(recordService.isFiled(dmDocument)); assertFalse(recordService.isFiled(dmDocument));
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
fileFolderService.move(dmDocument, rmFolder, "record.txt"); fileFolderService.move(dmDocument, rmFolder, "record.txt");
return dmDocument; return dmDocument;
} }
@Override @Override
public void test(NodeRef record) throws Exception public void test(NodeRef record) throws Exception
{ {
assertTrue(recordService.isRecord(record)); assertTrue(recordService.isRecord(record));
assertTrue(recordService.isFiled(record)); assertTrue(recordService.isFiled(record));
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
} }
}); });
} }
public void testFileDirectlyFromCollab() throws Exception public void testFileDirectlyFromCollab() throws Exception
{ {
doTestInTransaction(new Test<NodeRef>() doTestInTransaction(new Test<NodeRef>()
@@ -423,38 +423,38 @@ public class RecordServiceImplTest extends BaseRMTestCase
public NodeRef run() throws Exception public NodeRef run() throws Exception
{ {
assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED)); assertNull(nodeService.getProperty(dmDocument, PROP_DATE_FILED));
fileFolderService.move(dmDocument, rmFolder, "record.txt"); fileFolderService.move(dmDocument, rmFolder, "record.txt");
return dmDocument; return dmDocument;
} }
@Override @Override
public void test(NodeRef record) throws Exception public void test(NodeRef record) throws Exception
{ {
assertTrue(recordService.isRecord(record)); assertTrue(recordService.isRecord(record));
assertTrue(recordService.isFiled(record)); assertTrue(recordService.isFiled(record));
assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED)); assertNotNull(nodeService.getProperty(record, PROP_DATE_FILED));
} }
}); });
} }
private void checkPermissions(String permission, AccessStatus filePlanExpected, private void checkPermissions(String permission, AccessStatus filePlanExpected,
AccessStatus unfiledExpected, AccessStatus unfiledExpected,
AccessStatus recordCatExpected, AccessStatus recordCatExpected,
AccessStatus recordFolderExpected, AccessStatus recordFolderExpected,
AccessStatus recordExpected) AccessStatus recordExpected)
{ {
assertEquals(filePlanExpected, assertEquals(filePlanExpected,
dmPermissionService.hasPermission(filePlan, permission)); dmPermissionService.hasPermission(filePlan, permission));
assertEquals(unfiledExpected, assertEquals(unfiledExpected,
dmPermissionService.hasPermission(unfiledContainer, permission)); dmPermissionService.hasPermission(unfiledContainer, permission));
assertEquals(recordCatExpected, assertEquals(recordCatExpected,
dmPermissionService.hasPermission(rmContainer, permission)); dmPermissionService.hasPermission(rmContainer, permission));
assertEquals(recordFolderExpected, assertEquals(recordFolderExpected,
dmPermissionService.hasPermission(rmFolder, permission)); dmPermissionService.hasPermission(rmFolder, permission));
assertEquals(recordExpected, assertEquals(recordExpected,
dmPermissionService.hasPermission(dmDocument, permission)); dmPermissionService.hasPermission(dmDocument, permission));
} }
} }