diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6817194..80c46b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## [v1.1.1-SNAPSHOT] - 2022-09-06
+
+ - Minor fix on a megthod name
+
## [v1.1.0] - 2022-04-06
- First release
diff --git a/pom.xml b/pom.xml
index 54652e0..49b3774 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.gcube.social-networking
social-service-client
- 1.1.0
+ 1.1.1-SNAPSHOT
social-networking-service-client
jar
The social networking web service client library
@@ -20,14 +20,14 @@
org.gcube.distribution
gcube-bom
- 2.0.1
+ 2.0.2
pom
import
org.gcube.distribution
gcube-smartgears-bom
- 2.1.0
+ 2.1.1
pom
import
@@ -65,7 +65,7 @@
org.gcube.social-networking
social-service-model
- [1.0.0-SNAPSHOT, 2.0.0)
+ [1.0.0, 2.0.0)
commons-lang
diff --git a/src/main/java/org/gcube/social_networking/social_networking_client_library/UserClient.java b/src/main/java/org/gcube/social_networking/social_networking_client_library/UserClient.java
index 24dc9af..a0b1b41 100644
--- a/src/main/java/org/gcube/social_networking/social_networking_client_library/UserClient.java
+++ b/src/main/java/org/gcube/social_networking/social_networking_client_library/UserClient.java
@@ -2,8 +2,10 @@ package org.gcube.social_networking.social_networking_client_library;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.ws.rs.core.GenericType;
@@ -27,130 +29,146 @@ public class UserClient extends BaseClient{
public UserClient() throws Exception {
super(SUB_SERVICE_PATH);
}
-
+
/**
* Get attribute value
* @return
*/
public String getCustomAttribute(String attributeKey){
-
+
Validate.isTrue(attributeKey != null, "attribute key cannot be null");
-
+
logger.debug("Request for attribute value");
String thisMethodSignature = "get-custom-attribute";
String request = getServiceEndpoint() + thisMethodSignature + "?attribute=" + attributeKey;
return HttpClient.get(new GenericType>(){}, request);
-
+
}
-
+
/**
* Get fullname
* @return user's fullname
*/
public String getFullName(){
-
+
logger.debug("Request for fullname");
String thisMethodSignature = "get-fullname";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType>(){}, request);
-
+
}
-
+
/**
* Get email
* @return users'email
*/
public String getEmail(){
-
+
logger.debug("Request for email");
String thisMethodSignature = "get-email";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType>(){}, request);
-
+
}
-
+
/**
* Get profile
* @return
*/
public UserProfileExtended getProfile(){
-
+
logger.debug("Request for getting profile");
String thisMethodSignature = "get-profile";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType>(){}, request);
-
+
}
-
+
/**
* Get all usernames in this context
* @return
*/
public List getAllUsernamesContext(){
-
+
logger.debug("Request for getting usernames in this context");
String thisMethodSignature = "get-all-usernames";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType>>(){}, request);
-
+
}
-
+
/**
* Get all usernames and fullnames in this context
* @return
*/
public Map getAllUsernamesFullnamesContext(){
-
+
logger.debug("Request for getting usernames and fullnames in this context");
String thisMethodSignature = "get-all-fullnames-and-usernames";
String request = getServiceEndpoint() + thisMethodSignature;
return HttpClient.get(new GenericType>>(){}, request);
-
+
}
-
+
/**
* Get usernames by global role
* @return
*/
public List getAllUsernamesByGlobalRole(String globalRole){
-
+
Validate.isTrue(globalRole != null, "role cannot be null");
-
+
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "get-usernames-by-global-role";
String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + globalRole;
return HttpClient.get(new GenericType>>(){}, request);
-
+
}
-
+
/**
- * Get usernames by local role
- * @return
+ * Get usernames by role
+ * @deprecated use #getAllUsernamesByRole(String rolename) instead
+ * @return the usernames having such role
*/
+ @Deprecated
public List getAllUsernamesByLocalRole(String localRole){
-
+
Validate.isTrue(localRole != null, "role cannot be null");
-
+
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "get-usernames-by-role";
String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + localRole;
return HttpClient.get(new GenericType>>(){}, request);
-
+
}
-
+ /**
+ * Get usernames by role, the environment (i.e. VRE/VLab) is inferred from the token
+ * @return the usernames having such role
+ */
+ public SetgetAllUsernamesByRole(String rolename){
+ Validate.isTrue(rolename != null, "role cannot be null");
+
+ logger.debug("Request for getting usernames with global role");
+ String thisMethodSignature = "get-usernames-by-role";
+ String request = getServiceEndpoint() + thisMethodSignature + "?role-name=" + rolename;
+ ArrayList sourceList = HttpClient.get(new GenericType>>(){}, request);
+ Set usernames = new HashSet<>(sourceList);
+ return usernames;
+ }
+
/**
* Check if user exists
* @return
*/
public Boolean userExists(String username){
-
+
Validate.isTrue(username != null, "username cannot be null");
-
+
logger.debug("Request for getting usernames with global role");
String thisMethodSignature = "user-exists";
String request = getServiceEndpoint() + thisMethodSignature + "?username=" + username;
return HttpClient.get(new GenericType>(){}, request);
-
+
}
-
+
}
diff --git a/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java
index 657581f..85e6e94 100644
--- a/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java
+++ b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
@@ -53,8 +54,8 @@ public class TestClientServices {
public void setContextAndToken(){
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/gCube");
- String umaToken = "";
- //AccessTokenProvider.instance.set(umaToken);
+ String umaToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJySUJPYjZZY3p2ZE4xNVpuNHFkUTRLdEQ5VUhyY1dwNWJCT3NaLXpYbXM0In0.eyJleHAiOjE2NjM2NjU2NTgsImlhdCI6MTY2MzY2NTM1OCwi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saWFuby5hc3NhbnRlQGlzdGkuY25yLml0In0.KIxC9QYGZCp6jAdye_82q648JjZli9KMxe-lqyFWkuA-HaZ-Ig2lWyn747iKp3UmstQgCTTonmOsVANHp1Feu_U1CuiWqRZ8OhmrTj8Q5v-FKwVtN2GfbjOF9b4aMXySFPd1HtCGHJ4o57uUrIQvvOV_SJOK5SOjG0YzOmsrOcXzSPl97ZZLKwio-Py0rxN6fdK8Obx7TL1eGgllhAI7ZDFRfoZrbz-F1YL1IPlQ6RI76rb7sbt6oL-T6LirP92AmUaW_nTLBBqrFR7uCaZdZKIDd4zxBmyzXjkNHncMKg8yFl-i1SRe58EcucMwEN0O-kUkhIb2CzaClsiWcLjP5g";
+ AccessTokenProvider.instance.set(umaToken);
SecurityTokenProvider.instance.set("");
}
@@ -205,19 +206,9 @@ public class TestClientServices {
public void TestUsersClient() throws Exception{
UserClient userClient = new UserClient();
-
- // Requires user token bound to the root context
- // List administrators = userClient.getAllUsernamesByGlobalRole("administrator");
- //
- // assert(administrators != null && !administrators.isEmpty());
-
- // logger.debug("Administrators are " + administrators);
-
-// List vreManagers = userClient.getAllUsernamesByLocalRole("vre-manager");
-//
-// assert(vreManagers != null && !vreManagers.isEmpty());
-//
-// logger.debug("Vre Managers are " + vreManagers);
+ Set vreManagers = userClient.getAllUsernamesByRole("Data-Manager");
+ assert(vreManagers != null && !vreManagers.isEmpty());
+ System.out.println("Data Managers are " + vreManagers);
String myEmail = userClient.getEmail();