@Override public WorklogResult validateUpdate(JiraServiceContext jiraServiceContext, final WorklogInputParameters params) { notNull("params", params); Worklog originalWorklog = worklogManager.getById(params.getWorklogId()); ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); // Does the user have permission to edit a worklog if (hasPermissionToUpdate(jiraServiceContext, originalWorklog)) { Worklog updatedWorklog = validateParamsAndCreateWorklog(jiraServiceContext, originalWorklog.getIssue(), originalWorklog.getAuthorObject(), params.getVisibility(), params.getTimeSpent(), params.getStartDate(), params.getWorklogId(), params.getComment(), originalWorklog.getCreated(), new Date(), user, params.getErrorFieldPrefix()); if (updatedWorklog != null) { return WorklogResultFactory.create(updatedWorklog); } } return null; }
protected Worklog update(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { Worklog updatedWorklog = null; ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return null; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return null; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return null; } // Re-do the permission check if (hasPermissionToUpdate(jiraServiceContext, worklogResult.getWorklog())) { updatedWorklog = worklogManager.update(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return updatedWorklog; }