RM-695: Consolidation of RM actions appearing in RM rule UI

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@50977 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Craig Tan
2013-06-13 04:29:09 +00:00
parent 939703c163
commit 54883bd2bd
12 changed files with 340 additions and 31 deletions

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2009-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.action.constraint;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
/**
* Manual event parameter constraint
*
* @author Craig Tan
*/
public class ManualEventParameterConstraint extends BaseParameterConstraint
{
/** Name constant */
public static final String NAME = "rm-ac-manual-events";
private RecordsManagementEventService recordsManagementEventService;
public void setRecordsManagementEventService(RecordsManagementEventService recordsManagementEventService)
{
this.recordsManagementEventService = recordsManagementEventService;
}
/**
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/
protected Map<String, String> getAllowableValuesImpl()
{
List<RecordsManagementEvent> events = recordsManagementEventService.getEvents();
Map<String, String> result = new HashMap<String, String>(events.size());
for (RecordsManagementEvent event : events)
{
RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
if (eventType != null && !eventType.isAutomaticEvent())
{
result.put(event.getName(), event.getDisplayLabel());
}
}
return result;
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.action.dm;
import java.util.List;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ScriptActionExecuter;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
/**
* Executes a JavaScript
*
* Note: This is a 'normal' dm action, rather than a records management action.
*
* @author Craig Tan
*/
public class ExecuteScriptAction extends ScriptActionExecuter
{
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_SCRIPTREF, DataTypeDefinition.NODE_REF, true,
getParamDisplayLabel(PARAM_SCRIPTREF), false, "rm-ac-scripts"));
}
}

View File

@@ -18,10 +18,12 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -31,16 +33,32 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
{
/** Logger */
private static Log logger = LogFactory.getLog(CloseRecordFolderAction.class);
/** I18N */
private static final String MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER = "rm.action.close-record-folder-not-folder";
/** Parameter names */
public static final String PARAM_CLOSE_PARENT = "closeParent";
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
* org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// TODO check that the user in question has the correct permissions to close a records folder
if (recordService.isRecord(actionedUponNodeRef))
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{
actionedUponNodeRef = assocRef.getParentRef();
}
}
if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
{
@@ -52,7 +70,8 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, actionedUponNodeRef.toString()));
if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, actionedUponNodeRef.toString()));
}
}
}

View File

@@ -23,14 +23,16 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Complete event action
@@ -47,7 +49,18 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt";
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, DataTypeDefinition.TEXT, true,
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-event"));
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
* org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
@@ -55,7 +68,7 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
{
// Get the next disposition action
@@ -66,6 +79,16 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
EventCompletionDetails event = getEvent(da, eventName);
if (event != null)
{
if (eventCompletedAt == null)
{
eventCompletedAt = new Date();
}
if (eventCompletedBy == null)
{
eventCompletedBy = AuthenticationUtil.getRunAsUser();
}
// Update the event so that it is complete
NodeRef eventNodeRef = event.getNodeRef();
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
@@ -80,7 +103,8 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName));
// RM-695: Commenting error handling out. If the current disposition stage does not define the event being completed nothing should happen.
// throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName));
}
}
}

View File

@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -96,7 +95,10 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, actionedUponNodeRef.toString()));
if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_UNDECLARED_ONLY_RECORDS, actionedUponNodeRef.toString()));
}
}
}

View File

@@ -18,8 +18,13 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -32,6 +37,15 @@ public class FreezeAction extends RMActionExecuterAbstractBase
/** Parameter names */
public static final String PARAM_REASON = "reason";
/**
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_REASON, DataTypeDefinition.TEXT, true, getParamDisplayLabel(PARAM_REASON)));
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/

View File

@@ -18,10 +18,12 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -31,8 +33,14 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
{
/** Logger */
private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class);
private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder";
/** Parameter names */
public static final String PARAM_OPEN_PARENT = "openParent";
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
* org.alfresco.service.cmr.repository.NodeRef)
@@ -43,6 +51,15 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
// TODO move re-open logic into a service method
// TODO check that the user in question has the correct permission to re-open a records folder
if (recordService.isRecord(actionedUponNodeRef))
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{
actionedUponNodeRef = assocRef.getParentRef();
}
}
if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
{
Boolean isClosed = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
@@ -53,7 +70,8 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
}
}
}

View File

@@ -18,10 +18,11 @@
*/
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -31,6 +32,9 @@ import org.springframework.extensions.surf.util.I18NUtil;
*/
public class UndeclareRecordAction extends RMActionExecuterAbstractBase
{
/** Logger */
private static Log logger = LogFactory.getLog(UndeclareRecordAction.class);
/** I18N */
private static final String MSG_RECORDS_ONLY_UNDECLARED = "rm.action.records_only_undeclared";
@@ -50,7 +54,10 @@ public class UndeclareRecordAction extends RMActionExecuterAbstractBase
}
else
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
}
}
}
}

View File

@@ -21,11 +21,14 @@ package org.alfresco.repo.rule;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.namespace.QName;
/**
* Extended rule service implementation.
@@ -39,6 +42,8 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
private FilePlanAuthenticationService filePlanAuthenticationService;
protected NodeService nodeService;
private RecordsManagementService recordsManagementService;
public void setRunAsRmAdmin(boolean runAsRmAdmin)
@@ -56,6 +61,11 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
this.recordsManagementService = recordsManagementService;
}
public void setNodeService2(NodeService nodeService)
{
this.nodeService = nodeService;
}
@Override
public void saveRule(final NodeRef nodeRef, final Rule rule)
{
@@ -81,24 +91,31 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
@Override
public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules)
{
if (isFilePlanComponentRule(rule) == true && runAsRmAdmin == true)
QName typeQName = nodeService.getType(nodeRef);
// The dispositionSchedule node will not be executed by rules
if (recordsManagementService.isFilePlanComponent(nodeRef) == true
&& typeQName.equals(RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE) == false)
{
String user = AuthenticationUtil.getFullyAuthenticatedUser();
try
if (isFilePlanComponentRule(rule) == true && runAsRmAdmin == true)
{
AuthenticationUtil.setFullyAuthenticatedUser(filePlanAuthenticationService.getRmAdminUserName());
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
String user = AuthenticationUtil.getFullyAuthenticatedUser();
try
{
AuthenticationUtil.setFullyAuthenticatedUser(filePlanAuthenticationService.getRmAdminUserName());
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
}
finally
{
AuthenticationUtil.setFullyAuthenticatedUser(user);
}
}
finally
else
{
AuthenticationUtil.setFullyAuthenticatedUser(user);
// just execute the rule as the current user
super.executeRule(rule, nodeRef, executedRules);
}
}
else
{
// just execute the rule as the current user
super.executeRule(rule, nodeRef, executedRules);
}
}
private boolean isFilePlanComponentRule(Rule rule)