servers/Controller/src/main/java/com/controller/services/ImageSegmentationResource.java
/**
     * Retrieves representation of an instance of
     * com.controller.services.ImageSegmentationResource
     *
     * @param json
     * @return
     */
Retrieves representation of an instance of
com.controller.services.ImageSegmentationResource

@param json
@return
Retrieves representation of an instance of com . controller . services . ImageSegmentationResource @param json @return
@POST
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public Response segmentateImage(String json) {
        Client client = ClientBuilder.newClient();
        WebTarget webTarget = client.target("http://localhost:8080/PicturesHolder/getImage");
        Response response = webTarget.request().post(Entity.json(json));
        if (response.getStatus() == 204) {
            try {
                JSONObject jsonObject = (JSONObject) new JSONParser().parse(json);
                String imageString = (String) jsonObject.get(ENCODED_IMAGE_KEY);
                String numberOfClustersString = (String) jsonObject.get(NUMBER_OF_CLUSTERS_KEY);
                Response processedResponse = processRequest(imageString, numberOfClustersString);
                if (processedResponse.getStatus() == 200) {
                    JSONObject resultObject = (JSONObject) new JSONParser().parse(processedResponse.getEntity().toString());
                    JSONObject request = new JSONObject();
                    request.put(ENCODED_IMAGE_KEY, imageString);
                    request.put(NUMBER_OF_CLUSTERS_KEY, numberOfClustersString);
                    request.put(RESULT, (String) resultObject.get(ENCODED_IMAGE_KEY));
                    webTarget = client.target("http://localhost:8080/PicturesHolder/postImage");
                    webTarget.request().post(Entity.json(request.toJSONString()));
                }
                return processedResponse;
            } catch (ParseException ex) {
                Logger.getLogger(ImageSegmentationResource.class.getName()).log(Level.SEVERE, null, ex);
                return Response.serverError().build();
            }
        } else {
            return Response.ok().entity(response.readEntity(String.class)).build();
        }
    }
@ POST @ Produces ( MediaType . APPLICATION_JSON ) @ Consumes ( MediaType . APPLICATION_JSON ) public Response segmentateImage ( String json ) { Client client = ClientBuilder . newClient ( ) ; WebTarget webTarget = client . target ( "http://localhost:8080/PicturesHolder/getImage" ) ; Response response = webTarget . request ( ) . post ( Entity . json ( json ) ) ; if ( response . getStatus ( ) == 204 ) { try { JSONObject jsonObject = ( JSONObject ) new JSONParser ( ) . parse ( json ) ; String imageString = ( String ) jsonObject . get ( ENCODED_IMAGE_KEY ) ; String numberOfClustersString = ( String ) jsonObject . get ( NUMBER_OF_CLUSTERS_KEY ) ; Response processedResponse = processRequest ( imageString , numberOfClustersString ) ; if ( processedResponse . getStatus ( ) == 200 ) { JSONObject resultObject = ( JSONObject ) new JSONParser ( ) . parse ( processedResponse . getEntity ( ) . toString ( ) ) ; JSONObject request = new JSONObject ( ) ; request . put ( ENCODED_IMAGE_KEY , imageString ) ; request . put ( NUMBER_OF_CLUSTERS_KEY , numberOfClustersString ) ; request . put ( RESULT , ( String ) resultObject . get ( ENCODED_IMAGE_KEY ) ) ; webTarget = client . target ( "http://localhost:8080/PicturesHolder/postImage" ) ; webTarget . request ( ) . post ( Entity . json ( request . toJSONString ( ) ) ) ; } return processedResponse ; } catch ( ParseException ex ) { Logger . getLogger ( ImageSegmentationResource . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; return Response . serverError ( ) . build ( ) ; } } else { return Response . ok ( ) . entity ( response . readEntity ( String . class ) ) . build ( ) ; } }
Retrieves representation of an instance of
 com.controller.services.ImageSegmentationResource
Retrieves representation of an instance of com . controller . services . ImageSegmentationResource