mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge remote-tracking branch 'remotes/origin/master' into xperimental/RM-6313UpgradeRMSchedulers_remote
This commit is contained in:
@@ -35,11 +35,13 @@ 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.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.slingshot.RMSearchGet;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -328,6 +330,12 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue);
|
||||
services.getNodeService().setProperties(eventNodeRef, props);
|
||||
|
||||
// check a specific event from rmEventConfigBootstrap.json
|
||||
if (eventName.equals("declassification_review"))
|
||||
{
|
||||
setDeclassificationReview(eventNodeRef, completedAtValue, completedByValue);
|
||||
}
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEligible();
|
||||
|
||||
@@ -518,4 +526,38 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
|
||||
return eligible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets declassification review authority and date on records and record folder
|
||||
*
|
||||
* @param eventNodeRef Declassification review event node ref
|
||||
* @param completedAtValue Declassification review authority
|
||||
* @param completedByValue Declassification review date
|
||||
*/
|
||||
private void setDeclassificationReview(NodeRef eventNodeRef, Date completedAtValue, String completedByValue)
|
||||
{
|
||||
NodeRef nextDispositionActionNodeRef = services.getNodeService().getPrimaryParent(eventNodeRef).getParentRef();
|
||||
NodeRef nodeRef = services.getNodeService().getPrimaryParent(nextDispositionActionNodeRef).getParentRef();
|
||||
setPropsOnContent(nodeRef, completedAtValue, completedByValue);
|
||||
|
||||
// check if the node is a record folder then set the declassification review on the records also
|
||||
if (services.getNodeService().getType(nodeRef).equals(RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
// get all the records inside the record folder
|
||||
List<ChildAssociationRef> records = services.getNodeService().getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef child : records)
|
||||
{
|
||||
NodeRef recordNodeRef = child.getChildRef();
|
||||
setPropsOnContent(recordNodeRef, completedAtValue, completedByValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setPropsOnContent(NodeRef nodeRef, Date completedAtValue, String completedByValue)
|
||||
{
|
||||
Map<QName, Serializable> nodeProps = services.getNodeService().getProperties(nodeRef);
|
||||
nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT, completedAtValue);
|
||||
nodeProps.put(PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY, completedByValue);
|
||||
services.getNodeService().setProperties(nodeRef, nodeProps);
|
||||
}
|
||||
}
|
||||
|
@@ -482,8 +482,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
|
||||
{
|
||||
if(!details.isEventComplete())
|
||||
{
|
||||
((HashMap) rmNodeValues.get("properties")).put("combineDispositionStepConditions", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_COMBINE_DISPOSITION_STEP_CONDITIONS));
|
||||
((HashMap) rmNodeValues.get("properties")).put("incompleteDispositionEvent", details.getEventName());
|
||||
HashMap properties = ((HashMap) rmNodeValues.get("properties"));
|
||||
properties.put("combineDispositionStepConditions", nodeService.getProperty(dispositionService.getNextDispositionAction(nodeRef).getDispositionActionDefinition().getNodeRef(), PROP_COMBINE_DISPOSITION_STEP_CONDITIONS));
|
||||
properties.put("incompleteDispositionEvent", details.getEventName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -240,7 +240,6 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName PROP_RS_DISPOSITION_ACTION_AS_OF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");
|
||||
QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible");
|
||||
QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents");
|
||||
QName PROP_DISPOSITION_EVENTS = QName.createQName(RM_URI, "dispositionEvents");
|
||||
QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod");
|
||||
QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression");
|
||||
QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod");
|
||||
@@ -248,6 +247,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
|
||||
QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule");
|
||||
QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions");
|
||||
QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority");
|
||||
QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_AT = QName.createQName(RM_URI, "declassificationReviewCompletedAt");
|
||||
QName PROP_RS_DECLASSIFICATION_REVIEW_COMPLETED_BY = QName.createQName(RM_URI, "declassificationReviewCompletedBy");
|
||||
/** @depreacted as of 2.2, because disposable items can now be in multiple holds */
|
||||
@Deprecated
|
||||
QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason");
|
||||
|
@@ -51,6 +51,8 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
*/
|
||||
public class DispositionAbstractBase extends AbstractRmWebScript
|
||||
{
|
||||
|
||||
public final static String COMBINE_DISPOSITION_STEP_CONDITIONS = "combineDispositionStepConditions";
|
||||
/**
|
||||
* Parses the request and providing it's valid returns the DispositionSchedule object.
|
||||
*
|
||||
|
@@ -133,10 +133,10 @@ public class DispositionActionDefinitionPost extends DispositionAbstractBase
|
||||
json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and");
|
||||
}
|
||||
|
||||
if (json.has("combineDispositionStepConditions"))
|
||||
if (json.has(COMBINE_DISPOSITION_STEP_CONDITIONS))
|
||||
{
|
||||
props.put(RecordsManagementModel.PROP_COMBINE_DISPOSITION_STEP_CONDITIONS,
|
||||
json.getBoolean("combineDispositionStepConditions"));
|
||||
json.getBoolean(COMBINE_DISPOSITION_STEP_CONDITIONS));
|
||||
}
|
||||
|
||||
if (json.has("location"))
|
||||
|
@@ -131,10 +131,10 @@ public class DispositionActionDefinitionPut extends DispositionAbstractBase
|
||||
json.getBoolean("eligibleOnFirstCompleteEvent") ? "or" : "and");
|
||||
}
|
||||
|
||||
if (json.has("combineDispositionStepConditions"))
|
||||
if (json.has(COMBINE_DISPOSITION_STEP_CONDITIONS))
|
||||
{
|
||||
props.put(RecordsManagementModel.PROP_COMBINE_DISPOSITION_STEP_CONDITIONS,
|
||||
json.getBoolean("combineDispositionStepConditions"));
|
||||
json.getBoolean(COMBINE_DISPOSITION_STEP_CONDITIONS));
|
||||
}
|
||||
|
||||
if (json.has("location"))
|
||||
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2018 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.script.slingshot;
|
||||
|
||||
import static org.alfresco.model.ContentModel.PROP_NAME;
|
||||
import static org.alfresco.service.namespace.QName.createQName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Method to replace the plain text classification reason id with the correct nodeRef during record search
|
||||
* @author Ross Gale
|
||||
* @since 2.7
|
||||
*/
|
||||
public class ClassificationReasonsUtil extends SearchUtil
|
||||
{
|
||||
|
||||
public static final String CR_URI = "http://www.alfresco.org/model/securitymarks/1.0";
|
||||
public static final QName CLASSIFICATION_REASONS_CONTAINER = createQName(CR_URI,"classificationReasonsContainer");
|
||||
public static final QName PROP_CLASSIFICATION_REASON_CODE = createQName(CR_URI, "classificationReasonCode");
|
||||
public static final String REASONS_KEY = "clf:classificationReasons:";
|
||||
|
||||
/**
|
||||
* Replace plain text reason id with nodeRef
|
||||
* @param searchQuery String e.g. clf:classificationReasons:1.4(a)
|
||||
* @return String e.g. clf:classificationReasons:5cc6d344-fa94-4370-9c81-d947b7e8f2ac
|
||||
*/
|
||||
public String replaceReasonWithNodeRef(String searchQuery)
|
||||
{
|
||||
List<String> queries = new ArrayList<>(Arrays.asList(searchQuery.split(" ")));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String queryToEdit : queries)
|
||||
{
|
||||
if(queryToEdit.contains(REASONS_KEY))
|
||||
{
|
||||
for (String reasonId : retrieveAllNodeIds(getRootContainer(CLASSIFICATION_REASONS_CONTAINER)))
|
||||
{
|
||||
NodeRef reasonNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, reasonId);
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(reasonNodeRef);
|
||||
if (queryToEdit.equals(REASONS_KEY + properties.get(PROP_CLASSIFICATION_REASON_CODE).toString()) ||
|
||||
queryToEdit.equals(REASONS_KEY +"\""+ properties.get(PROP_CLASSIFICATION_REASON_CODE).toString() + "\""))
|
||||
{
|
||||
queryToEdit = REASONS_KEY + properties.get(PROP_NAME).toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuilder.append(queryToEdit).append(" ");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -27,6 +27,8 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.slingshot;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.script.slingshot.ClassificationReasonsUtil.REASONS_KEY;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
@@ -103,6 +105,9 @@ public class RMSearchGet extends DeclarativeWebScript
|
||||
/** Utility class for record categories */
|
||||
private RecordCategoryUtil recordCategoryUtil;
|
||||
|
||||
/** Utility class for classification reasons (enterprise only) */
|
||||
private ClassificationReasonsUtil classificationReasonsUtil;
|
||||
|
||||
/**
|
||||
* @param recordsManagementSearchService records management search service
|
||||
*/
|
||||
@@ -159,6 +164,11 @@ public class RMSearchGet extends DeclarativeWebScript
|
||||
this.recordCategoryUtil = recordCategoryUtil;
|
||||
}
|
||||
|
||||
public void setClassificationReasonsUtil(ClassificationReasonsUtil classificationReasonsUtil)
|
||||
{
|
||||
this.classificationReasonsUtil = classificationReasonsUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param personService person service
|
||||
*/
|
||||
@@ -198,6 +208,12 @@ public class RMSearchGet extends DeclarativeWebScript
|
||||
String filters = req.getParameter(PARAM_FILTERS);
|
||||
// TODO this is optional
|
||||
|
||||
//Replace any plain text reason ids with the appropriate node reference
|
||||
if(query.contains(REASONS_KEY))
|
||||
{
|
||||
query = classificationReasonsUtil.replaceReasonWithNodeRef(query);
|
||||
}
|
||||
|
||||
// Convert into a rm search parameter object
|
||||
RecordsManagementSearchParameters searchParameters =
|
||||
SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService);
|
||||
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2018 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.script.slingshot;
|
||||
|
||||
import static org.alfresco.model.ContentModel.ASSOC_CHILDREN;
|
||||
import static org.alfresco.model.ContentModel.TYPE_CONTAINER;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Parent class for records search utilities
|
||||
*
|
||||
* @author Ross Gale
|
||||
* @since 2.7
|
||||
*/
|
||||
public class SearchUtil
|
||||
{
|
||||
/**
|
||||
* Node service
|
||||
*/
|
||||
protected NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Setter for node service
|
||||
*
|
||||
* @param nodeService Node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a container node ref and return the nodeIds of the contents
|
||||
*
|
||||
* @param nodeRef container
|
||||
* @return list of nodeIds
|
||||
*/
|
||||
protected Set<String> retrieveAllNodeIds(NodeRef nodeRef)
|
||||
{
|
||||
List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(nodeRef);
|
||||
return childAssocRefs.stream().map(assoc -> assoc.getChildRef().getId()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the classification reason root container.
|
||||
* The method creates the container if it doesn't already exist.
|
||||
*
|
||||
* @return reference to the classification reason root container
|
||||
*/
|
||||
protected NodeRef getRootContainer(QName container)
|
||||
{
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(rootNodeRef, ASSOC_CHILDREN, container);
|
||||
|
||||
if (assocRefs.isEmpty())
|
||||
{
|
||||
return nodeService.createNode(rootNodeRef, ASSOC_CHILDREN, container, TYPE_CONTAINER).getChildRef();
|
||||
}
|
||||
else if (assocRefs.size() != 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Only one container is allowed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return assocRefs.iterator().next().getChildRef();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user