3135: Uri Resolver enhancements: create a Geonetwork Resolver

Task-Url: https://support.d4science.org/issues/3135

Added reset for cache and scope cached

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@126796 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-04-06 08:31:44 +00:00
parent 5fa9dcfaa9
commit 48541a1f09
1 changed files with 33 additions and 5 deletions

View File

@ -49,6 +49,8 @@ public class GeonetworkResolver extends HttpServlet{
*/
private static final long serialVersionUID = -61097584153314181L;
public static final String SCOPE = "scope";
public static final String RESET_CACHE = "resetcache";
public static final String RESET_CACHED_SCOPE = "resetcachedscope";
public static final String CSW_SERVER = "srv/en/csw";
/** The logger. */
@ -75,7 +77,7 @@ public class GeonetworkResolver extends HttpServlet{
@Override
public void run() {
logger.info("Resetting Geonetwork configuratios cache...");
reseCacheServerParameters();
resetCacheServerParameters();
}
}, CACHE_RESET_DELAY, CACHE_RESET_TIME);
}
@ -86,6 +88,8 @@ public class GeonetworkResolver extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String scope = req.getParameter(SCOPE);
String resetCache = req.getParameter(RESET_CACHE);
String resetScope = req.getParameter(RESET_CACHED_SCOPE);
if (scope == null || scope.equals("")) {
logger.debug("Scope not found");
@ -93,6 +97,14 @@ public class GeonetworkResolver extends HttpServlet{
return;
}
if(resetCache!=null && Boolean.parseBoolean(resetCache)){
resetCacheServerParameters();
}
if(resetScope!=null && Boolean.parseBoolean(resetScope)){
resetCacheServerParameterForScope(resetScope);
}
logger.info("SCOPE: " + scope +", Query String: " + req.getQueryString());
try {
@ -222,7 +234,7 @@ public class GeonetworkResolver extends HttpServlet{
protected ServerParameters getGeonetworkCachedServerParameters(String scope) throws Exception{
if(cacheGNServerParams==null)
reseCacheServerParameters();
resetCacheServerParameters();
logger.info("Tentative for recovering geonetwork server parameters from cache with scope: "+scope);
ServerParameters serverParam = cacheGNServerParams.get(scope);
@ -246,12 +258,28 @@ public class GeonetworkResolver extends HttpServlet{
return serverParam;
}
/**
* Rese cache server parameters.
* Reset cache server parameter for scope.
*
* @param scope the scope
*/
private void reseCacheServerParameters(){
private void resetCacheServerParameterForScope(String scope){
if(cacheGNServerParams!=null && cacheGNServerParams.get(scope)!=null){
cacheGNServerParams.remove(scope);
logger.info("Reset of "+scope+" in Cache Geonetwork server params perfomed!");
}else
logger.info("Reset of "+scope+" in Cache Geonetwork skipped, scope not exists!");
}
/**
* Reset cache server parameters.
*/
private void resetCacheServerParameters(){
cacheGNServerParams = new HashMap<String, ServerParameters>();
logger.info("Cache Geonetwork server params reset!");
logger.info("Reset of Cache Geonetwork server params perfomed!");
}
/**