Java Part of authoring steps for Event
parent
b210d8fcdd
commit
c18336bc5e
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public final class CmsEditorUtil {
|
||||||
|
|
||||||
|
private CmsEditorUtil() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CmsEditorLocaleVariantRow buildVariantRow(
|
||||||
|
final Map.Entry<Locale, String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,7 @@ import org.librecms.ui.contentsections.ItemPermissionChecker;
|
||||||
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
|
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
|
||||||
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
|
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
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.DocumentNotFoundException;
|
||||||
import org.librecms.ui.contentsections.documents.DocumentUi;
|
import org.librecms.ui.contentsections.documents.DocumentUi;
|
||||||
|
|
||||||
|
|
@ -144,6 +145,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
||||||
* @param sectionIdentifier
|
* @param sectionIdentifier
|
||||||
* @param documentPath
|
* @param documentPath
|
||||||
* @param localeParam
|
* @param localeParam
|
||||||
|
*
|
||||||
* @return The template for showing a preview of the text.
|
* @return The template for showing a preview of the text.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
|
|
@ -351,16 +353,16 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
||||||
);
|
);
|
||||||
articleTextBodyStepModel.setTitleValues(
|
articleTextBodyStepModel.setTitleValues(
|
||||||
getArticle()
|
getArticle()
|
||||||
.getTitle()
|
.getTitle()
|
||||||
.getValues()
|
.getValues()
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toMap(
|
Collectors.toMap(
|
||||||
entry -> entry.getKey().toString(),
|
entry -> entry.getKey().toString(),
|
||||||
Map.Entry::getValue
|
Map.Entry::getValue
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
articleTextBodyStepModel.setTextValues(
|
articleTextBodyStepModel.setTextValues(
|
||||||
getArticle()
|
getArticle()
|
||||||
|
|
@ -382,7 +384,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
||||||
.getValues()
|
.getValues()
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
.map(this::buildVariantRow)
|
.map(CmsEditorUtil::buildVariantRow)
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -404,18 +406,4 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
||||||
return (Article) getDocument();
|
return (Article) getDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CmsEditorLocaleVariantRow buildVariantRow(
|
|
||||||
final Map.Entry<Locale, String> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class MvcArticleTextBodyStepModel {
|
||||||
this.textValues = new HashMap<>(textValues);
|
this.textValues = new HashMap<>(textValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the locales for which the main text has not been defined yet.
|
* 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.
|
* @return The locales for which the main text has not been defined yet.
|
||||||
|
|
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@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<MvcEventInfoStep> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("CmsEventInfoStepEventDate")
|
||||||
|
class MvcEventInfoStepEventDateModel {
|
||||||
|
|
||||||
|
private boolean canEdit;
|
||||||
|
|
||||||
|
private Map<String, String> eventDateValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> variants;
|
||||||
|
|
||||||
|
private List<String> unusedLocales;
|
||||||
|
|
||||||
|
private String selectedLocale;
|
||||||
|
|
||||||
|
public Map<String, String> getEventDateValues() {
|
||||||
|
return Collections.unmodifiableMap(eventDateValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setEventDateValues(
|
||||||
|
final Map<String, String> eventDateValues
|
||||||
|
) {
|
||||||
|
this.eventDateValues = new HashMap<>(eventDateValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getVariants() {
|
||||||
|
return Collections.unmodifiableList(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setVariants(final List<CmsEditorLocaleVariantRow> variants) {
|
||||||
|
this.variants = new ArrayList<>(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUnusedLocales(final List<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("CmsEventInfoSstepEventType")
|
||||||
|
public class MvcEventInfoStepEventTypeModel {
|
||||||
|
|
||||||
|
private boolean canEdit;
|
||||||
|
|
||||||
|
private Map<String, String> eventTypeValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> variants;
|
||||||
|
|
||||||
|
private List<String> unusedLocales;
|
||||||
|
|
||||||
|
private String selectedLocale;
|
||||||
|
|
||||||
|
public Map<String, String> getEventTypeValues() {
|
||||||
|
return Collections.unmodifiableMap(eventTypeValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setEventTypeValues(final Map<String, String> eventTypeValues) {
|
||||||
|
this.eventTypeValues = new HashMap<>(eventTypeValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getVariants() {
|
||||||
|
return Collections.unmodifiableList(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setVariants(final List<CmsEditorLocaleVariantRow> variants) {
|
||||||
|
this.variants = new ArrayList<>(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUnusedLocales(final List<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("CmsEventInfoStepLocation")
|
||||||
|
public class MvcEventInfoStepLocationModel {
|
||||||
|
|
||||||
|
private boolean canEdit;
|
||||||
|
|
||||||
|
private Map<String, String> locationValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> variants;
|
||||||
|
|
||||||
|
private List<String> unusedLocales;
|
||||||
|
|
||||||
|
private String selectedLocale;
|
||||||
|
|
||||||
|
public Map<String, String> getLocationValues() {
|
||||||
|
return Collections.unmodifiableMap(locationValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setLocationValues(final Map<String, String> locationValues) {
|
||||||
|
this.locationValues = new HashMap<>(locationValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getVariants() {
|
||||||
|
return Collections.unmodifiableList(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setVariants(final List<CmsEditorLocaleVariantRow> variants) {
|
||||||
|
this.variants = new ArrayList<>(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUnusedLocales(final List<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("CmsEventInfoStepMainContributor")
|
||||||
|
public class MvcEventInfoStepMainContributorModel {
|
||||||
|
|
||||||
|
private boolean canEdit;
|
||||||
|
|
||||||
|
private Map<String, String> contributorValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> variants;
|
||||||
|
|
||||||
|
private List<String> unusedLocales;
|
||||||
|
|
||||||
|
private String selectedLocale;
|
||||||
|
|
||||||
|
public Map<String, String> getContributorValues() {
|
||||||
|
return Collections.unmodifiableMap(contributorValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setContributorValues(
|
||||||
|
final Map<String, String> contributorValues
|
||||||
|
) {
|
||||||
|
this.contributorValues = new HashMap<>(contributorValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getVariants() {
|
||||||
|
return Collections.unmodifiableList(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setVariants(final List<CmsEditorLocaleVariantRow> variants) {
|
||||||
|
this.variants = new ArrayList<>(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUnusedLocales(final List<String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -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.
|
||||||
Loading…
Reference in New Issue