Start page / Tutorials / Workflows / Workflow “RecursiveRelease”

Example: “RecursiveRelease” workflow

This workflow for recursive release consists of the workflow itself and the corresponding “serverrelease” script.

The element where the workflow was started is to be released recursively in the workflow along with all dependent elements.

Server-side release, which is used within the “serverrelease” script, controls both the release itself and the internal setting of write protection for the affected element. If elements already subject to write protection are found, the server-side release cannot be performed. These affected elements can be retrieved via the return value of the server-side release (only in test mode):

handle.getProgress(true).getLockFailedElements()

Accordingly, no recursive write protection has to be set via the script for server-side release. However, in order for release to take place, no write protection may be set by the workflow. Consequently, the write protection applied to the element is first removed using the script:

se.setLock(false, false);

Then server-side release is carried out by calling the method:                      

AccessUtil.release(IDProvider releaseStartNode, 
boolean checkOnly, boolean releaseParentPath, boolean recursive,
IDProvider.DependentReleaseType dependentType)

In the example, the following transition parameters are configured for server-side release:

handle = AccessUtil.release(se, false, false, true, 
de.espirit.firstspirit.access.store.IDProvider.DependentReleaseType.DEPENDENT_RELEASE_NEW_AND_CHANGED);

Return parameter:

ServerActionhandle<? extends ReleaseProgress,Boolean >

The server-side release returns a ServerActionHandle, which contains all the information about the release process.

The first thing to happen within the sample script is that the result of the release process is queried:

handle.getResult();
handle.checkAndThrow();

Next, the errors that occurred during release are examined. If elements cannot be released (e.g. because write protection was applied to the element or the editor did not have the relevant permissions to release an element), these can be queried via the methods                   
progress.getMissingPermissionElements() and                                               
progress.getLockFailedElements():

    progress = handle.getProgress(true);
         notReleased.addAll(progress.getMissingPermissionElements());
    notReleased.addAll(progress.getLockFailedElements());

The script error handling feature shows the editor which elements could not be released:

if (!notReleased.isEmpty()) {
text = "Unable to release the following elements: " + notReleased;
         requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
         requestOperation.setKind(RequestOperation.Kind.ERROR);
         requestOperation.addOk();
         requestOperation.perform(text);
}
Important The error message is shown in test mode only (“checkOnly”).

For information on pop-up dialogs, see Workflows / Messages and Plug-In Development / Message Boxes.

Script “serverrelease”:

//!Beanshell
import de.espirit.firstspirit.common.gui.*;
import de.espirit.firstspirit.access.*;
import de.espirit.firstspirit.access.store.*;
import de.espirit.firstspirit.ui.operations.RequestOperation;
import de.espirit.firstspirit.agency.OperationAgent;
 
se = context.getElement();
try {
          se.setLock(false, false);
          handle = AccessUtil.release(se, false, false, true,
de.espirit.firstspirit.access.store.IDProvider.DependentReleaseType.DEPENDENT_RELEASE_NEW_AND_CHANGED);
          handle.getResult();
          handle.checkAndThrow();
          Set notReleased = new HashSet();
          progress = handle.getProgress(true);
         
          notReleased.addAll(progress.getMissingPermissionElements());
          notReleased.addAll(progress.getLockFailedElements());
          if (!notReleased.isEmpty()) {
                      text = "Unable to release the following elements: " + notReleased;
                      requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
                      requestOperation.setKind(RequestOperation.Kind.ERROR);
                      requestOperation.addOk();
                      requestOperation.perform(text);
          }
          se.refresh();
          context.getGuiHost().gotoTreeNode(se);
          se.setLock(true, false);
          context.doTransition("->End");
} catch (Exception ex) {
          text = "Error while releasing: " + ex;
          requestOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(RequestOperation.TYPE);
          requestOperation.setKind(RequestOperation.Kind.ERROR);
          requestOperation.addOk();
          requestOperation.perform(text);
 
          context.getSession().put("error", ex.toString());
          context.doTransition("->Error");
}

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.5 | Data privacy