From 0903a36e7844372068d2de3aae67cfc70b4bdf37 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Fri, 28 Dec 2018 14:16:11 +0000 Subject: [PATCH] managed exception git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@176265 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../services/AnalyticsCreateResolver.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 7f2a4a9..11cd807 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java @@ -45,6 +45,7 @@ import org.gcube.data.analysis.dminvocation.DataMinerInvocationManager; import org.gcube.data.analysis.dminvocation.model.DataMinerInvocation; import org.gcube.datatransfer.resolver.requesthandler.TokenSetter; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; +import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException; import org.gcube.datatransfer.resolver.util.ScopeUtil; import org.gcube.datatransfer.resolver.util.Util; import org.gcube.resources.discovery.client.api.DiscoveryClient; @@ -168,10 +169,16 @@ public class AnalyticsCreateResolver { Metadata metadata = new Metadata(); Map theMap = new HashMap(); theMap.put("owner", owner); + URL thePublicLink = null; + try{ - logger.info("Saving dataminer-invocation file for the user: "+owner); - URL thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "application/xml", metadata); - logger.info("Saved dataminer-invocation file at: "+thePublicLink); + logger.info("Saving dataminer-invocation file for the user: "+owner); + thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "application/xml", metadata); + logger.info("Saved dataminer-invocation file at: "+thePublicLink); + }catch(Exception e){ + logger.error("Error when storing your 'dataminer-invocation':", e); + throw ExceptionManager.internalErrorException(req, "Error when storing your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI); + } // FileContainer fileContainer = shc.getWSRoot().uploadFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "DataMinerInvocation Request created by "+this.getClass().getSimpleName()); // logger.info("UPLOADED FILE at: "+fileContainer.getPublicLink()); @@ -179,6 +186,11 @@ public class AnalyticsCreateResolver { publicLinkToDMInvFile = thePublicLink!=null?thePublicLink.toString():null; } catch (Exception e) { + + if(e instanceof InternalServerException){ + //error during storing the file via StorageHubManagent + throw e; + } logger.error("Error on creating 'dataminer-invocation:", e); throw ExceptionManager.badRequestException(req, "Error on creating your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI); }finally{