private void sendOsgiEvent()

in src/main/java/org/apache/sling/resourceresolver/impl/observation/OsgiObservationBridge.java [109:163]


    private void sendOsgiEvent(ResourceChange change) {
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        String topic;
        switch (change.getType()) {
        case ADDED:
            topic = SlingConstants.TOPIC_RESOURCE_ADDED;
            break;

        case CHANGED:
            topic = SlingConstants.TOPIC_RESOURCE_CHANGED;
            break;

        case REMOVED:
            topic = SlingConstants.TOPIC_RESOURCE_REMOVED;
            break;

        default:
            return;
        }

        props.put(SlingConstants.PROPERTY_PATH, change.getPath());
        if (change.getUserId() != null) {
            props.put(SlingConstants.PROPERTY_USERID, change.getUserId());
        }
        if (change.getAddedPropertyNames() != null ) {
            props.put(SlingConstants.PROPERTY_ADDED_ATTRIBUTES, change.getAddedPropertyNames().toArray(new String[change.getAddedPropertyNames().size()]));
        }
        if (change.getChangedPropertyNames() != null) {
            props.put(SlingConstants.PROPERTY_CHANGED_ATTRIBUTES, change.getChangedPropertyNames().toArray(new String[change.getChangedPropertyNames().size()]));
        }
        if ( change.getRemovedPropertyNames() != null ) {
            props.put(SlingConstants.PROPERTY_REMOVED_ATTRIBUTES, change.getRemovedPropertyNames().toArray(new String[change.getRemovedPropertyNames().size()]));
        }
        if (change.getType() != ChangeType.REMOVED) {
            Resource resource = resolver.getResource(change.getPath());
            if (resource == null) {
                resolver.refresh();
                resource = resolver.getResource(change.getPath());
            }
            if (resource != null) {
                if (resource.getResourceType() != null) {
                    props.put(SlingConstants.PROPERTY_RESOURCE_TYPE, resource.getResourceType());
                }
                if (resource.getResourceSuperType() != null) {
                    props.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
                }
            }
        }
        if (change.isExternal()) {
            props.put("event.application", "unknown");
        }

        final Event event = new Event(topic, props);
        eventAdmin.sendEvent(event);
    }