use of org.apache.syncope.common.lib.types.AuditElements.EventCategoryType in project syncope by apache.
the class AuditLoggerName method parseEventCategory.
public static Pair<EventCategoryTO, Result> parseEventCategory(final String event) {
EventCategoryTO eventCategoryTO = new EventCategoryTO();
Result condition = null;
if (StringUtils.isNotEmpty(event)) {
final String[] elements = event.substring(1, event.length() - 1).split("\\]:\\[");
if (elements.length == 1) {
eventCategoryTO.setType(EventCategoryType.CUSTOM);
condition = Result.SUCCESS;
eventCategoryTO.getEvents().add(event);
} else {
EventCategoryType type;
if (EventCategoryType.PROPAGATION.toString().equals(elements[0])) {
type = EventCategoryType.PROPAGATION;
} else if (EventCategoryType.PULL.toString().equals(elements[0])) {
type = EventCategoryType.PULL;
} else if (EventCategoryType.PUSH.toString().equals(elements[0])) {
type = EventCategoryType.PUSH;
} else {
try {
type = EventCategoryType.valueOf(elements[0]);
} catch (Exception e) {
type = EventCategoryType.CUSTOM;
}
}
eventCategoryTO.setType(type);
eventCategoryTO.setCategory(StringUtils.isNotEmpty(elements[1]) ? elements[1] : null);
eventCategoryTO.setSubcategory(StringUtils.isNotEmpty(elements[2]) ? elements[2] : null);
if (elements.length > 3 && StringUtils.isNotEmpty(elements[3])) {
eventCategoryTO.getEvents().add(elements[3]);
}
if (elements.length > 4) {
condition = Result.valueOf(elements[4].toUpperCase());
}
}
}
return Pair.of(eventCategoryTO, condition);
}
Aggregations