當前位置: 首頁>>代碼示例>>Java>>正文


Java StaplerRequest.hasParameter方法代碼示例

本文整理匯總了Java中org.kohsuke.stapler.StaplerRequest.hasParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java StaplerRequest.hasParameter方法的具體用法?Java StaplerRequest.hasParameter怎麽用?Java StaplerRequest.hasParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.stapler.StaplerRequest的用法示例。


在下文中一共展示了StaplerRequest.hasParameter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUsernameFromAuthCode

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
@SuppressWarnings("unused")
public String getUsernameFromAuthCode() {
    final StaplerRequest request = Stapler.getCurrentRequest();
    if (request.hasParameter(getCodeParamKey())) {
        final User user = getUserForActivationCode(request.getParameter(getCodeParamKey()));
        if (user != null) {
            return user.getId();
        }
    }
    return "";
}
 
開發者ID:inFullMobile,項目名稱:restricted-register-plugin,代碼行數:12,代碼來源:HudsonSecurityRealmRegistration.java

示例2: isGetParamSecretValid

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
public static boolean isGetParamSecretValid() {
    String secret = null;
    final StaplerRequest request = Stapler.getCurrentRequest();
    if (request.hasParameter(BaseFormField.SECRET.getFieldName())) {
        secret = request.getParameter(BaseFormField.SECRET.getFieldName());
    }
    return isSecretKeyValid(secret);
}
 
開發者ID:inFullMobile,項目名稱:restricted-register-plugin,代碼行數:9,代碼來源:SecretKeyChecker.java

示例3: doBuild

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
@Override
public FormValidation doBuild(StaplerRequest req) throws IOException {
    FormValidation result;

    try {
        Jenkins instance = GitHubWebHook.getJenkinsInstance();
        if (!instance.hasPermission(Item.BUILD)) {
            return FormValidation.error("Forbidden");
        }

        final String prNumberParam = "prNumber";
        int prId = 0;
        if (req.hasParameter(prNumberParam)) {
            prId = Integer.valueOf(req.getParameter(prNumberParam));
        }

        if (prId == 0 || !getPulls().containsKey(prId)) {
            return FormValidation.error("No branch to build");
        }

        final GitHubPRPullRequest localPR = getPulls().get(prId);
        final GitHubPRCause cause = new GitHubPRCause(localPR, null, false, "Manual run.");

        final JobRunnerForCause runner = new JobRunnerForCause(getJob(), ghPRTriggerFromJob(getJob()));
        final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);

        if (nonNull(queueTaskFuture)) {
            result = FormValidation.ok("Build scheduled");
        } else {
            result = FormValidation.warning("Build not scheduled");
        }
    } catch (Exception e) {
        LOG.error("Can't start build", e.getMessage());
        result = FormValidation.error(e, "Can't start build: " + e.getMessage());
    }

    return result;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:39,代碼來源:GitHubPRRepository.java

示例4: doRebuild

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
@RequirePOST
public FormValidation doRebuild(StaplerRequest req) throws IOException {
    FormValidation result;

    try {
        Jenkins instance = GitHubWebHook.getJenkinsInstance();
        if (!instance.hasPermission(Item.BUILD)) {
            return FormValidation.error("Forbidden");
        }

        final String prNumberParam = "prNumber";
        int prId = 0;
        if (req.hasParameter(prNumberParam)) {
            prId = Integer.valueOf(req.getParameter(prNumberParam));
        }

        Map<Integer, List<Run<?, ?>>> builds = getAllPrBuilds();
        List<Run<?, ?>> prBuilds = builds.get(prId);
        if (prBuilds != null && !prBuilds.isEmpty()) {
            if (rebuild(prBuilds.get(0))) {
                result = FormValidation.ok("Rebuild scheduled");
            } else {
                result = FormValidation.warning("Rebuild not scheduled");
            }
        } else {
            result = FormValidation.warning("Build not found");
        }
    } catch (Exception e) {
        LOG.error("Can't start rebuild", e);
        result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage());
    }
    return result;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:34,代碼來源:GitHubPRRepository.java

示例5: doBuild

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
@RequirePOST
public FormValidation doBuild(StaplerRequest req) throws IOException {
    FormValidation result;

    try {
        Jenkins instance = GitHubWebHook.getJenkinsInstance();
        if (!instance.hasPermission(Item.BUILD)) {
            return FormValidation.error("Forbidden");
        }

        final String param = "branchName";
        String branchName = null;
        if (req.hasParameter(param)) {
            branchName = req.getParameter(param);
        }
        if (isNull(branchName) || !getBranches().containsKey(branchName)) {
            return FormValidation.error("No branch to build");
        }

        final GitHubBranch localBranch = getBranches().get(branchName);
        final GitHubBranchCause cause = new GitHubBranchCause(localBranch, this, "Manual run.", false);
        final JobRunnerForBranchCause runner = new JobRunnerForBranchCause(getJob(),
                ghBranchTriggerFromJob(getJob()));
        final QueueTaskFuture<?> queueTaskFuture = runner.startJob(cause);

        if (nonNull(queueTaskFuture)) {
            result = FormValidation.ok("Build scheduled");
        } else {
            result = FormValidation.warning("Build not scheduled");
        }
    } catch (Exception e) {
        LOG.error("Can't start build", e.getMessage());
        result = FormValidation.error(e, "Can't start build: " + e.getMessage());
    }

    return result;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:38,代碼來源:GitHubBranchRepository.java

示例6: doRebuild

import org.kohsuke.stapler.StaplerRequest; //導入方法依賴的package包/類
@Override
@RequirePOST
public FormValidation doRebuild(StaplerRequest req) throws IOException {
    FormValidation result;

    try {
        Jenkins instance = GitHubWebHook.getJenkinsInstance();
        if (!instance.hasPermission(Item.BUILD)) {
            return FormValidation.error("Forbidden");
        }

        final String param = "branchName";
        String branchName = "";
        if (req.hasParameter(param)) {
            branchName = req.getParameter(param);
        }

        Map<String, List<Run<?, ?>>> allBuilds = getAllBranchBuilds();
        List<Run<?, ?>> branchBuilds = allBuilds.get(branchName);
        if (branchBuilds != null && !allBuilds.isEmpty()) {
            if (rebuild(branchBuilds.get(0))) {
                result = FormValidation.ok("Rebuild scheduled");
            } else {
                result = FormValidation.warning("Rebuild not scheduled");
            }
        } else {
            result = FormValidation.warning("Build not found");
        }
    } catch (Exception e) {
        LOG.error("Can't start rebuild", e.getMessage());
        result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage());
    }
    return result;
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:35,代碼來源:GitHubBranchRepository.java


注:本文中的org.kohsuke.stapler.StaplerRequest.hasParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。