本文整理汇总了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());
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例9: isDELETE
protected boolean isDELETE() {
return this.request.getMethod() == HttpMethod.DELETE;
}
示例10: allowedMethods
@Override
public HttpMethod[] allowedMethods() {
return new HttpMethod[] { HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT,
HttpMethod.PATCH, HttpMethod.DELETE };
}
示例11: allowedMethods
@Override
public HttpMethod[] allowedMethods() {
return new HttpMethod[] { HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE };
}