public Builder addErrorMessage(final String message, final ErrorCollection.Reason reason) { errors.addErrorMessage(message, reason); return this; }
public Builder addErrorMessages(final Iterable<String> errorMessages) { for (final String errorMessage : errorMessages) { errors.addErrorMessage(errorMessage); } return this; }
public Builder addErrorMessage(final String errorMessage) { errors.addErrorMessage(errorMessage); return this; }
@Override public void addErrorMessage(final String error) { errorCollection.addErrorMessage(error); }
private void addRequiredAdminPermissionErrorMessage(final ErrorCollection errorCollection) { errorCollection.addErrorMessage(getText("project.roles.service.error.admin.permission"), ErrorCollection.Reason.FORBIDDEN); } }
void addErrorKey(String key, String errorValue, ErrorCollection.Reason reason) { simpleErrorCollection.addErrorMessage(key, reason); if (errorCollection != null) { errorCollection.addErrorMessage(componentService.translateKeyToMessage(key, errorValue), reason); } }
private boolean validateNonNullIssue(final JiraServiceContext jiraServiceContext, @Nullable final Issue issue) { if (issue == null) { jiraServiceContext.getErrorCollection().addErrorMessage(getText("attachment.service.error.null.issue")); return false; } return true; }
private ErrorCollection validateNoUsageOfRoleInWorkflows(final ProjectRole projectRole) { ErrorCollection errorCollection = new SimpleErrorCollection(); Set<JiraWorkflow> workflows = getAssociatedWorkflows(projectRole, errorCollection).keySet(); if(!workflows.isEmpty()) { List<String> workflowNames = workflows.stream().map(JiraWorkflow::getDisplayName).collect(Collectors.toList()); String workflowListString = "[" + StringUtils.join(workflowNames, ",") + "]"; errorCollection.addErrorMessage(getText("rest.role.used.in.workflows", workflowListString), ErrorCollection.Reason.CONFLICT); } return errorCollection; }
boolean hasPermissionToEdit(ApplicationUser user, Issue issue, I18nHelper i18n, ErrorCollection errors) { final boolean hasPermission = issueManager.isEditable(issue, user); if (!hasPermission) { errors.addErrorMessage(i18n.getText("editissue.error.no.edit.permission"), user == null ? Reason.NOT_LOGGED_IN : Reason.FORBIDDEN); } return hasPermission; }
boolean hasPermissionToDelete(ApplicationUser user, Issue issue, I18nHelper i18n, ErrorCollection errors) { final boolean hasPermission = permissionManager.hasPermission(DELETE_ISSUES, issue, user); if (!hasPermission) { errors.addErrorMessage(i18n.getText("admin.errors.issues.no.permission.to.delete"), user == null ? Reason.NOT_LOGGED_IN : Reason.FORBIDDEN); } return hasPermission; }
boolean hasPermissionToCreate(ApplicationUser user, Project project, I18nHelper i18n, ErrorCollection errors) { final boolean hasPermission = permissionManager.hasPermission(CREATE_ISSUES, project, user); if (!hasPermission) { errors.addErrorMessage(i18n.getText("createissue.projectnopermission"), user == null ? Reason.NOT_LOGGED_IN : Reason.FORBIDDEN); } return hasPermission; }
public JiraWorkflow getWorkflow(final JiraServiceContext jiraServiceContext, final String name) { if (StringUtils.isEmpty(name)) { jiraServiceContext.getErrorCollection().addErrorMessage(getI18nBean().getText("admin.workflows.service.error.null.name")); return null; } return workflowManager.getWorkflow(name); }
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); }
private void checkProjectAdminPermission(ErrorCollection errorCollection, ProjectComponent component, ApplicationUser user) { if (component == null) { errorCollection.addErrorMessage(translateKeyToMessage(KEY_NO_SUCH_COMPONENT, null), ErrorCollection.Reason.FORBIDDEN); } else { Long projectId = component.getProjectId(); checkProjectAdminPermission(errorCollection, projectId, user); } }
private ErrorCollection validateNoUsageOfRoleInComments(final ProjectRole projectRole) { ErrorCollection errorCollection = new SimpleErrorCollection(); long countForCommentsRestrictedByRole = commentManager.getCountForCommentsRestrictedByRole(projectRole.getId()); if (countForCommentsRestrictedByRole != 0) { errorCollection.addErrorMessage(getText("rest.role.used.in.comments"), ErrorCollection.Reason.CONFLICT); } return errorCollection; }
@Override public void doValidation(final String key, final Map<String, String> parameters, final JiraServiceContext jiraServiceContext) { if (!doValidation(key, parameters)) { final String localisedMessage = jiraAuthenticationContext.getI18nHelper().getText("admin.permissions.errors.please.select.user"); jiraServiceContext.getErrorCollection().addErrorMessage(localisedMessage); } }
private ErrorCollection validateNoUsageOfRoleInWorklogs(final ProjectRole projectRole) { ErrorCollection errorCollection = new SimpleErrorCollection(); long countForWorklogsRestrictedByRole = worklogManager.getCountForWorklogsRestrictedByRole(projectRole.getId()); if (countForWorklogsRestrictedByRole != 0) { errorCollection.addErrorMessage(getText("rest.role.used.in.worklogs"), ErrorCollection.Reason.CONFLICT); } return errorCollection; }
private void addError(final JiraServiceContext jiraServiceContext, final String msgKey, final Reason reason) { final ErrorCollection errorCollection = jiraServiceContext.getErrorCollection(); errorCollection.addErrorMessage(getI18nBean().getText(msgKey)); errorCollection.addReason(reason); } }
public String getIndexRootPath(final JiraServiceContext serviceContext) { if (permissionManager.hasPermission(Permissions.SYSTEM_ADMIN, serviceContext.getLoggedInUser())) { return indexPathManager.getIndexRootPath(); } else { serviceContext.getErrorCollection().addErrorMessage(serviceContext.getI18nBean().getText("admin.errors.indexpath.no.permission")); return null; } }
public boolean validateForGetPortalPage(final JiraServiceContext context, final Long portalPageId) { Assertions.notNull("context", context); Assertions.notNull("portalPageId", portalPageId); final PortalPage portalPage = portalPageManager.getPortalPage(context.getLoggedInApplicationUser(), portalPageId); if (portalPage == null) { context.getErrorCollection().addErrorMessage(context.getI18nBean().getText("admin.errors.portalpages.no.access")); return false; } return true; }