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; }
else if (!isValidDuration(timeSpent, jiraServiceContext))