managed exception

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@176265 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-12-28 14:16:11 +00:00
parent 9869badd04
commit 0903a36e78
1 changed files with 15 additions and 3 deletions

View File

@ -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<String, String> theMap = new HashMap<String, String>();
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{