From 0cb2214dd218737f2c27e19b380ca19a9cad8a3e Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 16 Sep 2020 21:23:44 +0200 Subject: [PATCH 01/93] Basic structure for new admin app --- ccm-bundle-devel-wildfly/faces-config.NavData | 0 ccm-bundle-devel-wildfly/pom.xml | 2 +- .../src/main/webapp/WEB-INF/faces-config.xml | 2 +- .../src/main/webapp/WEB-INF/web.xml | 6 +- .../libreccm/ui/admin/AdminApplication.java | 55 +++++++++++++ .../org/libreccm/ui/admin/AdminConstants.java | 34 ++++++++ .../java/org/libreccm/ui/admin/AdminPage.java | 72 +++++++++++++++++ .../SystemInformationController.java | 41 ++++++++++ .../SystemInformationModel.java | 79 +++++++++++++++++++ .../SystemInformationPage.java | 68 ++++++++++++++++ .../libreccm/ui/admin/systeminformation.xhtml | 21 +++++ .../org/libreccm/ui/AdminBundle.properties | 2 + .../org/libreccm/ui/AdminBundle_de.properties | 2 + 13 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 ccm-bundle-devel-wildfly/faces-config.NavData create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminApplication.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminConstants.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml create mode 100644 ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties create mode 100644 ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties diff --git a/ccm-bundle-devel-wildfly/faces-config.NavData b/ccm-bundle-devel-wildfly/faces-config.NavData new file mode 100644 index 000000000..e69de29bb diff --git a/ccm-bundle-devel-wildfly/pom.xml b/ccm-bundle-devel-wildfly/pom.xml index fe0fefee9..e936bc880 100644 --- a/ccm-bundle-devel-wildfly/pom.xml +++ b/ccm-bundle-devel-wildfly/pom.xml @@ -213,7 +213,7 @@ ccm-core jar - views/ + WEB-INF/ diff --git a/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/faces-config.xml b/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/faces-config.xml index a1999da81..16605090f 100644 --- a/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/faces-config.xml +++ b/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/faces-config.xml @@ -5,6 +5,6 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> - org.libreccm.ui.CcmFaceletsResourceHandler + org.libreccm.mvc.facelets.CcmViewResourceHandler diff --git a/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/web.xml b/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/web.xml index 8ee4f3591..a42350b9f 100644 --- a/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/web.xml +++ b/ccm-bundle-devel-wildfly/src/main/webapp/WEB-INF/web.xml @@ -15,6 +15,10 @@ ccm.distribution libreccm + + resteasy.resources + org.jboss.resteasy.plugins.stats.RegistryStatsResource + @@ -66,7 +70,7 @@ true - - + LibreCCM Core - + Lesser GPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1 - + org.seleniumhq.selenium @@ -59,13 +60,13 @@ hibernate-core provided - + org.hibernate hibernate-envers provided - + org.hibernate.validator hibernate-validator @@ -84,13 +85,13 @@ org.glassfish javax.el - + org.hibernate hibernate-search-orm provided - + javax.xml.bind jaxb-api @@ -101,7 +102,7 @@ jaxb-runtime provided - + javax.mvc javax.mvc-api @@ -111,12 +112,12 @@ krazo-core provided - + org.eclipse.krazo.ext krazo-freemarker provided - + @@ -124,7 +125,7 @@ org.flywaydb flyway-core - + org.apache.logging.log4j @@ -134,7 +135,7 @@ org.apache.logging.log4j log4j-api - + commons-beanutils commons-beanutils @@ -151,7 +152,7 @@ commons-lang commons-lang - + oro oro @@ -160,18 +161,18 @@ org.bouncycastle bcprov-jdk16 - + net.sf.jtidy jtidy - + junit junit test - + org.hamcrest hamcrest-core @@ -182,20 +183,20 @@ hamcrest-library test - + org.libreccm ccm-testutils ${project.parent.version} test - + nl.jqno.equalsverifier equalsverifier test - + org.jboss.arquillian.junit arquillian-junit-container @@ -211,12 +212,12 @@ shrinkwrap-resolver-impl-maven test - + org.apache.maven maven-artifact - + org.apache.shiro shiro-core @@ -225,7 +226,7 @@ org.apache.shiro shiro-web - + io.jsonwebtoken jjwt-api @@ -238,33 +239,33 @@ io.jsonwebtoken jjwt-jackson - + com.h2database h2 test - + org.reflections reflections - + - + org.freemarker freemarker - + net.sf.saxon Saxon-HE - + @@ -283,17 +284,17 @@ com.fasterxml.jackson.datatype jackson-datatype-jdk8 - + com.fasterxml.jackson.dataformat jackson-dataformat-xml - + com.fasterxml.jackson.dataformat jackson-dataformat-csv - + ccm-core - + src/main/resources true + + ./target/generated-resources + - + src/test/resources @@ -317,7 +321,7 @@ ${project.build.directory}/generated-resources - + org.apache.maven.plugins @@ -330,6 +334,39 @@ ${project.build.sourceEncoding} + + com.github.eirslett + frontend-maven-plugin + + ../node + + + + Install node.js and NPM + + install-node-and-npm + + + v12.18.3 + + + + npm install + + npm + + + + build + + npm + + + run build + + + + org.apache.maven.plugins maven-surefire-plugin @@ -394,7 +431,7 @@ - + @@ -443,7 +480,7 @@ spotbugs-exclude.xml - + org.apache.maven.plugins maven-pmd-plugin @@ -585,7 +622,7 @@ - + - + run-its-with-wildfly-h2mem @@ -795,7 +832,7 @@ Saxon-HE - + @@ -808,7 +845,7 @@ ${project.build.directory}/generated-resources - + de.jpdigital @@ -906,7 +943,7 @@ - + @@ -924,7 +961,7 @@ - + run-its-with-wildfly-pgsql @@ -943,7 +980,7 @@ provided - + @@ -956,7 +993,7 @@ ${project.build.directory}/generated-resources - + de.jpdigital @@ -1085,7 +1122,7 @@ - + @@ -1103,7 +1140,7 @@ - + run-its-in-remote-wildfly-h2mem @@ -1117,7 +1154,7 @@ Saxon-HE - + @@ -1130,7 +1167,7 @@ ${project.build.directory}/generated-resources - + de.jpdigital @@ -1178,7 +1215,7 @@ - + @@ -1196,7 +1233,7 @@ - + run-its-in-remote-wildfly-pgsql @@ -1210,7 +1247,7 @@ Saxon-HE - + @@ -1223,7 +1260,7 @@ ${project.build.directory}/generated-resources - + de.jpdigital @@ -1271,7 +1308,7 @@ - + @@ -1289,7 +1326,7 @@ - + - + diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml index b13f9f854..5de79a01c 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml @@ -4,6 +4,8 @@ xmlns:h="http://xmlns.jcp.org/jsf/html"> System Information +

System Information

@@ -11,11 +13,12 @@
-
-
#{prop.key}
-
#{prop.value}
-
+
+
#{prop.key}
+
#{prop.value}
+
+
diff --git a/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss new file mode 100644 index 000000000..a35964e3e --- /dev/null +++ b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss @@ -0,0 +1 @@ +@import "../../../../node_modules/bootstrap/scss/bootstrap"; \ No newline at end of file diff --git a/ccm-core/src/main/typescript/ccm-admin/ccm-admin.ts b/ccm-core/src/main/typescript/ccm-admin/ccm-admin.ts new file mode 100644 index 000000000..6fcacc09f --- /dev/null +++ b/ccm-core/src/main/typescript/ccm-admin/ccm-admin.ts @@ -0,0 +1 @@ +import "bootstrap"; \ No newline at end of file From ee1bc074252468bd4def20303b19b65b061d4f1d Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 19 Sep 2020 17:41:00 +0200 Subject: [PATCH 03/93] Filter for JAX-RS / EE MVC applications for redirecting unauthenticated users to the login application --- .../libreccm/ui/IsAuthenticatedFilter.java | 69 +++++++++++++++++++ .../libreccm/ui/admin/AdminApplication.java | 21 ++++-- .../SystemInformationController.java | 6 ++ 3 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/IsAuthenticatedFilter.java diff --git a/ccm-core/src/main/java/org/libreccm/ui/IsAuthenticatedFilter.java b/ccm-core/src/main/java/org/libreccm/ui/IsAuthenticatedFilter.java new file mode 100644 index 000000000..037a26ed8 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/IsAuthenticatedFilter.java @@ -0,0 +1,69 @@ +/* + * 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; + +import org.libreccm.security.Shiro; + +import java.io.IOException; +import java.net.URI; + +import javax.inject.Inject; +import javax.servlet.ServletContext; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerRequestFilter; +import javax.ws.rs.container.PreMatching; +import javax.ws.rs.core.Response; + +/** + * + * @author Jens Pelzetter + */ +@PreMatching +public class IsAuthenticatedFilter implements ContainerRequestFilter { + + @Inject + private ServletContext servletContext; + + @Inject + private Shiro shiro; + + @Override + public void filter(final ContainerRequestContext requestContext) + throws IOException { + if (!shiro.getSubject().isAuthenticated()) { + final String contextPath = servletContext.getContextPath(); + final String returnUrl = requestContext + .getUriInfo() + .getRequestUri() + .getPath(); + requestContext.abortWith( + Response.temporaryRedirect( + URI.create( + String.format( + "/%s/ccm/register?return_url=%s", + contextPath, + returnUrl + ) + ) + ).build() + ); + } + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminApplication.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminApplication.java index d9dcc457e..c8bc90169 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminApplication.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminApplication.java @@ -18,8 +18,9 @@ */ package org.libreccm.ui.admin; +import org.libreccm.ui.IsAuthenticatedFilter; - +import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -40,11 +41,19 @@ public class AdminApplication extends Application { @Override public Set> getClasses() { - return adminPages - .stream() - .map(AdminPage::getControllerClasses) - .flatMap(controllers -> controllers.stream()) - .collect(Collectors.toSet()); + final Set> classes = new HashSet<>(); + + classes.add(IsAuthenticatedFilter.class); + + classes.addAll( + adminPages + .stream() + .map(AdminPage::getControllerClasses) + .flatMap(controllers -> controllers.stream()) + .collect(Collectors.toSet()) + ); + + return classes; // final Set> classes = new HashSet<>(); // classes.add(SystemInformationController.class); diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationController.java index 98fd2acd6..bbc38465e 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationController.java @@ -18,6 +18,10 @@ */ package org.libreccm.ui.admin.systeminformation; +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; @@ -34,6 +38,8 @@ public class SystemInformationController { @GET @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) public String getSystemInformation() { return "org/libreccm/ui/admin/systeminformation.xhtml"; } From 26b7b31d940d79459aecdbfc961e1fe8ebad169f Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 20 Sep 2020 13:18:59 +0200 Subject: [PATCH 04/93] Base template for ccm-admin --- ccm-core/package-lock.json | 5 ++ ccm-core/package.json | 1 + .../java/org/libreccm/ui/admin/AdminPage.java | 22 ++++- .../org/libreccm/ui/admin/AdminPageModel.java | 67 ++++++++++++++++ .../libreccm/ui/admin/AdminPagesModel.java | 80 +++++++++++++++++++ .../SystemInformationModel.java | 2 - .../SystemInformationPage.java | 10 +++ .../org/libreccm/ui/admin/ccm-admin.xhtml | 64 +++++++++++++++ .../libreccm/ui/admin/systeminformation.xhtml | 40 +++++----- .../assets/bootstrap/bootstrap-icons.svg | 1 + ccm-core/src/main/scss/ccm-admin/_custom.scss | 60 ++++++++++++++ .../src/main/scss/ccm-admin/ccm-admin.scss | 1 + 12 files changed, 329 insertions(+), 24 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml create mode 100644 ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg create mode 100644 ccm-core/src/main/scss/ccm-admin/_custom.scss diff --git a/ccm-core/package-lock.json b/ccm-core/package-lock.json index 6106947ac..140618336 100644 --- a/ccm-core/package-lock.json +++ b/ccm-core/package-lock.json @@ -1571,6 +1571,11 @@ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.5.2.tgz", "integrity": "sha512-vlGn0bcySYl/iV+BGA544JkkZP5LB3jsmkeKLFQakCOwCM3AOk7VkldBz4jrzSe+Z0Ezn99NVXa1o45cQY4R6A==" }, + "bootstrap-icons": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.0.0.tgz", + "integrity": "sha512-PaQm3VtSqbUnWuyqGmFJG5iF9UMieDuk8raPOmKOtKeyWyiVshgLoKa+9EWGolGU/nvyBLEBWhZoQqhu9ccNBg==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", diff --git a/ccm-core/package.json b/ccm-core/package.json index 4f5daf16a..7f8459185 100644 --- a/ccm-core/package.json +++ b/ccm-core/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "bootstrap": "^4.5.2", + "bootstrap-icons": "^1.0.0", "jquery": "^3.5.1", "popper.js": "^1.16.1" } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java index 3aba8dbd8..27e1ab4b4 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java @@ -18,6 +18,7 @@ */ package org.libreccm.ui.admin; +import java.util.ResourceBundle; import java.util.Set; /** @@ -33,6 +34,16 @@ public interface AdminPage { */ Set> getControllerClasses(); + /** + * The entry point for the admin module. Used to generate the URL for an + * admin page in the navigation etc. For example, with the return value will + * {@code systeminformation} the generated link is + * {@code #{contextPath}/@admin/#{path}}. + * + * @return The path fragment of the entry point of the admin page/module. + */ + String getPath(); + /** * Gets the resourcebundle which provides the label of the admin page. * @@ -63,8 +74,15 @@ public interface AdminPage { String getDescriptionKey(); /** - * Gets the position of the page in the admin nav bar. - * + * Name of icon to use. + * + * @return The icon to use for the page. + */ + String getIcon(); + + /** + * Gets the position of the page in the admin nav bar. + * * @return The position of the page in the admin navigation. */ int getPosition(); diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java new file mode 100644 index 000000000..706fa3342 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java @@ -0,0 +1,67 @@ +/* + * 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; + +/** + * + * @author Jens Pelzetter + */ +public class AdminPageModel { + + private String path; + + private String label; + + private String description; + + private String icon; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java new file mode 100644 index 000000000..0335d7b32 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java @@ -0,0 +1,80 @@ +/* + * 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; + +import org.libreccm.l10n.GlobalizationHelper; + +import java.util.List; +import java.util.ResourceBundle; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Instance; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("AdminPagesModel") +public class AdminPagesModel { + + @Inject + private Instance adminPages; + + @Inject + private GlobalizationHelper globalizationHelper; + + public List getAdminPages() { + return adminPages + .stream() + .sorted( + (page1, page2) -> Integer.compare( + page1.getPosition(), page2.getPosition() + ) + ) + .map(this::buildAdminPageModel) + .collect(Collectors.toList()); + } + + private AdminPageModel buildAdminPageModel(final AdminPage fromAdminPage) { + final ResourceBundle labelBundle = ResourceBundle.getBundle( + fromAdminPage.getLabelBundle(), + globalizationHelper.getNegotiatedLocale() + ); + final ResourceBundle descriptionBundle = ResourceBundle.getBundle( + fromAdminPage.getDescriptionBundle(), + globalizationHelper.getNegotiatedLocale() + ); + + final AdminPageModel model = new AdminPageModel(); + model.setPath(fromAdminPage.getPath()); + model.setLabel(labelBundle.getString(fromAdminPage.getLabelKey())); + model.setDescription( + descriptionBundle.getString( + fromAdminPage.getDescriptionKey() + ) + ); + model.setIcon(fromAdminPage.getIcon()); + return model; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java index 4151afdcc..99b0b3b58 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java @@ -18,7 +18,6 @@ */ package org.libreccm.ui.admin.systeminformation; -import com.arsdigita.util.SystemInformation; import com.arsdigita.util.UncheckedWrapperException; import java.io.IOException; @@ -26,7 +25,6 @@ import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; import javax.inject.Named; diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java index 130bbab34..1b8144474 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java @@ -40,6 +40,11 @@ public class SystemInformationPage implements AdminPage { return classes; } + @Override + public String getPath() { + return "systeminformation"; + } + @Override public String getLabelBundle() { return AdminConstants.ADMIN_BUNDLE; @@ -60,6 +65,11 @@ public class SystemInformationPage implements AdminPage { return "systeminformation.description"; } + @Override + public String getIcon() { + return "info-circle-fill"; + } + @Override public int getPosition() { return 80; diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml new file mode 100644 index 000000000..233030774 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml @@ -0,0 +1,64 @@ + + + + #{title} - LibreCCM Admin + + + +
+ +
+
+ +
+ + + diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml index 5de79a01c..eb0301220 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml @@ -1,24 +1,24 @@ - - System Information - - - -

System Information

-

LibreCCM System Information

-
- -
-
#{prop.key}
-
#{prop.value}
-
-
-
- -
+ xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + + + +
+

System Information

+

LibreCCM System Information

+
+ +
+
#{prop.key}
+
#{prop.value}
+
+
+
+
+
+
diff --git a/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg b/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg new file mode 100644 index 000000000..f7731a14b --- /dev/null +++ b/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ccm-core/src/main/scss/ccm-admin/_custom.scss b/ccm-core/src/main/scss/ccm-admin/_custom.scss new file mode 100644 index 000000000..ba3e0c8f6 --- /dev/null +++ b/ccm-core/src/main/scss/ccm-admin/_custom.scss @@ -0,0 +1,60 @@ + +$grid-breakpoints: ( + xs: 0, + sm: 36rem, + md: 48rem, + lg: 62rem, + xl: 75rem +); + +$container-max-widths: ( + sm: 33.75rem, + md: 45rem, + lg: 60rem, + xl: 71.25rem +); + +$grid-gutter-width: 1.875rem; + +$form-grid-gutter-width: 0.625rem; + +$tooltip-max-width: 12.5rem; + +$popover-maxwidth: 17.25rem; + +$toast-max-width: 21.875rem; + +$modal-xl: 71.25rem; +$modal-lg: 50rem; +$modal-md: 31.25rem; +$modal-sm: 18.75rem; + +$modal-fade-transform: translate(0, -3.125rem); + +$carousel-indicator-width: 1.875rem; +$carousel-control-icon-width: 1.25rem; + +$pre-scrollable-max-height: 21.25rem; + +// Navbar default colors have insufficient contrast +$navbar-dark-color: #fff; + +table.users-table, +table.groups-table, +table.roles-table { + tbody { + td.action-col { + width: 8em; + } + } +} + +table.group-members, +table.group-roles, +table.role-members { + tbody { + td.action-col { + width: 8em; + } + } +} diff --git a/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss index a35964e3e..4c04ef71d 100644 --- a/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss +++ b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss @@ -1 +1,2 @@ +@import "custom"; @import "../../../../node_modules/bootstrap/scss/bootstrap"; \ No newline at end of file From 28e205a89ee76c681228b7468f00dfe7bfb527d7 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Mon, 21 Sep 2020 21:15:18 +0200 Subject: [PATCH 05/93] Placeholder pages for admin --- ccm-bundle-devel-wildfly/faces-config.NavData | 6 ++ .../applications/ApplicationsController.java | 46 ++++++++++ .../admin/applications/ApplicationsPage.java | 78 ++++++++++++++++ .../categories/CategoriesController.java | 46 ++++++++++ .../ui/admin/categories/CategoriesPage.java | 78 ++++++++++++++++ .../ConfigurationController.java | 46 ++++++++++ .../configuration/ConfigurationPage.java | 77 ++++++++++++++++ .../admin/dashboard/DashboardController.java | 46 ++++++++++ .../ui/admin/dashboard/DashboardPage.java | 76 ++++++++++++++++ .../ui/admin/imexport/ImExportController.java | 46 ++++++++++ .../ui/admin/imexport/ImExportPage.java | 78 ++++++++++++++++ .../ui/admin/sites/SitesController.java | 46 ++++++++++ .../libreccm/ui/admin/sites/SitesPage.java | 76 ++++++++++++++++ .../SystemInformationPage.java | 2 +- .../UsersGroupsRolesController.java | 46 ++++++++++ .../UsersGroupsRolesPage.java | 78 ++++++++++++++++ .../org/libreccm/ui/admin/applications.xhtml | 16 ++++ .../org/libreccm/ui/admin/categories.xhtml | 16 ++++ .../org/libreccm/ui/admin/ccm-admin.xhtml | 13 +-- .../org/libreccm/ui/admin/configuration.xhtml | 16 ++++ .../org/libreccm/ui/admin/dashboard.xhtml | 16 ++++ .../org/libreccm/ui/admin/imexport.xhtml | 16 ++++ .../views/org/libreccm/ui/admin/sites.xhtml | 16 ++++ .../libreccm/ui/admin/systeminformation.xhtml | 89 ++++++++++++++++--- .../ui/admin/users-groups-roles.xhtml | 16 ++++ .../org/libreccm/ui/AdminBundle.properties | 14 +++ .../org/libreccm/ui/AdminBundle_de.properties | 14 +++ 27 files changed, 1090 insertions(+), 23 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/applications.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/configuration.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/dashboard.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/imexport.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/sites.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml diff --git a/ccm-bundle-devel-wildfly/faces-config.NavData b/ccm-bundle-devel-wildfly/faces-config.NavData index e69de29bb..298bfc50a 100644 --- a/ccm-bundle-devel-wildfly/faces-config.NavData +++ b/ccm-bundle-devel-wildfly/faces-config.NavData @@ -0,0 +1,6 @@ + + + + + + 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 new file mode 100644 index 000000000..5245c612a --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsController.java @@ -0,0 +1,46 @@ +/* + * 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.applications; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/applications") +public class ApplicationsController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/applications.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java new file mode 100644 index 000000000..57b5da792 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java @@ -0,0 +1,78 @@ +/* + * 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.applications; + +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class ApplicationsPage implements AdminPage { + + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(ApplicationsController.class); + return classes; + } + + @Override + public String getPath() { + return "applications"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "applications.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "applications.description"; + } + + @Override + public String getIcon() { + return "journals"; + } + + @Override + public int getPosition() { + return 10; + } + +} 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 new file mode 100644 index 000000000..e15766460 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesController.java @@ -0,0 +1,46 @@ +/* + * 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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/categories") +public class CategoriesController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/categories.xhtml"; + } +} 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 new file mode 100644 index 000000000..666ac70e7 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoriesPage.java @@ -0,0 +1,78 @@ +/* + * 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.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class CategoriesPage implements AdminPage { + + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(CategoriesController.class); + return classes; + } + + @Override + public String getPath() { + return "categories"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "categories.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "categories.description"; + } + + @Override + public String getIcon() { + return "diagram-3-fill"; + } + + @Override + public int getPosition() { + return 20; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java new file mode 100644 index 000000000..1e36e66c6 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java @@ -0,0 +1,46 @@ +/* + * 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.configuration; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/configuration") +public class ConfigurationController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/configuration.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java new file mode 100644 index 000000000..463c136e6 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java @@ -0,0 +1,77 @@ +/* + * 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.configuration; + +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; +import org.libreccm.ui.admin.categories.CategoriesController; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class ConfigurationPage implements AdminPage { + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(ConfigurationController.class); + return classes; + } + + @Override + public String getPath() { + return "configuration"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "configuration.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "configuration.description"; + } + + @Override + public String getIcon() { + return "gear-fill"; + } + + @Override + public int getPosition() { + return 30; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java new file mode 100644 index 000000000..a3b72590b --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java @@ -0,0 +1,46 @@ +/* + * 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.dashboard; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/") +public class DashboardController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/dashboard.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java new file mode 100644 index 000000000..5620d3dd1 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java @@ -0,0 +1,76 @@ +/* + * 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.dashboard; + +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class DashboardPage implements AdminPage { + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(DashboardController.class); + return classes; + } + + @Override + public String getPath() { + return "/"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "dashboard.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "dashboard.description"; + } + + @Override + public String getIcon() { + return "house-fill"; + } + + @Override + public int getPosition() { + return 0; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java new file mode 100644 index 000000000..9e2dfef7b --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java @@ -0,0 +1,46 @@ +/* + * 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.imexport; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/imexport") +public class ImExportController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/imexport.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java new file mode 100644 index 000000000..d97224905 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java @@ -0,0 +1,78 @@ +/* + * 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.imexport; + +import org.libreccm.ui.admin.configuration.*; +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; +import org.libreccm.ui.admin.categories.CategoriesController; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class ImExportPage implements AdminPage { + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(ImExportController.class); + return classes; + } + + @Override + public String getPath() { + return "imexport"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "imexport.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "imexport.description"; + } + + @Override + public String getIcon() { + return "arrow-left-right"; + } + + @Override + public int getPosition() { + return 40; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java new file mode 100644 index 000000000..817821f05 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java @@ -0,0 +1,46 @@ +/* + * 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.sites; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/sites") +public class SitesController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/sites.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java new file mode 100644 index 000000000..3b80c3df7 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java @@ -0,0 +1,76 @@ +/* + * 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.sites; + +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class SitesPage implements AdminPage { + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(SitesController.class); + return classes; + } + + @Override + public String getPath() { + return "sites"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "sites.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "sites.description"; + } + + @Override + public String getIcon() { + return "bookshelf"; + } + + @Override + public int getPosition() { + return 60; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java index 1b8144474..27af5ad63 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java @@ -72,7 +72,7 @@ public class SystemInformationPage implements AdminPage { @Override public int getPosition() { - return 80; + return 70; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java new file mode 100644 index 000000000..6cfe77e65 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java @@ -0,0 +1,46 @@ +/* + * 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.usersgroupsroles; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/users-groups-roles") +public class UsersGroupsRolesController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getPlaceholder() { + return "org/libreccm/ui/admin/users-groups-roles.xhtml"; + } +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java new file mode 100644 index 000000000..1800ba090 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java @@ -0,0 +1,78 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.ui.admin.configuration.*; +import org.libreccm.ui.admin.AdminConstants; +import org.libreccm.ui.admin.AdminPage; +import org.libreccm.ui.admin.categories.CategoriesController; + +import java.util.HashSet; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; + +/** + * + * @author Jens Pelzetter + */ +@ApplicationScoped +public class UsersGroupsRolesPage implements AdminPage { + @Override + public Set> getControllerClasses() { + final Set> classes = new HashSet<>(); + classes.add(UsersGroupsRolesController.class); + return classes; + } + + @Override + public String getPath() { + return "users-groups-roles"; + } + + @Override + public String getLabelBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getLabelKey() { + return "usersgroupsroles.label"; + } + + @Override + public String getDescriptionBundle() { + return AdminConstants.ADMIN_BUNDLE; + } + + @Override + public String getDescriptionKey() { + return "usersgroupsroles.description"; + } + + @Override + public String getIcon() { + return "people-fill"; + } + + @Override + public int getPosition() { + return 80; + } +} diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/applications.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/applications.xhtml new file mode 100644 index 000000000..367fdcefb --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/applications.xhtml @@ -0,0 +1,16 @@ + + + + + + +
+

Applications

+

Placeholder

+
+
+
+ diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories.xhtml new file mode 100644 index 000000000..b7a561028 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories.xhtml @@ -0,0 +1,16 @@ + + + + + + +
+

Categories

+

Placeholder

+
+
+
+ diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml index 233030774..ec030cdf1 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml @@ -27,20 +27,9 @@ +
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/configuration.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/configuration.xhtml index e96b95e44..2b3f210b2 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/configuration.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/configuration.xhtml @@ -4,13 +4,22 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + + +
-

Configuration

+

#{AdminMessages['configuration.label']}

Placeholder

+
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/dashboard.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/dashboard.xhtml index b1d4b38ef..a77b8a7b7 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/dashboard.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/dashboard.xhtml @@ -4,13 +4,19 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + +
-

LibreCCM Admin Dashboard

+

#{AdminMessages['dashboard.label']}

Placeholder

+
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/imexport.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/imexport.xhtml index 76b0e2744..0910af948 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/imexport.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/imexport.xhtml @@ -4,13 +4,22 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + + +
-

Import/Export

+

#{AdminMessages['imexport.label']}

Placeholder

+
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/sites.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/sites.xhtml index 8747255cc..9ed2f5fc9 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/sites.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/sites.xhtml @@ -4,13 +4,23 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + + + +
-

Sites

+

#{AdminMessages['sites.label']}

Placeholder

+
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml index 1135e06c9..e4fd53b3d 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml @@ -4,11 +4,21 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + + +
-

System Information

+

#{AdminMessages['systeminformation.label']}

@@ -42,7 +52,7 @@ role="tabpanel" aria-labelled="LibreCCM System Information Tab" > -

LibreCCM System Information

+

AdminMessages['systeminformation.tabs.libreccm.label']

@@ -58,7 +68,7 @@ role="tabpanel" aria-labelled="Java System Properties Tab" > -

Java System Properties

+

#{AdminMessages['systeminformation.tabs.java.label']}

@@ -70,23 +80,6 @@
-
diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml index 984c6243a..426afd3b2 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml @@ -4,13 +4,22 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + - + + + + + +
-

Users/Groups/Roles

+

#{AdminMessages['usersgroupsroles.label']}

Placeholder

+
diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties index 3242d3205..8edd74f1b 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties @@ -14,3 +14,6 @@ sites.label=Sites sites.description=Manage sites usersgroupsroles.label=Users/Groups/Roles usersgroupsroles.description=Manage users, groups and roles +systeminformation.tabs.libreccm.label=LibreCCM System Information +systeminformation.tabs.java.label=Java System Properties +breadcrumbs.start=LibreCCM Admin diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties index 1ffeb074a..7f68a543e 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties @@ -5,7 +5,7 @@ applications.description=Verwalten der Anwendungsinstanzen imexport.label=Import/Export categories.label=Kategorien categories.description=Verwaltung der Kategorien -configuration.label=Configuration +configuration.label=Konfguration configuration.description=Bearbeiten der Konfiguration dashboard.label=Dashboard dashboard.description=Provides access to all applications @@ -14,3 +14,6 @@ sites.label=Sites sites.description=Sites verwalten usersgroupsroles.label=Benutzer*innen/Gruppen/Rollen usersgroupsroles.description=Verwaltungen von Benutzer*innen, Gruppen und Rollen +systeminformation.tabs.libreccm.label=LibreCCM System Informationen +systeminformation.tabs.java.label=Java System Properties +breadcrumbs.start=LibreCCM Admin From 917849e62298ded7fd57d51d42898d2a4756b291 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 23 Sep 2020 20:41:00 +0200 Subject: [PATCH 07/93] Table of users --- .gitignore | 1 + .../libreccm/ui/admin/AdminPagesModel.java | 30 ++++- .../admin/usersgroupsroles/OverviewModel.java | 90 ++++++++++++++ .../UsersGroupsRolesController.java | 42 ++++++- .../usersgroupsroles/UsersTableModel.java | 66 +++++++++++ .../ui/admin/users-groups-roles.xhtml | 45 +++++-- .../ui/admin/users-groups-roles/groups.xhtml | 26 +++++ .../admin/users-groups-roles/overview.xhtml | 24 ++++ .../ui/admin/users-groups-roles/roles.xhtml | 26 +++++ .../ui/admin/users-groups-roles/users.xhtml | 110 ++++++++++++++++++ .../org/libreccm/ui/AdminBundle.properties | 21 ++++ .../org/libreccm/ui/AdminBundle_de.properties | 21 ++++ 12 files changed, 482 insertions(+), 20 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/OverviewModel.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersTableModel.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/groups.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/overview.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/roles.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/users.xhtml diff --git a/.gitignore b/.gitignore index 56e4e14b7..144b13113 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ target .settings .tscache *.vscode +/ccm-core/nbproject/ diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java index 0335d7b32..72f07e4df 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java @@ -20,7 +20,9 @@ package org.libreccm.ui.admin; import org.libreccm.l10n.GlobalizationHelper; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.ResourceBundle; import java.util.stream.Collectors; @@ -43,6 +45,11 @@ public class AdminPagesModel { @Inject private GlobalizationHelper globalizationHelper; + /** + * Cache for bundles + */ + private final Map bundles = new HashMap<>(); + public List getAdminPages() { return adminPages .stream() @@ -56,13 +63,11 @@ public class AdminPagesModel { } private AdminPageModel buildAdminPageModel(final AdminPage fromAdminPage) { - final ResourceBundle labelBundle = ResourceBundle.getBundle( - fromAdminPage.getLabelBundle(), - globalizationHelper.getNegotiatedLocale() + final ResourceBundle labelBundle = getBundle( + fromAdminPage.getLabelBundle() ); - final ResourceBundle descriptionBundle = ResourceBundle.getBundle( - fromAdminPage.getDescriptionBundle(), - globalizationHelper.getNegotiatedLocale() + final ResourceBundle descriptionBundle = getBundle( + fromAdminPage.getDescriptionBundle() ); final AdminPageModel model = new AdminPageModel(); @@ -77,4 +82,17 @@ public class AdminPagesModel { return model; } + private ResourceBundle getBundle(final String bundleName) { + if (bundles.containsKey(bundleName)) { + return bundles.get(bundleName); + } else { + final ResourceBundle bundle = ResourceBundle.getBundle( + bundleName, + globalizationHelper.getNegotiatedLocale() + ); + bundles.put(bundleName, bundle); + return bundle; + } + } + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/OverviewModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/OverviewModel.java new file mode 100644 index 000000000..52d958648 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/OverviewModel.java @@ -0,0 +1,90 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.core.CoreConstants; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.GroupRepository; +import org.libreccm.security.RequiresPrivilege; +import org.libreccm.security.RoleRepository; +import org.libreccm.security.UserRepository; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("UsersGroupsRolesOverviewModel") +public class OverviewModel { + + @Inject + private GroupRepository groupRepository; + + @Inject + private RoleRepository roleRepository; + + @Inject + private UserRepository userRepository; + + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional + public long getActiveUsersCount() { + return userRepository + .findAll() + .stream() + .filter(user -> !user.isBanned()) + .count(); + } + + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional + public long getDisabledUsersCount() { + return userRepository + .findAll() + .stream() + .filter(user -> user.isBanned()) + .count(); + } + + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional + public long getGroupsCount() { + return groupRepository + .findAll() + .size(); + } + + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional + public long getRolesCount() { + return roleRepository + .findAll() + .size(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java index 6cfe77e65..69dd1d61e 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java @@ -23,9 +23,14 @@ import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.RequiresPrivilege; import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.mvc.Controller; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.FormParam; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; /** * @@ -35,12 +40,43 @@ import javax.ws.rs.Path; @Controller @Path("/users-groups-roles") public class UsersGroupsRolesController { - + + @Inject + private UsersTableModel usersTableModel; + @GET @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { - return "org/libreccm/ui/admin/users-groups-roles.xhtml"; + public String getOverview() { + return "org/libreccm/ui/admin/users-groups-roles/overview.xhtml"; } + + @GET + @Path("/groups") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getGroups() { + return "org/libreccm/ui/admin/users-groups-roles/groups.xhtml"; + } + + @GET + @Path("/roles") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getRoles() { + return "org/libreccm/ui/admin/users-groups-roles/roles.xhtml"; + } + + @GET + @Path("/users") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getUsers( + @QueryParam("filterterm") @DefaultValue("") final String filterTerm + ) { + usersTableModel.setFilterTerm(filterTerm); + return "org/libreccm/ui/admin/users-groups-roles/users.xhtml"; + } + } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersTableModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersTableModel.java new file mode 100644 index 000000000..e6a0b9c82 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersTableModel.java @@ -0,0 +1,66 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.core.CoreConstants; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.RequiresPrivilege; +import org.libreccm.security.User; +import org.libreccm.security.UserRepository; + +import java.util.List; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("UsersTableModel") +public class UsersTableModel { + + @Inject + private UserRepository userRepository; + + private String filterTerm; + + public String getFilterTerm() { + return filterTerm; + } + + protected void setFilterTerm(final String filterTerm) { + this.filterTerm = filterTerm; + } + + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + @Transactional + public List getUsers() { + if (filterTerm == null || filterTerm.isEmpty()) { + return userRepository.findAllOrderdByUsername(); + } else { + return userRepository.filtered(filterTerm); + } + } + +} diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml index 426afd3b2..2ddb572ad 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles.xhtml @@ -5,19 +5,42 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - - - - - - + -
-

#{AdminMessages['usersgroupsroles.label']}

-

Placeholder

+ diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/groups.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/groups.xhtml new file mode 100644 index 000000000..8029a7ff7 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/groups.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + +

Groups placeholder

+
+
+ + diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/overview.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/overview.xhtml new file mode 100644 index 000000000..1a3df4cff --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/overview.xhtml @@ -0,0 +1,24 @@ + + + + + + + + + + + + +

#{UsersGroupsRolesOverviewModel.activeUsersCount} #{AdminMessages['usersgroupsroles.active_users_count.label']}

+

#{UsersGroupsRolesOverviewModel.disabledUsersCount} #{AdminMessages['usersgroupsroles.disabled_users_count.label']}

+

#{UsersGroupsRolesOverviewModel.groupsCount} #{AdminMessages['usersgroupsroles.groups_count.label']}

+

#{UsersGroupsRolesOverviewModel.rolesCount} #{AdminMessages['usersgroupsroles.roles_count.label']}

+
+
+ diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/roles.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/roles.xhtml new file mode 100644 index 000000000..26bdf61c6 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/roles.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + +

Roles placeholder

+
+
+ + diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/users.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/users.xhtml new file mode 100644 index 000000000..58222e0e4 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/users.xhtml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + +
+
+
+
+ + +
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
#{AdminMessages['usersgroupsroles.users.table.headers.username']}#{AdminMessages['usersgroupsroles.users.table.headers.givenname']}#{AdminMessages['usersgroupsroles.users.table.headers.familyname']}#{AdminMessages['usersgroupsroles.users.table.headers.email']}#{AdminMessages['usersgroupsroles.users.table.headers.disabled']}#{AdminMessages['usersgroupsroles.users.table.headers.actions']}
#{user.name}#{user.givenName}#{user.familyName} + #{user.primaryEmailAddress.address} + + #{user.banned ? AdminMessages['usersgroupsroles.users.table.headers.disabled.true'] : AdminMessages['usersgroupsroles.users.table.headers.disabled.false']} + + + + + + #{AdminMessages['usersgroupsroles.users.detailslink.label']} + + + + +
+
+
+ + diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties index 8edd74f1b..d7384ddd0 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties @@ -17,3 +17,24 @@ usersgroupsroles.description=Manage users, groups and roles systeminformation.tabs.libreccm.label=LibreCCM System Information systeminformation.tabs.java.label=Java System Properties breadcrumbs.start=LibreCCM Admin +usersgroupsroles.users.label=Users +usersgroupsroles.groups.label=Groups +usersgroupsroles.roles.label=Roles +usersgroupsroles.overview.label=Overview +usersgroupsroles.active_users_count.label=active users +usersgroupsroles.disabled_users_count.label=disabled users +usersgroupsroles.groups_count.label=groups +usersgroupsroles.roles_count.label=roles +usersgroupsroles.users.table.headers.username=User Name +usersgroupsroles.users.table.headers.givenname=Given Name +usersgroupsroles.users.table.headers.familyname=Family Name +usersgroupsroles.users.table.headers.email=Email +usersgroupsroles.users.table.headers.disabled=Disabled? +usersgroupsroles.users.table.headers.actions=Actions +usersgroupsroles.users.table.headers.disabled.true=Yes +usersgroupsroles.users.table.headers.disabled.false=No +usersgroupsroles.users.detailslink.label=Details +usersgroupsroles.users.disablebutton.label=Disable +usersgroupsroles.users.add=Add user +usersgroupsroles.users.filter.label=Filter users +usersgroupsroles.users.filter.submit=Submit diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties index 7f68a543e..f8baca984 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties @@ -17,3 +17,24 @@ usersgroupsroles.description=Verwaltungen von Benutzer*innen, Gruppen und Rollen systeminformation.tabs.libreccm.label=LibreCCM System Informationen systeminformation.tabs.java.label=Java System Properties breadcrumbs.start=LibreCCM Admin +usersgroupsroles.users.label=Benutzer*innen +usersgroupsroles.groups.label=Gruppen +usersgroupsroles.roles.label=Rollen +usersgroupsroles.overview.label=\u00dcberblick +usersgroupsroles.active_users_count.label=aktive Benutzer*innen +usersgroupsroles.disabled_users_count.label=inaktive Benutzer*innen +usersgroupsroles.groups_count.label=Gruppen +usersgroupsroles.roles_count.label=Rollen +usersgroupsroles.users.table.headers.username=Benutzername +usersgroupsroles.users.table.headers.givenname=Vorname +usersgroupsroles.users.table.headers.familyname=Familienname +usersgroupsroles.users.table.headers.email=E-Mail +usersgroupsroles.users.table.headers.disabled=Inaktiv? +usersgroupsroles.users.table.headers.actions=Aktionen +usersgroupsroles.users.table.headers.disabled.true=Ja +usersgroupsroles.users.table.headers.disabled.false=Nein +usersgroupsroles.users.detailslink.label=Details +usersgroupsroles.users.disablebutton.label=Sperren +usersgroupsroles.users.add=Benutzer*in hinzuf\u00fcgen +usersgroupsroles.users.filter.label=Benutzer*innen filtern +usersgroupsroles.users.filter.submit=Anwenden From aed845570b770e19dc00cc06b88b4ad6ce1c1c23 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 23 Sep 2020 21:13:04 +0200 Subject: [PATCH 08/93] Changed order of admin pages to get the mosted used one the left most position --- .../org/libreccm/ui/admin/applications/ApplicationsPage.java | 2 +- .../java/org/libreccm/ui/admin/imexport/ImExportPage.java | 4 +--- .../src/main/java/org/libreccm/ui/admin/sites/SitesPage.java | 2 +- .../ui/admin/usersgroupsroles/UsersGroupsRolesPage.java | 5 ++--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java index 0eb0e7f4a..cedd9abc6 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java @@ -72,7 +72,7 @@ public class ApplicationsPage implements AdminPage { @Override public int getPosition() { - return 10; + return 40; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java index d97224905..4c758bd0e 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java @@ -18,10 +18,8 @@ */ package org.libreccm.ui.admin.imexport; -import org.libreccm.ui.admin.configuration.*; import org.libreccm.ui.admin.AdminConstants; import org.libreccm.ui.admin.AdminPage; -import org.libreccm.ui.admin.categories.CategoriesController; import java.util.HashSet; import java.util.Set; @@ -73,6 +71,6 @@ public class ImExportPage implements AdminPage { @Override public int getPosition() { - return 40; + return 60; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java index bab4b12cf..ae42934e7 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java @@ -71,6 +71,6 @@ public class SitesPage implements AdminPage { @Override public int getPosition() { - return 60; + return 50; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java index 1800ba090..4212574cb 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java @@ -18,10 +18,8 @@ */ package org.libreccm.ui.admin.usersgroupsroles; -import org.libreccm.ui.admin.configuration.*; import org.libreccm.ui.admin.AdminConstants; import org.libreccm.ui.admin.AdminPage; -import org.libreccm.ui.admin.categories.CategoriesController; import java.util.HashSet; import java.util.Set; @@ -38,6 +36,7 @@ public class UsersGroupsRolesPage implements AdminPage { public Set> getControllerClasses() { final Set> classes = new HashSet<>(); classes.add(UsersGroupsRolesController.class); + classes.add(UsersController.class); return classes; } @@ -73,6 +72,6 @@ public class UsersGroupsRolesPage implements AdminPage { @Override public int getPosition() { - return 80; + return 10; } } From 6ebb1aed5396dcf862ba7f7537b58256058070b2 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Wed, 23 Sep 2020 21:13:41 +0200 Subject: [PATCH 09/93] Moved controller methods for users administration to separate controller --- .../usersgroupsroles/UsersController.java | 146 ++++++++++++++++++ .../UsersGroupsRolesController.java | 21 +-- 2 files changed, 149 insertions(+), 18 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java new file mode 100644 index 000000000..ad6f27a62 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java @@ -0,0 +1,146 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.core.CoreConstants; +import org.libreccm.security.AuthorizationRequired; +import org.libreccm.security.RequiresPrivilege; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.mvc.Controller; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/users-groups-roles/users") +public class UsersController { + + @Inject + private UsersTableModel usersTableModel; + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getUsers( + @QueryParam("filterterm") @DefaultValue("") final String filterTerm + ) { + usersTableModel.setFilterTerm(filterTerm); + return "org/libreccm/ui/admin/users-groups-roles/users.xhtml"; + } + + @GET + @Path("/{userIdentifier}/details") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @POST + @Path("/{userIdentifier}/create") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String createUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @GET + @Path("/users/{userIdentifier}/edit") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String editUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @POST + @Path("/users/{userIdentifier}/edit") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String updateUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @POST + @Path("/users/{userIdentifier}/disable") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String disableUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @GET + @Path("/{userIdentifier}/emailaddresses") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getEmailAddressesOfUser( + @PathParam("userIdentifier") final String userIdentifier + ) { + + throw new UnsupportedOperationException(); + } + + @POST + @Path("/{userIdentifier}/emailaddresses/{address}/add") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String addEmailAddresses( + @PathParam("userIdentifier") final String userIdentifier, + @PathParam("address") final String addressToAdd + ) { + throw new UnsupportedOperationException(); + } + + @POST + @Path("/{userIdentifier}/emailaddresses/{address}/remove") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String removeEmailAddresses( + @PathParam("userIdentifier") final String userIdentifier, + @PathParam("address") final String addressToRemove + ) { + throw new UnsupportedOperationException(); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java index 69dd1d61e..a61c9f4b2 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java @@ -23,14 +23,9 @@ import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.RequiresPrivilege; import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; import javax.mvc.Controller; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.FormParam; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; /** * @@ -41,9 +36,7 @@ import javax.ws.rs.QueryParam; @Path("/users-groups-roles") public class UsersGroupsRolesController { - @Inject - private UsersTableModel usersTableModel; - + @GET @Path("/") @AuthorizationRequired @@ -68,15 +61,7 @@ public class UsersGroupsRolesController { return "org/libreccm/ui/admin/users-groups-roles/roles.xhtml"; } - @GET - @Path("/users") - @AuthorizationRequired - @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getUsers( - @QueryParam("filterterm") @DefaultValue("") final String filterTerm - ) { - usersTableModel.setFilterTerm(filterTerm); - return "org/libreccm/ui/admin/users-groups-roles/users.xhtml"; - } + + } From 29a567f4485a2d7d87d1c1fd46f6286643f75dda Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 24 Sep 2020 21:13:57 +0200 Subject: [PATCH 10/93] User Details view and some other enhancements for the Admin UI --- .../java/org/libreccm/api/ApiConstants.java | 35 ++ .../java/org/libreccm/api/Identifier.java | 46 +++ .../org/libreccm/api/IdentifierParser.java | 51 +++ .../java/org/libreccm/api/IdentifierType.java | 29 ++ .../java/org/libreccm/core/EmailAddress.java | 4 +- .../main/java/org/libreccm/ui/Message.java | 44 +++ .../java/org/libreccm/ui/MessageType.java | 36 +++ .../org/libreccm/ui/admin/AdminMessages.java | 28 +- .../java/org/libreccm/ui/admin/AdminPage.java | 18 +- .../org/libreccm/ui/admin/AdminPageModel.java | 16 +- .../libreccm/ui/admin/AdminPagesModel.java | 2 +- .../applications/ApplicationsController.java | 2 +- .../admin/applications/ApplicationsPage.java | 6 +- .../categories/CategoriesController.java | 2 +- .../ui/admin/categories/CategoriesPage.java | 6 +- .../ConfigurationController.java | 2 +- .../configuration/ConfigurationPage.java | 7 +- .../admin/dashboard/DashboardController.java | 2 +- .../ui/admin/dashboard/DashboardPage.java | 7 +- .../ui/admin/imexport/ImExportController.java | 2 +- .../ui/admin/imexport/ImExportPage.java | 6 +- .../ui/admin/sites/SitesController.java | 2 +- .../libreccm/ui/admin/sites/SitesPage.java | 6 +- .../SystemInformationPage.java | 8 +- .../usersgroupsroles/GroupsController.java | 47 +++ .../usersgroupsroles/PartyRoleMembership.java | 74 +++++ .../usersgroupsroles/RolesController.java | 47 +++ .../usersgroupsroles/UserDetailsModel.java | 156 +++++++++ .../usersgroupsroles/UserGroupMembership.java | 74 +++++ .../usersgroupsroles/UsersController.java | 63 +++- .../UsersGroupsRolesController.java | 20 -- .../UsersGroupsRolesPage.java | 15 +- .../org/libreccm/ui/admin/ccm-admin.xhtml | 6 +- .../ui/admin/users-groups-roles.xhtml | 8 +- .../ui/admin/users-groups-roles/groups.xhtml | 4 +- .../ui/admin/users-groups-roles/roles.xhtml | 4 +- .../users-groups-roles/user-details.xhtml | 298 ++++++++++++++++++ .../users-groups-roles/user-not-found.xhtml | 39 +++ .../ui/admin/users-groups-roles/users.xhtml | 12 +- .../org/libreccm/ui/AdminBundle.properties | 32 ++ .../org/libreccm/ui/AdminBundle_de.properties | 32 ++ 41 files changed, 1212 insertions(+), 86 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/api/ApiConstants.java create mode 100644 ccm-core/src/main/java/org/libreccm/api/Identifier.java create mode 100644 ccm-core/src/main/java/org/libreccm/api/IdentifierParser.java create mode 100644 ccm-core/src/main/java/org/libreccm/api/IdentifierType.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/Message.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/MessageType.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/GroupsController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/PartyRoleMembership.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/RolesController.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserDetailsModel.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserGroupMembership.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/user-details.xhtml create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/users-groups-roles/user-not-found.xhtml diff --git a/ccm-core/src/main/java/org/libreccm/api/ApiConstants.java b/ccm-core/src/main/java/org/libreccm/api/ApiConstants.java new file mode 100644 index 000000000..b8e5c7d09 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/api/ApiConstants.java @@ -0,0 +1,35 @@ +/* + * 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.api; + +/** + * + * @author Jens Pelzetter + */ +public final class ApiConstants { + + private ApiConstants() { + // Nothing + } + + public static final String IDENTIFIER_PREFIX_ID = "ID-"; + + public static final String IDENTIFIER_PREFIX_UUID = "UUID-"; + +} diff --git a/ccm-core/src/main/java/org/libreccm/api/Identifier.java b/ccm-core/src/main/java/org/libreccm/api/Identifier.java new file mode 100644 index 000000000..319ce1021 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/api/Identifier.java @@ -0,0 +1,46 @@ +/* + * 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.api; + +/** + * + * @author Jens Pelzetter + */ +public class Identifier { + + private final IdentifierType type; + + private final String identifier; + + protected Identifier( + final IdentifierType type, final String identifier + ) { + this.type = type; + this.identifier = identifier; + } + + public IdentifierType getType() { + return type; + } + + public String getIdentifier() { + return identifier; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/api/IdentifierParser.java b/ccm-core/src/main/java/org/libreccm/api/IdentifierParser.java new file mode 100644 index 000000000..5919eea24 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/api/IdentifierParser.java @@ -0,0 +1,51 @@ +/* + * 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.api; + +import java.util.Objects; + +import javax.enterprise.context.Dependent; + +/** + * + * @author Jens Pelzetter + */ +@Dependent +public class IdentifierParser { + + public Identifier parseIdentifier(final String identifierParam) { + Objects.requireNonNull(identifierParam, "identifier param is null."); + + if (identifierParam.startsWith(ApiConstants.IDENTIFIER_PREFIX_ID)) { + final String identifier = identifierParam + .substring(ApiConstants.IDENTIFIER_PREFIX_ID.length()); + return new Identifier(IdentifierType.ID, identifier); + } else if (identifierParam.startsWith( + ApiConstants.IDENTIFIER_PREFIX_UUID)) { + final String identifier = identifierParam + .substring(ApiConstants.IDENTIFIER_PREFIX_UUID.length()); + return new Identifier(IdentifierType.ID, identifier); + } else { + return new Identifier( + IdentifierType.PROPERTY, identifierParam + ); + } + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/api/IdentifierType.java b/ccm-core/src/main/java/org/libreccm/api/IdentifierType.java new file mode 100644 index 000000000..eaf85737b --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/api/IdentifierType.java @@ -0,0 +1,29 @@ +/* + * 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.api; + +/** + * + * @author Jens Pelzetter + */ +public enum IdentifierType { + ID, + UUID, + PROPERTY +} diff --git a/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java b/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java index 3d012d596..c5dcfbdd6 100644 --- a/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java +++ b/ccm-core/src/main/java/org/libreccm/core/EmailAddress.java @@ -18,8 +18,6 @@ */ package org.libreccm.core; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotBlank; import javax.persistence.Column; import javax.persistence.Embeddable; @@ -33,6 +31,8 @@ import static org.libreccm.core.CoreConstants.CORE_XML_NS; import javax.json.Json; import javax.json.JsonObjectBuilder; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; /** * An embeddable entity for storing email addresses. diff --git a/ccm-core/src/main/java/org/libreccm/ui/Message.java b/ccm-core/src/main/java/org/libreccm/ui/Message.java new file mode 100644 index 000000000..916aa2b29 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/Message.java @@ -0,0 +1,44 @@ +/* + * 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; + +/** + * + * @author Jens Pelzetter + */ +public class Message { + + private final String message; + + private final MessageType messageType; + + public Message(String message, MessageType messageType) { + this.message = message; + this.messageType = messageType; + } + + public String getMessage() { + return message; + } + + public MessageType getMessageType() { + return messageType; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/MessageType.java b/ccm-core/src/main/java/org/libreccm/ui/MessageType.java new file mode 100644 index 000000000..83f46f005 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/MessageType.java @@ -0,0 +1,36 @@ +/* + * 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; + +/** + * + * @author Jens Pelzetter + */ +public enum MessageType { + + PRIMARY, + SECONDARY, + SUCCESS, + DANGER, + WARNING, + INFO, + LIGHT, + DARK, + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminMessages.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminMessages.java index 6890af911..f0af45d4a 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminMessages.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminMessages.java @@ -20,7 +20,9 @@ package org.libreccm.ui.admin; import org.libreccm.l10n.GlobalizationHelper; +import java.text.MessageFormat; import java.util.AbstractMap; +import java.util.List; import java.util.ResourceBundle; import java.util.Set; import java.util.stream.Collectors; @@ -43,8 +45,6 @@ public class AdminMessages extends AbstractMap { private ResourceBundle messages; - - @PostConstruct private void init() { messages = ResourceBundle.getBundle( @@ -57,21 +57,37 @@ public class AdminMessages extends AbstractMap { if (messages.containsKey(key)) { return messages.getString(key); } else { - return "???key???"; + return String.format("???%s???", key); } } - + + public String getMessage( + final String key, final List parameters + ) { + return getMessage(key, parameters.toArray()); + } + + public String getMessage( + final String key, final Object[] parameters + ) { + if (messages.containsKey(key)) { + return MessageFormat.format(messages.getString(key), parameters); + } else { + return String.format("???%s???", key); + } + } + public String get(final String key) { return getMessage(key); } - + @Override public Set> entrySet() { return messages .keySet() .stream() .collect( - Collectors.toMap(key -> key, key-> messages.getString(key)) + Collectors.toMap(key -> key, key -> messages.getString(key)) ) .entrySet(); } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java index 27e1ab4b4..9fcf96015 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java @@ -18,9 +18,10 @@ */ package org.libreccm.ui.admin; -import java.util.ResourceBundle; import java.util.Set; +import javax.mvc.MvcContext; + /** * * @author Jens Pelzetter @@ -35,14 +36,15 @@ public interface AdminPage { Set> getControllerClasses(); /** - * The entry point for the admin module. Used to generate the URL for an - * admin page in the navigation etc. For example, with the return value will - * {@code systeminformation} the generated link is - * {@code #{contextPath}/@admin/#{path}}. - * - * @return The path fragment of the entry point of the admin page/module. + * A identifier to use by {@link MvcContext#uri(java.lang.String)} to + * generate the URI of the page. The identifier has the same format as used in JavaDoc: + *
+     *     ControllerSimpleClassName#methodName
+     * 
+ * + * @return The identifier to use for generating the URL of the page */ - String getPath(); + String getUriIdentifier(); /** * Gets the resourcebundle which provides the label of the admin page. diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java index 706fa3342..96a7899d3 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java @@ -24,7 +24,7 @@ package org.libreccm.ui.admin; */ public class AdminPageModel { - private String path; + private String uriIdentifier; private String label; @@ -32,19 +32,19 @@ public class AdminPageModel { private String icon; - public String getPath() { - return path; + public String getUriIdentifier() { + return uriIdentifier; } - public void setPath(String path) { - this.path = path; + public void setUriIdentifier(final String uriIdentifier) { + this.uriIdentifier = uriIdentifier; } public String getLabel() { return label; } - public void setLabel(String label) { + public void setLabel(final String label) { this.label = label; } @@ -52,7 +52,7 @@ public class AdminPageModel { return description; } - public void setDescription(String description) { + public void setDescription(final String description) { this.description = description; } @@ -60,7 +60,7 @@ public class AdminPageModel { return icon; } - public void setIcon(String icon) { + public void setIcon(final String icon) { this.icon = icon; } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java index 72f07e4df..08de0c083 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java @@ -71,7 +71,7 @@ public class AdminPagesModel { ); final AdminPageModel model = new AdminPageModel(); - model.setPath(fromAdminPage.getPath()); + model.setUriIdentifier(fromAdminPage.getUriIdentifier()); model.setLabel(labelBundle.getString(fromAdminPage.getLabelKey())); model.setDescription( descriptionBundle.getString( 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 5245c612a..0a9eff521 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 @@ -40,7 +40,7 @@ public class ApplicationsController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getApplications() { return "org/libreccm/ui/admin/applications.xhtml"; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java index cedd9abc6..185670232 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationsPage.java @@ -41,8 +41,10 @@ public class ApplicationsPage implements AdminPage { } @Override - public String getPath() { - return "applications"; + public String getUriIdentifier() { + return String.format( + "%s#getApplications", ApplicationsController.class.getSimpleName() + ); } @Override 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 e15766460..aebf65cf7 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 @@ -40,7 +40,7 @@ public class CategoriesController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getCategories() { return "org/libreccm/ui/admin/categories.xhtml"; } } 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 666ac70e7..fa877b379 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 @@ -41,8 +41,10 @@ public class CategoriesPage implements AdminPage { } @Override - public String getPath() { - return "categories"; + public String getUriIdentifier() { + return String.format( + "%s#getCategories", CategoriesController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java index 1e36e66c6..e36f7fdc7 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationController.java @@ -40,7 +40,7 @@ public class ConfigurationController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getSettings() { return "org/libreccm/ui/admin/configuration.xhtml"; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java index 463c136e6..d9ebcb039 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationPage.java @@ -20,7 +20,6 @@ package org.libreccm.ui.admin.configuration; import org.libreccm.ui.admin.AdminConstants; import org.libreccm.ui.admin.AdminPage; -import org.libreccm.ui.admin.categories.CategoriesController; import java.util.HashSet; import java.util.Set; @@ -41,8 +40,10 @@ public class ConfigurationPage implements AdminPage { } @Override - public String getPath() { - return "configuration"; + public String getUriIdentifier() { + return String.format( + "%s#getSettings", ConfigurationController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java index a3b72590b..d651b3453 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardController.java @@ -40,7 +40,7 @@ public class DashboardController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getDashboard() { return "org/libreccm/ui/admin/dashboard.xhtml"; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java index 5620d3dd1..51276a54a 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/DashboardPage.java @@ -20,6 +20,7 @@ package org.libreccm.ui.admin.dashboard; import org.libreccm.ui.admin.AdminConstants; import org.libreccm.ui.admin.AdminPage; +import org.libreccm.ui.admin.configuration.ConfigurationController; import java.util.HashSet; import java.util.Set; @@ -40,8 +41,10 @@ public class DashboardPage implements AdminPage { } @Override - public String getPath() { - return "/"; + public String getUriIdentifier() { + return String.format( + "%s#getDashboard", DashboardController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java index 9e2dfef7b..a89b01927 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportController.java @@ -40,7 +40,7 @@ public class ImExportController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getImExportDashboard() { return "org/libreccm/ui/admin/imexport.xhtml"; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java index 4c758bd0e..e41b58555 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportPage.java @@ -40,8 +40,10 @@ public class ImExportPage implements AdminPage { } @Override - public String getPath() { - return "imexport"; + public String getUriIdentifier() { + return String.format( + "%s#getImExportDashboard", ImExportController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java index 817821f05..e7bd0a708 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesController.java @@ -40,7 +40,7 @@ public class SitesController { @Path("/") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getPlaceholder() { + public String getSites() { return "org/libreccm/ui/admin/sites.xhtml"; } } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java index ae42934e7..a07f98a6f 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SitesPage.java @@ -40,8 +40,10 @@ public class SitesPage implements AdminPage { } @Override - public String getPath() { - return "sites"; + public String getUriIdentifier() { + return String.format( + "%s#getSites", SitesController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java index 27af5ad63..bacaa0888 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java @@ -23,6 +23,7 @@ import java.util.Set; import org.libreccm.ui.admin.AdminConstants; import org.libreccm.ui.admin.AdminPage; +import org.libreccm.ui.admin.imexport.ImExportController; import javax.enterprise.context.ApplicationScoped; @@ -41,8 +42,11 @@ public class SystemInformationPage implements AdminPage { } @Override - public String getPath() { - return "systeminformation"; + public String getUriIdentifier() { + return String.format( + "%s#getSystemInformation", + SystemInformationController.class.getSimpleName() + ); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/GroupsController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/GroupsController.java new file mode 100644 index 000000000..5c9ddf910 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/GroupsController.java @@ -0,0 +1,47 @@ +/* + * 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.usersgroupsroles; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/users-groups-roles/group") +public class GroupsController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getGroups() { + return "org/libreccm/ui/admin/users-groups-roles/groups.xhtml"; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/PartyRoleMembership.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/PartyRoleMembership.java new file mode 100644 index 000000000..46cbaeec1 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/PartyRoleMembership.java @@ -0,0 +1,74 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.security.Role; + +/** + * + * @author Jens Pelzetter + */ +public class PartyRoleMembership implements Comparable{ + + private long roleId; + + private String roleUuid; + + private String roleName; + + public PartyRoleMembership() { + // Nothing + } + + public PartyRoleMembership(final Role role) { + roleId = role.getRoleId(); + roleUuid = role.getUuid(); + roleName = role.getName(); + } + + public long getRoleId() { + return roleId; + } + + public void setRoleId(long roleId) { + this.roleId = roleId; + } + + public String getRoleUuid() { + return roleUuid; + } + + public void setRoleUuid(String roleUuid) { + this.roleUuid = roleUuid; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + @Override + public int compareTo(final PartyRoleMembership other) { + return roleName.compareTo(other.getRoleName()); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/RolesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/RolesController.java new file mode 100644 index 000000000..2154649eb --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/RolesController.java @@ -0,0 +1,47 @@ +/* + * 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.usersgroupsroles; + +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.Path; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Controller +@Path("/users-groups-roles/roles") +public class RolesController { + + @GET + @Path("/") + @AuthorizationRequired + @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) + public String getRoles() { + return "org/libreccm/ui/admin/users-groups-roles/roles.xhtml"; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserDetailsModel.java new file mode 100644 index 000000000..68b4a8a5a --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserDetailsModel.java @@ -0,0 +1,156 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.core.EmailAddress; +import org.libreccm.security.GroupMembership; +import org.libreccm.security.RoleMembership; +import org.libreccm.security.User; +import org.libreccm.ui.Message; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("UserDetailsModel") +public class UserDetailsModel { + + private long userId; + + private String uuid; + + private String name; + + private String givenName; + + private String familyName; + + private EmailAddress primaryEmailAddress; + + private List emailAddresses; + + private boolean banned; + + private boolean passwordResetRequired; + + private List groupMemberships; + + private List roles; + + private final List messages; + + public UserDetailsModel() { + messages = new ArrayList<>(); + } + + @Transactional(Transactional.TxType.REQUIRED) + protected void setUser(final User user) { + Objects.requireNonNull(user); + + userId = user.getPartyId(); + uuid = user.getUuid(); + name = user.getName(); + givenName = user.getGivenName(); + familyName = user.getFamilyName(); + primaryEmailAddress = user.getPrimaryEmailAddress(); + // Ensure that we don't get a lazyily initalized list. + emailAddresses = user + .getEmailAddresses() + .stream() + .collect(Collectors.toList()); + banned = user.isBanned(); + passwordResetRequired = user.isPasswordResetRequired(); + groupMemberships = user + .getGroupMemberships() + .stream() + .map(GroupMembership::getGroup) + .map(UserGroupMembership::new) + .collect(Collectors.toList()); + roles = user + .getRoleMemberships() + .stream() + .map(RoleMembership::getRole) + .map(PartyRoleMembership::new) + .collect(Collectors.toList()); + } + + public List getMessages() { + return Collections.unmodifiableList(messages); + } + + public void addMessage(final Message message) { + messages.add(message); + } + + public long getUserId() { + return userId; + } + + public String getUuid() { + return uuid; + } + + public String getName() { + return name; + } + + public String getGivenName() { + return givenName; + } + + public String getFamilyName() { + return familyName; + } + + public EmailAddress getPrimaryEmailAddress() { + return primaryEmailAddress; + } + + public List getEmailAddresses() { + return Collections.unmodifiableList(emailAddresses); + } + + public boolean isBanned() { + return banned; + } + + public boolean isPasswordResetRequired() { + return passwordResetRequired; + } + + public List getGroupMemberships() { + return Collections.unmodifiableList(groupMemberships); + } + + public List getRoles() { + return Collections.unmodifiableList(roles); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserGroupMembership.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserGroupMembership.java new file mode 100644 index 000000000..31b48b3aa --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UserGroupMembership.java @@ -0,0 +1,74 @@ +/* + * 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.usersgroupsroles; + +import org.libreccm.security.Group; + +/** + * + * @author Jens Pelzetter + */ +public class UserGroupMembership implements Comparable { + + private long groupId; + + private String groupUuid; + + private String groupName; + + public UserGroupMembership() { + // Nothing + } + + public UserGroupMembership(final Group group) { + this.groupId = group.getPartyId(); + this.groupUuid = group.getUuid(); + this.groupName = group.getName(); + } + + public long getGroupId() { + return groupId; + } + + public void setGroupId(final long groupId) { + this.groupId = groupId; + } + + public String getGroupUuid() { + return groupUuid; + } + + public void setGroupUuid(final String groupUuid) { + this.groupUuid = groupUuid; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(final String groupName) { + this.groupName = groupName; + } + + @Override + public int compareTo(final UserGroupMembership other) { + return groupName.compareTo(other.getGroupName()); + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java index ad6f27a62..3b079f3e4 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersController.java @@ -18,13 +18,24 @@ */ package org.libreccm.ui.admin.usersgroupsroles; +import org.libreccm.api.Identifier; +import org.libreccm.api.IdentifierParser; import org.libreccm.core.CoreConstants; import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.RequiresPrivilege; +import org.libreccm.security.User; +import org.libreccm.security.UserRepository; +import org.libreccm.ui.Message; +import org.libreccm.ui.MessageType; +import org.libreccm.ui.admin.AdminMessages; + +import java.util.Arrays; +import java.util.Optional; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.mvc.Controller; +import javax.transaction.Transactional; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -41,6 +52,18 @@ import javax.ws.rs.QueryParam; @Path("/users-groups-roles/users") public class UsersController { + @Inject + private AdminMessages adminMessages; + + @Inject + private IdentifierParser identifierParser; + + @Inject + private UserDetailsModel userDetailsModel; + + @Inject + private UserRepository userRepository; + @Inject private UsersTableModel usersTableModel; @@ -59,11 +82,45 @@ public class UsersController { @Path("/{userIdentifier}/details") @AuthorizationRequired @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getUser( - @PathParam("userIdentifier") final String userIdentifier + @Transactional(Transactional.TxType.REQUIRED) + public String getUserDetails( + @PathParam("userIdentifier") final String userIdentifierParam ) { + final Identifier identifier = identifierParser.parseIdentifier( + userIdentifierParam + ); + final Optional result; + switch (identifier.getType()) { + case ID: + result = userRepository.findById( + Long.parseLong(identifier.getIdentifier()) + ); + break; + case UUID: + result = userRepository.findByUuid( + identifier.getIdentifier() + ); + break; + default: + result = userRepository.findByName(identifier.getIdentifier()); + break; + } - throw new UnsupportedOperationException(); + if (result.isPresent()) { + userDetailsModel.setUser(result.get()); + return "org/libreccm/ui/admin/users-groups-roles/user-details.xhtml"; + } else { + userDetailsModel.addMessage( + new Message( + adminMessages.getMessage( + "usersgroupsroles.users.not_found.message", + Arrays.asList(userIdentifierParam) + ), + MessageType.WARNING + ) + ); + return "org/libreccm/ui/admin/users-groups-roles/user-not-found.xhtml"; + } } @POST diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java index a61c9f4b2..5011f27a1 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesController.java @@ -36,7 +36,6 @@ import javax.ws.rs.Path; @Path("/users-groups-roles") public class UsersGroupsRolesController { - @GET @Path("/") @AuthorizationRequired @@ -45,23 +44,4 @@ public class UsersGroupsRolesController { return "org/libreccm/ui/admin/users-groups-roles/overview.xhtml"; } - @GET - @Path("/groups") - @AuthorizationRequired - @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getGroups() { - return "org/libreccm/ui/admin/users-groups-roles/groups.xhtml"; - } - - @GET - @Path("/roles") - @AuthorizationRequired - @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) - public String getRoles() { - return "org/libreccm/ui/admin/users-groups-roles/roles.xhtml"; - } - - - - } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java index 4212574cb..bf32b3afd 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/usersgroupsroles/UsersGroupsRolesPage.java @@ -32,17 +32,23 @@ import javax.enterprise.context.ApplicationScoped; */ @ApplicationScoped public class UsersGroupsRolesPage implements AdminPage { - @Override + + @Override public Set> getControllerClasses() { final Set> classes = new HashSet<>(); classes.add(UsersGroupsRolesController.class); + classes.add(GroupsController.class); + classes.add(RolesController.class); classes.add(UsersController.class); return classes; } @Override - public String getPath() { - return "users-groups-roles"; + public String getUriIdentifier() { + return String.format( + "%s#getOverview", + UsersGroupsRolesController.class.getSimpleName() + ); } @Override @@ -57,7 +63,7 @@ public class UsersGroupsRolesPage implements AdminPage { @Override public String getDescriptionBundle() { - return AdminConstants.ADMIN_BUNDLE; + return AdminConstants.ADMIN_BUNDLE; } @Override @@ -74,4 +80,5 @@ public class UsersGroupsRolesPage implements AdminPage { public int getPosition() { return 10; } + } diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml index cd0d52d15..705e1dc97 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml @@ -29,8 +29,8 @@