diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java
new file mode 100644
index 000000000..f18aa74d6
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationController.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public interface ApplicationController {
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationTypeInfoItem.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationTypeInfoItem.java
new file mode 100644
index 000000000..6c58dca64
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/ApplicationTypeInfoItem.java
@@ -0,0 +1,98 @@
+/*
+ * 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 java.util.Objects;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class ApplicationTypeInfoItem implements
+ Comparable {
+
+ private String name;
+
+ private String title;
+
+ private String description;
+
+ private boolean singleton;
+
+ private long numberOfInstances;
+
+ protected ApplicationTypeInfoItem() {
+ // Nothing
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ protected void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ protected void setTitle(final String title) {
+ this.title = title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ protected void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public boolean isSingleton() {
+ return singleton;
+ }
+
+ protected void setSingleton(final boolean singleton) {
+ this.singleton = singleton;
+ }
+
+ public long getNumberOfInstances() {
+ return numberOfInstances;
+ }
+
+ protected void setNumberOfInstances(final long numberOfInstances) {
+ this.numberOfInstances = numberOfInstances;
+ }
+
+ @Override
+ public int compareTo(final ApplicationTypeInfoItem other) {
+ if (other == null) {
+ return 1;
+ }
+
+ int result = Objects.compare(title, other.getTitle(), String::compareTo);
+ if (result == 0) {
+ result = Objects.compare(name, other.getName(), String::compareTo);
+ }
+
+ return result;
+ }
+
+}
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 0a9eff521..720442830 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
@@ -19,13 +19,25 @@
package org.libreccm.ui.admin.applications;
import org.libreccm.core.CoreConstants;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.libreccm.l10n.LocalizedTextsUtil;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
+import org.libreccm.web.ApplicationManager;
+import org.libreccm.web.ApplicationRepository;
+import org.libreccm.web.ApplicationType;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
import javax.mvc.Controller;
+import javax.mvc.Models;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
/**
*
@@ -35,12 +47,64 @@ import javax.ws.rs.Path;
@Controller
@Path("/applications")
public class ApplicationsController {
+
+ @Inject
+ private ApplicationManager appManager;
+ @Inject
+ private ApplicationRepository appRepository;
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Inject
+ private Models models;
+
@GET
@Path("/")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
- public String getApplications() {
- return "org/libreccm/ui/admin/applications.xhtml";
+ public String getApplicationTypes() {
+ final List appTypes = appManager
+ .getApplicationTypes()
+ .entrySet()
+ .stream()
+ .map(Map.Entry::getValue)
+ .map(this::buildTypeInfoItem)
+ .sorted()
+ .collect(Collectors.toList());
+
+ models.put("applicationTypes", appTypes);
+
+ return "org/libreccm/ui/admin/applications/applicationtypes.xhtml";
}
+
+ @GET
+ @Path("/{type}")
+ @AuthorizationRequired
+ @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
+ public String getApplicationInstances(
+ @PathParam("type") final String type
+ ) {
+ throw new UnsupportedOperationException();
+ }
+
+ private ApplicationTypeInfoItem buildTypeInfoItem(
+ final ApplicationType applicationType
+ ) {
+ final ApplicationTypeInfoItem item = new ApplicationTypeInfoItem();
+ item.setName(applicationType.name());
+
+ final LocalizedTextsUtil textsUtil = globalizationHelper
+ .getLocalizedTextsUtil(applicationType.descBundle());
+ item.setTitle(textsUtil.getText(applicationType.titleKey()));
+ item.setDescription(textsUtil.getText(applicationType.descKey()));
+ item.setSingleton(applicationType.singleton());
+ item.setNumberOfInstances(
+ appRepository.findByType(applicationType.name()).size()
+ );
+
+ return item;
+ }
+
}
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 185670232..48a7677c3 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
@@ -43,7 +43,7 @@ public class ApplicationsPage implements AdminPage {
@Override
public String getUriIdentifier() {
return String.format(
- "%s#getApplications", ApplicationsController.class.getSimpleName()
+ "%s#getApplicationTypes", ApplicationsController.class.getSimpleName()
);
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java
new file mode 100644
index 000000000..7f76e96a7
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/DefaultApplicationController.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class DefaultApplicationController implements ApplicationController {
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java b/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java
index 5c5019960..285b56225 100644
--- a/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java
+++ b/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java
@@ -23,8 +23,12 @@ import com.arsdigita.ui.admin.applications.AbstractAppSettingsPane;
import com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm;
import com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane;
+import org.libreccm.ui.admin.applications.ApplicationController;
+import org.libreccm.ui.admin.applications.DefaultApplicationController;
+
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -111,9 +115,12 @@ public @interface ApplicationType {
*
* @return
*/
+ @SuppressWarnings("rawtypes") // Can't specify type here, otherwise problems in using classes.
Class extends ApplicationCreator> creator();
Class extends AbstractAppInstanceForm> instanceForm() default DefaultApplicationInstanceForm.class;
+
+ Class extends ApplicationController> adminController() default DefaultApplicationController.class;
Class extends AbstractAppSettingsPane> settingsPane() default DefaultApplicationSettingsPane.class;
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
deleted file mode 100644
index 25c5db283..000000000
--- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/applications.xhtml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-