Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)

137949 anechifor: REPO-2555 validate auditAppId


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137979 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2017-07-12 12:11:51 +00:00
parent 03ec9fbbcf
commit 0e86382a6b
2 changed files with 18 additions and 7 deletions

View File

@@ -54,6 +54,9 @@ public class AuditApplicationsAuditEntriesRelation implements RelationshipResour
ParameterCheck.mandatory("audit", this.audit); ParameterCheck.mandatory("audit", this.audit);
} }
/**
* If auditAppId does not exist, EntityNotFoundException (status 404).
*/
@WebApiDescription(title = "Returns audit entries for audit app id") @WebApiDescription(title = "Returns audit entries for audit app id")
@Override @Override
public CollectionWithPagingInfo<AuditEntry> readAll(String auditAppId, Parameters parameters) public CollectionWithPagingInfo<AuditEntry> readAll(String auditAppId, Parameters parameters)

View File

@@ -183,6 +183,8 @@ public class AuditImpl implements Audit
{ {
checkEnabled(); checkEnabled();
validateAuditAppId(auditAppId);
// adding orderBy property // adding orderBy property
Pair<String, Boolean> sortProp = getAuditEntrySortProp(parameters); Pair<String, Boolean> sortProp = getAuditEntrySortProp(parameters);
Boolean forward = true; Boolean forward = true;
@@ -228,6 +230,18 @@ public class AuditImpl implements Audit
} }
private void validateAuditAppId(String auditAppId)
{
AuditService.AuditApplication auditApplication = findAuditAppById(auditAppId);
// Check if id is valid
if (auditApplication == null)
{
throw new EntityNotFoundException(auditAppId);
}
}
/** /**
* *
* @param parameters * @param parameters
@@ -417,13 +431,7 @@ public class AuditImpl implements Audit
{ {
checkEnabled(); checkEnabled();
AuditService.AuditApplication auditApplication = findAuditAppById(auditAppId); validateAuditAppId(auditAppId);
// Check if id is valid
if (auditApplication == null)
{
throw new EntityNotFoundException(auditAppId);
}
// Enable/Disable audit application // Enable/Disable audit application
if (auditApp.getIsEnabled() && !auditApplication.isEnabled()) if (auditApp.getIsEnabled() && !auditApplication.isEnabled())