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

Java HttpResponses类代码示例

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

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



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

示例1: doProvision

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
public HttpResponse doProvision(@QueryParameter String template) throws ServletException, IOException {
    checkPermission(PROVISION);
    if (template == null) {
        throw HttpResponses.error(SC_BAD_REQUEST, "The 'template' query parameter is missing");
    }
    SlaveTemplate t = getTemplate(template);
    if (t == null) {
        throw HttpResponses.error(SC_BAD_REQUEST, "No such template: " + template);
    }

    StringWriter sw = new StringWriter();
    StreamTaskListener listener = new StreamTaskListener(sw);
    try {
        EC2AbstractSlave node = t.provision(listener);
        Hudson.getInstance().addNode(node);

        return HttpResponses.redirectViaContextPath("/computer/" + node.getNodeName());
    } catch (AmazonClientException e) {
        throw HttpResponses.error(SC_INTERNAL_SERVER_ERROR, e);
    }
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:22,代码来源:EC2Cloud.java


示例2: build

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build() throws IOException {
    try {
        FreeStyleProject testProject = jenkins.createFreeStyleProject();
        when(trigger.getTriggerOpenMergeRequestOnPush()).thenReturn(TriggerOpenMergeRequest.never);
        testProject.addTrigger(trigger);

        exception.expect(HttpResponses.HttpResponseException.class);
        new PushBuildAction(testProject, getJson("PushEvent.json"), null).execute(response);
    } finally {
        ArgumentCaptor<PushHook> pushHookArgumentCaptor = ArgumentCaptor.forClass(PushHook.class);
        verify(trigger).onPost(pushHookArgumentCaptor.capture());
        assertThat(pushHookArgumentCaptor.getValue().getProject(), is(notNullValue()));
        assertThat(pushHookArgumentCaptor.getValue().getProject().getWebUrl(), is(notNullValue()));
    }
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:17,代码来源:PushBuildActionTest.java


示例3: testEvaluationWorksEvenThoughWeUsedEqualsInParameterValues

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void testEvaluationWorksEvenThoughWeUsedEqualsInParameterValues() throws IOException {
    GroovyScript listScript = new GroovyScript(new SecureGroovyScript(SCRIPT_LIST, Boolean.FALSE, null),
            new SecureGroovyScript(FALLBACK_SCRIPT_LIST, Boolean.FALSE, null));
    GroovyScript listSelectionScript = new GroovyScript(
            new SecureGroovyScript(SCRIPT_LIST_SELECTION, Boolean.FALSE, null),
            new SecureGroovyScript(FALLBACK_SCRIPT_LIST_SELECTION, Boolean.FALSE, null));
    ChoiceParameter listParam = new ChoiceParameter("LIST", "description...", "random-name1", listScript,
            CascadeChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, true, 1);
    DynamicReferenceParameter listSelectionParam = new DynamicReferenceParameter("LIST_SELECTION", "description...",
            "random-name2", listSelectionScript, CascadeChoiceParameter.ELEMENT_TYPE_FORMATTED_HIDDEN_HTML, "LIST",
            true);
    // should be a String
    String listValue = listParam.getDefaultParameterValue().getValue().toString();
    try {
        listSelectionParam.doUpdate(String.format(String.format("%s=%s", listParam.getName(), listValue)));
    } catch (HttpResponses.HttpResponseException response) {
        // ignore
    }
    // as this is a formatted hidden HTML...
    String listSelectionValue = listSelectionParam.getChoicesAsString();

    // by default, the plug-in returns the first element in the list...
    assertEquals("Value returned from selection list doesn't match first element in list parameter", "A=1",
            listSelectionValue);
}
 
开发者ID:imoutsatsos,项目名称:uno-choice-plugin,代码行数:27,代码来源:TestParameterValuesWithEquals.java


示例4: doFinishLogin

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
public HttpResponse doFinishLogin(StaplerRequest request, StaplerResponse rsp) throws IOException {

        String code = request.getParameter("code");

        if (code == null || code.trim().length() == 0) {
            Log.info("doFinishLogin: missing code.");
            return HttpResponses.redirectToContextRoot();
        }

        String content = postForAccessToken(code);

        String accessToken = extractToken(content);
        updateOfflineAccessTokenForUser(accessToken);
        request.getSession().setAttribute("access_token", accessToken);

        String newProjectSetupUrl = getJenkinsRootUrl() + "/" + GithubReposController.URL;
        return HttpResponses.redirectTo(newProjectSetupUrl);
    }
 
开发者ID:groupon,项目名称:DotCi,代码行数:19,代码来源:GithubOauthLoginAction.java


示例5: extractListenerId

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
private String extractListenerId(StaplerRequest req) {
    String path = req.getRestOfPath();
    String id = getListenerId(path.substring(1));
    if (id == null) {
        throw HttpResponses.notFound();
    }

    return id;
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:10,代码来源:GitLabSCMWebHook.java


示例6: doFinishLogin

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
public HttpResponse doFinishLogin(StaplerRequest request) throws IOException {
    String code = request.getParameter("code");
    
    if (StringUtils.isBlank(code)) {
        LOGGER.log(Level.SEVERE, "doFinishLogin() code = null");
        return HttpResponses.redirectToContextRoot();
    }

    DeepinToken token = new DeepinOAuthApiService(clientID, clientSecret).getTokenByAuthorizationCode(code);

    if (!token.accessToken.isEmpty()) {
        DeepinAuthenticationToken auth = new DeepinAuthenticationToken(token, clientID, clientSecret);
        SecurityContextHolder.getContext().setAuthentication(auth);
        User u = User.current();
        u.setFullName(auth.getName());
    } else {
        LOGGER.log(Level.SEVERE, "doFinishLogin() accessToken = null");
    }

    // redirect to referer
    String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE);
    if (referer != null) {
        return HttpResponses.redirectTo(referer);
    } else {
        return HttpResponses.redirectToContextRoot();
    }
}
 
开发者ID:Iceyer,项目名称:deepin-oauth-plugin,代码行数:28,代码来源:DeepinSecurityRealm.java


示例7: doSubmitContainerStatus

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
/**
 * Submits a new event through Jenkins API.
 * @param inspectData JSON output of docker inspect container (array of container infos)
 * @param hostName Optional name of the host, which submitted the event
 *      &quot;unknown&quot; by default
 * @param hostId Optional host ID. 
 *      &quot;unknown&quot; by default
 * @param status Optional status of the container. 
 *      By default, an artificial {@link DockerEventType#NONE} will be used.    
 * @param time Optional time when the event happened. 
 *      The time is specified in seconds since January 1, 1970, 00:00:00 GMT
 *      Default value - current time
 * @param environment Optional field, which describes the environment
 * @param imageName Optional field, which provides the name of the image
 * @return {@link HttpResponse}
 * @throws IOException Request processing error
 * @throws ServletException Servlet error
 */
//TODO: parameters check
@RequirePOST
public HttpResponse doSubmitContainerStatus(
        @QueryParameter(required = true) String inspectData,
        @QueryParameter(required = false) String hostId,
        @QueryParameter(required = false) String hostName,
        @QueryParameter(required = false) String status,
        @QueryParameter(required = false) long time,
        @QueryParameter(required = false) @CheckForNull String environment,
        @QueryParameter(required = false) @CheckForNull String imageName
) throws IOException, ServletException { 
    checkPermission(DockerTraceabilityPlugin.SUBMIT);
    final ObjectMapper mapper = new ObjectMapper();
    final InspectContainerResponse[] inspectContainerResponses = mapper.readValue(inspectData, InspectContainerResponse[].class);
    final long eventTime = time != 0 ? time : System.currentTimeMillis()/1000;
    final String effectiveHostName = StringUtils.isNotBlank(hostName) ? hostName : "unknown";
    final String effectiveHostId = StringUtils.isNotBlank(hostId) ? hostId : "unknown";
    final String effectiveStatus = StringUtils.isNotBlank(status) 
            ? status.toUpperCase(Locale.ENGLISH) : DockerEventType.NONE.toString();
    final String effectiveImageName = hudson.Util.fixEmpty(imageName);
    final String effectiveEnvironment = hudson.Util.fixEmpty(environment);
    
    
    for (InspectContainerResponse inspectContainerResponse : inspectContainerResponses) {
        final Event event = new DockerEvent(effectiveStatus, inspectContainerResponse.getImageId(), 
                effectiveHostId, eventTime).toDockerEvent();
        final Info hostInfo = new DockerInfo(effectiveHostId, effectiveHostName).toInfo();

        DockerTraceabilityReport res = new DockerTraceabilityReport(event, hostInfo,
                inspectContainerResponse, 
                inspectContainerResponse.getImageId(), effectiveImageName,
                /* InspectImageResponse */ null, new LinkedList<String>(), effectiveEnvironment);
        DockerTraceabilityReportListener.fire(res);
    }
    return HttpResponses.ok();
}
 
开发者ID:jenkinsci,项目名称:docker-traceability-plugin,代码行数:55,代码来源:DockerTraceabilityRootAction.java


示例8: doSubmitReport

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
/**
 * Submits a new {@link DockerTraceabilityReport} via API.
 * @param json String representation of {@link DockerTraceabilityReport}
 * @return {@link HttpResponse}
 * @throws ServletException Servlet error
 * @throws IOException Processing error
 */
@RequirePOST
public HttpResponse doSubmitReport(@QueryParameter(required = true) String json) 
        throws IOException, ServletException { 
    checkPermission(DockerTraceabilityPlugin.SUBMIT);
    ObjectMapper mapper = new ObjectMapper();
    final DockerTraceabilityReport report = mapper.readValue(json, DockerTraceabilityReport.class);
    DockerTraceabilityReportListener.fire(report);
    return HttpResponses.ok();
}
 
开发者ID:jenkinsci,项目名称:docker-traceability-plugin,代码行数:17,代码来源:DockerTraceabilityRootAction.java


示例9: doDeleteContainer

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
/**
 * Removes the container reference from the registry.
 * @param id Container ID. Method supports full 64-char IDs only.
 * @throws IOException Cannot save the updated {@link DockerTraceabilityRootAction}
 * @throws ServletException Servlet exception
 * @return response
 */
@RequirePOST
public HttpResponse doDeleteContainer(@QueryParameter(required = true) String id) 
        throws IOException, ServletException {  
    checkPermission(DockerTraceabilityPlugin.DELETE);
    removeContainerID(id);
    return HttpResponses.ok();
}
 
开发者ID:jenkinsci,项目名称:docker-traceability-plugin,代码行数:15,代码来源:DockerTraceabilityRootAction.java


示例10: doRawImageInfo

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
/**
 * Retrieves the latest raw status via API.
 * The output will be retrieved in JSON.
 * @param id ID of the image, for which the info should be retrieved.
 *    Short container IDs are not supported.
 * @throws IOException Processing error
 * @throws ServletException Servlet error
 * @return {@link HttpResponse}
 */
public HttpResponse doRawImageInfo(@QueryParameter(required = true) String id) 
        throws IOException, ServletException {     
    checkPermission(DockerTraceabilityPlugin.READ_DETAILS);
    
    final InspectImageResponse report = DockerTraceabilityHelper.getLastInspectImageResponse(id);
    if (report == null) {   
        return HttpResponses.error(404, "No info available for the imageId=" + id);
    }
    
    // Return raw JSON in the response
    InspectImageResponse[] out = {report};
    return toJSONResponse(out);
}
 
开发者ID:jenkinsci,项目名称:docker-traceability-plugin,代码行数:23,代码来源:DockerTraceabilityRootAction.java


示例11: doBuildJob

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
public HttpResponse doBuildJob(@QueryParameter String issueId) {

		@SuppressWarnings("rawtypes")
		AbstractProject project = PayLoadInterceptorAction.getMatchingJob(issueId);
		if (project != null && project.isBuildable()) {
			project.scheduleBuild2(0);
		}
		return HttpResponses.plainText("Buld triggered: "+issueId);
	}
 
开发者ID:ivanoronee,项目名称:jenkins-jira-builder,代码行数:10,代码来源:Root.java


示例12: build

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build() throws IOException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);

    exception.expect(HttpResponses.HttpResponseException.class);
    new NoteBuildAction(testProject, getJson("NoteEvent.json"), null).execute(response);

    verify(trigger).onPost(any(NoteHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:11,代码来源:NoteBuildActionTest.java


示例13: build_alreadyBuiltMR_alreadyBuiltMR

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build_alreadyBuiltMR_alreadyBuiltMR() throws IOException, ExecutionException, InterruptedException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);
    testProject.setScm(new GitSCM(gitRepoUrl));
    QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new ParametersAction(new StringParameterValue("gitlabTargetBranch", "master")));
    future.get();

    exception.expect(HttpResponses.HttpResponseException.class);
    new NoteBuildAction(testProject, getJson("NoteEvent_alreadyBuiltMR.json"), null).execute(response);

    verify(trigger).onPost(any(NoteHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:14,代码来源:NoteBuildActionTest.java


示例14: build_alreadyBuiltMR_differentTargetBranch

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build_alreadyBuiltMR_differentTargetBranch() throws IOException, ExecutionException, InterruptedException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);
    testProject.setScm(new GitSCM(gitRepoUrl));
    QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new GitLabWebHookCause(causeData()
            .withActionType(CauseData.ActionType.NOTE)
            .withSourceProjectId(1)
            .withTargetProjectId(1)
            .withBranch("feature")
            .withSourceBranch("feature")
            .withUserName("")
            .withSourceRepoHomepage("https://gitlab.org/test")
            .withSourceRepoName("test")
            .withSourceNamespace("test-namespace")
            .withSourceRepoUrl("[email protected]:test.git")
            .withSourceRepoSshUrl("[email protected]:test.git")
            .withSourceRepoHttpUrl("https://gitlab.org/test.git")
            .withMergeRequestTitle("Test")
            .withMergeRequestId(1)
            .withMergeRequestIid(1)
            .withTargetBranch("master")
            .withTargetRepoName("test")
            .withTargetNamespace("test-namespace")
            .withTargetRepoSshUrl("[email protected]:test.git")
            .withTargetRepoHttpUrl("https://gitlab.org/test.git")
            .withTriggeredByUser("test")
            .withLastCommit("123")
            .withTargetProjectUrl("https://gitlab.org/test")
            .build()));
    future.get();

    exception.expect(HttpResponses.HttpResponseException.class);
    new NoteBuildAction(testProject, getJson("NoteEvent_alreadyBuiltMR.json"), null).execute(response);

    verify(trigger).onPost(any(NoteHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:38,代码来源:NoteBuildActionTest.java


示例15: build

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build() throws IOException {
    try {
        FreeStyleProject testProject = jenkins.createFreeStyleProject();
        testProject.addTrigger(trigger);

        exception.expect(HttpResponses.HttpResponseException.class);
        new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent.json"), null).execute(response);
    } finally {
        ArgumentCaptor<MergeRequestHook> pushHookArgumentCaptor = ArgumentCaptor.forClass(MergeRequestHook.class);
        verify(trigger).onPost(pushHookArgumentCaptor.capture());
        assertThat(pushHookArgumentCaptor.getValue().getProject(), is(notNullValue()));
        assertThat(pushHookArgumentCaptor.getValue().getProject().getWebUrl(), is(notNullValue()));
    }
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:16,代码来源:MergeRequestBuildActionTest.java


示例16: skip_closedMR

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void skip_closedMR() throws IOException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);

    exception.expect(HttpResponses.HttpResponseException.class);
    new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent_closedMR.json"), null).execute(response);

    verify(trigger, never()).onPost(any(MergeRequestHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:11,代码来源:MergeRequestBuildActionTest.java


示例17: skip_alreadyBuiltMR

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void skip_alreadyBuiltMR() throws IOException, ExecutionException, InterruptedException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);
    testProject.setScm(new GitSCM(gitRepoUrl));
    QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new ParametersAction(new StringParameterValue("gitlabTargetBranch", "master")));
    future.get();

    exception.expect(HttpResponses.HttpResponseException.class);
    new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent_alreadyBuiltMR.json"), null).execute(response);

    verify(trigger, never()).onPost(any(MergeRequestHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:14,代码来源:MergeRequestBuildActionTest.java


示例18: build_alreadyBuiltMR_differentTargetBranch

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void build_alreadyBuiltMR_differentTargetBranch() throws IOException, ExecutionException, InterruptedException {
    FreeStyleProject testProject = jenkins.createFreeStyleProject();
    testProject.addTrigger(trigger);
    testProject.setScm(new GitSCM(gitRepoUrl));
    QueueTaskFuture<?> future = testProject.scheduleBuild2(0, new GitLabWebHookCause(causeData()
            .withActionType(CauseData.ActionType.MERGE)
            .withSourceProjectId(1)
            .withTargetProjectId(1)
            .withBranch("feature")
            .withSourceBranch("feature")
            .withUserName("")
            .withSourceRepoHomepage("https://gitlab.org/test")
            .withSourceRepoName("test")
            .withSourceNamespace("test-namespace")
            .withSourceRepoUrl("[email protected]:test.git")
            .withSourceRepoSshUrl("[email protected]:test.git")
            .withSourceRepoHttpUrl("https://gitlab.org/test.git")
            .withMergeRequestTitle("Test")
            .withMergeRequestId(1)
            .withMergeRequestIid(1)
            .withTargetBranch("master")
            .withTargetRepoName("test")
            .withTargetNamespace("test-namespace")
            .withTargetRepoSshUrl("[email protected]:test.git")
            .withTargetRepoHttpUrl("https://gitlab.org/test.git")
            .withTriggeredByUser("test")
            .withLastCommit("123")
            .withTargetProjectUrl("https://gitlab.org/test")
            .build()));
    future.get();

    exception.expect(HttpResponses.HttpResponseException.class);
    new MergeRequestBuildAction(testProject, getJson("MergeRequestEvent_alreadyBuiltMR.json"), null).execute(response);

    verify(trigger).onPost(any(MergeRequestHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:38,代码来源:MergeRequestBuildActionTest.java


示例19: buildOnSuccess

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void buildOnSuccess () throws IOException {
    exception.expect(HttpResponses.HttpResponseException.class);
    new PipelineBuildAction(testProject, getJson("PipelineEvent.json"), null).execute(response);

    verify(trigger).onPost(any(PipelineHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:8,代码来源:PipelineBuildActionTest.java


示例20: doNotBuildOnFailure

import org.kohsuke.stapler.HttpResponses; //导入依赖的package包/类
@Test
public void doNotBuildOnFailure() throws IOException {
    exception.expect(HttpResponses.HttpResponseException.class);
    new PipelineBuildAction(testProject, getJson("PipelineFailureEvent.json"), null).execute(response);

    verify(trigger, never()).onPost(any(PipelineHook.class));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:8,代码来源:PipelineBuildActionTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JMXEnabledThreadPoolExecutor类代码示例发布时间:2022-05-22
下一篇:
Java SimpleEventBus类代码示例发布时间: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