git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@173837 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7069e5e1e3
commit
0ec7ab1ed2
|
@ -39,7 +39,7 @@ public class ItemManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest,
|
|||
String address = child.getTextContent();
|
||||
//GXWebTargetAdapterRequest request = GXWebTargetAdapterRequest.newRequest(address).path(this.name).path("items");
|
||||
GcubeService service = GcubeService.service().withName(Constants.MANAGER_QNAME).andPath("items");
|
||||
return TargetFactory.stubFor(service).at(address);
|
||||
return TargetFactory.stubFor(service).getAsGxRest(address);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,6 @@ public class WorkspaceManagerPlugin extends AbstractPlugin<GXWebTargetAdapterReq
|
|||
Node child=node.getFirstChild();
|
||||
String address = child.getTextContent();
|
||||
GcubeService service = GcubeService.service().withName(Constants.MANAGER_QNAME).useRootPath();
|
||||
return TargetFactory.stubFor(service).at(address);
|
||||
return TargetFactory.stubFor(service).getAsGxRest(address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ public class Items {
|
|||
@BeforeClass
|
||||
public static void setUp(){
|
||||
//SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
||||
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
||||
SecurityTokenProvider.instance.set("a5b623b6-6577-4271-aba6-7ada687d29cf-98187548");
|
||||
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
ScopeProvider.instance.set("/gcube/preprod");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import javax.ws.rs.client.Entity;
|
|||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
|
@ -36,7 +37,8 @@ import org.gcube.common.storagehub.model.expressions.logical.And;
|
|||
import org.gcube.common.storagehub.model.expressions.logical.ISDescendant;
|
||||
import org.gcube.common.storagehub.model.expressions.text.Like;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.GCubeItem;
|
||||
import org.gcube.common.storagehub.model.items.ImageFile;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.query.Queries;
|
||||
import org.gcube.common.storagehub.model.query.Query;
|
||||
|
@ -53,8 +55,8 @@ public class TestCall {
|
|||
|
||||
//SecurityTokenProvider.instance.set("0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548");
|
||||
//token costantino 9ca79556-54b0-4bbf-ab0f-151ae326f4cf-98187548
|
||||
SecurityTokenProvider.instance.set("d9431600-9fef-41a7-946d-a5b402de30d6-98187548");
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
SecurityTokenProvider.instance.set("04269c7d-dab7-498a-841d-8d38ae2d482b-98187548");
|
||||
ScopeProvider.instance.set("/gcube/preprod");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -120,6 +122,8 @@ public class TestCall {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getById() throws Exception{
|
||||
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||
|
@ -142,10 +146,23 @@ public class TestCall {
|
|||
prop.put("folderProp2", "test2");
|
||||
meta.setValues(prop);
|
||||
client.setMetadata("8822478a-4fd3-41d5-87de-9ff161d0935e", meta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createGcubeItem() {
|
||||
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||
GCubeItem item = new GCubeItem();
|
||||
item.setName("itemTest");
|
||||
item.setDescription("test descr");
|
||||
item.setScopes(new String[] {"/gcube", "/gcube/devsec"});
|
||||
item.setItemType("myType");
|
||||
item.setCreator("me");
|
||||
|
||||
WorkspaceManagerClient wsc = AbstractPlugin.workspace().build();
|
||||
Item ws = wsc.getWorkspace();
|
||||
|
||||
client.createGcubeItem(ws.getId(), item);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upload() throws Exception{
|
||||
|
@ -166,6 +183,8 @@ public class TestCall {
|
|||
|
||||
//client.uploadFile(new FileInputStream("/home/lucio/Downloads/test5Gb.zip"), "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "5gb.zip", "description");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -285,6 +304,19 @@ public class TestCall {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getImage() throws Exception{
|
||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||
ImageFile img = (ImageFile)itemclient.get("58acc91a-c8f9-4d78-be8e-1175042f171d");
|
||||
String ext = FilenameUtils.getExtension(img.getName());
|
||||
File imgFile = File.createTempFile("thumb", "."+ext);
|
||||
try (FileOutputStream f = new FileOutputStream(imgFile)){
|
||||
for (byte b : img.getContent().getThumbnailData())
|
||||
f.write(b);
|
||||
}
|
||||
System.out.println(imgFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void createFolder() throws Exception{
|
||||
|
@ -305,5 +337,40 @@ public class TestCall {
|
|||
System.out.println("result: "+!b);
|
||||
}
|
||||
|
||||
/* private InputStream getThumbnailAsPng(ImagePlus img, int thumbWidth,
|
||||
int thumbHeight) throws IOException {
|
||||
|
||||
InputStream stream = null;
|
||||
ImageProcessor processor = img.getProcessor();
|
||||
try{
|
||||
Image thumb = processor.resize(thumbWidth, thumbHeight).createImage();
|
||||
thumb = thumb.getScaledInstance(thumbWidth,thumbHeight,Image.SCALE_SMOOTH);
|
||||
|
||||
FileSaver fs = new FileSaver(new ImagePlus("",thumb));
|
||||
File tmpThumbFile = File.createTempFile("THUMB", "TMP");
|
||||
tmpThumbFile.deleteOnExit();
|
||||
|
||||
fs.saveAsPng(tmpThumbFile.getAbsolutePath());
|
||||
stream = new FileInputStream(tmpThumbFile);
|
||||
|
||||
}catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
public static ImagePlus getImgePlus(String pathOrURL) throws IOException {
|
||||
|
||||
//necessary to run without WINDOWS X11
|
||||
System.setProperty("java.awt.headless","true");
|
||||
|
||||
ImagePlus img = null;
|
||||
try{
|
||||
img = new ImagePlus(pathOrURL);
|
||||
}catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return img;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue