code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit bafbe208 authored by Tobias Jeger's avatar Tobias Jeger

REPO-1602 Rework after review (better logging)

parent c69afe4c
......@@ -84,10 +84,13 @@ public final class WorkflowUtils {
final WorkflowManager workflowManager = workspace.getWorkflowManager();
final Workflow workflow = workflowManager.getWorkflow(category, node);
if (workflow != null && clazz.isAssignableFrom(workflow.getClass())) {
if (workflow == null) {
log.info("Failed to find a workflow for category '{}' and node '{}'", category, node.getPath());
} else if (clazz.isAssignableFrom(workflow.getClass())) {
return Optional.of((T)workflow);
} else {
log.info("Failed to obtain workflow of desired class {}", clazz.getName());
log.info("Failed to obtain workflow of desired class '{}' for category '{}' and node '{}'.",
clazz.getName(), category, node.getPath());
}
} catch (RepositoryException e) {
if (log.isDebugEnabled()) {
......
......@@ -122,6 +122,7 @@ public class WorkflowUtilsTest {
final Workflow workflow = createMock(EditableWorkflow.class);
expect(node.getSession()).andReturn(session).anyTimes();
expect(node.getPath()).andReturn("/bla");
expect(session.getWorkspace()).andReturn(workspace).anyTimes();
expect(workspace.getWorkflowManager()).andReturn(wfm).anyTimes();
expect(wfm.getWorkflow("category", node)).andReturn(workflow).anyTimes();
......@@ -140,6 +141,7 @@ public class WorkflowUtilsTest {
final WorkflowManager wfm = createMock(WorkflowManager.class);
expect(node.getSession()).andReturn(session).anyTimes();
expect(node.getPath()).andReturn("/bla");
expect(session.getWorkspace()).andReturn(workspace).anyTimes();
expect(workspace.getWorkflowManager()).andReturn(wfm).anyTimes();
expect(wfm.getWorkflow("category", node)).andReturn(null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment