Search in sources :

Example 1 with ItemRoutes

use of com.liferay.apio.architect.routes.ItemRoutes in project com-liferay-apio-architect by liferay.

the class PageEndpointImpl method deleteCollectionItem.

@Override
public Response deleteCollectionItem(String id) throws Exception {
    Try<ItemRoutes<T, S>> itemRoutesTry = Try.fromOptional(_itemRoutesSupplier::get, notFound(_name));
    ThrowableConsumer<S> throwableConsumer = itemRoutesTry.mapOptional(ItemRoutes::getDeleteConsumerOptional, notAllowed(DELETE, _name, id)).map(function -> function.apply(_httpServletRequest)).getUnchecked();
    Path path = new Path(_name, id);
    throwableConsumer.accept(_identifierFunction.apply(path));
    return noContent().build();
}
Also used : Body(com.liferay.apio.architect.form.Body) ItemRoutes(com.liferay.apio.architect.routes.ItemRoutes) ExceptionSupplierUtil.notFound(com.liferay.apio.architect.endpoint.ExceptionSupplierUtil.notFound) NestedCollectionRoutes(com.liferay.apio.architect.routes.NestedCollectionRoutes) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ExceptionSupplierUtil.notAllowed(com.liferay.apio.architect.endpoint.ExceptionSupplierUtil.notAllowed) PageEndpoint(com.liferay.apio.architect.endpoint.PageEndpoint) Representor(com.liferay.apio.architect.representor.Representor) Identifier(com.liferay.apio.architect.identifier.Identifier) ThrowableFunction(com.liferay.apio.architect.function.throwable.ThrowableFunction) HttpServletRequest(javax.servlet.http.HttpServletRequest) Response.noContent(javax.ws.rs.core.Response.noContent) Page(com.liferay.apio.architect.pagination.Page) CollectionRoutes(com.liferay.apio.architect.routes.CollectionRoutes) POST(com.liferay.apio.architect.operation.Method.POST) DELETE(com.liferay.apio.architect.operation.Method.DELETE) RelatedCollection(com.liferay.apio.architect.related.RelatedCollection) SingleModel(com.liferay.apio.architect.single.model.SingleModel) NoSuchElementException(java.util.NoSuchElementException) PUT(com.liferay.apio.architect.operation.Method.PUT) Try(com.liferay.apio.architect.functional.Try) Predicate(java.util.function.Predicate) Path(com.liferay.apio.architect.uri.Path) Response(javax.ws.rs.core.Response) ThrowableConsumer(com.liferay.apio.architect.consumer.throwable.ThrowableConsumer) Optional(java.util.Optional) Path(com.liferay.apio.architect.uri.Path) ItemRoutes(com.liferay.apio.architect.routes.ItemRoutes)

Aggregations

ThrowableConsumer (com.liferay.apio.architect.consumer.throwable.ThrowableConsumer)1 ExceptionSupplierUtil.notAllowed (com.liferay.apio.architect.endpoint.ExceptionSupplierUtil.notAllowed)1 ExceptionSupplierUtil.notFound (com.liferay.apio.architect.endpoint.ExceptionSupplierUtil.notFound)1 PageEndpoint (com.liferay.apio.architect.endpoint.PageEndpoint)1 Body (com.liferay.apio.architect.form.Body)1 ThrowableFunction (com.liferay.apio.architect.function.throwable.ThrowableFunction)1 Try (com.liferay.apio.architect.functional.Try)1 Identifier (com.liferay.apio.architect.identifier.Identifier)1 DELETE (com.liferay.apio.architect.operation.Method.DELETE)1 POST (com.liferay.apio.architect.operation.Method.POST)1 PUT (com.liferay.apio.architect.operation.Method.PUT)1 Page (com.liferay.apio.architect.pagination.Page)1 RelatedCollection (com.liferay.apio.architect.related.RelatedCollection)1 Representor (com.liferay.apio.architect.representor.Representor)1 CollectionRoutes (com.liferay.apio.architect.routes.CollectionRoutes)1 ItemRoutes (com.liferay.apio.architect.routes.ItemRoutes)1 NestedCollectionRoutes (com.liferay.apio.architect.routes.NestedCollectionRoutes)1 SingleModel (com.liferay.apio.architect.single.model.SingleModel)1 Path (com.liferay.apio.architect.uri.Path)1 NoSuchElementException (java.util.NoSuchElementException)1