JavaDoc for the admin UI (general UI classes, general classes for admin UI, users management)

ccm-docs
Jens Pelzetter 2020-10-06 08:05:52 +02:00
parent 66c491e931
commit d84245684f
25 changed files with 196 additions and 28 deletions

View File

@ -31,6 +31,8 @@ import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.Response;
/**
* Filter for securing EE MVC UIs. Checks if the current user is authenticated.
* If not the user is redirected to the login application.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -19,13 +19,20 @@
package org.libreccm.ui;
/**
* Stores a message to be displayed in the UI.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class Message {
/**
* The message (or the translation key for the message).
*/
private final String message;
/**
* The type of the message.
*/
private final MessageType messageType;
public Message(String message, MessageType messageType) {

View File

@ -19,6 +19,8 @@
package org.libreccm.ui;
/**
* Possible message types. The types are equivalent to the contextual classes
* of the Bootstrap framework.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -28,6 +28,8 @@ import javax.mvc.locale.LocaleResolver;
import javax.mvc.locale.LocaleResolverContext;
/**
* A locale resolver implementation that simply passes the locale negoiated by
* LibreCCM to Jakarta EE MVC.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -30,12 +30,17 @@ import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
* Collects the controllers for the admin application and registers them with
* JAX-RS.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ApplicationPath("/@admin")
public class AdminApplication extends Application {
/**
* Injection point for the admin pages.
*/
@Inject
private Instance<AdminPage> adminPages;

View File

@ -19,6 +19,7 @@
package org.libreccm.ui.admin;
/**
* Some constants for the admin application
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -28,6 +29,9 @@ public class AdminConstants {
// Nothing
}
/**
* Bundle that provides the translations for the admin application.
*/
public static final String ADMIN_BUNDLE = "org.libreccm.ui.AdminBundle";

View File

@ -33,6 +33,18 @@ import javax.inject.Inject;
import javax.inject.Named;
/**
* Provides simple access to the messages in the admin bundle. The make it as
* easy as possible to access the messages this class is implemented as a map a
* made available as named bean. For simple messages, {@code AdminMesssages} can
* be used like a map in a facelets template:
*
* <pre>
* #{AdminMessages['some.message.key'])
* </pre>
*
* Messages with placeholders can be retrieved using
* {@link #getMessage(java.lang.String, java.util.List)} or
* {@link #getMessage(java.lang.String, java.lang.Object[])}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -40,11 +52,20 @@ import javax.inject.Named;
@Named("AdminMessages")
public class AdminMessages extends AbstractMap<String, String> {
/**
* Provides access to the locale negoiated by LibreCCM.
*/
@Inject
private GlobalizationHelper globalizationHelper;
/**
* The {@link ResourceBundle} to use.
*/
private ResourceBundle messages;
/**
* Loads the resource bundle.
*/
@PostConstruct
private void init() {
messages = ResourceBundle.getBundle(
@ -53,6 +74,13 @@ public class AdminMessages extends AbstractMap<String, String> {
);
}
/**
* Retrieves a message from the resource bundle.
*
* @param key The key of the message.
* @return The translated message or {@code ???message???} if the the key is
* not found in the resource bundle (message is replaced with the key).
*/
public String getMessage(final String key) {
if (messages.containsKey(key)) {
return messages.getString(key);
@ -61,12 +89,29 @@ public class AdminMessages extends AbstractMap<String, String> {
}
}
/**
* Retrieves a message with placeholders.
*
* @param key The key of the message.
* @param parameters The parameters for the placeholders.
* @return The translated message or {@code ???message???} if the the key is
* not found in the resource bundle (message is replaced with the key).
*/
public String getMessage(
final String key, final List<Object> parameters
) {
return getMessage(key, parameters.toArray());
}
/**
* The translated message or {@code ???message???} if the the key is
* not found in the resource bundle (message is replaced with the key).
*
@param key The key of the message.
* @param parameters The parameters for the placeholders.
* @return The translated message or {@code ???message???} if the the key is
* not found in the resource bundle (message is replaced with the key).
*/
public String getMessage(
final String key, final Object[] parameters
) {
@ -77,6 +122,11 @@ public class AdminMessages extends AbstractMap<String, String> {
}
}
@Override
public String get(final Object key) {
return get((String) key);
}
public String get(final String key) {
return getMessage(key);
}

View File

@ -23,6 +23,8 @@ import java.util.Set;
import javax.mvc.MvcContext;
/**
* Implementations of this interface provide the controllers etc. for an admin
* page.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -37,7 +39,8 @@ public interface AdminPage {
/**
* 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:
* generate the URI of the page. The identifier has the same format as used
* in JavaDoc:
* <pre>
* ControllerSimpleClassName#methodName
* </pre>

View File

@ -19,6 +19,9 @@
package org.libreccm.ui.admin;
/**
* Model for the data of an admin page.
*
* @see AdminPage
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -32,6 +32,7 @@ import javax.inject.Inject;
import javax.inject.Named;
/**
* Model for the available admin pages.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -39,6 +40,9 @@ import javax.inject.Named;
@Named("AdminPagesModel")
public class AdminPagesModel {
/**
* Injection point for the admin pages.
*/
@Inject
private Instance<AdminPage> adminPages;
@ -50,6 +54,12 @@ public class AdminPagesModel {
*/
private final Map<String, ResourceBundle> bundles = new HashMap<>();
/**
* Retrieves the available admin pages and converts them into
* {@link AdminPageModel}s for usage in the views.
*
* @return A list of the available admin pages.
*/
public List<AdminPageModel> getAdminPages() {
return adminPages
.stream()

View File

@ -0,0 +1,22 @@
/*
* 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
*/
/**
* Base classes for the admin application.
*/
package org.libreccm.ui.admin;

View File

@ -37,7 +37,6 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.mvc.binding.BindingResult;
import javax.transaction.Transactional;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
@ -45,21 +44,23 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
* Controller managing the post request from the email edit form.
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Controller
@Path(
"/users-groups-roles/users/{userIdentifier}/email-addresses/{emailIdentifier}/save")
"/users-groups-roles/users/{userIdentifier}/email-addresses/{emailIdentifier}/save"
)
public class EmailFormController {
@Inject
private AdminMessages adminMessages;
@Inject
private BindingResult bindingResult;
// @Inject
// private BindingResult bindingResult;
@Inject
private EmailFormModel emailFormModel;

View File

@ -29,6 +29,7 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
* Model providing the data for the email edit form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@ -38,7 +39,7 @@ public class EmailFormModel {
private String userIdentifier;
private int emailId;
private int emailId = -1;
private String address;
@ -77,7 +78,7 @@ public class EmailFormModel {
}
public boolean isNew() {
return emailId == 0;
return emailId == -1;
}
public String getUserIdentifier() {

View File

@ -31,6 +31,7 @@ import javax.inject.Named;
import javax.transaction.Transactional;
/**
* Model for the overview page of the users/groups/roles admin module.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -21,6 +21,7 @@ package org.libreccm.ui.admin.usersgroupsroles;
import org.libreccm.security.Role;
/**
* Model friendly representation of the role membership of a {@link Party}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -40,6 +40,7 @@ import javax.inject.Named;
import javax.transaction.Transactional;
/**
* Model used by the user details view and the user edit form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -48,6 +48,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
* Controller managing the user post requests from the user edit form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -21,6 +21,7 @@ package org.libreccm.ui.admin.usersgroupsroles;
import org.libreccm.security.Group;
/**
* Model friendly representation of a group membership of the user.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -19,6 +19,7 @@
package org.libreccm.ui.admin.usersgroupsroles;
/**
* Model for an selectable group in the user groups form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -19,6 +19,7 @@
package org.libreccm.ui.admin.usersgroupsroles;
/**
* Model for an entry of a selectable role in the user roles form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -48,6 +48,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
/**
* Controller for the user details view and the {@code GET} requests to the
* user edit form.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -28,6 +28,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
*
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -32,6 +32,7 @@ import javax.inject.Named;
import javax.transaction.Transactional;
/**
* Model for the table/list of users.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/

View File

@ -0,0 +1,23 @@
/*
* 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
*/
/**
* Provides the backend for the user interface for managing users, groups and
* roles.
*/
package org.libreccm.ui.admin.usersgroupsroles;

View File

@ -0,0 +1,22 @@
/*
* 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
*/
/**
* Utility classes for Jakarta EE MVC based user interfaces.
*/
package org.libreccm.ui;