• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WsClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.sonarqube.ws.client.WsClient的典型用法代码示例。如果您正苦于以下问题:Java WsClient类的具体用法?Java WsClient怎么用?Java WsClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WsClient类属于org.sonarqube.ws.client包,在下文中一共展示了WsClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: forEachIssue

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
/**
 * Loop over issues.
 * 
 * @param localConnector
 *            local connector
 * @param searchIssuesRequest
 *            search request
 * @param consumer
 *            callback called for each issues
 */
public static void forEachIssue(final LocalConnector localConnector, final SearchWsRequest searchIssuesRequest,
		final BiConsumer<SearchWsResponse, Issue> consumer) {
	// Loop through all issues of the project
	final WsClient wsClient = WsClientFactories.getLocal().newClient(localConnector);

	boolean doNextPage = true;
	while (doNextPage) {
		LOGGER.debug("Listing issues for project {}; page {}", searchIssuesRequest.getProjectKeys(),
				searchIssuesRequest.getPage());
		final SearchWsResponse searchIssuesResponse = wsClient.issues().search(searchIssuesRequest);
		for (final Issue issue : searchIssuesResponse.getIssuesList()) {
			consumer.accept(searchIssuesResponse, issue);
		}

		doNextPage = searchIssuesResponse.getPaging().getTotal() > (searchIssuesResponse.getPaging().getPageIndex()
				* searchIssuesResponse.getPaging().getPageSize());
		searchIssuesRequest.setPage(searchIssuesResponse.getPaging().getPageIndex() + 1);
		searchIssuesRequest.setPageSize(searchIssuesResponse.getPaging().getPageSize());
	}
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:31,代码来源:IssueHelper.java


示例2: resolveIssues

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
/**
 * Resolve issues.
 * 
 * @param localConnector
 *            local connector
 * @param importResult
 *            result
 * @param preview
 *            true if issues should not be actually resolved.
 * @param skipAssign
 *            if true, no assignments will be done
 * @param skipComments
 *            if true, no comments will be added
 * @param projectKey
 *            project key
 * @param issues
 *            issues
 */
public static void resolveIssues(final LocalConnector localConnector, final ImportResult importResult,
		final boolean preview, final boolean skipAssign, final boolean skipComments, final String projectKey,
		final Map<IssueKey, IssueData> issues) {
	// Read issues from project, match and resolve
	importResult.setPreview(preview);

	final WsClient wsClient = WsClientFactories.getLocal().newClient(localConnector);

	// Loop through all issues of the project
	final SearchWsRequest searchIssuesRequest = SearchHelper.findIssuesForImport(projectKey);

	forEachIssue(localConnector, searchIssuesRequest, (searchIssuesResponse, issue) -> {
		final IssueKey key = IssueKey.fromIssue(issue, searchIssuesResponse.getComponentsList());
		LOGGER.debug("Try to match issue: {}", key);
		// Match with issue from data
		final IssueData data = issues.remove(key);

		if (data != null) {
			importResult.registerMatchedIssue();

			// Handle issue, if data is found
			handleTransition(wsClient.wsConnector(), issue, data.getStatus(), data.getResolution(), preview,
					importResult);
			if (!skipAssign) {
				handleAssignee(wsClient.wsConnector(), issue, data.getAssignee(), preview, importResult);
			}
			if (!skipComments) {
				handleComments(wsClient.wsConnector(), issue, data.getComments(), preview, importResult);
			}
		}
	});
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:51,代码来源:IssueHelper.java


示例3: newAdminWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
public static WsClient newAdminWsClient(Orchestrator orchestrator) {
  Server server = orchestrator.getServer();
  return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
    .url(server.getUrl())
    .credentials(Server.ADMIN_LOGIN, Server.ADMIN_PASSWORD)
    .build());
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:8,代码来源:ItUtils.java


示例4: handle

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
@Override
public void handle(final Request request, final Response response) throws Exception {
    if (this.settings.getBoolean(BadgesPluginProperties.GATE_BADGES_ACTIVATION_KEY)) {
        final String key = request.mandatoryParam("key");
        final SVGImageTemplate template = request.mandatoryParamAsEnum("template", SVGImageTemplate.class);
        final boolean blinkingValueBackgroundColor = request.mandatoryParamAsBoolean("blinking");
        final WsClient wsClient = WsClientFactories.getLocal()
            .newClient(request.localConnector());
        LOGGER.debug("Retrieving quality gate status for key '{}'.", key);
        QualityGateBadge status = QualityGateBadge.NOT_FOUND;
        try {
            final ProjectStatusWsRequest wsRequest = new ProjectStatusWsRequest();
            wsRequest.setProjectKey(key);
            final ProjectStatusWsResponse wsResponse = wsClient.qualityGates()
                .projectStatus(wsRequest);
            status = QualityGateBadge.valueOf(wsResponse.getProjectStatus()
                .getStatus()
                .toString());
        } catch (final HttpException e) {
            LOGGER.debug("No project found with key '{}': {}", key, e);
        }
        // we prepare the response OutputStream
        final OutputStream responseOutputStream = response.stream()
            .setMediaType("image/svg+xml")
            .output();
        LOGGER.debug("Retrieving SVG image for for quality gate status '{}'.", status);
        final InputStream svgImageInputStream = this.qualityGateBadgeGenerator.svgImageInputStreamFor(status, template, blinkingValueBackgroundColor);
        LOGGER.debug("Writing SVG image to response OutputStream.");
        IOUtils.copy(svgImageInputStream, responseOutputStream);
        responseOutputStream.close();
        // don't close svgImageInputStream, we want it to be reusable
    } else {
        LOGGER.warn("Received a gate badge request, but webservice is turned off.");
        response.noContent();
    }

}
 
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-badges,代码行数:38,代码来源:QualityGateBadgeRequestHandler.java


示例5: handle

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
@Override
public void handle(final Request request, final Response response) throws Exception {
    if (this.settings.getBoolean(BadgesPluginProperties.MEASURE_BADGES_ACTIVATION_KEY)) {
        final String key = request.mandatoryParam("key");
        final String metric = request.mandatoryParam("metric");
        final SVGImageTemplate template = request.mandatoryParamAsEnum("template", SVGImageTemplate.class);
        final boolean blinkingValueBackgroundColor = request.mandatoryParamAsBoolean("blinking");
        final WsClient wsClient = WsClientFactories.getLocal()
            .newClient(request.localConnector());
        LOGGER.debug("Retrieving measure for key '{}' and metric {}.", key, metric);
        MeasureHolder measureHolder;
        try {
            measureHolder = retrieveMeasureHolder(wsClient, key, metric);
            measureHolder = applyQualityGateTreshold(wsClient, key, metric, measureHolder);
        } catch (final HttpException e) {
            LOGGER.debug("No project found with key '{}': {}", key, e);
            measureHolder = new MeasureHolder(metric);
        }
        // we prepare the response OutputStream
        final OutputStream responseOutputStream = response.stream()
            .setMediaType("image/svg+xml")
            .output();
        LOGGER.debug("Retrieving SVG image for metric holder '{}'.", measureHolder);
        final InputStream svgImageInputStream = this.measureBadgeGenerator.svgImageInputStreamFor(measureHolder, template, blinkingValueBackgroundColor);
        LOGGER.debug("Writing SVG image to response OutputStream.");
        IOUtils.copy(svgImageInputStream, responseOutputStream);
        responseOutputStream.close();
        // don't close svgImageInputStream, we want it to be reusable
    } else {
        LOGGER.warn("Received a measure badge request, but webservice is turned off.");
        response.noContent();
    }
}
 
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-badges,代码行数:34,代码来源:MeasureBadgeRequestHandler.java


示例6: applyQualityGateTreshold

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
private MeasureHolder applyQualityGateTreshold(final WsClient wsClient, final String key, final String metric, final MeasureHolder measureHolder) {
    final ProjectStatusWsRequest projectStatusWsRequest = new ProjectStatusWsRequest();
    projectStatusWsRequest.setProjectKey(key);
    final ProjectStatusWsResponse projectStatusWsResponse = wsClient.qualityGates()
        .projectStatus(projectStatusWsRequest);
    final List<Condition> conditions = projectStatusWsResponse.getProjectStatus()
        .getConditionsList();
    for (final Condition condition : conditions) {
        if (metric.equals(condition.getMetricKey())) {
            final Status status = condition.getStatus();
            switch (status) {
                case ERROR:
                    measureHolder.setBackgroundColor(SVGImageColor.RED);
                    break;
                case OK:
                    measureHolder.setBackgroundColor(SVGImageColor.GREEN);
                    break;
                case WARN:
                    measureHolder.setBackgroundColor(SVGImageColor.ORANGE);
                    break;
                default:
                    measureHolder.setBackgroundColor(SVGImageColor.GRAY);
                    break;

            }
        }
    }
    return measureHolder;
}
 
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-badges,代码行数:30,代码来源:MeasureBadgeRequestHandler.java


示例7: retrieveCeActivityBadge

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
private CeActivityBadge retrieveCeActivityBadge(final Request request, final String key) {
    CeActivityBadge ceActivityBadge = CeActivityBadge.NOT_FOUND;
    try {
        final WsClient wsClient = WsClientFactories.getLocal()
            .newClient(request.localConnector());
        final ActivityWsRequest wsRequest = new ActivityWsRequest();
        wsRequest.setQuery(key);
        wsRequest.setOnlyCurrents(true);
        final CeService ceService = wsClient.ce();
        final ActivityResponse activityResponse = ceService.activity(wsRequest);
        if (activityResponse.getTasksCount() >= 1) {
            // The task are ordered by date. 0 is the most recent.
            final Task task = activityResponse.getTasks(0);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("CeActivity Task Information");
                LOGGER.debug("CeActivity Task - id: " + task.getId());
                LOGGER.debug("CeActivity Task - type: " + task.getType());
                LOGGER.debug("CeActivity Task - componentId: " + task.getComponentId());
                LOGGER.debug("CeActivity Task - componentKey: " + task.getComponentKey());
                LOGGER.debug("CeActivity Task - componentName: " + task.getComponentName());
                LOGGER.debug("CeActivity Task - componentQualifier: " + task.getComponentQualifier());
                LOGGER.debug("CeActivity Task - analysisId: " + task.getAnalysisId());
                LOGGER.debug("CeActivity Task - status: " + task.getStatus());
                LOGGER.debug("CeActivity Task - submittedAt: " + task.getSubmittedAt());
                LOGGER.debug("CeActivity Task - submitterLogin: " + task.getSubmitterLogin());
                LOGGER.debug("CeActivity Task - startedAt: " + task.getStartedAt());
                LOGGER.debug("CeActivity Task - executedAt: " + task.getExecutedAt());
                LOGGER.debug("CeActivity Task - executionTimeMs: " + task.getExecutionTimeMs());
            }
            // status of the activity
            ceActivityBadge = CeActivityBadge.valueOf(task.getStatus()
                .toString());
        }
    } catch (final HttpException e) {
        LOGGER.debug("No project found with key '{}': {}", key, e);
    }
    return ceActivityBadge;
}
 
开发者ID:QualInsight,项目名称:qualinsight-plugins-sonarqube-badges,代码行数:39,代码来源:CeActivityBadgeRequestHandler.java


示例8: newWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
static WsClient newWsClient() {
  return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
    .url(ORCHESTRATOR.getServer().getUrl())
    .build());
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:6,代码来源:Tests.java


示例9: TestSonarClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
public TestSonarClient(WsClient wsClient, String project) {
    this.wsClient = wsClient;
    this.project = project;
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:5,代码来源:TestSonarClient.java


示例10: newWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
static WsClient newWsClient() {
  return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
    .url(orchestrator.getServer().getUrl())
    .build());
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:6,代码来源:AbstractMavenTest.java


示例11: newWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
private static WsClient newWsClient() {
  return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
    .url(ORCHESTRATOR.getServer().getUrl())
    .build());
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:6,代码来源:Tests.java


示例12: newWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
protected static WsClient newWsClient() {
  return newWsClient(null, null);
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:4,代码来源:XmlTestSuite.java


示例13: newAdminWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
protected static WsClient newAdminWsClient() {
  return newWsClient(ADMIN_LOGIN, ADMIN_PASSWORD);
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:4,代码来源:XmlTestSuite.java


示例14: newWsClient

import org.sonarqube.ws.client.WsClient; //导入依赖的package包/类
static WsClient newWsClient(Orchestrator orchestrator) {
  return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
    .url(orchestrator.getServer().getUrl())
    .build());
}
 
开发者ID:SonarSource,项目名称:sonar-web,代码行数:6,代码来源:WebTestSuite.java



注:本文中的org.sonarqube.ws.client.WsClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileURLMapper类代码示例发布时间:2022-05-22
下一篇:
Java ClientDatanodeProtocolService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap