mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Fixed review comments.
This commit is contained in:
@@ -112,8 +112,8 @@ import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
@@ -133,8 +133,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy
|
||||
{
|
||||
/** Logger */
|
||||
private static Log logger = LogFactory.getLog(RecordServiceImpl.class);
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RecordServiceImpl.class);
|
||||
|
||||
/** Sync Model URI */
|
||||
private static final String SYNC_MODEL_1_0_URI = "http://www.alfresco.org/model/sync/1.0";
|
||||
@@ -493,24 +492,15 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
catch (InvalidNodeRefException e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(e.getMessage());
|
||||
}
|
||||
LOGGER.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,10 +568,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
catch (AlfrescoRuntimeException e)
|
||||
{
|
||||
// do nothing but log error
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("Unable to file pending record.", e);
|
||||
}
|
||||
LOGGER.warn("Unable to file pending record.", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -966,13 +953,15 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
*
|
||||
* @param filePlan The reference of the file plan node
|
||||
*/
|
||||
private void recordCreationSanityCheckOnFilePlan(NodeRef filePlan)
|
||||
private NodeRef recordCreationSanityCheckOnFilePlan(NodeRef filePlan)
|
||||
{
|
||||
NodeRef result = null;
|
||||
|
||||
if (filePlan == null)
|
||||
{
|
||||
// TODO .. eventually make the file plan parameter required
|
||||
|
||||
filePlan = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
||||
result = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork()
|
||||
@@ -982,15 +971,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
|
||||
// if the file plan is still null, raise an exception
|
||||
if (filePlan == null)
|
||||
if (result == null)
|
||||
{
|
||||
String msg = "Cannot create record, because the default file plan cannot be determined. Make sure at least one file plan has been created.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
@@ -1000,15 +984,14 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (!filePlanService.isFilePlan(filePlan))
|
||||
{
|
||||
String msg = "Cannot create record, because the provided file plan node reference is not a file plan.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
result = filePlan;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1025,12 +1008,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
AuthenticationUtil.getRunAsUser() +
|
||||
" does not have Write permissions on the doucment " +
|
||||
nodeRef.toString();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AccessDeniedException(msg);
|
||||
}
|
||||
|
||||
@@ -1038,12 +1016,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (!nodeService.exists(nodeRef))
|
||||
{
|
||||
String msg = "Cannot create record, because " + nodeRef.toString() + " does not exist.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
@@ -1051,12 +1024,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String msg = "Cannot create record, because " + nodeRef.toString() + " is not a supported type.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
@@ -1064,12 +1032,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD))
|
||||
{
|
||||
String msg = "Cannot create record, because " + nodeRef.toString() + " is already a record.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
@@ -1077,25 +1040,15 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
String msg = "Can node create record, because " + nodeRef.toString() + " is a working copy.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
// can not create a record from a previously rejected one
|
||||
// Cannot create a record from a previously rejected one
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS))
|
||||
{
|
||||
String msg = "Cannot create record, because " + nodeRef.toString() + " has previously been rejected.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
|
||||
@@ -1103,12 +1056,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_SYNCED))
|
||||
{
|
||||
String msg = "Can't declare as record, because " + nodeRef.toString() + " is synched content.";
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
LOGGER.debug(msg);
|
||||
throw new AlfrescoRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
@@ -1356,10 +1304,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
behaviourFilter.enableBehaviour();
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Rename " + name + " to " + recordName);
|
||||
}
|
||||
LOGGER.debug("Rename " + name + " to " + recordName);
|
||||
|
||||
// add the record aspect
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
||||
@@ -1513,11 +1458,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
fileFolderService.rename(nodeRef, originalName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
logger.debug("Rename " + name + " to " + originalName);
|
||||
}
|
||||
LOGGER.debug("Rename " + name + " to " + originalName);
|
||||
}
|
||||
|
||||
// save the information about the rejection details
|
||||
@@ -1600,26 +1542,26 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
NodeRef filePlan = getFilePlan(record);
|
||||
|
||||
// DEBUG ...
|
||||
boolean debugEnabled = logger.isDebugEnabled();
|
||||
boolean debugEnabled = LOGGER.isDebugEnabled();
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug("Checking whether property " + property.toString() + " is editable for user " + AuthenticationUtil.getRunAsUser());
|
||||
LOGGER.debug("Checking whether property " + property.toString() + " is editable for user " + AuthenticationUtil.getRunAsUser());
|
||||
|
||||
Set<Role> roles = filePlanRoleService.getRolesByUser(filePlan, AuthenticationUtil.getRunAsUser());
|
||||
|
||||
logger.debug(" ... users roles");
|
||||
LOGGER.debug(" ... users roles");
|
||||
|
||||
for (Role role : roles)
|
||||
{
|
||||
logger.debug(" ... user has role " + role.getName() + " with capabilities ");
|
||||
LOGGER.debug(" ... user has role " + role.getName() + " with capabilities ");
|
||||
|
||||
for (Capability cap : role.getCapabilities())
|
||||
{
|
||||
logger.debug(" ... " + cap.getName());
|
||||
LOGGER.debug(" ... " + cap.getName());
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug(" ... user has the following set permissions on the file plan");
|
||||
LOGGER.debug(" ... user has the following set permissions on the file plan");
|
||||
|
||||
Set<AccessPermission> perms = permissionService.getAllSetPermissions(filePlan);
|
||||
for (AccessPermission perm : perms)
|
||||
@@ -1627,13 +1569,13 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
if ((perm.getPermission().contains(RMPermissionModel.EDIT_NON_RECORD_METADATA) ||
|
||||
perm.getPermission().contains(RMPermissionModel.EDIT_RECORD_METADATA)))
|
||||
{
|
||||
logger.debug(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString());
|
||||
LOGGER.debug(" ... " + perm.getAuthority() + " - " + perm.getPermission() + " - " + perm.getAccessStatus().toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (permissionService.hasPermission(filePlan, RMPermissionModel.EDIT_NON_RECORD_METADATA).equals(AccessStatus.ALLOWED))
|
||||
{
|
||||
logger.debug(" ... user has the edit non record metadata permission on the file plan");
|
||||
LOGGER.debug(" ... user has the edit non record metadata permission on the file plan");
|
||||
}
|
||||
}
|
||||
// END DEBUG ...
|
||||
@@ -1641,10 +1583,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
boolean result = alwaysEditProperty(property);
|
||||
if (result)
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... property marked as always editable.");
|
||||
}
|
||||
LOGGER.debug(" ... property marked as always editable.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1657,32 +1596,20 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
if (AccessStatus.ALLOWED.equals(accessNonRecord))
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... user has edit nonrecord metadata capability");
|
||||
}
|
||||
|
||||
LOGGER.debug(" ... user has edit nonrecord metadata capability");
|
||||
allowNonRecordEdit = true;
|
||||
}
|
||||
|
||||
if (AccessStatus.ALLOWED.equals(accessRecord) ||
|
||||
AccessStatus.ALLOWED.equals(accessDeclaredRecord))
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... user has edit record or declared metadata capability");
|
||||
}
|
||||
|
||||
LOGGER.debug(" ... user has edit record or declared metadata capability");
|
||||
allowRecordEdit = true;
|
||||
}
|
||||
|
||||
if (allowNonRecordEdit && allowRecordEdit)
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... so all properties can be edited.");
|
||||
}
|
||||
|
||||
LOGGER.debug(" ... so all properties can be edited.");
|
||||
result = true;
|
||||
}
|
||||
else if (allowNonRecordEdit && !allowRecordEdit)
|
||||
@@ -1690,19 +1617,12 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
// can only edit non record properties
|
||||
if (!isRecordMetadata(filePlan, property))
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... property is not considered record metadata so editable.");
|
||||
}
|
||||
|
||||
LOGGER.debug(" ... property is not considered record metadata so editable.");
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... property is considered record metadata so not editable.");
|
||||
}
|
||||
LOGGER.debug(" ... property is considered record metadata so not editable.");
|
||||
}
|
||||
}
|
||||
else if (!allowNonRecordEdit && allowRecordEdit)
|
||||
@@ -1710,19 +1630,12 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
// can only edit record properties
|
||||
if (isRecordMetadata(filePlan, property))
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... property is considered record metadata so editable.");
|
||||
}
|
||||
|
||||
LOGGER.debug(" ... property is considered record metadata so editable.");
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debugEnabled)
|
||||
{
|
||||
logger.debug(" ... property is not considered record metadata so not editable.");
|
||||
}
|
||||
LOGGER.debug(" ... property is not considered record metadata so not editable.");
|
||||
}
|
||||
}
|
||||
// otherwise we can't edit any properties so just return the empty set
|
||||
@@ -1852,7 +1765,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info(I18NUtil.getMessage(MSG_NODE_HAS_ASPECT, nodeRef.toString(), typeQName.toString()));
|
||||
LOGGER.info(I18NUtil.getMessage(MSG_NODE_HAS_ASPECT, nodeRef.toString(), typeQName.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user