CCM NG/ccm-cms: Avoid NPE in ItemWorkflowRequestLocalHelper when no workflow is assigned to a ContentItem.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4790 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-06-20 11:25:05 +00:00
parent 77ac9d7aaa
commit be3f1d51d5
1 changed files with 12 additions and 7 deletions

View File

@ -53,11 +53,16 @@ class ItemWorkflowRequestLocalHelper {
.format("No ContentItem with ID %d in the database.", .format("No ContentItem with ID %d in the database.",
item.getObjectId()))); item.getObjectId())));
final Workflow workflow = workflowRepo final Workflow workflow;
.findById(contentItem.getWorkflow().getWorkflowId()) if (contentItem.getWorkflow() == null) {
.orElseThrow(() -> new IllegalArgumentException(String workflow = null;
.format("No Workflow with ID %d in the database.", } else {
contentItem.getWorkflow().getWorkflowId()))); workflow = workflowRepo
.findById(contentItem.getWorkflow().getWorkflowId())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Workflow with ID %d in the database.",
contentItem.getWorkflow().getWorkflowId())));
}
return workflow; return workflow;
} }