git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@179497 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5cc9343aeb
commit
f24080c06b
|
@ -29,6 +29,7 @@ import org.gcube.datatransfer.resolver.ConstantsResolver;
|
|||
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
|
||||
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter.AccountType;
|
||||
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter.GeonetworkLoginLevel;
|
||||
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter;
|
||||
import org.gcube.datatransfer.resolver.gis.GeonetworkInstance;
|
||||
import org.gcube.datatransfer.resolver.gis.geonetwork.FilterGetRecords;
|
||||
import org.gcube.datatransfer.resolver.gis.geonetwork.GNAuthentication;
|
||||
|
@ -166,6 +167,67 @@ public class GeonetworkResolver {
|
|||
}
|
||||
|
||||
logger.info("Remaining path is: "+remainPath);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
GeonetworkAccessParameter gntwAccess = new GeonetworkAccessParameter(scope);
|
||||
GeonetworkInstance gnInstance = gntwAccess.getGeonetworkInstance(true, null,null);
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
HTTPCallsUtils httpUtils = new HTTPCallsUtils();
|
||||
Configuration config = gnInstance.getGeonetworkPublisher().getConfiguration();
|
||||
String geonetworkUrl = config.getGeoNetworkEndpoint();
|
||||
String baseURL = remainPath==null ||remainPath.isEmpty()?geonetworkUrl+"/"+CSW_SERVER:geonetworkUrl+"/"+CSW_SERVER+remainPath;
|
||||
logger.info("The base URL is: "+baseURL);
|
||||
String queryString = req.getQueryString()==null || req.getQueryString().isEmpty()?"":"?"+req.getQueryString();
|
||||
gnGetlURL = baseURL+queryString;
|
||||
logger.info("Sending get request to URL: "+gnGetlURL);
|
||||
HttpResponse proxedGNResponse = httpUtils.get(gnGetlURL);
|
||||
|
||||
switch(proxedGNResponse.getStatus()){
|
||||
case HttpServletResponse.SC_OK:
|
||||
|
||||
//Building the response
|
||||
InputStream streamToWrite = IOUtils.toInputStream(proxedGNResponse.getResponse());
|
||||
StreamingOutput so = new SingleFileStreamingOutput(streamToWrite);
|
||||
|
||||
logger.info("Response return Content-Type: "+httpUtils.getLastContentType());
|
||||
|
||||
ResponseBuilder responseBuilder = Response
|
||||
.ok(so)
|
||||
.header(ConstantsResolver.CONTENT_TYPE, httpUtils.getLastContentType());
|
||||
return responseBuilder.build();
|
||||
|
||||
case HttpServletResponse.SC_FORBIDDEN:
|
||||
throw ExceptionManager.forbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), helpURI);
|
||||
|
||||
default:
|
||||
throw ExceptionManager.internalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception:", e);
|
||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
try {
|
||||
|
||||
//I'M LOADING THE GN CONFIGURATIONS (ENDPOINT, USER, PWD AND SO ON..) FROM GN LIBRARY BY GENERAL CONSTRUCTOR THAT PERFORMS AUTHENTICATION ON GN,
|
||||
|
@ -249,7 +311,7 @@ public class GeonetworkResolver {
|
|||
logger.error("Exception:", e);
|
||||
String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!";
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
}*/
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue