@Nonnull public static Predicate<ReadOnlyApplicationLink> withRpcUrl(@Nonnull final URI rpcUrl) { checkNotNull(rpcUrl, "rpcUrl"); return link -> link != null && rpcUrl.equals(link.getRpcUrl()); }
/** * Get xml channel impersonally, always return fresh data. * * @param jqlQuery jql pass to jira server * @param appLink jira server connection * @return Channel */ public Channel getChannel(ReadOnlyApplicationLink appLink, String jqlQuery, int maxResult) { String hostName = appLink.getRpcUrl().toString(); String requestJiraUrl = hostName + XML_SEARCH_REQUEST_URI + jqlQuery + "&tempMax=" + maxResult; try { // fix for CONFDEV-20458, by changing cache parameter to false return jiraIssuesManager.retrieveXMLAsChannel(requestJiraUrl, DEFAULT_COLUMNS, appLink, false, false); } catch (CredentialsRequiredException e) { return getChannelByAnonymous(requestJiraUrl, appLink); } catch (Exception e) { LOGGER.error("Can not retrieve jira issues", e); } return null; }
private static void stub(ReadOnlyApplicationLink mockValue, MockApplink mockApplink) { String id = getId(mockApplink); ApplicationType applicationType = getType(mockApplink); when(mockValue.getId()).thenReturn(new ApplicationId(id)); when(mockValue.getName()).thenReturn(getName(mockApplink, id)); when(mockValue.getDisplayUrl()).thenReturn(URI.create(getUrl(mockApplink, id))); when(mockValue.getRpcUrl()).thenReturn(URI.create(getRpcUrl(mockApplink, id))); when(mockValue.getType()).thenReturn(applicationType); }
/** * The service retrieves all projects of server. * REST URL: /jirareports/1.0/appLink/{appLinkId}/projects * * @param appLinkId applink id to gain jira server * @return list of projects */ @GET @Path("appLink/{appLinkId}/projects") public Response getProjectsByAppLinkId(@PathParam("appLinkId") String appLinkId) { ReadOnlyApplicationLink appLink = null; String url = null; try { appLink = appLinkService.getApplicationLink(new ApplicationId(appLinkId)); url = appLink.getRpcUrl() + PROJECT_REST_URI; String projects = requestJiraByAuthenticatedUser(appLink, url); return Response.ok(projects).build(); } catch (CredentialsRequiredException e) { String projects = requestJiraByAnonymousUser(appLink, url); return buildUnAuthenticatedResponse(projects, e.getAuthorisationURI().toString()); } catch (Exception e) { LOG.info("Can not retrieve projects", e); return Response.status(HttpStatus.SC_BAD_REQUEST).build(); } }
/** * The service retrieves all versions of project. * REST URL: /jirareports/1.0/appLink/{appLinkId}/appLink/{appLinkId}/project/{projectKey}/versions * * @param appLinkId applink id to gain jira server * @param projectKey project key is maps in jira server * @return list of versions */ @GET @Path("appLink/{appLinkId}/project/{projectKey}/versions") public Response getVersionsByKeyProject(@PathParam("appLinkId") String appLinkId, @PathParam("projectKey") String projectKey) { ReadOnlyApplicationLink appLink = null; String url = null; try { appLink = appLinkService.getApplicationLink(new ApplicationId(appLinkId)); url = appLink.getRpcUrl() + PROJECT_REST_URI + "/" + projectKey + "/versions"; String versions = requestJiraByAuthenticatedUser(appLink, url); return Response.ok(versions).build(); } catch (CredentialsRequiredException e) { String versions = requestJiraByAnonymousUser(appLink, url); return buildUnAuthenticatedResponse(versions, e.getAuthorisationURI().toString()); } catch (Exception e) { LOG.info("Can not retrieve versions", e); return Response.status(HttpStatus.SC_BAD_REQUEST).build(); } }