@GET @Path("/{id}") @Produces("application/json") public Map<String, Object> getExtractorJSON( @PathParam("id") String id, @Context ServletContext context) { log.trace("/extractors/" + id + " requested"); Extractor extractor = getExtractor(context, id); Map<String, Object> json = new HashMap<String, Object>(); if (extractor != null) { json.put("name", extractor.getName()); json.put("id", extractor.getClass().getName()); json.put("supportedFeature", extractor.getFeatureType().getName()); } else { json.put("Error", "Extractor not found"); } return json; }
@GET @Path("/") @Produces("application/json") public List<Map<String, Object>> listJSON(@Context ServletContext context) { log.trace("/extractors requested"); Collection<Extractor> extractors = getExtractors(context); List<Map<String, Object>> jsonReturn = new ArrayList<Map<String, Object>>(); if (extractors.size() == 0) { return jsonReturn; } else { for (Extractor extractor : extractors) { Map<String, Object> json = new HashMap<String, Object>(); json.put("name", extractor.getName()); json.put("id", extractor.getClass().toString()); json.put("supportedFeature", extractor.getFeatureType().getName()); jsonReturn.add(json); } return jsonReturn; } }