[v1.0.1] Tuned some log levels and content sending the event and removed the use of deprecated code
This commit is contained in:
parent
539f6b0fb9
commit
dd27c3f442
|
@ -1,5 +1,8 @@
|
|||
# Changelog for "event-publisher-library"
|
||||
|
||||
## [v1.0.1-SNAPSHOT]
|
||||
- Tuned some log levels and content sending the event and removed the use of deprecated code
|
||||
|
||||
## [v1.0.0-SNAPSHOT]
|
||||
- First release (#19461)
|
||||
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>event-publisher-library</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>oidc-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -37,7 +37,7 @@ public class HTTPWithUMAAuthEventSender implements EventSender {
|
|||
log.debug("Starting HTTP POST thread to: {}", baseEnndpointURL);
|
||||
try {
|
||||
URL eventEndpoint = new URL(baseEnndpointURL, event.getName());
|
||||
new Thread(new HTTPost(eventEndpoint, event.toJSONString())).start();
|
||||
new Thread(new HTTPost(eventEndpoint, event)).start();
|
||||
} catch (MalformedURLException e) {
|
||||
log.error("Cannot compute event endpoint URL. Event name: " + event.getName() + ", base endpoint: "
|
||||
+ baseEnndpointURL, e);
|
||||
|
@ -50,11 +50,11 @@ public class HTTPWithUMAAuthEventSender implements EventSender {
|
|||
private static final int READ_TIMEOUT = 5000;
|
||||
|
||||
private URL endpoint;
|
||||
private String jsonString;
|
||||
private Event event;
|
||||
|
||||
public HTTPost(URL endpoint, String jsonString) {
|
||||
public HTTPost(URL endpoint, Event event) {
|
||||
this.endpoint = endpoint;
|
||||
this.jsonString = jsonString;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,8 @@ public class HTTPWithUMAAuthEventSender implements EventSender {
|
|||
log.debug("Getting OIDC token for clientId '{}' from: {}", clientId, tokenURL);
|
||||
JWTToken oidcToken = OpenIdConnectRESTHelper.queryClientToken(clientId, clientSecret, tokenURL);
|
||||
log.debug("Getting UMA token for audience '{}' from: {}", umaAudience, tokenURL);
|
||||
umaToken = OpenIdConnectRESTHelper.queryUMAToken(tokenURL, oidcToken.getAsBearer(), umaAudience, null);
|
||||
umaToken = OpenIdConnectRESTHelper.queryUMAToken(tokenURL, oidcToken.getAccessTokenAsBearer(),
|
||||
umaAudience, null);
|
||||
} else {
|
||||
log.debug("Can't get UMA token since not all the required params was provied");
|
||||
}
|
||||
|
@ -82,12 +83,13 @@ public class HTTPWithUMAAuthEventSender implements EventSender {
|
|||
// connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
if (umaToken != null) {
|
||||
log.debug("Setting authorization header as: {}", umaToken.getAsBearer());
|
||||
connection.setRequestProperty("Authorization", umaToken.getAsBearer());
|
||||
log.debug("Setting authorization header as: {}", umaToken.getAccessTokenAsBearer());
|
||||
connection.setRequestProperty("Authorization", umaToken.getAccessTokenAsBearer());
|
||||
} else {
|
||||
log.debug("Sending request without authorization header");
|
||||
}
|
||||
OutputStream os = connection.getOutputStream();
|
||||
String jsonString = event.toJSONString();
|
||||
log.trace("Sending event JSON: {}", jsonString);
|
||||
os.write(jsonString.getBytes("UTF-8"));
|
||||
os.flush();
|
||||
|
@ -114,10 +116,11 @@ public class HTTPWithUMAAuthEventSender implements EventSender {
|
|||
br.close();
|
||||
isr.close();
|
||||
if (ok) {
|
||||
log.debug("[{}] Event publish OK. Results: {}", httpResultCode, sb.toString());
|
||||
log.info("[{}] Event publish for {} is OK", httpResultCode, event.getName());
|
||||
} else {
|
||||
log.warn("[{}] Event publish is not OK. Results: {}", httpResultCode, sb.toString());
|
||||
log.debug("[{}] Event publish for {} is not OK", httpResultCode, event.getName());
|
||||
}
|
||||
log.trace("Response message from server: {}", sb.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("POSTing JSON to: " + endpoint, e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue