From 59dac810acc3e2abc8eba117bbdc98e431e056b5 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 13 May 2021 17:44:33 +0200 Subject: [PATCH] Fixed typos in comments --- .../ContentSectionApplication.java | 33 ++++++++++++++- .../documents/AuthoringStepsValidator.java | 17 ++++---- .../DefaultAuthoringStepConstants.java | 2 +- .../documents/DocumentController.java | 41 ++++++++----------- .../documents/MvcAuthoringKit.java | 5 ++- .../documents/MvcAuthoringStepDef.java | 10 ----- .../documents/MvcDocumentCreateStep.java | 4 +- .../documents/SelectedDocumentModel.java | 1 - 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionApplication.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionApplication.java index 34170509a..8b0ec5cf2 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionApplication.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionApplication.java @@ -21,6 +21,8 @@ package org.librecms.ui.contentsections; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.libreccm.ui.IsAuthenticatedFilter; +import org.librecms.ui.contentsections.assets.AssetEditStepsValidator; +import org.librecms.ui.contentsections.assets.MvcAssetEditSteps; import org.librecms.ui.contentsections.documents.AuthoringStepsValidator; import org.librecms.ui.contentsections.documents.DocumentController; import org.librecms.ui.contentsections.documents.DocumentLifecyclesController; @@ -50,7 +52,14 @@ public class ContentSectionApplication extends Application { ); @Inject - private AuthoringStepsValidator stepsValidator; + private AuthoringStepsValidator authoringStepsValidator; + + @Inject + private AssetEditStepsValidator editStepsValidator; + + @Inject + @Any + private Instance assetEditSteps; @Inject @Any @@ -76,6 +85,9 @@ public class ContentSectionApplication extends Application { classes.addAll(getAuthoringSteps()); classes.addAll(getAuthoringStepResources()); + classes.addAll(getAssetEditSteps()); + classes.addAll(getAssetEditStepResources()); + classes.add(IsAuthenticatedFilter.class); return classes; @@ -86,7 +98,7 @@ public class ContentSectionApplication extends Application { .stream() .map(MvcAuthoringSteps::getClasses) .flatMap(Set::stream) - .filter(stepsValidator::validateAuthoringStep) + .filter(authoringStepsValidator::validateAuthoringStep) .collect(Collectors.toSet()); } @@ -98,4 +110,21 @@ public class ContentSectionApplication extends Application { .collect(Collectors.toSet()); } + private Set> getAssetEditSteps() { + return assetEditSteps + .stream() + .map(MvcAssetEditSteps::getClasses) + .flatMap(Set::stream) + .filter(editStepsValidator::validateEditStep) + .collect(Collectors.toSet()); + } + + private Set> getAssetEditStepResources() { + return assetEditSteps + .stream() + .map(MvcAssetEditSteps::getResourceClasses) + .flatMap(Set::stream) + .collect(Collectors.toSet()); + } + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AuthoringStepsValidator.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AuthoringStepsValidator.java index 8f087f729..e370e403b 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AuthoringStepsValidator.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AuthoringStepsValidator.java @@ -32,21 +32,22 @@ import javax.ws.rs.Path; */ @Dependent public class AuthoringStepsValidator { - + private static final Logger LOGGER = LogManager.getLogger( AuthoringStepsValidator.class ); - + public boolean validateAuthoringStep(final Class stepClass) { if (stepClass.getAnnotation(Controller.class) == null) { LOGGER.warn( "Class {} is part of a set of authoringsteps, but is not" + " annotated with {}. The class will be ignored.", stepClass.getName(), - Controller.class.getName()); + Controller.class.getName() + ); return false; } - + final Path pathAnnotation = stepClass.getAnnotation(Path.class); if (pathAnnotation == null) { LOGGER.warn( @@ -70,7 +71,7 @@ public class AuthoringStepsValidator { MvcAuthoringSteps.PATH_PREFIX ); } - + if (stepClass.getAnnotation(MvcAuthoringStepDef.class) == null) { LOGGER.warn( "Class {} is part of a set of authoring steps, but is not " @@ -82,11 +83,12 @@ public class AuthoringStepsValidator { return true; } - + public boolean supportsItem( final Class stepClass, final ContentItem item ) { - final MvcAuthoringStepDef stepAnnotation = stepClass.getAnnotation(MvcAuthoringStepDef.class + final MvcAuthoringStepDef stepAnnotation = stepClass.getAnnotation( + MvcAuthoringStepDef.class ); if (stepAnnotation == null) { @@ -97,4 +99,5 @@ public class AuthoringStepsValidator { stepAnnotation.supportedDocumentType() ); } + } 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 8e2b6a240..c3aa86b91 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 @@ -26,7 +26,7 @@ package org.librecms.ui.contentsections.documents; public final class DefaultAuthoringStepConstants { private DefaultAuthoringStepConstants() { - + // Nothing } /** 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 b1eacf3c1..cc90c05c9 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 @@ -49,7 +49,6 @@ import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; import javax.enterprise.inject.Any; import javax.enterprise.inject.Instance; -import javax.enterprise.util.AnnotationLiteral; import javax.inject.Inject; import javax.mvc.Controller; import javax.mvc.Models; @@ -113,19 +112,12 @@ public class DocumentController { @Inject private ContentItemRepository itemRepo; - /** - * All available {@link MvcAuthoringStepDef}s. - */ - @Inject - @Any - private Instance authoringSteps; - /** * All available {@link MvcDocumentCreateStep}s. */ @Inject @Any - private Instance> createSteps; + private Instance> documentCreateSteps; /** * Messages for default steps @@ -161,7 +153,7 @@ public class DocumentController { private PublishStepModel publishStepModel; /** - * Named beans providing access to the properties of the selected document + * Named bean providing access to the properties of the selected document * (content item} from the view. */ @Inject @@ -188,15 +180,15 @@ public class DocumentController { // return "org/librecms/ui/contentsection/documents/pathTest.xhtml"; // } /** - * 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}. + * Redirect requests to the root path of this controller to the path for + * displaying the content of the root document folder. 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 root folder. * * @param sectionIdentifier The identififer of the current content section. * - * @return A redirect to the {@link DocumentFolderController}. + * @return A redirect to the root documents folder. */ @GET @Path("/") @@ -284,7 +276,6 @@ public class DocumentController { @Path("/{folderPath:(.+)?}/@create/{documentType}") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - @SuppressWarnings("unchecked") public String showCreateStepPost( @PathParam("sectionIdentifier") final String sectionIdentifier, @PathParam("folderPath") final String folderPath, @@ -320,7 +311,6 @@ public class DocumentController { @AuthorizationRequired @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Transactional(Transactional.TxType.REQUIRED) - @SuppressWarnings({"unchecked", "unchecked"}) public String createDocument( @PathParam("sectionIdentifier") final String sectionIdentifier, @PathParam("folderPath") final String folderPath, @@ -823,8 +813,9 @@ public class DocumentController { item.getContentType().getContentSection().getLabel() ) .replace( - String.format("/{%s}", - MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM + String.format( + "/{%s}", + MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM ), itemManager.getItemPath(item) ); @@ -895,7 +886,7 @@ public class DocumentController { /** * Helper method for showing the "document folder not found" page if there - * is not folder for the provided path. + * is no folder for the provided path. * * @param section The content section. * @param folderPath The folder path. @@ -912,13 +903,13 @@ public class DocumentController { } /** - * Helper method for showing the "documenttype not available" page if the + * Helper method for showing the "document type not available" page if the * requested document type is not available for the current content section. * * @param section The content section. - * @param folderPath The folder path. + * @param documentType The folder path. * - * @return The template of the "document folder not found" page. + * @return The template of the "document type not found" page. */ private String showDocumentTypeNotFound( final ContentSection section, final String documentType @@ -1021,7 +1012,7 @@ public class DocumentController { // final Instance> instance = createSteps // .select(new CreateDocumentOfTypeLiteral(documentClass)); final Instance> instance - = createSteps.select(createStepClass); + = documentCreateSteps.select(createStepClass); if (instance.isUnsatisfied() || instance.isAmbiguous()) { return new CreateStepResult( showCreateStepNotAvailable(section, folderPath, documentType) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringKit.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringKit.java index da0cfee83..fffa0b566 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringKit.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringKit.java @@ -20,11 +20,13 @@ package org.librecms.ui.contentsections.documents; import org.librecms.contentsection.ContentItem; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** - * Provides the steps for creating and viewing and editing a document (content + * Provides the steps for creating, viewing, and editing a document (content * item). The classes provided for {@link #createStep()} and * {@link #authoringSteps() } provide information about the steps. * @@ -33,6 +35,7 @@ import java.lang.annotation.RetentionPolicy; * * @author Jens Pelzetter */ +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface MvcAuthoringKit { diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringStepDef.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringStepDef.java index 2adbd9409..351fd8f49 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringStepDef.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcAuthoringStepDef.java @@ -25,19 +25,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Named; - /** * Metadata of an authoring step for documents (content items). * - * An authoring step for a document (content item). Implementing classes are - * used as subresources by {@link DocumentController#editDocument(java.lang.String, java.lang.String, java.lang.String) - * }. An implementation must be a named CDI bean (annotated with {@link Named}, - * annotated with the {@link AuthoringStepPathFragment} qualifier annotation. - * - * An implementation may contain multiple subresource paths for for displaying - * forms and apply changes from these forms. - * * @author Jens Pelzetter */ @Target(ElementType.TYPE) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcDocumentCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcDocumentCreateStep.java index 87356055b..feaac844b 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcDocumentCreateStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/MvcDocumentCreateStep.java @@ -28,13 +28,13 @@ import java.util.ResourceBundle; /** - * A create step for a document/content item. Implementing classes are MUST be + * A create step for a document/content item. Implementing classes MUST be * CDI beans (request scope is recommended). They are retrieved by the * {@link DocumentController} using CDI. The {@link DocumentController} will * first call * {@link #setContentSection(org.librecms.contentsection.ContentSection)} and {@link #setFolder(org.librecms.contentsection.Folder) * } to provide the current current content section and folder. After that, - * depending on the request method, either {@link #showCreateStep} or {@link #createItem(javax.ws.rs.core.Form)] + * depending on the request method, either {@link #showCreateStep} or {@link #createItem(java.util.Map) * will be called. * * In most cases, {@link AbstractMvcDocumentCreateStep} should be used as 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 04107922c..4d64e3894 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 @@ -48,7 +48,6 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Path; import javax.ws.rs.core.UriBuilder; -import static javax.transaction.Transactional.TxType.values; /** * Model/named bean providing data about the currently selected document for