How to create object of a response service class in spring framework

How to use this method in another class? I have to make its object as I have to use this API while creating otherAPI so how can I create its object and use this in another class in same project.


    @POST
    @Path(PathConstants.UPDATE_EPM_DETAILS)
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response updateEpmDetails(InputStream incomingData, @Context HttpHeaders headers) {
        logger.info();
        mapper = getObjectMapper();
        epmHelper = getEpmHelper();
        ElementUpdateEpmRequest[] updateEpmRequestArray = null;
        String jsonInString = "{}";
        UpdateEpmDetailsResponse updateEpmDetailsResponse = new UpdateEpmDetailsResponse();
        int responseStatus = Response.Status.OK.getStatusCode();
        try {
            updateEpmRequestArray = mapper.readValue(incomingData, ElementUpdateEpmRequest[].class);
            List<ElementUpdateEpmRequest> updateEpmRequestList = new ArrayList<>(Arrays.asList(updateEpmRequestArray));
            updateEpmDetailsResponse = epmHelper.updateEpmDetails(updateEpmRequestList);
            jsonInString = mapper.writeValueAsString(updateEpmDetailsResponse);
            logger.infoEndOfMethod();
            return Response.status(responseStatus).entity(jsonInString).build();
        } catch (Exception e) {
            return DataUtils.prepareServerErrorWithMessage(e, e.getMessage());
        }
    }



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation