User and Group management method upgrade
This commit is contained in:
parent
9de1e4ad59
commit
b56206b1e4
|
@ -41,7 +41,7 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this methdo is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this methdo is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this methdo is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this methdo is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else if (response.getHTTPCode()==403)
|
else if (response.getHTTPCode()==403)
|
||||||
throw new UserNotAuthorizedException("the call to this methdo is not allowed for the user");
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
else
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,12 @@ import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
||||||
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
import org.gcube.common.gxrest.response.inbound.GXInboundResponse;
|
||||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
|
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||||
|
|
||||||
public class DefaultUserManager implements UserManagerClient {
|
public class DefaultUserManager implements UserManagerClient {
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
|
|
||||||
public DefaultUserManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
public DefaultUserManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
@ -32,16 +33,19 @@ public class DefaultUserManager implements UserManagerClient {
|
||||||
MultivaluedMap<String, Object> formData = new MultivaluedHashMap<String, Object>();
|
MultivaluedMap<String, Object> formData = new MultivaluedHashMap<String, Object>();
|
||||||
formData.add("user", userId);
|
formData.add("user", userId);
|
||||||
formData.add("password", userId+"pwd");
|
formData.add("password", userId+"pwd");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else
|
else if (response.getHTTPCode()==403)
|
||||||
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -62,13 +66,21 @@ public class DefaultUserManager implements UserManagerClient {
|
||||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager;
|
GXWebTargetAdapterRequest myManager = manager;
|
||||||
|
|
||||||
GXInboundResponse response = myManager.path(userId).delete();
|
try {
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
GXInboundResponse response = myManager.path(userId).delete();
|
||||||
if (response.hasException())
|
|
||||||
throw response.getException();
|
if (response.isErrorResponse()) {
|
||||||
else
|
if (response.hasException())
|
||||||
throw new BackendGenericError();
|
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();
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -92,14 +104,17 @@ public class DefaultUserManager implements UserManagerClient {
|
||||||
GXWebTargetAdapterRequest myManager = manager;
|
GXWebTargetAdapterRequest myManager = manager;
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
else
|
else if (response.getHTTPCode()==403)
|
||||||
|
throw new UserNotAuthorizedException("the call to this method is not allowed for the user");
|
||||||
|
else
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return response.getSource().readEntity(List.class);
|
return response.getSource().readEntity(List.class);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -112,5 +127,5 @@ public class DefaultUserManager implements UserManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,14 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void creteAndREmoveUser() throws StorageHubException {
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
shc.createUserAccount("giorgino");
|
||||||
|
shc.deleteUserAccount("giorgino");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeUserFromVRE() throws StorageHubException {
|
public void removeUserFromVRE() throws StorageHubException {
|
||||||
|
|
Loading…
Reference in New Issue