void validateUpdateOrDeletePermissionCheckParams(Worklog worklog, ErrorCollection errorCollection, final JiraServiceContext jiraServiceContext) { if (worklog == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return; } Issue issue = worklog.getIssue(); if (issue == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return; } if (!isIssueInEditableWorkflowState(issue)) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.not.editable.workflow.state")); return; } if (worklog.getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); } }
public List getByIssue(JiraServiceContext jiraServiceContext, Issue issue) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (issue == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.null.issue")); return Collections.EMPTY_LIST; } return worklogManager.getByIssue(issue); }
protected boolean isValidNewEstimate(JiraServiceContext jiraServiceContext, String newEstimate, final String errorFieldPrefix) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); String errorField = "newEstimate"; if (StringUtils.isNotBlank(errorFieldPrefix)) { errorField = errorFieldPrefix + errorField; } if (TextUtils.stringSet(newEstimate)) { if (!isValidDuration(newEstimate, jiraServiceContext)) { errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.newestimate")); return false; } } else { errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.new.estimate.not.specified")); return false; } return true; }
/** * Checks if the given String is a valid amount of time to change an estimate by. * * @param jiraServiceContext JiraServiceContext * @param adjustmentAmount String with amount of time eg "3d 4h" * @param errorFieldPrefix the prefix for the error field * @return true if this change is a valid time. */ protected boolean isValidAdjustmentAmount(JiraServiceContext jiraServiceContext, String adjustmentAmount, final String errorFieldPrefix) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); String errorField = "adjustmentAmount"; if (StringUtils.isNotBlank(errorFieldPrefix)) { errorField = errorFieldPrefix + errorField; } // Check that it is not empty if (!TextUtils.stringSet(adjustmentAmount)) { errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.adjustment.amount.not.specified")); return false; } // Check that the String is a valid time. if (!isValidDuration(adjustmentAmount, jiraServiceContext)) { errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.adjustment.amount.invalid")); return false; } return true; }
errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.time.tracking.not.enabed")); return false; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.not.editable.workflow.state")); return false; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.permission", user.getDisplayName())); errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.permission.no.user"));
errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.timespent.required")); errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.invalid.time.duration")); errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.timespent.zero")); errorCollection.addError(errorField, getText(jiraServiceContext, "worklog.service.error.invalid.worklog.date"));
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; }
@Override public boolean deleteAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, boolean dispatchEvent) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); //these null checks are duplicated in update() but must be run before passing worklog to getAutoAdjustNewEstimateOnUpdate() if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return false; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return false; } Long timeSpent = worklogResult.getWorklog().getTimeSpent(); Long newEstimate = increaseEstimate(worklogResult.getWorklog().getIssue(), timeSpent); return delete(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
protected boolean delete(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { ApplicationUser user = jiraServiceContext.getLoggedInApplicationUser(); ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return false; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; } if (worklogResult.getWorklog().getId() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return false; } // Re-do the permission check if (hasPermissionToDelete(jiraServiceContext, worklogResult.getWorklog())) { return worklogManager.delete(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return false; }
@Override public boolean deleteWithManuallyAdjustedEstimate(JiraServiceContext jiraServiceContext, WorklogAdjustmentAmountResult worklogResult, boolean dispatchEvent) { ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); if (worklogResult == null || worklogResult.getWorklog() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return false; } if (worklogResult.getWorklog().getIssue() == null) { errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return false; } // Calculate the new remaining estimate Long newEstimate = increaseEstimate(worklogResult.getWorklog().getIssue(), worklogResult.getAdjustmentAmount()); return delete(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
@Override public Worklog createWithManuallyAdjustedEstimate(final JiraServiceContext jiraServiceContext, final WorklogAdjustmentAmountResult worklogResult, final boolean dispatchEvent) { 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; } // Calculate the new remaining estimate final Worklog worklog = worklogResult.getWorklog(); Long newEstimate = reduceEstimate(worklog.getIssue(), worklogResult.getAdjustmentAmount()); return create(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
@Override public Worklog createAndAutoAdjustRemainingEstimate(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, boolean dispatchEvent) { 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; } Long newEstimate = reduceEstimate(worklogResult.getWorklog().getIssue(), worklogResult.getWorklog().getTimeSpent()); return create(jiraServiceContext, worklogResult, newEstimate, dispatchEvent); }
errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.null")); return null; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.issue.null")); return null; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.worklog.id.null")); return null; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.worklog.for.id", worklogResult.getWorklog().getId().toString())); return null;
protected Worklog create(JiraServiceContext jiraServiceContext, WorklogResult worklogResult, Long newEstimate, boolean dispatchEvent) { Worklog newWorklog = 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; } // Re-do the permission check if (hasPermissionToCreate(jiraServiceContext, worklogResult.getWorklog().getIssue(), worklogResult.isEditableCheckRequired())) { newWorklog = worklogManager.create(user, worklogResult.getWorklog(), newEstimate, dispatchEvent); } return newWorklog; }
jiraServiceContext.getErrorCollection().addErrorMessage(getText(jiraServiceContext, "worklog.service.error.time.tracking.not.enabed")); return false; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.edit.permission", user.getDisplayName())); errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.edit.permission.no.user"));
jiraServiceContext.getErrorCollection().addErrorMessage(getText(jiraServiceContext, "worklog.service.error.time.tracking.not.enabed")); return false; errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.delete.permission", user.getDisplayName())); errorCollection.addErrorMessage(getText(jiraServiceContext, "worklog.service.error.no.delete.permission.no.user"));