本文整理汇总了Java中org.kohsuke.stapler.Stapler类的典型用法代码示例。如果您正苦于以下问题:Java Stapler类的具体用法?Java Stapler怎么用?Java Stapler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Stapler类属于org.kohsuke.stapler包,在下文中一共展示了Stapler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doIndex
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@SuppressWarnings("unused")
public void doIndex() throws IOException {
HttpServletRequest req = Stapler.getCurrentRequest();
GerritProjectEvent projectEvent = getBody(req);
log.info("GerritWebHook invoked for event " + projectEvent);
List<Item> jenkinsItems = Jenkins.getActiveInstance().getAllItems();
for (Item item : jenkinsItems) {
if (item instanceof SCMSourceOwner) {
SCMSourceOwner scmJob = (SCMSourceOwner) item;
log.info("Found SCM job " + scmJob);
List<SCMSource> scmSources = scmJob.getSCMSources();
for (SCMSource scmSource : scmSources) {
if (scmSource instanceof GerritSCMSource) {
GerritSCMSource gerritSCMSource = (GerritSCMSource) scmSource;
if (projectEvent.matches(gerritSCMSource.getRemote())) {
log.info(
"Triggering SCM event for source " + scmSources.get(0) + " on job " + scmJob);
scmJob.onSCMSourceUpdated(scmSource);
}
}
}
}
}
}
示例2: setupGlobalConfiguration
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
/**
* Setup the global configuration.
*
* @throws IOException
*/
public static void setupGlobalConfiguration() throws IOException
{
JSONObject hostConnection = new JSONObject();
hostConnection.put(TestConstants.DESCRIPTION, "TestConnection");
hostConnection.put(TestConstants.HOST_PORT, TestConstants.EXPECTED_HOST + ':' + TestConstants.EXPECTED_PORT);
hostConnection.put(TestConstants.CODE_PAGE, TestConstants.EXPECTED_CODE_PAGE);
hostConnection.put(TestConstants.TIMEOUT, TestConstants.EXPECTED_TIMEOUT);
hostConnection.put(TestConstants.CONNECTION_ID, TestConstants.EXPECTED_CONNECTION_ID);
hostConnection.put(TestConstants.CES_URL, TestConstants.EXPECTED_CES_URL);
JSONArray hostConnections = new JSONArray();
hostConnections.add(hostConnection);
JSONObject json = new JSONObject();
json.put("hostConn", hostConnections);
json.put(TestConstants.TOPAZ_CLI_LOCATION_LINUX, "/opt/Compuware/TopazCLI");
json.put(TestConstants.TOPAZ_CLI_LOCATION_WINDOWS, "C:\\Program Files\\Compuware\\Topaz Workbench CLI");
CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
globalConfig.configure(Stapler.getCurrentRequest(), json);
SystemCredentialsProvider.getInstance().getCredentials().add(new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
TestConstants.EXPECTED_CREDENTIALS_ID, null, TestConstants.EXPECTED_USER_ID, TestConstants.EXPECTED_PASSWORD));
SystemCredentialsProvider.getInstance().save();
}
示例3: writeLogTo
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@Override
public long writeLogTo(long start, int size, Writer w) throws IOException {
if (isHtml()) {
ConsoleAnnotationOutputStream caw = new ConsoleAnnotationOutputStream(w, this.createAnnotator(Stapler.getCurrentRequest()), this.context, this.charset);
long r = super.writeLogTo(start, size, caw);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Cipher sym = PASSING_ANNOTATOR.encrypt();
ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(new CipherOutputStream(baos, sym)));
oos.writeLong(System.currentTimeMillis());
oos.writeObject(caw.getConsoleAnnotator());
oos.close();
StaplerResponse rsp = Stapler.getCurrentResponse();
if(rsp != null) {
rsp.setHeader("X-ConsoleAnnotator", new String(Base64.encode(baos.toByteArray())));
}
return r;
} else {
return super.writeLogTo(start, size, w);
}
}
示例4: bind
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Describable> T bind(JSONObject json)
throws IOException, FormException {
final String clazz = checkNotNull(json.optString("$class", null));
final Descriptor descriptor = getDescriptor(clazz);
final Stapler stapler = getStapler();
final StaplerRequest request = getRequest(stapler, json);
// We do this instead of 'request.bindJson' because this doesn't
// require a DataBoundConstructor.
// TODO(mattmoor): Should we do the rewrite of describable lists
// here as well?
return (T) descriptor.newInstance(request, json);
}
示例5: AbstractScriptableParameter
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
/**
* Inherited constructor.
*
* {@inheritDoc}
*
* @param name name
* @param description description
* @param randomName parameter random generated name (uuid)
* @param script script used to generate the list of parameter values
*/
protected AbstractScriptableParameter(String name, String description, String randomName, Script script) {
super(name, description, randomName);
this.script = script;
// Try to get the project name from the current request. In case of being called in some other non-web way,
// the name will be fetched later via Jenkins.getInstance() and iterating through all items. This is for a
// performance wise approach first.
final StaplerRequest currentRequest = Stapler.getCurrentRequest();
String projectName = null;
if (currentRequest != null) {
final Ancestor ancestor = currentRequest.findAncestor(AbstractItem.class);
if (ancestor != null) {
final Object o = ancestor.getObject();
if (o instanceof AbstractItem) {
final AbstractItem parentItem = (AbstractItem) o;
projectName = parentItem.getName();
}
}
}
this.projectName = projectName;
}
示例6: getUpUrl
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@Override
public String getUpUrl() {
final StaplerRequest req = Stapler.getCurrentRequest();
if (req != null) {
final List<Ancestor> ancs = req.getAncestors();
for (int i = 1; i < ancs.size(); i++) {
if (ancs.get(i).getObject() == this) {
final Object parentObj = ancs.get(i - 1).getObject();
if (parentObj instanceof DynamicBuild || parentObj instanceof DynamicSubProject) {
return ancs.get(i - 1).getUrl() + '/';
}
}
}
}
return super.getDisplayName();
}
示例7: doFillCredsItems
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
public static ListBoxModel doFillCredsItems() {
StandardUsernameListBoxModel model = new StandardUsernameListBoxModel();
Item item = Stapler.getCurrentRequest().findAncestorObject(Item.class);
List<StandardUsernameCredentials> listOfAllCredentails = CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
List<StandardUsernameCredentials> listOfSandardUsernameCredentials = new ArrayList<StandardUsernameCredentials>();
// since we only care about 'UsernamePasswordCredentials' objects, lets seek those out and ignore the rest.
for (StandardUsernameCredentials c : listOfAllCredentails) {
if (c instanceof UsernamePasswordCredentials) {
listOfSandardUsernameCredentials.add(c);
}
}
model.withAll(listOfSandardUsernameCredentials);
return model;
}
示例8: getIconFileName
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getIconFileName() {
String iconClassName = getIconClassName();
if (iconClassName != null) {
Icon icon = IconSet.icons.getIconByClassSpec(iconClassName + " icon-md");
if (icon != null) {
JellyContext ctx = new JellyContext();
ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH);
return icon.getQualifiedUrl(ctx);
}
}
return null;
}
示例9: configure
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject formData) {
Stapler.CONVERT_UTILS.deregister(java.net.URL.class);
Stapler.CONVERT_UTILS.register(new EmptyFriendlyURLConverter(), java.net.URL.class);
sites.replaceBy(req.bindJSONToList(Site.class, formData.get("sites")));
save();
return true;
}
示例10: doCheckAcceptLicense
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
public FormValidation doCheckAcceptLicense(@QueryParameter boolean value) {
if (username==null || password==null)
return FormValidation.errorWithMarkup(Messages.JDKInstaller_RequireOracleAccount(Stapler.getCurrentRequest().getContextPath()+'/'+getDescriptorUrl()+"/enterCredential"));
if (value) {
return FormValidation.ok();
} else {
return FormValidation.error(Messages.JDKInstaller_DescriptorImpl_doCheckAcceptLicense());
}
}
开发者ID:jenkinsci,项目名称:apache-httpcomponents-client-4-api-plugin,代码行数:10,代码来源:Client4JDKInstaller.java
示例11: configure
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@Override
public boolean configure(StaplerRequest req, JSONObject formData) {
Stapler.CONVERT_UTILS.deregister(java.net.URL.class);
Stapler.CONVERT_UTILS.register(new EmptyFriendlyURLConverter(), java.net.URL.class);
sites.replaceBy(req.bindJSONToList(Site.class, formData.get("sites")));
save();
return true;
}
示例12: iconFileName
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
public static String iconFileName(String name, Size size) {
Icon icon = icons.getIconByClassSpec(classSpec(name, size));
if (icon == null) {
return null;
}
JellyContext ctx = new JellyContext();
ctx.setVariable("resURL", Stapler.getCurrentRequest().getContextPath() + Jenkins.RESOURCE_PATH);
return icon.getQualifiedUrl(ctx);
}
示例13: getUsernameFromAuthCode
import org.kohsuke.stapler.Stapler; //导入依赖的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
示例14: isGetParamSecretValid
import org.kohsuke.stapler.Stapler; //导入依赖的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);
}
示例15: getRedirectURL
import org.kohsuke.stapler.Stapler; //导入依赖的package包/类
@Override
protected String getRedirectURL(DisplayURLProvider provider) {
StaplerRequest req = Stapler.getCurrentRequest();
String page = req.getParameter("page");
String url;
if ("changes".equals(page)) {
url = provider.getChangesURL(run);
} else {
url = provider.getRunURL(run);
}
return url;
}