This commit is contained in:
Lucio Lelii 2019-05-22 15:12:47 +00:00
parent 16b2ab9440
commit 1cade193a4
3 changed files with 60 additions and 3 deletions

View File

@ -68,7 +68,12 @@ public abstract class ItemContainer<I extends Item> {
} }
public void delete() throws StorageHubException { 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(); invalidateItem();
} }

View File

@ -787,13 +787,23 @@ public class DefaultItemManager implements ItemManagerClient {
} }
@Override @Override
@Deprecated
public void delete(String id) throws StorageHubException { 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>() { Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
@Override @Override
public Void call(GXWebTargetAdapterRequest manager) throws Exception { public Void call(GXWebTargetAdapterRequest manager) throws Exception {
Objects.requireNonNull(id, "id cannot be null"); 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); GXWebTargetAdapterRequest myManager = manager.path(id);
myManager.queryParams(queryParam);
GXInboundResponse response = myManager.delete(); GXInboundResponse response = myManager.delete();
if (response.isErrorResponse()) { if (response.isErrorResponse()) {
@ -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 @Override
public String copy(String id, String destinationFolderId, String newFilename) throws StorageHubException { public String copy(String id, String destinationFolderId, String newFilename) throws StorageHubException {

View File

@ -45,6 +45,9 @@ public interface ItemManagerClient {
List<ACL> getACL(String id) 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; void delete(String id) throws StorageHubException;
URL getPublickLink(String id) throws StorageHubException; URL getPublickLink(String id) throws StorageHubException;
@ -89,6 +92,8 @@ public interface ItemManagerClient {
@Deprecated @Deprecated
Integer childrenCount(String id) throws StorageHubException; Integer childrenCount(String id) throws StorageHubException;
void delete(String id, boolean force) throws StorageHubException;
} }