Collect admin pages via CDI
parent
69c7bcd092
commit
29ac4dcf84
|
|
@ -86,6 +86,11 @@
|
||||||
<Logger name="org.libreccm.ui.admin.usersgroupsroles.RolesController"
|
<Logger name="org.libreccm.ui.admin.usersgroupsroles.RolesController"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
<Logger
|
||||||
|
name="org.libreccm.ui.admin.CcmAdmin"
|
||||||
|
level="debug"
|
||||||
|
>
|
||||||
|
</Logger>
|
||||||
<Logger name="org.librecms.contentsection.AssetRepository"
|
<Logger name="org.librecms.contentsection.AssetRepository"
|
||||||
level="debug">
|
level="debug">
|
||||||
</Logger>
|
</Logger>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class AdminConstants {
|
||||||
|
|
||||||
|
private AdminConstants() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String ADMIN_BUNDLE = "org.libreccm.ui.admin.AdminBundle";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -48,6 +48,7 @@ public class AdminPage extends WebPage {
|
||||||
.stream()
|
.stream()
|
||||||
.map(AdminPagesProvider::getAdminPagesData)
|
.map(AdminPagesProvider::getAdminPagesData)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
|
.filter(page -> page.getGroup().equals(""))
|
||||||
.sorted(
|
.sorted(
|
||||||
(page1, page2) -> Integer.compare(
|
(page1, page2) -> Integer.compare(
|
||||||
page1.getPosition(), page2.getPosition()
|
page1.getPosition(), page2.getPosition()
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ public class AdminPageData {
|
||||||
|
|
||||||
private final Class<? extends AdminPage> pageClass;
|
private final Class<? extends AdminPage> pageClass;
|
||||||
|
|
||||||
|
private final String group;
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
private final String label;
|
private final String label;
|
||||||
|
|
@ -39,12 +41,14 @@ public class AdminPageData {
|
||||||
AdminPageData(
|
AdminPageData(
|
||||||
final String path,
|
final String path,
|
||||||
final Class<? extends AdminPage> pageClass,
|
final Class<? extends AdminPage> pageClass,
|
||||||
|
final String group,
|
||||||
final int position,
|
final int position,
|
||||||
final String label,
|
final String label,
|
||||||
final String description
|
final String description
|
||||||
) {
|
) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.pageClass = pageClass;
|
this.pageClass = pageClass;
|
||||||
|
this.group = group;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
@ -58,6 +62,10 @@ public class AdminPageData {
|
||||||
return pageClass;
|
return pageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +83,7 @@ public class AdminPageData {
|
||||||
int hash = 3;
|
int hash = 3;
|
||||||
hash = 59 * hash + Objects.hashCode(path);
|
hash = 59 * hash + Objects.hashCode(path);
|
||||||
hash = 59 * hash + Objects.hashCode(pageClass);
|
hash = 59 * hash + Objects.hashCode(pageClass);
|
||||||
|
hash = 59 * hash + Objects.hashCode(group);
|
||||||
hash = 59 * hash + position;
|
hash = 59 * hash + position;
|
||||||
hash = 59 * hash + Objects.hashCode(label);
|
hash = 59 * hash + Objects.hashCode(label);
|
||||||
hash = 59 * hash + Objects.hashCode(description);
|
hash = 59 * hash + Objects.hashCode(description);
|
||||||
|
|
@ -102,6 +111,9 @@ public class AdminPageData {
|
||||||
if (!Objects.equals(pageClass, other.getPageClass())) {
|
if (!Objects.equals(pageClass, other.getPageClass())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!Objects.equals(group, other.getGroup())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (position != other.getPosition()) {
|
if (position != other.getPosition()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -119,11 +131,13 @@ public class AdminPageData {
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return toString("");
|
return toString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(final String data) {
|
public String toString(final String data) {
|
||||||
return String.format("%s{"
|
return String.format(
|
||||||
|
"%s{"
|
||||||
+ "path = %s, "
|
+ "path = %s, "
|
||||||
+ "pageClass = %s, "
|
+ "pageClass = %s, "
|
||||||
|
+ "group = %s, "
|
||||||
+ "order = %d, "
|
+ "order = %d, "
|
||||||
+ "label = %s, "
|
+ "label = %s, "
|
||||||
+ "description = %s%s"
|
+ "description = %s%s"
|
||||||
|
|
@ -131,13 +145,12 @@ public class AdminPageData {
|
||||||
super.toString(),
|
super.toString(),
|
||||||
path,
|
path,
|
||||||
pageClass.getName(),
|
pageClass.getName(),
|
||||||
|
group,
|
||||||
position,
|
position,
|
||||||
label,
|
label,
|
||||||
description,
|
description,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,139 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.ui.MissingPageDataException;
|
|
||||||
|
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class AdminPageDataBuilder {
|
|
||||||
|
|
||||||
private String path;
|
|
||||||
|
|
||||||
private final Class<? extends AdminPage> pageClass;
|
|
||||||
|
|
||||||
private Integer position;
|
|
||||||
|
|
||||||
private ResourceBundle labelBundle;
|
|
||||||
|
|
||||||
private String labelKey;
|
|
||||||
|
|
||||||
private ResourceBundle descriptionBundle;
|
|
||||||
|
|
||||||
private String descriptionKey;
|
|
||||||
|
|
||||||
private AdminPageDataBuilder(final Class<? extends AdminPage> pageClass) {
|
|
||||||
this.pageClass = pageClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminPageDataBuilder mountedTo(final String path) {
|
|
||||||
this.path = path;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AdminPageDataBuilder forPage(
|
|
||||||
final Class<? extends AdminPage> pageClass
|
|
||||||
) {
|
|
||||||
return new AdminPageDataBuilder(pageClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminPageDataBuilder atPosition(final int position) {
|
|
||||||
this.position = position;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminPageDataBuilder withLabel(
|
|
||||||
final ResourceBundle labelBundle, final String labelKey
|
|
||||||
) {
|
|
||||||
this.labelBundle = labelBundle;
|
|
||||||
this.labelKey = labelKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminPageDataBuilder withDescription(
|
|
||||||
final ResourceBundle descriptionBundle, final String descriptionKey
|
|
||||||
) {
|
|
||||||
this.descriptionBundle = descriptionBundle;
|
|
||||||
this.descriptionKey = descriptionKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminPageData build() {
|
|
||||||
if (path == null || path.isBlank()) {
|
|
||||||
throw new MissingPageDataException("Missing path for page.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pageClass == null) {
|
|
||||||
throw new MissingPageDataException("Missing class for page.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (position == null) {
|
|
||||||
throw new MissingPageDataException("Missing position for page.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (labelBundle == null) {
|
|
||||||
throw new MissingPageDataException(
|
|
||||||
"Missing label bundle for page."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (labelKey == null || labelKey.isBlank()) {
|
|
||||||
throw new MissingPageDataException("Missing label key for page.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptionBundle == null) {
|
|
||||||
throw new MissingPageDataException(
|
|
||||||
"Missing description bundle for page."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptionKey == null || descriptionKey.isBlank()) {
|
|
||||||
throw new MissingPageDataException(
|
|
||||||
"Missing description key for page."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String label = getLabelFromBundle();
|
|
||||||
final String description = getDescriptionFromBundle();
|
|
||||||
|
|
||||||
|
|
||||||
return new AdminPageData(path, pageClass, position, label, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getLabelFromBundle() {
|
|
||||||
try {
|
|
||||||
return labelBundle.getString(labelKey);
|
|
||||||
} catch(MissingResourceException ex) {
|
|
||||||
return labelKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDescriptionFromBundle() {
|
|
||||||
try {
|
|
||||||
return descriptionBundle.getString(descriptionKey);
|
|
||||||
} catch(MissingResourceException ex) {
|
|
||||||
return descriptionKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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 java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface AdminPageDescriptor {
|
||||||
|
|
||||||
|
String path();
|
||||||
|
|
||||||
|
int position();
|
||||||
|
|
||||||
|
Class<? extends AdminPage> subPageOf() default AdminPage.class;
|
||||||
|
|
||||||
|
String labelBundle();
|
||||||
|
|
||||||
|
String labelKey();
|
||||||
|
|
||||||
|
String descriptionBundle();
|
||||||
|
|
||||||
|
String descriptionKey();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -18,14 +18,127 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin;
|
package org.libreccm.ui.admin;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public interface AdminPagesProvider {
|
public abstract class AdminPagesProvider {
|
||||||
|
|
||||||
Set<AdminPageData> getAdminPagesData();
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
|
AdminPagesProvider.class
|
||||||
|
);
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
public abstract Set<Class<? extends AdminPage>> getClasses();
|
||||||
|
|
||||||
|
protected Set<AdminPageData> getAdminPagesData() {
|
||||||
|
return getClasses()
|
||||||
|
.stream()
|
||||||
|
.map(this::buildAdminPageData)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdminPageData buildAdminPageData(
|
||||||
|
final Class<? extends AdminPage> clazz
|
||||||
|
) {
|
||||||
|
final AdminPageDescriptor descriptor = clazz.getAnnotation(
|
||||||
|
AdminPageDescriptor.class
|
||||||
|
);
|
||||||
|
final String path = buildPath(descriptor);
|
||||||
|
final int position = descriptor.position();
|
||||||
|
final String labelBundle = descriptor.labelBundle();
|
||||||
|
final String labelKey = descriptor.labelKey();
|
||||||
|
final String descriptionBundle = descriptor.descriptionBundle();
|
||||||
|
final String descriptionKey = descriptor.descriptionKey();
|
||||||
|
final String group;
|
||||||
|
if (descriptor.subPageOf().equals(AdminPage.class)) {
|
||||||
|
group = "";
|
||||||
|
} else {
|
||||||
|
final AdminPageDescriptor parentDescriptor = descriptor
|
||||||
|
.subPageOf()
|
||||||
|
.getAnnotation(AdminPageDescriptor.class);
|
||||||
|
if (parentDescriptor == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"Parent page class %s of page class %s has no "
|
||||||
|
+ "AdminPageDescriptor annotation.",
|
||||||
|
descriptor.subPageOf().getName(),
|
||||||
|
clazz.getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
group = parentDescriptor.path();
|
||||||
|
}
|
||||||
|
|
||||||
|
final AdminPageData data = new AdminPageData(
|
||||||
|
path,
|
||||||
|
clazz,
|
||||||
|
group,
|
||||||
|
position,
|
||||||
|
findString(labelBundle, labelKey),
|
||||||
|
findString(descriptionBundle, descriptionKey)
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findString(final String bundleName, final String key) {
|
||||||
|
final ResourceBundle bundle;
|
||||||
|
try {
|
||||||
|
bundle = ResourceBundle.getBundle(
|
||||||
|
bundleName, globalizationHelper.getNegotiatedLocale()
|
||||||
|
);
|
||||||
|
} catch (MissingResourceException ex) {
|
||||||
|
LOGGER.warn("Resource Bundle {} not found.", bundleName);
|
||||||
|
LOGGER.warn(ex);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return bundle.getString(key);
|
||||||
|
} catch (MissingResourceException ex) {
|
||||||
|
LOGGER.warn("Key {} not found.", key);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildPath(final AdminPageDescriptor descriptor) {
|
||||||
|
if (descriptor.subPageOf().equals(AdminPage.class)) {
|
||||||
|
return descriptor.path();
|
||||||
|
} else {
|
||||||
|
final Class<? extends AdminPage> parent = descriptor.subPageOf();
|
||||||
|
final AdminPageDescriptor parentDescriptor = parent.getAnnotation(
|
||||||
|
AdminPageDescriptor.class
|
||||||
|
);
|
||||||
|
if (parentDescriptor == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(
|
||||||
|
"Parent page class %s of page class %s has no "
|
||||||
|
+ "AdminPageDescriptor annotation.",
|
||||||
|
descriptor.subPageOf().getName(),
|
||||||
|
parent.getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.join(
|
||||||
|
"/",
|
||||||
|
buildPath(parentDescriptor),
|
||||||
|
descriptor.path()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,22 @@ import org.libreccm.ui.admin.applications.ApplicationsPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "applications",
|
||||||
|
position = 10,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "applications.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "applications.description"
|
||||||
|
)
|
||||||
public class ApplicationsPage extends AdminPage {
|
public class ApplicationsPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@SuppressWarnings("OverridableMethodCallInConstructor")
|
@SuppressWarnings("OverridableMethodCallInConstructor")
|
||||||
public ApplicationsPage() {
|
public ApplicationsPage() {
|
||||||
super();
|
super();
|
||||||
add(new ApplicationsPanel("adminPanel"));
|
add(new ApplicationsPanel("adminPanel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.categories.CategoriesPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "categories",
|
||||||
|
position = 20,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "categories.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "categories.description"
|
||||||
|
)
|
||||||
public class CategoriesPage extends AdminPage {
|
public class CategoriesPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin;
|
package org.libreccm.ui.admin;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.wicket.cdi.CdiConfiguration;
|
import org.apache.wicket.cdi.CdiConfiguration;
|
||||||
import org.apache.wicket.markup.html.WebPage;
|
import org.apache.wicket.markup.html.WebPage;
|
||||||
import org.apache.wicket.protocol.http.WebApplication;
|
import org.apache.wicket.protocol.http.WebApplication;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -35,9 +40,12 @@ import javax.inject.Inject;
|
||||||
*/
|
*/
|
||||||
public class CcmAdmin extends WebApplication {
|
public class CcmAdmin extends WebApplication {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(CcmAdmin.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Instance<AdminPagesProvider> adminPages;
|
private Instance<AdminPagesProvider> adminPages;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends WebPage> getHomePage() {
|
public Class<? extends WebPage> getHomePage() {
|
||||||
return DashboardPage.class;
|
return DashboardPage.class;
|
||||||
|
|
@ -58,6 +66,11 @@ public class CcmAdmin extends WebApplication {
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (final AdminPageData adminPageData : adminPagesData) {
|
for (final AdminPageData adminPageData : adminPagesData) {
|
||||||
|
LOGGER.debug(
|
||||||
|
"Mounting page {} to path {}",
|
||||||
|
adminPageData.getPageClass().getName(),
|
||||||
|
adminPageData.getPath()
|
||||||
|
);
|
||||||
mountPage(adminPageData.getPath(), adminPageData.getPageClass());
|
mountPage(adminPageData.getPath(), adminPageData.getPageClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,5 +85,6 @@ public class CcmAdmin extends WebApplication {
|
||||||
// mountPage("users-groups-roles/roles", RolesPage.class);
|
// mountPage("users-groups-roles/roles", RolesPage.class);
|
||||||
// mountPage("users-groups-roles/users", UsersPage.class);
|
// mountPage("users-groups-roles/users", UsersPage.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,119 +18,35 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin;
|
package org.libreccm.ui.admin;
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.GroupsPage;
|
import org.libreccm.ui.admin.usersgroupsroles.GroupsPage;
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.RolesPage;
|
import org.libreccm.ui.admin.usersgroupsroles.RolesPage;
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.UsersPage;
|
import org.libreccm.ui.admin.usersgroupsroles.UsersPage;
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.enterprise.context.ApplicationScoped;
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class CcmCoreAdminPages implements AdminPagesProvider {
|
public class CcmCoreAdminPages extends AdminPagesProvider {
|
||||||
|
|
||||||
@Inject
|
|
||||||
private GlobalizationHelper globalizationHelper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<AdminPageData> getAdminPagesData() {
|
public Set<Class<? extends AdminPage>> getClasses() {
|
||||||
final ResourceBundle adminBundle = ResourceBundle.getBundle(
|
|
||||||
"org.libreccm.ui.admin.AdminBundle",
|
|
||||||
globalizationHelper.getNegotiatedLocale()
|
|
||||||
);
|
|
||||||
|
|
||||||
return Set.of(
|
return Set.of(
|
||||||
AdminPageDataBuilder
|
ApplicationsPage.class,
|
||||||
.forPage(ApplicationsPage.class)
|
CategoriesPage.class,
|
||||||
.mountedTo("applications")
|
ConfigurationPage.class,
|
||||||
.atPosition(10)
|
ImExportPage.class,
|
||||||
.withLabel(adminBundle, "applications.label")
|
PageModelsPage.class,
|
||||||
.withDescription(adminBundle, "applications.description")
|
SitesPage.class,
|
||||||
.build(),
|
SystemInformationPage.class,
|
||||||
AdminPageDataBuilder
|
UsersGroupsRolesPage.class,
|
||||||
.forPage(CategoriesPage.class)
|
GroupsPage.class,
|
||||||
.mountedTo("categories")
|
RolesPage.class,
|
||||||
.atPosition(20)
|
UsersPage.class
|
||||||
.withLabel(adminBundle, "categories.label")
|
|
||||||
.withDescription(adminBundle, "categories.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(ConfigurationPage.class)
|
|
||||||
.mountedTo("configuration")
|
|
||||||
.atPosition(30)
|
|
||||||
.withLabel(adminBundle, "configuration.label")
|
|
||||||
.withDescription(adminBundle, "configuration.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(ImExportPage.class)
|
|
||||||
.mountedTo("imexport")
|
|
||||||
.atPosition(40)
|
|
||||||
.withLabel(adminBundle, "imexport.label")
|
|
||||||
.withDescription(adminBundle, "imexport.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(ConfigurationPage.class)
|
|
||||||
.mountedTo("pagemodels")
|
|
||||||
.atPosition(50)
|
|
||||||
.withLabel(adminBundle, "pagemodels.label")
|
|
||||||
.withDescription(adminBundle, "pagemodels.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(SitesPage.class)
|
|
||||||
.mountedTo("sites")
|
|
||||||
.atPosition(60)
|
|
||||||
.withLabel(adminBundle, "sites.label")
|
|
||||||
.withDescription(adminBundle, "sites.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(SystemInformationPage.class)
|
|
||||||
.mountedTo("systeminformation")
|
|
||||||
.atPosition(70)
|
|
||||||
.withLabel(adminBundle, "systeminformation.label")
|
|
||||||
.withDescription(adminBundle, "systeminformation.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(UsersGroupsRolesPage.class)
|
|
||||||
.mountedTo("users-groups-roles")
|
|
||||||
.atPosition(80)
|
|
||||||
.withLabel(adminBundle, "usersGroupsRoles.label")
|
|
||||||
.withDescription(adminBundle, "usersGroupsRoles.description")
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(GroupsPage.class)
|
|
||||||
.mountedTo("users-groups-roles/groups")
|
|
||||||
.atPosition(90)
|
|
||||||
.withLabel(adminBundle, "usersGroupsRoles.groups.label")
|
|
||||||
.withDescription(
|
|
||||||
adminBundle, "usersGroupsRoles.groups.description"
|
|
||||||
)
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(RolesPage.class)
|
|
||||||
.mountedTo("users-groups-roles/roles")
|
|
||||||
.atPosition(100)
|
|
||||||
.withLabel(adminBundle, "usersGroupsRoles.roles.label")
|
|
||||||
.withDescription(
|
|
||||||
adminBundle, "usersGroupsRoles.roles.description"
|
|
||||||
)
|
|
||||||
.build(),
|
|
||||||
AdminPageDataBuilder
|
|
||||||
.forPage(UsersPage.class)
|
|
||||||
.mountedTo("users-groups-roles/users")
|
|
||||||
.atPosition(110)
|
|
||||||
.withLabel(adminBundle, "usersGroupsRoles.users.label")
|
|
||||||
.withDescription(
|
|
||||||
adminBundle, "usersGroupsRoles.users.description"
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.configuration.ConfigurationPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "configuration",
|
||||||
|
position = 30,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "configuration.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "configuration.description"
|
||||||
|
)
|
||||||
public class ConfigurationPage extends AdminPage {
|
public class ConfigurationPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.imexport.ImExportPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "imexport",
|
||||||
|
position = 40,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "imexport.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "imexport.description"
|
||||||
|
)
|
||||||
public class ImExportPage extends AdminPage {
|
public class ImExportPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.pagemodels.PageModelsPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "pagemodels",
|
||||||
|
position = 50,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "pagemodels.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "pagemodels.description"
|
||||||
|
)
|
||||||
public class PageModelsPage extends AdminPage {
|
public class PageModelsPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.sites.SitesPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "sites",
|
||||||
|
position = 60,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "sites.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "sites.description"
|
||||||
|
)
|
||||||
public class SitesPage extends AdminPage {
|
public class SitesPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.systeminformation.SystemInformationPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "systeminformation",
|
||||||
|
position = 70,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "systeminformation.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "systeminformation.description"
|
||||||
|
)
|
||||||
public class SystemInformationPage extends AdminPage {
|
public class SystemInformationPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ import org.libreccm.ui.admin.usersgroupsroles.UsersGroupsRolesPanel;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "users-groups-roles",
|
||||||
|
position = 80,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "usersGroupsRoles.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "usersGroupsRoles.description"
|
||||||
|
)
|
||||||
public class UsersGroupsRolesPage extends AdminPage {
|
public class UsersGroupsRolesPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,25 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin.usersgroupsroles;
|
package org.libreccm.ui.admin.usersgroupsroles;
|
||||||
|
|
||||||
|
import org.libreccm.ui.admin.AdminConstants;
|
||||||
import org.libreccm.ui.admin.AdminPage;
|
import org.libreccm.ui.admin.AdminPage;
|
||||||
|
import org.libreccm.ui.admin.AdminPageDescriptor;
|
||||||
|
import org.libreccm.ui.admin.UsersGroupsRolesPage;
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.groups.GroupsPanel;
|
import org.libreccm.ui.admin.usersgroupsroles.groups.GroupsPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "groups",
|
||||||
|
position = 20,
|
||||||
|
subPageOf = UsersGroupsRolesPage.class,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "usersGroupsRoles.groups.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "usersGroupsRoles.groups.description"
|
||||||
|
)
|
||||||
public class GroupsPage extends AdminPage {
|
public class GroupsPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,26 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin.usersgroupsroles;
|
package org.libreccm.ui.admin.usersgroupsroles;
|
||||||
|
|
||||||
|
import org.libreccm.ui.admin.AdminConstants;
|
||||||
import org.libreccm.ui.admin.AdminPage;
|
import org.libreccm.ui.admin.AdminPage;
|
||||||
|
import org.libreccm.ui.admin.AdminPageDescriptor;
|
||||||
|
import org.libreccm.ui.admin.UsersGroupsRolesPage;
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.roles.RolesPanel;
|
import org.libreccm.ui.admin.usersgroupsroles.roles.RolesPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "roles",
|
||||||
|
position = 30,
|
||||||
|
subPageOf = UsersGroupsRolesPage.class,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "usersGroupsRoles.roles.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "usersGroupsRoles.roles.description"
|
||||||
|
)
|
||||||
|
|
||||||
public class RolesPage extends AdminPage {
|
public class RolesPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,26 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.ui.admin.usersgroupsroles;
|
package org.libreccm.ui.admin.usersgroupsroles;
|
||||||
|
|
||||||
|
import org.libreccm.ui.admin.AdminConstants;
|
||||||
import org.libreccm.ui.admin.AdminPage;
|
import org.libreccm.ui.admin.AdminPage;
|
||||||
|
import org.libreccm.ui.admin.AdminPageDescriptor;
|
||||||
|
import org.libreccm.ui.admin.UsersGroupsRolesPage;
|
||||||
import org.libreccm.ui.admin.usersgroupsroles.users.UsersPanel;
|
import org.libreccm.ui.admin.usersgroupsroles.users.UsersPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AdminPageDescriptor(
|
||||||
|
path = "users",
|
||||||
|
position = 10,
|
||||||
|
subPageOf = UsersGroupsRolesPage.class,
|
||||||
|
labelBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
labelKey = "usersGroupsRoles.users.label",
|
||||||
|
descriptionBundle = AdminConstants.ADMIN_BUNDLE,
|
||||||
|
descriptionKey = "usersGroupsRoles.users.description"
|
||||||
|
)
|
||||||
|
|
||||||
public class UsersPage extends AdminPage {
|
public class UsersPage extends AdminPage {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue