TaskFinishForm

* Nach dem Absachließen eines Workflow-Schrittes wird nur dann wieder in das ContentCenter gewechselt, wenn der User keine Berechtigung für den nächsten Schritt hat.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2298 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2013-08-07 07:20:05 +00:00
parent 32504b4865
commit 0e89aeca3f
1 changed files with 37 additions and 36 deletions

View File

@ -37,6 +37,7 @@ import com.arsdigita.cms.workflow.CMSTask;
import com.arsdigita.cms.workflow.CMSTaskType; import com.arsdigita.cms.workflow.CMSTaskType;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Party; import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.User;
import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionDescriptor;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.web.RedirectSignal; import com.arsdigita.web.RedirectSignal;
@ -50,17 +51,15 @@ import org.apache.log4j.Logger;
import java.util.Iterator; import java.util.Iterator;
/** /**
* <p>A form that prompts the user to comment on and approve tasks and * <p>A form that prompts the user to comment on and approve tasks and then
* then finishes the task if it was approved.</p> * finishes the task if it was approved.</p>
* *
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: TaskFinishForm.java 1563 2007-04-18 15:58:17Z apevec $ * @version $Id: TaskFinishForm.java 1563 2007-04-18 15:58:17Z apevec $
*/ */
public final class TaskFinishForm extends CommentAddForm { public final class TaskFinishForm extends CommentAddForm {
private static final Logger s_log = Logger.getLogger private static final Logger s_log = Logger.getLogger(TaskFinishForm.class);
(TaskFinishForm.class);
private final TaskRequestLocal m_task; private final TaskRequestLocal m_task;
private final Label m_approvePrompt; private final Label m_approvePrompt;
private final RadioGroup m_approve; private final RadioGroup m_approve;
@ -71,10 +70,8 @@ public final class TaskFinishForm extends CommentAddForm {
m_task = task; m_task = task;
m_approve = new RadioGroup(new BooleanParameter("approve")); m_approve = new RadioGroup(new BooleanParameter("approve"));
m_approve.addOption m_approve.addOption(new Option("true", lz("cms.ui.workflow.task.approve")));
(new Option("true", lz("cms.ui.workflow.task.approve"))); m_approve.addOption(new Option("false", lz("cms.ui.workflow.task.reject")));
m_approve.addOption
(new Option("false", lz("cms.ui.workflow.task.reject")));
m_approvePrompt = new Label(gz("cms.ui.workflow.task.approve_prompt")); m_approvePrompt = new Label(gz("cms.ui.workflow.task.approve_prompt"));
@ -87,6 +84,7 @@ public final class TaskFinishForm extends CommentAddForm {
} }
private class InitListener implements FormInitListener { private class InitListener implements FormInitListener {
public final void init(final FormSectionEvent e) { public final void init(final FormSectionEvent e) {
s_log.debug("Initializing task finish"); s_log.debug("Initializing task finish");
@ -107,6 +105,7 @@ public final class TaskFinishForm extends CommentAddForm {
} }
private class ValidationListener implements FormValidationListener { private class ValidationListener implements FormValidationListener {
public final void validate(final FormSectionEvent e) public final void validate(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
s_log.debug("Validating task finish"); s_log.debug("Validating task finish");
@ -115,13 +114,13 @@ public final class TaskFinishForm extends CommentAddForm {
final CMSTask task = m_task.getTask(state); final CMSTask task = m_task.getTask(state);
if (requiresApproval(task) && m_approve.getValue(state) == null) { if (requiresApproval(task) && m_approve.getValue(state) == null) {
throw new FormProcessException throw new FormProcessException(lz("cms.ui.workflow.task.approval_or_reject_required"));
(lz("cms.ui.workflow.task.approval_or_reject_required"));
} }
} }
} }
private class ProcessListener implements FormProcessListener { private class ProcessListener implements FormProcessListener {
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
s_log.debug("Processing task finish"); s_log.debug("Processing task finish");
@ -140,8 +139,8 @@ public final class TaskFinishForm extends CommentAddForm {
PermissionService.assertPermission(taskAccess); PermissionService.assertPermission(taskAccess);
if (requiresApproval(task)) { if (requiresApproval(task)) {
s_log.debug("The task requires approval; checking to see " + s_log.debug("The task requires approval; checking to see "
"if it's approved"); + "if it's approved");
// XXX I think the fact that this returns a Boolean is // XXX I think the fact that this returns a Boolean is
// the effect of broken parameter marshalling in // the effect of broken parameter marshalling in
@ -158,8 +157,8 @@ public final class TaskFinishForm extends CommentAddForm {
throw new FormValidationException(te.toString()); throw new FormValidationException(te.toString());
} }
} else { } else {
s_log.debug("The task is rejected; reenabling dependent " + s_log.debug("The task is rejected; reenabling dependent "
"tasks"); + "tasks");
// Reenable the previous tasks. // Reenable the previous tasks.
@ -169,8 +168,7 @@ public final class TaskFinishForm extends CommentAddForm {
final Task dependent = (Task) iter.next(); final Task dependent = (Task) iter.next();
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug s_log.debug("Reenabling task " + dependent.getLabel());
("Reenabling task " + dependent.getLabel());
} }
dependent.enable(); dependent.enable();
@ -178,8 +176,8 @@ public final class TaskFinishForm extends CommentAddForm {
} }
} }
} else { } else {
s_log.debug("The task does not require approval; finishing " + s_log.debug("The task does not require approval; finishing "
"it"); + "it");
try { try {
task.finish(Web.getContext().getUser()); task.finish(Web.getContext().getUser());
@ -191,20 +189,23 @@ public final class TaskFinishForm extends CommentAddForm {
if (finishedTask) { if (finishedTask) {
Iterator tasks = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE).getEnabledTasks(Web.getContext().getUser(), Iterator tasks = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE).getEnabledTasks(Web.getContext().getUser(),
task.getParentID()).iterator(); task.getParentID()).iterator();
while (tasks.hasNext()) { if (tasks.hasNext()) {
CMSTask thisTask = (CMSTask) tasks.next(); CMSTask thisTask = (CMSTask) tasks.next();
if (thisTask.getTaskType().getID().equals(CMSTaskType.DEPLOY)) { PermissionDescriptor thisTaskAccess = new PermissionDescriptor(thisTask.getTaskType().getPrivilege(), task.getWorkflow().getObject(), user);
throw new RedirectSignal if (PermissionService.checkPermission(thisTaskAccess)) {
(URL.there(state.getRequest(),
// Lock task for user
thisTask.lock((User) user);
int targetTab = (thisTask.getTaskType().getID().equals(CMSTaskType.DEPLOY)) ? ContentItemPage.PUBLISHING_TAB : ContentItemPage.AUTHORING_TAB;
throw new RedirectSignal(URL.there(state.getRequest(),
ContentItemPage.getItemURL(task.getItem(), ContentItemPage.getItemURL(task.getItem(),
ContentItemPage.PUBLISHING_TAB)), targetTab)),
true); true);
} }
} }
// redirect to /content-center if streamlined creation mode is active. // redirect to /content-center if streamlined creation mode is active.
if (ContentSection.getConfig().getUseStreamlinedCreation()) { if (ContentSection.getConfig().getUseStreamlinedCreation()) {
throw new RedirectSignal throw new RedirectSignal(URL.there(state.getRequest(),
(URL.there(state.getRequest(),
ContentCenter.getURL()), ContentCenter.getURL()),
true); true);
} }