Event name is now sent as part of the URI
This commit is contained in:
parent
159da23f7b
commit
9f56248a54
|
@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.gcube.oidc.rest.JWTToken;
|
import org.gcube.oidc.rest.JWTToken;
|
||||||
|
@ -32,15 +33,22 @@ public class HTTPEventSender implements EventSender {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Starting HTTP POST thread to: " + endpoint);
|
log.debug("Starting HTTP POST thread to: " + endpoint);
|
||||||
}
|
}
|
||||||
new Thread(new HTTPost(event.toJSONString())).start();
|
try {
|
||||||
|
URL eventEndpoint = new URL(endpoint, event.getName());
|
||||||
|
new Thread(new HTTPost(eventEndpoint, event.toJSONString())).start();
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
log.error("Cannot compute event endpoint URL. Event name: " + event.getName() + ", base endpoint: "
|
||||||
|
+ endpoint, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HTTPost implements Runnable {
|
public class HTTPost implements Runnable {
|
||||||
|
|
||||||
private String json;
|
private URL endpoint;
|
||||||
|
private String jsonString;
|
||||||
|
|
||||||
public HTTPost(String json) {
|
public HTTPost(URL endpoint, String jsonString) {
|
||||||
this.json = json;
|
this.jsonString = jsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,7 +72,7 @@ public class HTTPEventSender implements EventSender {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Sending event JSON");
|
log.trace("Sending event JSON");
|
||||||
}
|
}
|
||||||
os.write(json.getBytes("UTF-8"));
|
os.write(jsonString.getBytes("UTF-8"));
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -101,4 +109,5 @@ public class HTTPEventSender implements EventSender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
Loading…
Reference in New Issue