package stockManagement.push; import java.util.*; import javax.ws.rs.*; import javax.ws.rs.client.*; import javax.ws.rs.core.*; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; import pushPullRefactor.*; import com.fasterxml.jackson.core.JsonProcessingException; @Path("/stock") @Resource("stock") @Component public class Stock { @State private Map<String, Integer> value = new HashMap<String, Integer>(); @POST @Message({"handling"}) public void updateHandling(@FormParam("handling") String handling_json) throws JsonProcessingException { Map.Entry<String, Map.Entry<Integer, Integer>> handling; { Map<String, Map<String, Integer>> i = new ObjectMapper().readValue(handling_json, HashMap.class); handling = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(), new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue())); } this.value.put(handling.getKey(),handling.getValue().getValue()); } @Produces(MediaType.APPLICATION_JSON) @GET @Getter public Map<String, Integer> getValue() { return value; } }