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
index 798f71912..3a7cacf61 100644
--- 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
@@ -19,7 +19,9 @@
package org.libreccm.ui.admin.applications;
/**
- *
+ * Interface for controllers providing the UI for managing the instances of
+ * an application.
+ *
* @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
index 862171648..2baa272ae 100644
--- 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
@@ -21,22 +21,45 @@ package org.libreccm.ui.admin.applications;
import java.util.Objects;
/**
+ * Data Transfer Object providing the information about an application. Used for
+ * rendering the informations the available applications in UI.
*
* @author Jens Pelzetter
*/
public class ApplicationTypeInfoItem implements
Comparable {
+ /**
+ * Name of the application.
+ */
private String name;
+ /**
+ * Localized title of the application, if available in the language of the
+ * current user.
+ */
private String title;
+ /**
+ * Localized title of the application, if available in the language of the
+ * current user.
+ */
private String description;
+ /**
+ * Is the application a singleton application?
+ */
private boolean singleton;
+ /**
+ * Number of existing instances of the application.
+ */
private long numberOfInstances;
-
+
+ /**
+ * Link the {@link ApplicationController} implementation of the application,
+ * if an implementation is available.
+ */
private String controllerLink;
protected ApplicationTypeInfoItem() {
@@ -82,11 +105,11 @@ public class ApplicationTypeInfoItem implements
protected void setNumberOfInstances(final long numberOfInstances) {
this.numberOfInstances = numberOfInstances;
}
-
+
public String getControllerLink() {
return controllerLink;
}
-
+
protected void setControllerLink(final String controllerLink) {
this.controllerLink = controllerLink;
}
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 8a5f4200f..4c62faf24 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,6 +40,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
+ * Controller for the UI for managing application instances.
*
* @author Jens Pelzetter
*/
@@ -60,9 +61,13 @@ public class ApplicationsController {
@Inject
private Models models;
-// @Inject
-// private MvcContext mvc;
-
+ /**
+ * Retrives the avaiable application types, creates
+ * {@link ApplicationTypeInfoItem}s for them and makes them available using
+ * {@link #models}.
+ *
+ * @return The template to render.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -83,6 +88,15 @@ public class ApplicationsController {
return "org/libreccm/ui/admin/applications/applicationtypes.xhtml";
}
+ /**
+ * Helper method for building an {@link ApplicationTypeInfoItem} for an
+ * {@link ApplicationType}.
+ *
+ * @param applicationType The application type.
+ *
+ * @return An {@link ApplicationTypeInfoItem} for the provided application
+ * type.
+ */
private ApplicationTypeInfoItem buildTypeInfoItem(
final ApplicationType applicationType
) {
@@ -101,15 +115,9 @@ public class ApplicationsController {
final Class extends ApplicationController> controllerClass
= applicationType.applicationController();
- if (!DefaultApplicationController.class
- .isAssignableFrom(controllerClass)) {
-// item.setControllerLink(
-// mvc.uri(
-// String.format(
-// "%s#getApplication", controllerClass.getSimpleName()
-// )
-// ).toString()
-// );
+ if (!DefaultApplicationController.class.isAssignableFrom(
+ controllerClass
+ )) {
item.setControllerLink(
String.format(
"%s#getApplication",
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 499a14483..f59dd840a 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
@@ -18,8 +18,6 @@
*/
package org.libreccm.ui.admin.applications;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import org.libreccm.ui.admin.AdminConstants;
import org.libreccm.ui.admin.AdminPage;
import org.libreccm.web.ApplicationManager;
@@ -32,7 +30,8 @@ import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
/**
- *
+ * {@link AdminPage} for managing applications.
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
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
index 126ed7f15..56a11f0b3 100644
--- 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
@@ -23,6 +23,10 @@ import javax.mvc.Controller;
import javax.ws.rs.Path;
/**
+ * A default implementation of the {@link ApplicationController} used if there
+ * is not implementation of the {@link ApplicationController} interface for an
+ * application.
+ *
*
* @author Jens Pelzetter
*/
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/applications/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/package-info.java
new file mode 100644
index 000000000..f8a9d5a4e
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/applications/package-info.java
@@ -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
+ */
+/**
+ * UI for managing application instances.
+ */
+package org.libreccm.ui.admin.applications;
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 b970811af..1c948edbe 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
@@ -50,6 +50,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
/**
+ * Primary controller for the UI for managing category systems and categories.
*
* @author Jens Pelzetter
*/
@@ -72,13 +73,20 @@ public class CategoriesController {
@Inject
private DomainRepository domainRepository;
-
+
@Inject
private IdentifierParser identifierParser;
@Inject
private Models models;
+ /**
+ * Show details about a category.
+ *
+ * @param categoryIdentifier Identifier of the category to show.
+ *
+ * @return The template to render.
+ */
@GET
@Path("/{categoryIdentifier}")
@AuthorizationRequired
@@ -120,6 +128,13 @@ public class CategoriesController {
}
}
+ /**
+ * Show the edit form for a category.
+ *
+ * @param categoryIdentifier Identifier of the category to edit.
+ *
+ * @return The template to render.
+ */
@GET
@Path("/{categoryIdentifier}/edit")
@AuthorizationRequired
@@ -161,6 +176,13 @@ public class CategoriesController {
}
}
+ /**
+ * Displays the form for creating a new subcategory.
+ *
+ * @param categoryIdentifier The identifier of the parent category.
+ *
+ * @return The template to render.
+ */
@GET
@Path("/{categoryIdentifier}/subcategories/new")
@AuthorizationRequired
@@ -202,6 +224,15 @@ public class CategoriesController {
}
}
+ /**
+ * Moves a category from one parent category to another. The target is
+ * provided
+ *
+ * @param categoryIdentifierParam Identifier of the category to move.
+ * @param targetIdentifierParam Identifier of the target category.
+ *
+ * @return Redirect to the detail page of the target category.
+ */
@POST
@Path("/{categoryIdentifier}/subcategories/move")
@AuthorizationRequired
@@ -286,6 +317,14 @@ public class CategoriesController {
);
}
+ /**
+ * Deletes a category.
+ *
+ * @param categoryIdentifier Identifier of the category to remove.
+ *
+ * @return Redirect to the details page of the parent category of the
+ * removed category.
+ */
@POST
@Path("/{categoryIdentifier}/subcategories/remove")
@AuthorizationRequired
@@ -341,6 +380,15 @@ public class CategoriesController {
}
}
+ /**
+ * Adds a localized title the a category.
+ *
+ * @param identifierParam Identifier of the category.
+ * @param localeParam The locale of the title.
+ * @param value The localized title.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}/title/add")
@AuthorizationRequired
@@ -390,6 +438,15 @@ public class CategoriesController {
}
}
+ /**
+ * Updates the localized title of a category.
+ *
+ * @param identifierParam Identifier of the category.
+ * @param localeParam The locale of the title.
+ * @param value The localized title.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}/title/{locale}/edit")
@AuthorizationRequired
@@ -439,6 +496,14 @@ public class CategoriesController {
}
}
+ /**
+ * Removes the localized title of a category.
+ *
+ * @param categoryIdentifierParam Identifier of the category.
+ * @param localeParam The locale of the title.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}/title/{locale}/remove")
@AuthorizationRequired
@@ -488,6 +553,15 @@ public class CategoriesController {
}
}
+ /**
+ * Adds a localized description the a category.
+ *
+ * @param identifierParam Identifier of the category.
+ * @param localeParam The locale of the description
+ * @param value The localized description.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}decsription/add")
@AuthorizationRequired
@@ -537,6 +611,15 @@ public class CategoriesController {
}
}
+ /**
+ * Updates the localized description the a category.
+ *
+ * @param identifierParam Identifier of the category.
+ * @param localeParam The locale of the description
+ * @param value The localized description.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}/description/{locale}/edit")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@@ -587,6 +670,14 @@ public class CategoriesController {
}
}
+ /**
+ * Removes a localized description the a category.
+ *
+ * @param identifierParam Identifier of the category.
+ * @param localeParam The locale of the description
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{identifier}/description/{locale}/remove")
@AuthorizationRequired
@@ -635,6 +726,16 @@ public class CategoriesController {
}
}
+ /**
+ * Changes the order of the subcategories of a category.
+ *
+ * @param categoryIdentifierParam Identifier of the category.
+ * @param subCategoryIdentifierParam Identifier of the sub category to move.
+ * @param direction The direction, either
+ * {@code INCREASE or DECREASE}.
+ *
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{categoryIdentifier}/subcategories/{subCategoryIdentifier}/reorder")
@AuthorizationRequired
@@ -724,7 +825,7 @@ public class CategoriesController {
)
);
}
-
+
if (category.getParentCategory() == null) {
final Optional categorySystem = domainRepository
.findByRootCategory(category);
@@ -735,7 +836,7 @@ public class CategoriesController {
);
} else {
return String.format(
- "redirect:categorymanager/categories/ID-%d",
+ "redirect:categorymanager/categories/ID-%d",
category.getObjectId()
);
}
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 7313df8ca..d4594658d 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
@@ -27,7 +27,9 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
- *
+ * {@link AdminPage} implementation for the UI for managing categories.
+ *
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java
index c34a21867..6ada58e99 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryDetailsModel.java
@@ -42,7 +42,8 @@ import javax.inject.Named;
import javax.transaction.Transactional;
/**
- *
+ * Model for the details of a category.
+ *
* @author Jens Pelzetter
*/
@RequestScoped
@@ -202,6 +203,11 @@ public class CategoryDetailsModel {
this.invalidFields = new HashSet<>(invalidFields);
}
+ /**
+ * Sets the model to the properties of the provided category.
+ *
+ * @param category The category.
+ */
@Transactional(Transactional.TxType.REQUIRED)
protected void setCategory(final Category category) {
Objects.requireNonNull(category);
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java
index 7582cca52..3ff5219bb 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryFormController.java
@@ -45,6 +45,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller processing the POST requests from the form for creating and
+ * editing categories.
*
* @author Jens Pelzetter
*/
@@ -67,7 +69,7 @@ public class CategoryFormController {
@Inject
private DomainRepository domainRepository;
-
+
@Inject
private IdentifierParser identifierParser;
@@ -86,6 +88,12 @@ public class CategoryFormController {
@FormParam("abstractCategory")
private String abstractCategory;
+ /**
+ * Create a new category.
+ *
+ * @param parentCategoryIdentifier Identifier of the parent category.
+ * @return Redirect to the details page of the parent category.
+ */
@POST
@Path("/{parentCategoryIdentifier}/new")
@AuthorizationRequired
@@ -135,9 +143,9 @@ public class CategoryFormController {
);
} else {
return String.format(
- "redirect:categorymanager/categories/ID-%d",
- parentCategory.getObjectId()
- );
+ "redirect:categorymanager/categories/ID-%d",
+ parentCategory.getObjectId()
+ );
}
} else {
return String.format(
@@ -158,6 +166,12 @@ public class CategoryFormController {
}
}
+ /**
+ * Updates a category with the data from the form.
+ *
+ * @param categoryIdentifierParam Identifier of the category to update.
+ * @return Redirect to the details page of the category.
+ */
@POST
@Path("/{categoryIdentifier}/edit")
@AuthorizationRequired
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java
index 3ff21db32..d915b3426 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryNodeModel.java
@@ -21,7 +21,8 @@ package org.libreccm.ui.admin.categories;
import java.util.Objects;
/**
- *
+ * A DTO with the of a category shown in the UI.
+ *
* @author Jens Pelzetter
*/
public class CategoryNodeModel implements Comparable {
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java
index 181bb8ea1..c50c2df55 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryPathModel.java
@@ -23,7 +23,8 @@ import java.util.Collections;
import java.util.List;
/**
- *
+ * Model for displaying the path of category in the UI.
+ *
* @author Jens Pelzetter
*/
public class CategoryPathModel {
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java
index 9dbc13ed9..2c136f59f 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java
@@ -46,7 +46,10 @@ import javax.inject.Named;
import javax.transaction.Transactional;
/**
- *
+ * Model for the details of a category system (Domain)
+ *
+ * @see org.libreccm.categorization.Domain
+ *
* @author Jens Pelzetter
*/
@RequestScoped
@@ -227,6 +230,10 @@ public class CategorySystemDetailsModel {
this.invalidFields = new HashSet<>(invalidFields);
}
+ /**
+ * Sets the properties of this model using the provided {@link Domain}.
+ * @param domain The domain to display.
+ */
@Transactional(Transactional.TxType.REQUIRED)
protected void setCategorySystem(final Domain domain) {
Objects.requireNonNull(domain);
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java
index b476c6015..8d491c256 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemFormController.java
@@ -47,6 +47,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for processing the {@code POST} requests from the form for
+ * creating and editing category systems.
*
* @author Jens Pelzetter
*/
@@ -82,6 +84,11 @@ public class CategorySystemFormController {
@FormParam("released")
private String released;
+ /**
+ * Creates a new category system (domain).
+ *
+ * @return Redirect to the list of category systems.
+ */
@POST
@Path("/new")
@AuthorizationRequired
@@ -117,6 +124,13 @@ public class CategorySystemFormController {
return "redirect:/categorymanager/categorysystems";
}
+ /**
+ * Update a category with the data from the form.
+ *
+ * @param identifierParam Identifier of the category system to update.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("{categorySystemIdentifier}/edit")
@AuthorizationRequired
@@ -191,6 +205,12 @@ public class CategorySystemFormController {
}
}
+ /**
+ * Helper method for converting the {@link #released} date to an ISO 8601
+ * formatted string.
+ *
+ * @return The released date in ISO 8601 format.
+ */
private LocalDate convertReleased() {
return LocalDate.parse(
released,
@@ -198,6 +218,11 @@ public class CategorySystemFormController {
);
}
+ /**
+ * Helper method for validating a URI.
+ *
+ * @return {@code true} if the URI is valid, {@code false} otherwise.
+ */
private boolean isValidUri() {
final UrlValidator urlValidator = new UrlValidator();
return urlValidator.isValid(uri);
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerOption.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerOption.java
index f0947a8f7..a0362daf3 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerOption.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerOption.java
@@ -23,7 +23,8 @@ import org.libreccm.web.CcmApplication;
import java.util.Objects;
/**
- *
+ * DTO for the options for selecting the owner applications of a category system.
+ *
* @author Jens Pelzetter
*/
public class CategorySystemOwnerOption
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerRow.java
index a7ac37117..c258b2619 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerRow.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemOwnerRow.java
@@ -19,7 +19,8 @@
package org.libreccm.ui.admin.categories;
/**
- *
+ * Data for a row in the table of owner applications of a category system.
+ *
* @author Jens Pelzetter
*/
public class CategorySystemOwnerRow
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemTableRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemTableRow.java
index 1ae934808..3cf5693b4 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemTableRow.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemTableRow.java
@@ -24,7 +24,8 @@ import java.util.Map;
import java.util.Objects;
/**
- *
+ * Data for a row in the table of category systems.
+ *
* @author Jens Pelzetter
*/
public class CategorySystemTableRow implements
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java
index c4f6c4e87..b70335f61 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsController.java
@@ -49,6 +49,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for the UI for managing category systems.
*
* @author Jens Pelzetter
*/
@@ -78,13 +79,11 @@ public class CategorySystemsController {
@Inject
private Models models;
-// @GET
-// @Path("/")
-// @AuthorizationRequired
-// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
-// public String getCategoryManager() {
-// return getCategorySystems();
-// }
+ /**
+ * Show a list of all available category systems.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -93,6 +92,14 @@ public class CategorySystemsController {
return "org/libreccm/ui/admin/categories/categorysystems.xhtml";
}
+ /**
+ * Display the details of a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system to
+ * show.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/{categorySystemIdentifier}/details")
@AuthorizationRequired
@@ -141,6 +148,11 @@ public class CategorySystemsController {
}
}
+ /**
+ * Show the form for creating a new category system.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/new")
@AuthorizationRequired
@@ -149,6 +161,14 @@ public class CategorySystemsController {
return "org/libreccm/ui/admin/categories/categorysystem-form.xhtml";
}
+ /**
+ * Edit a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system to
+ * edit.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/{categorySystemIdentifier}/edit")
@AuthorizationRequired
@@ -198,6 +218,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Delete a category system and all its categories.
+ *
+ * @param categorySystemIdentifier Identifier of the category system to
+ * delete.
+ * @param confirmed Was the deletion confirmed by the user?
+ *
+ * @return Redirect to the categorysystems overview.
+ */
@POST
@Path("/{categorySystemIdentifier}/delete")
@AuthorizationRequired
@@ -250,6 +279,15 @@ public class CategorySystemsController {
return "redirect:categorymanager/categorysystems";
}
+ /**
+ * Adds a localized title the a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the title.
+ * @param value The localized title.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{identifier}/title/add")
@AuthorizationRequired
@@ -306,6 +344,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Updates a localized title the a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the title.
+ * @param value The localized title.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{identifier}/title/${locale}/edit")
@AuthorizationRequired
@@ -362,6 +409,14 @@ public class CategorySystemsController {
}
}
+ /**
+ * Removes a localized title the a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the title.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{identifier}/title/${locale}/remove")
@AuthorizationRequired
@@ -422,6 +477,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Adds a localized description the a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the description.
+ * @param value The localized description.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{identifier}/description/add")
@AuthorizationRequired
@@ -478,6 +542,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Updates a localized description the a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the description.
+ * @param value The localized description.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path(
"categorysystems/{identifier}/description/${locale}/edit"
@@ -536,6 +609,14 @@ public class CategorySystemsController {
}
}
+ /**
+ * Removes a localized description of a category system.
+ *
+ * @param categorySystemIdentifier Identifier of the category system.
+ * @param localeParam The locale of the description.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path(
"categorysystems/{identifier}/description/${locale}/remove")
@@ -596,6 +677,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Adds an owner to a category system.
+ *
+ * @param categorySystemIdentifier Identifier of teh category system.
+ * @param applicationUuid UUID of the new owner.
+ * @param context An optional context.
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{categorySystemIdentifier}/owners/add")
@AuthorizationRequired
@@ -675,6 +765,15 @@ public class CategorySystemsController {
}
}
+ /**
+ * Remove an owner from a category system.
+ *
+ * @param categorySystemIdentifier Identifier of teh category system.
+ * @param applicationUuid UUID of the owner to remove.
+ * @param confirmed Was the deletion confirmed by the user?
+ *
+ * @return Redirect to the details page of the category system.
+ */
@POST
@Path("/{categorySystemIdentifier}/owners/${applicationUuid}/remove")
@AuthorizationRequired
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsTableModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsTableModel.java
index 516bb12be..62d56642c 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsTableModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemsTableModel.java
@@ -38,6 +38,11 @@ import javax.transaction.Transactional;
*
* @author Jens Pelzetter
*/
+/**
+ * Model providing the data for the table of category systems.
+ *
+ * @author Jens Pelzetter
+ */
@RequestScoped
@Named("CategorySystemsTableModel")
public class CategorySystemsTableModel {
@@ -45,6 +50,13 @@ public class CategorySystemsTableModel {
@Inject
private DomainRepository domainRepository;
+ /**
+ * Get all available category systems
+ *
+ * @return A list of
+ * {@link org.libreccm.ui.admin.categories.CategorySystemTableRow}
+ * items, one for each available category.
+ */
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional
@@ -57,6 +69,16 @@ public class CategorySystemsTableModel {
.collect(Collectors.toList());
}
+ /**
+ * Helper method for building a
+ * {@link org.libreccm.ui.admin.categories.CategorySystemTableRow} instance
+ * for a category system.
+ *
+ * @param domain The domain (category system) to convert.
+ *
+ * @return A {@link org.libreccm.ui.admin.categories.CategorySystemTableRow}
+ * instance for the category.
+ */
private CategorySystemTableRow buildTableRow(final Domain domain) {
final CategorySystemTableRow row = new CategorySystemTableRow();
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java
index b5ec284f1..e48aada08 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/DomainNodeModel.java
@@ -18,7 +18,10 @@
*/
package org.libreccm.ui.admin.categories;
+import org.libreccm.categorization.Domain;
+
/**
+ * DTO with the data about a {@link Domain} shown in the UI.
*
* @author Jens Pelzetter
*/
@@ -37,11 +40,11 @@ public class DomainNodeModel {
protected void setDomainId(final long domainId) {
this.domainId = domainId;
}
-
+
public String getIdentifier() {
return String.format("ID-%s", domainId);
}
-
+
public String getUuid() {
return uuid;
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/package-info.java
new file mode 100644
index 000000000..8a48ddc23
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/package-info.java
@@ -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
+ */
+/**
+ * UI for managing category systems (domains) and categories.
+ */
+package org.libreccm.ui.admin.categories;
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 a6ab323c2..1a6028cc6 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
@@ -38,6 +38,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
+ * Controller for the UI for managing the configuration of CCM.
*
* @author Jens Pelzetter
*/
@@ -51,10 +52,15 @@ public class ConfigurationController {
@Inject
private GlobalizationHelper globalizationHelper;
-
+
@Inject
private Models models;
+ /**
+ * Show all available configurations (groups of settings).
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -69,10 +75,20 @@ public class ConfigurationController {
.collect(Collectors.toList());
models.put("configurationClasses", configurationClasses);
-
+
return "org/libreccm/ui/admin/configuration/configuration.xhtml";
}
+ /**
+ * Helper method for converting a
+ * {@link org.libreccm.configuration.ConfigurationInfo} instance into a
+ * {@link org.libreccm.ui.admin.configuration.ConfigurationTableEntry}
+ * instance.
+ *
+ * @param confInfo Configuration info to convert.
+ *
+ * @return A {@link ConfigurationTableEntry} for the configuration.
+ */
private ConfigurationTableEntry buildTableEntry(
final ConfigurationInfo confInfo
) {
@@ -83,7 +99,7 @@ public class ConfigurationController {
.getLocalizedTextsUtil(confInfo.getDescBundle());
entry.setTitle(util.getText(confInfo.getTitleKey()));
entry.setDescription(util.getText(confInfo.getDescKey()));
-
+
return entry;
}
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 1a0f38922..1b0020b94 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
@@ -27,12 +27,15 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
+ * {@link AdminPage} implementation providing the UI for managing the
+ * configuration of CCM.
*
* @author Jens Pelzetter
*/
@ApplicationScoped
public class ConfigurationPage implements AdminPage {
- @Override
+
+ @Override
public Set> getControllerClasses() {
final Set> classes = new HashSet<>();
classes.add(ConfigurationController.class);
@@ -59,7 +62,7 @@ public class ConfigurationPage implements AdminPage {
@Override
public String getDescriptionBundle() {
- return AdminConstants.ADMIN_BUNDLE;
+ return AdminConstants.ADMIN_BUNDLE;
}
@Override
@@ -76,4 +79,5 @@ public class ConfigurationPage implements AdminPage {
public int getPosition() {
return 30;
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationTableEntry.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationTableEntry.java
index 9879542a5..b713dfd9e 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationTableEntry.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/ConfigurationTableEntry.java
@@ -21,7 +21,8 @@ package org.libreccm.ui.admin.configuration;
import java.util.Objects;
/**
- *
+ * A row in the table of available configurations.
+ *
* @author Jens Pelzetter
*/
public class ConfigurationTableEntry
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsController.java
index 68ac0b7bd..04b17048b 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsController.java
@@ -54,7 +54,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
- *
+ * Controller for the UI for viewing and editing settings.
+ *
* @author Jens Pelzetter
*/
@Controller
@@ -78,6 +79,12 @@ public class SettingsController {
@Inject
private SettingManager settingManager;
+ /**
+ * Show all settings of a configuration.
+ *
+ * @param configurationClass The configuration class
+ * @return The template to use.
+ */
@GET
@Path("/")
@Transactional(Transactional.TxType.REQUIRED)
@@ -146,6 +153,13 @@ public class SettingsController {
return "org/libreccm/ui/admin/configuration/settings.xhtml";
}
+ /**
+ * Helper method for building a {@link SettingsTableEntry} for a setting.
+ *
+ * @param settingInfo The setting to convert.
+ * @param configuration The configuration to which the settings belongs.
+ * @return A {@link SettingsTableEntry} for the setting.
+ */
@Transactional(Transactional.TxType.REQUIRED)
private SettingsTableEntry buildSettingsTableEntry(
final SettingInfo settingInfo,
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsTableEntry.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsTableEntry.java
index bf83bb223..bf723f1dd 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsTableEntry.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/SettingsTableEntry.java
@@ -21,7 +21,8 @@ package org.libreccm.ui.admin.configuration;
import java.util.Objects;
/**
- *
+ * Data for row in the table of settings of a configuration.
+ *
* @author Jens Pelzetter
*/
public class SettingsTableEntry implements Comparable {
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/package-info.java
new file mode 100644
index 000000000..b17aa4980
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/configuration/package-info.java
@@ -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
+ */
+/**
+ * UI for editing the configuration of LibreCCM.
+ */
+package org.libreccm.ui.admin.configuration;
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 d651b3453..efadf444b 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
@@ -28,7 +28,8 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
- *
+ * Controller for the dashboard page (start page) of the Admin UI:
+ *
* @author Jens Pelzetter
*/
@RequestScoped
@@ -36,6 +37,11 @@ import javax.ws.rs.Path;
@Path("/")
public class DashboardController {
+ /**
+ * Show the dashboard page.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
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 51276a54a..42dde7292 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,7 +20,6 @@ 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;
@@ -28,12 +27,14 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
+ * {@link AdminPage} implementation for the dashboard page.
*
* @author Jens Pelzetter
*/
@ApplicationScoped
public class DashboardPage implements AdminPage {
- @Override
+
+ @Override
public Set> getControllerClasses() {
final Set> classes = new HashSet<>();
classes.add(DashboardController.class);
@@ -59,7 +60,7 @@ public class DashboardPage implements AdminPage {
@Override
public String getDescriptionBundle() {
- return AdminConstants.ADMIN_BUNDLE;
+ return AdminConstants.ADMIN_BUNDLE;
}
@Override
@@ -76,4 +77,5 @@ public class DashboardPage implements AdminPage {
public int getPosition() {
return 0;
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/package-info.java
new file mode 100644
index 000000000..362349c53
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/dashboard/package-info.java
@@ -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
+ */
+/**
+ * Start page of the Admin UI.
+ */
+package org.libreccm.ui.admin.dashboard;
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTask.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTask.java
index 6ecbc907e..b4fb8d8c2 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTask.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTask.java
@@ -25,17 +25,30 @@ import java.util.Collection;
import java.util.Collections;
/**
- *
+ * Data for an export task.
+ *
* @author Jens Pelzetter
*/
public class ExportTask {
+ /**
+ * Name of the export archive.
+ */
private final String name;
+ /**
+ * When was the export task started?
+ */
private final LocalDate started;
+ /**
+ * The entities to export.
+ */
private final Collection entities;
+ /**
+ * The status of the export task.
+ */
private final ExportTaskStatus status;
public ExportTask(
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTaskStatus.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTaskStatus.java
index 2e63bbd16..0a1168e1b 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTaskStatus.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ExportTaskStatus.java
@@ -25,17 +25,30 @@ import java.util.Comparator;
import java.util.Objects;
/**
- *
+ * Status of an export task.
+ *
* @author Jens Pelzetter
*/
public class ExportTaskStatus implements Comparable {
+ /**
+ * Name of the export archive.
+ */
private String name;
+ /**
+ * When was the task started?
+ */
private LocalDateTime started;
+ /**
+ * Status of the export task.
+ */
private ImExportTaskStatus status;
+ /**
+ * If the proces throw an exception, it is stored here.
+ */
private Throwable exception;
public String getName() {
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 8d96f650c..7afe02994 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
@@ -41,11 +41,11 @@ import javax.mvc.Controller;
import javax.mvc.Models;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
-import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
/**
+ * Controller for the Import/Export UI.
*
* @author Jens Pelzetter
*/
@@ -63,6 +63,12 @@ public class ImExportController {
@Inject
private Models models;
+ /**
+ * Provides the main page with an overview of all running import/export
+ * processes.
+ *
+ * @return
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -71,6 +77,11 @@ public class ImExportController {
return "org/libreccm/ui/admin/imexport/imexport.xhtml";
}
+ /**
+ * UI for starting exports.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/export")
@AuthorizationRequired
@@ -99,6 +110,14 @@ public class ImExportController {
return "org/libreccm/ui/admin/imexport/export.xhtml";
}
+ /**
+ * Starts an export.
+ *
+ * @param selectedEntitiesParam The entity types selected for export.
+ * @param exportName The name of the export archive.
+ *
+ * @return Redirect to the main import/export page.
+ */
@POST
@Path("/export")
@AuthorizationRequired
@@ -135,6 +154,11 @@ public class ImExportController {
return "redirect:imexport";
}
+ /**
+ * Displays the import page that allows to select a import archive.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/import")
@AuthorizationRequired
@@ -157,6 +181,13 @@ public class ImExportController {
return "org/libreccm/ui/admin/imexport/import.xhtml";
}
+ /**
+ * Execute an import.
+ *
+ * @param importArchive The name of the import archive to use.
+ *
+ * @return Redirect to to the main import/export page.
+ */
@POST
@Path("/import")
@AuthorizationRequired
@@ -169,10 +200,34 @@ public class ImExportController {
return "redirect:imexport";
}
+ /**
+ * Merge function for {@link Collectors#toMap(java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator, java.util.function.Supplier).
+ *
+ * @param str1 First key
+ * @param str2 Second key
+ *
+ * @return First key.
+ *
+ * @throws RuntimeException if both keys are equal.
+ */
private String noDuplicateKeys(final String str1, final String str2) {
- throw new RuntimeException("No duplicate keys allowed.");
+ if (str1.equals(str2)) {
+ throw new RuntimeException("No duplicate keys allowed.");
+ } else {
+ return str1;
+ }
}
+ /**
+ * Helper method for adding required entities to an export task. Some entity
+ * types require also other entity types. This method traverses through the
+ * selected entity types of an export and adds required entity types if
+ * necessary.
+ *
+ * @param selectedNodes The selected entity types.
+ *
+ * @return The final list of exported types.
+ */
private Set addRequiredEntities(
final Set selectedNodes
) {
@@ -196,6 +251,16 @@ public class ImExportController {
}
}
+ /**
+ * Helper function to build an
+ * {@link org.libreccm.ui.admin.imexport.ImportOption} instance from a
+ * {@link org.libreccm.imexport.ImportManifest}.
+ *
+ * @param manifest The manifest to map to a
+ * {@link org.libreccm.ui.admin.imexport.ImportOption}.
+ *
+ * @return An {@link org.libreccm.ui.admin.imexport.ImportOption} instance.
+ */
private ImportOption buildImportOption(final ImportManifest manifest) {
return new ImportOption(
manifest.getImportName(),
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 e41b58555..2b00defd0 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
@@ -27,7 +27,8 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
- *
+ * Provides the UI for importing and exporting entities.
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTaskStatus.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTaskStatus.java
index 1e127b578..9b9b4de8e 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTaskStatus.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTaskStatus.java
@@ -19,13 +19,23 @@
package org.libreccm.ui.admin.imexport;
/**
- *
+ * Enumeration for the possible states of an export or import task.
+ *
* @author Jens Pelzetter
*/
public enum ImExportTaskStatus {
+ /**
+ * An error occured during the process.
+ */
ERROR,
+ /**
+ * The import or export task is finished.
+ */
FINISHED,
+ /**
+ * The task is still running.
+ */
RUNNING,
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTasks.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTasks.java
index 1804a5c59..4e7722729 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTasks.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImExportTasks.java
@@ -29,6 +29,8 @@ import javax.inject.Inject;
import javax.transaction.Transactional;
/**
+ * Listens for CDI events fired by {@link org.libreccm.ui.admin.imexport.ImportExportTaskManager}
+ * and executes tasks.
*
* @author Jens Pelzetter
*/
@@ -38,23 +40,33 @@ public class ImExportTasks {
@Inject
private ImportExport importExport;
-
+ /**
+ * Listens for {@link org.libreccm.ui.admin.imexport.ExportTask}s.
+ *
+ * @param task The task to execute.
+ * @return The task.
+ */
@Transactional(Transactional.TxType.REQUIRED)
public ExportTask exportEntities(@ObservesAsync final ExportTask task) {
final Collection entities = task.getEntities();
final String exportName = task.getName();
-
+
importExport.exportEntities(entities, exportName);
task.getStatus().setStatus(ImExportTaskStatus.FINISHED);
return task;
}
-
+
+ /**
+ * Listens for {@link org.libreccm.ui.admin.imexport.ImportTask}s.
+ *
+ * @param task The task to execute.
+ * @return The task.
+ */
@Transactional(Transactional.TxType.REQUIRED)
public void importEntitites(@ObservesAsync final ImportTask task) {
final String importName = task.getName();
-
+
importExport.importEntities(importName);
}
-
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportExportTaskManager.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportExportTaskManager.java
index b9bd1e56c..23a93d3b9 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportExportTaskManager.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportExportTaskManager.java
@@ -30,6 +30,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
import javax.ejb.Schedule;
import javax.enterprise.context.ApplicationScoped;
@@ -43,6 +44,7 @@ import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
/**
+ * Provides the backend for importing and exporting entities.
*
* @author Jens Pelzetter
*/
@@ -54,17 +56,34 @@ public class ImportExportTaskManager {
ImportExportTaskManager.class
);
+ /**
+ * Entity manager used for some special queries. To execute import and
+ * export tasks concurrently CDI events are used which are processed by the
+ * {@link ImExportTasks} class.
+ */
@Inject
private EntityManager entityManager;
+ /**
+ * CDI event sender for export tasks.
+ */
@Inject
private Event exportTaskSender;
+ /**
+ * CDI event sender for import tasks.
+ */
@Inject
private Event importTaskSender;
+ /**
+ * Status of all active export tasks.
+ */
private final SortedSet exportTasks;
+ /**
+ * Status of all active import tasks.
+ */
private final SortedSet importTasks;
public ImportExportTaskManager() {
@@ -80,14 +99,31 @@ public class ImportExportTaskManager {
);
}
+ /**
+ * Returns the active export tasks.
+ *
+ * @return All active export tasks.
+ */
public SortedSet getExportTasks() {
return Collections.unmodifiableSortedSet(exportTasks);
}
+ /**
+ * Returns the active import tasks.
+ *
+ * @return All active import tasks.
+ */
public SortedSet getImportTasks() {
return Collections.unmodifiableSortedSet(importTasks);
}
+ /**
+ * Export all entities of the selected entity types.
+ *
+ * @param exportTypes The entity types to export.
+ * @param exportName Name of the export archive.
+ *
+ */
@Transactional(Transactional.TxType.REQUIRED)
public void exportEntities(
final Set> exportTypes,
@@ -107,7 +143,7 @@ public class ImportExportTaskManager {
taskStatus.setStarted(LocalDateTime.now());
exportTaskSender.fireAsync(
new ExportTask(exportName, LocalDate.now(), entities, taskStatus)
- ).handle((task , ex) -> handleExportTaskResult(task, ex, taskStatus));
+ ).handle((task, ex) -> handleExportTaskResult(task, ex, taskStatus));
taskStatus.setStatus(ImExportTaskStatus.RUNNING);
exportTasks.add(taskStatus);
@@ -119,18 +155,32 @@ public class ImportExportTaskManager {
importTaskSender.fireAsync(
new ImportTask(importName, LocalDate.now(), taskStatus)
).handle((task, ex) -> handleImportTaskResult(task, ex, taskStatus));
-
+
taskStatus.setStatus(ImExportTaskStatus.RUNNING);
importTasks.add(taskStatus);
}
+ /**
+ * Called every 5 minutes to remove finished tasks from {@link #exportTasks}
+ * and and {@link #importTasks}.
+ */
@Schedule(hour = "*", minute = "*/5", persistent = false)
protected void removeFinishedTasks() {
- exportTasks.removeIf(taskStatus -> taskStatus.getStatus() == ImExportTaskStatus.FINISHED);
-// importTasks.removeIf(taskStatus -> taskStatus.getStatus() == ImExportTaskStatus.FINISHED);
+ exportTasks.removeIf(
+ taskStatus -> taskStatus.getStatus() == ImExportTaskStatus.FINISHED
+ );
+ importTasks.removeIf(
+ taskStatus -> taskStatus.getStatus() == ImExportTaskStatus.FINISHED
+ );
}
-
+ /**
+ * Collects the entities of the provided types for exporting.
+ *
+ * @param ofType The entity type.
+ *
+ * @return All entities of the provided type.
+ */
private Set extends Exportable> collectEntities(
final Class ofType
) {
@@ -145,6 +195,19 @@ public class ImportExportTaskManager {
);
}
+ /**
+ * Handler function for processing the result of an export tasks.
+ *
+ * @param task The task.
+ * @param ex Exception thrown during the export process. If the export
+ * process run without errors, this parameter will be
+ * {@code null}.
+ * @param status The status of the task.
+ *
+ * @return The task.
+ *
+ * @see CompletionStage#handle(java.util.function.BiFunction)
+ */
private Object handleExportTaskResult(
final ExportTask task, final Throwable ex, final ExportTaskStatus status
) {
@@ -159,6 +222,19 @@ public class ImportExportTaskManager {
return task;
}
+ /**
+ * Handler function for processing the result of an import tasks.
+ *
+ * @param task The task.
+ * @param ex Exception thrown during the import process. If the import
+ * process run without errors, this parameter will be
+ * {@code null}.
+ * @param status The status of the task.
+ *
+ * @return The task.
+ *
+ * @see CompletionStage#handle(java.util.function.BiFunction)
+ */
private Object handleImportTaskResult(
final ImportTask task, final Throwable ex, final ImportTaskStatus status
) {
@@ -172,4 +248,5 @@ public class ImportExportTaskManager {
}
return task;
}
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportOption.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportOption.java
index 6ffee8514..a62f73a74 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportOption.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportOption.java
@@ -18,16 +18,26 @@
*/
package org.libreccm.ui.admin.imexport;
+import org.libreccm.imexport.ImportManifest;
+
import java.util.Objects;
/**
+ * Provides a preprocessed {@link ImportManifest} for easier use in a template.
*
* @author Jens Pelzetter
*/
public class ImportOption implements Comparable {
+ /**
+ * Name of the import.
+ */
private final String importName;
+ /**
+ * Label of the import, includes the relevant data from the
+ * {@link ImportManifest}.
+ */
private final String label;
public ImportOption(
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTask.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTask.java
index 2ea5bc252..d3a9d217f 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTask.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTask.java
@@ -21,15 +21,25 @@ package org.libreccm.ui.admin.imexport;
import java.time.LocalDate;
/**
+ * Data for an import task.
*
* @author Jens Pelzetter
*/
public class ImportTask {
+ /**
+ * Name of the import archive.
+ */
private final String name;
+ /**
+ * When was the import task started?
+ */
private final LocalDate started;
+ /**
+ * The status of the import task.
+ */
private final ImportTaskStatus status;
public ImportTask(
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTaskStatus.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTaskStatus.java
index 8ec1ea92b..db9509f6c 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTaskStatus.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/ImportTaskStatus.java
@@ -25,24 +25,36 @@ import java.util.Comparator;
import java.util.Objects;
/**
+ * Status of an import task.
*
* @author Jens Pelzetter
*/
public class ImportTaskStatus implements Comparable {
+ /**
+ * Name of the import archive.
+ */
private String name;
+ /**
+ * When was the task started?
+ */
private LocalDateTime started;
+ /**
+ * Status of the import task.
+ */
private ImExportTaskStatus status;
-
+
+ /**
+ * If the proces throw an exception, it is stored here.
+ */
private Throwable exception;
public String getName() {
return name;
}
-
protected void setName(final String name) {
this.name = name;
}
@@ -62,8 +74,8 @@ public class ImportTaskStatus implements Comparable {
protected void setStatus(final ImExportTaskStatus status) {
this.status = status;
}
-
- public Throwable getException() {
+
+ public Throwable getException() {
return exception;
}
@@ -71,7 +83,7 @@ public class ImportTaskStatus implements Comparable {
this.exception = exception;
}
- @Override
+ @Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + Objects.hashCode(name);
@@ -104,7 +116,6 @@ public class ImportTaskStatus implements Comparable {
return status == other.getStatus();
}
-
public boolean canEqual(final Object obj) {
return obj instanceof ImportTaskStatus;
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/package-info.java
new file mode 100644
index 000000000..011755e60
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/imexport/package-info.java
@@ -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
+ */
+/**
+ * UI for importing and exporting entities.
+ */
+package org.libreccm.ui.admin.imexport;
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteDetailsModel.java
index 60fd9b9d1..c3c3041c6 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteDetailsModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteDetailsModel.java
@@ -22,7 +22,6 @@ import org.libreccm.sites.Site;
import org.libreccm.theming.ThemeInfo;
import org.libreccm.ui.Message;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -33,6 +32,7 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
+ * Model providing the properties of a site for the UI.
*
* @author Jens Pelzetter
*/
@@ -96,6 +96,12 @@ public class SiteDetailsModel {
messages.add(message);
}
+ /**
+ * Set the properties of this model to the values of the properties of the
+ * provided site.
+ *
+ * @param site The site.
+ */
protected void setSite(final Site site) {
Objects.requireNonNull(site);
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteFormController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteFormController.java
index a99e8fd03..9343f8c45 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteFormController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteFormController.java
@@ -42,6 +42,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for processing the {@code POST} requests from the form for
+ * creating and editing sites.
*
* @author Jens Pelzetter
*/
@@ -71,6 +73,11 @@ public class SiteFormController {
@FormParam("defaultTheme")
private String defaultTheme;
+ /**
+ * Create a new site.
+ *
+ * @return Redirect to the sites overview.
+ */
@POST
@Path("/new")
@AuthorizationRequired
@@ -90,6 +97,12 @@ public class SiteFormController {
return "redirect:sites";
}
+ /**
+ * Update a site with the data from the form.
+ *
+ * @param siteIdentifierParam The identifier of the site to update.
+ * @return Redirect to the details page of the site.
+ */
@POST
@Path("/{siteIdentifier}/edit")
@AuthorizationRequired
@@ -147,6 +160,9 @@ public class SiteFormController {
}
}
+ /**
+ * Helper method for resetting the default site of an installation.
+ */
private void resetDefaultSite() {
final Optional result = siteRepository
.findDefaultSite();
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteTableRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteTableRow.java
index 1c4df5c8a..98d942603 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteTableRow.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/SiteTableRow.java
@@ -19,7 +19,8 @@
package org.libreccm.ui.admin.sites;
/**
- *
+ * Data for a row in the table showing all available sites.
+ *
* @author Jens Pelzetter
*/
public class SiteTableRow {
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 1d84fc313..06c4e3fee 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
@@ -47,6 +47,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Primary controller for the UI for managing sites.
*
* @author Jens Pelzetter
*/
@@ -73,6 +74,11 @@ public class SitesController {
@Inject
private Themes themes;
+ /**
+ * Show all available sites.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -91,6 +97,13 @@ public class SitesController {
return "org/libreccm/ui/admin/sites/sites.xhtml";
}
+ /**
+ * Show the details of a site.
+ *
+ * @param siteIdentifierParam Identifier of the site to show.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/{siteIdentifier}/details")
@AuthorizationRequired
@@ -137,6 +150,11 @@ public class SitesController {
}
}
+ /**
+ * Show the form for creating a new site.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/new")
@AuthorizationRequired
@@ -147,6 +165,13 @@ public class SitesController {
return "org/libreccm/ui/admin/sites/site-form.xhtml";
}
+ /**
+ * Show the form for editing a site.
+ *
+ * @param siteIdentifierParam The identifier of the site to edit.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/{siteIdentifier}/edit")
@AuthorizationRequired
@@ -192,7 +217,15 @@ public class SitesController {
return "org/libreccm/ui/admin/sites/site-not-found.xhtml";
}
}
-
+
+ /**
+ * Delete a site.
+ *
+ * @param siteIdentifierParam The identifier of the site to delete.
+ * @param confirmed Was the deletion confirmed by the user?
+ *
+ * @return Redirect to the list of all available sites.
+ */
@POST
@Path("/{identifier}/delete")
@AuthorizationRequired
@@ -204,31 +237,40 @@ public class SitesController {
) {
if ("true".equals(confirmed)) {
final Identifier siteIdentifier = identifierParser.parseIdentifier(
- siteIdentifierParam
- );
+ siteIdentifierParam
+ );
- final Optional result;
- switch (siteIdentifier.getType()) {
- case ID:
- result = siteRepository.findById(
- Long.parseLong(siteIdentifier.getIdentifier())
- );
- break;
- default:
- result = siteRepository.findByUuid(
- siteIdentifier.getIdentifier()
- );
- break;
+ final Optional result;
+ switch (siteIdentifier.getType()) {
+ case ID:
+ result = siteRepository.findById(
+ Long.parseLong(siteIdentifier.getIdentifier())
+ );
+ break;
+ default:
+ result = siteRepository.findByUuid(
+ siteIdentifier.getIdentifier()
+ );
+ break;
+ }
+
+ if (result.isPresent()) {
+ siteRepository.delete(result.get());
+ }
}
- if (result.isPresent()) {
- siteRepository.delete(result.get());
- }
- }
-
return "redirect:sites";
}
+ /**
+ * Helper method for building a
+ * {@link org.libreccm.ui.admin.sites.SiteTableRow} instance for a
+ * {@link Site}.
+ *
+ * @param site The site.
+ *
+ * @return A {@link SiteTableRow} instance for the site.
+ */
private SiteTableRow buildSiteTableRow(final Site site) {
final SiteTableRow row = new SiteTableRow();
row.setSiteId(site.getObjectId());
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 6ae053284..d9f85c4c9 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
@@ -27,7 +27,8 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
- *
+ * {@link AdminPage} implementation for the UI for managing sites.
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/sites/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/package-info.java
new file mode 100644
index 000000000..2326c0214
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/sites/package-info.java
@@ -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
+ */
+/**
+ * UI for managing sites.
+ */
+package org.libreccm.ui.admin.sites;
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 a85cd9521..97e038520 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
@@ -30,6 +30,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
/**
+ * Controller for the systeminformations page.
*
* @author Jens Pelzetter
*/
@@ -37,10 +38,12 @@ import javax.ws.rs.Path;
@Controller
@Path("/systeminformation")
public class SystemInformationController {
-
- @Inject
- private MvcContext mvc;
-
+
+ /**
+ * Show the system information page.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -48,5 +51,5 @@ public class SystemInformationController {
public String getSystemInformation() {
return "org/libreccm/ui/admin/systeminformation.xhtml";
}
-
+
}
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 99b0b3b58..146a31ea1 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
@@ -30,6 +30,7 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
+ * Model providing the date for the system information page.
*
* @author Jens Pelzetter
*/
@@ -37,6 +38,12 @@ import javax.inject.Named;
@Named("SystemInformationModel")
public class SystemInformationModel {
+ /**
+ * Get some data about this LibreCCM installation, eg. version, application
+ * name, and homepage.
+ *
+ * @return The information about this CCM installation.
+ */
public Map getCcmSystemInformation() {
final Properties properties = new Properties();
try {
@@ -64,6 +71,11 @@ public class SystemInformationModel {
return sysInfo;
}
+ /**
+ * Get the Java System Properties from the runtime environment.
+ *
+ * @return The Java System Properties of the runtime environment.
+ */
public Map getJavaSystemProperties() {
final Properties systemProperties = System.getProperties();
final Map result = new HashMap<>();
@@ -74,4 +86,5 @@ public class SystemInformationModel {
}
return result;
}
+
}
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 b2fcb5a73..151aceff4 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
@@ -27,7 +27,8 @@ import org.libreccm.ui.admin.AdminPage;
import javax.enterprise.context.ApplicationScoped;
/**
- *
+ * {@link AdminPage} implementaton for the system information page.
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/package-info.java
new file mode 100644
index 000000000..a78260d3b
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/package-info.java
@@ -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
+ */
+/**
+ * UI for inspecting some information about LibreCCM and the runtime environment.
+ */
+package org.libreccm.ui.admin.systeminformation;
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesController.java b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesController.java
index f3ed452cb..8036e6c5c 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesController.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesController.java
@@ -21,12 +21,7 @@ package org.libreccm.ui.admin.themes;
import org.libreccm.core.CoreConstants;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
-import org.libreccm.theming.ThemeInfo;
import org.libreccm.theming.Themes;
-import org.libreccm.theming.manager.ThemeManager;
-;
-
-import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@@ -40,11 +35,10 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Primary controller for the UI for managing themes.
*
* @author Jens Pelzetter
*/
-
-
@RequestScoped
@Controller
@Path("/themes")
@@ -53,10 +47,14 @@ public class ThemesController {
@Inject
private Themes themes;
-
@Inject
private Models models;
+ /**
+ * Show all available themes.
+ *
+ * @return The template to use.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -66,6 +64,14 @@ public class ThemesController {
return "org/libreccm/ui/admin/themes/themes.xhtml";
}
+ /**
+ * Create a new theme.
+ *
+ * @param themeName The name of the new theme.
+ * @param providerName The provider of the new theme.
+ *
+ * @return Redirect to the list of available themes.
+ */
@POST
@Path("/new")
@AuthorizationRequired
@@ -76,10 +82,17 @@ public class ThemesController {
@FormParam("providerName") final String providerName
) {
themes.createTheme(themeName, providerName);
-
+
return "redirect:themes/";
}
-
+
+ /**
+ * (Re-)Publish a theme.
+ *
+ * @param themeName The theme to (re-)publish.
+ *
+ * @return Redirect to the list of themes.
+ */
@POST
@Path("/{themeName}/publish")
@AuthorizationRequired
@@ -87,10 +100,17 @@ public class ThemesController {
@Transactional(Transactional.TxType.REQUIRED)
public String publishTheme(final String themeName) {
themes.publishTheme(themeName);
-
+
return "redirect:themes/";
}
-
+
+ /**
+ * Unpublish a theme.
+ *
+ * @param themeName The theme to unpublish.
+ *
+ * @return Redirect to the list of themes.
+ */
@POST
@Path("/{themeName}/unpublish")
@AuthorizationRequired
@@ -98,10 +118,17 @@ public class ThemesController {
@Transactional(Transactional.TxType.REQUIRED)
public String unpublishTheme(final String themeName) {
themes.unpublishTheme(themeName);
-
+
return "redirect:themes/";
}
-
+
+ /**
+ * Delete a theme.
+ *
+ * @param themeName The theme to delete.
+ *
+ * @return Redirect to the list of themes.
+ */
@POST
@Path("/{themeName}/delete")
@AuthorizationRequired
@@ -109,9 +136,8 @@ public class ThemesController {
@Transactional(Transactional.TxType.REQUIRED)
public String deleteTheme(@PathParam("themeName") final String themeName) {
themes.deleteTheme(themeName);
-
+
return "redirect:themes/";
}
-
}
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesModel.java
index fc6c32ee5..ffa55f47c 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesModel.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesModel.java
@@ -34,12 +34,11 @@ import java.util.Optional;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.inject.Named;
/**
+ * Model for the themes page.
*
* @author Jens Pelzetter
*/
@@ -53,6 +52,11 @@ public class ThemesModel {
@Inject
private Themes themes;
+ /**
+ * Get all available themes.
+ *
+ * @return A list of all available themes.
+ */
public List getThemes() {
return themes
.getAvailableThemes()
@@ -61,6 +65,12 @@ public class ThemesModel {
.collect(Collectors.toList());
}
+ /**
+ * Get all available {@link org.libreccm.theming.ThemeProvider}s which
+ * support changes and draft themes.
+ *
+ * @return
+ */
public Map getProviderOptions() {
return themes
.getThemeProviders()
@@ -75,8 +85,15 @@ public class ThemesModel {
);
}
+ /**
+ * Helper function for mapping a {@link ThemeInfo} instance to a
+ * {@link ThemesTableRow} instance.
+ *
+ * @param themeInfo The {@link ThemeInfo} instance to map.
+ *
+ * @return A {@link ThemesTableRow} instance for the theme.
+ */
private ThemesTableRow mapThemeInfo(final ThemeInfo themeInfo) {
-
final LocalizedTextsUtil textsUtil = globalizationHelper
.getLocalizedTextsUtil(AdminConstants.ADMIN_BUNDLE);
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesPage.java
index eacd43de9..bcee4b564 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesPage.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesPage.java
@@ -27,7 +27,8 @@ import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
/**
- *
+ * {@link AdminPage} implementation for the UI for managing themes.
+ *
* @author Jens Pelzetter
*/
@ApplicationScoped
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesTableRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesTableRow.java
index b0b523a58..3796bbd68 100644
--- a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesTableRow.java
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/ThemesTableRow.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
import java.util.Comparator;
/**
+ * Data of theme for displaying in the table of available themes.
*
* @author Jens Pelzetter
*/
diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/themes/package-info.java b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/package-info.java
new file mode 100644
index 000000000..27d9497d3
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/ui/admin/themes/package-info.java
@@ -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
+ */
+/**
+ * UI for managing themes.
+ */
+package org.libreccm.ui.admin.themes;