Added possibility to read the user by gcube username

This commit is contained in:
Luca Frosini 2022-10-03 16:42:54 +02:00
parent cf150065d0
commit cfa089131a
2 changed files with 10 additions and 3 deletions

View File

@ -65,7 +65,12 @@ public class CKANUser extends CKAN {
catalogueModerator = null;
}
public String create() {
public void setName(String name) {
name = getCKANUsername(name);
this.name = name;
}
public String createInCkan() {
RandomString randomString = new RandomString(12);
ObjectNode objectNode = mapper.createObjectNode();
objectNode.put(NAME, name);
@ -173,7 +178,7 @@ public class CKANUser extends CKAN {
updateProfileIfNeeded();
} catch(WebApplicationException e) {
if(e.getResponse().getStatusInfo() == Status.NOT_FOUND) {
create();
createInCkan();
} else {
throw e;
}

View File

@ -106,7 +106,9 @@ public class User extends REST<CKANUser> implements org.gcube.gcat.api.interface
* The service add the user's role in <code>portal_role</code> property when the user read its own profile.
* See <a href="../docs/index.html#roles">Roles</a> section for more information.
*
* @pathExample /users/luca_frosini
* @param username Ckan or gcube username are both accepted
*
* @pathExample /users/luca.frosini
* @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/user/read-user-response.json
*/
@GET