Create steps now working
parent
2ab4b0c5ed
commit
9dc794a5fb
|
|
@ -18,20 +18,16 @@
|
|||
*/
|
||||
package org.librecms.ui.contentsections.documents;
|
||||
|
||||
import org.libreccm.api.IdentifierParser;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ContentSectionRepository;
|
||||
import org.librecms.contentsection.Folder;
|
||||
import org.librecms.contentsection.FolderManager;
|
||||
import org.librecms.contentsection.FolderRepository;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import javax.enterprise.util.AnnotationLiteral;
|
|||
import javax.inject.Inject;
|
||||
import javax.mvc.Controller;
|
||||
import javax.mvc.Models;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
|
|
@ -59,9 +60,8 @@ import javax.ws.rs.GET;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Form;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
/**
|
||||
* Controller for the UI for managing documents ({@link ContentItem}s.)
|
||||
|
|
@ -259,21 +259,19 @@ public class DocumentController {
|
|||
|
||||
@POST
|
||||
@Path("/@create/{documentType}")
|
||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
@AuthorizationRequired
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String createDocument(
|
||||
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||
@PathParam("documentType") final String documentType,
|
||||
//final MultivaluedMap<String, String> formParameters
|
||||
final Form form
|
||||
@Context final HttpServletRequest request
|
||||
) {
|
||||
return createDocument(
|
||||
sectionIdentifier,
|
||||
"",
|
||||
documentType,
|
||||
//formParameters
|
||||
form.asMap()
|
||||
request
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +285,7 @@ public class DocumentController {
|
|||
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||
@PathParam("folderPath") final String folderPath,
|
||||
@PathParam("documentType") final String documentType,
|
||||
final MultivaluedMap<String, String> formParameters
|
||||
@Context final HttpServletRequest request
|
||||
) {
|
||||
final CreateStepResult result = findCreateStep(
|
||||
sectionIdentifier,
|
||||
|
|
@ -295,7 +293,7 @@ public class DocumentController {
|
|||
);
|
||||
|
||||
if (result.isCreateStepAvailable()) {
|
||||
return result.getCreateStep().createItem(formParameters);
|
||||
return result.getCreateStep().createItem(request.getParameterMap());
|
||||
} else {
|
||||
return result.getErrorTemplate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import org.librecms.contentsection.Folder;
|
|||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
/**
|
||||
* A create step for a document/content item. Implementing classes are MUST be
|
||||
|
|
@ -63,7 +62,7 @@ public interface MvcDocumentCreateStep<T extends ContentItem> {
|
|||
*
|
||||
* @return A redirect to the first authoring step of the new document.
|
||||
*/
|
||||
String createItem(MultivaluedMap<String, String> formParams);
|
||||
String createItem(Map<String, String[]> formParams);
|
||||
|
||||
/**
|
||||
* Should be set by the implementing class to indicate if the current user
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ import org.librecms.contenttypes.Article;
|
|||
import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep;
|
||||
import org.librecms.ui.contentsections.documents.CreatesDocumentOfType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
|
@ -37,7 +39,6 @@ import javax.inject.Named;
|
|||
import javax.inject.Inject;
|
||||
import javax.mvc.Models;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
/**
|
||||
* Describes the create step for {@link Article}.
|
||||
|
|
@ -56,10 +57,10 @@ public class MvcArticleCreateStep
|
|||
|
||||
private static final String FORM_PARAM_SUMMARY = "summary";
|
||||
|
||||
private static final String FORM_PARAM_INITIAL_LOCALE = "initialLocale";
|
||||
private static final String FORM_PARAM_INITIAL_LOCALE = "locale";
|
||||
|
||||
private static final String FORM_PARAM_SELECTED_WORKFLOW
|
||||
= "selectedWorkflow";
|
||||
= "workflow";
|
||||
|
||||
/**
|
||||
* Provides functions for working with content items.
|
||||
|
|
@ -175,10 +176,10 @@ public class MvcArticleCreateStep
|
|||
@AuthorizationRequired
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public String createItem(final MultivaluedMap<String, String> formParams) {
|
||||
public String createItem(final Map<String, String[]> formParams) {
|
||||
if (!formParams.containsKey(FORM_PARAM_NAME)
|
||||
|| formParams.getFirst(FORM_PARAM_NAME) == null
|
||||
|| formParams.getFirst(FORM_PARAM_NAME).isEmpty()) {
|
||||
|| formParams.get(FORM_PARAM_NAME) == null
|
||||
|| formParams.get(FORM_PARAM_NAME).length == 0) {
|
||||
addMessage(
|
||||
"danger",
|
||||
globalizationHelper.getLocalizedTextsUtil(
|
||||
|
|
@ -188,7 +189,7 @@ public class MvcArticleCreateStep
|
|||
return showCreateStep();
|
||||
}
|
||||
|
||||
name = formParams.getFirst(FORM_PARAM_NAME);
|
||||
name = formParams.get(FORM_PARAM_NAME)[0];
|
||||
if (!name.matches("^([a-zA-Z0-9_-]*)$")) {
|
||||
addMessage(
|
||||
"danger",
|
||||
|
|
@ -200,8 +201,8 @@ public class MvcArticleCreateStep
|
|||
}
|
||||
|
||||
if (!formParams.containsKey(FORM_PARAM_TITLE)
|
||||
|| formParams.getFirst(FORM_PARAM_TITLE) == null
|
||||
|| formParams.getFirst(FORM_PARAM_TITLE).isEmpty()) {
|
||||
|| formParams.get(FORM_PARAM_TITLE) == null
|
||||
|| formParams.get(FORM_PARAM_TITLE).length == 0) {
|
||||
addMessage(
|
||||
"danger",
|
||||
globalizationHelper.getLocalizedTextsUtil(
|
||||
|
|
@ -210,11 +211,11 @@ public class MvcArticleCreateStep
|
|||
);
|
||||
return showCreateStep();
|
||||
}
|
||||
title = formParams.getFirst(FORM_PARAM_TITLE);
|
||||
title = formParams.get(FORM_PARAM_TITLE)[0];
|
||||
|
||||
if (!formParams.containsKey(FORM_PARAM_SUMMARY)
|
||||
|| formParams.getFirst(FORM_PARAM_SUMMARY) == null
|
||||
|| formParams.getFirst(FORM_PARAM_SUMMARY).isEmpty()) {
|
||||
|| formParams.get(FORM_PARAM_SUMMARY) == null
|
||||
|| formParams.get(FORM_PARAM_SUMMARY).length == 0) {
|
||||
addMessage(
|
||||
"danger",
|
||||
globalizationHelper.getLocalizedTextsUtil(
|
||||
|
|
@ -223,11 +224,11 @@ public class MvcArticleCreateStep
|
|||
);
|
||||
return showCreateStep();
|
||||
}
|
||||
summary = formParams.getFirst(FORM_PARAM_SUMMARY);
|
||||
summary = formParams.get(FORM_PARAM_SUMMARY)[0];
|
||||
|
||||
if (!formParams.containsKey(FORM_PARAM_INITIAL_LOCALE)
|
||||
|| formParams.getFirst(FORM_PARAM_INITIAL_LOCALE) == null
|
||||
|| formParams.getFirst(FORM_PARAM_INITIAL_LOCALE).isEmpty()) {
|
||||
|| formParams.get(FORM_PARAM_INITIAL_LOCALE) == null
|
||||
|| formParams.get(FORM_PARAM_INITIAL_LOCALE).length == 0) {
|
||||
addMessage(
|
||||
"danger",
|
||||
globalizationHelper.getLocalizedTextsUtil(
|
||||
|
|
@ -237,12 +238,12 @@ public class MvcArticleCreateStep
|
|||
return showCreateStep();
|
||||
}
|
||||
final Locale locale = new Locale(
|
||||
formParams.getFirst(FORM_PARAM_INITIAL_LOCALE)
|
||||
formParams.get(FORM_PARAM_INITIAL_LOCALE)[0]
|
||||
);
|
||||
|
||||
if (!formParams.containsKey(FORM_PARAM_SELECTED_WORKFLOW)
|
||||
|| formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW) == null
|
||||
|| formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW).isEmpty()) {
|
||||
|| formParams.get(FORM_PARAM_SELECTED_WORKFLOW) == null
|
||||
|| formParams.get(FORM_PARAM_SELECTED_WORKFLOW).length == 0) {
|
||||
addMessage(
|
||||
"danger",
|
||||
globalizationHelper.getLocalizedTextsUtil(
|
||||
|
|
@ -251,7 +252,7 @@ public class MvcArticleCreateStep
|
|||
);
|
||||
return showCreateStep();
|
||||
}
|
||||
selectedWorkflow = formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW);
|
||||
selectedWorkflow = formParams.get(FORM_PARAM_SELECTED_WORKFLOW)[0];
|
||||
|
||||
final Optional<Workflow> workflowResult = getContentSection()
|
||||
.getWorkflowTemplates()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<div class="container">
|
||||
<h1>#{CmsArticleMessageBundle['createform.title']}</h1>
|
||||
|
||||
<c:forEach items="#{CmsArticleCreateStep.messages.entrySet}"
|
||||
<c:forEach items="#{CmsArticleCreateStep.messages.entrySet()}"
|
||||
var="message">
|
||||
<div class="alert alert-#{message.key}" role="alert">
|
||||
#{message.value}
|
||||
|
|
|
|||
|
|
@ -30,3 +30,4 @@ basicproperties.title.header=Title
|
|||
basicproperties.description.header=Summary
|
||||
createform.title=Create new article
|
||||
createform.summary.label=Summary
|
||||
createstep.workflow.none_selected=No workflow selected
|
||||
|
|
|
|||
|
|
@ -30,3 +30,4 @@ basicproperties.title.header=Titel
|
|||
basicproperties.description.header=Zusammenfassung
|
||||
createform.title=Neuen Artikel anlegen
|
||||
createform.summary.label=Zusammenfassung
|
||||
createstep.workflow.none_selected=Es wurde keine Arbeitsablauf ausgew\u00e4hlt
|
||||
|
|
|
|||
Loading…
Reference in New Issue