public void checkout(Workflow workflow, UserUser user) {
if (workflow == null || user == null) {
return;
}
if (workflow.getUser() != null && !workflow.getUser().getId().equals(user.getId())) {
throw new DocumentCheckedoutException("Document is checkout by other user");
}
workflow.setUser(user);
workflowRepository.save(workflow);
}