Source:
<code>public Resource getCoreInfo(@PathVariable("variantCoreString") String variantCoreString, @RequestParam(name = "species") String species, @RequestParam(name = "assembly") String assembly, HttpServletResponse response) throws IllegalArgumentException{ initializeQuery(); try { checkParameters(variantCoreString, null, null, species, assembly); } catch (IllegalArgumentException e) { <START> System.out.println(e.getMessage()); <END> response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return new Resource<>(setErrorQueryResponse(e.getMessage())); } MultiMongoDbFactory.setDatabaseNameForCurrentThread(DBAdaptorConnector.getDBName(species + "_" + assembly)); List<VariantWithSamplesAndAnnotation> variantEntities; Long numTotalResults; try { variantEntities = getVariantEntitiesByParams(variantCoreString, null, null); numTotalResults = (long) variantEntities.size(); if (variantEntities.size() == 0) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return new Resource<>(setQueryResponse(variantEntities)); } } catch (AnnotationMetadataNotFoundException ex) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return new Resource<>(setQueryResponse(ex.getMessage())); } List<Variant> variantList = new ArrayList<>(); variantEntities.forEach(variantEntity->{ Variant variant = new Variant(variantEntity.getChromosome(), variantEntity.getStart(), variantEntity.getEnd(), variantEntity.getReference(),variantEntity.getAlternate()); variant.setIds(variantEntity.getIds()); variantList.add(variant); }); QueryResult<Variant> queryResult = buildQueryResult(variantList, numTotalResults); Link annotationLink = new Link(linkTo(methodOn(VariantWSServerV2.class).getAnnotations(variantCoreString, species, assembly, null, null, response)).toUri().toString(), "annotation"); Link sourcesLink = new Link(linkTo(methodOn(VariantWSServerV2.class).getsources(variantCoreString, species, assembly, null, null, response)).toUri().toString(), "sources"); List<Link> links = new ArrayList<>(); links.add(sourcesLink); links.add(annotationLink); return new Resource<>(setQueryResponse(queryResult), links); }</code><technical_language>logging is nice in production, implemented a logger class, instead of printing standard output</technical_language>

Target:
public Resource getCoreInfo(@PathVariable("variantCoreString") String variantCoreString, @RequestParam(name = "species") String species, @RequestParam(name = "assembly") String assembly, HttpServletResponse response) throws IllegalArgumentException { initializeQuery(); try { checkParameters(variantCoreString, null, null, species, assembly); } catch (IllegalArgumentException e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return new Resource<>(setErrorQueryResponse(e.getMessage())); } MultiMongoDbFactory.setDatabaseNameForCurrentThread(DBAdaptorConnector.getDBName(species + "_" + assembly)); Optional<VariantWithSamplesAndAnnotation> variantEntity; try { variantEntity = getVariantByCoordinatesAndAnnotationVersion(variantCoreString, null, null); } catch (AnnotationMetadataNotFoundException | IllegalArgumentException ex) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return new Resource<>(setQueryResponse(ex.getMessage())); } List<Variant> variantList = new ArrayList<>(); if (!variantEntity.isPresent()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); return new Resource<>(setQueryResponse(variantList)); } VariantWithSamplesAndAnnotation retrievedVariant = variantEntity.get(); Variant variant = new Variant(retrievedVariant.getChromosome(), retrievedVariant.getStart(), retrievedVariant.getEnd(), retrievedVariant.getReference(), retrievedVariant.getAlternate()); variant.setIds(variantEntity.get().getIds()); variantList.add(variant); QueryResult<Variant> queryResult = buildQueryResult(variantList, 1); Link annotationLink = new Link(linkTo(methodOn(VariantWSServerV2.class).getAnnotations(variantCoreString, species, assembly, null, null, response)).toUri().toString(), "annotation"); Link sourcesLink = new Link(linkTo(methodOn(VariantWSServerV2.class).getSources(variantCoreString, species, assembly, null, null, response)).toUri().toString(), "sources"); List<Link> links = new ArrayList<>(); links.add(sourcesLink); links.add(annotationLink); return new Resource<>(setQueryResponse(queryResult), links); }