Migrated request to social-service-client refs #23679
This commit is contained in:
parent
75b55cc8bb
commit
6d37e4b939
|
@ -3,6 +3,11 @@
|
||||||
All notable changes to this project will be documented in this file.
|
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).
|
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]
|
## [v1.13.1]
|
||||||
|
|
||||||
- Aligned code and wiki to the new requirements [#23167]
|
- Aligned code and wiki to the new requirements [#23167]
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.data-catalogue</groupId>
|
<groupId>org.gcube.data-catalogue</groupId>
|
||||||
<artifactId>grsf-publisher-ws</artifactId>
|
<artifactId>grsf-publisher-ws</artifactId>
|
||||||
<version>1.13.1</version>
|
<version>1.13.2-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>grsf-publisher-ws</name>
|
<name>grsf-publisher-ws</name>
|
||||||
<description>Utility library to publish GRSF products on GRSF catalogue.</description>
|
<description>Utility library to publish GRSF products on GRSF catalogue.</description>
|
||||||
|
@ -56,6 +56,11 @@
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
</dependency>
|
</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/ -->
|
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jsoup</groupId>
|
<groupId>org.jsoup</groupId>
|
||||||
|
|
|
@ -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.api.DiscoveryClient;
|
||||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
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.Jsoup;
|
||||||
import org.jsoup.safety.Whitelist;
|
import org.jsoup.safety.Whitelist;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -134,19 +135,16 @@ public abstract class HelperMethods {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static String getUserEmail(String context, String token){
|
public static String getUserEmail(String context, String token) throws Exception{
|
||||||
|
|
||||||
// check in cache
|
// check in cache
|
||||||
String result = null;
|
String result = null;
|
||||||
if((result = (String) userEmailCache.get(token)) != null){
|
if((result = (String) userEmailCache.get(token)) != null){
|
||||||
return result;
|
return result;
|
||||||
}else{
|
}else{
|
||||||
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
|
UserClient userClient = new UserClient();
|
||||||
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserEmail?gcube-token=" + token :
|
String email = userClient.getEmail();
|
||||||
baseUrl + "/users/getUserEmail?gcube-token=" + token;
|
userEmailCache.insert(token, email);
|
||||||
logger.debug("Request url is " + url);
|
|
||||||
result = executGETHttpRequest(url, 200);
|
|
||||||
userEmailCache.insert(token, result);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -158,19 +156,16 @@ public abstract class HelperMethods {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static String getUserFullname(String context, String token){
|
public static String getUserFullname(String context, String token) throws Exception{
|
||||||
|
|
||||||
// check in cache
|
// check in cache
|
||||||
String result = null;
|
String result = null;
|
||||||
if((result = (String) userFullnameCache.get(token)) != null){
|
if((result = (String) userFullnameCache.get(token)) != null){
|
||||||
return result;
|
return result;
|
||||||
}else{
|
}else{
|
||||||
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
|
UserClient userClient = new UserClient();
|
||||||
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserFullname?gcube-token=" + token :
|
String fuulName = userClient.getFullName();
|
||||||
baseUrl + "/users/getUserFullname?gcube-token=" + token;
|
userFullnameCache.insert(token, fuulName);
|
||||||
logger.debug("Request url is " + url);
|
|
||||||
result = executGETHttpRequest(url, 200);
|
|
||||||
userFullnameCache.insert(token, result);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue