git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@181652 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9d59308a21
commit
76bd21e063
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>1.0.6-SNAPSHOT</version>
|
<version>1.0.7-SNAPSHOT</version>
|
||||||
<name>storagehub-client-library</name>
|
<name>storagehub-client-library</name>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -550,15 +550,15 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
|
|
||||||
GXInboundResponse response =null;
|
GXInboundResponse response =null;
|
||||||
FormDataMultiPart multipart = new FormDataMultiPart();
|
FormDataMultiPart multipart = new FormDataMultiPart();
|
||||||
|
|
||||||
multipart.field("name", fileName);
|
multipart.field("name", fileName);
|
||||||
multipart.field("description", description);
|
multipart.field("description", description);
|
||||||
multipart.field("file", stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
multipart.field("file", stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
response = myManager.post(entity);
|
response = myManager.post(entity);
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
|
@ -675,8 +675,8 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createURL(String parentId, String name, String description,URL url) throws StorageHubException {
|
public String createURL(String parentId, String name, String description,URL url) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@ -831,20 +831,20 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public void delete(String id) throws StorageHubException {
|
public void delete(String id) throws StorageHubException {
|
||||||
delete(id, false);
|
delete(id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String id, boolean force) throws StorageHubException {
|
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[]>();
|
HashMap<String, Object[]> queryParam = new HashMap<String, Object[]>();
|
||||||
queryParam.put("force", new Object[] {force});
|
queryParam.put("force", new Object[] {force});
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id);
|
GXWebTargetAdapterRequest myManager = manager.path(id);
|
||||||
GXInboundResponse response = myManager.queryParams(queryParam).delete();
|
GXInboundResponse response = myManager.queryParams(queryParam).delete();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
|
@ -929,30 +929,30 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canWriteInto(String id) throws StorageHubException {
|
public boolean canWriteInto(String id) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, Boolean> call = new Call<GXWebTargetAdapterRequest, Boolean>() {
|
Call<GXWebTargetAdapterRequest, Boolean> call = new Call<GXWebTargetAdapterRequest, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Boolean call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls").path("write");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls").path("write");
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
throw new BackendGenericError();
|
throw new BackendGenericError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return response.getSource().readEntity(Boolean.class);
|
return response.getSource().readEntity(Boolean.class);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -964,9 +964,9 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String changeACL(String id, String user, AccessType accessType) throws StorageHubException {
|
public String changeACL(String id, String user, AccessType accessType) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@ -974,10 +974,10 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
Objects.requireNonNull(user, "user cannot be null");
|
Objects.requireNonNull(user, "user cannot be null");
|
||||||
|
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls");
|
||||||
|
|
||||||
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
||||||
multipart.field("access", accessType, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("access", accessType, MediaType.APPLICATION_JSON_TYPE);
|
||||||
multipart.field("user", user);
|
multipart.field("user", user);
|
||||||
|
@ -1005,6 +1005,44 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String removeSharedFolderAdmin(String id, String user) 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").path(user);
|
||||||
|
|
||||||
|
|
||||||
|
GXInboundResponse response = myManager.delete();
|
||||||
|
|
||||||
|
|
||||||
|
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 {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@ -1043,16 +1081,16 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String setPublic(String id, boolean publish) throws StorageHubException {
|
public String setPublic(String id, boolean publish) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id)
|
GXWebTargetAdapterRequest myManager = manager.path(id)
|
||||||
.path("publish");
|
.path("publish");
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ 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;
|
String changeACL(String id, String user, AccessType accessType) throws StorageHubException;
|
||||||
|
|
||||||
|
String removeSharedFolderAdmin(String id, String user) throws StorageHubException;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void delete(String id) throws StorageHubException;
|
void delete(String id) throws StorageHubException;
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class Items {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp(){
|
public static void setUp(){
|
||||||
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
SecurityTokenProvider.instance.set("257800d8-24bf-4bae-83cd-ea99369e7dd6-843339462");
|
||||||
ScopeProvider.instance.set("/gcube");
|
ScopeProvider.instance.set("/d4science.research-infrastructures.eu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ public class Items {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
FileContainer file = null;
|
FileContainer file = null;
|
||||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/PortletTesting.xlsx"))){
|
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/.richiesta speroni.pdf"))){
|
||||||
file = shc.open("1672d620-543e-4c76-b0af-4c46f52cbc82").asFolder().uploadFile(is, "PortletTestingSenzaExt", "graphs");
|
file = shc.getWSRoot().uploadFile(is, ".richiesta speroni.pdf", "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue