From 6388ca7c62f5a86ceef9110d54adf729a9cdb5f0 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 4 Jun 2020 20:27:02 +0200 Subject: [PATCH] More methods definitions for CategoriesApi --- .../admin/categorization/CategoriesApi.java | 204 ++++++++++++++---- 1 file changed, 158 insertions(+), 46 deletions(-) diff --git a/ccm-core/src/main/java/org/libreccm/api/admin/categorization/CategoriesApi.java b/ccm-core/src/main/java/org/libreccm/api/admin/categorization/CategoriesApi.java index ef2dfd324..9b1ae7167 100644 --- a/ccm-core/src/main/java/org/libreccm/api/admin/categorization/CategoriesApi.java +++ b/ccm-core/src/main/java/org/libreccm/api/admin/categorization/CategoriesApi.java @@ -18,8 +18,23 @@ */ package org.libreccm.api.admin.categorization; +import org.libreccm.api.admin.categorization.dto.CategoryData; +import org.libreccm.api.dto.ListView; +import org.libreccm.core.CoreConstants; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.RequiresPrivilege; + import javax.enterprise.context.RequestScoped; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; /** * @@ -28,64 +43,161 @@ import javax.ws.rs.Path; @RequestScoped @Path("/categories") public class CategoriesApi { - - // GET (sub-)categories for path @Path("/{domain-identifier}/{path} - - // POST add (sub-) category @Path("/{domain-identifier}/{path} - - // GET categoryById @Path("/ID-{categoryId}") - - // GET categoryByUuid @Path("UUID-{categoryId}") - - // GET category @Path("/{domain-identifier}/{path} - - // PUT update category @Path("/{domain-identifier}/{path} - - // PUT update category by id @Path("/ID-{categoryId}") - - // PUT update category by uuid @Path("/UUID-{categoryUuid}") - - // delete only for empty categories!!! - // delete category @Path("/{domain-identifier}/{path} + + @GET + @Path("/{domainIdentifier}/{path:^[\\w\\-/]+$}") + @Produces(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public ListView getCategories( + @PathParam("domainIdentifier") final String domainIdentifierParam, + @PathParam("path") final String categoryPathTokens + ) { + throw new UnsupportedOperationException(); + } + + @POST + @Path("/{domainIdentifier}/{path:^[\\w\\-/]+$}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public ListView addNewSubCategory( + @PathParam("domainIdentifier") final String domainIdentifierParam, + @PathParam("path") final String categoryPathTokens, + final CategoryData categoryData + ) { + throw new UnsupportedOperationException(); + } + + @GET + @Path("/{domainIdentifier}/{path:^[\\w\\-/]+$}") + @Produces(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData getCategory( + @PathParam("domainIdentifier") final String domainIdentifierParam, + @PathParam("path") final String categoryPathTokens + ) { + throw new UnsupportedOperationException(); + } + + @GET + @Path("/ID-{categoryId}") + @Produces(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData getCategory( + @PathParam("categoryId") final long categoryId + ) { + throw new UnsupportedOperationException(); + } + + @GET + @Path("/UUID-{categoryId}") + @Produces(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData getCategory( + @PathParam("categoryId") final String categoryUuid + ) { + throw new UnsupportedOperationException(); + } + + @PUT + @Path("/{domainIdentifier}/{path:^[\\w\\-/]+$}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData updateCategory( + @PathParam("domainIdentifier") final String domainIdentifierParam, + @PathParam("path") final String categoryPathTokens, + final CategoryData categoryData + ) { + throw new UnsupportedOperationException(); + } + + @PUT + @Path("/ID-{categoryId}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData updateCategory( + @PathParam("catgoryId") final long categoryIdParam, + final CategoryData categoryData + ) { + throw new UnsupportedOperationException(); + } + + @PUT + @Path("/UUID-{categoryUuid}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData updateCategory( + @PathParam("catgoryUid") final String categoryIdParam, + final CategoryData categoryData + ) { + throw new UnsupportedOperationException(); + } + + @DELETE + @Path("/{domainIdentifier}/{path:^[\\w\\-/]+$}") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData deleteCategory( + @PathParam("domainIdentifier") final String domainIdentifierParam, + @PathParam("path") final String categoryPathTokens + ) { + // Delete only empty categories!!! + throw new UnsupportedOperationException(); + } // delete update category by id @Path("/ID-{categoryId}") + @DELETE + @Path("/ID-{categoryId}") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData deleteCategory( + @PathParam("categoryId") final long categoryIdParam + ) { + // Delete only empty categories!!! + throw new UnsupportedOperationException(); + } - // delete update category by uuid @Path("/UUID-{categoryId}") - + @DELETE + @Path("/UUID-{categoryUuid}") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public CategoryData deleteCategory( + @PathParam("categoryId") final String categoryUuidParam + ) { + // Delete only empty categories!!! + throw new UnsupportedOperationException(); + } // GET object in category @Path("/{domain-identifier}/{path}/objects - // GET object in category @Path("/ID-{categoryId} - // GET object in category @Path("/UUID-{categoryUuid} - // PUT object in category @Path("/{domain-identifier}/{path}/objects/{objectIdentifier} - // PUT object in category @Path("/ID-{categoryId}/{objectIdentifier} - // PUT object in category @Path("/UUID-{categoryUuid}/{objectIdentifier} - // DELETE object in category @Path("/{domain-identifier}/{path}/objects/{objectIdentifier} - // DELETE object in category @Path("/ID-{categoryId}/{objectIdentifier} - // DELETE object in category @Path("/UUID-{categoryUuid}/{objectIdentifier} - // GET subcategory in category @Path("/{domain-identifier}/{path}/subcategories - - // GET subcategory in category @Path("/ID-{categoryId} - - // GET subcategory in category @Path("/UUID-{categoryUuid} - - // PUT subcategory in category @Path("/{domain-identifier}/{path}/subcategories/{subcategoryIdentifier} - - // PUT subcategory in category @Path("/ID-{categoryId}/{subcategoryIdentifier} - - // PUT subcategory in category @Path("/UUID-{categoryUuid}/{subcategoryIdentifier} - - // DELETE subcategory in category @Path("/{domain-identifier}/{path}/subcategories/{subcategoryIdentifier} - - // DELETE subcategory in category @Path("/ID-{categoryId}/{subcategoryIdentifier} - - // DELETE subcategory in category @Path("/UUID-{categoryUuid}/{subcategoryIdentifier} }