package org.gcube.keycloak.event;

import org.gcube.event.publisher.EventSender;
import org.json.simple.JSONObject;
import org.keycloak.events.Event;
import org.keycloak.events.admin.AdminEvent;

/**
 * Added to avoid errors for not configured provider also in realm where event listener is not configured (KC bug?)
 * 
 * @author <a href="mailto:mauro.mugnaini@nubisware.com">Mauro Mugnaini</a>
 *
 */
public class NoOpEventPublisherProvider extends OrchestratorEventPublisherProvider {

    public NoOpEventPublisherProvider() {
        super();
    }

    @Override
    public void close() {
    }

    @Override
    public void onEvent(Event event) {
        // Nothing to do
    }

    @Override
    public void onEvent(AdminEvent event, boolean includeRepresentation) {
        // Nothing to do
    }

    @Override
    protected EventSender createEventSender() {
        return new EventSender() {

            @Override
            public void send(org.gcube.event.publisher.Event event) {
                // Nothing to do
            }

            @Override
            public String sendAndGetResult(org.gcube.event.publisher.Event event) {
                // Nothing to do
                return null;
            }

            @Override
            public JSONObject retrive(String id) {
                // Nothing to do
                return null;
            }
        };
    }

}
