diff --git a/pom.xml b/pom.xml index b9c590d..2a804f3 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ com.googlecode.json-simple json-simple - compile + provided com.liferay.portal diff --git a/src/main/java/org/gcube/portal/event/publisher/lr62/AbstractLR62EventPublisher.java b/src/main/java/org/gcube/portal/event/publisher/lr62/AbstractLR62EventPublisher.java index b6c1a49..7b28a3d 100644 --- a/src/main/java/org/gcube/portal/event/publisher/lr62/AbstractLR62EventPublisher.java +++ b/src/main/java/org/gcube/portal/event/publisher/lr62/AbstractLR62EventPublisher.java @@ -1,8 +1,11 @@ package org.gcube.portal.event.publisher.lr62; import org.gcube.event.publisher.AbstractEventPublisher; +import org.gcube.event.publisher.Event; import org.gcube.event.publisher.EventSender; -import org.json.simple.JSONObject; +import org.gcube.event.publisher.HTTPEventSender; +import org.gcube.oidc.rest.OpenIdConnectConfiguration; +import org.gcube.portal.oidc.lr62.LiferayOpenIdConnectConfiguration; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; @@ -11,22 +14,28 @@ public abstract class AbstractLR62EventPublisher extends AbstractEventPublisher protected static final Log log = LogFactoryUtil.getLog(AbstractLR62EventPublisher.class); + protected static final boolean PUBLISH_ON_SYSOUT = false; + public AbstractLR62EventPublisher() { super(); } protected EventSender createEventSender() { -// OpenIdConnectConfiguration openIdConnectConfiguration = LiferayOpenIdConnectConfiguration.getConfiguration(); -// EventPublisherConfiguration eventPublisherConfiguration = EventPublisherConfiguration.getConfiguration(); -// return new HTTPEventSender(eventPublisherConfiguration.getEventPublisherURL(), -// openIdConnectConfiguration.getPortalClientId(), openIdConnectConfiguration.getPortalClientSecret(), -// openIdConnectConfiguration.getTokenURL()); - return new EventSender() { - @Override - public void send(JSONObject event) { - System.out.println(event); - } - }; + if (PUBLISH_ON_SYSOUT) { + return new EventSender() { + @Override + public void send(Event event) { + System.out.println(event); + } + }; + } else { + OpenIdConnectConfiguration openIdConnectConfiguration = LiferayOpenIdConnectConfiguration + .getConfiguration(); + EventPublisherConfiguration eventPublisherConfiguration = EventPublisherConfiguration.getConfiguration(); + return new HTTPEventSender(eventPublisherConfiguration.getEventPublisherURL(), + openIdConnectConfiguration.getPortalClientId(), openIdConnectConfiguration.getPortalClientSecret(), + openIdConnectConfiguration.getTokenURL()); + } } } \ No newline at end of file