diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java
new file mode 100644
index 000000000..c4c40de99
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/CmsEditorUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2022 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.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public final class CmsEditorUtil {
+
+ private CmsEditorUtil() {
+ // Nothing
+ }
+
+ public static CmsEditorLocaleVariantRow buildVariantRow(
+ final Map.Entry entry
+ ) {
+ final CmsEditorLocaleVariantRow variant
+ = new CmsEditorLocaleVariantRow();
+ variant.setLocale(entry.getKey().toString());
+ final Document document = Jsoup.parseBodyFragment(entry.getValue());
+ variant.setWordCount(
+ new StringTokenizer(document.body().text()).countTokens()
+ );
+
+ return variant;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java
index 80befc6a6..261c4db08 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStep.java
@@ -29,6 +29,7 @@ import org.librecms.ui.contentsections.ItemPermissionChecker;
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
+import org.librecms.ui.contentsections.documents.CmsEditorUtil;
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
import org.librecms.ui.contentsections.documents.DocumentUi;
@@ -144,6 +145,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
* @param sectionIdentifier
* @param documentPath
* @param localeParam
+ *
* @return The template for showing a preview of the text.
*/
@GET
@@ -167,7 +169,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
articleTextBodyStepModel.setSelectedLocale(
new Locale(localeParam).toString()
);
-
+
return "org/librecms/ui/contenttypes/article/article-text/view.xhtml";
}
@@ -351,16 +353,16 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
);
articleTextBodyStepModel.setTitleValues(
getArticle()
- .getTitle()
- .getValues()
- .entrySet()
- .stream()
- .collect(
- Collectors.toMap(
- entry -> entry.getKey().toString(),
- Map.Entry::getValue
+ .getTitle()
+ .getValues()
+ .entrySet()
+ .stream()
+ .collect(
+ Collectors.toMap(
+ entry -> entry.getKey().toString(),
+ Map.Entry::getValue
+ )
)
- )
);
articleTextBodyStepModel.setTextValues(
getArticle()
@@ -382,7 +384,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
.getValues()
.entrySet()
.stream()
- .map(this::buildVariantRow)
+ .map(CmsEditorUtil::buildVariantRow)
.collect(Collectors.toList())
);
@@ -404,18 +406,4 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
return (Article) getDocument();
}
- private CmsEditorLocaleVariantRow buildVariantRow(
- final Map.Entry entry
- ) {
- final CmsEditorLocaleVariantRow variant
- = new CmsEditorLocaleVariantRow();
- variant.setLocale(entry.getKey().toString());
- final Document document = Jsoup.parseBodyFragment(entry.getValue());
- variant.setWordCount(
- new StringTokenizer(document.body().text()).countTokens()
- );
-
- return variant;
- }
-
}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java
index 02b163275..b3c2e3fcf 100644
--- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/article/MvcArticleTextBodyStepModel.java
@@ -38,9 +38,9 @@ import javax.inject.Named;
public class MvcArticleTextBodyStepModel {
private boolean canEdit;
-
+
private Map titleValues;
-
+
private Map textValues;
private List variants;
@@ -48,7 +48,7 @@ public class MvcArticleTextBodyStepModel {
private List unusedLocales;
private String selectedLocale;
-
+
public Map getTitleValues() {
return Collections.unmodifiableMap(titleValues);
}
@@ -60,7 +60,7 @@ public class MvcArticleTextBodyStepModel {
public String getTitle() {
return titleValues.get(selectedLocale);
}
-
+
/**
* Get all localized values of the main text.
*
@@ -74,7 +74,7 @@ public class MvcArticleTextBodyStepModel {
this.textValues = new HashMap<>(textValues);
}
- /**
+ /**
* Gets the locales for which the main text has not been defined yet.
*
* @return The locales for which the main text has not been defined yet.
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java
new file mode 100644
index 000000000..c49c4a178
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStep.java
@@ -0,0 +1,815 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.libreccm.configuration.ConfigurationManager;
+import org.libreccm.l10n.GlobalizationHelper;
+import org.librecms.contentsection.ContentItemRepository;
+import org.librecms.contenttypes.Event;
+import org.librecms.ui.contentsections.ContentSectionNotFoundException;
+import org.librecms.ui.contentsections.ItemPermissionChecker;
+import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
+import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
+import org.librecms.ui.contentsections.documents.DocumentUi;
+import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
+import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
+
+import java.util.Locale;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.mvc.Controller;
+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.PathParam;
+
+/**
+ * Authoring step for editing the localizable information of an event.
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info")
+@Controller
+@MvcAuthoringStepDef(
+ bundle = EventStepsConstants.BUNDLE,
+ descriptionKey = "authoringsteps.info.description",
+ labelKey = "authoringstep.info.label",
+ supportedDocumentType = Event.class
+)
+public class MvcEventInfoStep extends AbstractMvcAuthoringStep {
+
+ @Inject
+ private EventMessageBundle eventMessageBundle;
+
+ @Inject
+ private ConfigurationManager confManager;
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Inject
+ private DocumentUi documentUi;
+
+ @Inject
+ private GlobalizationHelper globalizationHelper;
+
+ @Inject
+ private ItemPermissionChecker itemPermissionChecker;
+
+ @Inject
+ private MvcEventInfoStepEventDateModel eventDateModel;
+
+ @Inject
+ private MvcEventInfoStepLocationModel locationModel;
+
+ @Inject
+ private MvcEventInfoStepMainContributorModel mainContributorModel;
+
+ @Inject
+ private MvcEventInfoStepEventTypeModel eventTypeModel;
+
+ @Override
+ public Class getStepClass() {
+ return MvcEventInfoStep.class;
+ }
+
+ @GET
+ @Path("/")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String showStep(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ return "org/librecms/ui/contenttypes/event/event-info/overview.xhtml";
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ eventMessageBundle.getMessage("event.edit.denied")
+ );
+ }
+ }
+
+ // EventDate
+ @GET
+ @Path("/eventdate/view/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewEventDate(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ eventDateModel.setSelectedLocale(new Locale(localeParam).toString());
+
+ return "org/librecms/ui/contenttypes/event/eventdate/view.xhtml";
+ }
+
+ @POST
+ @Path("/eventdate/add")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String addEventDateValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @FormParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final String value;
+ if (getEvent().getEventDate().getAvailableLocales().isEmpty()) {
+ value = "";
+ } else {
+ value = globalizationHelper.getValueFromLocalizedString(
+ getEvent().getText()
+ );
+ }
+ final Locale locale = new Locale(localeParam);
+ getEvent().getEventDate().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @GET
+ @Path("/eventdate/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editEventDateValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ eventDateModel.setSelectedLocale(
+ new Locale(localeParam).toString()
+ );
+
+ return "org/librecms/ui/contenttypes/event/eventdate/edit.xhtml";
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/eventdate/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editEventDateValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam,
+ @FormParam("value") final String value
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getEventDate().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/eventdate/remove/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String removeEventDateValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getText().removeValue(locale);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ // Location
+ @GET
+ @Path("/location/view/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewLocation(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ locationModel.setSelectedLocale(new Locale(localeParam).toString());
+
+ return "org/librecms/ui/contenttypes/event/location/view.xhtml";
+ }
+
+ @POST
+ @Path("/location/add")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String addLocationValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @FormParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final String value;
+ if (getEvent().getLocation().getAvailableLocales().isEmpty()) {
+ value = "";
+ } else {
+ value = globalizationHelper.getValueFromLocalizedString(
+ getEvent().getLocation()
+ );
+ }
+ final Locale locale = new Locale(localeParam);
+ getEvent().getLocation().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @GET
+ @Path("/location/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editLocationValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ locationModel.setSelectedLocale(new Locale(localeParam).toString());
+
+ return "org/librecms/ui/contenttypes/event/location/edit.xhtml";
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/location/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editLocationValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam,
+ @FormParam("value") final String value
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getLocation().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/location/remove/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String removeLocationValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getLocation().removeValue(locale);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ // Main Contributor
+ @GET
+ @Path("/main-contributor/view/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewMainContributor(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ mainContributorModel.setSelectedLocale(
+ new Locale(localeParam).toString()
+ );
+
+ return "org/librecms/ui/contenttypes/event/main-contributor/view.xhtml";
+ }
+
+ @POST
+ @Path("/main-contributor/add")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String addMainContributorValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @FormParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final String value;
+ if (getEvent()
+ .getMainContributor()
+ .getAvailableLocales()
+ .isEmpty()) {
+ value = "";
+ } else {
+ value = globalizationHelper.getValueFromLocalizedString(
+ getEvent().getMainContributor()
+ );
+ }
+ final Locale locale = new Locale(localeParam);
+ getEvent().getText().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @GET
+ @Path("/main-contributor/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editMainContributorValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ mainContributorModel.setSelectedLocale(
+ new Locale(localeParam).toString()
+ );
+
+ return "org/librecms/ui/contenttypes/event/main-contributor/edit.xhtml";
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/main-contributor/add")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String addMainContributorValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam,
+ @FormParam("value") final String value
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getMainContributor().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/main-contributor/remove/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String removeMainContributorValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getMainContributor().removeValue(locale);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ // Event Type
+ @GET
+ @Path("/eventtype/view/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewEventType(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ eventTypeModel.setSelectedLocale(new Locale(localeParam).toString());
+
+ return "org/librecms/ui/contenttypes/event/eventtype/view.xhtml";
+ }
+
+ @POST
+ @Path("/eventtype/add")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String addEventTypeValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @FormParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final String value;
+ if (getEvent().getEventType().getAvailableLocales().isEmpty()) {
+ value = "";
+ } else {
+ value = globalizationHelper.getValueFromLocalizedString(
+ getEvent().getEventType()
+ );
+ }
+ final Locale locale = new Locale(localeParam);
+ getEvent().getEventDate().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @GET
+ @Path("/eventdate/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editEventTypeValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ eventTypeModel.setSelectedLocale(new Locale(localeParam).toString());
+
+ return "org/librecms/ui/contenttypes/event/eventtype/edit.xhtml";
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/eventdate/edit/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String editEventTypeValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam,
+ @FormParam("value") final String value
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getEventType().putValue(locale, value);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @POST
+ @Path("/eventdate/remove/{locale}")
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String removeEventTypeValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPath,
+ @PathParam("locale") final String localeParam
+ ) {
+ try {
+ init();
+ } catch (ContentSectionNotFoundException ex) {
+ return ex.showErrorMessage();
+ } catch (DocumentNotFoundException ex) {
+ return ex.showErrorMessage();
+ }
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ final Locale locale = new Locale(localeParam);
+ getEvent().getEventType().removeValue(locale);
+ itemRepo.save(getEvent());
+
+ return buildRedirectPathForStep();
+ } else {
+ return documentUi.showAccessDenied(
+ getContentSection(),
+ getEvent(),
+ getLabel()
+ );
+ }
+ }
+
+ @Override
+ public void init() throws ContentSectionNotFoundException,
+ DocumentNotFoundException {
+ super.init();
+
+ if (itemPermissionChecker.canEditItem(getEvent())) {
+ eventDateModel.setCanEdit(
+ itemPermissionChecker.canEditItem(getEvent())
+ );
+
+ locationModel.setCanEdit(
+ itemPermissionChecker.canEditItem(getEvent())
+ );
+
+ mainContributorModel.setCanEdit(
+ itemPermissionChecker.canEditItem(getEvent())
+ );
+
+ eventTypeModel.setCanEdit(
+ itemPermissionChecker.canEditItem(getEvent())
+ );
+
+ // toDo
+ }
+ }
+
+ private Event getEvent() {
+ return (Event) getDocument();
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java
new file mode 100644
index 000000000..e539a3d02
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventDateModel.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Named("CmsEventInfoStepEventDate")
+class MvcEventInfoStepEventDateModel {
+
+ private boolean canEdit;
+
+ private Map eventDateValues;
+
+ private List variants;
+
+ private List unusedLocales;
+
+ private String selectedLocale;
+
+ public Map getEventDateValues() {
+ return Collections.unmodifiableMap(eventDateValues);
+ }
+
+ protected void setEventDateValues(
+ final Map eventDateValues
+ ) {
+ this.eventDateValues = new HashMap<>(eventDateValues);
+ }
+
+ public List getVariants() {
+ return Collections.unmodifiableList(variants);
+ }
+
+ protected void setVariants(final List variants) {
+ this.variants = new ArrayList<>(variants);
+ }
+
+ public List getUnusedLocales() {
+ return Collections.unmodifiableList(unusedLocales);
+ }
+
+ protected void setUnusedLocales(final List unusedLocales) {
+ this.unusedLocales = new ArrayList<>(unusedLocales);
+ }
+
+ public String getSelectedLocale() {
+ return selectedLocale;
+ }
+
+ protected void setSelectedLocale(final String selectedLocale) {
+ this.selectedLocale = selectedLocale;
+ }
+
+ public boolean getCanEdit() {
+ return canEdit;
+ }
+
+ protected void setCanEdit(final boolean canEdit) {
+ this.canEdit = canEdit;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java
new file mode 100644
index 000000000..7e1ad195c
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepEventTypeModel.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Named("CmsEventInfoSstepEventType")
+public class MvcEventInfoStepEventTypeModel {
+
+ private boolean canEdit;
+
+ private Map eventTypeValues;
+
+ private List variants;
+
+ private List unusedLocales;
+
+ private String selectedLocale;
+
+ public Map getEventTypeValues() {
+ return Collections.unmodifiableMap(eventTypeValues);
+ }
+
+ protected void setEventTypeValues(final Map eventTypeValues) {
+ this.eventTypeValues = new HashMap<>(eventTypeValues);
+ }
+
+ public List getVariants() {
+ return Collections.unmodifiableList(variants);
+ }
+
+ protected void setVariants(final List variants) {
+ this.variants = new ArrayList<>(variants);
+ }
+
+ public List getUnusedLocales() {
+ return Collections.unmodifiableList(unusedLocales);
+ }
+
+ protected void setUnusedLocales(final List unusedLocales) {
+ this.unusedLocales = new ArrayList<>(unusedLocales);
+ }
+
+ public String getSelectedLocale() {
+ return selectedLocale;
+ }
+
+ protected void setSelectedLocale(final String selectedLocale) {
+ this.selectedLocale = selectedLocale;
+ }
+
+ public boolean getCanEdit() {
+ return canEdit;
+ }
+
+ protected void setCanEdit(final boolean canEdit) {
+ this.canEdit = canEdit;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java
new file mode 100644
index 000000000..6d3e773ce
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepLocationModel.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Named("CmsEventInfoStepLocation")
+public class MvcEventInfoStepLocationModel {
+
+ private boolean canEdit;
+
+ private Map locationValues;
+
+ private List variants;
+
+ private List unusedLocales;
+
+ private String selectedLocale;
+
+ public Map getLocationValues() {
+ return Collections.unmodifiableMap(locationValues);
+ }
+
+ protected void setLocationValues(final Map locationValues) {
+ this.locationValues = new HashMap<>(locationValues);
+ }
+
+ public List getVariants() {
+ return Collections.unmodifiableList(variants);
+ }
+
+ protected void setVariants(final List variants) {
+ this.variants = new ArrayList<>(variants);
+ }
+
+ public List getUnusedLocales() {
+ return Collections.unmodifiableList(unusedLocales);
+ }
+
+ protected void setUnusedLocales(final List unusedLocales) {
+ this.unusedLocales = new ArrayList<>(unusedLocales);
+ }
+
+ public String getSelectedLocale() {
+ return selectedLocale;
+ }
+
+ protected void setSelectedLocale(final String selectedLocale) {
+ this.selectedLocale = selectedLocale;
+ }
+
+ public boolean getCanEdit() {
+ return canEdit;
+ }
+
+ protected void setCanEdit(final boolean canEdit) {
+ this.canEdit = canEdit;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java
new file mode 100644
index 000000000..3a8a53449
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepMainContributorModel.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Named("CmsEventInfoStepMainContributor")
+public class MvcEventInfoStepMainContributorModel {
+
+ private boolean canEdit;
+
+ private Map contributorValues;
+
+ private List variants;
+
+ private List unusedLocales;
+
+ private String selectedLocale;
+
+ public Map getContributorValues() {
+ return Collections.unmodifiableMap(contributorValues);
+ }
+
+ protected void setContributorValues(
+ final Map contributorValues
+ ) {
+ this.contributorValues = new HashMap<>(contributorValues);
+ }
+
+ public List getVariants() {
+ return Collections.unmodifiableList(variants);
+ }
+
+ protected void setVariants(final List variants) {
+ this.variants = new ArrayList<>(variants);
+ }
+
+ public List getUnusedLocales() {
+ return Collections.unmodifiableList(unusedLocales);
+ }
+
+ protected void setUnusedLocales(final List unusedLocales) {
+ this.unusedLocales = new ArrayList<>(unusedLocales);
+ }
+
+ public String getSelectedLocale() {
+ return selectedLocale;
+ }
+
+ protected void setSelectedLocale(final String selectedLocale) {
+ this.selectedLocale = selectedLocale;
+ }
+
+ public boolean getCanEdit() {
+ return canEdit;
+ }
+
+ protected void setCanEdit(final boolean canEdit) {
+ this.canEdit = canEdit;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java
new file mode 100644
index 000000000..d44766652
--- /dev/null
+++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/event/MvcEventInfoStepResources.java
@@ -0,0 +1,374 @@
+/*
+ * Copyright (C) 2022 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.contenttypes.event;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.librecms.contentsection.ContentItem;
+import org.librecms.contentsection.ContentItemRepository;
+import org.librecms.contentsection.ContentSection;
+import org.librecms.contenttypes.Event;
+import org.librecms.ui.contentsections.ContentSectionsUi;
+import org.librecms.ui.contentsections.ItemPermissionChecker;
+import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
+
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
+import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.GET;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+@Path(MvcAuthoringSteps.PATH_PREFIX + "event-info-resources")
+public class MvcEventInfoStepResources {
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Inject
+ private ContentSectionsUi sectionsUi;
+
+ @Inject
+ private ItemPermissionChecker itemPermissionChecker;
+
+ // Event Date
+ @GET
+ @Path("/eventdate/wordcount/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getEventDateWordCount(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ final String text = event
+ .getEventDate()
+ .getValue(new Locale(localeParam));
+ final Document jsoupDoc = Jsoup.parseBodyFragment(text);
+ final long result = new StringTokenizer(
+ jsoupDoc.body().text()
+ ).countTokens();
+ return Long.toString(result);
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ @GET
+ @Path("/eventdate/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewEventDateValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ return event.getEventDate().getValue(new Locale(localeParam));
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ // Location
+ @GET
+ @Path("/eventdate/wordcount/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getLocationWordCount(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ final String text = event
+ .getLocation()
+ .getValue(new Locale(localeParam));
+ final Document jsoupDoc = Jsoup.parseBodyFragment(text);
+ final long result = new StringTokenizer(
+ jsoupDoc.body().text()
+ ).countTokens();
+ return Long.toString(result);
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ @GET
+ @Path("/eventdate/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewLocationValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ return event.getLocation().getValue(new Locale(localeParam));
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ // Main Contributor
+ @GET
+ @Path("/eventdate/wordcount/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getMainContributorWordCount(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ final String text = event
+ .getMainContributor()
+ .getValue(new Locale(localeParam));
+ final Document jsoupDoc = Jsoup.parseBodyFragment(text);
+ final long result = new StringTokenizer(
+ jsoupDoc.body().text()
+ ).countTokens();
+ return Long.toString(result);
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ @GET
+ @Path("/eventdate/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewMainContributorValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ return event.getMainContributor().getValue(new Locale(localeParam));
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ // Event Type
+ @GET
+ @Path("/eventdate/wordcount/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getEventTypeWordCount(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ final String text = event
+ .getEventType()
+ .getValue(new Locale(localeParam));
+ final Document jsoupDoc = Jsoup.parseBodyFragment(text);
+ final long result = new StringTokenizer(
+ jsoupDoc.body().text()
+ ).countTokens();
+ return Long.toString(result);
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+ @GET
+ @Path("/eventdate/{locale}")
+ @Produces(MediaType.TEXT_HTML)
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String viewEventTypeValue(
+ @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
+ final String sectionIdentifier,
+ @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
+ final String documentPathParam,
+ @PathParam("locale") final String localeParam
+ ) {
+ final ContentSection contentSection = sectionsUi
+ .findContentSection(sectionIdentifier)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ final ContentItem document = itemRepo
+ .findByPath(contentSection, documentPathParam)
+ .orElseThrow(
+ () -> new NotFoundException()
+ );
+
+ if (!(document instanceof Event)) {
+ throw new NotFoundException();
+ }
+
+ final Event event = (Event) document;
+ if (itemPermissionChecker.canEditItem(event)) {
+ return event.getEventType().getValue(new Locale(localeParam));
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
+}
diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties
new file mode 100644
index 000000000..55793bb94
--- /dev/null
+++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle.properties
@@ -0,0 +1,13 @@
+
+authoringsteps.basicproperties.description=General properties of an event, for example the begin and end date.
+authoringsteps.basicproperties.label=Basic Properties
+authoringsteps.info.description=Extended information about the event, for example about the location.
+authoringstep.info.label=Event Info
+createstep.description=Creates a new event.
+createstep.name.error.missing=The name of the event is missing.
+createstep.name.error.invalid=The name of the event is not valid. The name can only contain the letters a to z and A to Z, numbers (0 to 9), the underscore ("_") and the dash ("-").
+createstep.title.error.missing=The title of the event is missing.
+createstep.summary.error.missing=The summary of the event is missing.
+createstep.initial_locale.error.missing=The initial locale of the event is missing.
+createstep.workflow.none_selected=No workflow was selected.
+createstep.workflow.error.not_available=The selected workflow is not available.
diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties
new file mode 100644
index 000000000..e402052d7
--- /dev/null
+++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/EventBundle_de.properties
@@ -0,0 +1,13 @@
+
+authoringsteps.basicproperties.description=Basiseigenschaften einer Veranstaltung, z.B. das Datum der Veranstaltung
+authoringsteps.basicproperties.label=Basiseigenschaften
+authoringsteps.info.description=Weitere Informationen \u00fcber die Veranstaltung, z.B. \u00fcber den Veranstaltungsort.
+authoringstep.info.label=Informationen zur Veranstaltung
+createstep.description=Legt eine neue Veranstaltung an.
+createstep.name.error.missing=Der Name der Veranstaltung wurde nicht angegeben.
+createstep.name.error.invalid=Der Name der Veranstaltung ist nicht valide. Der Name darf nur die Buchstaben a bis z und A bis Z, Ziffern (0 to 9), den Unterstrich ("_") und den Bindestrich ("-") enthalten.
+createstep.title.error.missing=Der Titel der Veranstaltung wurde nicht angegeben.
+createstep.summary.error.missing=Es wurde keine Zusammenfassung der Veranstaltung angegeben.
+createstep.initial_locale.error.missing=Die initale Sprache f\u00fcr die Veranstaltung wurde nicht angegeben.
+createstep.workflow.none_selected=Es wurde kein Arbeitsablauf ausgew\u00e4hlt.
+createstep.workflow.error.not_available=Der ausgew\u00e4hlte Arbeitsablauf ist nicht verf\u00fcgbar.