Does the POST Request

@param id specifies the entity on which to perform the post request
@return a String containing the response content
@throws SDKException if the request fails
7990
public String requestPost(final String id) throws SDKException {
    CloseableHttpResponse response = null;
    HttpPost httpPost = null;
    checkToken();

    try {
      log.debug("pathUrl: " + pathUrl);
      log.debug("id: " + pathUrl + "/" + id);

      // call the api here
      log.debug("Executing post on: " + this.pathUrl + "/" + id);
      httpPost = new HttpPost(this.pathUrl + "/" + id);
      preparePostHeader(httpPost, "application/json", "application/json");

      response = httpClient.execute(httpPost);

      // check response status
      RestUtils.checkStatus(response, HttpURLConnection.HTTP_CREATED);
      // return the response of the request
      String result = "";
      if (response.getEntity() != null) {
        result = EntityUtils.toString(response.getEntity());
      }
      closeResponseObject(response);
      log.trace("received: " + result);

      httpPost.releaseConnection();
      return result;
    } catch (IOException e) {
      // catch request exceptions here
      log.error(e.getMessage(), e);
      if (httpPost != null) {
        httpPost.releaseConnection();
      }
      throw new SDKException(
          "Could not http-post or open the object properly",
          e.getStackTrace(),
          "Could not http-post or open the object properly because: " + e.getMessage());
    } catch (SDKException e) {
      if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
        token = null;
        if (httpPost != null) {
          httpPost.releaseConnection();
        }
        return requestPost(id);
      } else {
        if (httpPost != null) {
          httpPost.releaseConnection();
        }
        try {
          throw new SDKException(
              "Status is " + response.getStatusLine().getStatusCode(),
              new StackTraceElement[0],
              EntityUtils.toString(response.getEntity()));
        } catch (IOException e1) {
          e1.printStackTrace();
          throw new SDKException(
              "Status is " + response.getStatusLine().getStatusCode(),
              new StackTraceElement[0],
              "could not provide reason because: " + e.getMessage());
        }
      }
    }
  }
261867
@PostMapping(
      value = "/{entityTypeId}/meta/{attributeName}",
      params = "_method=GET",
      produces = APPLICATION_JSON_VALUE)
  public AttributeResponse retrieveEntityAttributeMetaPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeName") String attributeName,
      @Valid @RequestBody EntityTypeRequest request) {
    Set<String> attributeSet = toAttributeSet(request != null ? request.getAttributes() : null);
    Map<String, Set<String>> attributeExpandSet =
        toExpandMap(request != null ? request.getExpand() : null);

    return getAttributePostInternal(entityTypeId, attributeName, attributeSet, attributeExpandSet);
  }
895486
@RequestMapping(path="/{orderId}/status", method = RequestMethod.PUT)
    public ResponseEntity<Order> updateStatus(@PathVariable("orderId") Long orderId, @RequestParam("status") OrderStatus status){
        Order order = orderService.updateStatus(orderId, status);
        if(order != null){
            return new ResponseEntity<Order>(order, HttpStatus.OK);
        }
        return new ResponseEntity<Order>(HttpStatus.NOT_FOUND);
    }
294253
public String getRequestById(long requestId, boolean withErrors, boolean withData, String marshallingType) {

        String result = null;

        RequestInfo request = executorService.getRequestById(requestId);

        if (request == null) {
            throw new IllegalArgumentException("Request with id: " + requestId + " doesn't exist");
        } else {
            RequestInfoInstance requestInstance = convertToRequestInfo(request, withErrors, withData);

            String deploymentId = ((org.jbpm.executor.entities.RequestInfo) request).getDeploymentId();
            if (deploymentId != null && context.getContainer(deploymentId) != null) {
                result = marshallerHelper.marshal(deploymentId, marshallingType, requestInstance);
            } else {
                result = marshallerHelper.marshal(marshallingType, requestInstance);
            }
        }

        return result;
    }
614654
public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String accountId  = getServletContext().getInitParameter("accountId"); // Put your AccountId here
		String email      = getServletContext().getInitParameter("email"); // Put your Email address here (Used for authentication and replies)
		String password   = getServletContext().getInitParameter("password");  // Put your Password here				
		
		String alertId = request.getParameter("alertId");
		String tel = request.getParameter("tel");
		String alertText = request.getParameter("alertText");        
        if(alertText == null || alertText.length() < 1) {
	        // Get the content of the request as the text to parse
	        byte[] content = new byte[request.getContentLength()];
	        request.getInputStream().read(content,0, request.getContentLength());        
	        alertText = new String(content); 	        
        }
        alertId = URLEncoder.encode(alertId, "UTF-8");
//        tel = URLEncoder.encode(tel, "UTF-8");
//        alertText = URLEncoder.encode(alertText, "UTF-8");        
		
		Integer nResult;
		StringBuffer strResponse = new StringBuffer();
		String sData;

		try {
			sData = ("AccountId=" + URLEncoder.encode(accountId, "UTF-8"));
//			sData += ("&Email=" + URLEncoder.encode(email, "UTF-8"));
			sData += ("&Email=" + email);
			sData += ("&Password=" + URLEncoder.encode(password, "UTF-8"));
			sData += ("&Recipient=" + URLEncoder.encode(tel, "UTF-8"));
			sData += ("&Message=" + URLEncoder.encode(alertText, "UTF-8"));

			if(logger.isInfoEnabled()) {        	
	        	logger.info("Got an alert : \n alertID : " + alertId + " \n tel : " + tel + " \n text : " +alertText);
	        	logger.info("Red Oxygen : \n Account Id : " + accountId + " \n email : " + email + " \n password : " + password);
	        	logger.info("Red Oxygen URL : \n URL : " + RED_OXYGEN_URL + " \n data : " + sData);
	        }
	        
			
			URL urlObject = new URL(RED_OXYGEN_URL);

			HttpURLConnection con = (HttpURLConnection) urlObject.openConnection();
			con.setRequestMethod(HTTP_METHOD);
			con.setDoInput(true);
			con.setDoOutput(true);

			DataOutputStream out = new DataOutputStream(con.getOutputStream());
			out.writeBytes(sData);
			out.flush();
			out.close();

			BufferedReader in = new BufferedReader(new InputStreamReader(con
					.getInputStream()));

			String inputLine;
			StringBuffer responseBuffer = new StringBuffer();

			while ((inputLine = in.readLine()) != null) {
				responseBuffer = responseBuffer.append(inputLine);
				responseBuffer = responseBuffer.append("\n\n\n");
			}

			strResponse.replace(0, 0, responseBuffer.toString());

			String sResultCode = strResponse.substring(0, 4);
			nResult = new Integer(sResultCode);

			in.close();
		} catch (Exception e) {			
			logger.error("Exception caught sending SMS",e);
			nResult = -2;
		}		

		sendHttpResponse(response, RESPONSE_BEGIN + "result : " + nResult + "<br/>response : " + strResponse + RESPONSE_END);
	}
426710
@POST
    @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON})
    @Produces(Servlets.JSON_MEDIA_TYPE)
    public Response submit(@Context HttpServletRequest request) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("==> EntityResource.submit()");
        }

        String entityJson = null;
        AtlasPerfTracer perf = null;
        try {
            if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
                perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityResource.submit()");
            }

            String entities = Servlets.getRequestPayload(request);

            //Handle backward compatibility - if entities is not JSONArray, convert to JSONArray
            try {
                new JSONArray(entities);
            } catch (JSONException e) {
                final String finalEntities = entities;
                entities = new JSONArray() {{
                    put(finalEntities);
                }}.toString();
            }

            entityJson = AtlasClient.toString(new JSONArray(entities));

            if (LOG.isDebugEnabled()) {
                LOG.debug("submitting entities {} ", entityJson);
            }

            AtlasEntitiesWithExtInfo entitiesInfo     = restAdapters.toAtlasEntities(entities);
            EntityMutationResponse   mutationResponse = entityREST.createOrUpdate(entitiesInfo);

            final List<String> guids = restAdapters.getGuids(mutationResponse.getCreatedEntities());

            if (LOG.isDebugEnabled()) {
                LOG.debug("Created entities {}", guids);
            }

            final CreateUpdateEntitiesResult result = restAdapters.toCreateUpdateEntitiesResult(mutationResponse);

            JSONObject response    = getResponse(result);
            URI        locationURI = getLocationURI(guids);

            return Response.created(locationURI).entity(response).build();

        } catch (AtlasBaseException e) {
            LOG.error("Unable to persist entity instance entityDef={}", entityJson, e);
            throw toWebApplicationException(e);
        } catch(EntityExistsException e) {
            LOG.error("Unique constraint violation for entity entityDef={}", entityJson, e);
            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT));
        } catch (ValueConversionException ve) {
            LOG.error("Unable to persist entity instance due to a deserialization error entityDef={}", entityJson, ve);
            throw new WebApplicationException(Servlets.getErrorResponse(ve.getCause() != null ? ve.getCause() : ve, Response.Status.BAD_REQUEST));
        } catch (AtlasException | IllegalArgumentException e) {
            LOG.error("Unable to persist entity instance entityDef={}", entityJson, e);
            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
        } catch (WebApplicationException e) {
            LOG.error("Unable to persist entity instance entityDef={}", entityJson, e);
            throw e;
        } catch (Throwable e) {
            LOG.error("Unable to persist entity instance entityDef={}", entityJson, e);
            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
        } finally {
            AtlasPerfTracer.log(perf);

            if (LOG.isDebugEnabled()) {
                LOG.debug("<== EntityResource.submit()");
            }

        }
    }
911583
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public ResponseEntity<E> update(@PathVariable int id, HttpServletRequest request) {

        String errorPrefix = "Error updating "
            + getEntityClass().getSimpleName() + " with ID " + id + ": ";

        Reader reader = null;

        try {
            // read and parse the json request body
            reader = request.getReader();
            JsonNode jsonObject = objectMapper.readTree(reader);

            // validate json object
            if (jsonObject == null || !jsonObject.has("id")) {
                LOG.error(errorPrefix
                    + "The JSON body is empty or has no 'id' property.");
                return new ResponseEntity<E>(HttpStatus.BAD_REQUEST);
            }

            // assure that the path variable id equals the payload id
            final int payloadId = jsonObject.get("id").asInt();
            if (payloadId != id) {
                LOG.error(errorPrefix + "Requested to update entity with ID "
                    + id + ", but payload ID is " + payloadId);
                return new ResponseEntity<E>(HttpStatus.BAD_REQUEST);
            }

            // get the persisted entity
            E entity = service.findById(id);

            if (entity != null) {
                // we call this transactional method (instead of save or update)
                // to make sure that the possibly modified entity does not
                // get persisted / synced unexpectedly by hibernate
                // (due to FlushMode.AUTO) when another database-related
                // interaction is triggered in the meantime (which could happen
                // for example in a permission evaluation).
                // In other words: Do not get an entity, modify it and save it
                // in a non-transactional way (e.g. controller method), as
                // a possible permission evaluation could trigger an unwanted
                // persist action before the permission was evaluated.
                entity = service.updatePartialWithJsonNode(entity, jsonObject, objectMapper);
                return new ResponseEntity<E>(entity, HttpStatus.OK);
            }
            return new ResponseEntity<E>(HttpStatus.NOT_FOUND);
        } catch (Exception e) {
            LOG.error(errorPrefix + e.getMessage());
            return new ResponseEntity<E>(HttpStatus.NOT_FOUND);
        } finally {
            IOUtils.closeQuietly(reader);
        }
    }
612004
@Transactional
  @PostMapping(value = "/{entityTypeId}/{id}", params = "_method=PUT")
  @ResponseStatus(OK)
  public void updatePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestBody Map<String, Object> entityMap) {
    updateInternal(entityTypeId, untypedId, entityMap);
  }
776607
@GET
    @Path("status")
    @Produces(MediaType.TEXT_PLAIN)
    public String getStatus(@QueryParam("id") int id)
    {
        return JqmClientFactory.getClient().getJob(id).getState().toString();
    }
361651
@RequestMapping(value = "/getThumbnail.action", method = RequestMethod.GET)
    public ResponseEntity<?> getThumbnail(@RequestParam Integer id) {

        final HttpHeaders responseHeaders = new HttpHeaders();
        Map<String, Object> responseMap;

        try {
            // try to get the image
            ImageFile image = service.findById(id);
            if (image == null) {
                throw new Exception("Could not find the image with id " + id);
            }

            byte[] imageBytes = null;

            imageBytes = image.getThumbnail();

            responseHeaders.setContentType(
                MediaType.parseMediaType(image.getFileType()));

            LOG.info("Successfully got the image thumbnail " +
                image.getFileName());

            return new ResponseEntity<byte[]>(
                imageBytes, responseHeaders, HttpStatus.OK);
        } catch (Exception e) {
            final String errorMessage = "Could not get the image thumbnail: "
                + e.getMessage();

            LOG.error(errorMessage);
            responseMap = ResultSet.error(errorMessage);

            responseHeaders.setContentType(MediaType.APPLICATION_JSON);

            return new ResponseEntity<Map<String, Object>>(
                responseMap, responseHeaders, HttpStatus.OK);
        }
    }
38497
@Help(help = "Find the object of type {#} through the id")
  public T findById(final String id) throws SDKException {
    return (T) requestGet(id, clazz);
  }
533406
public ApiResponse createEntity(Entity entity) {
        assertValidApplicationId();
        if (isEmpty(entity.getType())) {
            throw new IllegalArgumentException("Missing entity type");
        }
        ApiResponse response = apiRequest(HttpMethod.POST, null, entity,
                organizationId, applicationId, entity.getType());
        return response;
    }
1226755
protected String getKunderaId(EntityMetadata metadata, Object id) {
        return metadata.getEntityClazz().getCanonicalName() + IndexingConstants.DELIMETER + id;
    }
1133137
@Route(method= HttpMethod.POST, uri="/")
    public Result post(@FormParameter("id") String id, @FormParameter("name") String name) {
        // The values of id and names are computed the request attributes.
        return ok(id + " - " + name);
    }
443594
public ApiResponse connectEntities(String connectingEntityType,
            String connectingEntityId, String connectionType,
            String connectedEntityId) {
        return apiRequest(HttpMethod.POST, null, null,  organizationId, applicationId,
                connectingEntityType, connectingEntityId, connectionType,
                connectedEntityId);
    }
841336
protected RequestEntity createStringRequestContent(HTTPRequest httpRequest)
    {
        RequestEntity requestEntity=null;
        String contentString=httpRequest.getContentAsString();
        if(contentString!=null)
        {
            try
            {
                requestEntity=new StringRequestEntity(contentString,"text/plain",null);
            }
            catch(UnsupportedEncodingException exception)
            {
                throw new FaxException("Unable to set string request entity.",exception);
            }
        }
        
        return requestEntity;
    }
691776
public BoxRequestsComment.GetCommentInfo getInfoRequest(String id) {
        BoxRequestsComment.GetCommentInfo request = new BoxRequestsComment.GetCommentInfo(id, getCommentInfoUrl(id), mSession);
        return request;
    }