/** * Update the specified issue link type. * * @request.representation.example * {@link ResourceExamples#ISSUE_LINK_TYPE_EXAMPLE_CREATE} * * @response.representation.404.doc * Returned if issue linking is disabled or no issue link type with the given id exists. * * @response.representation.400.doc * Returned if the supplied id is not a number. * * @response.representation.200.example * {@link ResourceExamples#ISSUE_LINK_TYPE_EXAMPLE} */ @PUT @Path ("/{issueLinkTypeId}") public Response updateIssueLinkType(@PathParam ("issueLinkTypeId") final String issueLinkTypeIdString, IssueLinkTypeJsonBean linkTypeJsonBean) { final IssueLinkType linkType = findLinkType(issueLinkTypeIdString); final ServiceOutcome<IssueLinkType> outcome = issueLinkTypeService.updateIssueLinkType(authenticationContext.getUser(), linkType, linkTypeJsonBean.name(), linkTypeJsonBean.outward(), linkTypeJsonBean.inward()); if (outcome.isValid()) { return status(Response.Status.OK).entity(getIssueLinkType(issueLinkTypeIdString).getEntity()).build(); } else { throw new RESTException(ErrorCollection.of(outcome.getErrorCollection())); } }
ServiceOutcome<IssueLinkType> outcome = issueLinkTypeService.createIssueLinkType(authenticationContext.getUser(), linkTypeBean.name(), linkTypeBean.outward(), linkTypeBean.inward()); if (outcome.isValid())
private void validateForCreate(final IssueLinkTypeJsonBean linkTypeBean) { ErrorCollection errors = new ErrorCollection(); if (StringUtils.isEmpty(linkTypeBean.inward())) { errors.addErrorMessage(i18n.getText("admin.errors.linking.error.missing.inward")); } if (StringUtils.isEmpty(linkTypeBean.outward())) { errors.addErrorMessage(i18n.getText("admin.errors.linking.error.missing.outward")); } if (StringUtils.isEmpty(linkTypeBean.name())) { errors.addErrorMessage(i18n.getText("admin.errors.linking.error.missing.name")); } if (errors.hasAnyErrors()) { throw new RESTException(Response.Status.BAD_REQUEST, errors); } }