/** * Handles /samplecontainer/setstate and /samplecontainer/setevilness/{doevil}. TODO(doll): These * urls aren't very resty. Consider changing the samplecontainer.html calls post. */ @Operation(httpMethods = "POST", bodyParam = "data") public Future<?> create(RequestItem request) throws ProtocolException { String type = request.getParameter("type"); if ("setstate".equals(type)) { try { @SuppressWarnings("unchecked") Map<String, String> bodyparams = request.getTypedParameter("data", Map.class); String stateFile = bodyparams.get("fileurl"); service.setDb(new JSONObject(fetchStateDocument(stateFile))); } catch (JSONException e) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "The json state file was not valid json", e); } } else if ("setevilness".equals(type)) { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "evil data has not been implemented yet"); } return Futures.immediateFuture(null); }