Java orchestration calls from two CRUD endpoints Here is my orchestration endpoint where I call customer endpoint and product endpoint. Product endpoint contains info about what customer have what product. I do not like how it look and smells as shit hope there is a better way to do it. Couldn't find a better way to do it but RestTemplate feels so wrong here.

@RestController
public class ApiController {

    private final static String CUSTOMER_URI = "http://localhost:8090/customers";
    private final static String PRODUCT_URI = "http://localhost:8085/products";
    private final static String PRODUCT_CUSTOM_URI = "http://localhost:8085/products/search/findByOwners";

    @GetMapping("/getCustomerById/{id}")
    public Customer getCustomerById( @PathVariable int id){
        MappingJackson2HttpMessageConverter converter = getMappingJackson2HttpMessageConverter();
        RestTemplate restTemplateHal = new RestTemplate(Collections.&lt;HttpMessageConverter&lt;?&gt;&gt; singletonList(converter));
        RestTemplate restTemplate = new RestTemplate();

        Customer customer = getCustomer(id, restTemplate);
        ArrayList&lt;String&gt; products = getProduct(id, restTemplateHal);
        customer.setProducts(products);
        customer.setId(id);
        return customer;
    }

    private ArrayList&lt;String&gt; getProduct(@PathVariable int id, RestTemplate restTemplateHal) {
        Collection content = restTemplateHal.getForObject(PRODUCT_CUSTOM_URI + "?id=" + id, PagedResources.class).getContent();
        ArrayList&lt;String&gt; products = new ArrayList&lt;&gt;();
        for (Object o : content) {
            System.out.println(o);
            LinkedHashMap&lt;String, String&gt; o1 = (LinkedHashMap&lt;String, String&gt;)o;
            products.add(o1.get("name"));
        }
        return products;
    }

    private Customer getCustomer(@PathVariable int id, RestTemplate restTemplate) {
        ResponseEntity&lt;Customer&gt; responseCustomer
                = restTemplate.getForEntity(CUSTOMER_URI + "/"+id, Customer.class);
        return responseCustomer.getBody();
    }

    private MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.registerModule(new Jackson2HalModule());

        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
        converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
        converter.setObjectMapper(mapper);
        return converter;
    }
}
It's because your presentation layer does the orchestration. I'd recommend to make the rest layer as stupid as possible. Its only purpose should be to get the request information from the URL, load the corresponding data from the service layer, and transform the data to JSON or whatever format it needs to be.