checkPermission(CreatePermission.class, newResource); newResource.auditClass(Audit.Action.CREATE, new ChangeSpec(newResource, null, null, newResource.getObject()));
checkPermission(CreatePermission.class, newResource); newResource.auditClass(Audit.Action.CREATE, new ChangeSpec(newResource, null, null, newResource.getObject()));
/** * Audit an action on field. * * @param changeSpec Change spec for audit */ protected void auditField(final ChangeSpec changeSpec) { final String fieldName = changeSpec.getFieldName(); Audit[] annotations = dictionary.getAttributeOrRelationAnnotations(getResourceClass(), Audit.class, fieldName ); if (annotations == null || annotations.length == 0) { // Default to class-level annotation for action auditClass(Audit.Action.UPDATE, changeSpec); return; } for (Audit annotation : annotations) { if (annotation.action().length == 1 && annotation.action()[0] == Audit.Action.UPDATE) { LogMessage message = new LogMessage(annotation, this, Optional.of(changeSpec)); getRequestScope().getAuditLogger().log(message); } else { throw new InvalidSyntaxException("Only Audit.Action.UPDATE is allowed on fields."); } } }
auditClass(Audit.Action.DELETE, new ChangeSpec(this, null, getObject(), null)); requestScope.publishLifecycleEvent(this, CRUDEvent.CRUDAction.DELETE); requestScope.getDeletedResources().add(this);
/** * Audit an action on field. * * @param changeSpec Change spec for audit */ protected void auditField(final ChangeSpec changeSpec) { final String fieldName = changeSpec.getFieldName(); Audit[] annotations = dictionary.getAttributeOrRelationAnnotations(getResourceClass(), Audit.class, fieldName ); if (annotations == null || annotations.length == 0) { // Default to class-level annotation for action auditClass(Audit.Action.UPDATE, changeSpec); return; } for (Audit annotation : annotations) { if (annotation.action().length == 1 && annotation.action()[0] == Audit.Action.UPDATE) { LogMessage message = new LogMessage(annotation, this, Optional.of(changeSpec)); getRequestScope().getAuditLogger().log(message); } else { throw new InvalidSyntaxException("Only Audit.Action.UPDATE is allowed on fields."); } } }
auditClass(Audit.Action.DELETE, new ChangeSpec(this, null, getObject(), null)); requestScope.publishLifecycleEvent(this, CRUDEvent.CRUDAction.DELETE); requestScope.getDeletedResources().add(this);