Skip to main content

Workflows

JavaDoc

WorkflowSession wf = resourceResolver.adaptTo(WorkflowSession.class);
Workflow[] workflows = wf.getAllWorkflows();

Beispiel: Terminate all Workflows for current user / resourceResolvers Access Rights

final WorkflowSession workflowSession = resourceResolver.adaptTo(WorkflowSession.class);
final Workflow[] allWorkflows = workflowSession.getAllWorkflows();
for (Workflow wf : allWorkflows) {
if (wf.getState().equals("RUNNING")) {
final String id = wf.getId();
LOG.info("Found running wf id: {}. Termination initiated.", id);
try {
workflowSession.terminateWorkflow(wf);
}
catch (WorkflowException we) {
LOG.error("Could not terminate Workflow with id: {}", id, we);
}
}
}

Get All WorkflowLauncher and their Configs:

ResourceResolver resourceResolver = getClientMergeReportingService().getResourceResolver();
WorkflowLauncher wfl = resourceResolver.adaptTo(WorkflowLauncher.class);
if (wfl != null) {
Iterator<ConfigEntry> configEntries = wfl.getConfigEntries();
List<ConfigEntry> wflConfigs = new ArrayList<>();
configEntries.forEachRemaining(wflConfigs::add);
for (ConfigEntry ce : wflConfigs) {
LOG.info("desc: " + ce.getId());
LOG.info("desc: " + ce.getDescription() + "\n");
}

// Disable all
for (ConfigEntry ce : list) {
ce.setEnabled(false);
}
}

Disable / Enable All WorkflowLauncher

try {
ResourceResolver resourceResolver = getClientMergeReportingService().getResourceResolver();
WorkflowLauncher workflowLauncher = resourceResolver.adaptTo(WorkflowLauncher.class);
if (workflowLauncher != null) {
Iterator<ConfigEntry> configEntries = workflowLauncher.getConfigEntries();
while (configEntries.hasNext()) {
final ConfigEntry configEntry = configEntries.next();
configEntries.next().setEnabled(false);
LOG.info("Disabled: " + configEntry.getId());
getClientMergeReportingService().details("Disabled WFL: " + configEntry.getId());
}
}
}
catch (LoginException le) {
LOG.error("Error during ResourceResolver login.", le);
return false;
}
catch (Exception e) {
LOG.error("Error during step execution.", e);
return false;
}

Administering Workflows

Extending Workflows

Youtube Playlist / slightly outdated