use of com.serotonin.m2m2.vo.AbstractVO in project ma-core-public by infiniteautomation.
the class AuditEventType method raiseDeletedEvent.
public static void raiseDeletedEvent(String auditEventType, AbstractVO<?> o) {
Map<String, Object> context = new HashMap<String, Object>();
JsonSerializableUtility scanner = new JsonSerializableUtility();
try {
context = scanner.findValues(o);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | JsonException | IOException e) {
LOG.error(e.getMessage(), e);
}
raiseEvent(AuditEventInstanceVO.CHANGE_TYPE_DELETE, auditEventType, o, "event.audit.extended.deleted", context);
}
use of com.serotonin.m2m2.vo.AbstractVO in project ma-core-public by infiniteautomation.
the class AuditEventType method raiseAddedEvent.
public static void raiseAddedEvent(String auditEventType, AbstractVO<?> o) {
Map<String, Object> context = new HashMap<String, Object>();
JsonSerializableUtility scanner = new JsonSerializableUtility();
try {
context = scanner.findValues(o);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | JsonException | IOException e) {
LOG.error(e.getMessage(), e);
}
raiseEvent(AuditEventInstanceVO.CHANGE_TYPE_CREATE, auditEventType, o, "event.audit.extended.added", context);
}
use of com.serotonin.m2m2.vo.AbstractVO in project ma-core-public by infiniteautomation.
the class MangoTestBase method validate.
/**
* Validate a vo, fail if invalid
* @param vo
*/
public void validate(AbstractVO<?> vo) {
ProcessResult result = new ProcessResult();
vo.validate(result);
if (result.getHasMessages()) {
String messages = new String();
for (ProcessMessage message : result.getMessages()) messages += message.toString(Common.getTranslations()) + " ";
fail("Validation of " + vo.getClass().getName() + " failed because " + messages);
}
}
use of com.serotonin.m2m2.vo.AbstractVO in project ma-core-public by infiniteautomation.
the class AuditEventType method raiseChangedEvent.
public static void raiseChangedEvent(String auditEventType, AbstractVO<?> from, AbstractVO<?> to) {
Map<String, Object> context = new HashMap<String, Object>();
// Find the annotated properties
JsonSerializableUtility scanner = new JsonSerializableUtility();
try {
context = scanner.findChanges(from, to);
if (context.size() == 0)
// If the object wasn't in fact changed, don't raise an event.
return;
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | JsonException | IOException e) {
LOG.error(e.getMessage(), e);
}
raiseEvent(AuditEventInstanceVO.CHANGE_TYPE_MODIFY, auditEventType, to, "event.audit.extended.changed", context);
}
use of com.serotonin.m2m2.vo.AbstractVO in project ma-core-public by infiniteautomation.
the class AuditEventType method raiseEvent.
private static void raiseEvent(int changeType, String auditEventType, AbstractVO<?> to, String key, Map<String, Object> context) {
User user = Common.getUser();
Object username;
if (user != null)
username = user.getUsername() + " (" + user.getId() + ")";
else {
String descKey = Common.getBackgroundProcessDescription();
if (descKey == null)
username = new TranslatableMessage("common.unknown");
else
username = new TranslatableMessage(descKey);
}
TranslatableMessage message = new TranslatableMessage(key, username, new TranslatableMessage(to.getTypeKey()), to.getName(), to.getXid());
AuditEventType type = new AuditEventType(auditEventType, changeType, to.getId());
type.setRaisingUser(user);
Common.backgroundProcessing.addWorkItem(new AuditEventWorkItem(type, Common.timer.currentTimeMillis(), message, context));
}
Aggregations