APPS-139 other code review comments

This commit is contained in:
Roxana Lucanu
2020-06-09 14:29:51 +03:00
parent eaec3f0fd4
commit 06de12a10c
3 changed files with 20 additions and 22 deletions

View File

@@ -27,6 +27,8 @@
package org.alfresco.module.org_alfresco_module_rm.action.dm; package org.alfresco.module.org_alfresco_module_rm.action.dm;
import static org.alfresco.module.org_alfresco_module_rm.action.dm.RecordActionUtils.resolvePath;
import java.util.List; import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase; import org.alfresco.module.org_alfresco_module_rm.action.AuditableActionExecuterAbstractBase;
@@ -128,13 +130,13 @@ public class CreateRecordAction extends AuditableActionExecuterAbstractBase
Boolean hideRecordValue = ((Boolean) action.getParameterValue(PARAM_HIDE_RECORD)); Boolean hideRecordValue = ((Boolean) action.getParameterValue(PARAM_HIDE_RECORD));
if (hideRecordValue != null) if (hideRecordValue != null)
{ {
hideRecord = hideRecordValue.booleanValue(); hideRecord = hideRecordValue;
} }
if (pathParameter != null && !pathParameter.isEmpty()) if (pathParameter != null && !pathParameter.isEmpty())
{ {
RecordActionUtils.Services services = new Services(nodeService, filePlanService, authenticationUtil); RecordActionUtils.Services services = new Services(nodeService, filePlanService, authenticationUtil);
destinationRecordFolder = RecordActionUtils.resolvePath(services, filePlan, pathParameter, NAME); destinationRecordFolder = resolvePath(services, filePlan, pathParameter, NAME);
} }
synchronized (this) synchronized (this)

View File

@@ -181,7 +181,7 @@ public class DeclareAsVersionRecordAction extends AuditableActionExecuterAbstrac
logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " is not a supported type."); logger.debug("Can not declare version as record, because " + actionedUponNodeRef.toString() + " is not a supported type.");
} }
} }
else if (!isActionEligible(actionedUponNodeRef)) else if (isActionEligible(actionedUponNodeRef))
{ {
NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN); NodeRef filePlan = (NodeRef)action.getParameterValue(PARAM_FILE_PLAN);
if (filePlan == null) if (filePlan == null)
@@ -261,7 +261,7 @@ public class DeclareAsVersionRecordAction extends AuditableActionExecuterAbstrac
{ {
logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + aspect.getValue()); logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + aspect.getValue());
} }
return true; return false;
} }
} }
if (!nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE)) if (!nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE))
@@ -270,8 +270,8 @@ public class DeclareAsVersionRecordAction extends AuditableActionExecuterAbstrac
{ {
logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " does not have the versionable aspect applied."); logger.debug("Can not declare version record, because " + actionedUponNodeRef.toString() + " does not have the versionable aspect applied.");
} }
return true; return false;
} }
return false; return true;
} }
} }

View File

@@ -37,8 +37,8 @@ import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
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.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@@ -50,7 +50,7 @@ public class RecordActionUtils
/** /**
* Logger * Logger
*/ */
private static final Log LOGGER = LogFactory.getLog(RecordActionUtils.class); private static final Logger LOGGER = LoggerFactory.getLogger(RecordActionUtils.class);
/** Private constructor to prevent instantiation. */ /** Private constructor to prevent instantiation. */
private RecordActionUtils() private RecordActionUtils()
@@ -139,15 +139,12 @@ public class RecordActionUtils
{ {
throw new AlfrescoRuntimeException("Unable to execute " + actionName + " action, because the destination path could not be found."); throw new AlfrescoRuntimeException("Unable to execute " + actionName + " action, because the destination path could not be found.");
} }
else QName nodeType = nodeService.getType(nodeRef);
if (nodeType.equals(RecordsManagementModel.TYPE_HOLD_CONTAINER) ||
nodeType.equals(RecordsManagementModel.TYPE_TRANSFER_CONTAINER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER))
{ {
QName nodeType = nodeService.getType(nodeRef); throw new AlfrescoRuntimeException("Unable to execute " + actionName + " action, because the destination path is invalid.");
if (nodeType.equals(RecordsManagementModel.TYPE_HOLD_CONTAINER) ||
nodeType.equals(RecordsManagementModel.TYPE_TRANSFER_CONTAINER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER))
{
throw new AlfrescoRuntimeException("Unable to execute " + actionName + " action, because the destination path is invalid.");
}
} }
if (pathElements.size() > 1) if (pathElements.size() > 1)
{ {
@@ -168,11 +165,10 @@ public class RecordActionUtils
// 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)
{ {
if (LOGGER.isDebugEnabled()) final String logMessage =
{ String.format("Unable to execute %s action, because the fileplan path could not be determined. Make sure at least one file plan has been created.", actionName);
LOGGER.debug("Unable to execute " + actionName + " action, because the fileplan path could not be determined. Make sure at least one file plan has been created."); LOGGER.debug(logMessage);
} throw new AlfrescoRuntimeException(logMessage);
throw new AlfrescoRuntimeException("Unable to execute " + actionName + " action, because the fileplan path could not be determined.");
} }
return filePlan; return filePlan;
} }