mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge master into feature/RM-4199_UnitTests
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -152,15 +152,15 @@
|
||||
<regexPropertySetting>
|
||||
<name>rm.module.repo.version.min</name>
|
||||
<value>${alfresco.version}</value>
|
||||
<regex>([0-9\.]*[0-9]).*</regex>
|
||||
<replacement>$1</replacement>
|
||||
<regex>(\d+)\.(\d+).*</regex>
|
||||
<replacement>$1.$2</replacement>
|
||||
<failIfNoMatch>false</failIfNoMatch>
|
||||
</regexPropertySetting>
|
||||
<regexPropertySetting>
|
||||
<name>rm.module.version</name>
|
||||
<value>${project.version}</value>
|
||||
<regex>(\d+)\.(\d+).*</regex>
|
||||
<replacement>$1.$2</replacement>
|
||||
<regex>([0-9\.]*[0-9]).*</regex>
|
||||
<replacement>$1</replacement>
|
||||
<failIfNoMatch>false</failIfNoMatch>
|
||||
</regexPropertySetting>
|
||||
</regexPropertySettings>
|
||||
|
@@ -81,6 +81,12 @@ rm.completerecord.mandatorypropertiescheck.enabled=true
|
||||
#
|
||||
rm.patch.v22.convertToStandardFilePlan=false
|
||||
|
||||
# Permission mapping
|
||||
# these take a comma separated string of permissions from org.alfresco.service.cmr.security.PermissionService
|
||||
# read maps to ReadRecords and write to FileRecords
|
||||
rm.haspermissionmap.read=ReadProperties,ReadChildren
|
||||
rm.haspermissionmap.write=WriteProperties,AddChildren
|
||||
|
||||
#
|
||||
# Extended auto-version behaviour. If true and other auto-version properties are satisfied, then
|
||||
# a document will be auto-versioned when its type is changed.
|
||||
|
@@ -114,6 +114,12 @@
|
||||
<ref bean="extendedReaderDynamicAuthority" />
|
||||
</list>
|
||||
</property>
|
||||
<property name="configuredReadPermissions">
|
||||
<value>${rm.haspermissionmap.read}</value>
|
||||
</property>
|
||||
<property name="configuredFilePermissions">
|
||||
<value>${rm.haspermissionmap.write}</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.util.BeanExtender">
|
||||
<property name="beanName" value="permissionServiceImpl"/>
|
||||
@@ -262,4 +268,4 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
@@ -389,6 +389,11 @@
|
||||
<type>d:date</type>
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
<property name="rma:manuallySetAsOf">
|
||||
<title>Manually Set Disposition Date Flag</title>
|
||||
<type>d:boolean</type>
|
||||
<default>false</default>
|
||||
</property>
|
||||
<property name="rma:dispositionEventsEligible">
|
||||
<title>Disposition Events Eligible</title>
|
||||
<type>d:boolean</type>
|
||||
|
@@ -39,12 +39,6 @@
|
||||
|
||||
<bean id="RecordsManagementServiceRegistry" class="org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistryImpl" />
|
||||
|
||||
<!-- Disposition selection strategy -->
|
||||
<bean id="org_alfresco_module_rm_dispositionSelectionStrategy"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSelectionStrategy" >
|
||||
<property name="dispositionService" ref="dispositionService"/>
|
||||
</bean>
|
||||
|
||||
<!-- Vital Record Service -->
|
||||
|
||||
<bean id="vitalRecordService" parent="baseService" class="org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordServiceImpl">
|
||||
@@ -96,9 +90,6 @@
|
||||
<property name="recordFolderService" ref="RecordFolderService"/>
|
||||
<property name="recordService" ref="RecordService"/>
|
||||
<property name="freezeService" ref="FreezeService"/>
|
||||
<property name="dispositionSelectionStrategy">
|
||||
<ref local="org_alfresco_module_rm_dispositionSelectionStrategy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="DispositionService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
@@ -139,6 +130,7 @@
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.registerDispositionProperty=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getDispositionProperties=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getOriginDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getAssociatedDispositionSchedule=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getAssociatedRecordsManagementContainer=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.hasDisposableItems=RM_ALLOW
|
||||
|
@@ -127,6 +127,7 @@ rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockStatus=RM.Rea
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.isLockedAndReadOnly=RM.Read.0
|
||||
rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY
|
||||
|
||||
## Multilingual Content Service
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -194,7 +196,8 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
||||
{
|
||||
// the change does effect the nextAction for this node
|
||||
// so go ahead and determine what needs updating
|
||||
if (changedProps.contains(PROP_DISPOSITION_PERIOD))
|
||||
if (changedProps.contains(PROP_DISPOSITION_PERIOD)
|
||||
&& isNotTrue((Boolean) getNodeService().getProperty(nextAction.getNodeRef(), PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
persistPeriodChanges(dispositionActionDef, nextAction);
|
||||
}
|
||||
|
@@ -74,6 +74,7 @@ public class EditDispositionActionAsOfDateAction extends RMActionExecuterAbstrac
|
||||
if (da != null)
|
||||
{
|
||||
getNodeService().setProperty(da.getNodeRef(), PROP_DISPOSITION_AS_OF, asOfDate);
|
||||
getNodeService().setProperty(da.getNodeRef(), PROP_MANUALLY_SET_AS_OF, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -243,6 +243,17 @@ public interface DispositionService
|
||||
* @param nodeRef node reference
|
||||
*/
|
||||
void refreshDispositionAction(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Gets date of the disposition action for the given
|
||||
* disposition schedule with the given action name
|
||||
*
|
||||
* @param record
|
||||
* @param dispositionSchedule nodeRef
|
||||
* @param dispositionActionName
|
||||
* @return date
|
||||
*/
|
||||
Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName);
|
||||
|
||||
/**
|
||||
* Compute the "disposition as of" date (if necessary) for a disposition action and a node.
|
||||
@@ -254,4 +265,13 @@ public interface DispositionService
|
||||
*/
|
||||
Date calculateAsOfDate(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition,
|
||||
boolean allowContextFromAsOf);
|
||||
|
||||
/**
|
||||
* Gets the origin disposition schedule for the record, not the calculated one
|
||||
* in case of multiple dispositions applied to record
|
||||
*
|
||||
* @param nodeRef record
|
||||
* @return the initial disposition
|
||||
*/
|
||||
DispositionSchedule getOriginDispositionSchedule(NodeRef nodeRef);
|
||||
}
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -36,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
||||
@@ -47,6 +50,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
import org.alfresco.repo.dictionary.types.period.Immediately;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
@@ -79,15 +83,26 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
/** Logger */
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DispositionServiceImpl.class);
|
||||
|
||||
/** Transaction mode for setting next action */
|
||||
public enum WriteMode
|
||||
{
|
||||
/** Do not update any data. */
|
||||
READ_ONLY,
|
||||
/** Only set the "disposition as of" date. */
|
||||
DATE_ONLY,
|
||||
/**
|
||||
* Set the "disposition as of" date and the name of the next action. This only happens during the creation of a
|
||||
* disposition schedule impl node under a record or folder.
|
||||
*/
|
||||
DATE_AND_NAME
|
||||
};
|
||||
|
||||
/** Behaviour filter */
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
/** Records management service registry */
|
||||
private RecordsManagementServiceRegistry serviceRegistry;
|
||||
|
||||
/** Disposition selection strategy */
|
||||
private DispositionSelectionStrategy dispositionSelectionStrategy;
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
@@ -177,16 +192,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dispositionSelectionStrategy bean.
|
||||
*
|
||||
* @param dispositionSelectionStrategy
|
||||
*/
|
||||
public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy)
|
||||
{
|
||||
this.dispositionSelectionStrategy = dispositionSelectionStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Behavior to initialize the disposition schedule of a newly filed record.
|
||||
*
|
||||
@@ -276,31 +281,68 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public DispositionSchedule getDispositionSchedule(NodeRef nodeRef)
|
||||
public DispositionSchedule getDispositionSchedule(final NodeRef nodeRef)
|
||||
{
|
||||
DispositionSchedule di = null;
|
||||
NodeRef diNodeRef = null;
|
||||
DispositionSchedule ds = null;
|
||||
NodeRef dsNodeRef = null;
|
||||
if (isRecord(nodeRef))
|
||||
{
|
||||
// Get the record folders for the record
|
||||
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(nodeRef);
|
||||
// At this point, we may have disposition instruction objects from 1..n folders.
|
||||
diNodeRef = dispositionSelectionStrategy.selectDispositionScheduleFrom(recordFolders);
|
||||
DispositionSchedule originDispositionSchedule = getOriginDispositionSchedule(nodeRef);
|
||||
// if the initial disposition schedule of the record is folder based
|
||||
if (originDispositionSchedule == null ||
|
||||
isNotTrue(originDispositionSchedule.isRecordLevelDisposition()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
||||
|
||||
if (dsNextAction != null)
|
||||
{
|
||||
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
||||
if (isNotTrue((Boolean)nodeService.getProperty(action, PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
if (!dsNextAction.getWriteMode().equals(WriteMode.READ_ONLY))
|
||||
{
|
||||
final String dispositionActionName = dsNextAction.getNextActionName();
|
||||
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
|
||||
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
||||
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))
|
||||
{
|
||||
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
dsNodeRef = dsNextAction.getDispositionNodeRef();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the disposition instructions for the node reference provided
|
||||
diNodeRef = getDispositionScheduleImpl(nodeRef);
|
||||
dsNodeRef = getDispositionScheduleImpl(nodeRef);
|
||||
}
|
||||
|
||||
if (diNodeRef != null)
|
||||
if (dsNodeRef != null)
|
||||
{
|
||||
di = new DispositionScheduleImpl(serviceRegistry, nodeService, diNodeRef);
|
||||
ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
|
||||
}
|
||||
|
||||
return di;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This method returns a NodeRef
|
||||
* Gets the disposition instructions
|
||||
@@ -322,6 +364,28 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public DispositionSchedule getOriginDispositionSchedule(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef parent = this.nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||
if (parent != null)
|
||||
{
|
||||
if (filePlanService.isRecordCategory(parent))
|
||||
{
|
||||
NodeRef result = getAssociatedDispositionScheduleImpl(parent);
|
||||
if (result == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new DispositionScheduleImpl(serviceRegistry, nodeService, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getOriginDispositionSchedule(parent);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getAssociatedDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef)
|
||||
@@ -631,8 +695,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
* @param dispositionActionDefinition disposition action definition
|
||||
* @param allowContextFromAsOf true if the context date is allowed to be obtained from the disposition "as of" property.
|
||||
*/
|
||||
private void initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||
private DispositionAction initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition, boolean allowContextFromAsOf)
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
|
||||
if (childAssocs != null && childAssocs.size() > 0)
|
||||
{
|
||||
return new DispositionActionImpl(serviceRegistry, childAssocs.get(0).getChildRef());
|
||||
}
|
||||
|
||||
// Create the properties
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
|
||||
|
||||
@@ -662,6 +732,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
// For every event create an entry on the action
|
||||
da.addEventCompletionDetails(event);
|
||||
}
|
||||
return da;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -694,9 +765,16 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now use 'NOW' as the default context date
|
||||
// TODO set the default period property ... cut off date or last disposition date depending on context
|
||||
contextDate = new Date();
|
||||
if (period.getPeriodType().equals(Immediately.PERIOD_TYPE))
|
||||
{
|
||||
contextDate = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now use 'NOW' as the default context date
|
||||
// TODO set the default period property ... cut off date or last disposition date depending on context
|
||||
contextDate = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the as of date
|
||||
@@ -907,6 +985,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
// Get the current action
|
||||
String currentADId = (String) nodeService.getProperty(currentDispositionAction, PROP_DISPOSITION_ACTION_ID);
|
||||
currentDispositionActionDefinition = di.getDispositionActionDefinition(currentADId);
|
||||
|
||||
// When the record has multiple disposition schedules the current disposition action may not be found by id
|
||||
// In this case it will be searched by name
|
||||
if(currentDispositionActionDefinition == null)
|
||||
@@ -1001,6 +1080,24 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
}
|
||||
|
||||
public Date getDispositionActionDate(NodeRef record, NodeRef dispositionSchedule, String dispositionActionName)
|
||||
{
|
||||
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, dispositionSchedule);
|
||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(dispositionSchedule);
|
||||
if (assocs != null && assocs.size() > 0)
|
||||
{
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
if (assoc != null && assoc.getQName().getLocalName().contains(dispositionActionName))
|
||||
{
|
||||
DispositionActionDefinition actionDefinition = ds.getDispositionActionDefinition(assoc.getChildRef().getId());
|
||||
return calculateAsOfDate(record, actionDefinition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine if a node is frozen or has frozen children
|
||||
*
|
||||
@@ -1048,4 +1145,169 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculate next disposition action for a record
|
||||
*
|
||||
* @param record
|
||||
* @return next disposition action (name, date) and the disposition associated
|
||||
*/
|
||||
|
||||
protected NextActionFromDisposition getDispositionActionByNameForRecord(NodeRef record)
|
||||
{
|
||||
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(record);
|
||||
DispositionAction nextDispositionAction = getNextDispositionAction(record);
|
||||
|
||||
if (nextDispositionAction == null)
|
||||
{
|
||||
DispositionAction lastCompletedDispositionAction = getLastCompletedDispostionAction(record);
|
||||
if (lastCompletedDispositionAction != null)
|
||||
{
|
||||
// all disposition actions upon the given record were completed
|
||||
return null;
|
||||
}
|
||||
|
||||
return getFirstDispositionAction(record, recordFolders);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getNextDispositionAction(record, recordFolders, nextDispositionAction);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next disposition action when the record already has one
|
||||
* @param recordFolders
|
||||
* @param nextDispositionAction
|
||||
* @return next disposition action and the associated disposition schedule
|
||||
*/
|
||||
private NextActionFromDisposition getNextDispositionAction(NodeRef record, List<NodeRef> recordFolders, DispositionAction nextDispositionAction)
|
||||
{
|
||||
String recordNextDispositionActionName = nextDispositionAction.getName();
|
||||
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
||||
// We're looking for the latest date, so initially start with a very early one.
|
||||
Date nextDispositionActionDate = new Date(Long.MIN_VALUE);
|
||||
NodeRef dispositionNodeRef = null;
|
||||
|
||||
// Find the latest "disposition as of" date from all the schedules this record is subject to.
|
||||
for (NodeRef folder : recordFolders)
|
||||
{
|
||||
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
||||
if (dsNodeRef != null)
|
||||
{
|
||||
Date dispActionDate = getDispositionActionDate(record, dsNodeRef, recordNextDispositionActionName);
|
||||
if (dispActionDate == null || (nextDispositionActionDate != null
|
||||
&& nextDispositionActionDate.before(dispActionDate)))
|
||||
{
|
||||
nextDispositionActionDate = dispActionDate;
|
||||
dispositionNodeRef = dsNodeRef;
|
||||
if (dispActionDate == null)
|
||||
{
|
||||
// Treat null as the latest date possible (so stop searching further).
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dispositionNodeRef == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
WriteMode mode = determineWriteMode(recordNextDispositionActionDate, nextDispositionActionDate);
|
||||
|
||||
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
||||
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine what should be updated for an existing disposition schedule impl. We only update the date if the
|
||||
* existing date is earlier than the calculated one.
|
||||
*
|
||||
* @param recordNextDispositionActionDate The next action date found on the record node (or folder node).
|
||||
* @param nextDispositionActionDate The next action date calculated from the current disposition schedule(s)
|
||||
* affecting the node.
|
||||
* @return READ_ONLY if nothing should be updated, or DATE_ONLY if the date needs updating.
|
||||
*/
|
||||
private WriteMode determineWriteMode(Date recordNextDispositionActionDate, Date nextDispositionActionDate)
|
||||
{
|
||||
// Treat null dates as being the latest possible date.
|
||||
Date maxDate = new Date(Long.MAX_VALUE);
|
||||
Date recordDate = (recordNextDispositionActionDate != null ? recordNextDispositionActionDate : maxDate);
|
||||
Date calculatedDate = (nextDispositionActionDate != null ? nextDispositionActionDate : maxDate);
|
||||
|
||||
// We only need to update the date if the current one is too early.
|
||||
if (recordDate.before(calculatedDate))
|
||||
{
|
||||
return WriteMode.DATE_ONLY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return WriteMode.READ_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate first disposition action when the record doesn't have one
|
||||
* @param recordFolders
|
||||
* @return next disposition action and the associated disposition schedule
|
||||
*/
|
||||
private NextActionFromDisposition getFirstDispositionAction(NodeRef record, List<NodeRef> recordFolders)
|
||||
{
|
||||
NodeRef newAction = null;
|
||||
String newDispositionActionName = null;
|
||||
// We're looking for the latest date, so start with a very early one.
|
||||
Date newDispositionActionDateAsOf = new Date(Long.MIN_VALUE);
|
||||
NodeRef dispositionNodeRef = null;
|
||||
for (NodeRef folder : recordFolders)
|
||||
{
|
||||
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
||||
if (folderDS != null)
|
||||
{
|
||||
DispositionSchedule ds = new DispositionScheduleImpl(serviceRegistry, nodeService, folderDS);
|
||||
List<DispositionActionDefinition> dispositionActionDefinitions = ds.getDispositionActionDefinitions();
|
||||
|
||||
if (dispositionActionDefinitions != null && dispositionActionDefinitions.size() > 0)
|
||||
{
|
||||
DispositionActionDefinition firstDispositionActionDef = dispositionActionDefinitions.get(0);
|
||||
dispositionNodeRef = folderDS;
|
||||
|
||||
if (newAction == null)
|
||||
{
|
||||
NodeRef recordOrFolder = record;
|
||||
if (!ds.isRecordLevelDisposition())
|
||||
{
|
||||
recordOrFolder = folder;
|
||||
}
|
||||
DispositionAction firstDispositionAction = initialiseDispositionAction(recordOrFolder, firstDispositionActionDef, true);
|
||||
newAction = firstDispositionAction.getNodeRef();
|
||||
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
||||
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
||||
}
|
||||
else if (firstDispositionActionDef.getPeriod() != null)
|
||||
{
|
||||
Date firstActionDate = calculateAsOfDate(record, firstDispositionActionDef, true);
|
||||
if (firstActionDate == null || (newDispositionActionDateAsOf != null
|
||||
&& newDispositionActionDateAsOf.before(firstActionDate)))
|
||||
{
|
||||
newDispositionActionName = firstDispositionActionDef.getName();
|
||||
newDispositionActionDateAsOf = firstActionDate;
|
||||
if (firstActionDate == null)
|
||||
{
|
||||
// Treat null as the latest date possible, so there's no point searching further.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newDispositionActionName == null || dispositionNodeRef == null || newAction == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
||||
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DATE_AND_NAME);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl.WriteMode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
public class NextActionFromDisposition
|
||||
{
|
||||
public NextActionFromDisposition(NodeRef dispositionNodeRef, NodeRef nextActionNodeRef, String nextActionName, Date nextActionDateAsOf,
|
||||
WriteMode writeMode)
|
||||
{
|
||||
super();
|
||||
this.dispositionNodeRef = dispositionNodeRef;
|
||||
this.nextActionNodeRef = nextActionNodeRef;
|
||||
this.nextActionName = nextActionName;
|
||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||
this.writeMode = writeMode;
|
||||
}
|
||||
|
||||
private NodeRef dispositionNodeRef;
|
||||
|
||||
private NodeRef nextActionNodeRef;
|
||||
|
||||
private String nextActionName;
|
||||
|
||||
private Date nextActionDateAsOf;
|
||||
|
||||
private WriteMode writeMode;
|
||||
|
||||
public WriteMode getWriteMode()
|
||||
{
|
||||
return writeMode;
|
||||
}
|
||||
|
||||
public void setWriteMode(WriteMode writeMode)
|
||||
{
|
||||
this.writeMode = writeMode;
|
||||
}
|
||||
|
||||
public NodeRef getNextActionNodeRef()
|
||||
{
|
||||
return nextActionNodeRef;
|
||||
}
|
||||
|
||||
public void setNextActionNodeRef(NodeRef nextActionNodeRef)
|
||||
{
|
||||
this.nextActionNodeRef = nextActionNodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getDispositionNodeRef()
|
||||
{
|
||||
return dispositionNodeRef;
|
||||
}
|
||||
|
||||
public void setDispositionNodeRef(NodeRef dispositionNodeRef)
|
||||
{
|
||||
this.dispositionNodeRef = dispositionNodeRef;
|
||||
}
|
||||
|
||||
public String getNextActionName()
|
||||
{
|
||||
return nextActionName;
|
||||
}
|
||||
|
||||
public void setNextActionName(String nextActionName)
|
||||
{
|
||||
this.nextActionName = nextActionName;
|
||||
}
|
||||
|
||||
public Date getNextActionDateAsOf()
|
||||
{
|
||||
return nextActionDateAsOf;
|
||||
}
|
||||
|
||||
public void setNextActionDateAsOf(Date nextActionDateAsOf)
|
||||
{
|
||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||
}
|
||||
}
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.disposition.property;
|
||||
|
||||
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -220,7 +222,11 @@ public class DispositionProperty extends BaseBehaviourBean
|
||||
|
||||
// update asOf date on the disposition action based on the new property value
|
||||
NodeRef daNodeRef = dispositionAction.getNodeRef();
|
||||
nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf);
|
||||
// Don't overwrite a manually set "disposition as of" date.
|
||||
if (isNotTrue((Boolean) nodeService.getProperty(daNodeRef, PROP_MANUALLY_SET_AS_OF)))
|
||||
{
|
||||
nodeService.setProperty(daNodeRef, PROP_DISPOSITION_AS_OF, updatedAsOf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -160,6 +160,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName PROP_DISPOSITION_ACTION_ID = QName.createQName(RM_URI, "dispositionActionId");
|
||||
QName PROP_DISPOSITION_ACTION = QName.createQName(RM_URI, "dispositionAction");
|
||||
QName PROP_DISPOSITION_AS_OF = QName.createQName(RM_URI, "dispositionAsOf");
|
||||
/** A flag indicating that the "disposition as of" date has been manually set and shouldn't be changed. */
|
||||
QName PROP_MANUALLY_SET_AS_OF = QName.createQName(RM_URI, "manuallySetAsOf");
|
||||
QName PROP_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "dispositionEventsEligible");
|
||||
QName PROP_DISPOSITION_ACTION_STARTED_AT = QName.createQName(RM_URI, "dispositionActionStartedAt");
|
||||
QName PROP_DISPOSITION_ACTION_STARTED_BY = QName.createQName(RM_URI, "dispositionActionStartedBy");
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.permissions.processor.impl.PermissionPostProcessorBaseImpl;
|
||||
@@ -55,20 +57,21 @@ public class RecordsManagementPermissionPostProcessor extends PermissionPostProc
|
||||
* @see org.alfresco.repo.security.permissions.processor.PermissionPostProcessor#process(org.alfresco.service.cmr.security.AccessStatus, org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm)
|
||||
public AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm,
|
||||
List configuredReadPermissions, List configuredFilePermissions)
|
||||
{
|
||||
AccessStatus result = accessStatus;
|
||||
if (AccessStatus.DENIED.equals(accessStatus) &&
|
||||
nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
{
|
||||
// if read denied on rm artifact
|
||||
if (PermissionService.READ.equals(perm))
|
||||
if (PermissionService.READ.equals(perm) || configuredReadPermissions.contains(perm))
|
||||
{
|
||||
// check for read record
|
||||
result = permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS);
|
||||
}
|
||||
// if write deinied on rm artificat
|
||||
else if (PermissionService.WRITE.equals(perm) || PermissionService.ADD_CHILDREN.equals(perm))
|
||||
else if (PermissionService.WRITE.equals(perm) || configuredFilePermissions.contains(perm))
|
||||
{
|
||||
// check for file record
|
||||
result = permissionService.hasPermission(nodeRef, RMPermissionModel.FILE_RECORDS);
|
||||
|
@@ -45,12 +45,14 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeFileRecord;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
@@ -241,7 +243,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
/** recordable version service */
|
||||
private RecordableVersionService recordableVersionService;
|
||||
|
||||
|
||||
/** list of available record meta-data aspects and the file plan types the are applicable to */
|
||||
private Map<QName, Set<QName>> recordMetaDataAspects;
|
||||
|
||||
@@ -398,7 +400,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
this.recordableVersionService = recordableVersionService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@@ -1753,7 +1755,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
private void validateLinkConditions(NodeRef record, NodeRef recordFolder)
|
||||
{
|
||||
// ensure that the linking record folders have compatible disposition schedules
|
||||
DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record);
|
||||
|
||||
// get the origin disposition schedule for the record, not the calculated one
|
||||
DispositionSchedule recordDispositionSchedule = dispositionService.getOriginDispositionSchedule(record);
|
||||
|
||||
if (recordDispositionSchedule != null)
|
||||
{
|
||||
DispositionSchedule recordFolderDispositionSchedule = dispositionService.getDispositionSchedule(recordFolder);
|
||||
|
@@ -30,6 +30,7 @@ package org.alfresco.repo.security.permissions.impl;
|
||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -40,6 +41,7 @@ import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
|
||||
import org.alfresco.repo.security.permissions.AccessControlEntry;
|
||||
import org.alfresco.repo.security.permissions.AccessControlList;
|
||||
import org.alfresco.repo.security.permissions.processor.PermissionPostProcessor;
|
||||
@@ -55,6 +57,7 @@ import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Extends the core permission service implementation allowing the consideration of the read records permission.
|
||||
* <p>
|
||||
@@ -67,6 +70,20 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
|
||||
/** Writers simple cache */
|
||||
protected SimpleCache<Serializable, Set<String>> writersCache;
|
||||
|
||||
/**
|
||||
* Configured Permission mapping.
|
||||
* <p>
|
||||
* This string comes from alfresco-global.properties and allows fine tuning of the how permissions are mapped.
|
||||
* This was added as a fix for MNT-16852 to enhance compatibility with our Outlook Integration.
|
||||
*/
|
||||
protected List<String> configuredReadPermissions;
|
||||
/**
|
||||
* Configured Permission mapping.
|
||||
* <p>
|
||||
* This string also comes from alfresco-global.properties.
|
||||
*/
|
||||
protected List<String> configuredFilePermissions;
|
||||
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
@@ -124,6 +141,28 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
|
||||
this.writersCache = writersCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the string from the properties file (rm.haspermissionmap.read)
|
||||
* to the list used in the hasPermission method
|
||||
*
|
||||
* @param readMapping the mapping of permissions to ReadRecord
|
||||
*/
|
||||
public void setConfiguredReadPermissions(String readMapping)
|
||||
{
|
||||
this.configuredReadPermissions = Arrays.asList(readMapping.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the string set in the properties file (rm.haspermissionmap.write)
|
||||
* to the list used in the hasPermission method
|
||||
*
|
||||
* @param fileMapping the mapping of permissions to FileRecord
|
||||
*/
|
||||
public void setConfiguredFilePermissions(String fileMapping)
|
||||
{
|
||||
this.configuredFilePermissions = Arrays.asList(fileMapping.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.security.permissions.impl.PermissionServiceImpl#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@@ -166,7 +205,7 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
|
||||
for (PermissionPostProcessor postProcessor : postProcessors)
|
||||
{
|
||||
// post process permission
|
||||
result = postProcessor.process(result, nodeRef, perm);
|
||||
result = postProcessor.process(result, nodeRef, perm, this.configuredReadPermissions, this.configuredFilePermissions);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.repo.security.permissions.processor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
|
||||
@@ -46,7 +48,9 @@ public interface PermissionPostProcessor
|
||||
* @param accessStatus current access status
|
||||
* @param nodeRef node reference
|
||||
* @param perm permission
|
||||
*
|
||||
* @return {@link AccessStatus}
|
||||
*/
|
||||
AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm);
|
||||
AccessStatus process(AccessStatus accessStatus, NodeRef nodeRef, String perm,
|
||||
List configuredReadPermissions, List configuredFilePermissions);
|
||||
}
|
||||
|
@@ -37,9 +37,14 @@ import org.alfresco.rest.api.Nodes;
|
||||
*/
|
||||
public interface RMNodes extends Nodes
|
||||
{
|
||||
String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
|
||||
String PARAM_INCLUDE_IS_CLOSED = "isClosed";
|
||||
String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
|
||||
public static String PATH_FILE_PLAN = "-filePlan-";
|
||||
public static String PATH_TRANSFERS = "-transfers-";
|
||||
public static String PATH_UNFILED = "-unfiled-";
|
||||
public static String PATH_HOLDS = "-holds-";
|
||||
|
||||
public static String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
|
||||
public static String PARAM_INCLUDE_IS_CLOSED = "isClosed";
|
||||
public static String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
|
||||
|
||||
/**
|
||||
* Identifies if one node is RM site node.
|
||||
|
@@ -74,11 +74,6 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
{
|
||||
String FILE_PLAN = "-filePlan-";
|
||||
String TRANSFERS = "-transfers-";
|
||||
String UNFILED = "-unfiled-";
|
||||
String HOLDS = "-holds-";
|
||||
|
||||
private enum RMNodeType
|
||||
{
|
||||
// Note: ordered
|
||||
@@ -213,7 +208,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
throw new InvalidArgumentException("Missing nodeId");
|
||||
}
|
||||
|
||||
if (nodeId.equals(FILE_PLAN))
|
||||
if (nodeId.equals(PATH_FILE_PLAN))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
@@ -225,7 +220,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(TRANSFERS))
|
||||
else if (nodeId.equals(PATH_TRANSFERS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
@@ -237,7 +232,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(UNFILED))
|
||||
else if (nodeId.equals(PATH_UNFILED))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
@@ -249,7 +244,7 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(HOLDS))
|
||||
else if (nodeId.equals(PATH_HOLDS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
|
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance REST API
|
||||
* Package info that defines the Information Governance Nodes REST API
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
|
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Integration tests for records linked to multiple disposition schedules.
|
||||
*
|
||||
* @author Tom Page
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public class MultipleSchedulesTest extends BaseRMTestCase
|
||||
{
|
||||
/** A unique prefix for the constants in this test. */
|
||||
protected static final String TEST_PREFIX = MultipleSchedulesTest.class.getName() + GUID.generate() + "_";
|
||||
/** The name to use for the first category. */
|
||||
protected static final String CATEGORY_A_NAME = TEST_PREFIX + "CategoryA";
|
||||
/** The name to use for the folder within the first category. */
|
||||
protected static final String FOLDER_A_NAME = TEST_PREFIX + "FolderA";
|
||||
/** The name to use for the second category. */
|
||||
protected static final String CATEGORY_B_NAME = TEST_PREFIX + "CategoryB";
|
||||
/** The name to use for the folder within the second category. */
|
||||
protected static final String FOLDER_B_NAME = TEST_PREFIX + "FolderB";
|
||||
/** The name to use for the record. */
|
||||
protected static final String RECORD_NAME = TEST_PREFIX + "Record";
|
||||
|
||||
/** The internal disposition service is used to avoid permissions issues when updating the record. */
|
||||
private DispositionService internalDispositionService;
|
||||
|
||||
/** The first category node. */
|
||||
private NodeRef categoryA;
|
||||
/** The folder node within the first category. */
|
||||
private NodeRef folderA;
|
||||
/** The second category node. */
|
||||
private NodeRef categoryB;
|
||||
/** The folder node within the second category. */
|
||||
private NodeRef folderB;
|
||||
/** The record node. */
|
||||
private NodeRef record;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
BehaviourTest.initBehaviourTests(retryingTransactionHelper);
|
||||
|
||||
// Get the application context
|
||||
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||
internalDispositionService = (DispositionService) applicationContext.getBean("dispositionService");
|
||||
|
||||
// Ensure different records are used for each test.
|
||||
record = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create two categories each containing a folder. Set up a schedule on category A that applies to records (cutoff
|
||||
* immediately, destroy immediately). Set up a schedule on category B that is the same, but with a week delay before
|
||||
* destroy becomes eligible.
|
||||
*/
|
||||
private void setUpFilePlan()
|
||||
{
|
||||
// Only set up the file plan if it hasn't already been done.
|
||||
if (categoryA != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create two categories.
|
||||
categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME);
|
||||
categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME);
|
||||
// Create a disposition schedule for category A (Cut off immediately, then Destroy immediately).
|
||||
DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false);
|
||||
Map<QName, Serializable> cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedA, cutOffParamsA);
|
||||
Map<QName, Serializable> destroyParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedA, destroyParamsA);
|
||||
// Create a disposition schedule for category B (Cut off immediately, then Destroy one week after cutoff).
|
||||
DispositionSchedule dispSchedB = utils.createBasicDispositionSchedule(categoryB, "instructions", "authority", true, false);
|
||||
Map<QName, Serializable> cutOffParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedB, cutOffParamsB);
|
||||
Map<QName, Serializable> destroyParamsB = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME,
|
||||
PROP_DISPOSITION_DESCRIPTION, "description",
|
||||
PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK,
|
||||
PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE);
|
||||
dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB);
|
||||
// Create a folder within each category.
|
||||
folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME);
|
||||
folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
|
||||
* <p><pre>
|
||||
* Given a record subject to a disposition schedule
|
||||
* And it is linked to a disposition schedule with the same step order, but a longer destroy step
|
||||
* When the record is moved onto the destroy step
|
||||
* Then the "as of" date is calculated using the longer period.
|
||||
* </pre>
|
||||
*/
|
||||
public void testLinkedToLongerSchedule()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
test()
|
||||
.given(() -> {
|
||||
setUpFilePlan();
|
||||
// Create a record filed under category A and linked to category B.
|
||||
record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
recordService.link(record, folderB);
|
||||
})
|
||||
.when(() -> {
|
||||
// Cut off the record.
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
// Ensure the update has been applied to the record.
|
||||
internalDispositionService.updateNextDispositionAction(record);
|
||||
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, 1);
|
||||
})
|
||||
.then()
|
||||
.expect(calendar.getTime())
|
||||
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
|
||||
.because("Record should follow largest rentention schedule period, which is one week.");
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://issues.alfresco.com/jira/browse/RM-2526">RM-2526</a>
|
||||
* <p><pre>
|
||||
* Given a record subject to a disposition schedule
|
||||
* And it is linked to a disposition schedule with the same step order, but a shorter destroy step
|
||||
* When the record is moved onto the destroy step
|
||||
* Then the "as of" date is calculated using the longer period.
|
||||
* </pre>
|
||||
*/
|
||||
public void testLinkedToShorterSchedule()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
test()
|
||||
.given(() -> {
|
||||
setUpFilePlan();
|
||||
// Create a record filed under category B and linked to category A.
|
||||
record = fileFolderService.create(folderB, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
|
||||
recordService.link(record, folderA);
|
||||
})
|
||||
.when(() -> {
|
||||
// Cut off the record.
|
||||
dispositionService.cutoffDisposableItem(record);
|
||||
// Ensure the update has been applied to the record.
|
||||
internalDispositionService.updateNextDispositionAction(record);
|
||||
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, 1);
|
||||
})
|
||||
.then()
|
||||
.expect(calendar.getTime())
|
||||
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
|
||||
.because("Record should follow largest rentention schedule period, which is one week.");
|
||||
}
|
||||
}
|
@@ -44,6 +44,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.impl.EditDispositionAct
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@@ -51,7 +52,7 @@ import org.alfresco.service.namespace.QName;
|
||||
* Update next disposition step integration tests.
|
||||
*
|
||||
* @author Roxana Lucanu
|
||||
* @since 2.4.1
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public class UpdateNextDispositionActionTest extends BaseRMTestCase
|
||||
{
|
||||
@@ -103,11 +104,6 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
|
||||
// complete record
|
||||
utils.completeRecord(record);
|
||||
|
||||
// set the disposition as of date to now on the record
|
||||
rmActionService.executeRecordsManagementAction(record,
|
||||
EditDispositionActionAsOfDateAction.NAME,
|
||||
Collections.singletonMap(EditDispositionActionAsOfDateAction.PARAM_AS_OF_DATE, new Date()));
|
||||
|
||||
// cut off
|
||||
rmActionService.executeRecordsManagementAction(record, CutOffAction.NAME, null);
|
||||
}
|
||||
@@ -115,7 +111,7 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
assertTrue(nodeService.hasAspect(record, ASPECT_CUT_OFF));
|
||||
assertTrue("Record " + record + " doesn't have the cutOff aspect.", nodeService.hasAspect(record, ASPECT_CUT_OFF));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -128,7 +124,7 @@ public class UpdateNextDispositionActionTest extends BaseRMTestCase
|
||||
Map<QName, Serializable> cutOff = new HashMap<QName, Serializable>(3);
|
||||
cutOff.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||
cutOff.put(PROP_DISPOSITION_DESCRIPTION, generate());
|
||||
cutOff.put(PROP_DISPOSITION_PERIOD, PERIOD_ONE_WEEK);
|
||||
cutOff.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
|
||||
dispositionService.addDispositionActionDefinition(ds, cutOff);
|
||||
|
||||
// create the properties for TRANSFER action and add it to the disposition action definition
|
||||
|
@@ -666,7 +666,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
|
||||
checkDisposableItemChanged(mhRecordFolder42);
|
||||
checkDisposableItemChanged(record43);
|
||||
checkDisposableItemUnchanged(mhRecordFolder44);
|
||||
checkDisposableItemUnchanged(record45);;
|
||||
checkDisposableItemUnchanged(record45);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.permission;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RecordsManagementPermissionPostProcessor}.
|
||||
*
|
||||
* @author David Webster
|
||||
* @since 2.4.1
|
||||
*/
|
||||
public class RecordsManagementPermissionPostProcessorUnitTest
|
||||
{
|
||||
|
||||
private @InjectMocks
|
||||
RecordsManagementPermissionPostProcessor recordsManagementPermissionPostProcessor = new RecordsManagementPermissionPostProcessor();
|
||||
|
||||
private @Mock NodeService nodeService;
|
||||
private @Mock PermissionService permissionService;
|
||||
|
||||
@Before
|
||||
public void setup()
|
||||
{
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the configured permissions are set
|
||||
* When process is called
|
||||
* Then access is allowed
|
||||
*/
|
||||
@Test
|
||||
public void configurePermissionsAllowed()
|
||||
{
|
||||
AccessStatus accessStatus = AccessStatus.DENIED;
|
||||
NodeRef nodeRef = new NodeRef("node://ref/");
|
||||
String perm = AlfMock.generateText();
|
||||
// permissions includes the perm created above
|
||||
List<String> configuredReadPermissions = asList("ReadProperties", "ReadChildren", perm);
|
||||
List<String> configuredFilePermissions = asList("WriteProperties", "AddChildren");
|
||||
|
||||
when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
.thenReturn(true);
|
||||
when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
|
||||
|
||||
assertEquals(AccessStatus.ALLOWED, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the configured permissions are not set
|
||||
* When process is called
|
||||
* Then access is denied
|
||||
*/
|
||||
@Test
|
||||
public void configurePermissionsDenied()
|
||||
{
|
||||
AccessStatus accessStatus = AccessStatus.DENIED;
|
||||
NodeRef nodeRef = new NodeRef("node://ref/");
|
||||
String perm = AlfMock.generateText();
|
||||
// permissions do not include perm created above
|
||||
List<String> configuredReadPermissions = asList("ReadProperties", "ReadChildren");
|
||||
List<String> configuredFilePermissions = asList("WriteProperties", "AddChildren");
|
||||
|
||||
when(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT))
|
||||
.thenReturn(true);
|
||||
when(permissionService.hasPermission(nodeRef, RMPermissionModel.READ_RECORDS))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
AccessStatus result = recordsManagementPermissionPostProcessor.process(accessStatus, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
|
||||
|
||||
assertEquals(AccessStatus.DENIED, result);
|
||||
}
|
||||
}
|
@@ -274,7 +274,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
|
||||
DispositionSchedule recordDispositionSchedule = mock(DispositionSchedule.class);
|
||||
when(recordDispositionSchedule.isRecordLevelDisposition())
|
||||
.thenReturn(true);
|
||||
when(mockedDispositionService.getDispositionSchedule(record))
|
||||
when(mockedDispositionService.getOriginDispositionSchedule(record))
|
||||
.thenReturn(recordDispositionSchedule);
|
||||
|
||||
DispositionSchedule recordFolderDispositionSchedule = mock(DispositionSchedule.class);
|
||||
|
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -146,15 +147,21 @@ public class ExtendedPermissionServiceImplUnitTest extends BaseUnitTest
|
||||
{
|
||||
NodeRef nodeRef = generateCmContent("anyname");
|
||||
String perm = AlfMock.generateText();
|
||||
List<String> configuredReadPermissions = asList("ReadProperties", "ReadChildren");
|
||||
List<String> configuredFilePermissions = asList("WriteProperties", "AddChildren");
|
||||
|
||||
extendedPermissionServiceImpl.setConfiguredReadPermissions("ReadProperties,ReadChildren");
|
||||
extendedPermissionServiceImpl.setConfiguredFilePermissions("WriteProperties,AddChildren");
|
||||
|
||||
when(mockedPermissionProcessorRegistry.getPermissionPostProcessors())
|
||||
.thenReturn(asList(mockedPermissionPostProcessor));
|
||||
when(mockedPermissionPostProcessor.process(AccessStatus.UNDETERMINED, nodeRef, perm))
|
||||
when(mockedPermissionPostProcessor.process(AccessStatus.UNDETERMINED, nodeRef, perm, configuredReadPermissions, configuredFilePermissions))
|
||||
.thenReturn(AccessStatus.ALLOWED);
|
||||
|
||||
AccessStatus result = extendedPermissionServiceImpl.hasPermission(nodeRef, perm);
|
||||
|
||||
assertEquals(AccessStatus.ALLOWED, result);
|
||||
verify(mockedPermissionPostProcessor).process(AccessStatus.UNDETERMINED, nodeRef, perm);
|
||||
verify(mockedPermissionPostProcessor).process(AccessStatus.UNDETERMINED, nodeRef, perm, configuredReadPermissions, configuredFilePermissions);
|
||||
verify(extendedPermissionServiceImpl).hasPermissionImpl(nodeRef, perm);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user