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


Java HttpMethod.GET属性代码示例

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


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

示例1: setRequest

/**
 * {@inheritDoc }
 */
@Override
public ODataSingleRequest setRequest(final ODataBatchableRequest request) {
  if (!isOpen()) {
    throw new IllegalStateException("Current batch item is closed");
  }

  hasStreamedSomething = true;

  // stream the request
  if (request.getMethod() == HttpMethod.GET) {
    streamRequestHeader(request);
  } else {
    streamRequestHeader(ODataSingleResponseItem.SINGLE_CONTENT_ID);
    request.batch(req, ODataSingleResponseItem.SINGLE_CONTENT_ID);
  }

  // close before in order to avoid any further setRequest calls.
  close();

  // add request to the list
  expectedResItem.addResponse(
          ODataSingleResponseItem.SINGLE_CONTENT_ID, ((AbstractODataRequest) request).getResponseTemplate());

  return this;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:28,代码来源:ODataSingleRequestImpl.java

示例2: invalidMethodForChangeset

@Test
public void invalidMethodForChangeset() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.GET + " " + PROPERTY_URI + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + "--"
      + CRLF
      + "--" + BOUNDARY + "--";

  parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_CHANGESET_METHOD);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:BatchRequestParserTest.java

示例3: handleMediaValueDispatching

private void handleMediaValueDispatching(final ODataRequest request, final ODataResponse response,
    final UriResource resource) throws ContentNegotiatorException, 
   ODataApplicationException, ODataLibraryException,
    ODataHandlerException, PreconditionException {
  final HttpMethod method = request.getMethod();
  if (method == HttpMethod.GET) {
    // This can be a GET on an EntitySet, Navigation or Function
    final ContentType requestedContentType = ContentNegotiator.
        doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.MEDIA);
    handler.selectProcessor(MediaEntityProcessor.class)
        .readMediaEntity(request, response, uriInfo, requestedContentType);
    // PUT and DELETE can only be called on EntitySets or Navigation properties which are media resources
  } else if (method == HttpMethod.PUT && (isEntityOrNavigationMedia(resource) 
      || isSingletonMedia(resource))) {
    validatePreconditions(request, true);
    final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
    final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
    handler.selectProcessor(MediaEntityProcessor.class)
        .updateMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
  } else if (method == HttpMethod.DELETE && isEntityOrNavigationMedia(resource)) {
    validatePreconditions(request, true);
    handler.selectProcessor(MediaEntityProcessor.class)
        .deleteMediaEntity(request, response, uriInfo);
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:ODataDispatcher.java

示例4: handlePrimitiveValueDispatching

private void handlePrimitiveValueDispatching(final ODataRequest request, final ODataResponse response,
    final UriResource resource) throws ContentNegotiatorException, 
ODataApplicationException, ODataLibraryException,
    ODataHandlerException, PreconditionException {
  final HttpMethod method = request.getMethod();
  final EdmType type = resource instanceof UriResourceProperty ?
      ((UriResourceProperty) resource).getType() : ((UriResourceFunction) resource).getType();
  final RepresentationType valueRepresentationType =
      type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Binary) ?
          RepresentationType.BINARY : RepresentationType.VALUE;
  if (method == HttpMethod.GET) {
    final ContentType requestedContentType = ContentNegotiator.
        doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), valueRepresentationType);

    handler.selectProcessor(PrimitiveValueProcessor.class)
        .readPrimitiveValue(request, response, uriInfo, requestedContentType);
  } else if (method == HttpMethod.PUT && resource instanceof UriResourceProperty) {
    validatePreconditions(request, false);
    final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
        valueRepresentationType, true);
    final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), valueRepresentationType);
    handler.selectProcessor(PrimitiveValueProcessor.class)
        .updatePrimitiveValue(request, response, uriInfo, requestFormat, responseFormat);
  } else if (method == HttpMethod.DELETE && resource instanceof UriResourceProperty) {
    validatePreconditions(request, false);
    handler.selectProcessor(PrimitiveValueProcessor.class)
        .deletePrimitiveValue(request, response, uriInfo);
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:ODataDispatcher.java

示例5: handleSingleEntityDispatching

private void handleSingleEntityDispatching(final ODataRequest request, final ODataResponse response,
    final boolean isMedia, final boolean isSingleton) throws 
ContentNegotiatorException, ODataApplicationException,
    ODataLibraryException, ODataHandlerException, PreconditionException {
  final HttpMethod method = request.getMethod();
  if (method == HttpMethod.GET) {
    final ContentType requestedContentType = ContentNegotiator.
        doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
    handler.selectProcessor(EntityProcessor.class)
        .readEntity(request, response, uriInfo, requestedContentType);
  } else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
    validatePreconditions(request, false);
    final ContentType requestFormat = getSupportedContentType(
        request.getHeader(HttpHeader.CONTENT_TYPE),
        RepresentationType.ENTITY, true);
    final ContentType responseFormat = ContentNegotiator.
        doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
    handler.selectProcessor(EntityProcessor.class)
        .updateEntity(request, response, uriInfo, requestFormat, responseFormat);
  } else if (method == HttpMethod.DELETE && !isSingleton) {
    validateIsSingleton(method);
    validatePreconditions(request, false);
    handler.selectProcessor(isMedia ? MediaEntityProcessor.class : EntityProcessor.class)
        .deleteEntity(request, response, uriInfo);
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:ODataDispatcher.java

示例6: missingHttpVersion

@Test
public void missingHttpVersion() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " ESAllPrim?$format=json" + CRLF
      + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_STATUS_LINE);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:BatchRequestParserTest.java

示例7: missingHttpVersion2

@Test
public void missingHttpVersion2() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " ESAllPrim?$format=json " + CRLF
      + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.INVALID_HTTP_VERSION);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:BatchRequestParserTest.java

示例8: getRequestMissingCRLF

@Test
public void getRequestMissingCRLF() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.GET + " " + PROPERTY_URI + HTTP_VERSION + CRLF
      // + CRLF // Belongs to the GET request
      + CRLF // Belongs to the boundary
      + "--" + BOUNDARY + "--";

  parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.MISSING_BLANK_LINE);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:BatchRequestParserTest.java

示例9: noContentId

@Test
public void noContentId() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " ESMedia" + HTTP_VERSION + CRLF
      + ACCEPT_HEADER
      + CRLF
      + CRLF
      + "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
      + "Content-Transfer-Encoding: base64" + CRLF
      + CRLF
      + "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
      + "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{\"value\":5}" + CRLF
      + "--" + CHANGESET_BOUNDARY + "--" + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  parse(batch);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:37,代码来源:BatchRequestParserTest.java

示例10: createBatchWithGetRequest

private String createBatchWithGetRequest(final String url, final String additionalHeader) {
  return "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " " + url + HTTP_VERSION + CRLF
      + (additionalHeader == null ? "" : (additionalHeader + CRLF))
      + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:BatchRequestParserTest.java

示例11: handleComplexDispatching

private void handleComplexDispatching(final ODataRequest request, final ODataResponse response,
    final boolean isCollection) throws ODataApplicationException, ODataLibraryException {
  final HttpMethod method = request.getMethod();
  final RepresentationType complexRepresentationType = isCollection ? RepresentationType.COLLECTION_COMPLEX
      : RepresentationType.COMPLEX;
  if (method == HttpMethod.GET) {
    final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), complexRepresentationType);
    if (isCollection) {
      handler.selectProcessor(ComplexCollectionProcessor.class)
          .readComplexCollection(request, response, uriInfo, requestedContentType);
    } else {
      handler.selectProcessor(ComplexProcessor.class)
          .readComplex(request, response, uriInfo, requestedContentType);
    }
  } else if (method == HttpMethod.PUT || method == HttpMethod.PATCH) {
    validatePreconditions(request, false);
    final ContentType requestFormat = getSupportedContentType(request.getHeader(HttpHeader.CONTENT_TYPE),
        complexRepresentationType, true);
    final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), complexRepresentationType);
    if (isCollection) {
      handler.selectProcessor(ComplexCollectionProcessor.class)
          .updateComplexCollection(request, response, uriInfo, requestFormat, responseFormat);
    } else {
      handler.selectProcessor(ComplexProcessor.class)
          .updateComplex(request, response, uriInfo, requestFormat, responseFormat);
    }
  } else if (method == HttpMethod.DELETE) {
    validatePreconditions(request, false);
    if (isCollection) {
      handler.selectProcessor(ComplexCollectionProcessor.class)
          .deleteComplexCollection(request, response, uriInfo);
    } else {
      handler.selectProcessor(ComplexProcessor.class)
          .deleteComplex(request, response, uriInfo);
    }
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:ODataDispatcher.java

示例12: allowedMethods

@Override
public HttpMethod[] allowedMethods() {
  return new HttpMethod[] { HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE };
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:4,代码来源:DataRequest.java

示例13: methodsForIndividualRequests

@Test
public void methodsForIndividualRequests() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.POST + " ESAllPrim" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{ \"PropertyString\": \"Foo\" }"
      + CRLF
      + "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.DELETE + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
      + CRLF
      + CRLF
      + "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.PATCH + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{ \"PropertyString\": \"Foo\" }" + CRLF
      + "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.PUT + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{ \"PropertyString\": \"Foo\" }" + CRLF
      + "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " ESAllPrim(32767)" + HTTP_VERSION + CRLF
      + ACCEPT_HEADER
      + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  final List<BatchRequestPart> requests = parse(batch);

  Assert.assertEquals(HttpMethod.POST, requests.get(0).getRequests().get(0).getMethod());
  Assert.assertEquals("/ESAllPrim", requests.get(0).getRequests().get(0).getRawODataPath());
  Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
      IOUtils.toString(requests.get(0).getRequests().get(0).getBody()));

  Assert.assertEquals(HttpMethod.DELETE, requests.get(1).getRequests().get(0).getMethod());
  Assert.assertEquals("/ESAllPrim(32767)", requests.get(1).getRequests().get(0).getRawODataPath());

  Assert.assertEquals(HttpMethod.PATCH, requests.get(2).getRequests().get(0).getMethod());
  Assert.assertEquals("/ESAllPrim(32767)", requests.get(2).getRequests().get(0).getRawODataPath());
  Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
      IOUtils.toString(requests.get(2).getRequests().get(0).getBody()));

  Assert.assertEquals(HttpMethod.PUT, requests.get(3).getRequests().get(0).getMethod());
  Assert.assertEquals("/ESAllPrim(32767)", requests.get(3).getRequests().get(0).getRawODataPath());
  Assert.assertEquals("{ \"PropertyString\": \"Foo\" }",
      IOUtils.toString(requests.get(3).getRequests().get(0).getBody()));

  Assert.assertEquals(HttpMethod.GET, requests.get(4).getRequests().get(0).getMethod());
  Assert.assertEquals("/ESAllPrim(32767)", requests.get(4).getRequests().get(0).getRawODataPath());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:62,代码来源:BatchRequestParserTest.java

示例14: isGET

protected boolean isGET() {
  return this.request.getMethod() == HttpMethod.GET;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:3,代码来源:ServiceRequest.java

示例15: preamble

@Test
public void preamble() throws Exception {
  final String batch = "This is a preamble and must be ignored" + CRLF
      + CRLF
      + CRLF
      + "----1242" + CRLF
      + "--" + BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.GET + " ESAllPrim" + HTTP_VERSION + CRLF
      + ACCEPT_HEADER
      + CRLF
      + CRLF
      + "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "This is a preamble and must be ignored" + CRLF
      + CRLF
      + CRLF
      + "----1242" + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.POST + " ESMedia" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": image/png" + CRLF
      + "Content-Transfer-Encoding: base64" + CRLF
      + CRLF
      + "iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
      + "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 2" + CRLF
      + CRLF
      + HttpMethod.PUT + " $1/PropertyInt16" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "{\"value\":5}" + CRLF
      + "--" + CHANGESET_BOUNDARY + "--" + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";
  final List<BatchRequestPart> batchRequestParts = parse(batch);

  Assert.assertNotNull(batchRequestParts);
  Assert.assertEquals(2, batchRequestParts.size());

  final BatchRequestPart getRequestPart = batchRequestParts.get(0);
  Assert.assertEquals(1, getRequestPart.getRequests().size());

  final ODataRequest getRequest = getRequestPart.getRequests().get(0);
  Assert.assertEquals(HttpMethod.GET, getRequest.getMethod());

  final BatchRequestPart changeSetPart = batchRequestParts.get(1);
  Assert.assertEquals(2, changeSetPart.getRequests().size());
  Assert.assertEquals("iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAABmJLR0QA/wD/AP+gvaeTAAAAH0lE"
      + "QVQokWNgGHmA8S4FmpkosXngNDP+PzdANg+cZgBqiQK5mkdWWgAAAABJRU5ErkJggg==" + CRLF,
      IOUtils.toString(changeSetPart.getRequests().get(0).getBody()));
  Assert.assertEquals("{\"value\":5}", IOUtils.toString(changeSetPart.getRequests().get(1).getBody()));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:60,代码来源:BatchRequestParserTest.java


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