public Either<CommitHookErrors, Worklog> handle(ApplicationUser user, MutableIssue issue, String commandName, List<String> args) { JiraServiceContextImpl jiraServiceContext = new JiraServiceContextImpl(user); WorklogResult result = worklogService.validateCreate( jiraServiceContext, WorklogInputParametersImpl.builder() .issue(issue) .timeSpent(args.isEmpty() ? null : args.get(0)) .comment(args.size() > 1 ? args.get(1) : null) .startDate(new Date()) .build()); if (!jiraServiceContext.getErrorCollection().hasAnyErrors()) { return Either.value(worklogService.createAndAutoAdjustRemainingEstimate( jiraServiceContext, result, true)); } else { return Either.error(CommitHookErrors.fromErrorCollection( CMD_TYPE.getName(), issue.getKey(), jiraServiceContext.getErrorCollection())); } } }