RM-2967 - added exists, null and empty checks to solve the problems

This commit is contained in:
Ana Bozianu
2016-04-01 19:02:29 +03:00
parent 1aecba721e
commit 3be929afae
2 changed files with 9 additions and 1 deletions

View File

@@ -1446,7 +1446,11 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
if (entry.getEvent().equals("Create Person") && entry.getNodeRef() != null) if (entry.getEvent().equals("Create Person") && entry.getNodeRef() != null)
{ {
NodeRef nodeRef = entry.getNodeRef(); NodeRef nodeRef = entry.getNodeRef();
String userName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); String userName = null;
if(nodeService.exists(nodeRef))
{
userName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME);
}
json.put("nodeName", userName == null ? "": userName); json.put("nodeName", userName == null ? "": userName);
json.put("createPerson", true); json.put("createPerson", true);
} }

View File

@@ -158,6 +158,10 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
if( targetNode == null ) if( targetNode == null )
{ {
targetNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID); targetNode = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
if(targetNode == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The default RM site was not found");
}
} }
return AccessStatus.ALLOWED.equals( return AccessStatus.ALLOWED.equals(
capabilityService.getCapabilityAccessState(targetNode, ACCESS_AUDIT_CAPABILITY)); capabilityService.getCapabilityAccessState(targetNode, ACCESS_AUDIT_CAPABILITY));