本文整理汇总了Java中org.kohsuke.stapler.QueryParameter类的典型用法代码示例。如果您正苦于以下问题:Java QueryParameter类的具体用法?Java QueryParameter怎么用?Java QueryParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryParameter类属于org.kohsuke.stapler包,在下文中一共展示了QueryParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillCredentialsIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Stapler form completion.
*
* @param serverUrl the server URL.
* @return the available credentials.
*/
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
Jenkins.getActiveInstance().checkPermission(Jenkins.ADMINISTER);
StandardListBoxModel result = new StandardListBoxModel();
serverUrl = GiteaServers.normalizeServerUrl(serverUrl);
result.includeMatchingAs(
ACL.SYSTEM,
Jenkins.getActiveInstance(),
StandardCredentials.class,
URIRequirementBuilder.fromUri(serverUrl).build(),
AuthenticationTokens.matcher(GiteaAuth.class)
);
return result;
}
示例2: doCheckToken
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Sanity check for a Gitea access token.
*
* @param value the token.
* @return the resulst of the sanity check.
*/
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused") // stapler
public FormValidation doCheckToken(@QueryParameter String value) {
Secret secret = Secret.fromString(value);
if (secret == null) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenRequired());
}
if (StringUtils.equals(value, secret.getPlainText())) {
if (value.length() != 40) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
} else if (secret.getPlainText().length() != 40) {
return FormValidation.warning(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
return FormValidation.ok();
}
示例3: doFillPolicyNameItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* This method is called to populate the policy list on the Jenkins config page.
* @param context
* @param orgName
* @param credentialsId
* @return
*/
public ListBoxModel doFillPolicyNameItems(@AncestorInPath ItemGroup context,
@QueryParameter final String orgName,
@QueryParameter final String toolchainName,
@QueryParameter final String credentialsId) {
String targetAPI = chooseTargetAPI(environment);
try {
// if user changes to a different credential, need to get a new token
if (!credentialsId.equals(preCredentials) || Util.isNullOrEmpty(bluemixToken)) {
bluemixToken = getBluemixToken(context, credentialsId, targetAPI);
preCredentials = credentialsId;
}
} catch (Exception e) {
return new ListBoxModel();
}
if(debug_mode){
LOGGER.info("#######GATE : calling getPolicyList#######");
}
return getPolicyList(bluemixToken, orgName, toolchainName, environment, debug_mode);
}
示例4: doFillPrincipalCredentialIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public ListBoxModel doFillPrincipalCredentialIdItems(
@AncestorInPath Item item,
@QueryParameter String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
}
List<AzureCredentials> creds = CredentialsProvider.lookupCredentials(AzureCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
for (AzureCredentials cred
:
creds) {
result.add(cred.getId());
}
return result.includeEmptyValue()
.includeCurrentValue(credentialsId);
}
示例5: doCheckQueueUuid
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public FormValidation doCheckQueueUuid(@QueryParameter final String value) {
if (this.getSqsQueues().size() == 0) {
return FormValidation.error(Messages.errorQueueUnavailable());
}
if (StringUtils.isEmpty(value)) {
return FormValidation.ok(Messages.infoQueueDefault());
}
final SQSQueue queue = this.getSqsQueue(value);
if (queue == null) {
return FormValidation.error(Messages.errorQueueUuidUnknown());
}
return FormValidation.ok();
}
示例6: doTestConnection
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public FormValidation doTestConnection(
@QueryParameter("mirrorGateAPIUrl") final String mirrorGateAPIUrl,
@QueryParameter("mirrorgateCredentialsId") final String credentialsId)
throws Descriptor.FormException {
MirrorGateService testMirrorGateService = getMirrorGateService();
if (testMirrorGateService != null) {
MirrorGateResponse response
= testMirrorGateService.testConnection();
return response.getResponseCode() == HttpStatus.SC_OK
? FormValidation.ok("Success")
: FormValidation.error("Failure<"
+ response.getResponseCode() + ">");
} else {
return FormValidation.error("Failure");
}
}
示例7: doFillMirrorgateCredentialsIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public ListBoxModel doFillMirrorgateCredentialsIdItems(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
return result
.includeEmptyValue()
.includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
示例8: doCheckMirrorgateCredentialsId
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public FormValidation doCheckMirrorgateCredentialsId(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return FormValidation.ok();
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
if (StringUtils.isBlank(credentialsId)) {
return FormValidation.ok();
}
if (credentialsId.startsWith("${") && credentialsId.endsWith("}")) {
return FormValidation.warning(
"Cannot validate expression based credentials");
}
return FormValidation.ok();
}
示例9: doFillCheckoutCredentialsIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
@Restricted(NoExternalUse.class)
public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) {
if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId);
}
StandardListBoxModel result = new StandardListBoxModel();
result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS);
return result.includeMatchingAs(
context instanceof Queue.Task
? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
context,
StandardUsernameCredentials.class,
SettingsUtils.gitLabConnectionRequirements(connectionName),
GitClient.CREDENTIALS_MATCHER
);
}
示例10: doCheckCredentialsId
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Validator for the 'Login credentials' field.
*
* @param credentialsId
* login credentials passed from the config.jelly "credentialsId" field
*
* @return validation message
*/
public FormValidation doCheckCredentialsId(@QueryParameter String credentialsId)
{
String tempValue = StringUtils.trimToEmpty(credentialsId);
if (tempValue.isEmpty())
{
return FormValidation.error(Messages.checkLoginCredentialsError());
}
return FormValidation.ok();
}
示例11: doFillConnectionIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Fills in the Host Connection selection box with applicable connections.
*
* @param context
* filter for host connections
* @param connectionId
* an existing host connection identifier; can be null
* @param project
* the Jenkins project
*
* @return host connection selections
*/
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
@AncestorInPath Item project)
{
CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
HostConnection[] hostConnections = globalConfig.getHostConnections();
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (HostConnection connection : hostConnections)
{
boolean isSelected = false;
if (connectionId != null)
{
isSelected = connectionId.matches(connection.getConnectionId());
}
model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
connection.getConnectionId(), isSelected));
}
return model;
}
示例12: doFillCredentialsIdItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable connections.
*
* @param context
* filter for login credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return login credentials selection
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
@AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例13: doFillProjectItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public ListBoxModel doFillProjectItems(@QueryParameter String serverUrl, @QueryParameter String username,
@QueryParameter Secret password) throws URISyntaxException {
ListBoxModel items = new ListBoxModel();
if (validInputs(serverUrl, username, password)) {
try {
TfsClient client = getTfsClientFactory().getValidatedClient(serverUrl, username, password);
List<TeamProjectReference> references = client.getProjectClient().getProjects();
for (TeamProjectReference ref : references) {
items.add(ref.getName(), String.valueOf(ref.getId()));
}
} catch (VssServiceException vse) {
return items;
}
}
return items;
}
示例14: doFillBuildDefinitionItems
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
public ListBoxModel doFillBuildDefinitionItems(@QueryParameter String serverUrl, @QueryParameter String username,
@QueryParameter Secret password, @QueryParameter String project) throws URISyntaxException {
ListBoxModel items = new ListBoxModel();
if (validInputs(serverUrl, username, password, project)) {
try {
TfsClient client = getTfsClientFactory().getValidatedClient(serverUrl, username, password);
List<DefinitionReference> definitions = client.getBuildClient().getDefinitions(UUID.fromString(project));
for (DefinitionReference definition : definitions) {
items.add(definition.getName(), String.valueOf(definition.getId()));
}
} catch (VssServiceException vse) {
return items;
}
}
return items;
}
示例15: doTestIcon
import org.kohsuke.stapler.QueryParameter; //导入依赖的package包/类
/**
* Serves the testCoverage badge image. TO DO
* @param req
* @param rsp
* @param job
* @return
*/
@SuppressWarnings("rawtypes")
public HttpResponse doTestIcon(StaplerRequest req, StaplerResponse rsp, @QueryParameter String job) {
Job<?, ?> project = getProject(job);
Integer testPass = null;
Integer testTotal = null;
if (project.getLastCompletedBuild() != null) {
AbstractTestResultAction testAction = project.getLastCompletedBuild().getAction(AbstractTestResultAction.class);
if(testAction != null){
int total = testAction.getTotalCount();
int pass = total - testAction.getFailCount() - testAction.getSkipCount();
testTotal = total;
testPass = pass;
}
}
return iconResolver.getTestResultImage(testPass, testTotal);
}