/** * * @return null if the input is null */ public static VotesJsonBean shortBean(final String issueKey, final long votes, final boolean hasVoted, final JiraBaseUrls urls) { final VotesJsonBean bean = new VotesJsonBean(); bean.self = urls.restApi2BaseUrl() + "issue/" + issueKey + "/votes"; bean.hasVoted = hasVoted; bean.votes = votes; return bean; }
/** * * @return null if the input is null */ public static WatchersJsonBean shortBean(final String issueKey, final long watchers, final boolean isWatching, final JiraBaseUrls urls) { final WatchersJsonBean bean = new WatchersJsonBean(); bean.self = urls.restApi2BaseUrl() + "issue/" + issueKey + "/watchers"; bean.watching = isWatching; bean.watchCount = watchers; return bean; }
/** * @since 7.0.0 */ public static String propertySelf(JiraBaseUrls urls, Long entityId, String propertyKey, BiFunction<Long, String, String> selfFunction) { return urls.restApi2BaseUrl() + selfFunction.apply(entityId, JiraUrlCodec.encode(propertyKey)); }
private String selfLinkFor(PortalPage page) { // e.g. http://localhost:8090/jira/rest/api/2/dashboard/10019 return String.format("%s%s/%s", jiraBaseUrls.restApi2BaseUrl(), "dashboard", page.getId()); }
public URI toUri() { UriBuilder builder = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()); for (String path : paths) { builder.path(path); } for (Map.Entry<String, String> queryParam : queryParams.entrySet()) { builder.queryParam(queryParam.getKey(), queryParam.getValue()); } return builder.build(); }
private String getNotificationSchemeSelf(final NotificationScheme notificationScheme) { return jiraBaseUrls.restApi2BaseUrl() + "notificationscheme/" + notificationScheme.getId(); } }
public static URI makeSelfUri(String groupName, JiraBaseUrls urls) { return URI.create(urls.restApi2BaseUrl() + "group?groupname=" + JiraUrlCodec.encode(groupName)); }
private URI getSelf(final String restApiPath, final Long since) { return UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()) .path(WorklogResource.class) .path(restApiPath) .queryParam("since", since) .build(); } }
private String baseSelfForPagedVersions(String projectKey, String orderByQuery) { UriBuilder withoutOrderBy = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()) .path(ProjectResource.class) .path(projectKey) .path("version"); if (orderByQuery != null) { return withoutOrderBy.queryParam("orderBy", orderByQuery).build().toString(); } return withoutOrderBy.build().toString(); }
protected URI createSelfLink() { return UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()) .path(UserResource.class) .queryParam("username", "{0}") // JRADEV-3622. Workaround for percent encoding problem. .build(user.getUsername()); //JRADEV-22338: FIXME: we should start returning key instead of username here! }
private URI createSelfURI(Version version) { final JiraBaseUrls jiraBaseUrls = ComponentAccessor.getComponent(JiraBaseUrls.class); final UriBuilder uriBuilder = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()); return uriBuilder.path(VersionResource.class).path(version.getId().toString()).build(); } }
public IssueLinkJsonBean buildIssueLinkBean(IssueLinkType issueLinkType, String id) { URI linkTypeURI = URI.create(jiraBaseUrls.restApi2BaseUrl() + "issueLinkType/" + issueLinkType.getId()); URI selfURI = URI.create(jiraBaseUrls.restApi2BaseUrl() + "issueLink/" + id); IssueLinkJsonBean issueLink = new IssueLinkJsonBean().type(IssueLinkTypeJsonBean.create(issueLinkType, linkTypeURI)); issueLink.self(selfURI); issueLink.id(id); return issueLink; }
@Override protected ImmutableMap.Builder<String, Object> putFields(final T event, final ImmutableMap.Builder<String, Object> defaultJson) { String url = urls.restApi2BaseUrl() + "configuration"; ApplicationPropertyBean propertyBean = new ApplicationPropertyBean(url, event.getPropertyKey(), getEventValue(event)); defaultJson.put("property", propertyBean); return defaultJson; }
private static ComponentBean shortComponent(final ProjectComponent component, final JiraBaseUrls jiraBaseUrls) { final ComponentBean bean = new ComponentBean(); bean.self = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()).path(ComponentResource.class).path(component.getId().toString()).build(); bean.id = component.getId().toString(); bean.description = component.getDescription(); bean.name = component.getName(); return bean; }
public static ProjectCategoryJsonBean bean(final ProjectCategory projectCategoryObject, final JiraBaseUrls urls) { if (projectCategoryObject == null) { return null; } final ProjectCategoryJsonBean bean = new ProjectCategoryJsonBean(); bean.id = projectCategoryObject.getId().toString(); bean.name = projectCategoryObject.getName(); bean.description = projectCategoryObject.getDescription(); bean.self = urls.restApi2BaseUrl() + "projectCategory/" + JiraUrlCodec.encode(bean.getId()); return bean; }
public static StatusCategoryJsonBean bean(final StatusCategory statusCategory, final JiraBaseUrls baseUrls) { if (null == statusCategory) { return null; } return bean( baseUrls.restApi2BaseUrl() + "statuscategory/" + JiraUrlCodec.encode(String.valueOf(statusCategory.getId())), statusCategory.getId(), statusCategory.getKey(), statusCategory.getColorName(), statusCategory.getTranslatedName() ); }
private static void addNonRenderableStuff(CommentJsonBean bean, @Nonnull final Comment comment, final JiraBaseUrls urls, final ProjectRoleManager projectRoleManager, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { UserBeanFactory userBeanFactory = ComponentAccessor.getComponent(UserBeanFactory.class); bean.self = urls.restApi2BaseUrl() + "issue/" + comment.getIssue().getId() + "/comment/" + JiraUrlCodec.encode(comment.getId().toString()); bean.id = comment.getId().toString(); bean.author = userBeanFactory.createBean(comment.getAuthorApplicationUser(), loggedInUser, urls, emailFormatter, ComponentAccessor.getComponent(TimeZoneManager.class)); bean.updateAuthor = userBeanFactory.createBean(comment.getUpdateAuthorApplicationUser(), loggedInUser, urls, emailFormatter, ComponentAccessor.getComponent(TimeZoneManager.class)); bean.visibility = getVisibilityBean(comment, projectRoleManager); }
public static SecuritySchemeJsonBean shortBean(final IssueSecurityLevelScheme securityLevelScheme, final JiraBaseUrls urls) { SecuritySchemeJsonBean bean = new SecuritySchemeJsonBean( getSelf(urls.restApi2BaseUrl(), JiraUrlCodec.encode(securityLevelScheme.getId().toString())), securityLevelScheme.getId(), securityLevelScheme.getName(), securityLevelScheme.getDescription()); bean.setDefaultSecurityLevelId(securityLevelScheme.getDefaultSecurityLevelId()); return bean; }
/** * Takes a business issue object and returns a bean that can be serialized to the JSON representation used in our REST API. * * @param issue JIRA issue * @return issue object that can be serialized to JSON */ public IssueBean createBean(Issue issue) { final IssueBeanBuilder issueBeanBuilder = restBeanBuilderFactory.newIssueBeanBuilder(issue, IncludedFields.includeAllByDefault(null)); final JiraBaseUrls jiraBaseUrls = ComponentAccessor.getComponent(JiraBaseUrls.class); final UriBuilder uriBuilder = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()); return issueBeanBuilder.uriBuilder(uriBuilder).build(); } }
public IssueRefJsonBean createIssueRefJsonBean(final Issue issue) { return new IssueRefJsonBean() .id(String.valueOf(issue.getId())) .key(issue.getKey()) .self(URI.create(jiraBaseUrls.restApi2BaseUrl() + "issue/" + issue.getId())) .fields(new IssueRefJsonBean.Fields() .summary(issue.getSummary()) .status(StatusJsonBean.bean(issue.getStatusObject(), jiraBaseUrls)) .issueType(IssueTypeJsonBean.shortBean(issue.getIssueTypeObject(), jiraBaseUrls)) .priority(PriorityJsonBean.shortBean(issue.getPriorityObject(), jiraBaseUrls)) ); } }