diff --git a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java
index cfff37306..f0dff3026 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java
@@ -34,7 +34,7 @@ import javax.transaction.Transactional;
/**
* Model for table of content sections.
*
- * @see CmsController#getContentSections()
+ * @see ContentSectionsController#getContentSections()
*
* @author Jens Pelzetter
*/
diff --git a/ccm-cms/src/main/java/org/librecms/ui/PagesController.java b/ccm-cms/src/main/java/org/librecms/ui/PagesController.java
index 0566dd5e5..6d31214a5 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/PagesController.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/PagesController.java
@@ -18,11 +18,17 @@
*/
package org.librecms.ui;
+import org.libreccm.categorization.Domain;
+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.transaction.Transactional;
+import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
/**
@@ -35,9 +41,9 @@ import javax.ws.rs.Path;
public class PagesController {
/**
- * ToDo: Show UI for managing pages.
+ * Shows all available pages instances.
*
- * @return Placeholder
+ * @return The template to use.
*/
@GET
@Path("/")
@@ -46,4 +52,39 @@ public class PagesController {
return "org/librecms/ui/cms/pages.xhtml";
}
+ /**
+ * Creates a new {@link Pages} instance.
+ *
+ * @param siteParam The site for which the {@link Pages} instance
+ * is created.
+ * @param primaryUrlParam The primary URL/path of the pages instance.
+ * @param categoryDomainParam The category {@link Domain} to link with the
+ * {@link Pages} instance.
+ *
+ * @return Redirect to the list of {@link Pages} instances.
+ */
+ @POST
+ @Path("/@new")
+ @AuthorizationRequired
+ @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String createPagesInstance(
+ @FormParam("site") final String siteParam,
+ @FormParam("primaryUrl") final String primaryUrlParam,
+ @FormParam("categoryDomain") final String categoryDomainParam
+ ) {
+ // ToDo
+ throw new UnsupportedOperationException();
+ }
+
+ //ToDo: Update Pages instance
+ //ToDo: Delete Pages instance
+ //ToDo: Show details for Pages instance
+ //ToDo: Show details for page
+ //ToDo: Create Page for category
+ //ToDo: Edit Page for category
+ //ToDo: Remove page from category
+ //ToDo: Add page property
+ //ToDo: Edit page property
+ //ToDo: Remove page property
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/PagesTableModel.java b/ccm-cms/src/main/java/org/librecms/ui/PagesTableModel.java
new file mode 100644
index 000000000..296228684
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/PagesTableModel.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2021 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.librecms.ui;
+
+import org.libreccm.security.AuthorizationRequired;
+import org.librecms.pages.Pages;
+import org.librecms.pages.PagesRepository;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.transaction.Transactional;
+
+/**
+ * Model for the table of pages instances.
+ *
+ * @see PagesController#getPages()
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Named("CmsPagesTableModel")
+public class PagesTableModel {
+
+ /**
+ * Repository for pages.
+ */
+ @Inject
+ private PagesRepository pagesRepo;
+
+ /**
+ * Retrieves all available pages instances and builds a
+ * {@link PagesTableRow} for each pages instance.
+ *
+ * @return A list of {@link PagesTableRow}s.
+ */
+ @AuthorizationRequired
+ @Transactional(Transactional.TxType.REQUIRED)
+ public List getPages() {
+ return pagesRepo
+ .findAll()
+ .stream()
+ .map(this::buildTableRow)
+ .sorted()
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Helper method for building a {@link PagesTableRow} for a {@link Pages}
+ * instance.
+ *
+ * @param pages The pages instance to map to an {@link PagesTableRow}.
+ *
+ * @return A {@link PagesTableRow} for the pages instance.
+ */
+ private PagesTableRow buildTableRow(final Pages pages) {
+ final PagesTableRow row = new PagesTableRow();
+
+ row.setPagesId(pages.getObjectId());
+ row.setPrimaryUrl(pages.getPrimaryUrl());
+ row.setSite(pages.getSite().getDomainOfSite());
+
+ return row;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/PagesTableRow.java b/ccm-cms/src/main/java/org/librecms/ui/PagesTableRow.java
new file mode 100644
index 000000000..5670a2dde
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/PagesTableRow.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2021 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.librecms.ui;
+
+import java.util.Comparator;
+
+/**
+ * Model for a row in the {@link PagesTableModel}.
+ *
+ * @author Jens Pelzetter
+ */
+public class PagesTableRow implements Comparable{
+
+ private long pagesId;
+
+ private String site;
+
+ private String primaryUrl;
+
+ public long getPagesId() {
+ return pagesId;
+ }
+
+ public void setPagesId(final long pagesId) {
+ this.pagesId = pagesId;
+ }
+
+ public String getSite() {
+ return site;
+ }
+
+ public void setSite(final String site) {
+ this.site = site;
+ }
+
+ public String getPrimaryUrl() {
+ return primaryUrl;
+ }
+
+ public void setPrimaryUrl(final String primaryUrl) {
+ this.primaryUrl = primaryUrl;
+ }
+
+ @Override
+ public int compareTo(final PagesTableRow other) {
+ return Comparator
+ .comparing(PagesTableRow::getPrimaryUrl, String::compareTo)
+ .thenComparing(PagesTableRow::getSite, String::compareTo)
+ .thenComparing(PagesTableRow::getPagesId)
+ .compare(this, other);
+ }
+}