@Test public void findImagesForExternalId() throws IOException { TaxonImage image = imageService.findTaxonImagesForExternalId("EOL:1234", "en"); assertThat(image.getCommonName(), is("some common name for EOL:1234")); }
@RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody public TaxonImage findTaxonImagesForExternalId( @PathVariable("externalId") String externalId, @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage) throws IOException { TaxonImage taxonImage = imageSearch.lookupImageForExternalId(externalId, () -> preferredLanguage); if (taxonImage == null) { throw new ResourceNotFoundException("no image for [" + externalId + "]"); } return taxonImage; }
ImageService { @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody public TaxonImage findTaxonImagesForExternalId( @PathVariable("externalId") String externalId, @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage) throws IOException { TaxonImage taxonImage = imageSearch.lookupImageForExternalId(externalId, () -> preferredLanguage); if (taxonImage == null) { throw new ResourceNotFoundException("no image for [" + externalId + "]"); } return taxonImage; } }
ImageService { @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody public TaxonImage findTaxonImagesForExternalId( @PathVariable("externalId") String externalId, @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage) throws IOException { TaxonImage taxonImage = imageSearch.lookupImageForExternalId(externalId, () -> preferredLanguage); if (taxonImage == null) { throw new ResourceNotFoundException("no image for [" + externalId + "]"); } return taxonImage; }  }
ImageService { @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody public TaxonImage findTaxonImagesForExternalId( @PathVariable("externalId") String externalId, @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage) throws IOException { TaxonImage taxonImage = imageSearch.lookupImageForExternalId(externalId, () -> preferredLanguage); if (taxonImage == null) { throw new ResourceNotFoundException("no image for [" + externalId + "]"); } return taxonImage; }  @RequestMapping(value = "/imagesForName/{scientificName}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForTaxonWithName(
            @PathVariable("scientificName") String scientificName,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/imagesForName", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForTaxonWithName2(
            @RequestParam(value = "name", required = false) String[] names,
            @RequestParam(value = "externalId", required = false) String[] externalIds,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/imagesForNames", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody List<TaxonImage> findImagesForNames(
            @RequestParam(value = "name") String[] names,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForExternalId(
            @PathVariable("externalId") String externalId,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); }
ImageService { @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody public TaxonImage findTaxonImagesForExternalId( @PathVariable("externalId") String externalId, @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage) throws IOException { TaxonImage taxonImage = imageSearch.lookupImageForExternalId(externalId, () -> preferredLanguage); if (taxonImage == null) { throw new ResourceNotFoundException("no image for [" + externalId + "]"); } return taxonImage; }  @RequestMapping(value = "/imagesForName/{scientificName}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForTaxonWithName(
            @PathVariable("scientificName") String scientificName,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/imagesForName", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForTaxonWithName2(
            @RequestParam(value = "name", required = false) String[] names,
            @RequestParam(value = "externalId", required = false) String[] externalIds,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/imagesForNames", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody List<TaxonImage> findImagesForNames(
            @RequestParam(value = "name") String[] names,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage); @RequestMapping(value = "/images/{externalId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8") @ResponseBody TaxonImage findTaxonImagesForExternalId(
            @PathVariable("externalId") String externalId,
            @RequestParam(value = "lang", required = false, defaultValue = "en") String preferredLanguage);  }