use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class DispositionAbstractBase method getDispositionScheduleModel.
/**
* Helper method to parse the request and retrieve the disposition schedule model.
*
* @param req The webscript request
* @return Map representing the model
*/
protected Map<String, Object> getDispositionScheduleModel(WebScriptRequest req) {
// parse the request to retrieve the schedule object
DispositionSchedule schedule = parseRequestForSchedule(req);
// add all the schedule data to Map
Map<String, Object> scheduleModel = new HashMap<String, Object>(8);
// build url
String serviceUrl = req.getServiceContextPath() + req.getPathInfo();
scheduleModel.put("url", serviceUrl);
String actionsUrl = serviceUrl + "/dispositionactiondefinitions";
scheduleModel.put("actionsUrl", actionsUrl);
scheduleModel.put("nodeRef", schedule.getNodeRef().toString());
scheduleModel.put("recordLevelDisposition", schedule.isRecordLevelDisposition());
scheduleModel.put("canStepsBeRemoved", !getDispositionService().hasDisposableItems(schedule));
if (schedule.getDispositionAuthority() != null) {
scheduleModel.put("authority", schedule.getDispositionAuthority());
}
if (schedule.getDispositionInstructions() != null) {
scheduleModel.put("instructions", schedule.getDispositionInstructions());
}
boolean unpublishedUpdates = false;
boolean publishInProgress = false;
List<Map<String, Object>> actions = new ArrayList<Map<String, Object>>();
for (DispositionActionDefinition actionDef : schedule.getDispositionActionDefinitions()) {
NodeRef actionDefNodeRef = actionDef.getNodeRef();
if (getNodeService().hasAspect(actionDefNodeRef, RecordsManagementModel.ASPECT_UNPUBLISHED_UPDATE)) {
unpublishedUpdates = true;
publishInProgress = ((Boolean) getNodeService().getProperty(actionDefNodeRef, RecordsManagementModel.PROP_PUBLISH_IN_PROGRESS)).booleanValue();
}
actions.add(createActionDefModel(actionDef, actionsUrl + "/" + actionDef.getId()));
}
scheduleModel.put("actions", actions);
scheduleModel.put("unpublishedUpdates", unpublishedUpdates);
scheduleModel.put("publishInProgress", publishInProgress);
// create model object with just the schedule data
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("schedule", scheduleModel);
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class DispositionAbstractBase method parseRequestForActionDefinition.
/**
* Parses the request and providing it's valid returns the DispositionActionDefinition object.
*
* @param req The webscript request
* @param schedule The disposition schedule
* @return The DispositionActionDefinition object the request is aimed at
*/
protected DispositionActionDefinition parseRequestForActionDefinition(WebScriptRequest req, DispositionSchedule schedule) {
// make sure the requested action definition exists
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String actionDefId = templateVars.get("action_def_id");
DispositionActionDefinition actionDef = schedule.getDispositionActionDefinition(actionDefId);
if (actionDef == null) {
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Requested disposition action definition (id:" + actionDefId + ") does not exist");
}
return actionDef;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class DispositionActionDefinitionPost method executeImpl.
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
// parse the request to retrieve the schedule object
DispositionSchedule schedule = parseRequestForSchedule(req);
// retrieve the rest of the post body and create the action
// definition
JSONObject json = null;
DispositionActionDefinition actionDef = null;
try {
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
actionDef = createActionDefinition(json, schedule);
} catch (IOException iox) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
}
// create model object with just the action data
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("action", createActionDefModel(actionDef, req.getURL() + "/" + actionDef.getId()));
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class TransferServiceImpl method transfer.
/**
* @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean)
*/
@Override
public NodeRef transfer(NodeRef nodeRef, boolean isAccession) {
ParameterCheck.mandatory("nodeRef", nodeRef);
// Get the root rm node
NodeRef root = filePlanService.getFilePlan(nodeRef);
// Get the transfer object
NodeRef transferNodeRef = (NodeRef) AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF);
if (transferNodeRef == null) {
// Calculate a transfer name
QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid);
String transferName = StringUtils.leftPad(dbId.toString(), 10, "0");
// Create the transfer object
Map<QName, Serializable> transferProps = new HashMap<QName, Serializable>(2);
transferProps.put(ContentModel.PROP_NAME, transferName);
transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, isAccession);
// setup location property from disposition schedule
DispositionAction da = dispositionService.getNextDispositionAction(nodeRef);
if (da != null) {
DispositionActionDefinition actionDef = da.getDispositionActionDefinition();
if (actionDef != null) {
transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation());
}
}
NodeRef transferContainer = filePlanService.getTransferContainer(root);
transferContainerType.disable();
transferType.disable();
try {
transferNodeRef = nodeService.createNode(transferContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, transferName), TYPE_TRANSFER, transferProps).getChildRef();
} finally {
transferContainerType.enable();
transferType.enable();
}
// Bind the hold node reference to the transaction
AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);
} else {
// ensure this node has not already in the process of being transferred
List<ChildAssociationRef> transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
for (ChildAssociationRef car : transferredAlready) {
if (car.getChildRef().equals(nodeRef)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, nodeRef.toString()));
}
}
}
// Link the record to the trasnfer object
transferType.disable();
try {
nodeService.addChild(transferNodeRef, nodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
// Set PDF indicator flag
setPDFIndicationFlag(transferNodeRef, nodeRef);
} finally {
transferType.enable();
}
// Set the transferring indicator aspect
nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null);
if (isRecordFolder(nodeRef)) {
// add the transferring indicator aspect to all the child records
for (NodeRef record : recordService.getRecords(nodeRef)) {
nodeService.addAspect(record, ASPECT_TRANSFERRING, null);
}
}
return transferNodeRef;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition in project records-management by Alfresco.
the class UpdateDispositionScheduleTest method testUpdatePeriod.
/**
* <a href="https://issues.alfresco.com/jira/browse/RM-3386">RM-3386</a>
* <p><pre>
* Given a record subject to a disposition schedule
* And the next step is due to run at some period after the date the content was created
* When I update the period of the next step (and wait for this to be processed)
* Then the "as of" date is updated to be at the new period after the creation date.
* </pre>
*/
public void testUpdatePeriod() {
test().given(() -> {
// Create a category.
category = filePlanService.createRecordCategory(filePlan, CATEGORY_NAME);
// Create a disposition schedule for the category (Cut off immediately, then Destroy 1 year after the creation date).
DispositionSchedule dispSched = utils.createBasicDispositionSchedule(category, "instructions", "authority", true, false);
Map<QName, Serializable> cutOffParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
dispositionService.addDispositionActionDefinition(dispSched, cutOffParams);
Map<QName, Serializable> destroyParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_YEAR, PROP_DISPOSITION_PERIOD_PROPERTY, ContentModel.PROP_CREATED);
dispositionService.addDispositionActionDefinition(dispSched, destroyParams);
// Create a folder containing a record within the category.
folder = recordFolderService.createRecordFolder(category, FOLDER_NAME);
record = fileFolderService.create(folder, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
dispositionService.cutoffDisposableItem(record);
// Ensure the update has been applied to the record.
internalDispositionService.updateNextDispositionAction(record);
originalAsOfDate = dispositionService.getNextDispositionAction(record).getAsOfDate();
}).when(() -> {
// Update the Destroy step to be 3 years after the creation date.
DispositionSchedule dispSched = dispositionService.getDispositionSchedule(category);
DispositionActionDefinition destroy = dispSched.getDispositionActionDefinitionByName(DestroyAction.NAME);
Map<QName, Serializable> destroyParams = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, PROP_DISPOSITION_DESCRIPTION, "description", PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_THREE_YEARS, PROP_DISPOSITION_PERIOD_PROPERTY, ContentModel.PROP_CREATED);
dispositionService.updateDispositionActionDefinition(destroy, destroyParams);
// Make the disposition action definition update job run.
dispositionActionDefinitionPublishExecutor.publish(destroy.getNodeRef());
}).then().expect(true).from(() -> aboutTwoYearsApart(originalAsOfDate, dispositionService.getNextDispositionAction(record).getAsOfDate())).because("Increasing the destroy period by two years should increase the 'as of' date by two years.");
}
Aggregations