/** * Returns the representation based on IMCCE response. * * @return the representation */ private Representation resolveIMCCE() { LOG.finest( String.format( "IMCCE name resolver is choosen with the following parameter %s", objectName)); final AbstractNameResolver imcce = new IMCCESsoResolver(objectName, epoch); final NameResolverResponse response = imcce.getResponse(); if (response.hasResult()) { LOG.log(Level.INFO, "IMCCE name resolver is selected for {0}.", objectName); getResponse().setStatus(Status.SUCCESS_OK); final List<AstroCoordinate> coordinates = response.getAstroCoordinates(); for (AstroCoordinate iter : coordinates) { iter.processTo(coordSystem); } final String credits = response.getCredits(); final Map dataModel = getDataModel(credits, coordinates, this.coordSystem.name()); Representation rep = new GeoJsonRepresentation(dataModel); final CacheBrowser cache = CacheBrowser.createCache(CacheBrowser.CacheDirectiveBrowser.NO_CACHE, rep); rep = cache.getRepresentation(); getResponse().setCacheDirectives(cache.getCacheDirectives()); return rep; } else { LOG.log(Level.WARNING, null, response.getError()); throw new ResourceException( response.getError().getStatus(), response.getError().getMessage()); } }
/** * Returns the GeoJSON of the object name after calling all resolvers until an object is found or * all resolvers have been called. * * @return the GeoJSON of the object name */ private Representation callChainedResolver() { Map dataModel; final AbstractNameResolver cds = new CDSNameResolver(objectName, CDSNameResolver.NameResolverService.all); final AbstractNameResolver imcce = new IMCCESsoResolver(objectName, "now"); // final AbstractNameResolver corot = new CorotIdResolver(objectName); final AbstractNameResolver sitools2 = new ConstellationNameResolver(objectName); cds.setNext(sitools2); sitools2.setNext(imcce); // imcce.setNext(corot); final NameResolverResponse response = cds.getResponse(); if (!response.hasResult()) { throw new ResourceException( response.getError().getStatus(), response.getError().getMessage()); } final String credits = response.getCredits(); final List<AstroCoordinate> coordinates = response.getAstroCoordinates(); for (AstroCoordinate iter : coordinates) { iter.processTo(coordSystem); } dataModel = getDataModel(credits, coordinates, this.coordSystem.name()); Representation rep = new GeoJsonRepresentation(dataModel); final CacheBrowser.CacheDirectiveBrowser cacheDirective = (credits.equals("IMCCE")) ? CacheBrowser.CacheDirectiveBrowser.NO_CACHE : CacheBrowser.CacheDirectiveBrowser.FOREVER; final CacheBrowser cache = CacheBrowser.createCache(cacheDirective, rep); rep = cache.getRepresentation(); getResponse().setCacheDirectives(cache.getCacheDirectives()); return rep; }
/** * Returns the representation based on SITools2 db response. * * @return the representation */ private Representation resolveConstellation() { final AbstractNameResolver sitools2 = new ConstellationNameResolver(objectName); final NameResolverResponse response = sitools2.getResponse(); if (response.hasResult()) { LOG.log(Level.INFO, "Constellation name resolver is selected for {0}", objectName); getResponse().setStatus(Status.SUCCESS_OK); final List<AstroCoordinate> coordinates = response.getAstroCoordinates(); for (AstroCoordinate iter : coordinates) { iter.processTo(coordSystem); } final String credits = response.getCredits(); final Map dataModel = getDataModel(credits, coordinates, this.coordSystem.name()); Representation rep = new GeoJsonRepresentation(dataModel); final CacheBrowser cache = CacheBrowser.createCache(CacheBrowser.CacheDirectiveBrowser.FOREVER, rep); rep = cache.getRepresentation(); getResponse().setCacheDirectives(cache.getCacheDirectives()); return rep; } else { LOG.log(Level.WARNING, null, response.getError()); throw new ResourceException( response.getError().getStatus(), response.getError().getMessage()); } }