props = super.properties(state);
- final Lifecycle cycle = selectedLifecycle.getLifecycle(state);
-
- final DateFormat format = DateFormat.getDateTimeInstance(
- DateFormat.FULL,
- DateFormat.FULL);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final Locale language = globalizationHelper
- .getNegotiatedLocale();
-
- props.add(new Property(
- gz("cms.ui.name"),
- cycle.getDefinition().getLabel().getValue(language)));
- props.add(new Property(
- gz("cms.ui.item.lifecycle.start_date"),
- format.format(cycle.getStartDateTime())));
-
- final java.util.Date endDate = cycle.getEndDateTime();
-
- if (endDate == null) {
- props.add(new Property(gz("cms.ui.item.lifecycle.end_date"),
- lz("cms.ui.none")));
- } else {
- props.add(new Property(gz("cms.ui.item.lifecycle.end_date"),
- format.format(endDate)));
- }
-
- return props;
- }
-
- }
-
- }
-
- private class PublishLink extends ActionLink {
-
- private final RequestLocal canPublishRequestLocal = new RequestLocal();
-
- PublishLink(final Component component) {
- super(component);
- }
-
- @Override
- public void generateXML(final PageState state, final Element parent) {
- Boolean canPublish = (Boolean) canPublishRequestLocal.get(state);
- if (null == canPublish) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- ContentItem item = selectedItem.getContentItem(state);
- if (permissionChecker.isPermitted(ItemPrivileges.PUBLISH, item)) {
- canPublish = true;
- } else {
- canPublish = false;
- }
-
- canPublishRequestLocal.set(state, canPublish);
- }
-
- if (canPublish) {
- if (LOGGER.isDebugEnabled()) {
- final ContentItem item = selectedItem.getContentItem(state);
- LOGGER.debug("User can publish {}" + item.getUuid());
- }
-
- super.generateXML(state, parent);
- } else if (LOGGER.isDebugEnabled()) {
- final ContentItem item = selectedItem.getContentItem(state);
- LOGGER.debug("User cannot publish {}", item.getUuid());
- }
- }
-
- }
-
- private class UnpublishLink extends PublishLink {
-
- UnpublishLink() {
- super(new Label(gz("cms.ui.item.lifecycle.unpublish")));
-
- super.addActionListener(new Listener());
- }
-
- private class Listener implements ActionListener {
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final ContentItem item = selectedItem.getContentItem(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemManager itemManager = cdiUtil.findBean(
- ContentItemManager.class);
-
- itemManager.unpublish(item);
-
- final String target = String.join(
- "",
- URL.getDispatcherPath(),
- ContentItemPage.getItemURL(item,
- ContentItemPage.AUTHORING_TAB));
-
- throw new RedirectSignal(target, true);
- }
-
- }
-
- }
-
- private static void republish(final ContentItem item,
- final boolean reset,
- final User user) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- controller.repulish(item);
- }
-
- private class RepublishLink extends PublishLink {
-
- RepublishLink() {
- super(new Label(gz("cms.ui.item.lifecycle.republish")));
-
- super.addActionListener(new Listener());
- }
-
- private class Listener implements ActionListener {
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
- final ContentItem item = selectedItem.getContentItem(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final Shiro shiro = cdiUtil.findBean(Shiro.class);
- final User user = shiro.getUser().get();
-
- /*
- * jensp 2011-12-14: Check is threaded publishing is active.
- * If yes, execute publishing in a thread.
- */
- if (CMSConfig.getConfig().isThreadPublishing()) {
- final Republisher republisher = new Republisher(item, user);
- final Thread thread = new Thread(republisher);
- thread.setUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler() {
-
- @Override
- public void uncaughtException(final Thread thread,
- final Throwable ex) {
- final StringWriter strWriter = new StringWriter();
- final PrintWriter writer
- = new PrintWriter(strWriter);
- ex.printStackTrace(writer);
-
-// PublishLock.getInstance().setError(item, strWriter
-// .toString());
- LOGGER.error(String.format(
- "An error occurred while "
- + "publishing the item '%s': ",
- item.getUuid()), ex);
-
- if ((CMSConfig.getConfig()
- .getPublishingFailureSender()
- == null)
- && (CMSConfig.getConfig()
- .getPublishingFailureReceiver()
- == null)) {
- return;
- }
-
- final UserRepository userRepo = cdiUtil.findBean(
- UserRepository.class);
- final User receiver = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureReceiver()).get();
- final User sender = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureSender()).get();
-
- if ((sender != null) && (receiver != null)) {
- final Writer traceWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(
- traceWriter);
- ex.printStackTrace(printWriter);
-
- final Mail notification = new Mail(
- receiver.getPrimaryEmailAddress()
- .getAddress(),
- sender.getPrimaryEmailAddress().getAddress(),
- String.format(
- "Failed to publish item '%s'",
- item.getUuid()));
- notification.setBody(String.format(
- "Publishing item '%s' failed "
- + "with error message: %s.\n\n"
- + "Stacktrace:\n%s",
- item.getUuid(),
- ex.getMessage(),
- traceWriter.toString()));
- try {
- notification.send();
- } catch (MessagingException msgex) {
- throw new UncheckedWrapperException(msgex);
- }
- }
- }
-
- });
-
- thread.start();
-
- throw new RedirectSignal(
- URL.getDispatcherPath()
- + ContentItemPage.getItemURL(item,
- ContentItemPage.PUBLISHING_TAB),
- true);
- /*
- * jensp 2011-12-14 end
- */
- } else {
- republish(item, false, user);
-// if (CMSConfig.getConfig().isUseStreamlinedCreation()) {
-// throw new RedirectSignal(
-// URL.there(state.getRequest(),
-// CmsConstants.CONTENT_CENTER_URL),
-// true);
-// }
- }
- }
-
- }
-
- /**
- * @author Jens Pelzetter
- */
- private class Republisher implements Runnable {
-
- private final String itemUuid;
- private final User user;
-
- private Republisher(final ContentItem item, User user) {
- itemUuid = item.getUuid();
- this.user = user;
- }
-
- @Override
- public void run() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final ContentItem item = itemRepo.findByUuid(itemUuid).get();
-
-// PublishLock.getInstance().lock(item);
- republish(item, false, user);
-// PublishLock.getInstance().unlock(item);
- }
-
- }
-
- }
-
- private class RepublishAndResetLink extends PublishLink {
-
- RepublishAndResetLink() {
- super(new Label(gz("cms.ui.item.lifecycle.republish_and_reset")));
-
- super.addActionListener(new Listener());
- // warning gets a bit annoying, and link should be descriptive
- // enough that it is not required
- // setConfirmation("This will reset all your publication dates, are
- // you sure you want to continue?");
- }
-
- private class Listener implements ActionListener {
-
- @Override
- public final void actionPerformed(final ActionEvent e) {
- final PageState state = e.getPageState();
- final ContentItem item = selectedItem.getContentItem(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final Shiro shiro = cdiUtil.findBean(Shiro.class);
- final User user = shiro.getUser().get();
-
- /**
- * jensp 2011-12-14: Execute is a thread if threaded publishing
- * is active.
- */
- if (CMSConfig.getConfig().isThreadPublishing()) {
- final Republisher republisher = new Republisher(item, user);
- final Thread thread = new Thread(republisher);
- thread.setUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler() {
-
- @Override
- public void uncaughtException(final Thread thread,
- final Throwable ex) {
- final StringWriter strWriter = new StringWriter();
- final PrintWriter writer
- = new PrintWriter(strWriter);
- ex.printStackTrace(writer);
-
-// PublishLock.getInstance().setError(item, strWriter
-// .toString());
- LOGGER.error(String.format(
- "An error occurred while "
- + "publishing the item '%s': ",
- item.getUuid()), ex);
-
- if ((CMSConfig.getConfig().
- getPublishingFailureSender() == null)
- && (CMSConfig.getConfig().
- getPublishingFailureReceiver()
- == null)) {
- return;
- }
-
- final UserRepository userRepo = cdiUtil.findBean(
- UserRepository.class);
- final User receiver = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureReceiver()).get();
- final User sender = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureSender()).get();
-
- if ((sender != null) && (receiver != null)) {
- final Writer traceWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(
- traceWriter);
- ex.printStackTrace(printWriter);
-
- final Mail notification = new Mail(
- receiver.getPrimaryEmailAddress()
- .getAddress(),
- sender.getPrimaryEmailAddress().getAddress(),
- String.format(
- "Failed to publish item '%s'",
- item.getUuid()));
- notification.setBody(String.format(
- "Publishing item '%s' failed "
- + "with error message: %s.\n\n"
- + "Stacktrace:\n%s",
- item.getUuid(),
- ex.getMessage(),
- traceWriter.toString()));
- try {
- notification.send();
- } catch (MessagingException msgex) {
- throw new UncheckedWrapperException(msgex);
- }
- }
- }
-
- });
-
- thread.start();
-
- throw new RedirectSignal(
- URL.getDispatcherPath()
- + ContentItemPage.getItemURL(item,
- ContentItemPage.PUBLISHING_TAB),
- true);
- } else {
- /**
- * jensp 2011-12-14 end
- */
- republish(item, true, user);
-// if (CMSConfig.getConfig().isUseStreamlinedCreation()) {
-// throw new RedirectSignal(
-// URL.there(state.getRequest(),
-// CmsConstants.CONTENT_CENTER_URL),
-// true);
-// }
- }
- }
-
- }
-
- /**
- * @author Jens Pelzetter
- */
- private class Republisher implements Runnable {
-
- private final String itemUuid;
- private final User user;
-
- private Republisher(final ContentItem item, User user) {
- itemUuid = item.getUuid();
- this.user = user;
- }
-
- @Override
- public void run() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final ContentItem item = itemRepo.findByUuid(itemUuid).get();
-// PublishLock.getInstance().lock(item);
- republish(item, true, user);
-// PublishLock.getInstance().unlock(item);
- }
-
- }
-
- }
-
- private class PhaseSection extends Section {
-
- PhaseSection() {
- super(gz("cms.ui.lifecycle.phases"));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(new PhaseTable());
- }
-
- }
-
- private class PhaseTable extends Table {
-
- PhaseTable() {
- super(new ItemPhaseTableModelBuilder(selectedLifecycle),
- new String[]{
- lz("cms.ui.name"),
- lz("cms.ui.description"),
- lz("cms.ui.item.lifecycle.start_date"),
- lz("cms.ui.item.lifecycle.end_date")
- });
- }
-
- }
-
- /**
- * New style pane. Uses a select box for the action to avoid wrong clicks on
- * unpublish.
- *
- * @author Jens Pelzetter
- */
- private class ActionForm
- extends Form
- implements FormProcessListener,
- FormInitListener {
-
- private static final String LIFECYCLE_ACTION
- = "itemLifecycleItemPaneActionSelect";
- private static final String REPUBLISH = "republish";
- private static final String UNPUBLISH = "unpublish";
- private static final String REPUBLISH_AND_RESET = "republishAndReset";
- private final Submit submit;
- private final Label notAuthorized;
-
- public ActionForm() {
- super("itemLifecycleItemPaneActionForm");
-
- final BoxPanel actionPanel = new BoxPanel(BoxPanel.HORIZONTAL);
- final SingleSelect actionSelect = new SingleSelect(
- LIFECYCLE_ACTION);
-
- actionSelect.addOption(new Option(
- REPUBLISH,
- new Label(new GlobalizedMessage(
- "cms.ui.item.lifecycle.republish",
- CmsConstants.CMS_BUNDLE))));
- if (!CMSConfig.getConfig().isHideResetLifecycleLink()) {
- actionSelect.addOption(new Option(
- REPUBLISH_AND_RESET,
- new Label(new GlobalizedMessage(
- "cms.ui.item.lifecycle.republish_and_reset",
- CmsConstants.CMS_BUNDLE))));
- }
- actionSelect.addOption(new Option(
- UNPUBLISH,
- new Label(gz("cms.ui.item.lifecycle.unpublish"))));
-
- submit = new Submit(gz("cms.ui.item.lifecycle.do"));
- notAuthorized = new Label(gz(
- "cms.ui.item.lifecycle.do.not_authorized"));
-
- actionPanel.add(actionSelect);
- actionPanel.add(submit);
- actionPanel.add(notAuthorized);
- add(actionPanel);
-
- addInitListener(this);
- addProcessListener(this);
- }
-
- @Override
- public void init(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final ContentItem item = selectedItem.getContentItem(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- if (permissionChecker.isPermitted(ItemPrivileges.PUBLISH, item)) {
- submit.setVisible(state, true);
- notAuthorized.setVisible(state, false);
- } else {
- submit.setVisible(state, false);
- notAuthorized.setVisible(state, true);
- }
- }
-
- @Override
- public void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final FormData data = event.getFormData();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final Shiro shiro = cdiUtil.findBean(Shiro.class);
- final User user = shiro.getUser().get();
-
- String selected = (String) data.get(LIFECYCLE_ACTION);
- final ContentItem item = selectedItem.getContentItem(state);
-
- /**
- * Republish/Republish and Reset are executed in the thread if
- * threaded publishing is active.
- */
- if (REPUBLISH.equals(selected)) {
- if (CMSConfig.getConfig().isThreadPublishing()) {
- final RepublishRunner runner = new RepublishRunner(item,
- user);
- final Thread thread = new Thread(runner);
- thread.setUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler() {
-
- @Override
- public void uncaughtException(final Thread thread,
- final Throwable ex) {
- final StringWriter strWriter = new StringWriter();
- final PrintWriter writer
- = new PrintWriter(strWriter);
- ex.printStackTrace(writer);
-
-// PublishLock.getInstance().setError(item, strWriter
-// .toString());
- LOGGER.error(String.format(
- "An error occurred while "
- + "publishing the item '%s': ",
- item.getUuid()), ex);
-
- if ((CMSConfig.getConfig()
- .getPublishingFailureSender()
- == null)
- && (CMSConfig.getConfig()
- .getPublishingFailureReceiver()
- == null)) {
- return;
- }
-
- final UserRepository userRepo = cdiUtil.findBean(
- UserRepository.class);
- final User receiver = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureReceiver()).get();
- final User sender = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureSender()).get();
-
- if ((sender != null) && (receiver != null)) {
- final Writer traceWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(
- traceWriter);
- ex.printStackTrace(printWriter);
-
- final Mail notification = new Mail(
- receiver.getPrimaryEmailAddress()
- .getAddress(),
- sender.getPrimaryEmailAddress().getAddress(),
- String.format(
- "Failed to publish item '%s'",
- item.getUuid()));
- notification.setBody(String.format(
- "Publishing item '%s' failed "
- + "with error message: %s.\n\n"
- + "Stacktrace:\n%s",
- item.getUuid(),
- ex.getMessage(),
- traceWriter.toString()));
- try {
- notification.send();
- } catch (MessagingException msgex) {
- throw new UncheckedWrapperException(msgex);
- }
- }
- }
-
- });
-
- thread.start();
-
- throw new RedirectSignal(
- URL.getDispatcherPath()
- + ContentItemPage.getItemURL(item,
- ContentItemPage.PUBLISHING_TAB),
- true);
- } else {
- republish(item, false, user);
-
-// if (CMSConfig.getConfig().isUseStreamlinedCreation()) {
-// throw new RedirectSignal(
-// URL.there(state.getRequest(),
-// CmsConstants.CONTENT_CENTER_URL), true);
-// }
- }
- } else if (REPUBLISH_AND_RESET.equals(selected)) {
- if (CMSConfig.getConfig().isThreadPublishing()) {
- final RepublishAndResetRunner runner
- = new RepublishAndResetRunner(
- item, user);
- final Thread thread = new Thread(runner);
- thread.setUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler() {
-
- @Override
- public void uncaughtException(final Thread thread,
- final Throwable ex) {
- final StringWriter strWriter = new StringWriter();
- final PrintWriter writer
- = new PrintWriter(strWriter);
- ex.printStackTrace(writer);
-
-// PublishLock.getInstance().setError(item, strWriter
-// .toString());
- LOGGER.error(String.format(
- "An error occurred while "
- + "publishing the item '%s': ",
- item.getUuid()), ex);
-
- if ((CMSConfig.getConfig()
- .getPublishingFailureSender()
- == null)
- && (CMSConfig.getConfig()
- .getPublishingFailureReceiver()
- == null)) {
- return;
- }
-
- final UserRepository userRepo = cdiUtil.findBean(
- UserRepository.class);
- final User receiver = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureReceiver()).get();
- final User sender = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureSender()).get();
-
- if ((sender != null) && (receiver != null)) {
- final Writer traceWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(
- traceWriter);
- ex.printStackTrace(printWriter);
-
- final Mail notification = new Mail(
- receiver.getPrimaryEmailAddress()
- .getAddress(),
- sender.getPrimaryEmailAddress().getAddress(),
- String.format(
- "Failed to publish item '%s'",
- item.getUuid()));
- notification.setBody(String.format(
- "Publishing item '%s' failed "
- + "with error message: %s.\n\n"
- + "Stacktrace:\n%s",
- item.getUuid(),
- ex.getMessage(),
- traceWriter.toString()));
- try {
- notification.send();
- } catch (MessagingException msgex) {
- throw new UncheckedWrapperException(msgex);
- }
- }
- }
-
- });
-
- thread.start();
-
- throw new RedirectSignal(
- URL.getDispatcherPath()
- + ContentItemPage.getItemURL(item,
- ContentItemPage.PUBLISHING_TAB),
- true);
- } else {
- republish(item, true, user);
-
-// if (CMSConfig.getConfig().isUseStreamlinedCreation()) {
-// throw new RedirectSignal(
-// URL.there(state.getRequest(),
-// CmsConstants.CONTENT_CENTER_URL), true);
-// }
- }
- } else if (UNPUBLISH.equals(selected)) {
- final ContentItemManager itemManager = cdiUtil.findBean(
- ContentItemManager.class);
- itemManager.unpublish(item);
- } else {
- throw new IllegalArgumentException("Illegal selection");
- }
- }
-
- private class RepublishRunner implements Runnable {
-
- private final String itemUuid;
- private final User user;
-
- private RepublishRunner(final ContentItem item,
- final User user) {
- itemUuid = item.getUuid();
- this.user = user;
- }
-
- private void doRepublish() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final ContentItem item = itemRepo.findByUuid(itemUuid).get();
- republish(item, false, user);
- }
-
- @Override
- public void run() {
-// PublishLock.getInstance().lock(item);
- doRepublish();
-// PublishLock.getInstance().unlock(item);
- }
-
- }
-
- private class RepublishAndResetRunner implements Runnable {
-
- private final String itemUuid;
- private final User user;
-
- private RepublishAndResetRunner(final ContentItem item,
- final User user) {
- itemUuid = item.getUuid();
- this.user = user;
- }
-
- private void doRepublishAndReset() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final ContentItem item = itemRepo.findByUuid(itemUuid).get();
- republish(item, true, user);
- }
-
- @Override
- public void run() {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final ContentItem item = itemRepo.findByUuid(itemUuid).get();
-// PublishLock.getInstance().lock(item);
- doRepublishAndReset();
-// PublishLock.getInstance().unlock(item);
- }
-
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java
deleted file mode 100755
index 8262fe089..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.BoxPanel;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.Text;
-import com.arsdigita.bebop.event.FormInitListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormValidationListener;
-import com.arsdigita.bebop.event.PrintEvent;
-import com.arsdigita.bebop.event.PrintListener;
-import com.arsdigita.bebop.form.Date;
-import com.arsdigita.bebop.form.Option;
-import com.arsdigita.bebop.form.SingleSelect;
-import com.arsdigita.bebop.form.Submit;
-import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.bebop.parameters.DateParameter;
-import com.arsdigita.bebop.parameters.IntegerParameter;
-import com.arsdigita.bebop.parameters.NumberInRangeValidationListener;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ui.BaseForm;
-import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
-import com.arsdigita.cms.ui.item.ItemWorkflowRequestLocal;
-import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal;
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.mail.Mail;
-import com.arsdigita.util.UncheckedWrapperException;
-import com.arsdigita.web.RedirectSignal;
-import com.arsdigita.web.URL;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.libreccm.security.Shiro;
-import org.libreccm.security.User;
-import org.libreccm.security.UserRepository;
-import org.libreccm.workflow.Task;
-import org.libreccm.workflow.TaskManager;
-import org.libreccm.workflow.Workflow;
-import org.libreccm.workflow.WorkflowManager;
-import org.libreccm.workflow.WorkflowRepository;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemManager;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.privileges.ItemPrivileges;
-import org.librecms.lifecycle.LifecycleDefinition;
-import org.librecms.workflow.CmsTask;
-import org.librecms.workflow.CmsTaskManager;
-import org.librecms.workflow.CmsTaskType;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-import java.util.TimeZone;
-import java.util.TooManyListenersException;
-
-import javax.mail.MessagingException;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- *
- * A form to select and apply a lifecycle to a content item.
- *
- * @author Michael Pih
- * @author Xixi D'moon <xdmoon@redhat.com>
- * @author Justin Ross <jross@redhat.com>
- * @author Jens Pelzetter
- */
-class ItemLifecycleSelectForm extends BaseForm {
-
- private static final Logger LOGGER = LogManager.getLogger(
- ItemLifecycleSelectForm.class);
-
- private final static String LIFECYCLE = "lifecycle";
- private final static String START_DATE = "start_date";
- private final static String END_DATE = "end_date";
- private final static String NOTIFICATION_DAYS = "notifyDays";
- private final static String NOTIFICATION_HOURS = "notifyHours";
-
- private final ContentItemRequestLocal itemRequestLocal;
- private final WorkflowRequestLocal workflowRequestLocal;
-
- // Form widgets
- private final SingleSelect cycleSelect;
- private final Date startDateField;
- private final TextField startHourField;
- private final TextField startMinuteField;
- private final SingleSelect startAmpmSelect;
- private final Date endDateField;
- private final TextField endHourField;
- private final TextField endMinuteField;
- private final SingleSelect endAmpmSelect;
- private final TextField notificationDaysField;
- private final TextField notificationHoursField;
-
- public ItemLifecycleSelectForm(final ContentItemRequestLocal item) {
- super("PublishItem", gz("cms.ui.item.lifecycle.apply"));
-
- this.itemRequestLocal = item;
- workflowRequestLocal = new ItemWorkflowRequestLocal();
-
- cycleSelect = new SingleSelect(new BigDecimalParameter(LIFECYCLE));
- try {
- cycleSelect.addPrintListener(new OptionPrinter());
- } catch (TooManyListenersException tmle) {
- throw new UncheckedWrapperException(tmle);
- }
- addField(gz("cms.ui.item.lifecycle"), cycleSelect);
-
- // Start date
- startDateField = new Date(new DateParameter(START_DATE) {
-
- @Override
- protected final Calendar getCalendar(final HttpServletRequest sreq) {
- final Calendar cal = super.getCalendar(sreq);
-
- cal.setLenient(false);
-
- return cal;
- }
-
- });
- addField(gz("cms.ui.item.lifecycle.start_date"), startDateField);
-
- // Start time
- final BoxPanel startTime = new BoxPanel(BoxPanel.HORIZONTAL);
- addField(gz("cms.ui.item.lifecycle.start_time"), startTime);
-
- // Hour
- startHourField = new TextField(new IntegerParameter("start_hour"));
- startTime.add(startHourField);
-
- startHourField.setSize(3);
- startHourField.addValidationListener(
- new NumberInRangeValidationListener(1, 12));
-
- // Minute
- startMinuteField = new TextField(new IntegerParameter("start_minute"));
- startTime.add(startMinuteField);
-
- startMinuteField.setSize(3);
- startMinuteField.addValidationListener(
- new NumberInRangeValidationListener(
- 0, 59));
-
- // AM/PM
- startAmpmSelect = new SingleSelect(new IntegerParameter("start_ampm"));
- startTime.add(startAmpmSelect);
-
- startAmpmSelect.addOption(new Option("0", "am"));
- startAmpmSelect.addOption(new Option("1", "pm"));
-
- // Time zone
- startTime.add(new Label(new TimeZonePrinter()));
-
- // Expiration date
- endDateField = new Date(new DateParameter(END_DATE) {
-
- @Override
- protected final Calendar getCalendar(final HttpServletRequest sreq) {
- final Calendar cal = super.getCalendar(sreq);
-
- cal.setLenient(false);
-
- return cal;
- }
-
- });
- addField(gz("cms.ui.item.lifecycle.end_date"), endDateField);
-
- // End time
- final BoxPanel endTime = new BoxPanel(BoxPanel.HORIZONTAL);
- addField(gz("cms.ui.item.lifecycle.end_time"), endTime);
-
- // Hour
- endHourField = new TextField(new IntegerParameter("end_hour"));
- endTime.add(endHourField);
-
- endHourField.setSize(3);
- endHourField.addValidationListener(
- new NumberInRangeValidationListener(1,
- 12));
-
- // Minute
- endMinuteField = new TextField(new IntegerParameter("end_minute"));
- endTime.add(endMinuteField);
-
- endMinuteField.setSize(3);
- endMinuteField.addValidationListener(
- new NumberInRangeValidationListener(0, 59));
-
- // AM/PM
- endAmpmSelect = new SingleSelect(new IntegerParameter("end_ampm"));
- endTime.add(endAmpmSelect);
-
- endAmpmSelect.addOption(new Option("0", "am"));
- endAmpmSelect.addOption(new Option("1", "pm"));
-
- endTime.add(new Label(new TimeZonePrinter()));
-
- notificationDaysField = new TextField(new IntegerParameter(
- NOTIFICATION_DAYS));
- notificationDaysField.setSize(4);
- notificationHoursField = new TextField(new IntegerParameter(
- NOTIFICATION_HOURS));
- notificationHoursField.setSize(4);
- SimpleContainer cont = new SimpleContainer();
- cont.add(notificationDaysField);
- cont.add(new Label(new GlobalizedMessage("cms.ui.item.days",
- CmsConstants.CMS_BUNDLE),
- false));
- cont.add(notificationHoursField);
- cont.add(new Label(new GlobalizedMessage("cms.ui.item.hours",
- CmsConstants.CMS_BUNDLE),
- false));
-
- addField(gz("cms.ui.item.notification_period"), cont);
-
- // A hidden field that checks to see if the user wants publish
- // with a start time earlier than current time.
- addAction(new Submit("finish", gz("cms.ui.item.lifecycle.publish")));
-
- // Form listeners
- super.addValidationListener(new ValidationListener());
- super.addSecurityListener(ItemPrivileges.PUBLISH, item);
- super.addInitListener(new InitListener());
- super.addProcessListener(new ProcessListener());
- }
-
- private class OptionPrinter implements PrintListener {
-
- @Override
- public final void prepare(final PrintEvent event) {
- final ContentSection section = CMS.getContext().getContentSection();
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- final List definitions = controller
- .getLifecycleDefinitions(section);
-
- final SingleSelect target = (SingleSelect) event.getTarget();
- target.clearOptions();
-
- final GlobalizationHelper globalizationHelper = cdiUtil.findBean(
- GlobalizationHelper.class);
- final Locale locale = globalizationHelper.getNegotiatedLocale();
-
- for (final LifecycleDefinition definition : definitions) {
-// final List phaseDefinitions = definition
-// .getPhaseDefinitions();
-//
-// if (!phaseDefinitions.isEmpty()) {
- target.addOption(
- new Option(
- Long.toString(definition.getDefinitionId()),
- new Text(globalizationHelper
- .getValueFromLocalizedString(definition.getLabel()))));
-// }
- }
- }
-
- }
-
- private class InitListener implements FormInitListener {
-
- @Override
- public final void init(final FormSectionEvent event) {
-
- final PageState state = event.getPageState();
-
- final ContentItem item = itemRequestLocal.getContentItem(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentItemManager itemManager = cdiUtil
- .findBean(ContentItemManager.class);
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- if (itemManager.isLive(item)) {
- // If the item is published, select the currently
- // associated lifecycle.
-
- final LifecycleDefinition definition = controller
- .getDefinitionOfLifecycle(item);
-// final LifecycleDefinition definition = item
-// .getLifecycle()
-// .getDefinition();
- cycleSelect.setValue(state, definition.getDefinitionId());
- } else {
- // Set the default lifecycle (if it exists).
- controller
- .getDefaultLifecycle(item)
- .ifPresent(definition -> cycleSelect.setValue(state,
- definition));
- }
-
- // Set the default start date.
- // XXX Isn't just new Date() sufficient?
- final java.util.Date start = new java.util.Date();
- startDateField.setValue(state, start);
-
- final Calendar calendar = Calendar.getInstance();
- calendar.setTime(start);
-
- // If the hour is 12, then Calendar.get(Calendar.HOUR)
- // returns 0 (from the 24 hour time - 12). We want it to
- // return 12.
- if (calendar.get(Calendar.HOUR) == 0) {
- startHourField.setValue(state, 12);
- } else {
- startHourField.setValue(state, calendar.get(Calendar.HOUR));
- }
-
- final Integer min = calendar.get(Calendar.MINUTE);
-
- if (min < 10) {
- startMinuteField.setValue(state, "0" + min.toString());
- } else {
- startMinuteField.setValue(state, min.toString());
- }
-
- startAmpmSelect.setValue(state, calendar.get(Calendar.AM_PM));
-
- final int defaultIime = CMSConfig.getConfig()
- .getDefaultNotificationTime();
- final int defaultTimeDays = defaultIime / 24;
- final int defaultTimeHours = defaultIime % 24;
-
- notificationDaysField.setValue(state, defaultTimeDays);
- notificationHoursField.setValue(state, defaultTimeHours);
- }
-
- }
-
- /**
- * jensp 2011-12-14: Some larger changes to the behavior of the process
- * listener. The real action has been moved to the
- * @link{Publisher} class. If threaded publishing is active, the publish
- * process runs in a separate thread (the item is locked before using
- * {@link PublishLock}. If threaded publishing is not active, nothing has
- * changed.
- */
- private class ProcessListener implements FormProcessListener {
-
- @Override
- public final void process(final FormSectionEvent event)
- throws FormProcessException {
- final PageState state = event.getPageState();
- final ContentItem item = itemRequestLocal.getContentItem(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- final Publisher publisher = new Publisher(state);
- if (CMSConfig.getConfig().isThreadPublishing()) {
- final Runnable threadAction = new Runnable() {
-
- @Override
- public void run() {
-// PublishLock.getInstance().lock(item);
- publisher.publish();
-// PublishLock.getInstance().unlock(item);
- }
-
- };
- final Thread thread = new Thread(threadAction);
- thread.setUncaughtExceptionHandler(
- new Thread.UncaughtExceptionHandler() {
-
- @Override
- public void uncaughtException(final Thread thread,
- final Throwable ex) {
- final StringWriter strWriter = new StringWriter();
- final PrintWriter writer = new PrintWriter(strWriter);
- ex.printStackTrace(writer);
-
-// PublishLock.getInstance().setError(item, strWriter
-// .toString());
- LOGGER.error(String.format(
- "An error occurred while "
- + "publishing the item '%s': ",
- item.getUuid()), ex);
-
- if ((CMSConfig.getConfig()
- .getPublishingFailureSender() == null)
- && (CMSConfig.getConfig()
- .getPublishingFailureReceiver()
- == null)) {
- return;
- }
-
- final UserRepository userRepo = cdiUtil.findBean(
- UserRepository.class);
- final User receiver = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureReceiver()).get();
- final User sender = userRepo.findByEmailAddress(
- CMSConfig.getConfig()
- .getPublishingFailureSender()).get();
-
- if ((sender != null) && (receiver != null)) {
- final Writer traceWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(
- traceWriter);
- ex.printStackTrace(printWriter);
-
- final Mail notification = new Mail(
- receiver.getPrimaryEmailAddress()
- .getAddress(),
- sender.getPrimaryEmailAddress().getAddress(),
- String.format(
- "Failed to publish item '%s'",
- item.getUuid()));
- notification.setBody(String.format(
- "Publishing item '%s' failed "
- + "with error message: %s.\n\n"
- + "Stacktrace:\n%s",
- item.getUuid(),
- ex.getMessage(),
- traceWriter.toString()));
- try {
- notification.send();
- } catch (MessagingException msgex) {
- throw new UncheckedWrapperException(msgex);
- }
- }
- }
-
- });
- thread.start();
- } else {
- publisher.publish();
- }
-
- if (CMSConfig.getConfig().isThreadPublishing()) {
- throw new RedirectSignal(
- URL.getDispatcherPath()
- + controller.getPublishingTabUrl(item),
- true);
- } else {
- if (CMSConfig.getConfig().isUseStreamlinedCreation()) {
- throw new RedirectSignal(
- URL.there(state.getRequest(),
- CmsConstants.CONTENT_CENTER_URL), true);
- }
- }
-
- /*
- * final Integer startHour = (Integer) m_startHour.getValue(state);
- * Integer startMinute = (Integer) m_startMinute.getValue(state);
- *
- * if (startMinute == null) { startMinute = new Integer(0); }
- *
- * final Integer startAmpm = (Integer) m_startAmpm.getValue(state);
- *
- * final Integer endHour = (Integer) m_endHour.getValue(state);
- * Integer endMinute = (Integer) m_endMinute.getValue(state);
- *
- * if (endMinute == null) { endMinute = new Integer(0); }
- *
- * final Integer endAmpm = (Integer) m_endAmpm.getValue(state);
- *
- * // Instantiate the instance of the content type. final
- * ContentItem item = m_item.getContentItem(state);
- *
- * final BigDecimal defID = (BigDecimal)
- * m_cycleSelect.getValue(state); Assert.exists(defID); final
- * LifecycleDefinition cycleDef = new LifecycleDefinition(defID);
- *
- * java.util.Date startDate = (java.util.Date)
- * m_startDate.getValue(state);
- *
- * final Calendar start = Calendar.getInstanceOf();
- * start.setTime(startDate); start.set(Calendar.AM_PM,
- * startAmpm.intValue()); start.set(Calendar.MINUTE,
- * startMinute.intValue()); start.set(Calendar.AM_PM,
- * startAmpm.intValue()); if (startHour.intValue() != 12) {
- * start.set(Calendar.HOUR_OF_DAY, 12 * startAmpm.intValue() +
- * startHour.intValue()); start.set(Calendar.HOUR,
- * startHour.intValue()); } else { if (startAmpm.intValue() == 0) {
- * start.set(Calendar.HOUR_OF_DAY, 0); start.set(Calendar.HOUR, 0);
- * } else { start.set(Calendar.HOUR_OF_DAY, 12);
- * start.set(Calendar.HOUR, 0); } } startDate = start.getTime();
- *
- * java.util.Date endDate = (java.util.Date)
- * m_endDate.getValue(state);
- *
- * if (endDate != null) { final Calendar end =
- * Calendar.getInstanceOf();
- *
- * end.setTime(endDate); end.set(Calendar.AM_PM,
- * endAmpm.intValue()); end.set(Calendar.MINUTE,
- * endMinute.intValue()); end.set(Calendar.AM_PM,
- * endAmpm.intValue());
- *
- * if (endHour.intValue() != 12) { end.set(Calendar.HOUR_OF_DAY, 12
- * * endAmpm.intValue() + endHour.intValue());
- * end.set(Calendar.HOUR, endHour.intValue()); } else { if
- * (endAmpm.intValue() == 0) { end.set(Calendar.HOUR_OF_DAY, 0);
- * end.set(Calendar.HOUR, 0); } else { end.set(Calendar.HOUR_OF_DAY,
- * 12); end.set(Calendar.HOUR, 0); } } endDate = end.getTime(); }
- *
- * // If the item is already published, remove the current
- * lifecycle. // Do not touch the live version. if
- * (item.isPublished()) { item.removeLifecycle(item); item.save(); }
- *
- * // Apply the new lifecycle. ContentItem pending =
- * item.publish(cycleDef, startDate); final Lifecycle lifecycle =
- * pending.getLifecycle();
- *
- * // XXX domlay Whoa. This must be broken for multiphase //
- * lifecycles.
- *
- * if (endDate != null) {
- *
- * // update individual phases final PhaseCollection phases =
- * lifecycle.getPhases();
- *
- * while (phases.next()) { final Phase phase = phases.getPhase();
- * java.util.Date thisEnd = phase.getEndDate(); java.util.Date
- * thisStart = phase.getStartDate(); if
- * (thisStart.compareTo(endDate) > 0) { phase.setStartDate(endDate);
- * phase.save(); }
- *
- * if (thisEnd == null || thisEnd.compareTo(endDate) > 0) {
- * phase.setEndDate(endDate); phase.save(); } } }
- *
- * // endOfCycle may be the original date according to lifecycle
- * phase definitions, or endDate if that was before // natural end
- * of lifecycle java.util.Date endOfCycle = lifecycle.getEndDate();
- * if (endOfCycle != null) {
- *
- * // if advance notification is requested (!= 0) // add another
- * phase at the start of which the user is notified Integer
- * notificationDays = (Integer) m_notificationDays.getValue(state);
- * Integer notificationHours = (Integer)
- * m_notificationHours.getValue(state); java.util.Date
- * notificationDate = null;
- *
- * int notificationPeriod = 0; if (notificationDays != null) {
- * notificationPeriod += notificationDays.intValue() * 24; } if
- * (notificationHours != null) { notificationPeriod +=
- * notificationHours.intValue(); }
- *
- * if (notificationPeriod > 0) { notificationDate =
- * computeNotificationDate(endOfCycle, notificationPeriod);
- * s_log.debug("adding custom phase"); Phase expirationImminentPhase
- * = lifecycle.addCustomPhase("expirationImminent", new
- * Long(notificationDate. getTime()), new
- * Long(endOfCycle.getTime()));
- * expirationImminentPhase.setListenerClassName(
- * "org.librecms.lifecycle.NotifyLifecycleListener");
- * expirationImminentPhase.save(); } }
- *
- * // Force the lifecycle scheduler to run to avoid any //
- * scheduler delay for items that should be published //
- * immediately. pending.getLifecycle().start();
- *
- * item.save();
- *
- * final Workflow workflow = m_workflow.getWorkflow(state); try {
- * finish(workflow, item, Web.getWebContext().getUser()); } catch
- * (TaskException te) { throw new FormProcessException(te); } //
- * redirect to /content-center if streamlined creation mode is
- * active. if
- * (ContentSection.getConfig().getUseStreamlinedCreation()) { throw
- * new RedirectSignal(URL.there(state.getRequest(),
- * Utilities.getWorkspaceURL()), true); }
- */
- }
-
- }
-
- /**
- * This class contains the real publish action.
- */
- private class Publisher {
-
- private final Integer startHour;
- private final Integer startMinute;
- private final Integer startAmpm;
- private final Integer endHour;
- private final Integer endMinute;
- private final Integer endAmpm;
- private final String itemUuid;
- private final Long defID;
- private final java.util.Date startDate;
- private final java.util.Date endDate;
- private final Integer notificationDays;
- private final Integer notificationHours;
- private final String workflowUuid;
- private final User user;
-
- /**
- * The constructor collects all necessary data and stores them.
- *
- * @param state
- */
- public Publisher(final PageState state) {
- startHour = (Integer) startHourField.getValue(state);
- if (startMinuteField.getValue(state) == null) {
- startMinute = 0;
- } else {
- startMinute = (Integer) startMinuteField.getValue(state);
- }
- startAmpm = (Integer) startAmpmSelect.getValue(state);
-
- endHour = (Integer) endHourField.getValue(state);
- if (endMinuteField.getValue(state) == null) {
- endMinute = 0;
- } else {
- endMinute = (Integer) endMinuteField.getValue(state);
- }
- endAmpm = (Integer) endAmpmSelect.getValue(state);
-
- //item = m_item.getContentItem(state);
- itemUuid = itemRequestLocal.getContentItem(state).getItemUuid();
-
- if (cycleSelect.getValue(state) instanceof BigDecimal) {
- defID = ((Number) cycleSelect.getValue(state)).longValue();
- } else if (cycleSelect.getValue(state) instanceof Long) {
- defID = (Long) cycleSelect.getValue(state);
- } else {
- defID = Long.parseLong(cycleSelect.getValue(state).toString());
- }
-
- final Calendar start = Calendar.getInstance();
- start.setTime((java.util.Date) startDateField.getValue(state));
- start.set(Calendar.AM_PM, startAmpm);
- start.set(Calendar.MINUTE, startMinute);
- start.set(Calendar.AM_PM, startAmpm);
- if (startHour != 12) {
- start.set(Calendar.HOUR_OF_DAY,
- 12 * startAmpm + startHour);
- start.set(Calendar.HOUR, startHour);
- } else {
- if (startAmpm == 0) {
- start.set(Calendar.HOUR_OF_DAY, 0);
- start.set(Calendar.HOUR, 0);
- } else {
- start.set(Calendar.HOUR_OF_DAY, 12);
- start.set(Calendar.HOUR, 0);
- }
- }
- startDate = start.getTime();
-
- if (endDateField.getValue(state) == null) {
- endDate = null;
- } else {
- final Calendar end = Calendar.getInstance();
-
- end.setTime((java.util.Date) endDateField.getValue(state));
- end.set(Calendar.AM_PM, endAmpm);
- end.set(Calendar.MINUTE, endMinute);
- end.set(Calendar.AM_PM, endAmpm);
-
- if (endHour != 12) {
- end.set(Calendar.HOUR_OF_DAY,
- 12 * endAmpm + endHour);
- end.set(Calendar.HOUR, endHour);
- } else {
- if (endAmpm == 0) {
- end.set(Calendar.HOUR_OF_DAY, 0);
- end.set(Calendar.HOUR, 0);
- } else {
- end.set(Calendar.HOUR_OF_DAY, 12);
- end.set(Calendar.HOUR, 0);
- }
- }
- endDate = end.getTime();
- }
-
- notificationDays = (Integer) notificationDaysField.getValue(state);
- notificationHours = (Integer) notificationHoursField.getValue(state);
-
- if (workflowRequestLocal.getWorkflow(state) != null) {
- workflowUuid = workflowRequestLocal.getWorkflow(state).getUuid();
- } else {
- workflowUuid = null;
- }
-
- user = CdiUtil.createCdiUtil().findBean(Shiro.class).getUser().get();
- }
-
- /**
- * Published the item
- */
- public void publish() {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- controller.publish(itemUuid, defID, endDate, workflowUuid, user);
-
-// final ContentItemRepository itemRepo = cdiUtil.findBean(
-// ContentItemRepository.class);
-// final ContentItemManager itemManager = cdiUtil.findBean(
-// ContentItemManager.class);
-// final PhaseRepository phaseRepo = cdiUtil.findBean(
-// PhaseRepository.class);
-// final LifecycleDefinitionRepository lifecycleDefRepo = cdiUtil
-// .findBean(LifecycleDefinitionRepository.class);
-// final LifecycleManager lifecycleManager = cdiUtil.findBean(
-// LifecycleManager.class);
-//
-// final ContentItem item = itemRepo.findByUuid(itemUuid).get();
-//
-// // If the item is already published, remove the current lifecycle.
-// // Do not touch the live version.
-// if (itemManager.isLive(item)) {
-// item.setLifecycle(null);
-// itemRepo.save(item);
-// }
-//
-// ContentItem pending;
-// final LifecycleDefinition cycleDef;
-// final Lifecycle lifecycle;
-// // Apply the new lifecycle.
-// cycleDef = lifecycleDefRepo.findById(defID).get();
-// pending = itemManager.publish(item, cycleDef);
-// lifecycle = pending.getLifecycle();
-//
-// if (endDate != null) {
-//
-// // update individual phases
-// final List phases = lifecycle.getPhases();
-//
-// for (final Phase phase : phases) {
-// final java.util.Date thisEnd = phase.getEndDateTime();
-// final java.util.Date thisStart = phase.getStartDateTime();
-// if (thisStart.compareTo(endDate) > 0) {
-// phase.setStartDateTime(endDate);
-// phaseRepo.save(phase);
-// }
-// }
-// }
-//
-// // endOfCycle may be the original date according to lifecycle phase definitions, or endDate if that was before
-// // natural end of lifecycle
-// final java.util.Date endOfCycle = lifecycle.getEndDateTime();
-// if (endOfCycle != null) {
-//
-// // if advance notification is requested (!= 0)
-// // add another phase at the start of which the user is notified
-// java.util.Date notificationDate;
-//
-// int notificationPeriod = 0;
-// if (notificationDays != null) {
-// notificationPeriod += notificationDays * 24;
-// }
-// if (notificationHours != null) {
-// notificationPeriod += notificationHours;
-// }
-// }
-//
-// // Force the lifecycle scheduler to run to avoid any
-// // scheduler delay for items that should be published
-// // immediately.
-// lifecycleManager.startLifecycle(pending.getLifecycle());
-//
-// if (workflowUuid != null) {
-// final WorkflowRepository workflowRepo = cdiUtil.findBean(
-// WorkflowRepository.class);
-// final Workflow workflow = workflowRepo.findByUuid(workflowUuid)
-// .get();
-// finish(workflow, item, user);
-// }
- }
-
- }
-
- static void finish(final Workflow workflow,
- final ContentItem item,
- final User user) {
- if ((workflow != null) && (user != null)) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowRepository workflowRepo = cdiUtil.findBean(
- WorkflowRepository.class);
- final WorkflowManager workflowManager = cdiUtil.findBean(
- WorkflowManager.class);
- final TaskManager taskManager = cdiUtil.findBean(TaskManager.class);
- final CmsTaskManager cmsTaskManager = cdiUtil.findBean(
- CmsTaskManager.class);
-
- final List enabledTasks = workflowManager.findEnabledTasks(
- workflow);
- for (final Task task : enabledTasks) {
- LOGGER.debug("Task is {}.", task.getUuid());
- if (task instanceof CmsTask) {
- final CmsTask cmsTask = (CmsTask) task;
-
- if (cmsTask.getTaskType() == CmsTaskType.DEPLOY) {
- LOGGER.debug("Found DEPLOY task.");
- taskManager.finish(cmsTask);
- }
- }
- }
-
- if (CMSConfig.getConfig().isDeleteWorkflowAfterPublication()) {
- workflowRepo.delete(workflow);
- } else {
- // restart the workflow by recreating it
- // from the same workflow template
- final Workflow template = workflow.getTemplate();
- workflowRepo.delete(workflow);
- final Workflow restarted = workflowManager.createWorkflow(
- template, item);
- // Startring the workflow will probably do the wrong thing, because most of the time
- // the current user would be a publisher, not an author
- workflowRepo.save(restarted);
- }
- }
- }
-
- private class ValidationListener implements FormValidationListener {
-
- @Override
- public void validate(final FormSectionEvent event) throws
- FormProcessException {
- final PageState state = event.getPageState();
-
- final Integer startHour = (Integer) startHourField.getValue(state);
- if (startHour == null) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.start_time_incomplete",
- CmsConstants.CMS_BUNDLE));
- }
-
- final Integer startMinute;
- if (startMinuteField.getValue(state) == null) {
- startMinute = 0;
- } else {
- startMinute = (Integer) startMinuteField.getValue(state);
- }
-
- final Integer startAmpm = (Integer) startAmpmSelect.getValue(state);
-
- java.util.Date startDate = (java.util.Date) startDateField.getValue(
- state);
- if (startDate == null) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.lifecycle.start_date_invalid",
- CmsConstants.CMS_BUNDLE));
- }
-
- final java.util.Date nowDate = new java.util.Date();
-
- final Calendar cStart = Calendar.getInstance();
- final Calendar cNow = Calendar.getInstance();
- cStart.setTime(startDate);
- cNow.setTime(nowDate);
-
- if (startHour != 12) {
- cStart.set(Calendar.HOUR_OF_DAY,
- 12 * startAmpm + startHour);
- cStart.set(Calendar.HOUR, startHour);
- } else {
- if (startAmpm == 0) {
- cStart.set(Calendar.HOUR_OF_DAY, 0);
- cStart.set(Calendar.HOUR, 0);
- } else {
- cStart.set(Calendar.HOUR_OF_DAY, 12);
- cStart.set(Calendar.HOUR, 0);
- }
- }
-
- // Give the user extra 5 minutes before form complains
- // start time's in the past.
- cStart.set(Calendar.MINUTE, startMinute + 5);
- cStart.set(Calendar.AM_PM, startAmpm);
- cStart.set(Calendar.SECOND, cNow.get(Calendar.SECOND));
- cStart.set(Calendar.MILLISECOND, cNow.get(Calendar.MILLISECOND));
-
- if (cNow.after(cStart)) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.lifecycle.start_date_in_past",
- CmsConstants.CMS_BUNDLE));
- }
-
- final Integer endHour = (Integer) endHourField.getValue(state);
- final Integer endMinuteTmp = (Integer) endMinuteField
- .getValue(state);
- final java.util.Date endDate = (java.util.Date) endDateField
- .getValue(state);
-
- if (endHour == null && (endMinuteTmp != null || endDate != null)) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.lifecycle.end_time_incomplete",
- CmsConstants.CMS_BUNDLE));
- }
-
- final Integer endMinute;
- if (endMinuteTmp == null && endHour != null) {
- endMinute = 0;
- } else {
- endMinute = endMinuteTmp;
- }
-
- boolean timeBlank = (endHour == null) && (endMinute == null);
-
- final Integer endAmpm = (Integer) endAmpmSelect.getValue(state);
-
- if (endDate == null && !timeBlank) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.lifecycle.end_date_invalid",
- CmsConstants.CMS_BUNDLE));
- }
-
- if (endDate != null) {
- final Calendar cEnd = Calendar.getInstance();
- cEnd.setTime(endDate);
-
- if (endHour != 12) {
- cEnd.set(Calendar.HOUR_OF_DAY,
- 12 * endAmpm + endHour);
- cEnd.set(Calendar.HOUR, endHour);
- } else {
- if (endAmpm == 0) {
- cEnd.set(Calendar.HOUR_OF_DAY, 0);
- cEnd.set(Calendar.HOUR, 0);
- } else {
- cEnd.set(Calendar.HOUR_OF_DAY, 12);
- cEnd.set(Calendar.HOUR, 0);
- }
- }
-
- // Give the user extra 5 minutes before form complains
- // end time's in the past.
- cEnd.set(Calendar.MINUTE, endMinute + 5);
- cEnd.set(Calendar.AM_PM, endAmpm);
- cEnd.set(Calendar.SECOND, cNow.get(Calendar.SECOND));
- cEnd.set(Calendar.MILLISECOND, cNow.get(Calendar.MILLISECOND));
-
- //check if the end date is prior to the start date
- if (cStart.after(cEnd)) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.lifecycle.end_date_before_start_date",
- CmsConstants.CMS_BUNDLE));
- }
-
- final Integer notificationDays = (Integer) notificationDaysField
- .getValue(state);
- final Integer notificationHours
- = (Integer) notificationHoursField
- .getValue(state);
-
- int notificationPeriod = 0;
- if (notificationDays != null) {
- notificationPeriod += notificationDays * 24;
- }
- if (notificationHours != null) {
- notificationPeriod += notificationHours;
- }
-
- if (notificationPeriod > 0) {
- // point in time for notification == end date - notificationPeriod
- final java.util.Date notificationDate
- = computeNotificationDate(
- cEnd.getTime(),
- notificationPeriod);
- LOGGER.debug("cStart (Date): {}", cStart.getTime());
- LOGGER.debug("notificationDate: {}", notificationDate);
- // complain if date for notification is before the start date
- if (notificationDate.before(cStart.getTime())) {
- LOGGER.debug("notification date is before start date!");
-
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.item.notification_period_before_start",
- CmsConstants.CMS_BUNDLE));
- } else {
- LOGGER.debug(
- "notification date is after start date, OK");
- }
- }
- }
- }
-
- }
-
- public class TimeZonePrinter implements PrintListener {
-
- @Override
- public void prepare(final PrintEvent event) {
- final Label target = (Label) event.getTarget();
- if (CMSConfig.getConfig().isHideTimezone()) {
- target.setLabel("");
- } else {
- final PageState state = event.getPageState();
- final Calendar mStart = Calendar.getInstance();
- final java.util.Date startDate = (java.util.Date) startDateField
- .getValue(state);
-
- if (startDate != null) {
- mStart.setTime((java.util.Date) startDateField.getValue(
- state));
- }
-
- final String zone = mStart.getTimeZone().getDisplayName(true,
- TimeZone.SHORT);
-
- target.setLabel(zone);
- }
- }
-
- }
-
- /**
- * Find out at which date a notification (about an item that is about to
- * expire) should be sent, based on the endDate (== date at which the item
- * is unpublished) and the notification period.
- *
- * @param endDate the endDate of the lifecycle, i.e. the date when the
- * item is going to be unpublished
- * @param notification how many hours the users shouls be notified in
- * advance
- */
- private java.util.Date computeNotificationDate(final java.util.Date endDate,
- final int notificationPeriod) {
- if (endDate == null) {
- return null;
- }
-
- return new java.util.Date(
- endDate.getTime() - notificationPeriod * 3600000L);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModel.java
deleted file mode 100644
index e197029c4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModel.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.globalization.GlobalizedMessage;
-
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.l10n.GlobalizationHelper;
-import org.librecms.CmsConstants;
-
-import java.text.DateFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class ItemPhaseTableModel implements TableModel {
-
- private final Iterator iterator;
- private ItemPhaseTableRow currentRow;
-
- public ItemPhaseTableModel(final List rows) {
- iterator = rows.iterator();
- }
-
- @Override
- public int getColumnCount() {
- return 4;
- }
-
- @Override
- public boolean nextRow() {
-
- if (iterator.hasNext()) {
- currentRow = iterator.next();
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Object getElementAt(final int columnIndex) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- final Locale locale = globalizationHelper.getNegotiatedLocale();
- final DateFormat format;
- if (CMSConfig.getConfig().isHideTimezone()) {
- format = DateFormat.getDateTimeInstance(
- DateFormat.FULL, DateFormat.SHORT, locale);
- } else {
- format = DateFormat.getDateTimeInstance(
- DateFormat.FULL, DateFormat.FULL, locale);
- }
-
- switch (columnIndex) {
- case 0:
- return currentRow.getName();
- case 1:
- return currentRow.getDescription();
- case 2:
- if (currentRow.getStartDate() == null) {
- return "";
- } else {
- return format.format(currentRow.getStartDate());
- }
- case 3:
- if (currentRow.getEndDate() == null) {
- return new GlobalizedMessage("cms.ui.lifecycle.forever",
- CmsConstants.CMS_BUNDLE)
- .localize();
- } else {
- return currentRow.getEndDate();
- }
- default:
- throw new IllegalArgumentException("Illegal Column Index");
- }
-
- }
-
- @Override
- public Object getKeyAt(final int columnIndex) {
-
- return currentRow.getPhaseId();
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModelBuilder.java
deleted file mode 100755
index 8eafe3d04..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableModelBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.table.AbstractTableModelBuilder;
-import com.arsdigita.bebop.table.TableModel;
-
-import org.libreccm.cdi.utils.CdiUtil;
-
-import java.util.List;
-
-/**
- * @author Xixi D'Moon <xdmoon@arsdigita.com>
- * @author Michael Pih
- * @author Justin Ross <jross@redhat.com>
- * @author Jens Pelzetter
- */
-class ItemPhaseTableModelBuilder extends AbstractTableModelBuilder {
-
- private final LifecycleRequestLocal lifecycle;
-
- public ItemPhaseTableModelBuilder(final LifecycleRequestLocal lifecycle) {
- this.lifecycle = lifecycle;
- }
-
- @Override
- public final TableModel makeModel(final Table table,
- final PageState state) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ItemLifecycleAdminController controller = cdiUtil
- .findBean(ItemLifecycleAdminController.class);
-
- final List rows = controller
- .findPhasesOfLifecycle(lifecycle.getLifecycle(state));
-
- return new ItemPhaseTableModel(rows);
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableRow.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableRow.java
deleted file mode 100644
index 8a56b9700..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/ItemPhaseTableRow.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.arsdigita.cms.ui.lifecycle;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class ItemPhaseTableRow implements Serializable {
-
- private static final long serialVersionUID = -8947185134493863779L;
-
- private long phaseId;
- private String name;
- private String description;
- private Date startDate;
- private Date endDate;
-
- public long getPhaseId() {
- return phaseId;
- }
-
- public void setPhaseId(final long phaseId) {
- this.phaseId = phaseId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(final String description) {
- this.description = description;
- }
-
- public Date getStartDate() {
- if (startDate == null) {
- return null;
- } else {
- return new Date(startDate.getTime());
- }
- }
-
- public void setStartDate(final Date startDate) {
- if (startDate == null) {
- this.startDate = startDate;
- } else {
- this.startDate = new Date(startDate.getTime());
- }
- }
-
- public Date getEndDate() {
- if (endDate == null) {
- return null;
- } else {
- return new Date(endDate.getTime());
- }
- }
-
- public void setEndDate(final Date endDate) {
- if (endDate == null) {
- this.endDate = endDate;
- } else {
- this.endDate = new Date(endDate.getTime());
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAddForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAddForm.java
deleted file mode 100755
index 85dd00c5e..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAddForm.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.lifecycle.LifecycleDefinition;
-import org.libreccm.cdi.utils.CdiUtil;
-
-/**
- * @author Michael Pih
- * @author Jack Chung
- * @author Xixi D'Moon
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-class LifecycleAddForm extends BaseLifecycleForm {
-
- private final SingleSelectionModel selectedLifecycle;
-
- LifecycleAddForm(final SingleSelectionModel selectedLifecycle) {
- super("LifecycleDefinition", gz("cms.ui.lifecycle.add"));
-
- this.selectedLifecycle = selectedLifecycle;
-
- getLifecycleName().addValidationListener(
- new LifecycleNameUniqueListener(this));
-
- addProcessListener(new ProcessListener());
- }
-
- private class ProcessListener implements FormProcessListener {
-
- @Override
- public final void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final LifecycleAdminPaneController controller = cdiUtil
- .findBean(LifecycleAdminPaneController.class);
-
- final LifecycleDefinition definition = controller
- .createLifecycleDefinition(
- CMS.getContext().getContentSection(),
- (String) getLifecycleName().getValue(state),
- (String) getLifecycleDescription().getValue(state));
-
- selectedLifecycle.setSelectedKey(state,
- definition.getDefinitionId());
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminContainer.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminContainer.java
deleted file mode 100755
index 151ad4491..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminContainer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.PageState;
-
-import org.libreccm.security.Party;
-
-import com.arsdigita.toolbox.ui.SecurityContainer;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-/**
- * Security container that wraps the canAdministerLifecycles access check around
- * its components.
- *
- * @author Michael Pih
- * @author Jens Pelzetter
- */
-public class LifecycleAdminContainer extends SecurityContainer {
-
- /**
- * This default constructor should be followed by calls to add.
- */
- public LifecycleAdminContainer() {
- super();
- }
-
- /**
- * Create a SecurityContainer around a child component.
- *
- * @param component The child component
- */
- public LifecycleAdminContainer(final Component component) {
- super(component);
- }
-
- /**
- * Returns true if the current user can access the child component.
- *
- * @param state The page state
- *
- * @return true if the access checks pass, false otherwise
- */
- @Override
- protected boolean canAccess(final Party party, final PageState state) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- return permissionChecker.isPermitted(
- AdminPrivileges.ADMINISTER_LIFECYLES);
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPane.java
deleted file mode 100755
index 1cb636a61..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPane.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.CMS;
-
-import org.librecms.contentsection.ContentSection;
-import org.librecms.lifecycle.LifecycleDefinition;
-
-import com.arsdigita.cms.ui.BaseAdminPane;
-import com.arsdigita.cms.ui.BaseDeleteForm;
-import com.arsdigita.cms.ui.FormSecurityListener;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-import org.librecms.lifecycle.LifecycleDefinitionRepository;
-
-/**
- * This class contains the split pane for the lifecycle administration
- * interface.
- *
- *
- * @author Michael Pih
- * @author Jack Chung
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-public class LifecycleAdminPane extends BaseAdminPane {
-
- private final SingleSelectionModel selectionModel;
- private final LifecycleDefinitionRequestLocal selectionLifecycleDefinition;
-
- public LifecycleAdminPane() {
- super(new Label(gz("cms.ui.lifecycles")),
- new LifecycleListModelBuilder());
-
- selectionModel = getSelectionModel();
- selectionLifecycleDefinition = new SelectionRequestLocal();
-
- // XXX secvis
- //add(new LifecycleAdminContainer(m_addLink));
- setAdd(gz("cms.ui.lifecycle.add"),
- new LifecycleAddForm(selectionModel));
- setEdit(gz("cms.ui.lifecycle.edit"),
- new LifecycleEditForm(selectionLifecycleDefinition));
- setDelete(gz("cms.ui.lifecycle.delete"), new DeleteForm());
-
- setIntroPane(new Label(gz("cms.ui.lifecycle.intro")));
- setItemPane(new LifecycleItemPane(selectionLifecycleDefinition,
- getEditLink(),
- getDeleteLink()));
-
- addAction(new LifecycleAdminContainer(getAddLink()));
- }
-
- private class SelectionRequestLocal
- extends LifecycleDefinitionRequestLocal {
-
- @Override
- protected final Object initialValue(final PageState state) {
- final String id = selectionModel.getSelectedKey(state).toString();
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final LifecycleDefinitionRepository lifecycleDefRepo = cdiUtil
- .findBean(LifecycleDefinitionRepository.class);
-
- return lifecycleDefRepo.findById(Long.parseLong(id));
- }
-
- }
-
- private final class DeleteForm extends BaseDeleteForm {
-
- DeleteForm() {
- super(new Label(gz("cms.ui.lifecycle.delete_prompt")));
-
- addSubmissionListener(new FormSecurityListener(
- AdminPrivileges.ADMINISTER_LIFECYLES));
- }
-
- @Override
- public final void process(final FormSectionEvent event)
- throws FormProcessException {
-
- final PageState state = event.getPageState();
- final ContentSection section = CMS.getContext().getContentSection();
- final LifecycleDefinition definition = selectionLifecycleDefinition
- .getLifecycleDefinition(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final LifecycleAdminPaneController controller = cdiUtil
- .findBean(LifecycleAdminPaneController.class);
- controller.deleteLifecycleDefinition(definition, section);
-
- selectionModel.clearSelection(state);
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPaneController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPaneController.java
deleted file mode 100644
index 6a321dd75..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/lifecycle/LifecycleAdminPaneController.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.arsdigita.cms.ui.lifecycle;
-
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.toolbox.ui.Property;
-
-import org.libreccm.configuration.ConfigurationManager;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-import org.librecms.contentsection.ContentSectionRepository;
-import org.librecms.lifecycle.LifecycleDefinition;
-import org.librecms.lifecycle.LifecycleDefinitionRepository;
-import org.librecms.lifecycle.PhaseDefinition;
-import org.librecms.lifecycle.PhaseDefinititionRepository;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-class LifecycleAdminPaneController {
-
- @Inject
- private ConfigurationManager confManager;
-
- @Inject
- private ContentSectionRepository sectionRepo;
-
- @Inject
- private ContentSectionManager sectionManager;
-
- @Inject
- private LifecycleDefinitionRepository lifecycleDefRepo;
-
- @Inject
- private PhaseDefinititionRepository phaseDefRepo;
-
- @Transactional(Transactional.TxType.REQUIRED)
- public List getLifecyclesForContentSection(
- final ContentSection section) {
-
- final ContentSection contentSection = sectionRepo
- .findById(section.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String.format(
- "No ContentSection with ID %d in the database. "
- + "Where did that ID come from?",
- section.getObjectId())));
-
- return new ArrayList<>(contentSection.getLifecycleDefinitions());
- }
-
- @Transactional
- public List