private Request<?, Response> createGetIssueRequest(final String baseUri, final String issueKey, final RestVersion restVersion) throws CredentialsRequiredException { final String restUrl = new UrlBuilder(baseUri) .addPathUnsafe(REST_BASE_URL) .addPathUnsafe(restVersion.toString()) .addPathUnsafe(ISSUE_RESOURCE) .addPath(issueKey) .asUrlString(); return requestFactory.createRequest(Request.MethodType.GET, restUrl); }
/** * URL encodes and adds the given paths to the URL. If needed a '/' will be added between the existing URL and the given * paths. The paths in between the path separator ('/') will be encoded. * * @param paths paths to be encoded and added to the URL. E.g. "/one/two/three". Cannot be blank. * @return this builder so that calls may be chained * @throws IllegalArgumentException if paths is blank */ public UrlBuilder addPaths(String paths) { notBlank("paths", paths); String[] pathComponents = StringUtils.split(paths, PATH_SEPARATOR_CHAR); List<String> safePathComponents = Lists.newArrayListWithExpectedSize(pathComponents.length); for (String singlePath : pathComponents) { safePathComponents.add(encode(singlePath)); } String safePaths = StringUtils.join(safePathComponents, '/'); final boolean pathEndsWithSlash = paths.charAt(paths.length() - 1) == PATH_SEPARATOR_CHAR; if (pathEndsWithSlash) { safePaths += PATH_SEPARATOR_CHAR; } return addPathUnsafe(safePaths); }
private static ApplicationLinkRequest createGetRestResourceRequest(final ApplicationLink applicationLink, final String resourcePath, final Map<String, String> params, final RestVersion restVersion) throws CredentialsRequiredException { final UrlBuilder urlBuilder = new UrlBuilder(REST_BASE_URL) .addPathUnsafe(restVersion.toString()) .addPathUnsafe(resourcePath); return createGetURLRequest(applicationLink, urlBuilder.asUrlString(), params); }
private static ApplicationLinkRequest createCreateRemoteIssueLinkRequest(final ApplicationLink applicationLink, final String issueKey, final RestVersion restVersion) throws CredentialsRequiredException { final UrlBuilder urlBuilder = new UrlBuilder(REST_BASE_URL) .addPathUnsafe(restVersion.toString()) .addPathUnsafe(ISSUE_RESOURCE) .addPath(issueKey) .addPathUnsafe(REMOTE_LINK_RESOURCE); final String restUrl = urlBuilder.asUrlString(); final ApplicationLinkRequestFactory requestFactory = applicationLink.createAuthenticatedRequestFactory(); return requestFactory.createRequest(Request.MethodType.POST, restUrl); }
/** * URL encodes and adds the given path to the URL. If needed a '/' will be added between the existing URL and the given * path. * * @param path path to be encoded and added to the URL. The path cannot be blank. * @return this builder so that calls may be chained * @throws IllegalArgumentException if path is blank */ public UrlBuilder addPath(String path) { notBlank("path", path); String safePath = encode(StringUtils.strip(path, "/")); final boolean pathEndsWithSlash = path.charAt(path.length() - 1) == PATH_SEPARATOR_CHAR; if (pathEndsWithSlash) { safePath += PATH_SEPARATOR_CHAR; } return addPathUnsafe(safePath); }
private static String buildPageUrl(final ApplicationLink appLink, final String pageId) { return new UrlBuilder(appLink.getRpcUrl().toASCIIString()) .addPathUnsafe("pages/viewpage.action") .addParameter("pageId", pageId) .asUrlString(); } }
public static String buildIssueUrl(final String baseUri, final String issueKey) { return new UrlBuilder(baseUri) .addPathUnsafe("browse") .addPath(issueKey) .asUrlString(); }
private static ApplicationLinkRequest createGetIssueRequest(final ApplicationLink applicationLink, final String issueKey, final RestVersion restVersion) throws CredentialsRequiredException { final String restUrl = new UrlBuilder(REST_BASE_URL) .addPathUnsafe(restVersion.toString()) .addPathUnsafe(ISSUE_RESOURCE) .addPath(issueKey) .asUrlString(); final ApplicationLinkRequestFactory requestFactory = applicationLink.createAuthenticatedRequestFactory(); return requestFactory.createRequest(Request.MethodType.GET, restUrl); }
public static String buildIssueUrl(final String baseUri, final String issueKey) { return new UrlBuilder(baseUri) .addPathUnsafe("browse") .addPath(issueKey) .asUrlString(); }
private String getUrlForInitialRequest(String orgName, String slug, int changesetLimit, BitbucketChangesetPage currentPage) { UrlBuilder urlBuilder = new UrlBuilder("/api/2.0/repositories", "UTF-8", false); urlBuilder.addPath(orgName); urlBuilder.addPath(slug); urlBuilder.addPathUnsafe("/commits/"); urlBuilder.addParameter("pagelen", Integer.toString(changesetLimit)); int pageNumber = 1; if (currentPage != null && currentPage.getPage() > 0) { pageNumber = currentPage.getPage(); } urlBuilder.addParameter("page", Integer.toString(pageNumber)); return urlBuilder.asUrlString(); } }
private static ApplicationLinkRequest createCreateRemoteIssueLinkRequest(final ApplicationLink applicationLink, final String issueKey) throws CredentialsRequiredException { final UrlBuilder urlBuilder = new UrlBuilder(REST_BASE_URL) .addPath(issueKey) .addPathUnsafe(REMOTE_LINK_RESOURCE); final String restUrl = urlBuilder.asUrlString(); final ApplicationLinkRequestFactory requestFactory = applicationLink.createAuthenticatedRequestFactory(); return requestFactory.createRequest(Request.MethodType.POST, restUrl); }
.addPathUnsafe(FAVICON_PATH) .asUrlString();