Fixed typos in comments

pull/10/head
Jens Pelzetter 2021-05-13 17:44:33 +02:00
parent 3c486f7610
commit 59dac810ac
8 changed files with 64 additions and 49 deletions

View File

@ -21,6 +21,8 @@ package org.librecms.ui.contentsections;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.libreccm.ui.IsAuthenticatedFilter; 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.AuthoringStepsValidator;
import org.librecms.ui.contentsections.documents.DocumentController; import org.librecms.ui.contentsections.documents.DocumentController;
import org.librecms.ui.contentsections.documents.DocumentLifecyclesController; import org.librecms.ui.contentsections.documents.DocumentLifecyclesController;
@ -50,7 +52,14 @@ public class ContentSectionApplication extends Application {
); );
@Inject @Inject
private AuthoringStepsValidator stepsValidator; private AuthoringStepsValidator authoringStepsValidator;
@Inject
private AssetEditStepsValidator editStepsValidator;
@Inject
@Any
private Instance<MvcAssetEditSteps> assetEditSteps;
@Inject @Inject
@Any @Any
@ -76,6 +85,9 @@ public class ContentSectionApplication extends Application {
classes.addAll(getAuthoringSteps()); classes.addAll(getAuthoringSteps());
classes.addAll(getAuthoringStepResources()); classes.addAll(getAuthoringStepResources());
classes.addAll(getAssetEditSteps());
classes.addAll(getAssetEditStepResources());
classes.add(IsAuthenticatedFilter.class); classes.add(IsAuthenticatedFilter.class);
return classes; return classes;
@ -86,7 +98,7 @@ public class ContentSectionApplication extends Application {
.stream() .stream()
.map(MvcAuthoringSteps::getClasses) .map(MvcAuthoringSteps::getClasses)
.flatMap(Set::stream) .flatMap(Set::stream)
.filter(stepsValidator::validateAuthoringStep) .filter(authoringStepsValidator::validateAuthoringStep)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
@ -98,4 +110,21 @@ public class ContentSectionApplication extends Application {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
private Set<Class<?>> getAssetEditSteps() {
return assetEditSteps
.stream()
.map(MvcAssetEditSteps::getClasses)
.flatMap(Set::stream)
.filter(editStepsValidator::validateEditStep)
.collect(Collectors.toSet());
}
private Set<Class<?>> getAssetEditStepResources() {
return assetEditSteps
.stream()
.map(MvcAssetEditSteps::getResourceClasses)
.flatMap(Set::stream)
.collect(Collectors.toSet());
}
} }

View File

@ -43,7 +43,8 @@ public class AuthoringStepsValidator {
"Class {} is part of a set of authoringsteps, but is not" "Class {} is part of a set of authoringsteps, but is not"
+ " annotated with {}. The class will be ignored.", + " annotated with {}. The class will be ignored.",
stepClass.getName(), stepClass.getName(),
Controller.class.getName()); Controller.class.getName()
);
return false; return false;
} }
@ -86,7 +87,8 @@ public class AuthoringStepsValidator {
public boolean supportsItem( public boolean supportsItem(
final Class<?> stepClass, final ContentItem item final Class<?> stepClass, final ContentItem item
) { ) {
final MvcAuthoringStepDef stepAnnotation = stepClass.getAnnotation(MvcAuthoringStepDef.class final MvcAuthoringStepDef stepAnnotation = stepClass.getAnnotation(
MvcAuthoringStepDef.class
); );
if (stepAnnotation == null) { if (stepAnnotation == null) {
@ -97,4 +99,5 @@ public class AuthoringStepsValidator {
stepAnnotation.supportedDocumentType() stepAnnotation.supportedDocumentType()
); );
} }
} }

View File

@ -26,7 +26,7 @@ package org.librecms.ui.contentsections.documents;
public final class DefaultAuthoringStepConstants { public final class DefaultAuthoringStepConstants {
private DefaultAuthoringStepConstants() { private DefaultAuthoringStepConstants() {
// Nothing
} }
/** /**

View File

@ -49,7 +49,6 @@ import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Any; import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance; import javax.enterprise.inject.Instance;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject; import javax.inject.Inject;
import javax.mvc.Controller; import javax.mvc.Controller;
import javax.mvc.Models; import javax.mvc.Models;
@ -113,19 +112,12 @@ public class DocumentController {
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;
/**
* All available {@link MvcAuthoringStepDef}s.
*/
@Inject
@Any
private Instance<MvcAuthoringStepDef> authoringSteps;
/** /**
* All available {@link MvcDocumentCreateStep}s. * All available {@link MvcDocumentCreateStep}s.
*/ */
@Inject @Inject
@Any @Any
private Instance<MvcDocumentCreateStep<?>> createSteps; private Instance<MvcDocumentCreateStep<?>> documentCreateSteps;
/** /**
* Messages for default steps * Messages for default steps
@ -161,7 +153,7 @@ public class DocumentController {
private PublishStepModel publishStepModel; 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. * (content item} from the view.
*/ */
@Inject @Inject
@ -188,15 +180,15 @@ public class DocumentController {
// return "org/librecms/ui/contentsection/documents/pathTest.xhtml"; // return "org/librecms/ui/contentsection/documents/pathTest.xhtml";
// } // }
/** /**
* Redirect requests to the root path of this controller to the * Redirect requests to the root path of this controller to the path for
* {@link DocumentFolderController}. The root path of this controller has no * displaying the content of the root document folder. The root path of this
* function. We assume that somebody who access the root folders wants to * controller has no function. We assume that somebody who access the root
* browse all documents in the content section. Therefore we redirect these * folders wants to browse all documents in the content section. Therefore
* requests to the {@link DocumentFolderController}. * we redirect these requests to the root folder.
* *
* @param sectionIdentifier The identififer of the current content section. * @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 @GET
@Path("/") @Path("/")
@ -284,7 +276,6 @@ public class DocumentController {
@Path("/{folderPath:(.+)?}/@create/{documentType}") @Path("/{folderPath:(.+)?}/@create/{documentType}")
@AuthorizationRequired @AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@SuppressWarnings("unchecked")
public String showCreateStepPost( public String showCreateStepPost(
@PathParam("sectionIdentifier") final String sectionIdentifier, @PathParam("sectionIdentifier") final String sectionIdentifier,
@PathParam("folderPath") final String folderPath, @PathParam("folderPath") final String folderPath,
@ -320,7 +311,6 @@ public class DocumentController {
@AuthorizationRequired @AuthorizationRequired
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@SuppressWarnings({"unchecked", "unchecked"})
public String createDocument( public String createDocument(
@PathParam("sectionIdentifier") final String sectionIdentifier, @PathParam("sectionIdentifier") final String sectionIdentifier,
@PathParam("folderPath") final String folderPath, @PathParam("folderPath") final String folderPath,
@ -823,7 +813,8 @@ public class DocumentController {
item.getContentType().getContentSection().getLabel() item.getContentType().getContentSection().getLabel()
) )
.replace( .replace(
String.format("/{%s}", String.format(
"/{%s}",
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM
), ),
itemManager.getItemPath(item) itemManager.getItemPath(item)
@ -895,7 +886,7 @@ public class DocumentController {
/** /**
* Helper method for showing the "document folder not found" page if there * 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 section The content section.
* @param folderPath The folder path. * @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. * requested document type is not available for the current content section.
* *
* @param section The 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( private String showDocumentTypeNotFound(
final ContentSection section, final String documentType final ContentSection section, final String documentType
@ -1021,7 +1012,7 @@ public class DocumentController {
// final Instance<MvcDocumentCreateStep<?>> instance = createSteps // final Instance<MvcDocumentCreateStep<?>> instance = createSteps
// .select(new CreateDocumentOfTypeLiteral(documentClass)); // .select(new CreateDocumentOfTypeLiteral(documentClass));
final Instance<? extends MvcDocumentCreateStep<?>> instance final Instance<? extends MvcDocumentCreateStep<?>> instance
= createSteps.select(createStepClass); = documentCreateSteps.select(createStepClass);
if (instance.isUnsatisfied() || instance.isAmbiguous()) { if (instance.isUnsatisfied() || instance.isAmbiguous()) {
return new CreateStepResult( return new CreateStepResult(
showCreateStepNotAvailable(section, folderPath, documentType) showCreateStepNotAvailable(section, folderPath, documentType)

View File

@ -20,11 +20,13 @@ package org.librecms.ui.contentsections.documents;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; 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 * item). The classes provided for {@link #createStep()} and
* {@link #authoringSteps() } provide information about the steps. * {@link #authoringSteps() } provide information about the steps.
* *
@ -33,6 +35,7 @@ import java.lang.annotation.RetentionPolicy;
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface MvcAuthoringKit { public @interface MvcAuthoringKit {

View File

@ -25,19 +25,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import javax.inject.Named;
/** /**
* Metadata of an authoring step for documents (content items). * 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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)

View File

@ -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 * CDI beans (request scope is recommended). They are retrieved by the
* {@link DocumentController} using CDI. The {@link DocumentController} will * {@link DocumentController} using CDI. The {@link DocumentController} will
* first call * first call
* {@link #setContentSection(org.librecms.contentsection.ContentSection)} and {@link #setFolder(org.librecms.contentsection.Folder) * {@link #setContentSection(org.librecms.contentsection.ContentSection)} and {@link #setFolder(org.librecms.contentsection.Folder)
* } to provide the current current content section and folder. After that, * } 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. * will be called.
* *
* In most cases, {@link AbstractMvcDocumentCreateStep} should be used as * In most cases, {@link AbstractMvcDocumentCreateStep} should be used as

View File

@ -48,7 +48,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
import static javax.transaction.Transactional.TxType.values;
/** /**
* Model/named bean providing data about the currently selected document for * Model/named bean providing data about the currently selected document for