/** * @param worklog the worklog * @return Creates a simple {@link WorklogResult} that just contains the {@link Worklog} to use. The editable check will be required. */ public static WorklogResult create(final Worklog worklog) { return create(worklog, true); }
@Override public WorklogResult validateDelete(JiraServiceContext jiraServiceContext, Long worklogId) { Worklog originalWorklog = worklogManager.getById(worklogId); // Does the user have permission to delete a worklog if (hasPermissionToDelete(jiraServiceContext, originalWorklog)) { return WorklogResultFactory.create(originalWorklog); } return null; }
@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; }
@Override public WorklogResult validateCreate(JiraServiceContext jiraServiceContext, WorklogInputParameters params) { ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); // Does the user have permission to create a worklog if (hasPermissionToCreate(jiraServiceContext, params.getIssue(), params.isEditableCheckRequired())) { Worklog worklog = validateParamsAndCreateWorklog(jiraServiceContext, params.getIssue(), user, params.getVisibility(), params.getTimeSpent(), params.getStartDate(), null, params.getComment(), null, null, null, params.getErrorFieldPrefix()); if (worklog != null) { return WorklogResultFactory.create(worklog, params.isEditableCheckRequired()); } } return null; }