depIdList = blockedTasks
- .stream()
- .map(TaskDependency::getBlockedTask)
- .map(blockedTask -> Long.toString(blockedTask.getTaskId()))
- .collect(Collectors.toList());
-
- getDependenciesOptionGroup().setValue(state, depIdList.toArray());
- }
-
- }
-
- private class ProcessListener implements FormProcessListener {
-
- @Override
- public final void process(final FormSectionEvent event)
- throws FormProcessException {
- final PageState state = event.getPageState();
- final CmsTask task = selectedTask.getTask(state);
-
- final String name = (String) getNameTextField().getValue(state);
- final String desc = (String) getDescriptionTextArea()
- .getValue(state);
- final CmsTaskType taskType = CmsTaskType
- .valueOf((String) getTypeOptionGroup().getValue(state));
- final String[] deps = (String[]) getDependenciesOptionGroup()
- .getValue(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowAdminPaneController controller = cdiUtil
- .findBean(WorkflowAdminPaneController.class);
-
- controller.updateTask(task, name, desc, taskType, deps);
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishForm.java
deleted file mode 100755
index 3ef87d1bb..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishForm.java
+++ /dev/null
@@ -1,263 +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.workflow;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.PageState;
-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.form.Option;
-import com.arsdigita.bebop.form.RadioGroup;
-import com.arsdigita.bebop.parameters.BooleanParameter;
-
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.util.UncheckedWrapperException;
-
-import org.librecms.workflow.CmsTask;
-
-import com.arsdigita.web.RedirectSignal;
-import com.arsdigita.web.URL;
-
-import org.libreccm.workflow.Task;
-import org.apache.logging.log4j.Logger;
-
-import java.util.Optional;
-
-import org.apache.logging.log4j.LogManager;
-import org.librecms.CMSConfig;
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.configuration.ConfigurationManager;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.workflow.AssignableTask;
-import org.libreccm.workflow.TaskDependency;
-import org.libreccm.workflow.Workflow;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.workflow.CmsTaskType;
-
-import java.util.List;
-
-/**
- *
- * A form that prompts the user to comment on and approve tasks and then
- * finishes the task if it was approved.
- *
- * @author Justin Ross <jross@redhat.com>
- * @author Jens Pelzetter
- */
-public final class TaskFinishForm extends CommentAddForm {
-
- private static final Logger LOGGER = LogManager.getLogger(
- TaskFinishForm.class);
- private final TaskRequestLocal m_task;
- private final Label m_approvePrompt;
- private final RadioGroup m_approve;
-
- public TaskFinishForm(final TaskRequestLocal task) {
- super(task);
-
- m_task = task;
-
- m_approve = new RadioGroup(new BooleanParameter("approve"));
- m_approve.addOption(new Option(
- "true",
- new Label(gz("cms.ui.workflow.task.approve"))));
- m_approve.addOption(new Option(
- "false",
- new Label(gz("cms.ui.workflow.task.reject"))));
-
- m_approvePrompt = new Label(gz("cms.ui.workflow.task.approve_prompt"));
-
- addComponent(m_approvePrompt);
- addComponent(m_approve);
-
- addInitListener(new InitListener());
- addValidationListener(new ValidationListener());
- addProcessListener(new ProcessListener());
- }
-
- private class InitListener implements FormInitListener {
-
- @Override
- public final void init(final FormSectionEvent e) {
- LOGGER.debug("Initializing task finish");
-
- final PageState state = e.getPageState();
-
- if (isVisible(state)) {
- final CmsTask task = m_task.getTask(state);
-
- if (requiresApproval(task)) {
- m_approvePrompt.setVisible(state, true);
- m_approve.setVisible(state, true);
- } else {
- m_approvePrompt.setVisible(state, false);
- m_approve.setVisible(state, false);
- }
- }
- }
-
- }
-
- private class ValidationListener implements FormValidationListener {
-
- @Override
- public final void validate(final FormSectionEvent e)
- throws FormProcessException {
- LOGGER.debug("Validating task finish");
-
- final PageState state = e.getPageState();
- final CmsTask task = m_task.getTask(state);
-
- if (requiresApproval(task) && m_approve.getValue(state) == null) {
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.workflow.task.approval_or_reject_required",
- CmsConstants.CMS_BUNDLE));
- }
- }
-
- }
-
- private class ProcessListener implements FormProcessListener {
-
- @Override
- public final void process(final FormSectionEvent event)
- throws FormProcessException {
- LOGGER.debug("Processing task finish");
-
- final PageState state = event.getPageState();
- final CmsTask task = m_task.getTask(state);
- boolean finishedTask = false;
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
- final ContentItemRepository itemRepo = cdiUtil.findBean(
- ContentItemRepository.class);
- final Optional item = itemRepo.findItemWithWorkflow(
- task.getWorkflow());
-
- if (!item.isPresent()) {
- throw new UncheckedWrapperException(
- "Workflow not assigned to an item");
- }
-
- permissionChecker.checkPermission(task.getTaskType().getPrivilege(),
- item.get());
-
- final TaskFinishFormController controller = cdiUtil
- .findBean(TaskFinishFormController.class);
- final ConfigurationManager confManager = cdiUtil.findBean(
- ConfigurationManager.class);
- final KernelConfig kernelConfig = confManager.findConfiguration(
- KernelConfig.class);
-
- if (requiresApproval(task)) {
- LOGGER.debug("The task requires approval; checking to see "
- + "if it's approved");
-
- // XXX I think the fact that this returns a Boolean is
- // the effect of broken parameter marshalling in
- // Bebop.
- final Boolean isApproved = (Boolean) m_approve.getValue(state);
-
- if (isApproved.equals(Boolean.TRUE)) {
- LOGGER.debug("The task is approved; finishing the task");
-
- controller.finish(task);
- finishedTask = true;
- } else {
- LOGGER.debug("The task is rejected; reenabling dependent "
- + "tasks");
-
- // Reenable the previous tasks.
- for (final TaskDependency blockedTask : task
- .getBlockedTasks()) {
- LOGGER.debug("Reenabling task {}",
- blockedTask
- .getBlockedTask()
- .getLabel()
- .getValue(kernelConfig
- .getDefaultLocale()));
-
- controller.enable(blockedTask.getBlockedTask());
- }
- }
- } else {
- LOGGER.debug("The task does not require approval; finishing it");
-
- controller.finish(task);
- finishedTask = true;
- }
- if (finishedTask) {
- final Workflow workflow = task.getWorkflow();
- final List tasks = controller.findEnabledTasks(
- workflow);
- for (final AssignableTask currentTask : tasks) {
- if (!(currentTask instanceof CmsTask)) {
- continue;
- }
-
- final CmsTask currentCmsTask = (CmsTask) currentTask;
- final String privilege = currentCmsTask.getTaskType()
- .getPrivilege();
- if (permissionChecker.isPermitted(privilege,
- workflow.getObject())) {
- //Lock task for current user
- controller.lock(currentCmsTask);
-
- if (CmsTaskType.DEPLOY == currentCmsTask.getTaskType()) {
-
- } else {
- throw new RedirectSignal(
- URL.there(
- state.getRequest(),
- controller
- .getContentItemPublishUrl(item.get())),
- true);
- }
-
- }
- }
-
- // redirect to /content-center if streamlined creation mode is active.
- final CMSConfig cmsConfig = confManager.findConfiguration(
- CMSConfig.class);
- if (cmsConfig.isUseStreamlinedCreation()) {
- throw new RedirectSignal(
- URL.there(state.getRequest(),
- CmsConstants.CONTENT_CENTER_URL),
- true);
- }
-
- }
- }
-
- }
-
- private static boolean requiresApproval(final CmsTask task) {
- return task.getTaskType() != CmsTaskType.AUTHOR;
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishFormController.java
deleted file mode 100644
index 172cd24d1..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskFinishFormController.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2016 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.workflow;
-
-import com.arsdigita.cms.ui.ContentItemPage;
-
-import org.libreccm.security.Role;
-import org.libreccm.security.Shiro;
-import org.libreccm.security.User;
-import org.libreccm.workflow.AssignableTask;
-import org.libreccm.workflow.AssignableTaskManager;
-import org.libreccm.workflow.Task;
-import org.libreccm.workflow.TaskManager;
-import org.libreccm.workflow.TaskRepository;
-import org.libreccm.workflow.Workflow;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentItemRepository;
-import org.librecms.workflow.CmsTask;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-public class TaskFinishFormController {
-
- @Inject
- private ContentItemRepository itemRepo;
-
- @Inject
- private TaskRepository taskRepo;
-
- @Inject
- private TaskManager taskManager;
-
- @Inject
- private AssignableTaskManager assignableTaskManager;
-
- @Inject
- private Shiro shiro;
-
- @Transactional(Transactional.TxType.REQUIRED)
- public List findEnabledTasks(final Workflow workflow) {
- final User user = shiro.getUser().get();
- final List roles = user.getRoleMemberships().stream()
- .map(membership -> membership.getRole())
- .collect(Collectors.toList());
-
- return assignableTaskManager.findAssignedTasks(workflow, roles);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void addComment(final CmsTask task, final String comment) {
-
- final Task theTask = taskRepo
- .findById(task.getTaskId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No Task with ID %d in the database.",
- task.getTaskId())));
-
- taskManager.addComment(theTask, comment);
- }
-
- @Transactional
- public void lock(final AssignableTask task) {
-
- final AssignableTask theTask = (AssignableTask) taskRepo
- .findById(task.getTaskId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No Task with ID %d in the database.",
- task.getTaskId())));
-
- assignableTaskManager.unlockTask(theTask);
- assignableTaskManager.lockTask(theTask);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void enable(final Task task) {
-
- final Task theTask = taskRepo
- .findById(task.getTaskId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No Task with ID %d in the database.",
- task.getTaskId())));
-
- taskManager.enable(theTask);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public void finish(final CmsTask task) {
-
- final Task theTask = taskRepo
- .findById(task.getTaskId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No Task with ID %d in the database.",
- task.getTaskId())));
-
- taskManager.finish(theTask);
- }
-
- @Transactional(Transactional.TxType.REQUIRED)
- public String getContentItemPublishUrl(final ContentItem item) {
-
- final ContentItem contentItem = itemRepo
- .findById(item.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String
- .format("No ContentItem with ID %d in the database.",
- item.getObjectId())));
-
- return ContentItemPage.getItemURL(contentItem,
- ContentItemPage.PUBLISHING_TAB);
-
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskItemPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskItemPane.java
deleted file mode 100755
index b246082ec..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskItemPane.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
- *
- * The contents of this file are subject to the CCM Public
- * License (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the
- * License at http://www.redhat.com/licenses/ccmpl.html.
- *
- * Software distributed under the License is distributed on an
- * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
- * or implied. See the License for the specific language
- * governing rights and limitations under the License.
- *
- */
-package com.arsdigita.cms.ui.workflow;
-
-import com.arsdigita.bebop.ActionLink;
-import com.arsdigita.bebop.Component;
-import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.TableActionAdapter;
-import com.arsdigita.bebop.event.TableActionEvent;
-import com.arsdigita.bebop.table.DefaultTableCellRenderer;
-import com.arsdigita.bebop.table.TableColumn;
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.bebop.table.TableModelBuilder;
-import com.arsdigita.cms.ui.BaseItemPane;
-import com.arsdigita.cms.ui.VisibilityComponent;
-import com.arsdigita.kernel.KernelConfig;
-
-import org.librecms.workflow.CmsTask;
-import org.libreccm.security.User;
-
-import com.arsdigita.toolbox.ui.ActionGroup;
-import com.arsdigita.toolbox.ui.Property;
-import com.arsdigita.toolbox.ui.PropertyList;
-import com.arsdigita.toolbox.ui.Section;
-import com.arsdigita.util.LockableImpl;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.security.Role;
-import org.libreccm.security.RoleRepository;
-import org.libreccm.security.Shiro;
-import org.libreccm.workflow.Task;
-import org.libreccm.workflow.AssignableTask;
-import org.libreccm.workflow.AssignableTaskManager;
-import org.libreccm.workflow.TaskDependency;
-import org.librecms.contentsection.privileges.AdminPrivileges;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.stream.Collectors;
-
-/**
- * @author Justin Ross
- * @author Jens Pelzetter
- */
-final class TaskItemPane extends BaseItemPane {
-
- private final WorkflowRequestLocal m_workflow;
- private final TaskRequestLocal m_task;
-
- private final SimpleContainer m_detailPane;
-
- TaskItemPane(final WorkflowRequestLocal workflow,
- final TaskRequestLocal task,
- final ActionLink finishLink,
- final ActionLink editLink,
- final ActionLink deleteLink,
- final ActionLink backLink) {
- m_workflow = workflow;
- m_task = task;
-
- m_detailPane = new SimpleContainer();
- m_detailPane.add(new Navigation(backLink));
- m_detailPane.add(new SummarySection(finishLink, editLink, deleteLink));
-
- // Users
- final ActionLink userAddLink = new ActionLink(new Label(gz(
- "cms.ui.workflow.task.user.add")));
-
- final TaskAddUser userAddPane = new TaskAddUser(m_task);
-
- final Form search = userAddPane.getSearchForm();
- final Form add = userAddPane.getAddForm().getForm();
-
- // Roles
- final ActionLink roleAddLink = new ActionLink(new Label(gz(
- "cms.ui.workflow.task.role.add")));
-
- final TaskAddRole roleAddForm = new TaskAddRole(m_task);
-
- m_detailPane.add(new RoleSection(roleAddLink));
-
- add(m_detailPane);
- setDefault(m_detailPane);
- add(userAddPane);
- add(roleAddForm);
-
- userAddLink.addActionListener(new NavigationListener(userAddPane));
- search.addSubmissionListener(new CancelListener(search));
- add.addSubmissionListener(new CancelListener(add));
- add.addProcessListener(new FormNavigationListener(m_detailPane));
-
- connect(roleAddLink, roleAddForm);
- resume(roleAddForm, m_detailPane);
- }
-
- private boolean hasAdmin(final PageState state) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- return permissionChecker.isPermitted(AdminPrivileges.ADMINISTER_WORKFLOWS);
- }
-
- private class AdminVisible extends VisibilityComponent {
-
- public AdminVisible(final Component child) {
- super(child, AdminPrivileges.ADMINISTER_WORKFLOWS);
- }
-
- }
-
- private class AssigneeVisible extends AdminVisible {
-
- private final Component m_child;
- private final Assigned m_assigned;
-
- public AssigneeVisible(final Component child) {
- super(child);
-
- m_child = child;
- m_assigned = new Assigned();
- }
-
- @Override
- public final boolean isVisible(final PageState state) {
- if (m_child.isVisible(state)) {
- return m_assigned.isAssigned(state) || hasPermission(state);
- } else {
- return false;
- }
- }
-
- private class Assigned extends RequestLocal {
-
- @Override
- protected final Object initialValue(final PageState state) {
- if (assigned(state)) {
- return Boolean.TRUE;
- } else {
- return Boolean.FALSE;
- }
- }
-
- private boolean assigned(final PageState state) {
- final CmsTask task = m_task.getTask(state);
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssignableTaskManager taskManager = cdiUtil.findBean(
- AssignableTaskManager.class);
- final Shiro shiro = cdiUtil.findBean(Shiro.class);
-
- final User user = shiro.getUser().get();
-
- final List tasks = taskManager.lockedBy(user);
-
- return tasks.contains(task);
- }
-
- final boolean isAssigned(final PageState state) {
- return ((Boolean) get(state));
- }
-
- }
-
- }
-
- private class VisibilityListener implements ActionListener {
-
- private final TableColumn m_column;
-
- VisibilityListener(final TableColumn column) {
- m_column = column;
- }
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
-
- if (state.isVisibleOnPage(TaskItemPane.this) && !hasAdmin(state)) {
- m_column.setVisible(state, false);
- }
- }
-
- }
-
- private class Navigation extends ActionGroup {
-
- Navigation(final ActionLink backLink) {
- addAction(backLink, ActionGroup.RETURN);
- }
-
- }
-
- private class SummarySection extends Section {
-
- SummarySection(final ActionLink finishLink,
- final ActionLink editLink,
- final ActionLink deleteLink) {
- setHeading(new Label(gz("cms.ui.workflow.task.details")));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(new Properties());
- group.addAction(new AssigneeVisible(new LockLink()));
- group.addAction(new AssigneeVisible(new UnlockLink()));
- group.addAction(new AssigneeVisible(finishLink));
- group.addAction(new AdminVisible(editLink), ActionGroup.EDIT);
- group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE);
- }
-
- private class LockLink extends ActionLink {
-
- LockLink() {
- super(new Label(gz("cms.ui.workflow.task.lock")));
-
- addActionListener(new Listener());
- }
-
- @Override
- public final boolean isVisible(final PageState state) {
-
- final CmsTask task = m_task.getTask(state);
-
- return task.isActive() && !task.isLocked();
- }
-
- private class Listener implements ActionListener {
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
-
- if (hasAdmin(state)) {
- final CmsTask task = m_task.getTask(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssignableTaskManager taskManager = cdiUtil
- .findBean(AssignableTaskManager.class);
- taskManager.lockTask(task);
- }
- }
-
- }
-
- }
-
- private class UnlockLink extends ActionLink {
-
- UnlockLink() {
- super(new Label(gz("cms.ui.workflow.task.unlock")));
-
- addActionListener(new Listener());
- }
-
- @Override
- public final boolean isVisible(final PageState state) {
- final CmsTask task = m_task.getTask(state);
-
- return task.isActive() && task.isLocked();
- }
-
- private class Listener implements ActionListener {
-
- @Override
- public final void actionPerformed(final ActionEvent event) {
- final PageState state = event.getPageState();
-
- if (hasAdmin(state)) {
- final CmsTask task = m_task.getTask(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final AssignableTaskManager taskManager = cdiUtil
- .findBean(AssignableTaskManager.class);
- taskManager.unlockTask(task);
- }
- }
-
- }
-
- }
-
- private class Properties extends PropertyList {
-
- @Override
- protected final List properties(final PageState state) {
- @SuppressWarnings("unchecked")
- final List props = super.properties(state);
- final CmsTask task = m_task.getTask(state);
-
- final KernelConfig kernelConfig = KernelConfig.getConfig();
- final Locale defaultLocale = kernelConfig.getDefaultLocale();
-
- props.add(new Property(gz("cms.ui.workflow.task.name"),
- task.getLabel().getValue(defaultLocale)));
- props.add(new Property(gz("cms.ui.workflow.task.description"),
- task.getDescription().getValue(
- defaultLocale)));
- props.add(new Property(gz("cms.ui.workflow.task.dependencies"),
- deps(task)));
- if (task.getTaskState() == null) {
- props.add(new Property(gz("cms.ui.workflow.task.state"),
- gz("cms.ui.workflow.task.state.none")));
- } else {
- props.add(new Property(gz("cms.ui.workflow.task.state"),
- task.getTaskState().toString()));
- }
- if (task.isLocked()) {
- props.add(new Property(gz("cms.ui.workflow.task.locked"),
- gz("cms.ui.yes")));
- } else {
- props.add(new Property(gz("cms.ui.workflow.task.locked"),
- gz("cms.ui.no")));
- }
-
- return props;
- }
-
- private String deps(final CmsTask task) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowAdminPaneController controller = cdiUtil
- .findBean(WorkflowAdminPaneController.class);
-
- final List blockedTasks = controller
- .getBlockedTasks(task);
- final KernelConfig kernelConfig = KernelConfig.getConfig();
- final Locale defaultLocale = kernelConfig.getDefaultLocale();
-
- return blockedTasks
- .stream()
- .map(TaskDependency::getBlockedTask)
- .map(blockedTask -> blockedTask.getLabel().getValue(
- defaultLocale))
- .collect(Collectors.joining(", "));
- }
-
- }
-
- }
-
- private class RoleSection extends Section {
-
- public RoleSection(final ActionLink roleAddLink) {
- setHeading(new Label(gz("cms.ui.workflow.task.roles")));
-
- final ActionGroup group = new ActionGroup();
- setBody(group);
-
- group.setSubject(new RoleTable());
- group.addAction(new AdminVisible(roleAddLink), ActionGroup.ADD);
- }
-
- }
-
- private class RoleTable extends Table {
-
- public RoleTable() {
- super(new RoleTableModelBuilder(m_task),
- new String[]{
- lz("cms.ui.workflow.task.role.name"),
- lz("cms.ui.workflow.task.role.delete")
- });
-
- setEmptyView(new Label(gz("cms.ui.workflow.task.role.none")));
-
- getColumn(1).setCellRenderer(new DefaultTableCellRenderer(true));
-
- addTableActionListener(new TableActionAdapter() {
-
- @Override
- public final void cellSelected(final TableActionEvent event) {
- final PageState state = event.getPageState();
- final int column = event.getColumn();
-
- if (column == 1) {
- if (hasAdmin(state)) {
- final CmsTask task = m_task.getTask(state);
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowAdminPaneController controller =
- cdiUtil.findBean(WorkflowAdminPaneController.class);
- controller.removeAssignment(task,
- (String) event.getRowKey());
-
- }
- }
- }
-
- });
- }
-
- @Override
- public final void register(final Page page) {
- super.register(page);
-
- page.addActionListener(new VisibilityListener(getColumn(1)));
- }
-
- }
-
- private static class RoleTableModelBuilder extends LockableImpl
- implements TableModelBuilder {
-
- private final TaskRequestLocal m_task;
-
- public RoleTableModelBuilder(final TaskRequestLocal task) {
- m_task = task;
- }
-
- @Override
- public final TableModel makeModel(final Table table,
- final PageState state) {
- return new Model(m_task.getTask(state));
- }
-
- private class Model implements TableModel {
-
- private final List roles;
- private int index = -1;
-
- private Model(final CmsTask task) {
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowAdminPaneController controller = cdiUtil.findBean(
- WorkflowAdminPaneController.class);
-
- roles = controller.findAssignees(task);
- }
-
- @Override
- public final int getColumnCount() {
- return 2;
- }
-
- @Override
- public final boolean nextRow() {
- index++;
- return index < roles.size();
- }
-
- @Override
- public final Object getKeyAt(final int column) {
- return Long.toString(roles.get(index).getRoleId());
- }
-
- @Override
- public final Object getElementAt(final int column) {
- switch (column) {
- case 0:
- return roles.get(index).getName();
- case 1:
- return lz("cms.ui.workflow.task.role.delete");
- default:
- throw new IllegalStateException();
- }
- }
-
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskRequestLocal.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskRequestLocal.java
deleted file mode 100755
index 84e285504..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskRequestLocal.java
+++ /dev/null
@@ -1,35 +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.workflow;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.RequestLocal;
-import org.librecms.workflow.CmsTask;
-import com.arsdigita.util.Assert;
-
-public abstract class TaskRequestLocal extends RequestLocal {
-
- public final CmsTask getTask(final PageState state) {
- final CmsTask task = (CmsTask) get(state);
-
- Assert.exists(task, "CmsTask task");
-
- return task;
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelBuilder.java
deleted file mode 100755
index a902c2ad5..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelBuilder.java
+++ /dev/null
@@ -1,161 +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.workflow;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.Table;
-import com.arsdigita.bebop.table.AbstractTableModelBuilder;
-import com.arsdigita.bebop.table.TableModel;
-import com.arsdigita.kernel.KernelConfig;
-
-import org.apache.logging.log4j.LogManager;
-import org.libreccm.workflow.Task;
-import org.libreccm.workflow.Workflow;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.logging.log4j.Logger;
-import org.libreccm.cdi.utils.CdiUtil;
-
-import java.util.Locale;
-
-class TaskTableModelBuilder extends AbstractTableModelBuilder {
-
- private static final Logger LOGGER = LogManager.getLogger(
- TaskTableModelBuilder.class);
-
- private final WorkflowRequestLocal workflow;
-
- TaskTableModelBuilder(final WorkflowRequestLocal workflow) {
- this.workflow = workflow;
- }
-
- @Override
- public final TableModel makeModel(final Table table,
- final PageState state) {
- LOGGER.debug("Creating a new table model for the current request");
-
- return new Model(workflow.getWorkflow(state));
- }
-
- private static class Model implements TableModel {
-
- private Task currentTask;
- private Iterator tasksIterator;
- private Map dependencies;
-
- private Model(final Workflow workflow) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final WorkflowAdminPaneController controller = cdiUtil.findBean(
- WorkflowAdminPaneController.class);
-
- final TaskTableModelData data = controller
- .getTaskTableModelData(workflow);
- tasksIterator = data.getTasks();
- dependencies = data.getDependencies();
-
-
-// final Iterator tasksIter = controller
-// .getTasksForWorkflow(workflow)
-// .iterator();
-// GraphSet graphSet = new GraphSet();
-//
-// while (tasksIter.hasNext()) {
-// Task task = tasksIter.next();
-// final Iterator deps = task.getDependsOn().iterator();
-// final StringBuffer buffer = new StringBuffer();
-// while (deps.hasNext()) {
-// Task dep = deps.next();
-// graphSet.addEdge(task, dep, null);
-// buffer
-// .append(dep.getLabel())
-// .append(", ");
-// }
-//
-// final int len = buffer.length();
-// if (len >= 2) {
-// buffer.setLength(len - 2);
-// } else {
-// graphSet.addNode(task);
-// }
-// m_dependencies.put(task, buffer.toString());
-// }
-//
-// List tasks = new ArrayList();
-// outer:
-// while (graphSet.nodeCount() > 0) {
-// List list = Graphs.getSinkNodes(graphSet);
-// for (Iterator it = list.iterator(); it.hasNext();) {
-// Task t = (Task) it.next();
-// tasks.add(t);
-// graphSet.removeNode(t);
-// continue outer;
-// }
-// // break loop if no nodes removed
-// LOGGER.error("found possible loop in tasks for " + workflow);
-// break;
-// }
-//
-// m_tasks = tasks.iterator();
- }
-
- @Override
- public final int getColumnCount() {
- return 4;
- }
-
- @Override
- public final boolean nextRow() {
- if (tasksIterator.hasNext()) {
- currentTask = tasksIterator.next();
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public final Object getKeyAt(final int column) {
- return currentTask.getTaskId();
- }
-
- @Override
- public final Object getElementAt(final int column) {
- final Locale defaultLocale = KernelConfig.getConfig().getDefaultLocale();
-
- switch (column) {
- case 0:
- return currentTask.getLabel().getValue(defaultLocale);
- case 1:
- return currentTask.getDescription().getValue(defaultLocale);
- case 2:
- return dependencies.get(currentTask);
- case 3:
- return "";
-// return m_task.getStateString();
- default:
- throw new IllegalStateException();
- }
- }
-
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelData.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelData.java
deleted file mode 100644
index 47cc4bd29..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/TaskTableModelData.java
+++ /dev/null
@@ -1,51 +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.workflow;
-
-import org.libreccm.workflow.Task;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- *
- * @author Jens Pelzetter
- */
-class TaskTableModelData {
-
- private final Iterator tasks;
- private final Map dependencies;
-
- protected TaskTableModelData(final Iterator tasks,
- final Map dependencies) {
- this.tasks = tasks;
- this.dependencies = dependencies;
- }
-
- public Iterator getTasks() {
- return tasks;
- }
-
- public Map getDependencies() {
- return dependencies;
- }
-
-
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/WorkflowAdminPaneController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/WorkflowAdminPaneController.java
deleted file mode 100644
index fad27ad70..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/WorkflowAdminPaneController.java
+++ /dev/null
@@ -1,486 +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.workflow;
-
-import com.arsdigita.globalization.GlobalizedMessage;
-import com.arsdigita.kernel.KernelConfig;
-import com.arsdigita.toolbox.ui.Property;
-import com.arsdigita.util.GraphSet;
-import com.arsdigita.util.Graphs;
-import com.arsdigita.util.UncheckedWrapperException;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.libreccm.configuration.ConfigurationManager;
-import org.libreccm.security.Role;
-import org.libreccm.security.RoleRepository;
-import org.libreccm.workflow.AssignableTaskManager;
-import org.libreccm.workflow.CircularTaskDependencyException;
-import org.libreccm.workflow.Task;
-import org.libreccm.workflow.TaskDependency;
-import org.libreccm.workflow.TaskManager;
-import org.libreccm.workflow.TaskRepository;
-import org.libreccm.workflow.Workflow;
-import org.libreccm.workflow.WorkflowRepository;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-import org.librecms.contentsection.ContentSectionRepository;
-import org.librecms.workflow.CmsTask;
-import org.librecms.workflow.CmsTaskType;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.transaction.Transactional;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@RequestScoped
-public class WorkflowAdminPaneController {
-
- private static final Logger LOGGER = LogManager
- .getLogger(WorkflowAdminPaneController.class);
-
- @Inject
- private ConfigurationManager confManager;
-
- @Inject
- private ContentSectionRepository sectionRepo;
-
- @Inject
- private ContentSectionManager sectionManager;
-
- @Inject
- private WorkflowRepository workflowRepo;
-
- @Inject
- private TaskRepository taskRepo;
-
- @Inject
- private TaskManager taskManager;
-
- @Inject
- private AssignableTaskManager assignableTaskManager;
-
- @Inject
- private RoleRepository roleRepo;
-
- @Transactional(Transactional.TxType.REQUIRED)
- public List retrieveWorkflows(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.getWorkflowTemplates());
- }
-
- @Transactional
- public List