fix on scope

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@148750 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-05-16 15:50:41 +00:00
parent eba2b6985e
commit 6d26d97361
1 changed files with 12 additions and 2 deletions

View File

@ -115,6 +115,8 @@ public class GeonetworkResolver extends HttpServlet{
String resetCache = req.getParameter(RESET_CACHE);
String resetScope = req.getParameter(RESET_CACHED_SCOPE);
String originalScope = ScopeProvider.instance.get();
if (scopeValue == null || scopeValue.equals("")) {
logger.debug("Scope not found");
sendError(resp, HttpServletResponse.SC_BAD_REQUEST, SCOPE+" not found or empty");
@ -140,8 +142,8 @@ public class GeonetworkResolver extends HttpServlet{
// gnInstance = gntwAccess.getGeonetworkInstance();
// }
// GeonetworkServiceInterface gntwAccess = new GeonetworkAccessParameter(scopeValue);
// GeonetworkInstance gnInstance = gntwAccess.getGeonetworkInstance();
ScopeProvider.instance.set(scopeValue);
HTTPCallsUtils httpUtils = new HTTPCallsUtils();
Configuration config = gnInstance.getGeonetworkPublisher().getConfiguration();
String geonetworkUrl = config.getGeoNetworkEndpoint();
@ -190,6 +192,14 @@ public class GeonetworkResolver extends HttpServlet{
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scopeValue+". Please, contact support!";
sendError(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error);
return;
}finally{
if(originalScope!=null){
ScopeProvider.instance.set(originalScope);
logger.info("scope provider set to orginal scope: "+originalScope);
}else{
ScopeProvider.instance.reset();
logger.info("scope provider reset");
}
}
}