diff --git a/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java b/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java
index 85c20347d..cb8145ee3 100644
--- a/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java
+++ b/ccm-cms/src/main/java/org/librecms/contenttypes/Article.java
@@ -75,13 +75,13 @@ import javax.xml.bind.annotation.XmlRootElement;
order = 2
)
})
-@MvcAuthoringKit(
- createStep = MvcArticleCreateStep.class,
- authoringSteps = {
- MvcArticlePropertiesStep.class,
- MvcArticleTextBodyStep.class
- }
-)
+//@MvcAuthoringKit(
+// createStep = MvcArticleCreateStep.class,
+// authoringSteps = {
+// MvcArticlePropertiesStep.class,
+// MvcArticleTextBodyStep.class
+// }
+//)
@XmlRootElement(name = "article", namespace = CMS_XML_NS)
public class Article extends ContentItem implements Serializable {
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 0830628ad..63d0799ab 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
@@ -18,6 +18,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.documents.DocumentController;
import org.librecms.ui.contentsections.documents.DocumentLifecyclesController;
@@ -31,12 +33,16 @@ import javax.ws.rs.core.Application;
/**
* JAX-RS application for managing a content section.
- *
+ *
* @author Jens Pelzetter
*/
@ApplicationPath("/@contentsections")
public class ContentSectionApplication extends Application {
+ private static final Logger LOGGER = LogManager.getLogger(
+ ContentSectionApplication.class
+ );
+
@Override
public Set> getClasses() {
final Set> classes = new HashSet<>();
@@ -58,4 +64,6 @@ public class ContentSectionApplication extends Application {
return classes;
}
+
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionModel.java
index 6e4f62041..5e3d382e2 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/ContentSectionModel.java
@@ -79,7 +79,7 @@ public class ContentSectionModel {
*
* @param section The content section.
*/
- protected void setSection(final ContentSection section) {
+ public void setSection(final ContentSection section) {
this.section = Objects.requireNonNull(
section, "Parameter section can't be null"
);
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AbstractMvcDocumentCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AbstractMvcDocumentCreateStep.java
new file mode 100644
index 000000000..b1be45a8c
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/AbstractMvcDocumentCreateStep.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2021 LibreCCM Foundation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+package org.librecms.ui.contentsections.documents;
+
+import org.libreccm.api.Identifier;
+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 org.librecms.contentsection.FolderType;
+import org.librecms.ui.contentsections.ItemPermissionChecker;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ * @param
+ */
+@Dependent
+public abstract class AbstractMvcDocumentCreateStep
+ implements MvcDocumentCreateStep {
+
+ @Inject
+ private ContentSectionRepository sectionRepo;
+
+ @Inject
+ private FolderRepository folderRepository;
+
+ /**
+ * Provides operations for folders.
+ */
+ @Inject
+ private FolderManager folderManager;
+
+ /**
+ * Provides functions for working with {@link LocalizedString}s.
+ */
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Inject
+ private IdentifierParser identifierParser;
+
+ private boolean canCreate;
+
+ /**
+ * The current folder.
+ */
+ private Folder folder;
+
+ /**
+ * The current content section.
+ */
+ private ContentSection section;
+
+ /**
+ * Messages to be shown to the user.
+ */
+ private SortedMap messages;
+
+ public AbstractMvcDocumentCreateStep() {
+ messages = new TreeMap<>();
+ }
+
+ @Override
+ public ContentSection getContentSection() {
+ return section;
+ }
+
+ @Override
+ public void setContentSection(final ContentSection section) {
+ this.section = section;
+ }
+
+ @Override
+ public String getContentSectionLabel() {
+ return section.getLabel();
+ }
+
+ @Override
+ public String getContentSectionTitle() {
+ return globalizationHelper.getValueFromLocalizedString(
+ section.getTitle()
+ );
+ }
+
+// protected final void setContentSectionByIdentifier(
+// final String sectionIdentifierParam
+// ) {
+// final Identifier identifier = identifierParser.parseIdentifier(
+// sectionIdentifierParam
+// );
+// final Optional sectionResult;
+// switch (identifier.getType()) {
+// case ID:
+// sectionResult = sectionRepo.findById(
+// Long.parseLong(identifier.getIdentifier())
+// );
+// break;
+// case UUID:
+// sectionResult = sectionRepo.findByUuid(
+// identifier.getIdentifier()
+// );
+// break;
+// default:
+// sectionResult = sectionRepo.findByLabel(
+// identifier.getIdentifier()
+// );
+// break;
+// }
+//
+// if (sectionResult.isPresent()) {
+// section = sectionResult.get();
+// canCreate = true;
+// } else {
+// messages.put("error", "ContentSection not found.");
+// canCreate = false;
+// }
+// }
+
+// protected final void setFolderByPath(final String folderPath) {
+// final Optional folderResult = folderRepository.findByPath(
+// section,
+// folderPath,
+// FolderType.DOCUMENTS_FOLDER
+// );
+// if (folderResult.isPresent()) {
+// folder = folderResult.get();
+// if (itemPermissionChecker.canCreateNewItems(folder)) {
+// canCreate = true;
+// } else {
+// canCreate = false;
+// messages.put("error", "Not allowed");
+// }
+// } else {
+// messages.put("error", "Folder not found.");
+// canCreate = false;
+// }
+// }
+ @Override
+ public boolean getCanCreate() {
+ return canCreate;
+ }
+
+ @Override
+ public Folder getFolder() {
+ return folder;
+ }
+
+ @Override
+ public void setFolder(final Folder folder) {
+ this.folder = folder;
+ }
+
+ @Override
+ public String getFolderPath() {
+ return folderManager.getFolderPath(folder);
+ }
+
+ @Override
+ public Map getMessages() {
+ return Collections.unmodifiableSortedMap(messages);
+ }
+
+ public void addMessage(final String context, final String message) {
+ messages.put(context, message);
+ }
+
+ public void setMessages(final SortedMap messages) {
+ this.messages = new TreeMap<>(messages);
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentSectionNotFound.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentSectionNotFound.java
deleted file mode 100644
index ea08da863..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentSectionNotFound.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when the requested
- * content section does not exist.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */
-public class ContentSectionNotFound
- implements MvcDocumentCreateStep, MvcAuthoringStep {
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Class extends ContentItem> supportedDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentItem(ContentItem document) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentItem getContentItem() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String showStep() {
- return "org/librecms/ui/contentsection/contentsection-not-found.xhtml";
- }
-
- @GET
- @Path("/documentPath:(.+)?")
- public String showForAllGets() {
- return showStep();
- }
-
- @POST
- @Path("/")
- public String showForPost() {
- return showStep();
- }
-
- @POST
- @Path("/documentPath:(.+)?")
- public String showForAllPosts() {
- return showStep();
- }
-
- @Override
- public String showCreateForm() {
- return showStep();
- }
-
- @Override
- public String createContentItem() {
- return showStep();
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentItemPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentItemTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentTypeNotAvailable.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentTypeNotAvailable.java
deleted file mode 100644
index 3d679898a..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/ContentTypeNotAvailable.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when the requested
- * document type/content type is not available for the current content section.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */
-public class ContentTypeNotAvailable
- implements MvcDocumentCreateStep {
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String showCreateForm() {
- return "org/librecms/ui/contentsection/documents/document-type-not-available.xhtml";
- }
-
- @Override
- public String createContentItem() {
- return "org/librecms/ui/contentsection/documents/document-type-not-available.xhtml";
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateDenied.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateDenied.java
deleted file mode 100644
index a3b795f8e..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateDenied.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when the current
- * user is not permitted to create new items.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */public class CreateDenied
- implements MvcDocumentCreateStep{
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String showCreateForm() {
- return "org/librecms/ui/contentsection/documents/access-denied.xhtml";
- }
-
- @Override
- public String createContentItem() {
- return "org/librecms/ui/contentsection/documents/access-denied.xhtml";
- }
-
-}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateStepNotAvailable.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateStepNotAvailable.java
deleted file mode 100644
index 7c91a1e07..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CreateStepNotAvailable.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when not create step
- * for the requested document type/content type is available.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */
-public class CreateStepNotAvailable
- implements MvcDocumentCreateStep {
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @POST
- @Path("/")
- @Override
- public String showCreateForm() {
- return "org/librecms/ui/contentsection/documents/create-step-not-available.xhtml";
- }
-
- @POST
- @Path("/@create")
- @Override
- public String createContentItem() {
- return "org/librecms/ui/contentsection/documents/create-step-not-available.xhtml";
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
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 175addd10..597814ef5 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
@@ -32,15 +32,14 @@ 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.ContentSectionModel;
import org.librecms.ui.contentsections.ContentSectionsUi;
import org.librecms.ui.contentsections.DocumentFolderController;
import org.librecms.ui.contentsections.ItemPermissionChecker;
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;
@@ -57,6 +56,7 @@ 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.MultivaluedMap;
/**
* Controller for the UI for managing documents ({@link ContentItem}s.)
@@ -74,6 +74,9 @@ public class DocumentController {
@Inject
private ContentItemManager itemManager;
+ @Inject
+ private ContentSectionModel sectionModel;
+
/**
* {@link ContentSectionsUi} instance providing for helper functions for
* dealing with {@link ContentSection}s.
@@ -100,12 +103,11 @@ public class DocumentController {
@Inject
private ContentItemRepository itemRepo;
- /**
- * All available {@link MvcAuthoringStep}s.
- */
- @Inject
- private Instance authoringSteps;
-
+// /**
+// * All available {@link MvcAuthoringStep}s.
+// */
+// @Inject
+// private Instance authoringSteps;
/**
* All available {@link MvcDocumentCreateStep}s.
*/
@@ -152,6 +154,26 @@ public class DocumentController {
@Inject
private SelectedDocumentModel selectedDocumentModel;
+// @GET
+// @Path("/@pathtest")
+// public String pathTest() {
+//
+// models.put("folderPath", "--root folder--");
+//
+// return "org/librecms/ui/contentsection/documents/pathTest.xhtml";
+// }
+//
+// @GET
+// @Path("/{folderPath:(.*)?}/@pathtest")
+// public String pathTest(@PathParam("folderPath") final String folderPath) {
+// if (folderPath == null || folderPath.isEmpty()) {
+// models.put("folderPath", "--root folder--");
+// } else {
+// models
+// .put("folderPath", String.format("folderPath: %s", folderPath));
+// }
+// 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
@@ -184,236 +206,214 @@ public class DocumentController {
* @param sectionIdentifier The identifier of the current content section.
* @param documentType The type of the document to create.
*
- * @return The create step subresource.
+ * @return The template of the create step.
*/
+ @GET
@Path("/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
- public MvcDocumentCreateStep extends ContentItem> createDocument(
+ public String showCreateStep(
@PathParam("sectionIdentifier") final String sectionIdentifier,
@PathParam("documentType") final String documentType
) {
- return createDocument(sectionIdentifier, "", documentType);
+ return showCreateStep(sectionIdentifier, "", documentType);
}
/**
- * Delegates requests for the path {@code @create} to the create step
- * (subresource) of the document type.
+ * Shows the create step 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.
+ * @return The create step template.
*/
- @Path("/{folderPath:(.+)?}/@create/")
+ @GET
+ @Path("/{folderPath:(.+)?}/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@SuppressWarnings("unchecked")
- public MvcDocumentCreateStep extends ContentItem> createDocument(
+ public String showCreateStep(
@PathParam("sectionIdentifier") final String sectionIdentifier,
@PathParam("folderPath") final String folderPath,
@FormParam("documentType") final String documentType
) {
- final Optional sectionResult = sectionsUi
- .findContentSection(sectionIdentifier);
- if (!sectionResult.isPresent()) {
- models.put("sectionIdentifier", sectionIdentifier);
- return new ContentSectionNotFound();
- }
- final ContentSection section = sectionResult.get();
+ final CreateStepResult result = findCreateStep(
+ sectionIdentifier,
+ folderPath, documentType
+ );
- final Folder folder;
- if (folderPath.isEmpty()) {
- folder = section.getRootDocumentsFolder();
+ if (result.isCreateStepAvailable()) {
+ return result.getCreateStep().showCreateStep();
} else {
- final Optional folderResult = folderRepo
- .findByPath(
- section, folderPath, FolderType.DOCUMENTS_FOLDER
- );
- if (!folderResult.isPresent()) {
- models.put("section", section.getLabel());
- models.put("folderPath", folderPath);
- return new FolderNotFound();
- }
- folder = folderResult.get();
+ return result.getErrorTemplate();
}
-
- if (!itemPermissionChecker.canCreateNewItems(folder)) {
- models.put("section", section.getLabel());
- models.put("folderPath", folderPath);
- models.put(
- "step", defaultStepsMessageBundle.getMessage("create_step")
- );
- return new CreateDenied();
- }
-
- final Class extends ContentItem> documentClass;
- try {
- documentClass = (Class extends ContentItem>) Class.forName(
- documentType
- );
- } catch (ClassNotFoundException ex) {
- models.put("documentType", documentType);
- return new DocumentTypeClassNotFound();
- }
-
- final boolean hasRequestedType = section
- .getContentTypes()
- .stream()
- .anyMatch(
- type -> type.getContentItemClass().equals(documentType)
- );
- if (!hasRequestedType) {
- models.put("documentType", documentType);
- models.put("section", section.getLabel());
- return new ContentTypeNotAvailable();
- }
-
- final Instance> instance = createSteps
- .select(new CreateDocumentOfTypeLiteral(documentClass));
- if (instance.isUnsatisfied() || instance.isAmbiguous()) {
- models.put("section", section.getLabel());
- models.put("folderPath", folderPath);
- models.put("documentType", documentType);
- return new CreateStepNotAvailable();
- }
- final MvcDocumentCreateStep extends ContentItem> createStep = instance
- .get();
-
- createStep.setContentSection(section);
- createStep.setFolder(folder);
-
- 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:(.+)?}")
+ @POST
+ @Path("/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
- public String editDocument(
+ public String createDocument(
@PathParam("sectionIdentifier") final String sectionIdentifier,
- @PathParam("documentPath") final String documentPath
+ @PathParam("documentType") final String documentType,
+ final MultivaluedMap formParameters
) {
- final Optional sectionResult = sectionsUi
- .findContentSection(sectionIdentifier);
- if (!sectionResult.isPresent()) {
- sectionsUi.showContentSectionNotFound(sectionIdentifier);
- }
- final ContentSection section = sectionResult.get();
-
- final Optional itemResult = itemRepo
- .findByPath(section, documentPath);
- if (!itemResult.isPresent()) {
- models.put("section", section.getLabel());
- models.put("documentPath", documentPath);
- documentUi.showDocumentNotFound(section, documentPath);
- }
- final ContentItem item = itemResult.get();
- if (!itemPermissionChecker.canEditItem(item)) {
- return documentUi.showAccessDenied(
- section,
- item,
- defaultStepsMessageBundle.getMessage("edit_denied")
- );
- }
-
- return String.format(
- "redirect:/%s/documents/%s/@authoringsteps/%s",
+ return createDocument(
sectionIdentifier,
- documentPath,
- findPathFragmentForFirstStep(item)
+ "", documentType,
+ formParameters
);
}
- /**
- * 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}")
+ @POST
+ @Path("/{folderPath:(.+)?}/@create/{documentType}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
- public MvcAuthoringStep editDocument(
+ @SuppressWarnings({"unchecked", "unchecked"})
+ public String createDocument(
@PathParam("sectionIdentifier") final String sectionIdentifier,
- @PathParam("documentPath") final String documentPath,
- @PathParam("authoringStep") final String authoringStepIdentifier
+ @PathParam("folderPath") final String folderPath,
+ @PathParam("documentType") final String documentType,
+ final MultivaluedMap formParameters
) {
- final Optional sectionResult = sectionsUi
- .findContentSection(sectionIdentifier);
- if (!sectionResult.isPresent()) {
- models.put("sectionIdentifier", sectionIdentifier);
- return new ContentSectionNotFound();
+ final CreateStepResult result = findCreateStep(
+ sectionIdentifier,
+ folderPath, documentType
+ );
+
+ if (result.isCreateStepAvailable()) {
+ return result.getCreateStep().createItem(formParameters);
+ } else {
+ return result.getErrorTemplate();
}
- final ContentSection section = sectionResult.get();
-
- final Optional itemResult = itemRepo
- .findByPath(section, documentPath);
- if (!itemResult.isPresent()) {
- models.put("section", section.getLabel());
- models.put("documentPath", documentPath);
- return new DocumentNotFound();
- }
- final ContentItem item = itemResult.get();
- if (!itemPermissionChecker.canEditItem(item)) {
- models.put("section", section.getLabel());
- models.put("documentPath", itemManager.getItemFolder(item));
- models.put(
- "step", defaultStepsMessageBundle.getMessage("edit_step")
- );
- return new EditDenied();
- }
-
- final Instance instance = authoringSteps
- .select(
- new AuthoringStepPathFragmentLiteral(
- authoringStepIdentifier
- )
- );
- if (instance.isUnsatisfied() || instance.isAmbiguous()) {
- models.put("section", section.getLabel());
- models.put("documentPath", documentPath);
- models.put("authoringStep", authoringStepIdentifier);
- return new AuthoringStepNotAvailable();
- }
- final MvcAuthoringStep authoringStep = instance.get();
-
- if (!authoringStep.supportedDocumentType().isAssignableFrom(item
- .getClass())) {
- models.put("section", section.getLabel());
- models.put("documentPath", documentPath);
- models.put("documentType", item.getClass().getName());
- models.put("authoringStep", authoringStepIdentifier);
- return new UnsupportedDocumentType();
- }
-
- models.put("authoringStep", authoringStepIdentifier);
-
- selectedDocumentModel.setContentItem(item);
-
- authoringStep.setContentSection(section);
- authoringStep.setContentItem(item);
-
- return authoringStep;
}
+// /**
+// * 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)
+// public String editDocument(
+// @PathParam("sectionIdentifier") final String sectionIdentifier,
+// @PathParam("documentPath") final String documentPath
+// ) {
+// final Optional sectionResult = sectionsUi
+// .findContentSection(sectionIdentifier);
+// if (!sectionResult.isPresent()) {
+// sectionsUi.showContentSectionNotFound(sectionIdentifier);
+// }
+// final ContentSection section = sectionResult.get();
+//
+// final Optional itemResult = itemRepo
+// .findByPath(section, documentPath);
+// if (!itemResult.isPresent()) {
+// models.put("section", section.getLabel());
+// models.put("documentPath", documentPath);
+// documentUi.showDocumentNotFound(section, documentPath);
+// }
+// final ContentItem item = itemResult.get();
+// if (!itemPermissionChecker.canEditItem(item)) {
+// return documentUi.showAccessDenied(
+// section,
+// item,
+// defaultStepsMessageBundle.getMessage("edit_denied")
+// );
+// }
+//
+// return String.format(
+// "redirect:/%s/documents/%s/@authoringsteps/%s",
+// sectionIdentifier,
+// documentPath,
+// findPathFragmentForFirstStep(item)
+// );
+// }
+// /**
+// * 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)
+// public MvcAuthoringStep editDocument(
+// @PathParam("sectionIdentifier") final String sectionIdentifier,
+// @PathParam("documentPath") final String documentPath,
+// @PathParam("authoringStep") final String authoringStepIdentifier
+// ) {
+// final Optional sectionResult = sectionsUi
+// .findContentSection(sectionIdentifier);
+// if (!sectionResult.isPresent()) {
+// models.put("sectionIdentifier", sectionIdentifier);
+// return new ContentSectionNotFound();
+// }
+// final ContentSection section = sectionResult.get();
+//
+// final Optional itemResult = itemRepo
+// .findByPath(section, documentPath);
+// if (!itemResult.isPresent()) {
+// models.put("section", section.getLabel());
+// models.put("documentPath", documentPath);
+// return new DocumentNotFound();
+// }
+// final ContentItem item = itemResult.get();
+// if (!itemPermissionChecker.canEditItem(item)) {
+// models.put("section", section.getLabel());
+// models.put("documentPath", itemManager.getItemFolder(item));
+// models.put(
+// "step", defaultStepsMessageBundle.getMessage("edit_step")
+// );
+// return new EditDenied();
+// }
+//
+// final Instance instance = authoringSteps
+// .select(
+// new AuthoringStepPathFragmentLiteral(
+// authoringStepIdentifier
+// )
+// );
+// if (instance.isUnsatisfied() || instance.isAmbiguous()) {
+// models.put("section", section.getLabel());
+// models.put("documentPath", documentPath);
+// models.put("authoringStep", authoringStepIdentifier);
+// return new AuthoringStepNotAvailable();
+// }
+// final MvcAuthoringStep authoringStep = instance.get();
+//
+// if (!authoringStep.supportedDocumentType().isAssignableFrom(item
+// .getClass())) {
+// models.put("section", section.getLabel());
+// models.put("documentPath", documentPath);
+// models.put("documentType", item.getClass().getName());
+// models.put("authoringStep", authoringStepIdentifier);
+// return new UnsupportedDocumentType();
+// }
+//
+// models.put("authoringStep", authoringStepIdentifier);
+//
+// selectedDocumentModel.setContentItem(item);
+//
+// authoringStep.setContentSection(section);
+// authoringStep.setContentItem(item);
+//
+// return authoringStep;
+// }
/**
* Show the document history page.
*
@@ -650,7 +650,7 @@ public class DocumentController {
* @return A redirect to the publish step (redirect after POST pattern).
*/
@POST
- @Path("/{documentPath:(.+)?}/@publish")
+ @Path("/{documentPath:(.+)?}/@unpublish")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String unpublish(
@@ -686,50 +686,46 @@ 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
+// ) {
+// final MvcAuthoringKit authoringKit = item
+// .getClass()
+// .getAnnotation(MvcAuthoringKit.class);
+//
+// final Class extends MvcAuthoringStep>[] stepClasses = authoringKit
+// .authoringSteps();
+//
+// return Arrays
+// .stream(stepClasses)
+// .map(authoringSteps::select)
+// .filter(instance -> instance.isResolvable())
+// .map(Instance::get)
+// .collect(Collectors.toList());
+// }
/**
- * 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.
+ * // * 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 List readAuthoringSteps(
- final ContentItem item
- ) {
- final MvcAuthoringKit authoringKit = item
- .getClass()
- .getAnnotation(MvcAuthoringKit.class);
-
- final Class extends MvcAuthoringStep>[] stepClasses = authoringKit
- .authoringSteps();
-
- return Arrays
- .stream(stepClasses)
- .map(authoringSteps::select)
- .filter(instance -> instance.isResolvable())
- .map(Instance::get)
- .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()
- .getAnnotation(AuthoringStepPathFragment.class);
- return pathFragment.value();
- }
-
+// private String findPathFragmentForFirstStep(final ContentItem item) {
+// final List steps = readAuthoringSteps(item);
+//
+// final MvcAuthoringStep firstStep = steps.get(0);
+// final AuthoringStepPathFragment pathFragment = firstStep
+// .getClass()
+// .getAnnotation(AuthoringStepPathFragment.class);
+// return pathFragment.value();
+// }
/**
* Helper method for building an entry in the list of lifecycles for the
* view.
@@ -841,4 +837,172 @@ public class DocumentController {
}
+ /**
+ * Helper method for showing the "document folder not found" page if there
+ * is not folder for the provided path.
+ *
+ * @param section The content section.
+ * @param folderPath The folder path.
+ *
+ * @return The template of the "document folder not found" page.
+ */
+ private String showDocumentFolderNotFound(
+ final ContentSection section, final String folderPath
+ ) {
+ models.put("contentSection", section.getLabel());
+ models.put("folderPath", folderPath);
+
+ return "org/librecms/ui/contentsection/documentfolder/documentfolder-not-found.xhtml";
+ }
+
+ /**
+ * Helper method for showing the "documenttype 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.
+ *
+ * @return The template of the "document folder not found" page.
+ */
+ private String showDocumentTypeNotFound(
+ final ContentSection section, final String documentType
+ ) {
+ models.put("section", section.getLabel());
+ models.put("documentType", documentType);
+ return "org/librecms/ui/contentsection/documents/document-type-not-available.xhtml";
+ }
+
+ private String showCreateStepNotAvailable(
+ final ContentSection section,
+ final String folderPath,
+ final String documentType
+ ) {
+ models.put("section", section.getLabel());
+ models.put("folderPath", folderPath);
+ models.put("documentType", documentType);
+
+ return "org/librecms/ui/contentsection/documents/create-step-not-available.xhtml";
+ }
+
+ private CreateStepResult findCreateStep(
+ final String sectionIdentifier,
+ final String folderPath,
+ final String documentType
+ ) {
+ final Optional sectionResult = sectionsUi
+ .findContentSection(sectionIdentifier);
+ if (!sectionResult.isPresent()) {
+ return new CreateStepResult(
+ sectionsUi.showContentSectionNotFound(sectionIdentifier)
+ );
+ }
+ final ContentSection section = sectionResult.get();
+ sectionModel.setSection(section);
+
+ final Folder folder;
+ if (folderPath.isEmpty()) {
+ folder = section.getRootDocumentsFolder();
+ } else {
+ final Optional folderResult = folderRepo
+ .findByPath(
+ section, folderPath, FolderType.DOCUMENTS_FOLDER
+ );
+ if (!folderResult.isPresent()) {
+ return new CreateStepResult(
+ showDocumentFolderNotFound(section, folderPath)
+ );
+ }
+ folder = folderResult.get();
+ }
+
+ if (!itemPermissionChecker.canCreateNewItems(folder)) {
+ return new CreateStepResult(
+ sectionsUi.showAccessDenied(
+ "sectionidentifier", sectionIdentifier,
+ "folderPath", folderPath,
+ "step", defaultStepsMessageBundle.getMessage("create_step")
+ )
+ );
+ }
+
+ //final Class extends ContentItem> documentClass;
+ final Class> clazz;
+ try {
+// documentClass = (Class extends ContentItem>) Class.forName(
+// documentType
+// );
+ clazz = Class.forName(documentType);
+ } catch (ClassNotFoundException ex) {
+ return new CreateStepResult(
+ showDocumentTypeNotFound(section, documentType)
+ );
+ }
+ @SuppressWarnings("unchecked")
+ final Class extends ContentItem> documentClass
+ = (Class extends ContentItem>) clazz;
+
+ final boolean hasRequestedType = section
+ .getContentTypes()
+ .stream()
+ .anyMatch(
+ type -> type.getContentItemClass().equals(documentType)
+ );
+ if (!hasRequestedType) {
+ return new CreateStepResult(
+ showDocumentTypeNotFound(section, documentType)
+ );
+ }
+
+ final Instance> instance = createSteps
+ .select(new CreateDocumentOfTypeLiteral(documentClass));
+ if (instance.isUnsatisfied() || instance.isAmbiguous()) {
+ return new CreateStepResult(
+ showCreateStepNotAvailable(section, folderPath, documentType)
+ );
+ }
+ final MvcDocumentCreateStep extends ContentItem> createStep = instance
+ .get();
+
+ createStep.setContentSection(section);
+ createStep.setFolder(folder);
+
+ return new CreateStepResult(createStep);
+ }
+
+ private class CreateStepResult {
+
+ private final MvcDocumentCreateStep extends ContentItem> createStep;
+
+ private final boolean createStepAvailable;
+
+ private final String errorTemplate;
+
+ public CreateStepResult(
+ final MvcDocumentCreateStep extends ContentItem> createStep
+ ) {
+ this.createStep = createStep;
+ createStepAvailable = true;
+ errorTemplate = null;
+ }
+
+ public CreateStepResult(final String errorTemplate) {
+ this.createStep = null;
+ createStepAvailable = false;
+ this.errorTemplate = errorTemplate;
+ }
+
+ public MvcDocumentCreateStep extends ContentItem> getCreateStep() {
+ return createStep;
+ }
+
+ public boolean isCreateStepAvailable() {
+ return createStepAvailable;
+ }
+
+ public String getErrorTemplate() {
+ return errorTemplate;
+ }
+
+ }
+
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentTypeClassNotFound.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentTypeClassNotFound.java
deleted file mode 100644
index 909b853dd..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/DocumentTypeClassNotFound.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when the requested
- * document type does not exist.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */
-class DocumentTypeClassNotFound
- implements MvcDocumentCreateStep {
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String showCreateForm() {
- return "org/librecms/ui/contentsection/documents/document-type-not-available.xhtml";
- }
-
- @Override
- public String createContentItem() {
- return "org/librecms/ui/contentsection/documents/document-type-not-available.xhtml";
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/FolderNotFound.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/FolderNotFound.java
deleted file mode 100644
index 3a89bd798..000000000
--- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/FolderNotFound.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2021 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.librecms.ui.contentsections.documents;
-
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-
-import java.util.Map;
-
-/**
- * A pseudo implemention of the {@link MvcDocumentCreateStep} interface used by
- * the {@link DocumentController} to show an error message when the requested
- * folder does not exist.
- *
- * Most of methods in this implementation are throwing an
- * {@link UnsupportedOperationException}.
- *
- * @author Jens Pelzetter
- */
-public class FolderNotFound
- implements MvcDocumentCreateStep {
-
- @Override
- public Class getDocumentType() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getDescription() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getBundle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setContentSection(ContentSection section) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public ContentSection getContentSection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void setFolder(Folder folder) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Folder getFolder() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String showCreateForm() {
- return "org/librecms/ui/contentsection/documents/folder-not-found.xhtml";
- }
-
- @Override
- public String createContentItem() {
- return "org/librecms/ui/contentsection/documents/folder-not-found.xhtml";
- }
-
- @Override
- public String getContentSectionLabel() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getContentSectionTitle() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public String getFolderPath() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Map getMessages() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
-}
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 55b89df1a..1a3a343b3 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
@@ -26,26 +26,54 @@ import org.librecms.contentsection.Folder;
import java.util.Map;
import java.util.ResourceBundle;
-import javax.inject.Named;
-import javax.transaction.Transactional;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MultivaluedMap;
/**
- * A create step for a document/content item. Implementing classes are used as
- * subresources by {@link DocumentController#createDocument(java.lang.String, java.lang.String)
- * }. An implmenting class must be a named CDI bean (annotated with
- * {@link Named}), annotated with the {@link CreatesDocumentOfType} qualifier
- * annotation. The implementing bean must also contain properties annotated with
- * {@link FormParam} for all fields of the create form.
+ * A create step for a document/content item. Implementing classes are 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)]
+ * will be called.
+ *
+ * In most cases, {@link AbstractMvcDocumentCreateStep} should be used as
+ * base for implementations. {@link AbstractMvcDocumentCreateStep} implements
+ * several common operations.
*
* @author Jens Pelzetter
+ *
* @param The document type created by the create step.
*/
public interface MvcDocumentCreateStep {
+ /**
+ * Return the template for the create step.
+ *
+ * @return
+ */
+ String showCreateStep();
+
+ /**
+ * Processes the data from the create step form and creates the
+ * document/content item.
+ *
+ * @param formParams The data of the create step form.
+ *
+ * @return A redirect to the first authoring step of the new document.
+ */
+ String createItem(MultivaluedMap formParams);
+
+ /**
+ * Should be set by the implementing class to indicate if the current user
+ * can create document in the current folder.
+ *
+ * @return
+ */
+ boolean getCanCreate();
+
/**
* The document type generated by the create step described by an instance
* of this class.
@@ -125,30 +153,10 @@ public interface MvcDocumentCreateStep {
/**
* Gets messages from the create step.
- *
- * @return
+ *
+ * @return
*/
Map getMessages();
-
- /**
- * Endpoint displaying the create form.
- *
- * @return The template of the create step.
- */
- @GET
- @Path("/")
- @Transactional(Transactional.TxType.REQUIRED)
- String showCreateForm();
-
- /**
- * Creates the new document using the values provided in the form
- * parameters.
- *
- * @return A redirect to the new content item.
- */
- @POST
- @Path("/")
- @Transactional(Transactional.TxType.REQUIRED)
- String createContentItem();
+//
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticleCreateStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticleCreateStep.java
index d6992c28f..aaea54ebb 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticleCreateStep.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticleCreateStep.java
@@ -23,32 +23,19 @@ import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.Folder;
-import org.librecms.contentsection.FolderManager;
import org.librecms.contenttypes.Article;
-import org.librecms.ui.contentsections.ItemPermissionChecker;
+import org.librecms.ui.contentsections.documents.AbstractMvcDocumentCreateStep;
import org.librecms.ui.contentsections.documents.CreatesDocumentOfType;
-import org.librecms.ui.contentsections.documents.DocumentUi;
+
+import java.util.Locale;
+import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
-import org.librecms.ui.contentsections.documents.MvcDocumentCreateStep;
-
-import java.util.Collections;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.stream.Collectors;
-
import javax.inject.Inject;
import javax.mvc.Models;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
+import javax.ws.rs.core.MultivaluedMap;
/**
* Describes the create step for {@link Article}.
@@ -58,11 +45,20 @@ import javax.ws.rs.Path;
@RequestScoped
@Named("CmsArticleCreateStep")
@CreatesDocumentOfType(Article.class)
-public class MvcArticleCreateStep implements MvcDocumentCreateStep {
+public class MvcArticleCreateStep
+ extends AbstractMvcDocumentCreateStep {
+
+ private static final String FORM_PARAM_NAME = "name";
+
+ private static final String FORM_PARAM_TITLE = "title";
+
+ private static final String FORM_PARAM_SUMMARY = "summary";
+
+ private static final String FORM_PARAM_INITIAL_LOCALE = "initialLocale";
+
+ private static final String FORM_PARAM_SELECTED_WORKFLOW
+ = "selectedWorkflow";
- @Inject
- private ArticleMessageBundle articleMessageBundle;
-
/**
* Provides functions for working with content items.
*/
@@ -75,81 +71,43 @@ public class MvcArticleCreateStep implements MvcDocumentCreateStep {
@Inject
private ContentItemRepository itemRepo;
-
-
- @Inject
- private DocumentUi documentUi;
-
- /**
- * Provides operations for folders.
- */
- @Inject
- private FolderManager folderManager;
-
/**
* Provides functions for working with {@link LocalizedString}s.
*/
@Inject
private GlobalizationHelper globalizationHelper;
- @Inject
- private ItemPermissionChecker itemPermissionChecker;
-
/**
* Used to provided data for the views without a named bean.
*/
@Inject
private Models models;
- /**
- * The current content section.
- */
- private ContentSection section;
-
- /**
- * The current folder.
- */
- private Folder folder;
-
- /**
- * Messages to be shown to the user.
- */
- private SortedMap messages;
-
/**
* Name of the article.
*/
- @FormParam("name")
private String name;
/**
* Title of the article.
*/
- @FormParam("title")
private String title;
/**
* Summary of the article.
*/
- @FormParam("summary")
private String summary;
/**
* The initial locale of the article.
*/
- @FormParam("locale")
private String initialLocale;
/**
* The workflow to use for the new article.
*/
- @FormParam("selectedWorkflow")
private String selectedWorkflow;
- public MvcArticleCreateStep() {
- messages = new TreeMap<>();
- }
-
@Override
public Class getDocumentType() {
return Article.class;
@@ -167,175 +125,6 @@ public class MvcArticleCreateStep implements MvcDocumentCreateStep {
return ArticleStepsConstants.BUNDLE;
}
- @Override
- public ContentSection getContentSection() {
- return section;
- }
-
- @Override
- public String getContentSectionLabel() {
- return section.getLabel();
- }
-
- @Override
- public String getContentSectionTitle() {
- return globalizationHelper
- .getValueFromLocalizedString(section.getTitle());
- }
-
- @Override
- public void setContentSection(final ContentSection section) {
- this.section = section;
- }
-
- @Override
- public Folder getFolder() {
- return folder;
- }
-
- @Override
- public String getFolderPath() {
- return folderManager.getFolderPath(folder);
- }
-
- @Override
- public void setFolder(final Folder folder) {
- this.folder = folder;
- }
-
- @Override
- public Map getMessages() {
- return Collections.unmodifiableSortedMap(messages);
- }
-
- public void addMessage(final String context, final String message) {
- messages.put(context, message);
- }
-
- public void setMessages(final SortedMap messages) {
- this.messages = new TreeMap<>(messages);
- }
-
- @POST
- @Path("/")
- @Override
- public String showCreateForm() {
- if (itemPermissionChecker.canCreateNewItems(folder)) {
- return "org/librecms/ui/contenttypes/article/create-article.xhtml";
- } else {
- return documentUi.showAccessDenied(
- section,
- getFolderPath(),
- articleMessageBundle.getMessage("create_new_article.denied")
- );
- }
- }
-
- @POST
- @Path("/@create")
- @Override
- public String createContentItem() {
- if (name == null || name.isEmpty()) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.name.error.missing")
- );
- }
-
- if (!name.matches("^([a-zA-Z0-9_-]*)$")) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.name.error.invalid")
- );
- }
-
- if (title == null || title.isEmpty()) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.title.error.missing")
- );
- }
-
- if (summary == null || summary.isEmpty()) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.summary.error.missing")
- );
- }
-
- if (initialLocale == null || initialLocale.isEmpty()) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.initial_locale.error.missing")
- );
- }
-
- final Optional workflowResult = section
- .getWorkflowTemplates()
- .stream()
- .filter(template -> template.getUuid().equals(selectedWorkflow))
- .findAny();
-
- if (!workflowResult.isPresent()) {
- messages.put(
- "danger",
- globalizationHelper.getLocalizedTextsUtil(
- getBundle()
- ).getText("createstep.workflow.error.not_available")
- );
- }
-
- if (!messages.isEmpty()) {
- final String folderPath = getFolderPath();
- if (folderPath.isEmpty() || "/".equals(folderPath)) {
- return String.format(
- "/@contentsections/%s/documents/@create/%s",
- section.getLabel(),
- getDocumentType().getName()
- );
- } else {
- return String.format(
- "/@contentsections/%s/documents/%s/@create/%s",
- section.getLabel(),
- folderPath,
- getDocumentType().getName()
- );
- }
- }
-
- final Locale locale = new Locale(initialLocale);
-
- final Article article = itemManager.createContentItem(
- name,
- section,
- folder,
- workflowResult.get(),
- Article.class,
- locale
- );
-
- article.getTitle().addValue(locale, title);
- article.getDescription().addValue(locale, summary);
- itemRepo.save(article);
-
- return String.format(
- "redirect:/%s/documents/%s/%s/@edit/basicproperties",
- section.getLabel(),
- folderManager.getFolderPath(folder),
- name
- );
- }
-
public String getName() {
return name;
}
@@ -354,7 +143,7 @@ public class MvcArticleCreateStep implements MvcDocumentCreateStep {
public String getSelectedWorkflow() {
if (selectedWorkflow == null || selectedWorkflow.isEmpty()) {
- return section
+ return getContentSection()
.getContentTypes()
.stream()
.filter(
@@ -375,30 +164,136 @@ public class MvcArticleCreateStep implements MvcDocumentCreateStep {
}
}
- public Map getAvailableLocales() {
- return globalizationHelper
- .getAvailableLocales()
- .stream()
- .collect(Collectors.toMap(
- Locale::toString,
- locale -> locale.getDisplayLanguage(
- globalizationHelper.getNegotiatedLocale()
- )
- ));
+ @Override
+ public String showCreateStep() {
+ return "org/librecms/ui/contenttypes/article/create-article.xhtml";
}
- public Map getAvailableWorkflows() {
- return section
+ @Override
+ public String createItem(final MultivaluedMap formParams) {
+ if (!formParams.containsKey(FORM_PARAM_NAME)
+ || formParams.getFirst(FORM_PARAM_NAME) == null
+ || formParams.getFirst(FORM_PARAM_NAME).isEmpty()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.name.error.missing")
+ );
+ }
+
+ name = formParams.getFirst(FORM_PARAM_NAME);
+ if (!name.matches("^([a-zA-Z0-9_-]*)$")) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.name.error.invalid")
+ );
+ }
+
+ if (!formParams.containsKey(FORM_PARAM_TITLE)
+ || formParams.getFirst(FORM_PARAM_TITLE) == null
+ || formParams.getFirst(FORM_PARAM_TITLE).isEmpty()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.title.error.missing")
+ );
+ }
+ title = formParams.getFirst(FORM_PARAM_TITLE);
+
+ if (!formParams.containsKey(FORM_PARAM_SUMMARY)
+ || formParams.getFirst(FORM_PARAM_SUMMARY) == null
+ || formParams.getFirst(FORM_PARAM_SUMMARY).isEmpty()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.summary.error.missing")
+ );
+ }
+ summary = formParams.getFirst(FORM_PARAM_SUMMARY);
+
+ if (!formParams.containsKey(FORM_PARAM_INITIAL_LOCALE)
+ || formParams.getFirst(FORM_PARAM_INITIAL_LOCALE) == null
+ || formParams.getFirst(FORM_PARAM_INITIAL_LOCALE).isEmpty()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.initial_locale.error.missing")
+ );
+ }
+ final Locale locale = new Locale(
+ formParams.getFirst(FORM_PARAM_INITIAL_LOCALE)
+ );
+
+ if (!formParams.containsKey(FORM_PARAM_SELECTED_WORKFLOW)
+ || formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW) == null
+ || formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW).isEmpty()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.workflow.none_selected")
+ );
+ }
+ selectedWorkflow = formParams.getFirst(FORM_PARAM_SELECTED_WORKFLOW);
+
+ final Optional workflowResult = getContentSection()
.getWorkflowTemplates()
.stream()
- .collect(
- Collectors.toMap(
- workflow -> workflow.getUuid(),
- workflow -> globalizationHelper.getValueFromLocalizedString(
- workflow.getName()
- )
- )
+ .filter(template -> template.getUuid().equals(selectedWorkflow))
+ .findAny();
+
+ if (!workflowResult.isPresent()) {
+ addMessage(
+ "danger",
+ globalizationHelper.getLocalizedTextsUtil(
+ getBundle()
+ ).getText("createstep.workflow.error.not_available")
);
+ }
+
+ if (!getMessages().isEmpty()) {
+ final String folderPath = getFolderPath();
+ if (folderPath.isEmpty() || "/".equals(folderPath)) {
+ return String.format(
+ "/@contentsections/%s/documents/@create/%s",
+ getContentSectionLabel(),
+ getDocumentType().getName()
+ );
+ } else {
+ return String.format(
+ "/@contentsections/%s/documents/%s/@create/%s",
+ getContentSectionLabel(),
+ folderPath,
+ getDocumentType().getName()
+ );
+ }
+ }
+
+ final Article article = itemManager.createContentItem(
+ name,
+ getContentSection(),
+ getFolder(),
+ workflowResult.get(),
+ Article.class,
+ locale
+ );
+
+ article.getTitle().addValue(locale, title);
+ article.getDescription().addValue(locale, summary);
+ itemRepo.save(article);
+
+ return String.format(
+ "redirect:/%s/documents/%s/%s/@edit/basicproperties",
+ getContentSectionLabel(),
+ getFolderPath(),
+ name
+ );
}
}
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/access-denied.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/access-denied.xhtml
index 268f10941..af8195bb6 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/access-denied.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/access-denied.xhtml
@@ -4,13 +4,13 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
-
+
#{CmsAdminMessages['contentsection.document_access_denied.breadcrumb']}
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/asset-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/asset-not-found.xhtml
index 5601522bb..c5cc43717 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/asset-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/asset-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/attachment-list-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/attachment-list-not-found.xhtml
index 2045f0c9c..79e6ee5b8 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/attachment-list-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/attachment-list-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep-not-available.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep-not-available.xhtml
index 2d5a25f79..1e0fd7fd3 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep-not-available.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep-not-available.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-domain-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-domain-not-found.xhtml
index 645ac3d00..4286ae9c7 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-domain-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/categorization-domain-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/create-step-not-available.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/create-step-not-available.xhtml
index aa426b661..d8468446e 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/create-step-not-available.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/create-step-not-available.xhtml
@@ -4,13 +4,13 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
-
+
#{CmsAdminMessages['contentsection.documents.createstep.breadcrumb']} #{documentType}
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-not-found.xhtml
index fea05e0d9..0204e6b3d 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-type-not-available.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-type-not-available.xhtml
index c8b505275..d87cd8292 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-type-not-available.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/document-type-not-available.xhtml
@@ -4,13 +4,13 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
-
+
#{documentType}
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/folder-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/folder-not-found.xhtml
index dba3ee82a..464afd035 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/folder-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/folder-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/internal-link-asset-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/internal-link-asset-not-found.xhtml
index 3587ca435..d070d91ee 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/internal-link-asset-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/internal-link-asset-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-def-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-def-not-found.xhtml
index d88a31bc5..a9227c74b 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-def-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-def-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-definition-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-definition-not-found.xhtml
index d1719e611..7cc87d17d 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-definition-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/lifecycle-definition-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/pathTest.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/pathTest.xhtml
new file mode 100644
index 000000000..a032672ab
--- /dev/null
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/pathTest.xhtml
@@ -0,0 +1,15 @@
+]>
+
+
+ Content Section #{ContentSectionModel.sectionName} #{title} - LibreCMS
+
+
+
+ #{folderPath}
+
+
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/phase-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/phase-not-found.xhtml
index 7953aa991..0ba71b1ab 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/phase-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/phase-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/publish.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/publish.xhtml
index 81bf9fd6f..f44e1c4a3 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/publish.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/publish.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-attachmentlist-details.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-attachmentlist-details.xhtml
index 9a9e0b1e0..41e7908d9 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-attachmentlist-details.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-attachmentlist-details.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-internallink-details.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-internallink-details.xhtml
index ba9b22eca..840310c47 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-internallink-details.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo-internallink-details.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
index 6a916a85d..8f2dc82fe 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/target-item-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/target-item-not-found.xhtml
index b41525669..b771df19f 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/target-item-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/target-item-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/task-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/task-not-found.xhtml
index ce989728e..7a6265219 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/task-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/task-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/unsupported-documenttype.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/unsupported-documenttype.xhtml
index 6b99fcbf3..d6a86c399 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/unsupported-documenttype.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/unsupported-documenttype.xhtml
@@ -4,13 +4,13 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+
-
+
#{CmsAdminMessages['contentsection.unsupportedDocumentType.breadcrumb']}
diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/workflow-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/workflow-not-found.xhtml
index e4f22327c..0adc3631a 100644
--- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/workflow-not-found.xhtml
+++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/workflow-not-found.xhtml
@@ -4,7 +4,7 @@
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
+