Restored HTTP publish of events instead of logging on sysout

This commit is contained in:
Mauro Mugnaini 2020-06-23 13:10:56 +02:00
parent 313881d04b
commit 858f2a6d24
2 changed files with 22 additions and 13 deletions

View File

@ -94,7 +94,7 @@
<dependency> <dependency>
<groupId>com.googlecode.json-simple</groupId> <groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId> <artifactId>json-simple</artifactId>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>

View File

@ -1,8 +1,11 @@
package org.gcube.portal.event.publisher.lr62; package org.gcube.portal.event.publisher.lr62;
import org.gcube.event.publisher.AbstractEventPublisher; import org.gcube.event.publisher.AbstractEventPublisher;
import org.gcube.event.publisher.Event;
import org.gcube.event.publisher.EventSender; 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.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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 Log log = LogFactoryUtil.getLog(AbstractLR62EventPublisher.class);
protected static final boolean PUBLISH_ON_SYSOUT = false;
public AbstractLR62EventPublisher() { public AbstractLR62EventPublisher() {
super(); super();
} }
protected EventSender createEventSender() { protected EventSender createEventSender() {
// OpenIdConnectConfiguration openIdConnectConfiguration = LiferayOpenIdConnectConfiguration.getConfiguration(); if (PUBLISH_ON_SYSOUT) {
// EventPublisherConfiguration eventPublisherConfiguration = EventPublisherConfiguration.getConfiguration();
// return new HTTPEventSender(eventPublisherConfiguration.getEventPublisherURL(),
// openIdConnectConfiguration.getPortalClientId(), openIdConnectConfiguration.getPortalClientSecret(),
// openIdConnectConfiguration.getTokenURL());
return new EventSender() { return new EventSender() {
@Override @Override
public void send(JSONObject event) { public void send(Event event) {
System.out.println(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());
}
} }
} }