Search in sources :

Example 1 with EventCategoryType

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);
}
Also used : EventCategoryType(org.apache.syncope.common.lib.types.AuditElements.EventCategoryType) EventCategoryTO(org.apache.syncope.common.lib.log.EventCategoryTO) ParseException(java.text.ParseException) Result(org.apache.syncope.common.lib.types.AuditElements.Result)

Aggregations

ParseException (java.text.ParseException)1 EventCategoryTO (org.apache.syncope.common.lib.log.EventCategoryTO)1 EventCategoryType (org.apache.syncope.common.lib.types.AuditElements.EventCategoryType)1 Result (org.apache.syncope.common.lib.types.AuditElements.Result)1