private void addLinkFromNewParent(final MutableIssue newIssue, final Issue newParent, final ApplicationUser applicationUser) { if (newParent != null) { try { subTaskManager.createSubTaskIssueLink(newParent, newIssue, applicationUser); } catch (CreateException e) { log.warn(e.getMessage(), e); throw new RuntimeException(e); } } }
/** * @deprecated since version 6.0 */ @Deprecated public Version createVersion(final String name, final Date releaseDate, final String description, final GenericValue project, final Long scheduleAfterVersion) throws CreateException { if (project == null) { throw new CreateException("You cannot create a version without a project."); } return createVersion(name, releaseDate, description, project.getLong("id"), scheduleAfterVersion); }
private void handleCreateException(final I18nHelper i18n, final ErrorCollection errors, final CreateException createException) { final String errMsg = i18n.getText("admin.errors.issues.error.creating", createException.getMessage()); Throwable cause = createException.getCause(); if (cause instanceof InvalidInputException) { InvalidInputException inputException = (InvalidInputException) cause; handleInvalidInputException(errors, inputException); } else { errors.addErrorMessage(errMsg); } }
throw new ServerErrorWebException(ErrorCollection.of(e.getLocalizedMessage()));
private void handleCreateException(final I18nHelper i18n, final ErrorCollection errors, final CreateException createException) { errors.addErrorMessage(i18n.getText("remotelink.service.error.creating", createException.getMessage()), Reason.SERVER_ERROR); }
private void validateGlobalIdForCreate(final Issue issue, final String globalId) throws CreateException { final Result result = validateGlobalId(issue, globalId); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
@Override @Nonnull public ServiceOutcome<Version> create(@Nullable ApplicationUser user, @Nonnull VersionBuilderValidationResult validationResult) { check(validationResult); try { final VersionBuilderImpl builder = (VersionBuilderImpl) validationResult.getResult(); Version version = versionManager.createVersion(builder.getName(), builder.getStartDate(), builder.getReleaseDate(), builder.getDescription(), builder.getProjectId(), builder.getScheduleAfterVersion()); return ServiceOutcomeImpl.ok(version); } catch (CreateException ex) { log.error("Unable to create version", ex); return ServiceOutcomeImpl.error("Unable to create version: " + ex.getMessage(), ErrorCollection.Reason.SERVER_ERROR); } }
private void validateFieldLengthsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateFieldLengths(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
public RemoteUser createUser(User remoteUser, String username, String password, String fullName, String email) throws RemoteValidationException, RemotePermissionException { if (username != null) { username = username.trim(); } final com.atlassian.jira.bc.user.UserService.CreateUserValidationResult result = userService.validateCreateUserForAdminPasswordRequired(remoteUser, username, password, password, email, fullName); if (!result.isValid()) { throw new RemoteValidationException("Error creating user", result.getErrorCollection()); } try { User user = userService.createUserWithNotification(result); return remoteEntityFactory.createUser(user); } catch (PermissionException e) { throw new RemoteValidationException("cannot create user details, cause: " + e.getMessage(), e); } catch (CreateException e) { throw new RemoteValidationException("cannot create user details, cause: " + e.getMessage(), e); } }
private void validateUrlsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateUrls(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
@Override public Either<NegativeResponseStatus, SuccessfulResponse> copyRemoteIssueLink(RemoteIssueLink remoteIssueLink, String remoteIssueKey) { Issue issue = issueManager.getIssueObject(remoteIssueKey); try { RemoteIssueLinkBuilder builder = new RemoteIssueLinkBuilder(remoteIssueLink).issueId(issue.getId()).id(null); remoteIssueLinkManager.createRemoteIssueLink(builder.build(), jiraAuthenticationContext.getUser()); return SuccessfulResponse.buildEither(jiraLocation); } catch (CreateException e) { return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, e.getMessage())); } }
@Override public GenericValue createIssue(final ApplicationUser remoteUser, final Issue issue) throws CreateException { validateCreateIssueTextFieldsLength(issue); try { final Map<String, Object> fields = new HashMap<>(); fields.put(ISSUE_MAP_KEY, issue); final MutableIssue originalIssueGV = getIssueObject(issue.getId()); fields.put(WorkflowFunctionUtils.ORIGINAL_ISSUE_KEY, originalIssueGV); final GenericValue issueGV = workflowManager.createIssue(remoteUser != null ? remoteUser.getName() : null, fields); return issueGV; } catch (final WorkflowException workflowException) { final Throwable cause = workflowException.getCause(); if (cause instanceof InvalidInputException) { throw new CreateException("Error occurred while creating issue through workflow: " + cause.getMessage(), (InvalidInputException) cause); } throw new CreateException(workflowException); } }
@Override public Either<NegativeResponseStatus, SuccessfulResponse> copyLocalIssueLink(Issue localIssue, String remoteIssueKey, Long remoteIssueId, SimplifiedIssueLinkType issueLinkType, LinkCreationDirection localDirection, LinkCreationDirection remoteDirection) { try { //In contrary to remote links, local are always created in both directions so is is not possible to create only one-way local link. //So here we care only local direction (ie creating link from source issue) if (localDirection == LinkCreationDirection.OUTWARD) { issueLinkManager.createIssueLink(localIssue.getId(), remoteIssueId, issueLinkType.getId(), null, jiraAuthenticationContext.getLoggedInUser()); } else if (localDirection == LinkCreationDirection.INWARD) { issueLinkManager.createIssueLink(remoteIssueId, localIssue.getId(), issueLinkType.getId(), null, jiraAuthenticationContext.getLoggedInUser()); } return SuccessfulResponse.buildEither(jiraLocation); } catch (CreateException e) { return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, e.getMessage())); } }
if ((cause != null) && (cause instanceof InvalidInputException)) throw new CreateException("Error occurred while creating issue through workflow: " + cause.getMessage(), (InvalidInputException) cause); throw new CreateException(e.getMessage(), e);
addError("username", getText("admin.errors.user.cannot.create", e.getMessage()));
/** * Mandatory fields are: * - issueId * - title * - url * * @param remoteIssueLink * @throws CreateException */ private void validateMandatoryFieldsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateMandatoryFields(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
public IssueType insertSubTaskIssueType(String name, Long sequence, String description, Long avatarId) throws CreateException { // Check that an issue type of that name does not already exist. if (issueTypeExistsByName(name)) { throw new CreateException("Issue Type with name '" + name + "' already exists."); } // Insert the record into the database final IssueType subTaskIssueType = constantsManager.insertIssueType(name, sequence, SUB_TASK_ISSUE_TYPE_STYLE, description, avatarId); // Add to default scheme issueTypeSchemeManager.addOptionToDefault(subTaskIssueType.getId()); return subTaskIssueType; }
@Override public IssueType insertSubTaskIssueType(String name, Long sequence, String description, String iconurl) throws CreateException { // Check that an issue type of that name does not already exist. if (issueTypeExistsByName(name)) { throw new CreateException("Issue Type with name '" + name + "' already exists."); } // Insert the record into the database final IssueType subTaskIssueType = constantsManager.insertIssueType(name, sequence, SUB_TASK_ISSUE_TYPE_STYLE, description, iconurl); // Add to default scheme issueTypeSchemeManager.addOptionToDefault(subTaskIssueType.getId()); return subTaskIssueType; }
throw new CreateException(e);
throw new CreateException("You cannot create a version without a name."); throw new CreateException("You cannot create a version without a project.");