Migrated request to social-service-client refs #23679

This commit is contained in:
Luca Frosini 2022-08-01 14:39:25 +02:00
parent 75b55cc8bb
commit 6d37e4b939
3 changed files with 20 additions and 15 deletions

View File

@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.13.2-SNAPSHOT]
- Migrated request to social-service-client [#23679]
## [v1.13.1]
- Aligned code and wiki to the new requirements [#23167]

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-publisher-ws</artifactId>
<version>1.13.1</version>
<version>1.13.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>grsf-publisher-ws</name>
<description>Utility library to publish GRSF products on GRSF catalogue.</description>
@ -56,6 +56,11 @@
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<dependency>
<groupId>org.jsoup</groupId>

View File

@ -31,6 +31,7 @@ import org.gcube.datacatalogue.common.caches.CacheInterface;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.gcube.social_networking.social_networking_client_library.UserClient;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.slf4j.LoggerFactory;
@ -134,19 +135,16 @@ public abstract class HelperMethods {
* @return
* @throws Exception
*/
public static String getUserEmail(String context, String token){
public static String getUserEmail(String context, String token) throws Exception{
// check in cache
String result = null;
if((result = (String) userEmailCache.get(token)) != null){
return result;
}else{
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserEmail?gcube-token=" + token :
baseUrl + "/users/getUserEmail?gcube-token=" + token;
logger.debug("Request url is " + url);
result = executGETHttpRequest(url, 200);
userEmailCache.insert(token, result);
UserClient userClient = new UserClient();
String email = userClient.getEmail();
userEmailCache.insert(token, email);
}
return result;
}
@ -158,19 +156,16 @@ public abstract class HelperMethods {
* @return
* @throws Exception
*/
public static String getUserFullname(String context, String token){
public static String getUserFullname(String context, String token) throws Exception{
// check in cache
String result = null;
if((result = (String) userFullnameCache.get(token)) != null){
return result;
}else{
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserFullname?gcube-token=" + token :
baseUrl + "/users/getUserFullname?gcube-token=" + token;
logger.debug("Request url is " + url);
result = executGETHttpRequest(url, 200);
userFullnameCache.insert(token, result);
UserClient userClient = new UserClient();
String fuulName = userClient.getFullName();
userFullnameCache.insert(token, fuulName);
}
return result;
}