This commit is contained in:
Lucio Lelii 2019-07-25 15:47:18 +00:00
parent f9c211f55a
commit ed2ef1de33
6 changed files with 50 additions and 10 deletions

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<name>storagehub-client-library</name>
<dependencyManagement>

View File

@ -41,6 +41,16 @@ public class StorageHubClient {
wsClient.emptyTrash();
}
public double getTotalVolume() {
return wsClient.getTotalVolume();
}
public long getTotalItemCount() {
return wsClient.getTotalItemCount();
}
public GenericItemContainer restoreThrashItem(String itemId) {
return new GenericItemContainer(itemclient, wsClient.restoreFromTrash(itemId));
}

View File

@ -351,7 +351,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
}
@Override
public String getTotalItemCount() {
public long getTotalItemCount() {
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
@Override
public String call(GXWebTargetAdapterRequest manager) throws Exception {
@ -370,14 +370,14 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
}
};
try {
return delegate.make(call);
return Long.parseLong(delegate.make(call));
}catch(Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getTotalVolume() {
public long getTotalVolume() {
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
@Override
public String call(GXWebTargetAdapterRequest manager) throws Exception {
@ -396,7 +396,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
}
};
try {
return delegate.make(call);
return Long.parseLong(delegate.make(call));
}catch(Exception e) {
throw new RuntimeException(e);
}

View File

@ -28,8 +28,8 @@ public interface WorkspaceManagerClient {
void emptyTrash();
String getTotalItemCount();
long getTotalItemCount();
String getTotalVolume();
long getTotalVolume();
}

View File

@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
@ -19,6 +20,7 @@ import org.gcube.common.storagehub.client.dsl.FileContainer;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
@ -148,6 +150,34 @@ public class Items {
}
@Test
public void changeProp() throws Exception {
StorageHubClient shc = new StorageHubClient();
ItemContainer item = shc.open("6399daa7-2173-4314-b4f7-2afa24eae8f8").asItem();
Metadata first = item.get().getMetadata();
first.getMap().put("lucio", "ok");
item.setMetadata(first);
Metadata second = item.get().getMetadata();
for (Entry<String, Object> entry: second.getMap().entrySet())
System.out.println(entry.getKey()+" "+entry.getValue());
second.getMap().put("lucio", null);
second.getMap().put("lelii", "0");
item.setMetadata(second);
Metadata third = item.get().getMetadata();
for (Entry<String, Object> entry: third.getMap().entrySet())
System.out.println(entry.getKey()+" "+entry.getValue());
}
@Test
public void uploadArchive() throws Exception {

View File

@ -53,8 +53,8 @@ public class TestCall {
@BeforeClass
public static void setUp(){
SecurityTokenProvider.instance.set("7c26a682-f47b-4e6e-90e0-6d101a4314cd-980114272");
ScopeProvider.instance.set("/pred4s");
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
ScopeProvider.instance.set("/gcube");
}
@Test(expected=UserNotAuthorizedException.class)
@ -281,7 +281,7 @@ public class TestCall {
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
//String path = wsclient.getVreFolder("hl:accounting").getPath();
//System.out.println("path is "+path);
query.setExpression(new ISDescendant(Paths.getPath("/Home/m.assante/Workspace/")));
query.setExpression(new ISDescendant(Paths.getPath("/Home/lucio.lelii/Workspace/")));
query.setLimit(10);
query.setOrder(new OrderField(GenericSearchableItem.get().title));
List<? extends Item> items = wsclient.search(query, "hl:accounting", "jcr:content");