removed double call for upload file
This commit is contained in:
parent
28e4e9eb56
commit
18d2fb9287
|
@ -662,22 +662,6 @@ public class DefaultItemManager extends DefaultManagerClient implements ItemMana
|
||||||
multipart.bodyPart(filePart);
|
multipart.bodyPart(filePart);
|
||||||
|
|
||||||
response = myManager.queryParams(initQueryParameters()).post(Entity.entity(multipart, multipart.getMediaType()));
|
response = myManager.queryParams(initQueryParameters()).post(Entity.entity(multipart, multipart.getMediaType()));
|
||||||
|
|
||||||
|
|
||||||
ContentDisposition contentDisposition;
|
|
||||||
if (contentLength>0)
|
|
||||||
contentDisposition = ContentDisposition.type("attachment").fileName(fileName).size(contentLength).build();
|
|
||||||
else
|
|
||||||
contentDisposition = ContentDisposition.type("attachment").fileName(fileName).build();
|
|
||||||
|
|
||||||
|
|
||||||
BodyPart fdp = new StreamDataBodyPart("file", stream);
|
|
||||||
|
|
||||||
multipart.bodyPart(fdp);
|
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
|
||||||
|
|
||||||
response = myManager.queryParams(initQueryParameters()).header("Content-Disposition",Arrays.asList(contentDisposition.toString())).post(entity);
|
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Items {
|
||||||
|
|
||||||
private static final String tokens = "dev-devvre";
|
private static final String tokens = "dev-devvre";
|
||||||
//private static final String tokens = "prod-root";
|
//private static final String tokens = "prod-root";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp(){
|
public static void setUp(){
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class Items {
|
||||||
String[] splitValue = value.split(",");
|
String[] splitValue = value.split(",");
|
||||||
String token = splitValue[1];
|
String token = splitValue[1];
|
||||||
//SecretManagerProvider.instance.set(new GCubeSecret(token));
|
//SecretManagerProvider.instance.set(new GCubeSecret(token));
|
||||||
|
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
ScopeProvider.instance.set(splitValue[0]);
|
ScopeProvider.instance.set(splitValue[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -64,14 +64,14 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addUserToVRe() throws StorageHubException {
|
public void addUserToVRe() throws StorageHubException {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
|
||||||
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File(vresFile))){
|
try(InputStream is = new FileInputStream(new File(vresFile))){
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
prop.load(is);
|
prop.load(is);
|
||||||
|
@ -85,32 +85,32 @@ public class Items {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uploadTovolatile() throws StorageHubException {
|
public void uploadTovolatile() throws StorageHubException {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
|
||||||
String vresFile = "/home/lucio/Downloads/stampa_crossover_retro.pdf";
|
String vresFile = "/home/lucio/Downloads/stampa_crossover_retro.pdf";
|
||||||
|
|
||||||
File file = new File(vresFile);
|
File file = new File(vresFile);
|
||||||
|
|
||||||
try ( InputStream fileIS = new FileInputStream(file)){
|
try ( InputStream fileIS = new FileInputStream(file)){
|
||||||
shc.getWSRoot().uploadFile(fileIS, "stampa_crossover_retro.pdf", "description");
|
shc.getWSRoot().uploadFile(fileIS, "stampa_crossover_retro.pdf", "description");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeTest() {
|
public void removeTest() {
|
||||||
try {
|
try {
|
||||||
|
@ -128,29 +128,36 @@ public class Items {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void stressTest() {
|
public void stressTest() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
IntStream.range(1, 100).forEach( i-> {
|
IntStream.range(1, 300).forEach( i-> {
|
||||||
try {
|
try {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
FolderContainer vre = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
FolderContainer vre = shc.openVREFolder().openByRelativePath("testLucio").asFolder();
|
||||||
FolderContainer fc = vre.newFolder("folder"+i, "");
|
FolderContainer fc = vre.newFolder("folder"+i, "");
|
||||||
IntStream.range(1, 3).forEach(k -> {
|
for (int t =1 ; t<10; t++) {
|
||||||
String vresFile = "/home/lucio/Scaricati/NLP-Hub-Algorithms.pptx";
|
StorageHubClient shc1 = new StorageHubClient();
|
||||||
|
FolderContainer sub = shc1.open(fc.getId()).asFolder();
|
||||||
File file = new File(vresFile);
|
FolderContainer fcsub2 = sub.newFolder("folder"+i+"-"+t, "");
|
||||||
|
for (int k=0;k<3;k++) {
|
||||||
try ( InputStream fileIS = new FileInputStream(file)){
|
String vresFile = "/home/lucio/Downloads/GNA_foto_Cuma Necropoli mediana_4B.jpg";
|
||||||
fc.uploadFile(fileIS, "file"+k, "description");
|
|
||||||
} catch (Exception e) {
|
StorageHubClient shc2 = new StorageHubClient();
|
||||||
e.printStackTrace();
|
FolderContainer sub2 = shc2.open(fcsub2.getId()).asFolder();
|
||||||
|
|
||||||
|
File file = new File(vresFile);
|
||||||
|
|
||||||
|
try ( InputStream fileIS = new FileInputStream(file)){
|
||||||
|
sub2.uploadFile(fileIS, "file"+k, "description");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
} catch (StorageHubException e) {
|
} catch (StorageHubException e) {
|
||||||
System.out.println("error creating stressTest"+i);
|
System.out.println("error creating stressTest"+i);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +166,7 @@ public class Items {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() {
|
public void search() {
|
||||||
try {
|
try {
|
||||||
|
@ -222,7 +229,7 @@ public class Items {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItem() throws Exception{
|
public void getItem() throws Exception{
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
@ -230,7 +237,7 @@ public class Items {
|
||||||
System.out.println("owner is "+owner);
|
System.out.println("owner is "+owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uploadFile() throws Exception{
|
public void uploadFile() throws Exception{
|
||||||
|
|
||||||
|
@ -238,12 +245,12 @@ public class Items {
|
||||||
|
|
||||||
FolderContainer myRoot = shc.open("11cbdc0c-e873-418c-bc53-5f6329eb88fb").asFolder();
|
FolderContainer myRoot = shc.open("11cbdc0c-e873-418c-bc53-5f6329eb88fb").asFolder();
|
||||||
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
File inFile = new File("/home/lucio/Downloads/scimmia braccia aperte.mp4");
|
File inFile = new File("/home/lucio/Downloads/scimmia braccia aperte.mp4");
|
||||||
try(InputStream is = new FileInputStream(inFile)){
|
try(InputStream is = new FileInputStream(inFile)){
|
||||||
myRoot.uploadFile(is, "scimmia braccia aperte.mp4", "file");
|
myRoot.uploadFile(is, "scimmia braccia aperte.mp4", "file");
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
||||||
|
@ -296,10 +303,10 @@ public class Items {
|
||||||
/*AccessTokenSecret secret = new AccessTokenSecret("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDQyNDM4ODUsImlhdCI6MTY0NDI0MzU4NSwiYXV0aF90aW1lIjoxNjQ0MjQzNTg1LCJqdGkiOiI1NWQ4ZDc5OS1kNTIzLTQ0YmEtYTRkMC1iZjIyYzVlMTg4NzQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsImF1ZCI6IiUyRmdjdWJlIiwic3ViIjoiNGMxMWRlODQtZGRjOS00ZGQxLWI5N2EtZWE4MmQyZDEzOGE2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoibmV4dC5kNHNjaWVuY2Uub3JnIiwic2Vzc2lvbl9zdGF0ZSI6ImZkZTA3MGE2LTVkOTUtNDc3Ni1hMTFiLTBhZTI1MzQ5NGQyMyIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVzb3VyY2VfYWNjZXNzIjp7IiUyRmdjdWJlIjp7InJvbGVzIjpbIkluZnJhc3RydWN0dXJl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xXNBLsoEpELju3pr2gEkv1ZRH9bZkyg7_3hW4mGzxq_Ea9w1FBVJOlkp6vypuISLNyJZcVOnBa4Dg1KRxxlp3aZ6vA");
|
||||||
SecretManagerProvider.instance.set(secret);*/
|
SecretManagerProvider.instance.set(secret);*/
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
shc.getVreFolderManager("gcube-devsec-devVre").addUser("vincenzo.cestone");
|
shc.getVreFolderManager("gcube-devsec-devVre").addUser("vincenzo.cestone");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeUser() throws Exception {
|
public void removeUser() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
@ -308,8 +315,8 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeProp() throws Exception {
|
public void changeProp() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
@ -351,7 +358,7 @@ public class Items {
|
||||||
}
|
}
|
||||||
con.connect();
|
con.connect();
|
||||||
int responseCode = con.getResponseCode();
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
if (responseCode < 400 && responseCode > 299) {
|
if (responseCode < 400 && responseCode > 299) {
|
||||||
String redirectUrl = con.getHeaderField("Location");
|
String redirectUrl = con.getHeaderField("Location");
|
||||||
try {
|
try {
|
||||||
|
@ -362,7 +369,7 @@ public class Items {
|
||||||
return urlToInputStream(newUrl, args);
|
return urlToInputStream(newUrl, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inputStream = con.getInputStream();
|
inputStream = con.getInputStream();
|
||||||
return inputStream;
|
return inputStream;
|
||||||
|
@ -378,12 +385,12 @@ public class Items {
|
||||||
URL remote = new URI("https://data.bluecloud.cineca.it/api/download/gAAAAABhaSJN8TUA71la3mKMOL9D"
|
URL remote = new URI("https://data.bluecloud.cineca.it/api/download/gAAAAABhaSJN8TUA71la3mKMOL9D"
|
||||||
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
||||||
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==").toURL();
|
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==").toURL();
|
||||||
|
|
||||||
|
|
||||||
try(InputStream is = remote.openStream() ){
|
try(InputStream is = remote.openStream() ){
|
||||||
shc.getWSRoot().uploadArchive(is, "testUploadArchive");
|
shc.getWSRoot().uploadArchive(is, "testUploadArchive");
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -431,7 +438,7 @@ public class Items {
|
||||||
public void createFolderWhenNotExists() throws Exception{
|
public void createFolderWhenNotExists() throws Exception{
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
FolderContainer container = shc.openVREFolder();
|
FolderContainer container = shc.openVREFolder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FolderContainer attachmentFolder = container.openByRelativePath("Attachment-Lucio").asFolder();
|
FolderContainer attachmentFolder = container.openByRelativePath("Attachment-Lucio").asFolder();
|
||||||
System.out.println("fodler name is "+attachmentFolder.get().getName());
|
System.out.println("fodler name is "+attachmentFolder.get().getName());
|
||||||
|
@ -441,7 +448,7 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadFile() throws Exception{
|
public void downloadFile() throws Exception{
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
Loading…
Reference in New Issue