This commit is contained in:
Lucio Lelii 2018-10-15 14:43:53 +00:00
parent 715e845187
commit 6d3d9e2faa
3 changed files with 39 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.GCubeItem;
public class FolderContainer extends ItemContainer<FolderItem>{
@ -42,6 +43,11 @@ public class FolderContainer extends ItemContainer<FolderItem>{
return new FolderContainer(itemclient, newFolderId);
}
public GenericItemContainer newGcubeItem(GCubeItem item) throws Exception {
String itemId = itemclient.createGcubeItem(this.itemId, item);
return new GenericItemContainer(itemclient, itemId);
}
public List<ACL> getAcls() throws Exception {
return itemclient.getACL(this.itemId);
}

View File

@ -23,6 +23,7 @@ import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.annotations.RootNode;
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
import org.gcube.common.storagehub.model.items.GCubeItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.service.ItemList;
import org.gcube.common.storagehub.model.service.ItemWrapper;
@ -496,7 +497,35 @@ public class DefaultItemManager implements ItemManagerClient {
throw new RuntimeException(e);
}
}
@Override
public String createGcubeItem(String parentId, GCubeItem item) {
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
@Override
public String call(GXWebTargetAdapterRequest manager) throws Exception {
GXWebTargetAdapterRequest myManager = manager.path(parentId)
.path("create").path("GCUBEITEM");
GXInboundResponse response = myManager.post(Entity.json(item));
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(Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String shareFolder(String id, Set<String> users, AccessType accessType) {
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {

View File

@ -9,6 +9,7 @@ import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.items.GCubeItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.service.Version;
@ -65,5 +66,7 @@ public interface ItemManagerClient {
StreamDescriptor downloadSpecificVersion(String id, String version);
String setMetadata(String id,Metadata metadata);
String createGcubeItem(String parentId, GCubeItem item);
}