diff --git a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/dataspace/DataspaceManager.java b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/dataspace/DataspaceManager.java index bfd0467..5669956 100755 --- a/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/dataspace/DataspaceManager.java +++ b/src/main/java/org/gcube/dataanalysis/wps/statisticalmanager/synchserver/mapping/dataspace/DataspaceManager.java @@ -64,7 +64,7 @@ public class DataspaceManager implements Runnable { public static String payload = "payload"; private String statusComputationName; - private static final String STATUS_POSTFIX="-STATUS"; + private static final String STATUS_POSTFIX = "-STATUS"; public DataspaceManager(AlgorithmConfiguration config, ComputationData computation, List inputData, List outputData, List generatedFiles) { @@ -73,7 +73,7 @@ public class DataspaceManager implements Runnable { this.inputData = inputData; this.outputData = outputData; this.generatedFiles = generatedFiles; - this.statusComputationName = this.computation.id+STATUS_POSTFIX; + this.statusComputationName = this.computation.id + STATUS_POSTFIX; LOGGER.debug("DataspaceManager [config=" + config + ", computation=" + computation + ", inputData=" + inputData + ", outputData=" + outputData + ", generatedFiles=" + generatedFiles + "]"); @@ -142,25 +142,26 @@ public class DataspaceManager implements Runnable { } public String uploadData(StoredData data, FolderContainer destinationFolder, boolean changename) throws Exception { - LOGGER.debug("Dataspace->Analysing " + data); + LOGGER.debug("Dataspace->Uploaddata:" + + " [data={},destinationFolder={}, changename={}] ", data, destinationFolder, + changename); // String filenameonwsString = WorkspaceUtil.getUniqueName(data.name, // wsFolder); String filenameonwsString = data.name; if (changename) - filenameonwsString = String.format("%s_(%s)%s", data.name, data.computationId, - getExtension(data.payload)); + filenameonwsString = String.format("%s_(%s)%s", data.name, data.computationId, getExtension(data.payload)); InputStream in = null; String url = ""; try { - //long size = 0; + // long size = 0; if (data.type.equals("text/csv") || data.type.equals("application/d4science") || data.type.equals("image/png")) { if (new File(data.payload).exists() || !data.payload.startsWith("http")) { LOGGER.debug("Dataspace->Uploading file {}", data.payload); in = new FileInputStream(new File(data.payload)); - //size = new File(data.payload).length(); + // size = new File(data.payload).length(); } else { LOGGER.debug("Dataspace->Uploading via URL {}", data.payload); int tries = 10; @@ -188,7 +189,7 @@ public class DataspaceManager implements Runnable { // LOGGER.debug("Dataspace->final file name on ws " + // data.name+" description "+data.description); - LOGGER.debug("Dataspace->WS OP saving the following file on the WS " + filenameonwsString); + LOGGER.debug("Dataspace->WS OP saving the following file on the WS: " + filenameonwsString); Map properties = new LinkedHashMap(); properties.put(computation_id, data.computationId); @@ -203,9 +204,11 @@ public class DataspaceManager implements Runnable { properties.put(payload, url); FileContainer fileContainer = destinationFolder.uploadFile(in, filenameonwsString, data.description); - fileContainer.setMetadata(new Metadata(properties)); + LOGGER.debug("Dataspace->WS OP file uploaded on WS: " + filenameonwsString); + Metadata metadata = new Metadata(properties); + fileContainer.setMetadata(metadata); - LOGGER.debug("Dataspace->WS OP file saved on the WS " + filenameonwsString); + LOGGER.debug("Dataspace->WS OP file set metadata: " + metadata); url = fileContainer.getPublicLink().toString(); LOGGER.debug("Dataspace->WS OP url produced for the file " + url); @@ -395,10 +398,9 @@ public class DataspaceManager implements Runnable { } /* * List scopes = new ArrayList(); - * scopes.add(config.getGcubeScope()); - * ws.createGcubeItem(computation.id, computation.operatorDescription, - * scopes, computation.user, itemType, properties, - * newcomputationFolder.getId()); + * scopes.add(config.getGcubeScope()); ws.createGcubeItem(computation.id, + * computation.operatorDescription, scopes, computation.user, itemType, + * properties, newcomputationFolder.getId()); */ newcomputationFolder.setMetadata(new Metadata(properties)); @@ -465,8 +467,8 @@ public class DataspaceManager implements Runnable { List scopes = new ArrayList(); scopes.add(config.getGcubeScope()); - - //TODO: update gcubeItem not recreate it... + + // TODO: update gcubeItem not recreate it... GCubeItem gcubeItem = new GCubeItem(); gcubeItem.setName(this.statusComputationName); gcubeItem.setDescription(computation.operatorDescription); @@ -509,7 +511,8 @@ public class DataspaceManager implements Runnable { .getContainers().get(0); LOGGER.debug("Dataspace->removing computation data"); - List> wi = computationContainer.findByName(this.statusComputationName).getContainers(); + List> wi = computationContainer.findByName(this.statusComputationName) + .getContainers(); if (!wi.isEmpty()) { for (ItemContainer container : wi) { boolean retry = false; @@ -517,25 +520,23 @@ public class DataspaceManager implements Runnable { try { container.forceDelete(); retry = false; - }catch (ItemLockedException e) { + } catch (ItemLockedException e) { LOGGER.warn("item locked, retrying"); Thread.sleep(1000); retry = true; } - }while (retry); + } while (retry); } } else LOGGER.debug("Dataspace->Warning Could not find {} under {}", this.statusComputationName, computationContainer.get().getName()); - /* * TODO: ASK GIANPAOLO int maxtries = 3; int i =1; while - * (ws.exists(computation.id,computationsFolderWs.getId()) && - * icomputation data still exist... retrying "+i - * ); Thread.sleep(1000); - * computationsFolderWs.find(computation.id).remove(); i++; } + * (ws.exists(computation.id,computationsFolderWs.getId()) && icomputation data still exist... retrying "+i ); + * Thread.sleep(1000); computationsFolderWs.find(computation.id).remove(); i++; + * } */ LOGGER.debug("Dataspace->finished removing computation data "); @@ -544,7 +545,7 @@ public class DataspaceManager implements Runnable { // TODO public static String getExtension(String payload) { LOGGER.debug("DataSpace->Get Extension from: " + payload); - String extension=""; + String extension = ""; if (payload.toLowerCase().startsWith("http")) { try { URL obj = new URL(payload);