EventInfo.java 2.02 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.osgi.service.event.Event
 */
package com.adobe.cq.dam.mac.sync.impl;

import org.osgi.service.event.Event;

public class EventInfo {
    private static final String RENDITIONS_FOLDER_PATH = "jcr:content/renditions";
    private static final String METADATA_FOLDER_PATH = "jcr:content/metadata";
    private static final String COMMENT_PATH = "/content/dam/.*/comments/.*";
    private DAMEventType damEventType;
    private ResourceEventType resourceEventType;

    public EventInfo(Event event) {
        String eventPath = (String)event.getProperty("path");
        String topic = event.getTopic();
        if (eventPath != null && eventPath.contains("jcr:content/renditions")) {
            this.damEventType = DAMEventType.RENDITION;
        } else if (eventPath != null && eventPath.contains("jcr:content/metadata")) {
            this.damEventType = DAMEventType.METADATA;
        } else if (eventPath != null && eventPath.matches("/content/dam/.*/comments/.*")) {
            this.damEventType = DAMEventType.ACTIVITY_STREAM;
        }
        if ("org/apache/sling/api/resource/Resource/CHANGED".equals(topic)) {
            this.resourceEventType = ResourceEventType.CHANGED;
        } else if ("org/apache/sling/api/resource/Resource/REMOVED".equals(topic)) {
            this.resourceEventType = ResourceEventType.REMOVED;
        } else if ("org/apache/sling/api/resource/Resource/ADDED".equals(topic)) {
            this.resourceEventType = ResourceEventType.ADDED;
        }
    }

    public DAMEventType getDamEventType() {
        return this.damEventType;
    }

    public ResourceEventType getResourceEventType() {
        return this.resourceEventType;
    }

    static enum DAMEventType {
        METADATA,
        RENDITION,
        ACTIVITY_STREAM;
        

        private DAMEventType() {
        }
    }

    static enum ResourceEventType {
        ADDED,
        CHANGED,
        REMOVED;
        

        private ResourceEventType() {
        }
    }

}