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


Java HttpMethod.DELETE属性代码示例

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


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

示例1: validatePropertyOperations

private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
    throws UriValidationException {
  final List<UriResource> parts = uriInfo.getUriResourceParts();
  final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
  final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null
      && (last.getKind() == UriResourceKind.primitiveProperty
      || last.getKind() == UriResourceKind.complexProperty
      || (last.getKind() == UriResourceKind.value
          && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
    final EdmProperty property = ((UriResourceProperty)
        (last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("Attempt to patch collection property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("Attempt to delete non-nullable property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:UriValidator.java

示例2: 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

示例3: 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

示例4: 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

示例5: getDeleteRequest

@Override
public ODataDeleteRequest getDeleteRequest(final URI targetURI) {
  final ODataDeleteRequest req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataDeleteRequestImpl(client, HttpMethod.POST, targetURI);
    req.setXHTTPMethod(HttpMethod.DELETE.name());
  } else {
    req = new ODataDeleteRequestImpl(client, HttpMethod.DELETE, targetURI);
  }

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

示例6: 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

示例7: handlePrimitiveDispatching

private void handlePrimitiveDispatching(final ODataRequest request, final ODataResponse response,
    final boolean isCollection) throws ODataApplicationException, ODataLibraryException {
  final HttpMethod method = request.getMethod();
  final RepresentationType representationType = isCollection ? RepresentationType.COLLECTION_PRIMITIVE
      : RepresentationType.PRIMITIVE;
  if (method == HttpMethod.GET) {
    final ContentType requestedContentType = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), representationType);
    if (isCollection) {
      handler.selectProcessor(PrimitiveCollectionProcessor.class)
          .readPrimitiveCollection(request, response, uriInfo, requestedContentType);
    } else {
      handler.selectProcessor(PrimitiveProcessor.class)
          .readPrimitive(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, true);
    final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), representationType);
    if (isCollection) {
      handler.selectProcessor(PrimitiveCollectionProcessor.class)
          .updatePrimitiveCollection(request, response, uriInfo, requestFormat, responseFormat);
    } else {
      handler.selectProcessor(PrimitiveProcessor.class)
          .updatePrimitive(request, response, uriInfo, requestFormat, responseFormat);
    }
  } else if (method == HttpMethod.DELETE) {
    validatePreconditions(request, false);
    if (isCollection) {
      handler.selectProcessor(PrimitiveCollectionProcessor.class)
          .deletePrimitiveCollection(request, response, uriInfo);
    } else {
      handler.selectProcessor(PrimitiveProcessor.class)
          .deletePrimitive(request, response, uriInfo);
    }
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:41,代码来源:ODataDispatcher.java

示例8: 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

示例9: isDELETE

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

示例10: allowedMethods

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

示例11: allowedMethods

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


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