Package org.apache.olingo.odata2.api.commons

Examples of org.apache.olingo.odata2.api.commons.HttpStatusCodes


                @Override
                public void onCompleted(HttpResponse result)
                    throws IOException, EntityProviderException, BatchException, ODataApplicationException {

                    // if a entity is created (via POST request) the response body contains the new created entity
                    HttpStatusCodes statusCode = HttpStatusCodes.fromStatusCode(result.getStatusLine().getStatusCode());
                    if (statusCode != HttpStatusCodes.NO_CONTENT) {

                        // TODO do we need to handle response based on other UriTypes???
                        switch (uriInfo.getUriType()) {
                        case URI9:
View Full Code Here


        this.responseHandler = responseHandler;
    }

    public static HttpStatusCodes checkStatus(HttpResponse response) throws ODataApplicationException {
        final StatusLine statusLine = response.getStatusLine();
        HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(statusLine.getStatusCode());
        if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
            if (response.getEntity() != null) {
                try {
                    final ContentType responseContentType = ContentType.create(
                        response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
View Full Code Here

    HttpURLConnection connection = initializeConnection(absoluteUri, contentType, httpMethod);
    byte[] buffer = content.getBytes("UTF-8");
    connection.getOutputStream().write(buffer);

    // if a entity is created (via POST request) the response body contains the new created entity
    HttpStatusCodes statusCode = HttpStatusCodes.fromStatusCode(connection.getResponseCode());
    if(statusCode == HttpStatusCodes.CREATED) {
      // get the content as InputStream and de-serialize it into an ODataEntry object
      InputStream responseContent = connection.getInputStream();
      logRawContent(httpMethod + " response:\n  ", responseContent, "\n");
    } else if(statusCode == HttpStatusCodes.NO_CONTENT) {
View Full Code Here

    LOG.info(content);
  }


  private HttpStatusCodes checkStatus(HttpURLConnection connection) throws IOException {
    HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(connection.getResponseCode());
    if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
      connection.disconnect();
      throw new RuntimeException("Http Connection failed with status " + httpStatusCode.getStatusCode() + " " + httpStatusCode.toString());
    }
    return httpStatusCode;
  }
View Full Code Here

      String path = fitTestSet.path;
      List<String> queryOptions = fitTestSet.queryOptions;
      List<String> acceptHeaders = fitTestSet.acceptHeader;
      String content = fitTestSet.content;
      List<String> requestContentTypeHeaders = fitTestSet.requestContentTypes;
      HttpStatusCodes expectedStatusCode = fitTestSet.expectedStatusCode;

      return create(uriType, httpMethod, path, queryOptions, acceptHeaders, acceptHeader2ContentType,
          content, requestContentTypeHeaders, expectedStatusCode);
    }
View Full Code Here

    String path = "/Employees";
    String queryOption = "";
    String acceptHeader = "*";
    String content = "IMAGE_;o)";
    String requestContentType = "image/jpeg";
    HttpStatusCodes expectedStatusCode = HttpStatusCodes.CREATED;
    String expectedContentType = "application/atom+xml; charset=utf-8; type=entry";

    FitTest test =
        FitTest.create(uriType, httpMethod, path, queryOption, acceptHeader, content, requestContentType,
            expectedStatusCode, expectedContentType);
View Full Code Here

    String path = "/Employees('1')";
    String queryOption = "";
    String acceptHeader = "*";
    String content = "IMAGE_;o)";
    String requestContentType = "image/jpeg";
    HttpStatusCodes expectedStatusCode = HttpStatusCodes.CREATED;
    String expectedContentType = "image/jpeg";

    FitTest test =
        FitTest.create(uriType, httpMethod, path, queryOption, acceptHeader, content, requestContentType,
            expectedStatusCode, expectedContentType);
View Full Code Here

        .replace("'1'", "'9'")
        .replace("Id>1", "Id>9")
        .replace("Team 1", "Team X")
        .replaceAll("<link.+?/>", "");
    String requestContentType = HttpContentType.APPLICATION_ATOM_XML_ENTRY;
    HttpStatusCodes expectedStatusCode = HttpStatusCodes.CREATED;
    String headerName = "Accept";
    String headerValue = "application/atom+xml;type=entry";
    HttpResponse response =
        callUri(ODataHttpMethod.POST, "Teams()", headerName, headerValue, requestBody, requestContentType,
            expectedStatusCode);
View Full Code Here

    return edm;
  }

  private void checkStatus(final HttpURLConnection connection) throws IOException, HttpException {
    if (400 <= connection.getResponseCode() && connection.getResponseCode() <= 599) {
      HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(connection.getResponseCode());
      throw new HttpException(httpStatusCode, httpStatusCode.getStatusCode() + " " + httpStatusCode.toString());
    }
  }
View Full Code Here

      ODataResponseBuilder extendedResponse = ODataResponse.fromResponse(odataResponse);
      final UriType uriType = uriInfo.getUriType();
      final String location =
          (method == ODataHttpMethod.POST && (uriType == UriType.URI1 || uriType == UriType.URI6B)) ? odataResponse
              .getIdLiteral() : null;
      final HttpStatusCodes s = getStatusCode(odataResponse, method, uriType);
      extendedResponse = extendedResponse.idLiteral(location).status(s);

      if (!odataResponse.containsHeader(ODataHttpHeaders.DATASERVICEVERSION)) {
        extendedResponse = extendedResponse.header(ODataHttpHeaders.DATASERVICEVERSION, serverDataServiceVersion);
      }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.commons.HttpStatusCodes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.