diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/AssetFolderModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/AssetFolderModel.java
index 44f4431fa..d2afb115a 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/AssetFolderModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/AssetFolderModel.java
@@ -14,7 +14,7 @@ import javax.inject.Named;
/**
* Model for the current asset folder. Provides data about the folder for the
- * template.
+ * view template.
*
* @author Jens Pelzetter
*/
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreatesDocumentOfType.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreatesDocumentOfType.java
index 91ee203cd..c0f99e8b1 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreatesDocumentOfType.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreatesDocumentOfType.java
@@ -29,7 +29,7 @@ import javax.inject.Qualifier;
/**
* Qualifier annotation for implementation of {@link MvcDocumentCreateStep}
- * providing the type of the created document/content item. Used to select
+ * defining the type of the created document/content item. Used to select
* the requested create step from all available implementations.
*
* @author Jens Pelzetter
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultAuthoringStepConstants.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultAuthoringStepConstants.java
index 954bff261..cc1dfbd27 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultAuthoringStepConstants.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultAuthoringStepConstants.java
@@ -19,17 +19,21 @@
package org.librecms.ui.contentsections.documents;
/**
+ * Some constants shared by the default authoring steps.
*
* @author Jens Pelzetter
*/
public final class DefaultAuthoringStepConstants {
-
+
private DefaultAuthoringStepConstants() {
-
+
}
-
-
+
+ /**
+ * Fully qualified name of the bundle used for providing the labels and
+ * other localized resource of the default authoring steps.
+ */
public static final String BUNDLE
= "org.libreccms.ui.DefaultAuthoringStepsBundle";
-
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultStepsMessageBundle.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultStepsMessageBundle.java
index edcbf6d2c..538755f22 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultStepsMessageBundle.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DefaultStepsMessageBundle.java
@@ -20,10 +20,14 @@ package org.librecms.ui.contentsections.documents;
import org.libreccm.ui.AbstractMessagesBean;
+import java.util.ResourceBundle;
+
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
+ * Named bean wrapping the {@link ResourceBundle} providing the localized labels
+ * and other localized resources for the default authoring steps.
*
* @author Jens Pelzetter
*/
@@ -35,8 +39,5 @@ public class DefaultStepsMessageBundle extends AbstractMessagesBean {
protected String getMessageBundle() {
return DefaultAuthoringStepConstants.BUNDLE;
}
-
-
-
-
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentController.java
index e2067ab11..bb70fdf60 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentController.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentController.java
@@ -29,13 +29,16 @@ import org.librecms.contentsection.Folder;
import org.librecms.contentsection.FolderRepository;
import org.librecms.contentsection.FolderType;
import org.librecms.contentsection.privileges.ItemPrivileges;
+import org.librecms.lifecycle.Lifecycle;
import org.librecms.lifecycle.LifecycleDefinition;
import org.librecms.lifecycle.Phase;
import org.librecms.ui.contentsections.ContentSectionsUi;
+import org.librecms.ui.contentsections.DocumentFolderController;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -44,7 +47,6 @@ import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Instance;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.transaction.Transactional;
@@ -56,6 +58,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for the UI for managing documents ({@link ContentItem}s.)
*
* @author Jens Pelzetter
*/
@@ -64,42 +67,92 @@ import javax.ws.rs.PathParam;
@Controller
public class DocumentController {
+ /**
+ * Item manager instance for performing operations on {@link ContentItem}s.
+ */
@Inject
private ContentItemManager itemManager;
+ /**
+ * {@link ContentSectionsUi} instance providing for helper functions for
+ * dealing with {@link ContentSection}s.
+ */
@Inject
private ContentSectionsUi sectionsUi;
+ /**
+ * {@link DocumentUi} instance providing some common functions for managing
+ * documents.
+ */
@Inject
private DocumentUi documentUi;
+ /**
+ * {@link FolderRepository} instance for retrieving folders.
+ */
@Inject
private FolderRepository folderRepo;
+ /**
+ * {@link ContentItemRepository} instance for retrieving content items.
+ */
@Inject
private ContentItemRepository itemRepo;
+ /**
+ * All available {@link MvcAuthoringStep}s.
+ */
@Inject
private Instance authoringSteps;
+ /**
+ * All available {@link MvcDocumentCreateStep}s.
+ */
@Inject
private Instance> createSteps;
+ /**
+ * {@link GlobalizationHelper} for working with localized texts etc.
+ */
@Inject
private GlobalizationHelper globalizationHelper;
+ /**
+ * Used to make avaiable in the views without a named bean.
+ */
@Inject
private Models models;
+ /**
+ * Used to check permissions on content items.
+ */
@Inject
private PermissionChecker permissionChecker;
+ /**
+ * Model for the {@link PublishStep}.
+ */
@Inject
private PublishStepModel publishStepModel;
+ /**
+ * Named beans providing access to the properties of the selected document
+ * (content item} from the view.
+ */
@Inject
private SelectedDocumentModel selectedDocumentModel;
+ /**
+ * Redirect requests to the root path of this controller to the
+ * {@link DocumentFolderController}. The root path of this controller has no
+ * function. We assume that somebody who access the root folders wants to
+ * browse all documents in the content section. Therefore we redirect these
+ * requests to the {@link DocumentFolderController}.
+ *
+ * @param sectionIdentifier The identififer of the current content section.
+ *
+ * @return A redirect to the {@link DocumentFolderController}.
+ */
@GET
@Path("/")
@AuthorizationRequired
@@ -113,6 +166,16 @@ public class DocumentController {
);
}
+ /**
+ * Delegates requests for the path {@code @create} to the create step
+ * (subresource) of the document type. The new document will be created in
+ * the root folder of the current content section.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentType The type of the document to create.
+ *
+ * @return The create step subresource.
+ */
@Path("/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@@ -123,6 +186,17 @@ public class DocumentController {
return createDocument(sectionIdentifier, "", documentType);
}
+ /**
+ * Delegates requests for the path {@code @create} to the create step
+ * (subresource) of the document type.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param folderPath Path of the folder in which the new document is
+ * created.
+ * @param documentType The type of the document to create.
+ *
+ * @return The create step subresource.
+ */
@Path("/{folderPath:(.+)?}/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@@ -195,6 +269,16 @@ public class DocumentController {
return createStep;
}
+ /**
+ * Redirects to the first authoring step for the document identified by the
+ * provided path.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document.
+ *
+ * @return A redirect to the first authoring step of the document, or the
+ * {@link DocumentNotFound} pseudo authoring step.
+ */
@Path("/{documentPath:(.+)?}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@@ -225,6 +309,18 @@ public class DocumentController {
);
}
+ /**
+ * Redirect requests for an authoring step to the subresource of the
+ * authoring step.
+ *
+ * @param sectionIdentifier The identifier of the current content
+ * section.
+ * @param documentPath The path of the document to edit.
+ * @param authoringStepIdentifier The identifier/path fragment of the
+ * authoring step.
+ *
+ * @return The authoring step subresource.
+ */
@Path("/{documentPath:(.+)?}/@authoringsteps/{authoringStep}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@@ -274,7 +370,7 @@ public class DocumentController {
}
models.put("authoringStep", authoringStepIdentifier);
-
+
selectedDocumentModel.setContentItem(item);
authoringStep.setContentSection(section);
@@ -283,6 +379,14 @@ public class DocumentController {
return authoringStep;
}
+ /**
+ * Show the document history page.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document.
+ *
+ * @return The template for the document history page.
+ */
@POST
@Path("/{documentPath:(.+)?}/@history")
@AuthorizationRequired
@@ -320,6 +424,14 @@ public class DocumentController {
return "org/librecms/ui/contentsection/documents/history.xhtml";
}
+ /**
+ * Shows the publish step for the current document.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document to publish.
+ *
+ * @return The template for the publish step.
+ */
@GET
@Path("/{documentPath:(.+)?}/@publish")
@AuthorizationRequired
@@ -355,22 +467,32 @@ public class DocumentController {
.map(this::buildLifecycleListEntry)
.collect(Collectors.toList())
);
- if (item.getLifecycle() != null) {
- publishStepModel.setPhases(
- item
- .getLifecycle()
- .getPhases()
- .stream()
- .map(this::buildPhaseListEntry)
- .collect(Collectors.toList())
- );
- }
-
+ publishStepModel.setPhases(
+ Optional
+ .ofNullable(item.getLifecycle())
+ .map(Lifecycle::getPhases)
+ .orElse(Collections.emptyList())
+ .stream()
+ .map(this::buildPhaseListEntry)
+ .collect(Collectors.toList())
+ );
+
models.put("authoringStep", "publish");
return "org/librecms/ui/contentsection/documents/publish.xhtml";
}
+ /**
+ * Published a document.
+ *
+ * @param sectionIdentifier The identifier of the current content
+ * section.
+ * @param documentPath The path of the document to publish.
+ * @param selectedLifecycleUuid The UUID of the lifecycle selected for the
+ * document.
+ *
+ * @return A redirect to the publish step (redirect after POST pattern).
+ */
@POST
@Path("/{documentPath:(.+)?}/@publish")
@AuthorizationRequired
@@ -426,6 +548,14 @@ public class DocumentController {
);
}
+ /**
+ * Republishes a document.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document to republish.
+ *
+ * @return A redirect to the publish step (redirect after POST pattern).
+ */
@POST
@Path("/{documentPath:(.+)?}/@republish")
@AuthorizationRequired
@@ -463,6 +593,14 @@ public class DocumentController {
);
}
+ /**
+ * Unpublishes a document.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document to unpublish.
+ *
+ * @return A redirect to the publish step (redirect after POST pattern).
+ */
@POST
@Path("/{documentPath:(.+)?}/@publish")
@AuthorizationRequired
@@ -500,6 +638,14 @@ public class DocumentController {
);
}
+ /**
+ * Helper method for reading the authoring steps for the current content
+ * item.
+ *
+ * @param item The content item.
+ *
+ * @return A list of authoring steps for the provided item.
+ */
private List readAuthoringSteps(
final ContentItem item
) {
@@ -518,9 +664,17 @@ public class DocumentController {
.collect(Collectors.toList());
}
+ /**
+ * Helper method for finding the path fragment for the first authoring step
+ * for a content item.
+ *
+ * @param item The content item.
+ *
+ * @return The path fragment of the first authoring step of the item.
+ */
private String findPathFragmentForFirstStep(final ContentItem item) {
final List steps = readAuthoringSteps(item);
-
+
final MvcAuthoringStep firstStep = steps.get(0);
final AuthoringStepPathFragment pathFragment = firstStep
.getClass()
@@ -528,6 +682,16 @@ public class DocumentController {
return pathFragment.value();
}
+ /**
+ * Helper method for building an entry in the list of lifecycles for the
+ * view.
+ *
+ * @param definition The lifecycle definition from which the entry is
+ * created.
+ *
+ * @return A {@link LifecycleListEntry} for the provided
+ * {@link LifecycleDefinition}.
+ */
private LifecycleListEntry buildLifecycleListEntry(
final LifecycleDefinition definition
) {
@@ -546,6 +710,14 @@ public class DocumentController {
return entry;
}
+ /**
+ * Builds a {@link PhaseListEntry} for displaying the phases of a
+ * {@link Lifecycle}.
+ *
+ * @param phase The phase from which the entry is created.
+ *
+ * @return A {@link PhaseListEntry} for the provided {@link Phase}.
+ */
private PhaseListEntry buildPhaseListEntry(final Phase phase) {
final DateTimeFormatter dateTimeFormatter
= DateTimeFormatter.ISO_DATE_TIME
@@ -573,6 +745,10 @@ public class DocumentController {
return entry;
}
+ /**
+ * An annotation literal used to retrieve the create step for a specific
+ * content type.
+ */
private static class CreateDocumentOfTypeLiteral
extends AnnotationLiteral
implements CreatesDocumentOfType {
@@ -594,6 +770,10 @@ public class DocumentController {
}
+ /**
+ * An annotation literal for retrieving the authoring step with a specific
+ * path fragment.
+ */
private static class AuthoringStepPathFragmentLiteral
extends AnnotationLiteral
implements AuthoringStepPathFragment {
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentLifecyclesController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentLifecyclesController.java
index 070550e7e..2af9f478c 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentLifecyclesController.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentLifecyclesController.java
@@ -46,6 +46,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for managing the lifecycles of a document.
*
* @author Jens Pelzetter
*/
@@ -53,25 +54,58 @@ import javax.ws.rs.PathParam;
@Path("/{sectionIdentifier}/documents/{documentPath:(.+)?}/@lifecycle/")
@Controller
public class DocumentLifecyclesController {
-
+
+ /**
+ * {@link ContentItemRepository} instance for retrieving content items.
+ */
@Inject
private ContentItemRepository itemRepo;
-
+
+ /**
+ * Several common functions for {@link ContentSection}s.
+ */
@Inject
private ContentSectionsUi sectionsUi;
-
+
+ /**
+ * Several common functions for documents/{@link ContentItem}s.
+ */
@Inject
private DocumentUi documentUi;
-
+
+ /**
+ * Used to provide data for the views without a named bean.
+ */
@Inject
private Models models;
-
+
+ /**
+ * Used to check permissions.
+ */
@Inject
private PermissionChecker permissionChecker;
-
+
+ /**
+ * Used to retrive {
+ *
+ * @Phase}s of a {@link Lifecycle}.
+ */
@Inject
private PhaseRepository phaseRepository;
-
+
+ /**
+ * Update the dates of a {@link Phase}.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the document.
+ * @param phaseId The ID of the phase.
+ * @param startDateTimeParam The start date of the phase of ISO formatted
+ * date/time.
+ * @param endDateTimeParam The end date of the phase of ISO formatted
+ * date/time.
+ *
+ * @return
+ */
@POST
@Path("/phases/{phaseId}")
@AuthorizationRequired
@@ -80,8 +114,8 @@ public class DocumentLifecyclesController {
@PathParam("sectionIdentifider") final String sectionIdentifier,
@PathParam("documentPath") final String documentPath,
@PathParam("phaseId") final long phaseId,
- @FormParam("startDate") final String startDateParam,
- @FormParam("endDate") final String endDateParam
+ @FormParam("startDate") final String startDateTimeParam,
+ @FormParam("endDate") final String endDateTimeParam
) {
final Optional sectionResult = sectionsUi
.findContentSection(sectionIdentifier);
@@ -122,7 +156,7 @@ public class DocumentLifecyclesController {
= DateTimeFormatter.ISO_DATE_TIME
.withZone(ZoneId.systemDefault());
final LocalDateTime startLocalDateTime = LocalDateTime
- .parse(startDateParam, dateTimeFormatter);
+ .parse(startDateTimeParam, dateTimeFormatter);
phase.setStartDateTime(
Date.from(
startLocalDateTime.toInstant(
@@ -131,7 +165,7 @@ public class DocumentLifecyclesController {
)
);
final LocalDateTime endLocalDateTime = LocalDateTime
- .parse(endDateParam, dateTimeFormatter);
+ .parse(endDateTimeParam, dateTimeFormatter);
phase.setEndDateTime(
Date.from(
endLocalDateTime.toInstant(
@@ -149,4 +183,5 @@ public class DocumentLifecyclesController {
documentPath
);
}
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentUi.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentUi.java
index 11ede343d..341dede86 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentUi.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentUi.java
@@ -25,12 +25,16 @@ import javax.inject.Inject;
import javax.mvc.Models;
/**
- *
+ * Provides common functions used by several controllers.
+ *
* @author Jens Pelzetter
*/
@RequestScoped
class DocumentUi {
+ /**
+ * Used to provide data for the views without a named bean.
+ */
@Inject
private Models models;
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentWorkflowController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentWorkflowController.java
index 0c81e06a8..bd29c3d66 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentWorkflowController.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentWorkflowController.java
@@ -46,6 +46,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
/**
+ * Controller for managing the {@link Workflow} assigned to a
+ * {@link ContentItem}.
*
* @author Jens Pelzetter
*/
@@ -54,33 +56,70 @@ import javax.ws.rs.PathParam;
@Controller
public class DocumentWorkflowController {
+ /**
+ * Used to manage the tasks of the workflow.
+ */
@Inject
private AssignableTaskManager assignableTaskManager;
+ /**
+ * Used to retrieve the current content item.
+ */
@Inject
private ContentItemRepository itemRepo;
+ /**
+ * Common functions for controllers working with {@link ContentSection}s.
+ */
@Inject
private ContentSectionsUi sectionsUi;
+ /**
+ * Common functions for controllers working with {@link ContentItem}s.
+ */
@Inject
private DocumentUi documentUi;
+ /**
+ * {@link IdentifierParser} instance for parsing identifiers.
+ */
@Inject
private IdentifierParser identifierParser;
+ /**
+ * Used to check permissions for the current content item.
+ */
@Inject
private PermissionChecker permissionChecker;
+ /**
+ * Provides access to the properties of the select content item in the view.
+ */
@Inject
private SelectedDocumentModel selectedDocumentModel;
+ /**
+ * Used to provided data for the view without a named bean.
+ */
@Inject
private Models models;
+ /**
+ * Used to manage the workflow of a {@link ContentItem}.
+ */
@Inject
private WorkflowManager workflowManager;
+ /**
+ * Lock a task of a workflow.
+ *
+ * @param sectionIdentifier The identifier of the curent content section.
+ * @param documentPath The path of the current document.
+ * @param taskIdentifier The identifier of the task to lock.
+ * @param returnUrl The URL to return to.
+ *
+ * @return A redirect to the {@code returnUrl}.
+ */
@POST
@Path("/tasks/${taskIdentifier}/@lock")
@AuthorizationRequired
@@ -119,6 +158,16 @@ public class DocumentWorkflowController {
return String.format("redirect:%s", returnUrl);
}
+ /**
+ * Unlocks/releases a task.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The identifier of the current document.
+ * @param taskIdentifier The identifier of the task to unlock.
+ * @param returnUrl The URL to return to.
+ *
+ * @return A redirect to the {@code returnUrl}.
+ */
@POST
@Path("/tasks/${taskIdentifier}/@unlock")
@AuthorizationRequired
@@ -157,6 +206,17 @@ public class DocumentWorkflowController {
return String.format("redirect:%s", returnUrl);
}
+ /**
+ * Finishes a task.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the current document.
+ * @param taskIdentifier The identifier of task to finish.
+ * @param comment A comment to add to the task.
+ * @param returnUrl The URL to return to.
+ *
+ * @return A redirect to the {@code returnUrl}.
+ */
@POST
@Path("/tasks/${taskIdentifier}/@finish")
@AuthorizationRequired
@@ -200,6 +260,17 @@ public class DocumentWorkflowController {
return String.format("redirect:%s", returnUrl);
}
+ /**
+ * Apply another workflow to a content item.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the currentd document.
+ * @param newWorkflowUuid The UUID of the the workflow definition form
+ * which the new workflow is created.
+ * @param returnUrl The URL to return to.
+ *
+ * @return A redirect to the {@code returnUrl}.
+ */
@POST
@Path("@workflow/@applyAlternative/{workflowIdentifier}")
@AuthorizationRequired
@@ -248,6 +319,15 @@ public class DocumentWorkflowController {
return String.format("redirect:%s", returnUrl);
}
+ /**
+ * Restarts the workflow assigned to an content item.
+ *
+ * @param sectionIdentifier The identifier of the current content section.
+ * @param documentPath The path of the current document.
+ * @param returnUrl The URL to return to.
+ *
+ * @return A redirect to the {@code returnUrl}.
+ */
@POST
@Path("/@restart")
@AuthorizationRequired
@@ -287,6 +367,17 @@ public class DocumentWorkflowController {
return String.format("redirect:%s", returnUrl);
}
+ /**
+ * Helper method to find a specific task of the current workflow of a
+ * content item.
+ *
+ * @param item The content item.
+ * @param taskIdentifier The identifier of the task.
+ *
+ * @return An {@link Optional} with the task identified by the provided
+ * {@code taskIdentifier} or an empty {@link Optional} if no such
+ * task could be found.
+ */
private Optional findTask(
final ContentItem item,
final String taskIdentifier
@@ -324,6 +415,15 @@ public class DocumentWorkflowController {
}
}
+ /**
+ * Helper method for showing the "task not found" error message.
+ *
+ * @param section
+ * @param documentPath
+ * @param taskIdentifier
+ *
+ * @return
+ */
private String showTaskNotFound(
final ContentSection section,
final String documentPath,
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/InternalLinkDetailsModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/InternalLinkDetailsModel.java
index d19abc6dc..b478960f3 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/InternalLinkDetailsModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/InternalLinkDetailsModel.java
@@ -19,7 +19,9 @@
package org.librecms.ui.contentsections.documents;
import org.libreccm.l10n.GlobalizationHelper;
+import org.libreccm.l10n.LocalizedString;
import org.librecms.assets.RelatedLink;
+import org.librecms.contentsection.AttachmentList;
import java.util.Collections;
import java.util.List;
@@ -34,6 +36,8 @@ import javax.inject.Inject;
import javax.inject.Named;
/**
+ * Model proving the properties of an internal {@link RelatedLink} for the
+ * internal link edit view of the {@link RelatedInfoStep}.
*
* @author Jens Pelzetter
*/
@@ -41,23 +45,52 @@ import javax.inject.Named;
@Named("CmsInternalLinkDetailsModel")
public class InternalLinkDetailsModel {
+ /**
+ * Used to retrieve values from {@link LocalizedString}s.
+ */
@Inject
private GlobalizationHelper globalizationHelper;
+ /**
+ * The identifier of the {@link AttachmentList} of the link.
+ */
private String listIdentifier;
+ /**
+ * The UUID of the link.
+ */
private String uuid;
+ /**
+ * The label of the link.
+ */
private String label;
-
+
+ /**
+ * The localized titles of the link.
+ */
private Map title;
+ /**
+ * The locales for which no title has been specified.
+ */
private List unusedTitleLocales;
+ /**
+ * The UUID of the target item of the link.
+ */
private String targetItemUuid;
+ /**
+ * The name of the target item of the link
+ */
private String targetItemName;
+ /**
+ * The title of the target item of the link. This value is determined from
+ * the title of the target item using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String targetItemTitle;
public String getListIdentifier() {
@@ -75,7 +108,7 @@ public class InternalLinkDetailsModel {
public String getLabel() {
return label;
}
-
+
public Map getTitle() {
return Collections.unmodifiableMap(title);
}
@@ -96,6 +129,12 @@ public class InternalLinkDetailsModel {
return targetItemTitle;
}
+ /**
+ * Sets the properties of this model based on the properties on the provided
+ * link.
+ *
+ * @param link The link to use.
+ */
protected void setInternalLink(final RelatedLink link) {
Objects.requireNonNull(link);
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ItemAttachmentDto.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ItemAttachmentDto.java
index d6ecf3990..aa3661e4b 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ItemAttachmentDto.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ItemAttachmentDto.java
@@ -18,22 +18,48 @@
*/
package org.librecms.ui.contentsections.documents;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.contentsection.ItemAttachment;
+
/**
+ * A DTO for providing data about an {@link ItemAttachment} in a form suitable
+ * for a MVC view.
*
* @author Jens Pelzetter
*/
public class ItemAttachmentDto {
+ /**
+ * The ID of the attachment.
+ */
private long attachmentId;
+ /**
+ * The UUID of the attachment.
+ */
private String uuid;
+ /**
+ * The sort key of the attachment.
+ */
private long sortKey;
+ /**
+ * The type of the asset of the attachment.
+ */
private String assetType;
+ /**
+ * The title of the asset assigned to an content item. This value is
+ * determined from the title of the asset using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String title;
-
+
+ /**
+ * An indicator if the attachment is containing an internal
+ * {@link RelatedLink}.
+ */
private boolean internalLink;
public long getAttachmentId() {
@@ -83,7 +109,5 @@ public class ItemAttachmentDto {
public void setInternalLink(final boolean internalLink) {
this.internalLink = internalLink;
}
-
-
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/LifecycleListEntry.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/LifecycleListEntry.java
index 5263e1136..dd7748f8f 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/LifecycleListEntry.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/LifecycleListEntry.java
@@ -18,16 +18,33 @@
*/
package org.librecms.ui.contentsections.documents;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.lifecycle.LifecycleDefinition;
+
/**
+ * Entry in the list of lifecycle definitions.
*
* @author Jens Pelzetter
*/
public class LifecycleListEntry {
-
+
+ /**
+ * The UUID of the lifecycle
+ */
private String uuid;
-
+
+ /**
+ * The label of the lifecycle. This value is determined from
+ * {@link LifecycleDefinition#label} using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String label;
-
+
+ /**
+ * The description of the lifecycle. This value is determined from
+ * {@link LifecycleDefinition#description} using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String description;
public String getLabel() {
@@ -53,7 +70,5 @@ public class LifecycleListEntry {
public void setUuid(final String uuid) {
this.uuid = uuid;
}
-
-
-
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PhaseListEntry.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PhaseListEntry.java
index f8b1dc11e..1bcf8edf2 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PhaseListEntry.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PhaseListEntry.java
@@ -18,24 +18,53 @@
*/
package org.librecms.ui.contentsections.documents;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.lifecycle.PhaseDefinition;
+
/**
+ * Entry in the list of phases of a lifecycle.
*
* @author Jens Pelzetter
*/
public class PhaseListEntry {
+ /**
+ * The ID of the phase.
+ */
private long phaseId;
+ /**
+ * The label of the phase. This value is determined from the label of the
+ * {@link PhaseDefinition} of the phase using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String label;
+ /**
+ * The description of the phase. This value is determined from the description of the
+ * {@link PhaseDefinition} of the phase using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String description;
+ /**
+ * Has the phase already started?
+ */
private boolean started;
+ /**
+ * Is the phase finished?
+ */
private boolean finished;
+ /**
+ * The start date and time of the phase.
+ */
private String startDateTime;
+ /**
+ * The end date and time of the phase.
+ */
private String endDateTime;
public String getLabel() {
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStep.java
index 52f42b345..18518c529 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStep.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStep.java
@@ -22,6 +22,7 @@ import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentSection;
+import org.librecms.lifecycle.Lifecycle;
import org.librecms.lifecycle.LifecycleDefinition;
import org.librecms.lifecycle.LifecycleDefinitionRepository;
@@ -46,6 +47,9 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
/**
+ * Authoring step (part of the default steps) for publishing a
+ * {@link ContentItem}. This class acts as controller for the view(s) of the
+ * publish step as well as named bean providing some data for these views.
*
* @author Jens Pelzetter
*/
@@ -56,6 +60,9 @@ import javax.ws.rs.Path;
@Named("CmsPublishStep")
public class PublishStep implements MvcAuthoringStep {
+ /**
+ * The path fragment of the publish step.
+ */
static final String PATH_FRAGMENT = "publish";
@Inject
@@ -158,20 +165,52 @@ public class PublishStep implements MvcAuthoringStep {
return "org/librecms/ui/documents/publish.xhtml";
}
+ /**
+ * Is the current document live?
+ *
+ * @return
+ */
public boolean isLive() {
return itemManager.isLive(document);
}
+ /**
+ * Get the label of the lifecycle assigned to the current content item. The
+ * value is determined from the label of the definition of the lifecycle
+ * using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ *
+ * @return The label of the lifecycle assigned to the current content item,
+ * or an empty string if no lifecycle is assigned to the item.
+ */
+ @Transactional(Transactional.TxType.REQUIRED)
public String getAssignedLifecycleLabel() {
- return globalizationHelper.getValueFromLocalizedString(
- document.getLifecycle().getDefinition().getLabel()
- );
+ return Optional
+ .ofNullable(document.getLifecycle())
+ .map(Lifecycle::getDefinition)
+ .map(LifecycleDefinition::getLabel)
+ .map(globalizationHelper::getValueFromLocalizedString)
+ .orElse("");
+
}
+ /**
+ * Get the description of the lifecycle assigned to the current content
+ * item. The value is determined from the description of the definition of
+ * the lifecycle using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ *
+ * @return The description of the lifecycle assigned to the current content
+ * item, or an empty string if no lifecycle is assigned to the item.
+ */
+ @Transactional(Transactional.TxType.REQUIRED)
public String getAssignedLifecycleDecription() {
- return globalizationHelper.getValueFromLocalizedString(
- document.getLifecycle().getDefinition().getDescription()
- );
+ return Optional
+ .ofNullable(document.getLifecycle())
+ .map(Lifecycle::getDefinition)
+ .map(LifecycleDefinition::getDescription)
+ .map(globalizationHelper::getValueFromLocalizedString)
+ .orElse("");
}
/**
@@ -329,6 +368,11 @@ public class PublishStep implements MvcAuthoringStep {
);
}
+ /**
+ * Unpublishes the current content item.
+ *
+ * @return A redirect to the publish step.
+ */
@POST
@Path("/@unpublish")
@Transactional(Transactional.TxType.REQUIRED)
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStepModel.java
index c2ab1eba4..cd3fec7d2 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStepModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/PublishStepModel.java
@@ -26,15 +26,22 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
/**
- *
+ * Model providing some data for the views of the {@link PublishStep}.
+ *
* @author Jens Pelzetter
*/
@RequestScoped
@Named("CmsDocumentPublishStepModel")
public class PublishStepModel {
+ /**
+ * A list of the available lifecycles.
+ */
private List availableListcycles;
+ /**
+ * The phases of the lifecycle assigned to the current content item.
+ */
private List phases;
public PublishStepModel() {
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/RelatedInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/RelatedInfoStep.java
index 9031ed1ba..ff23dfe3a 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/RelatedInfoStep.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/RelatedInfoStep.java
@@ -18,6 +18,8 @@
*/
package org.librecms.ui.contentsections.documents;
+import com.arsdigita.kernel.KernelConfig;
+
import org.libreccm.api.Identifier;
import org.libreccm.api.IdentifierParser;
import org.libreccm.l10n.GlobalizationHelper;
@@ -29,7 +31,6 @@ import org.librecms.contentsection.AssetFolderEntry;
import org.librecms.contentsection.AssetManager;
import org.librecms.contentsection.AssetRepository;
import org.librecms.contentsection.AttachmentList;
-import org.librecms.contentsection.AttachmentListL10NManager;
import org.librecms.contentsection.AttachmentListManager;
import org.librecms.contentsection.AttachmentListRepository;
import org.librecms.contentsection.ContentItem;
@@ -85,6 +86,13 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
/**
+ * Authoring step for managing the {@link AttachmentList} and
+ * {@link ItemAttachment}s assigned to a {@link ContentItem}.
+ *
+ * This class acts as controller for several views as well as named bean that
+ * provides data for these views. Some of the views of the step use JavaScript
+ * enhanced widgets. Therefore, some of the paths/endpoints provided by this
+ * class return JSON data.
*
* @author Jens Pelzetter
*/
@@ -95,8 +103,14 @@ import javax.ws.rs.core.MediaType;
@Named("CmsRelatedInfoStep")
public class RelatedInfoStep implements MvcAuthoringStep {
+ /**
+ * The path fragment of the step.
+ */
static final String PATH_FRAGMENT = "relatedinfo";
+ /**
+ * The asset folder tree of the current content section.
+ */
@Inject
private AssetFolderTree assetFolderTree;
@@ -106,68 +120,128 @@ public class RelatedInfoStep implements MvcAuthoringStep {
@Inject
private AssetPermissionsModelProvider assetPermissions;
+ /**
+ * {@link AssetManager} instance of managing {@link Asset}s.
+ */
@Inject
private AssetManager assetManager;
+ /**
+ * Used to retrieve and save {@link Asset}s.
+ */
@Inject
private AssetRepository assetRepo;
+ /**
+ * Provides access to the available asset types.
+ */
@Inject
private AssetTypesManager assetTypesManager;
+ /**
+ * Model for the details view of an {@link AttachmentList}.
+ */
@Inject
private AttachmentListDetailsModel listDetailsModel;
+ /**
+ * Manager for {@link AttachmentList}s.
+ */
@Inject
private AttachmentListManager listManager;
- @Inject
- private AttachmentListL10NManager listL10NManager;
-
+ /**
+ * Used to retrieve and save {@link AttachmentList}s.
+ */
@Inject
private AttachmentListRepository listRepo;
+ /**
+ * The document folder tree of the current content section.
+ */
@Inject
private DocumentFolderTree documentFolderTree;
+ /**
+ * Used to check permissions of the current content item.
+ */
@Inject
private DocumentPermissions documentPermissions;
+ /**
+ * Used to retrieve the path of folders.
+ */
@Inject
private FolderManager folderManager;
+ /**
+ * Used to retrieve folders.
+ */
@Inject
private FolderRepository folderRepo;
+ /**
+ * Model for the details view of an internal {@link RelatedLink}.
+ */
@Inject
private InternalLinkDetailsModel internalLinkDetailsModel;
+ /**
+ * Manages localization of {@link ContentItem}s.
+ */
@Inject
private ContentItemL10NManager itemL10NManager;
+ /**
+ * Manages {@link ContentItem}s.
+ */
@Inject
private ContentItemManager itemManager;
+ /**
+ * Used to retrieve the current content item.
+ */
@Inject
private ContentItemRepository itemRepo;
+ /**
+ * Used to retrieve content types.
+ */
@Inject
private ContentTypeRepository contentTypeRepo;
+ /**
+ * Used for globalization stuff.
+ */
@Inject
private GlobalizationHelper globalizationHelper;
+ /**
+ * Used to parse identifiers.
+ */
@Inject
private IdentifierParser identifierParser;
+ /**
+ * Manages {@link ItemAttachment}.
+ */
@Inject
private ItemAttachmentManager attachmentManager;
+ /**
+ * Used to provide data for the views without a named bean.
+ */
@Inject
private Models models;
+ /**
+ * The current document/content item.
+ */
private ContentItem document;
+ /**
+ * The current content section.
+ */
private ContentSection section;
@Override
@@ -241,6 +315,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return "org/librecms/ui/documents/relatedinfo.xhtml";
}
+ /**
+ * Gets the {@link AttachmentList}s of the current content item and converts
+ * them to {@link AttachmentListDto}s to make data about the lists available
+ * in the views.
+ *
+ * @return A list of the {@link AttachmentList} of the current content item.
+ */
@Transactional(Transactional.TxType.REQUIRED)
public List getAttachmentLists() {
return document
@@ -251,6 +332,12 @@ public class RelatedInfoStep implements MvcAuthoringStep {
.collect(Collectors.toList());
}
+ /**
+ * Gets the asset folder tree of the current content section as JSON data.
+ *
+ * @return The assets folder tree of the current content section as JSON
+ * data.
+ */
@GET
@Path("/asset-folders")
@Produces(MediaType.APPLICATION_JSON)
@@ -261,6 +348,17 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Gets the assets in the folder as JSON data.
+ *
+ * @param folderPath The path of the folder.
+ * @param firstResult The index of the firset result to show.
+ * @param maxResults The maximum number of results to show.
+ * @param filterTerm An optional filter term for filtering the assets in
+ * the folder by their name.
+ *
+ * @return A list of the assets in the folder as JSON data.
+ */
@GET
@Path("/asset-folders/{folderPath}/assets")
@Produces(MediaType.APPLICATION_JSON)
@@ -293,6 +391,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
.collect(Collectors.toList());
}
+ /**
+ * Show all assets of a content section filtered by their name.
+ *
+ * @param firstResult The index of the first result to show.
+ * @param maxResults The maximum number of results to show.
+ * @param searchTerm An optional search term applied to the names of the
+ * assets.
+ *
+ * @return A list of matching assets as JSON.
+ */
@GET
@Path("/search-assets")
@Produces(MediaType.APPLICATION_JSON)
@@ -309,6 +417,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
}
+ /**
+ * Gets the document folder tree of the current content section as JSON
+ * data.
+ *
+ * @return The document folder tree of the current content section as JSON
+ * data.
+ */
@GET
@Path("/document-folders")
@Produces(MediaType.APPLICATION_JSON)
@@ -319,6 +434,17 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Gets the documents in the folder as JSON data.
+ *
+ * @param folderPath The path of the folder.
+ * @param firstResult The index of the firset result to show.
+ * @param maxResults The maximum number of results to show.
+ * @param filterTerm An optional filter term for filtering the documents in
+ * the folder by their name.
+ *
+ * @return A list of the documents in the folder as JSON data.
+ */
@GET
@Path("/document-folders/{folderPath}/documents")
@Produces(MediaType.APPLICATION_JSON)
@@ -355,6 +481,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
.collect(Collectors.toList());
}
+ /**
+ * Show all documents of a content section filtered by their name.
+ *
+ * @param firstResult The index of the first result to show.
+ * @param maxResults The maximum number of results to show.
+ * @param searchTerm An optional search term applied to the names of the
+ * docuemnts.
+ *
+ * @return A list of matching documents/content items as JSON.
+ */
@GET
@Path("/search-documents")
@Produces(MediaType.APPLICATION_JSON)
@@ -370,6 +506,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
.collect(Collectors.toList());
}
+ /**
+ * Adds a new attachment list.
+ *
+ * @param name The name of the list.
+ * @param title The title of the list for the language returned by {@link GlobalizationHelper#getNegotiatedLocale()
+ * } .
+ * @param description The description of the list of the default locale {@link GlobalizationHelper#getNegotiatedLocale().
+ *
+ * @return A redirect to the list of attachment lists.
+ */
@POST
@Path("/attachmentlists/@add")
@Transactional(Transactional.TxType.REQUIRED)
@@ -397,6 +543,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Shows the details of an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ *
+ * @return The template for the details view.
+ */
@GET
@Path("/attachmentlists/{attachmentListIdentifier}/@details")
@Transactional(Transactional.TxType.REQUIRED)
@@ -415,6 +568,14 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return "org/librecms/ui/documents/relatedinfo-attachmentlist-details.xhtml";
}
+ /**
+ * Updates an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list to update.
+ * @param name The new name of the list.
+ *
+ * @return A redirect to the list of attachment lists.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/@update")
@Transactional(Transactional.TxType.REQUIRED)
@@ -442,6 +603,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Removes an attachment list and all item attachment of the list.
+ *
+ * @param listIdentifierParam The identifier of the list to remove.
+ * @param confirm The value of the confirm parameter. Must
+ * contain {@code true} (as string not as
+ * boolean), otherwise this method does nothing.
+ *
+ * @return A redirect to the list of attachment lists.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/@remove")
@Transactional(Transactional.TxType.REQUIRED)
@@ -468,6 +639,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Adds a localized title to an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the new title value.
+ * @param value The value of the new title value.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/title/@add")
@Transactional(Transactional.TxType.REQUIRED)
@@ -496,6 +676,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Updates a localized title value of an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the title value to update.
+ * @param value The new title value.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/title/@edit/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
@@ -524,13 +713,20 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Removes a localized title value of an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the title value to remove.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/title/@remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
public String removeAttachmentListTitle(
@PathParam("attachmentListIdentifier") final String listIdentifierParam,
- @PathParam("locale") final String localeParam,
- @FormParam("value") final String value
+ @PathParam("locale") final String localeParam
) {
final Optional listResult = findAttachmentList(
listIdentifierParam
@@ -552,6 +748,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Adds a localized description to an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the new description value.
+ * @param value The value of the new description value.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/description/@add")
@Transactional(Transactional.TxType.REQUIRED)
@@ -580,6 +785,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Updates a localized description value of an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the description value to update.
+ * @param value The new description value.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/description/@edit/{locale}")
@@ -609,14 +823,21 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Removes a localized description value of an attachment list.
+ *
+ * @param listIdentifierParam The identifier of the list.
+ * @param localeParam The locale of the description value to remove.
+ *
+ * @return A redirect to the details view of the attachment list.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/description/@remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
public String removeAttachmentListDescription(
@PathParam("attachmentListIdentifier") final String listIdentifierParam,
- @PathParam("locale") final String localeParam,
- @FormParam("value") final String value
+ @PathParam("locale") final String localeParam
) {
final Optional listResult = findAttachmentList(
listIdentifierParam
@@ -638,6 +859,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Create new attachment.
+ *
+ * @param listIdentifierParam The identifier of the list to which the
+ * attachment is added.
+ * @param assetUuid The asset to use for the attachment.
+ *
+ * @return A redirect to the list of attachment lists and attachments.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/attachments")
@Transactional(Transactional.TxType.REQUIRED)
@@ -673,6 +903,14 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Shows the form for creating a new internal link.
+ *
+ * @param listIdentifierParam The identifier of the list to which the
+ * attachment is added.
+ *
+ * @return The template for the form for creating a new internal link.
+ */
@GET
@Path("/attachmentlists/{attachmentListIdentifier}/internal-links/@create")
@Transactional(Transactional.TxType.REQUIRED)
@@ -692,6 +930,19 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return "org/librecms/ui/documents/relatedinfo-create-internallink.xhtml";
}
+ /**
+ * Create a new internal link.
+ *
+ * @param listIdentifierParam The identifier of the list to which the
+ * attachment is added.
+ * @param targetItemUuid The UUID of the target item of the internal
+ * link.
+ * @param title The title of the new internal link for the
+ * language return by {@link GlobalizationHelper#getNegotiatedLocale()
+ * }.
+ *
+ * @return A redirect to the list of attachment lists and attachments.
+ */
@POST
@Path("/attachmentlists/{attachmentListIdentifier}/internal-links/@create")
@Transactional(Transactional.TxType.REQUIRED)
@@ -732,6 +983,17 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Show the details of an internal link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the link belongs.
+ * @param internalLinkUuid The UUID of the link.
+ *
+ * @return The template for the details view of the link, or the template
+ * for the link not found message if the link iwth the provided UUID
+ * is found in the provided attachment list.
+ */
@GET
@Path(
"/attachmentlists/{attachmentListIdentifier}/internal-links/{interalLinkUuid}/@details")
@@ -772,6 +1034,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return "org/librecms/ui/documents/relatedinfo-internallink-details.xhtml";
}
+ /**
+ * Updates the target of an internal link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the link belongs.
+ * @param internalLinkUuid The UUID of the link.
+ * @param targetItemUuid The UUID of the new target item.
+ *
+ * @return A redirect to the details view of the link.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/internal-links/{interalLinkUuid}"
@@ -827,6 +1099,17 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Add a localized title value to an internal link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the link belongs.
+ * @param internalLinkUuid The UUID of the link.
+ * @param localeParam The locale of the new title value.
+ * @param value The localized value.
+ *
+ * @return A redirect to the details view of the link.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/internal-links/{interalLinkUuid}/title/@add")
@@ -875,6 +1158,17 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Updates a localized title value of an internal link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the link belongs.
+ * @param internalLinkUuid The UUID of the link.
+ * @param localeParam The locale of the title value to update.
+ * @param value The localized value.
+ *
+ * @return A redirect to the details view of the link.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/internal-links/{interalLinkUuid}/title/@edit/{locale}")
@@ -923,6 +1217,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Removes a localized title value from an internal link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the link belongs.
+ * @param internalLinkUuid The UUID of the link.
+ * @param localeParam The locale of the value to remove.
+ *
+ * @return A redirect to the details view of the link.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/internal-links/{interalLinkUuid}/title/@remove/{locale}"
@@ -971,6 +1275,19 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Removes an attachment from an {@link AttachmentList}. The {@link Asset}
+ * of the attachment will not be deleted unless it is a related link.
+ *
+ * @param listIdentifierParam The identifier of the {@link AttachmentList}
+ * to which the attachment belongs.
+ * @param attachmentUuid The UUID of the attachment to remove.
+ * @param confirm The value of the {@code confirm} parameter. If
+ * the value anything other than the string
+ * {@code true} the method does nothing.
+ *
+ * @return
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/attachments/{attachmentUuid}/@remove")
@@ -1012,6 +1329,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Move an attachment list one position up.
+ *
+ * @param listIdentifierParam The identifer of the list to move.
+ *
+ * @return A redirect to list of attachment lists.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/@moveUp")
@@ -1038,6 +1362,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Move an attachment list one position down.
+ *
+ * @param listIdentifierParam The identifer of the list to move.
+ *
+ * @return A redirect to list of attachment lists.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/@moveDown")
@@ -1064,6 +1395,14 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Move an attachment one position up.
+ *
+ * @param listIdentifierParam The identifer to which the attachment belongs.
+ * @param attachmentUuid The UUID of the attachment ot move.
+ *
+ * @return A redirect to list of attachment lists and attachments.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/attachments/{attachmentUuid}/@moveUp")
@@ -1101,6 +1440,14 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * Move an attachment one position down.
+ *
+ * @param listIdentifierParam The identifer to which the attachment belongs.
+ * @param attachmentUuid The UUID of the attachment ot move.
+ *
+ * @return A redirect to list of attachment lists and attachements.
+ */
@POST
@Path(
"/attachmentlists/{attachmentListIdentifier}/attachments/{attachmentUuid}/@moveDown")
@@ -1138,6 +1485,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
);
}
+ /**
+ * A helper function to find an attachment list.
+ *
+ * @param attachmentListIdentifier The idenfifier of the attachment list.
+ *
+ * @return An {@link Optional} with the attachment list or an empty optional
+ * if the current content item has no list with the provided
+ * identifier.
+ */
private Optional findAttachmentList(
final String attachmentListIdentifier
) {
@@ -1169,6 +1525,13 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return listResult;
}
+ /**
+ * Show the "attachment list not found" error page.
+ *
+ * @param listIdentifier The identifier of the list that was not found.
+ *
+ * @return The template for the "attachment list not found" page.
+ */
private String showAttachmentListNotFound(final String listIdentifier) {
models.put("contentItem", itemManager.getItemPath(document));
models.put("listIdentifier", listIdentifier);
@@ -1205,6 +1568,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return dto;
}
+ /**
+ * Helper function for building a {@link ItemAttachmentDto} for an
+ * {@link ItemAttachment}.
+ *
+ * @param itemAttachment The {@link ItemAttachment} from which the
+ * {@link ItemAttachmentDto} is build.
+ *
+ * @return The {@link ItemAttachmentDto}.
+ */
private ItemAttachmentDto buildItemAttachmentDto(
final ItemAttachment> itemAttachment
) {
@@ -1233,6 +1605,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return dto;
}
+ /**
+ * Build the model for a row in the asset folder listing.
+ *
+ * @param section The content section.
+ * @param entry The {@link AssetFolderEntry} from which the model is
+ * build.
+ *
+ * @return The {@link AssetFolderRowModel} for the provided {@code entry}.
+ */
private AssetFolderRowModel buildAssetFolderRowModel(
final ContentSection section, final AssetFolderEntry entry
) {
@@ -1291,6 +1672,14 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return row;
}
+ /**
+ * Build the model for a row in the asset folder listing.
+ *
+ * @param section The content section.
+ * @param asset The {@link Asset} from which the model is build.
+ *
+ * @return The {@link AssetFolderRowModel} for the provided {@code asset}.
+ */
private AssetFolderRowModel buildAssetFolderRowModel(
final ContentSection section, final Asset asset
) {
@@ -1315,6 +1704,16 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return row;
}
+ /**
+ * Build the model for a row in the document folder listing.
+ *
+ * @param section The content section.
+ * @param entry The {@link DocumentFolderEntry} from which the model is
+ * build.
+ *
+ * @return The {@link DocumentFolderRowModel} for the provided
+ * {@code entry}.
+ */
private DocumentFolderRowModel buildDocumentFolderRowModel(
final ContentSection section, final DocumentFolderEntry entry
) {
@@ -1441,6 +1840,15 @@ public class RelatedInfoStep implements MvcAuthoringStep {
return row;
}
+ /**
+ * Build the model for a row in the document folder listing.
+ *
+ * @param section The content section.
+ * @param contentItem The {@link Contentitem} from which the model is build.
+ *
+ * @return The {@link DocumentFolderRowModel} for the provided
+ * {@code contentItem}.
+ */
private DocumentFolderRowModel buildDocumentFolderRowModel(
final ContentSection section, final ContentItem contentItem
) {
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/SelectedDocumentModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/SelectedDocumentModel.java
index 4028ac02a..4a19d8187 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/SelectedDocumentModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/SelectedDocumentModel.java
@@ -44,6 +44,8 @@ import javax.inject.Inject;
import javax.inject.Named;
/**
+ * Model/named bean providing data about the currently selected document for
+ * several views.
*
* @author Jens Pelzetter
*/
@@ -51,49 +53,107 @@ import javax.inject.Named;
@Named("CmsSelectedDocumentModel")
public class SelectedDocumentModel {
+ /**
+ * Used to retrive information about tasks.
+ */
@Inject
private AssignableTaskManager taskManager;
+ /**
+ * All available authoring steps.
+ */
@Inject
private Instance authoringSteps;
+ /**
+ * Used to get information about the item.
+ */
@Inject
private ContentItemManager itemManager;
+ /**
+ * Used to get information about folders.
+ */
@Inject
private FolderManager folderManager;
+ /**
+ * Used to retrieve some localized data.
+ */
@Inject
private GlobalizationHelper globalizationHelper;
+ /**
+ * Used to check permissions
+ */
@Inject
private PermissionChecker permissionChecker;
+ /**
+ * Used to get the current user.
+ */
@Inject
private Shiro shiro;
+ /**
+ * The current content item/document.
+ */
private ContentItem item;
+ /**
+ * The name of the current content item.
+ */
private String itemName;
-
+
+ /**
+ * The title of the current content item. This value is determined from
+ * {@link ContentItem#title} using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String itemTitle;
+ /**
+ * The path of the current item.
+ */
private String itemPath;
+ /**
+ * The breadcrumb trail of the folder of the current item.
+ */
private List parentFolderBreadcrumbs;
+ /**
+ * List of authoring steps appliable for the current item.
+ */
private List authoringStepsList;
+ /**
+ * Should the default steps be excluded?
+ */
private boolean excludeDefaultAuthoringSteps;
+ /**
+ * The workflow assigned to the current content item.
+ */
private Workflow workflow;
+ /**
+ * The name of the workflow assigned to the current item. This value is
+ * determined from {@link Workflow#name} using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String workflowName;
+ /**
+ * The current task of the workflow assigned to the current item.
+ */
private TaskListEntry currentTask;
+ /**
+ * The tasks of the workflow assigned to the current item.
+ */
private List allTasks;
-
+
public String getItemName() {
return itemName;
}
@@ -136,6 +196,12 @@ public class SelectedDocumentModel {
);
}
+ /**
+ * Sets the current content item/document and sets the properties of this
+ * model based on the item.
+ *
+ * @param item
+ */
void setContentItem(final ContentItem item) {
this.item = Objects.requireNonNull(item);
itemName = item.getDisplayName();
@@ -175,6 +241,14 @@ public class SelectedDocumentModel {
}
}
+ /**
+ * Helper method for building the breadcrumb trail for the folder of the
+ * current item.
+ *
+ * @param folder The folder of the current item.
+ *
+ * @return The breadcrumb trail of the folder.
+ */
private FolderBreadcrumbsModel buildFolderBreadcrumbsModel(
final Folder folder
) {
@@ -185,6 +259,14 @@ public class SelectedDocumentModel {
return model;
}
+ /**
+ * Helper method for building a {@link TaskListEntry} from a
+ * {@link AssignableTask}.
+ *
+ * @param task The task.
+ *
+ * @return A {@link TaskListEntry} for the task.
+ */
private TaskListEntry buildTaskListEntry(final AssignableTask task) {
final TaskListEntry entry = new TaskListEntry();
entry.setTaskUuid(task.getUuid());
@@ -210,6 +292,14 @@ public class SelectedDocumentModel {
return entry;
}
+ /**
+ * Helper method for building the list of applicable authoring steps for the
+ * current item.
+ *
+ * @param item The current item.
+ *
+ * @return The list of applicable authoring steps for the current item.
+ */
private List buildAuthoringStepsList(
final ContentItem item
) {
@@ -229,6 +319,14 @@ public class SelectedDocumentModel {
.collect(Collectors.toList());
}
+ /**
+ * Helper method for building a {@link AuthoringStepListEntry} from the
+ * {@link MvcAuthoringStep}.
+ *
+ * @param step Th step.
+ *
+ * @return An {@link AuthoringStepListEntry} for the step.
+ */
private AuthoringStepListEntry buildAuthoringStepListEntry(
final MvcAuthoringStep step
) {
@@ -239,6 +337,13 @@ public class SelectedDocumentModel {
return entry;
}
+ /**
+ * Helper method for retrieving the path fragment of an authoring step.
+ *
+ * @param step The step.
+ *
+ * @return The path fragment of the step.
+ */
private String readAuthoringStepPathFragment(final MvcAuthoringStep step) {
return step
.getClass()
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/TaskListEntry.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/TaskListEntry.java
index ae550449a..8946f77e1 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/TaskListEntry.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/TaskListEntry.java
@@ -18,26 +18,56 @@
*/
package org.librecms.ui.contentsections.documents;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.libreccm.workflow.Task;
import org.libreccm.workflow.TaskState;
+import org.librecms.contentsection.ContentItem;
/**
+ * An entry in the list of tasks of the workflow assigned to an
+ * {@link ContentItem}.
*
* @author Jens Pelzetter
*/
public class TaskListEntry {
+ /**
+ * The UUID of the task.
+ */
private String taskUuid;
+ /**
+ * The label of the task. This value is determined from {@link Task#label}
+ * using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String label;
+ /**
+ * The description of the task. This value is determined from
+ * {@link Task#description} using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
+ * }.
+ */
private String description;
+ /**
+ * The state of the task.
+ */
private TaskState taskState;
+ /**
+ * Is the task the current task?
+ */
private boolean currentTask;
+ /**
+ * Is the task assigned to the current user?
+ */
private boolean assignedToCurrentUser;
+ /**
+ * Is the task locked?
+ */
private boolean locked;
public String getTaskUuid() {