From 7ba904f3f123ec959b3324f9cd6272016eacb849 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 14 Jan 2021 20:14:52 +0100 Subject: [PATCH] Fixed remaining links in @admin Former-commit-id: 573af19c5f4d8c1ed84ad81705f8b8fa251e00da --- .../ContentSectionApplicationController.java | 5 ++++ .../applications/ApplicationController.java | 2 ++ .../applications/ApplicationsController.java | 29 ++++++++++++++----- .../DefaultApplicationController.java | 5 ++++ .../categories/CategoriesController.java | 8 ++--- .../categories/CategorySystemsController.java | 14 ++++----- .../libreccm/localizedStringEditor.xhtml | 12 ++++---- .../admin/applications/applicationtypes.xhtml | 2 +- .../admin/categories/category-details.xhtml | 10 +++---- .../categories/categorysystem-details.xhtml | 12 ++++---- .../libreccm/ui/admin/imexport/export.xhtml | 6 ++-- .../libreccm/ui/admin/imexport/imexport.xhtml | 21 ++++---------- .../libreccm/ui/admin/imexport/import.xhtml | 6 ++-- .../ShortcutsApplicationController.java | 5 ++++ .../applications/shortcuts/shortcuts.xhtml | 10 ++++--- 15 files changed, 85 insertions(+), 62 deletions(-) diff --git a/ccm-cms/src/main/java/org/libreccm/ui/admin/contentsections/ContentSectionApplicationController.java b/ccm-cms/src/main/java/org/libreccm/ui/admin/contentsections/ContentSectionApplicationController.java index 5cc918e27..0a021aa06 100644 --- a/ccm-cms/src/main/java/org/libreccm/ui/admin/contentsections/ContentSectionApplicationController.java +++ b/ccm-cms/src/main/java/org/libreccm/ui/admin/contentsections/ContentSectionApplicationController.java @@ -47,6 +47,11 @@ public class ContentSectionApplicationController @Inject private ContentSectionRepository sectionRepository; + @Override + public String getControllerLink() { + return "applications/content-sections"; + } + @GET @Path("/") @AuthorizationRequired diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java index 3a7cacf61..32deae496 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java @@ -28,4 +28,6 @@ public interface ApplicationController { String getApplication(); + String getControllerLink(); + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java index 4c62faf24..5472ad660 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java @@ -32,6 +32,8 @@ import java.util.Map; import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Any; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import javax.mvc.Controller; import javax.mvc.Models; @@ -49,6 +51,10 @@ import javax.ws.rs.Path; @Path("/applications") public class ApplicationsController { + @Inject + @Any + private Instance applicationControllers; + @Inject private ApplicationManager appManager; @@ -115,17 +121,24 @@ public class ApplicationsController { final Class controllerClass = applicationType.applicationController(); - if (!DefaultApplicationController.class.isAssignableFrom( - controllerClass - )) { - item.setControllerLink( - String.format( - "%s#getApplication", - controllerClass.getSimpleName()) - ); + final Instance controllerInstance + = applicationControllers.select(controllerClass); + + if (hasControllerLink(controllerClass, controllerInstance)) { + final ApplicationController controller = controllerInstance.get(); + item.setControllerLink(controller.getControllerLink()); } return item; } + private boolean hasControllerLink( + final Class controllerClass, + final Instance controllerInstance + ) { + return !DefaultApplicationController.class + .isAssignableFrom(controllerClass) + && controllerInstance.isResolvable(); + } + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java index 56a11f0b3..c9e975d43 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java @@ -40,4 +40,9 @@ public class DefaultApplicationController implements ApplicationController { return ""; } + @Override + public String getControllerLink() { + return "application"; + } + } 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/CategoriesController.java index 1c948edbe..6d241ec09 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/CategoriesController.java @@ -448,7 +448,7 @@ public class CategoriesController { * @return Redirect to the details page of the category. */ @POST - @Path("/{identifier}/title/{locale}/edit") + @Path("/{identifier}/title/edit/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String editTitle( @@ -505,7 +505,7 @@ public class CategoriesController { * @return Redirect to the details page of the category. */ @POST - @Path("/{identifier}/title/{locale}/remove") + @Path("/{identifier}/title/remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String removeTitle( @@ -621,7 +621,7 @@ public class CategoriesController { * @return Redirect to the details page of the category. */ @POST - @Path("/{identifier}/description/{locale}/edit") + @Path("/{identifier}/description/edit/{locale}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) @@ -679,7 +679,7 @@ public class CategoriesController { * @return Redirect to the details page of the category. */ @POST - @Path("/{identifier}/description/{locale}/remove") + @Path("/{identifier}/description/remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String removeDescription( 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 index b70335f61..6e3f6ff7a 100644 --- 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 @@ -354,7 +354,7 @@ public class CategorySystemsController { * @return Redirect to the details page of the category system. */ @POST - @Path("/{identifier}/title/${locale}/edit") + @Path("/{identifier}/title/edit/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String editTitle( @@ -414,18 +414,18 @@ public class CategorySystemsController { * * @param categorySystemIdentifier Identifier of the category system. * @param localeParam The locale of the title. + * @param confirmed Has the deletion been confirmed? * * @return Redirect to the details page of the category system. */ @POST - @Path("/{identifier}/title/${locale}/remove") + @Path("/{identifier}/title/remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String removeTitle( @PathParam("identifier") final String categorySystemIdentifier, @PathParam("locale") final String localeParam, - @FormParam("confirmed") - final String confirmed + @FormParam("confirmed") final String confirmed ) { final Identifier identifier = identifierParser.parseIdentifier( @@ -553,7 +553,7 @@ public class CategorySystemsController { */ @POST @Path( - "categorysystems/{identifier}/description/${locale}/edit" + "categorysystems/{identifier}/description/edit/{locale}" ) @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) @@ -619,7 +619,7 @@ public class CategorySystemsController { */ @POST @Path( - "categorysystems/{identifier}/description/${locale}/remove") + "categorysystems/{identifier}/description/remove/{locale}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String removeDescription( @@ -770,7 +770,7 @@ public class CategorySystemsController { * * @param categorySystemIdentifier Identifier of teh category system. * @param applicationUuid UUID of the owner to remove. - * @param confirmed Was the deletion confirmed by the user? + * @param confirmed Was the deletion confirmed by the user? * * @return Redirect to the details page of the category system. */ diff --git a/ccm-core/src/main/resources/META-INF/resources/components/libreccm/localizedStringEditor.xhtml b/ccm-core/src/main/resources/META-INF/resources/components/libreccm/localizedStringEditor.xhtml index f68a2c444..1eae7d77b 100644 --- a/ccm-core/src/main/resources/META-INF/resources/components/libreccm/localizedStringEditor.xhtml +++ b/ccm-core/src/main/resources/META-INF/resources/components/libreccm/localizedStringEditor.xhtml @@ -6,7 +6,7 @@