当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatusCodes.NO_CONTENT属性代码示例

本文整理汇总了Java中org.apache.olingo.odata2.api.commons.HttpStatusCodes.NO_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatusCodes.NO_CONTENT属性的具体用法?Java HttpStatusCodes.NO_CONTENT怎么用?Java HttpStatusCodes.NO_CONTENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.olingo.odata2.api.commons.HttpStatusCodes的用法示例。


在下文中一共展示了HttpStatusCodes.NO_CONTENT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeEntity

private void writeEntity(String absoluteUri, String content, String contentType, String httpMethod)
    throws IOException, URISyntaxException {

  print(httpMethod + " request on uri: " + absoluteUri + ":\n  " + content + "\n");
  //
  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) {
    print("No content.");
  } else {
    checkStatus(connection);
  }

  //
  connection.disconnect();
}
 
开发者ID:mirchiseth,项目名称:cf-cars-svc,代码行数:24,代码来源:AnnotationSampleDataGenerator.java

示例2: executeValidated

public HttpResponse executeValidated(HttpStatusCodes expectedStatusCode) throws IOException {
  HttpResponse response = this.execute();
  assertNotNull(response);
  assertEquals(expectedStatusCode.getStatusCode(), response.getStatusLine().getStatusCode());

  if (expectedStatusCode == HttpStatusCodes.OK) {
    assertNotNull(response.getEntity());
    assertNotNull(response.getEntity().getContent());
  } else if (expectedStatusCode == HttpStatusCodes.CREATED) {
    assertNotNull(response.getEntity());
    assertNotNull(response.getEntity().getContent());
    assertNotNull(response.getFirstHeader(HttpHeaders.LOCATION));
  } else if (expectedStatusCode == HttpStatusCodes.NO_CONTENT) {
    assertTrue(response.getEntity() == null || response.getEntity().getContent() == null);
  }

  return response;
}
 
开发者ID:mibo,项目名称:janos,代码行数:18,代码来源:AbstractRefTest.java

示例3: getStatusCode

private HttpStatusCodes getStatusCode(final ODataResponse odataResponse, final ODataHttpMethod method,
    final UriType uriType) {
  if (odataResponse.getStatus() == null) {
    if (method == ODataHttpMethod.POST) {
      if (uriType == UriType.URI9) {
        return HttpStatusCodes.OK;
      } else if (uriType == UriType.URI7B) {
        return HttpStatusCodes.NO_CONTENT;
      }
      return HttpStatusCodes.CREATED;
    } else if (method == ODataHttpMethod.PUT
        || method == ODataHttpMethod.PATCH
        || method == ODataHttpMethod.MERGE
        || method == ODataHttpMethod.DELETE) {
      return HttpStatusCodes.NO_CONTENT;
    }
    return HttpStatusCodes.OK;
  }
  return odataResponse.getStatus();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:ODataRequestHandler.java

示例4: writeEntity

private String writeEntity(String absoluteUri, String content, String contentType, String httpMethod)
    throws IOException, URISyntaxException {

  String location = null;
  print(httpMethod + " request on uri: " + absoluteUri + ":\n  " + content + "\n");
  //
  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");
    location = connection.getHeaderField("Location");
  } else if (statusCode == HttpStatusCodes.NO_CONTENT) {
    print("No content.");
  } else {
    checkStatus(connection);
  }

  //
  connection.disconnect();
  return location;
}
 
开发者ID:mibo,项目名称:janos,代码行数:27,代码来源:JpaSampleDataGenerator.java

示例5: callUri

protected HttpResponse callUri(
    final ODataHttpMethod httpMethod, final String uri,
    final String additionalHeader, final String additionalHeaderValue,
    final String requestBody, final String requestContentType,
    final HttpStatusCodes expectedStatusCode) throws Exception {

  HttpRequestBase request =
      httpMethod == ODataHttpMethod.GET ? new HttpGet() :
          httpMethod == ODataHttpMethod.DELETE ? new HttpDelete() :
              httpMethod == ODataHttpMethod.POST ? new HttpPost() :
                  httpMethod == ODataHttpMethod.PUT ? new HttpPut() : new HttpPatch();
  request.setURI(URI.create(getEndpoint() + uri));
  if (additionalHeader != null) {
    request.addHeader(additionalHeader, additionalHeaderValue);
  }
  if (requestBody != null) {
    ((HttpEntityEnclosingRequest) request).setEntity(new StringEntity(requestBody));
    request.setHeader(HttpHeaders.CONTENT_TYPE, requestContentType);
  }

  final HttpResponse response = getHttpClient().execute(request);

  assertNotNull(response);
  assertEquals(expectedStatusCode.getStatusCode(), response.getStatusLine().getStatusCode());

  if (expectedStatusCode == HttpStatusCodes.OK) {
    assertNotNull(response.getEntity());
    assertNotNull(response.getEntity().getContent());
  } else if (expectedStatusCode == HttpStatusCodes.CREATED) {
    assertNotNull(response.getEntity());
    assertNotNull(response.getEntity().getContent());
    assertNotNull(response.getFirstHeader(HttpHeaders.LOCATION));
  } else if (expectedStatusCode == HttpStatusCodes.NO_CONTENT) {
    assertTrue(response.getEntity() == null || response.getEntity().getContent() == null);
  }

  return response;
}
 
开发者ID:mibo,项目名称:janos,代码行数:38,代码来源:AbstractRefTest.java

示例6: deleteUri

protected void deleteUri(final String uri, final HttpStatusCodes expectedStatusCode)
    throws Exception, AssertionError {
  final HttpResponse response = callUri(ODataHttpMethod.DELETE, uri, null, null, null, null, expectedStatusCode);
  if (expectedStatusCode != HttpStatusCodes.NO_CONTENT) {
    response.getEntity().getContent().close();
  }
}
 
开发者ID:mibo,项目名称:janos,代码行数:7,代码来源:AbstractRefTest.java

示例7: putUri

protected void putUri(final String uri,
    final String requestBody, final String requestContentType,
    final HttpStatusCodes expectedStatusCode) throws Exception {
  final HttpResponse response =
      callUri(ODataHttpMethod.PUT, uri, null, null, requestBody, requestContentType, expectedStatusCode);
  if (expectedStatusCode != HttpStatusCodes.NO_CONTENT) {
    response.getEntity().getContent().close();
  }
}
 
开发者ID:mibo,项目名称:janos,代码行数:9,代码来源:AbstractRefTest.java


注:本文中的org.apache.olingo.odata2.api.commons.HttpStatusCodes.NO_CONTENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。