RM should not use a class from the enterprise package as this breaks the compatibility with the community version

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@56609 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-10-14 13:47:33 +00:00
parent 02f5553530
commit eb3736d8f6

View File

@@ -20,7 +20,6 @@ package org.alfresco.module.org_alfresco_module_rm.action.dm;
import java.util.List; import java.util.List;
import org.alfresco.enterprise.repo.sync.SyncModel;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
@@ -36,14 +35,15 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
/** /**
* Creates a new record from an existing content object. * Creates a new record from an existing content object.
* *
* Note: This is a 'normal' dm action, rather than a records management action. * Note: This is a 'normal' dm action, rather than a records management action.
* *
* @author Roy Wetherall * @author Roy Wetherall
*/ */
public class CreateRecordAction extends AuditableActionExecuterAbstractBase public class CreateRecordAction extends AuditableActionExecuterAbstractBase
@@ -51,29 +51,34 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(CreateRecordAction.class); private static Log logger = LogFactory.getLog(CreateRecordAction.class);
/** Action name */ /** Action name */
public static final String NAME = "create-record"; public static final String NAME = "create-record";
/** Parameter names */ /** Parameter names */
public static final String PARAM_FILE_PLAN = "file-plan"; public static final String PARAM_FILE_PLAN = "file-plan";
public static final String PARAM_HIDE_RECORD = "hide-record"; public static final String PARAM_HIDE_RECORD = "hide-record";
/** Sync Model URI */
static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0";
/** Synced aspect */
static final QName ASPECT_SYNCED = QName.createQName(SYNC_MODEL_1_0_URI, "synced");
/** Record service */ /** Record service */
private RecordService recordService; private RecordService recordService;
/** Node service */ /** Node service */
private NodeService nodeService; private NodeService nodeService;
/** File plan service */ /** File plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** Dictionary service */ /** Dictionary service */
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
/** File plan authentication service */ /** File plan authentication service */
private FilePlanAuthenticationService filePlanAuthenticationService; private FilePlanAuthenticationService filePlanAuthenticationService;
/** /**
* @param recordService record service * @param recordService record service
*/ */
@@ -81,7 +86,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
this.recordService = recordService; this.recordService = recordService;
} }
/** /**
* @param nodeService node service * @param nodeService node service
*/ */
@@ -89,7 +94,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/** /**
* @param filePlanService file plan service * @param filePlanService file plan service
*/ */
@@ -97,7 +102,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
this.filePlanService = filePlanService; this.filePlanService = filePlanService;
} }
/** /**
* @param dictionaryService dictionary service * @param dictionaryService dictionary service
*/ */
@@ -105,7 +110,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
} }
/** /**
* @param filePlanAuthenticationService file plan authentication service * @param filePlanAuthenticationService file plan authentication service
*/ */
@@ -113,15 +118,15 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
this.filePlanAuthenticationService = filePlanAuthenticationService; this.filePlanAuthenticationService = filePlanAuthenticationService;
} }
/** /**
* @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 @Override
protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef) protected void executeImpl(final Action action, final NodeRef actionedUponNodeRef)
{ {
if (nodeService.exists(actionedUponNodeRef) == false) if (nodeService.exists(actionedUponNodeRef) == false)
{ {
// do not create record if the actioned upon node does not exist! // do not create record if the actioned upon node does not exist!
if (logger.isDebugEnabled() == true) if (logger.isDebugEnabled() == true)
@@ -152,7 +157,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
logger.debug("Can node create record, because " + actionedUponNodeRef.toString() + " is a working copy."); logger.debug("Can node create record, because " + actionedUponNodeRef.toString() + " is a working copy.");
} }
} }
else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS) == true) else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_RECORD_REJECTION_DETAILS) == true)
{ {
@@ -162,7 +167,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " has previously been rejected."); logger.debug("Can not create record, because " + actionedUponNodeRef.toString() + " has previously been rejected.");
} }
} }
else if (nodeService.hasAspect(actionedUponNodeRef, SyncModel.ASPECT_SYNCED) == true) else if (nodeService.hasAspect(actionedUponNodeRef, ASPECT_SYNCED) == true)
{ {
// can't declare the record if the node is sync'ed // can't declare the record if the node is sync'ed
if (logger.isDebugEnabled() == true) if (logger.isDebugEnabled() == true)
@@ -170,11 +175,11 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
logger.debug("Can't declare as record, because " + actionedUponNodeRef.toString() + " is synched content."); logger.debug("Can't declare as record, because " + actionedUponNodeRef.toString() + " is synched content.");
} }
} }
else else
{ {
NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN);
if (filePlan == null) if (filePlan == null)
{ {
// TODO .. eventually make the file plan parameter required // TODO .. eventually make the file plan parameter required
filePlan = filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<NodeRef>() filePlan = filePlanAuthenticationService.runAsRmAdmin(new RunAsWork<NodeRef>()
{ {
@@ -184,7 +189,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
} }
}); });
// if the file plan is still null, raise an exception // if the file plan is still null, raise an exception
if (filePlan == null) if (filePlan == null)
{ {
@@ -193,7 +198,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
logger.debug("Can not create record, because the default file plan can not be determined. Make sure at least one file plan has been created."); logger.debug("Can not create record, because the default file plan can not be determined. Make sure at least one file plan has been created.");
} }
throw new AlfrescoRuntimeException("Can not create record, because the default file plan can not be determined."); throw new AlfrescoRuntimeException("Can not create record, because the default file plan can not be determined.");
} }
} }
else else
{ {
@@ -207,7 +212,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
throw new AlfrescoRuntimeException("Can not create record, because the provided file plan node reference is not a file plan."); throw new AlfrescoRuntimeException("Can not create record, because the provided file plan node reference is not a file plan.");
} }
} }
// indicate whether the record should be hidden or not (default not) // indicate whether the record should be hidden or not (default not)
boolean hideRecord = false; boolean hideRecord = false;
Boolean hideRecordValue = ((Boolean)action.getParameterValue(PARAM_HIDE_RECORD)); Boolean hideRecordValue = ((Boolean)action.getParameterValue(PARAM_HIDE_RECORD));
@@ -215,7 +220,7 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
{ {
hideRecord = hideRecordValue.booleanValue(); hideRecord = hideRecordValue.booleanValue();
} }
// create record from existing document // create record from existing document
recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord); recordService.createRecord(filePlan, actionedUponNodeRef, !hideRecord);
} }
@@ -231,5 +236,5 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
//params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN))); //params.add(new ParameterDefinitionImpl(PARAM_FILE_PLAN, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_FILE_PLAN)));
params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD))); params.add(new ParameterDefinitionImpl(PARAM_HIDE_RECORD, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_HIDE_RECORD)));
} }
} }