diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java index db1c4a5..5a78cbb 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java @@ -9,10 +9,11 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.file.Files; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; -import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; @@ -53,7 +54,7 @@ public class AnalyticsCreateResolver { /** - * + * */ private static final String DATAMINER_INVOCATION_MODEL = "dim"; /** @@ -63,6 +64,8 @@ public class AnalyticsCreateResolver { private static Logger logger = LoggerFactory.getLogger(AnalyticsCreateResolver.class); private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#Analitycs_Resolver"; + private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + /** * Post catalogue. * @@ -169,7 +172,8 @@ public class AnalyticsCreateResolver { try { ByteArrayOutputStream xmlByteArray = DataMinerInvocationManager.marshaling(dmInvocation, org.gcube.data.analysis.dminvocation.MediaType.ApplicationXML); - tempInvocationFile = createTempFile("dataminer-invocation"+UUID.randomUUID(), ".xml", xmlByteArray.toByteArray()); + String uniqueName = createDMInvocationFileName(jsonRequest.getOperatorId()); + tempInvocationFile = createTempFile(uniqueName, ".xml", xmlByteArray.toByteArray()); //CREATE THE FILE ON STORAGE HUB @@ -205,6 +209,7 @@ public class AnalyticsCreateResolver { } + /** * Creates the temp file. * @@ -224,4 +229,22 @@ public class AnalyticsCreateResolver { return file; } + + /** + * Creates the dm invocation file name. + * + * @param operatorId the operator id + * @return the string + */ + private static String createDMInvocationFileName(String operatorId){ + String fileName = "dim"; + int index = operatorId.lastIndexOf("."); + if(index>0 && indexDataTransfer 1.0.0-SNAPSHOT URIResolver RESTful - /analytics/create /knime/create - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/java/rest/TestResolvers.java b/src/test/java/rest/TestResolvers.java index 6518bdb..fc8cbb9 100644 --- a/src/test/java/rest/TestResolvers.java +++ b/src/test/java/rest/TestResolvers.java @@ -19,7 +19,6 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.http.HttpStatus; import org.gcube.datatransfer.resolver.util.HTTPCallsUtils; -import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,7 +85,7 @@ public class TestResolvers { * * @throws Exception the exception */ - @Test + //@Test public void testStorageID() throws Exception{ String storageID = "clZ2YmxTYytETzVLaHkwMjM3TmVETTFMb256YVRMS3lHbWJQNStIS0N6Yz0"; @@ -130,7 +129,7 @@ public class TestResolvers { * * @throws Exception the exception */ - @Test + //@Test public void testStorageIDdoHEAD() throws Exception{ String storageID = "clZ2YmxTYytETzVLaHkwMjM3TmVETTFMb256YVRMS3lHbWJQNStIS0N6Yz0";