RM-895: Ensure RM actions with side effects don't try and execute if things are frozen

RM-965: Unable to declare a record from the repository view.




git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55371 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-09-17 00:52:58 +00:00
parent 11ec6eea5f
commit 90a63d7c71
15 changed files with 256 additions and 117 deletions

View File

@@ -918,6 +918,7 @@
<property name="publicAction" value="true"/> <property name="publicAction" value="true"/>
<property name="delegateAction" ref="set-property-value" /> <property name="delegateAction" ref="set-property-value" />
<property name="adhocPropertiesAllowed" value="true" /> <property name="adhocPropertiesAllowed" value="true" />
<property name="checkFrozen" value="true" />
</bean> </bean>
<!-- add record types --> <!-- add record types -->

View File

@@ -58,8 +58,10 @@ public class AddRecordTypeAction extends RMActionExecuterAbstractBase
*/ */
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
if (recordService.isRecord(actionedUponNodeRef)) if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false &&
recordService.isRecord(actionedUponNodeRef) == true)
{ {
String recordTypes = (String) action.getParameterValue(PARAM_ADD_RECORD_TYPES); String recordTypes = (String) action.getParameterValue(PARAM_ADD_RECORD_TYPES);
String[] types = recordTypes.split(","); String[] types = recordTypes.split(",");

View File

@@ -38,7 +38,7 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
/** I18N */ /** I18N */
private static final String MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER = "rm.action.close-record-folder-not-folder"; private static final String MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER = "rm.action.close-record-folder-not-folder";
/** Parameter names */ /** Parameter names */
public static final String PARAM_CLOSE_PARENT = "closeParent"; public static final String PARAM_CLOSE_PARENT = "closeParent";
@@ -49,29 +49,31 @@ public class CloseRecordFolderAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
// TODO check that the user in question has the correct permissions to close a records folder if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false)
{
if (recordService.isRecord(actionedUponNodeRef))
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{
actionedUponNodeRef = assocRef.getParentRef();
}
}
if (recordService.isRecord(actionedUponNodeRef)) if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
{
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null)
{ {
actionedUponNodeRef = assocRef.getParentRef(); Boolean isClosed = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
if (Boolean.FALSE.equals(isClosed) == true)
{
this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, true);
}
} }
} else
if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
{
Boolean isClosed = (Boolean)this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
if (Boolean.FALSE.equals(isClosed) == true)
{ {
this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, true); if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, actionedUponNodeRef.toString()));
} }
} }
else
{
if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, actionedUponNodeRef.toString()));
}
} }
} }

View File

@@ -62,46 +62,50 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME); if (nodeService.exists(actionedUponNodeRef) == true &&
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY); freezeService.isFrozen(actionedUponNodeRef) == false)
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
{ {
// Get the next disposition action String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef); String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
if (da != null) Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
if (this.nodeService.hasAspect(actionedUponNodeRef, ASPECT_DISPOSITION_LIFECYCLE) == true)
{ {
// Get the disposition event // Get the next disposition action
EventCompletionDetails event = getEvent(da, eventName); DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
if (event != null) if (da != null)
{ {
if (eventCompletedAt == null) // Get the disposition event
EventCompletionDetails event = getEvent(da, eventName);
if (event != null)
{ {
eventCompletedAt = new Date(); 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);
props.put(PROP_EVENT_EXECUTION_COMPLETE, true);
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, eventCompletedAt);
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, eventCompletedBy);
this.nodeService.setProperties(eventNodeRef, props);
// Check to see if the events eligible property needs to be updated
updateEventEligible(da);
} }
else
if (eventCompletedBy == null)
{ {
eventCompletedBy = AuthenticationUtil.getRunAsUser(); // 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));
} }
// Update the event so that it is complete
NodeRef eventNodeRef = event.getNodeRef();
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
props.put(PROP_EVENT_EXECUTION_COMPLETE, true);
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, eventCompletedAt);
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, eventCompletedBy);
this.nodeService.setProperties(eventNodeRef, props);
// Check to see if the events eligible property needs to be updated
updateEventEligible(da);
}
else
{
// 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

@@ -61,7 +61,9 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
{ {
if (recordService.isRecord(actionedUponNodeRef) == true) if (nodeService.exists(actionedUponNodeRef) == true &&
recordService.isRecord(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false)
{ {
if (recordService.isDeclared(actionedUponNodeRef) == false) if (recordService.isDeclared(actionedUponNodeRef) == false)
{ {

View File

@@ -39,6 +39,9 @@ public class DelegateAction extends RMActionExecuterAbstractBase
/** Delegate action executer*/ /** Delegate action executer*/
private ActionExecuter delegateActionExecuter; private ActionExecuter delegateActionExecuter;
/** should we check whether the node is frozen */
private boolean checkFrozen = false;
/** /**
* @param delegateActionExecuter delegate action executer * @param delegateActionExecuter delegate action executer
*/ */
@@ -46,6 +49,14 @@ public class DelegateAction extends RMActionExecuterAbstractBase
{ {
this.delegateActionExecuter = delegateActionExecuter; this.delegateActionExecuter = delegateActionExecuter;
} }
/**
* @param checkFrozen true if we check whether the actioned upon node reference is frozen, false otherwise
*/
public void setCheckFrozen(boolean checkFrozen)
{
this.checkFrozen = checkFrozen;
}
/** /**
* @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)
@@ -53,7 +64,11 @@ public class DelegateAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
delegateActionExecuter.execute(action, actionedUponNodeRef); if (nodeService.exists(actionedUponNodeRef) == true &&
(checkFrozen == false || freezeService.isFrozen(actionedUponNodeRef) == false))
{
delegateActionExecuter.execute(action, actionedUponNodeRef);
}
} }
/** /**

View File

@@ -72,7 +72,8 @@ public class FileToAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
{ {
if (nodeService.exists(actionedUponNodeRef) == true) if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false)
{ {
if (recordService.isFiled(actionedUponNodeRef) == false) if (recordService.isFiled(actionedUponNodeRef) == false)
{ {

View File

@@ -36,6 +36,7 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class); private static Log logger = LogFactory.getLog(OpenRecordFolderAction.class);
/** I18N */
private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder"; private static final String MSG_NO_OPEN_RECORD_FOLDER = "rm.action.no-open-record-folder";
/** Parameter names */ /** Parameter names */
@@ -48,30 +49,34 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
// TODO move re-open logic into a service method if (nodeService.exists(actionedUponNodeRef) == true &&
// TODO check that the user in question has the correct permission to re-open a records folder freezeService.isFrozen(actionedUponNodeRef) == false)
{
if (recordService.isRecord(actionedUponNodeRef)) // 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
ChildAssociationRef assocRef = nodeService.getPrimaryParent(actionedUponNodeRef);
if (assocRef != null) if (recordService.isRecord(actionedUponNodeRef))
{ {
actionedUponNodeRef = assocRef.getParentRef(); 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);
if (Boolean.TRUE.equals(isClosed) == true) if (this.recordsManagementService.isRecordFolder(actionedUponNodeRef) == true)
{ {
this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false); Boolean isClosed = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, PROP_IS_CLOSED);
} if (Boolean.TRUE.equals(isClosed) == true)
} {
else this.nodeService.setProperty(actionedUponNodeRef, PROP_IS_CLOSED, false);
{ }
if (logger.isWarnEnabled()) }
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString())); else
} {
if (logger.isWarnEnabled())
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
}
}
} }
} }

View File

@@ -48,6 +48,7 @@ public class RejectAction extends RMActionExecuterAbstractBase
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
if (nodeService.exists(actionedUponNodeRef) == true && if (nodeService.exists(actionedUponNodeRef) == true &&
freezeService.isFrozen(actionedUponNodeRef) == false &&
nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION) != null) nodeService.getProperty(actionedUponNodeRef, PROP_RECORD_ORIGINATING_LOCATION) != null)
{ {
recordService.rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON)); recordService.rejectRecord(actionedUponNodeRef, (String) action.getParameterValue(PARAM_REASON));

View File

@@ -44,20 +44,25 @@ public class UndeclareRecordAction extends RMActionExecuterAbstractBase
@Override @Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
if (recordService.isRecord(actionedUponNodeRef) == true) if (nodeService.exists(actionedUponNodeRef) == true)
{ {
if (recordService.isDeclared(actionedUponNodeRef) == true) if (recordService.isRecord(actionedUponNodeRef) == true)
{ {
// Remove the declared aspect // repoen if already complete and not frozen
this.nodeService.removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD); if (recordService.isDeclared(actionedUponNodeRef) == true &&
} freezeService.isFrozen(actionedUponNodeRef) == false)
} {
else // Remove the declared aspect
{ this.nodeService.removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD);
if (logger.isWarnEnabled()) }
{ }
logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED)); else
} {
} if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_RECORDS_ONLY_UNDECLARED));
}
}
}
} }
} }

View File

@@ -32,7 +32,7 @@ import org.alfresco.service.namespace.QName;
public interface ModelSecurityService public interface ModelSecurityService
{ {
/** /**
* Sets whether model security is enabled or not. * Sets whether model security is enabled globally or not.
* *
* @param enabled * @param enabled
*/ */
@@ -45,6 +45,16 @@ public interface ModelSecurityService
*/ */
boolean isEnabled(); boolean isEnabled();
/**
* Disable model security checks for the current thread.
*/
void disable();
/**
* Enable model security checks for the current thread.
*/
void enable();
/** /**
* Registers a protected model artifact with the service. * Registers a protected model artifact with the service.
* *

View File

@@ -153,6 +153,28 @@ public class ModelSecurityServiceImpl implements ModelSecurityService,
this, this,
onUpdatePropertiesBehaviour); onUpdatePropertiesBehaviour);
} }
/**
* @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#disable()
*/
@Override
public void disable()
{
beforeAddAspectBehaviour.disable();
beforeRemoveAspectBehaviour.disable();
onUpdatePropertiesBehaviour.disable();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#enable()
*/
@Override
public void enable()
{
beforeAddAspectBehaviour.enable();
beforeRemoveAspectBehaviour.enable();
onUpdatePropertiesBehaviour.enable();
}
/** /**
* @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#register(org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedModelArtifact) * @see org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService#register(org.alfresco.module.org_alfresco_module_rm.model.security.ProtectedModelArtifact)

View File

@@ -74,7 +74,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
* @since 2.1 * @since 2.1
*/ */
public class FilePlanRoleServiceImpl implements FilePlanRoleService, public class FilePlanRoleServiceImpl implements FilePlanRoleService,
RecordsManagementModel RecordsManagementModel
{ {
/** I18N */ /** I18N */
private static final String MSG_FIRST_NAME = "bootstrap.rmadmin.firstName"; private static final String MSG_FIRST_NAME = "bootstrap.rmadmin.firstName";

View File

@@ -271,7 +271,8 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
for (String authority : authorities) for (String authority : authorities)
{ {
if (authority.equals(PermissionService.ALL_AUTHORITIES) == false) if (authority.equals(PermissionService.ALL_AUTHORITIES) == false &&
authority.equals(PermissionService.OWNER_AUTHORITY) == false)
{ {
if (referenceCountMap == null || if (referenceCountMap == null ||
referenceCountMap.containsKey(authority) == false) referenceCountMap.containsKey(authority) == false)

View File

@@ -23,6 +23,7 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; 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.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -39,36 +40,67 @@ import org.alfresco.service.namespace.QName;
*/ */
public class ExtendedRuleServiceImpl extends RuleServiceImpl public class ExtendedRuleServiceImpl extends RuleServiceImpl
{ {
/** indicates whether the rules should be run as rmadmin or not */
private boolean runAsRmAdmin = true; private boolean runAsRmAdmin = true;
/** ignore types */
private Set<QName> ignoredTypes = new HashSet<QName>(); private Set<QName> ignoredTypes = new HashSet<QName>();
/** file plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** file plan authentication service */
private FilePlanAuthenticationService filePlanAuthenticationService; private FilePlanAuthenticationService filePlanAuthenticationService;
/** node service */
protected NodeService nodeService; protected NodeService nodeService;
/** model security service */
protected ModelSecurityService modelSecurityService;
/**
* @param runAsRmAdmin true if run rules as rmadmin, false otherwise
*/
public void setRunAsRmAdmin(boolean runAsRmAdmin) public void setRunAsRmAdmin(boolean runAsRmAdmin)
{ {
this.runAsRmAdmin = runAsRmAdmin; this.runAsRmAdmin = runAsRmAdmin;
} }
/**
* @param filePlanAuthenticationService file plan authentication service
*/
public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService) public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService)
{ {
this.filePlanAuthenticationService = filePlanAuthenticationService; this.filePlanAuthenticationService = filePlanAuthenticationService;
} }
/**
* @param nodeService node service
*/
public void setNodeService2(NodeService nodeService) public void setNodeService2(NodeService nodeService)
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService) public void setFilePlanService(FilePlanService filePlanService)
{ {
this.filePlanService = filePlanService; this.filePlanService = filePlanService;
} }
/**
* @param modelSecurityService model security service
*/
public void setModelSecurityService(ModelSecurityService modelSecurityService)
{
this.modelSecurityService = modelSecurityService;
}
/**
* Init method
*/
@Override @Override
public void init() public void init()
{ {
@@ -81,10 +113,13 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
ignoredTypes.add(RecordsManagementModel.TYPE_EVENT_EXECUTION); ignoredTypes.add(RecordsManagementModel.TYPE_EVENT_EXECUTION);
} }
/**
* @see org.alfresco.repo.rule.RuleServiceImpl#saveRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule)
*/
@Override @Override
public void saveRule(final NodeRef nodeRef, final Rule rule) public void saveRule(final NodeRef nodeRef, final Rule rule)
{ {
if (filePlanService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true) if (filePlanService.isFilePlanComponent(nodeRef) == true)
{ {
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{ {
@@ -103,10 +138,13 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
} }
} }
/**
* @see org.alfresco.repo.rule.RuleServiceImpl#removeRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule)
*/
@Override @Override
public void removeRule(final NodeRef nodeRef, final Rule rule) public void removeRule(final NodeRef nodeRef, final Rule rule)
{ {
if (filePlanService.isFilePlanComponent(nodeRef) == true && runAsRmAdmin == true) if (filePlanService.isFilePlanComponent(nodeRef) == true)
{ {
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{ {
@@ -125,27 +163,50 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
} }
} }
/**
* @see org.alfresco.repo.rule.RuleServiceImpl#executeRule(org.alfresco.service.cmr.rule.Rule, org.alfresco.service.cmr.repository.NodeRef, java.util.Set)
*/
@Override @Override
public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules) public void executeRule(final Rule rule, final NodeRef nodeRef, final Set<ExecutedRuleData> executedRules)
{ {
QName typeQName = nodeService.getType(nodeRef); QName typeQName = nodeService.getType(nodeRef);
if (filePlanService.isFilePlanComponent(nodeRef) == true // check if this is a rm rule on a rm artifact
&& isFilePlanComponentRule(rule) == true && runAsRmAdmin == true) if (filePlanService.isFilePlanComponent(nodeRef) == true &&
isFilePlanComponentRule(rule) == true)
{ {
// ignore and
if (isIgnoredType(typeQName) == false) if (isIgnoredType(typeQName) == false)
{ {
String user = AuthenticationUtil.getFullyAuthenticatedUser(); // disable model security whilst we execute the RM rule
try //modelSecurityService.disable();
{ //try
AuthenticationUtil.setFullyAuthenticatedUser(filePlanAuthenticationService.getRmAdminUserName()); //{
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules); if (runAsRmAdmin == true)
} {
finally // run as rmadmin
{ filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<Void>()
AuthenticationUtil.setFullyAuthenticatedUser(user); {
} @Override
} public Void doWork() throws Exception
{
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
return null;
}
});
}
else
{
// run as current user
ExtendedRuleServiceImpl.super.executeRule(rule, nodeRef, executedRules);
}
//}
//finally
//{
// enable model security
// modelSecurityService.enable();
//}
}
} }
else else
{ {
@@ -154,6 +215,12 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
} }
} }
/**
* Indicates whether the rule is a file plan component
*
* @param rule rule
* @return boolean true if rule is set on a file plan component, false otherwise
*/
private boolean isFilePlanComponentRule(Rule rule) private boolean isFilePlanComponentRule(Rule rule)
{ {
NodeRef nodeRef = getOwningNodeRef(rule); NodeRef nodeRef = getOwningNodeRef(rule);
@@ -161,7 +228,8 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl
} }
/** /**
* @param typeQName * @param typeQName type qname
* @return boolean true if ignore type, false otherwise
*/ */
private boolean isIgnoredType(QName typeQName) private boolean isIgnoredType(QName typeQName)
{ {