From 4dd7aa5efb45e8f957dcc3fce3bd88d8a9492b3f Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 10 May 2022 11:13:50 +0200 Subject: [PATCH] Fixed issue with thread --- CHANGELOG.md | 2 +- pom.xml | 3 +-- src/main/java/org/gcube/gcat/social/SocialMessage.java | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24583d0..1c4c6e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for gCube Catalogue (gCat) Service -## [v2.2.0] +## [v2.2.0-SNAPSHOT] - Switched gcat credentials to new IAM authz [#21628][#22727] - Added support to manage configurations [#22658][#22742] diff --git a/pom.xml b/pom.xml index 78ccd48..457ce8d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.data-catalogue gcat war - 2.2.0 + 2.2.0-SNAPSHOT gCube Catalogue (gCat) Service This service allows any client to publish on the gCube Catalogue. @@ -72,7 +72,6 @@ org.gcube.common authorization-utils - [2.0.0, 3.0.0-SNAPSHOT) org.gcube.common diff --git a/src/main/java/org/gcube/gcat/social/SocialMessage.java b/src/main/java/org/gcube/gcat/social/SocialMessage.java index eaa7c4a..6253eb4 100644 --- a/src/main/java/org/gcube/gcat/social/SocialMessage.java +++ b/src/main/java/org/gcube/gcat/social/SocialMessage.java @@ -33,11 +33,15 @@ public class SocialMessage extends Thread { protected final ObjectMapper objectMapper; + private final String token; + protected Message message; public SocialMessage() throws Exception { super(); this.objectMapper = new ObjectMapper(); + SecretManager secretManager = SecretManagerProvider.instance.get(); + this.token = secretManager.getCurrentSecretHolder().getSecrets().first().getToken(); } public Message getMessage() { @@ -76,8 +80,7 @@ public class SocialMessage extends Thread { GXHTTPStringRequest gxhttpStringRequest = GXHTTPStringRequest.newRequest(basePath); gxhttpStringRequest.from(Constants.CATALOGUE_NAME); gxhttpStringRequest.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - SecretManager secretManager = SecretManagerProvider.instance.get(); - gxhttpStringRequest.setSecurityToken(secretManager.getCurrentSecretHolder().getSecrets().first().getToken()); + gxhttpStringRequest.setSecurityToken(token); gxhttpStringRequest.path(SOCIAL_SERVICE_SEND_MESSAGE_PATH); HttpURLConnection httpURLConnection = gxhttpStringRequest.post(messageString);