From c6a140c3db764d020bfc109787f4c6d8d0fdcfa2 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 8 Nov 2020 10:38:07 +0100 Subject: [PATCH] Renamed CategoriesController to CategorySystemController --- .../ui/admin/categories/CategoriesPage.java | 5 +- ...java => CategorySystemFormController.java} | 28 ++-- .../categories/CategorySystemsController.java | 134 ++++++++++++++++++ 3 files changed, 157 insertions(+), 10 deletions(-) rename ccm-core/src/main/java/org/libreccm/ui/admin/categories/{CategoriesController.java => CategorySystemFormController.java} (68%) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java index fa877b379..d9dba20df 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java @@ -36,14 +36,15 @@ public class CategoriesPage implements AdminPage { @Override public Set> getControllerClasses() { final Set> classes = new HashSet<>(); - classes.add(CategoriesController.class); + classes.add(CategorySystemsController.class); + classes.add(CategorySystemFormController.class); return classes; } @Override public String getUriIdentifier() { return String.format( - "%s#getCategories", CategoriesController.class.getSimpleName() + "%s#getCategories", CategorySystemsController.class.getSimpleName() ); } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java similarity index 68% rename from ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java rename to ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java index aebf65cf7..179f25fe2 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java @@ -24,23 +24,35 @@ import org.libreccm.security.RequiresPrivilege; import javax.enterprise.context.RequestScoped; import javax.mvc.Controller; -import javax.ws.rs.GET; +import javax.transaction.Transactional; +import javax.ws.rs.POST; import javax.ws.rs.Path; /** * * @author Jens Pelzetter */ -@RequestScoped @Controller -@Path("/categories") -public class CategoriesController { +@Path("/categorysystems") +@RequestScoped +public class CategorySystemFormController { - @GET - @Path("/") + @POST + @Path("/new") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getCategories() { - return "org/libreccm/ui/admin/categories.xhtml"; + @Transactional(Transactional.TxType.REQUIRED) + public String createCategorySystem() { + throw new UnsupportedOperationException(); } + + @POST + @Path("/{categorySystemIdentifier}/edit") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional(Transactional.TxType.REQUIRED) + public String updateCategorySystem() { + throw new UnsupportedOperationException(); + } + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java new file mode 100644 index 000000000..c324456b6 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2020 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.ui.admin.categories; + +import org.libreccm.core.CoreConstants; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.RequiresPrivilege; + +import javax.enterprise.context.RequestScoped; +import javax.mvc.Controller; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/categorymanager") +public class CategorySystemsController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getCategoryManager() { + return getCategorySystems(); + } + + @GET + @Path("/categorysystems") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getCategorySystems() { + // ToDo + return "org/libreccm/ui/admin/categories/categorysystems.xhtml"; + } + + @GET + @Path("/categorysystems/{categorySystemIdentifier}/details") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getCategorySystem( + @PathParam("categorySystemIdentifier") + final String categorySystemIdentifier + ) { + // ToDo + return "org/libreccm/ui/admin/categories/categorysystem-details.xhtml"; + } + + @GET + @Path("/categorysystems/new") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String newCategorySystem( + ) { + // ToDo + return "org/libreccm/ui/admin/categories/categorysystem-form.xhtml"; + } + + @GET + @Path("/categorysystems/{categorySystemIdentifier}/edit") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String editCategorySystem( + @PathParam("categorySystemIdentifier") + final String categorySystemIdentifier + ) { + // ToDo + return "org/libreccm/ui/admin/categories/categorysystem-form.xhtml"; + } + + @POST + @Path("/categorysystems/{categorySystemIdentifier}/delete") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String deleteCategorySystem( + @PathParam("categorySystemIdentifier") + final String categorySystemIdentifier + ) { + // ToDo + return "redirect:categorymanager/categorysystems"; + } + + @POST + @Path("/categorysystems/{categorySystemIdentifier}/owners/add") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String addOwner( + @PathParam("categorySystemIdentifier") + final String categorySystemIdentifier + ) { + // ToDo + return String.format( + "redirect:categorymanager/categorysystems/%s", + categorySystemIdentifier + ); + } + + @POST + @Path("/categorysystems/{categorySystemIdentifier}/owners/remove") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String removeOwner( + @PathParam("categorySystemIdentifier") + final String categorySystemIdentifier + ) { + // ToDo + return String.format( + "redirect:categorymanager/categorysystems/%s", + categorySystemIdentifier + ); + } + +}