@Override public int hashCode() { return level != null ? level.hashCode() : 0; } }
public boolean withAudit() { return !AuditLevel.NONE.equals(level); }
@Override public void write(final OutputStream output) throws IOException, WebApplicationException { // CSV by default for now exportUserApi.exportDataAsCSVForAccount(UUID.fromString(accountId), output, callContext); } };
@Test(groups = "fast") public void testForObject() throws Exception { for (final ObjectType objectType : ObjectType.values()) { for (final UUID objectId : objectIds) { for (final AuditLevel level : AuditLevel.values()) { if (AuditLevel.NONE.equals(level)) { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext).size(), 0); } else if (AuditLevel.MINIMAL.equals(level)) { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), ImmutableList.<AuditLog>of(auditLogs.get(0))); } else { Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), auditLogs); } } } } } }
@Override public Response toResponse(final TagApiException exception) { if (exception.getCode() == ErrorCode.TAG_DOES_NOT_EXIST.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TAG_CANNOT_BE_REMOVED.getCode()) { return buildBadRequestResponse(exception, uriInfo); } else { return buildBadRequestResponse(exception, uriInfo); } } }
@Override public CustomFieldJson apply(final CustomField customField) { // TODO Really slow - we should instead try to figure out the account id final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(customField.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), tenantContext); return new CustomFieldJson(customField, auditLogs); } },
protected Response getCustomFields(final UUID id, final AuditMode auditMode, final TenantContext context) { final List<CustomField> fields = customFieldUserApi.getCustomFieldsForObject(id, getObjectType(), context); final List<CustomFieldJson> result = new LinkedList<CustomFieldJson>(); for (final CustomField cur : fields) { // TODO PIERRE - Bulk API final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(cur.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), context); result.add(new CustomFieldJson(cur, auditLogs)); } return Response.status(Response.Status.OK).entity(result).build(); }
@Override protected TagApiException generateAlreadyExistsException(final TagModelDao entity, final InternalCallContext context) { // Print the tag details, not the id here, as we throw this exception when checking if a tag already exists // by using the isSame(TagModelDao) method (see above) return new TagApiException(ErrorCode.TAG_ALREADY_EXISTS, entity.toString()); }
@Override public AccountJson apply(final Account account) { final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext); return getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext); } },
public AuditMode(final String auditModeString) { this.level = AuditLevel.valueOf(auditModeString.toUpperCase()); }
@Override protected TagDefinitionApiException generateAlreadyExistsException(final TagDefinitionModelDao entity, final InternalCallContext context) { return new TagDefinitionApiException(ErrorCode.TAG_DEFINITION_ALREADY_EXISTS, entity.getId()); } }
@Override protected CustomFieldApiException generateAlreadyExistsException(final CustomFieldModelDao entity, final InternalCallContext context) { return new CustomFieldApiException(ErrorCode.CUSTOM_FIELD_ALREADY_EXISTS, entity.getId()); }
protected Response deleteTags(final UUID id, final String tagList, final CallContext context) throws TagApiException { final Collection<UUID> input = getTagDefinitionUUIDs(tagList); tagUserApi.removeTags(id, getObjectType(), input, context); return Response.status(Response.Status.OK).build(); }
@Override public Response toResponse(final TagDefinitionApiException exception) { if (exception.getCode() == ErrorCode.TAG_DEFINITION_ALREADY_EXISTS.getCode()) { return buildConflictingRequestResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TAG_DEFINITION_CONFLICTS_WITH_CONTROL_TAG.getCode()) { return buildConflictingRequestResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TAG_DEFINITION_DOES_NOT_EXIST.getCode()) { return buildNotFoundResponse(exception, uriInfo); } else if (exception.getCode() == ErrorCode.TAG_DEFINITION_IN_USE.getCode()) { return buildBadRequestResponse(exception, uriInfo); } else { return buildBadRequestResponse(exception, uriInfo); } } }
private void remove_AUTO_INVOICE_OFF_on_clear(final UUID accountId, final InternalCallContext context) throws OverdueApiException { try { tagApi.removeTag(accountId, ObjectType.ACCOUNT, ControlTagType.AUTO_INVOICING_OFF.getId(), context); } catch (TagApiException e) { if (e.getCode() != ErrorCode.TAG_DOES_NOT_EXIST.getCode()) { throw new OverdueApiException(e); } } }
@Override public AccountAuditLogs getAccountAuditLogs(final UUID accountId, final AuditLevel auditLevel, final TenantContext tenantContext) { // Optimization - bail early if (AuditLevel.NONE.equals(auditLevel)) { return new DefaultAccountAuditLogs(accountId); } return auditDao.getAuditLogsForAccountRecordId(auditLevel, internalCallContextFactory.createInternalTenantContext(accountId, tenantContext)); }
@Override public CustomFieldJson apply(final CustomField customField) { // TODO Really slow - we should instead try to figure out the account id final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(customField.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), tenantContext); return new CustomFieldJson(customField, auditLogs); } },
@Override public AccountJson apply(final Account account) { final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext); return getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext); } },
@Override public TagJson apply(final Tag tag) { final TagDefinition tagDefinition = tagDefinitionsCache.get(tag.getTagDefinitionId()); // TODO Really slow - we should instead try to figure out the account id final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tag.getId(), ObjectType.TAG, auditMode.getLevel(), tenantContext); return new TagJson(tag, tagDefinition, auditLogs); } },
@Override public TagJson apply(final Tag tag) { final TagDefinition tagDefinition = tagDefinitionsCache.get(tag.getTagDefinitionId()); // TODO Really slow - we should instead try to figure out the account id final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tag.getId(), ObjectType.TAG, auditMode.getLevel(), tenantContext); return new TagJson(tag, tagDefinition, auditLogs); } },