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

Former-commit-id: 06a336d252
pull/2/head
jensp 2017-06-20 11:25:05 +00:00
parent 21bc4a1ec4
commit 18d1304c5b
1 changed files with 12 additions and 7 deletions

View File

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