method exist user added
This commit is contained in:
parent
913fa3c9c0
commit
74281ed64f
|
@ -3,6 +3,12 @@
|
|||
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.2.2] - [2021-02-08]
|
||||
|
||||
### Feature
|
||||
|
||||
method for user existence check added
|
||||
|
||||
|
||||
## [v1.2.1] - [2020-07-17]
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -18,7 +18,7 @@
|
|||
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>1.2.2</version>
|
||||
<name>storagehub-client-library</name>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
|
@ -76,4 +76,9 @@ public class StorageHubClient {
|
|||
public void deleteUserAccount(String userId) throws StorageHubException {
|
||||
userClient.removeUser(userId);
|
||||
}
|
||||
|
||||
public boolean userExists(String user) throws StorageHubException {
|
||||
return userClient.exists(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.gcube.common.storagehub.client.plugins;
|
||||
|
||||
import org.gcube.common.authorization.library.policies.Users;
|
||||
import org.gcube.common.clients.Plugin;
|
||||
import org.gcube.common.clients.ProxyBuilder;
|
||||
import org.gcube.common.clients.ProxyBuilderImpl;
|
||||
|
|
|
@ -12,9 +12,7 @@ import org.gcube.common.gxrest.response.entity.SerializableErrorEntityTextReader
|
|||
import org.gcube.common.storagehub.client.Constants;
|
||||
import org.gcube.common.storagehub.client.MyInputStreamProvider;
|
||||
import org.gcube.common.storagehub.client.proxies.DefaultGroupManager;
|
||||
import org.gcube.common.storagehub.client.proxies.DefaultUserManager;
|
||||
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
|
||||
import org.gcube.common.storagehub.client.proxies.UserManagerClient;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.common.clients.delegates.ProxyDelegate;
|
|||
import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||
import org.gcube.common.storagehub.model.exceptions.IdNotFoundException;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||
|
||||
|
@ -127,5 +128,39 @@ public class DefaultUserManager implements UserManagerClient {
|
|||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String user) throws StorageHubException {
|
||||
Call<GXWebTargetAdapterRequest, Boolean> call = new Call<GXWebTargetAdapterRequest, Boolean>() {
|
||||
@Override
|
||||
public Boolean call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||
GXWebTargetAdapterRequest myManager = manager.path(user);
|
||||
|
||||
GXInboundResponse response = myManager.get();
|
||||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException())
|
||||
if (response.getException().getClass().equals(IdNotFoundException.class))
|
||||
return false;
|
||||
else throw response.getException();
|
||||
else if (response.getHTTPCode()==403)
|
||||
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||
|
||||
else
|
||||
throw new BackendGenericError();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
try {
|
||||
return delegate.make(call);
|
||||
}catch(StorageHubException e) {
|
||||
throw e;
|
||||
}catch(Exception e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,5 +11,7 @@ public interface UserManagerClient {
|
|||
void removeUser(String userId) throws StorageHubException;
|
||||
|
||||
List<String> getUsers() throws StorageHubException;
|
||||
|
||||
boolean exists(String user) throws StorageHubException;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue