git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@179517 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
16b2ab9440
commit
1cade193a4
|
@ -68,10 +68,15 @@ public abstract class ItemContainer<I extends Item> {
|
|||
}
|
||||
|
||||
public void delete() throws StorageHubException {
|
||||
itemclient.delete(this.itemId);
|
||||
itemclient.delete(this.itemId, false);
|
||||
invalidateItem();
|
||||
}
|
||||
|
||||
public void forceDelete() throws StorageHubException {
|
||||
itemclient.delete(this.itemId, true);
|
||||
invalidateItem();
|
||||
}
|
||||
|
||||
public void rename(String newName) throws StorageHubException {
|
||||
itemclient.rename(this.getId(), newName);
|
||||
invalidateItem();
|
||||
|
|
|
@ -787,15 +787,25 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void delete(String id) throws StorageHubException {
|
||||
delete(id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id, boolean force) throws StorageHubException {
|
||||
Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
|
||||
@Override
|
||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||
Objects.requireNonNull(id, "id cannot be null");
|
||||
|
||||
|
||||
HashMap<String, Object[]> queryParam = new HashMap<String, Object[]>();
|
||||
queryParam.put("force", new Object[] {force});
|
||||
|
||||
GXWebTargetAdapterRequest myManager = manager.path(id);
|
||||
myManager.queryParams(queryParam);
|
||||
GXInboundResponse response = myManager.delete();
|
||||
|
||||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException())
|
||||
throw response.getException();
|
||||
|
@ -880,6 +890,43 @@ public class DefaultItemManager implements ItemManagerClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeACL(String id, String user, AccessType accessType) throws StorageHubException {
|
||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||
@Override
|
||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||
Objects.requireNonNull(id, "id cannot be null");
|
||||
Objects.requireNonNull(user, "user cannot be null");
|
||||
|
||||
|
||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls");
|
||||
|
||||
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
||||
multipart.field("accessType", accessType, MediaType.APPLICATION_JSON_TYPE);
|
||||
multipart.field("user", user);
|
||||
|
||||
GXInboundResponse response = myManager.put(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||
|
||||
if (response.isErrorResponse()) {
|
||||
if (response.hasException())
|
||||
throw response.getException();
|
||||
else
|
||||
throw new BackendGenericError();
|
||||
}
|
||||
|
||||
return response.getSource().readEntity(String.class);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
try {
|
||||
return delegate.make(call);
|
||||
}catch(StorageHubException e) {
|
||||
throw e;
|
||||
}catch(Exception e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String copy(String id, String destinationFolderId, String newFilename) throws StorageHubException {
|
||||
|
|
|
@ -44,7 +44,10 @@ public interface ItemManagerClient {
|
|||
String createFolder(String parentId, String name, String description) throws StorageHubException;
|
||||
|
||||
List<ACL> getACL(String id) throws StorageHubException;
|
||||
|
||||
String changeACL(String id, String user, AccessType accessType) throws StorageHubException;
|
||||
|
||||
@Deprecated
|
||||
void delete(String id) throws StorageHubException;
|
||||
|
||||
URL getPublickLink(String id) throws StorageHubException;
|
||||
|
@ -89,6 +92,8 @@ public interface ItemManagerClient {
|
|||
@Deprecated
|
||||
Integer childrenCount(String id) throws StorageHubException;
|
||||
|
||||
void delete(String id, boolean force) throws StorageHubException;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue