本文整理汇总了Java中org.kohsuke.stapler.bind.JavaScriptMethod类的典型用法代码示例。如果您正苦于以下问题:Java JavaScriptMethod类的具体用法?Java JavaScriptMethod怎么用?Java JavaScriptMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaScriptMethod类属于org.kohsuke.stapler.bind包,在下文中一共展示了JavaScriptMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebuildDatabase
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public JSReturnCollection rebuildDatabase(int workers) {
JSReturnCollection statement = verifyNotInProgress();
this.workers = workers;
if (this.workers <= 0) {
statement.message = "Invalid number of workers";
statement.code = 1;
return statement;
}
if (statement.code == 0) {
progress = new ManagerProgress();
backendManager.rebuildDatabase(progress, this.workers);
statement.message = "Work completed succesfully";
statement.code = 0;
}
return statement;
}
示例2: getStatus
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public JSReturnCollection getStatus() {
JSReturnCollection statement = new JSReturnCollection();
if (progress != null) {
statement.progress = progress;
statement.workers = workers;
switch (progress.getState()) {
case COMPLETE:
statement.message = "Completed without errors";
break;
case COMPLETE_WITH_ERROR:
statement.message = progress.getReasonsAsString();
statement.code = 2;
break;
case PROCESSING:
statement.running = true;
statement.message = "processing";
break;
}
} else {
statement.message = "Never started";
statement.neverStarted = true;
}
return statement;
}
示例3: triggerManual
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
@Override
public void triggerManual(String projectName, String upstreamName, String buildId)
throws TriggerException, AuthenticationException {
try {
LOG.fine("Trigger manual build " + projectName + " " + upstreamName + " " + buildId);
AbstractProject project = ProjectUtil.getProject(projectName, Jenkins.getInstance());
if (!project.hasPermission(Item.BUILD)) {
throw new BadCredentialsException("Not authorized to trigger build");
}
AbstractProject upstream = ProjectUtil.getProject(upstreamName, Jenkins.getInstance());
ManualTrigger trigger = ManualTriggerFactory.getManualTrigger(project, upstream);
if (trigger != null) {
trigger.triggerManual(project, upstream, buildId, getOwner().getItemGroup());
} else {
String message = "Trigger not found for manual build " + projectName + " for upstream "
+ upstreamName + " id: " + buildId;
LOG.log(Level.WARNING, message);
throw new TriggerException(message);
}
} catch (TriggerException e) {
LOG.log(Level.WARNING, triggerExceptionMessage(projectName, upstreamName, buildId), e);
throw e;
}
}
示例4: checkSecret
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@SuppressWarnings("unused")
@JavaScriptMethod
public JSONObject checkSecret(String secret) {
if (SecretKeyChecker.isSecretKeyValid(secret)) {
return API.success();
} else {
return API.errorWithException(new RegistrationException(Messages.RRError_Hudson_Unauthorized()));
}
}
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:10,代码来源:HudsonSecurityRealmRegistration.java
示例5: checkActivationCode
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@SuppressWarnings("unused")
@JavaScriptMethod
public JSONObject checkActivationCode(String secret, String activationCode) {
try {
if (!SecretKeyChecker.isSecretKeyValid(secret)) {
throw new RegistrationException(Messages.RRError_Hudson_Unauthorized());
}
validateActivationCode(activationCode);
} catch (Exception e) {
return API.errorWithException(e);
}
return API.success();
}
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:14,代码来源:HudsonSecurityRealmRegistration.java
示例6: abort
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public JSReturnCollection abort() throws Exception {
JSReturnCollection statement = new JSReturnCollection();
statement.message = "Not implemented";
statement.code = 1;
return statement;
}
示例7: checkStatusNow
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
/**
* Method which is invoked as an AJAX call when the 'Check Now' link is clicked. This method waits for 5 seconds
* before executing the Sauce REST API call to simulate server activity.
*
* @return the Sauce system status via the Sauce REST API
*/
@JavaScriptMethod
public String checkStatusNow() {
//Wait for 5 seconds to simulate some server activity
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
logger.log(Level.WARNING, "Thread interrupted");
}
return getsauceStatus();
}
示例8: getBuildsByEnvironment
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public List<Stat> getBuildsByEnvironment(String env) {
RunList<B> builds = getBuilds();
if (env == null) {
env = "null";
}
List<Stat> stats = StatsHelper.getBuildsByEnvironment(builds, env);
Collections.sort(stats, new Comparator<Stat>() {
@Override
public int compare(Stat o1, Stat o2) {
return o2.timestamp.compareTo(o1.timestamp);
}
});
return stats;
}
示例9: getBuildsByWorkflow
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public List<Stat> getBuildsByWorkflow(String workflow) {
RunList<B> builds = getBuilds();
if (workflow == null) {
workflow = "null";
}
List<Stat> stats = StatsHelper.getBuildByWorkflow(builds, workflow);
Collections.sort(stats, new Comparator<Stat>() {
@Override
public int compare(Stat o1, Stat o2) {
return o2.timestamp.compareTo(o1.timestamp);
}
});
return stats;
}
示例10: getJSONFile
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
/**
* @param fileDestination destination of file on local dist
* @return String with contents of file
* @throws IOException file was not found
*/
@JavaScriptMethod
private String getJSONFile(String fileDestination) throws IOException {
FileInputStream inputStream = null;
try {
File jsonFile = new File(fileDestination);
inputStream = new FileInputStream(jsonFile);
return IOUtils.toString(inputStream);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
示例11: isConsume
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
/**
* Gets specified queue is consumed or not. Note that this is called by
* Ajax.
*
* @param queueName
* the queue name.
* @return true if specified queue is already consumed.
*/
@JavaScriptMethod
public boolean isConsume(String queueName) {
RMQManager manager = RMQManager.getInstance();
if (manager.isOpen()) {
return manager.getChannelStatus(queueName);
}
return false;
}
示例12: increment
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
/**
* The annotation exposes this method to JavaScript proxy.
*/
@JavaScriptMethod
public int increment(int n) {
return i+=n;
}
示例13: iframeLoadTime
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public void iframeLoadTime(int time) {
Analytics.trackIframeLoad(time);
}
示例14: deploy
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public String deploy(String version, String environment) {
LOGGER.info("Deploy version " + version + " to environment " + environment);
// Get the environment with corresponding build-job
Environment buildEnvironment = null;
for (Environment env : environments) {
if (env.getAwsInstance().equals(environment)) {
buildEnvironment = env;
break;
}
}
final AbstractProject buildJob = Jenkins.getInstance().getItemByFullName(buildEnvironment.getBuildJob(), AbstractProject.class);
LOGGER.info("Executing job: " + buildJob);
if (buildJob == null) {
return String.format(Messages.DashboardView_buildJobNotFound(), buildEnvironment.getName());
}
if ((!buildJob.isBuildable()) || (!buildJob.isParameterized())) {
return Messages.DashboardView_deploymentCannotBeExecuted();
}
final ParametersAction versionParam = new ParametersAction(new StringParameterValue(PARAM_VERSION, version));
final ParametersAction environmentParam = new ParametersAction(new StringParameterValue(PARAM_ENVIRONMENT, environment));
final ParametersAction ec2RegionParam = new ParametersAction(new StringParameterValue(PARAM_EC2_REGION, environment));
final ParametersAction awsKeyParam = new ParametersAction(new StringParameterValue(PARAM_AWS_KEY, environment));
List<ParametersAction> actions = Arrays.asList(versionParam, environmentParam, ec2RegionParam, awsKeyParam);
QueueTaskFuture<AbstractBuild> scheduledBuild = buildJob.scheduleBuild2(2, new Cause.UserIdCause(), actions);
Result result = Result.FAILURE;
try {
AbstractBuild finishedBuild = scheduledBuild.get();
result = finishedBuild.getResult();
LOGGER.info("Build finished with result: " + result + " completed in: " + finishedBuild.getDurationString() + ". ");
} catch (Exception e) {
LOGGER.severe("Error while waiting for build " + scheduledBuild.toString() + ".");
LOGGER.severe(e.getMessage());
LOGGER.severe(ExceptionUtils.getFullStackTrace(e));
return String.format(Messages.DashboardView_buildJobFailed(), buildJob.getName());
}
if (result == Result.SUCCESS) {
return String.format(Messages.DashboardView_buildJobScheduledSuccessfully(), buildJob.getName());
}
return String.format(Messages.DashboardView_buildJobSchedulingFailed(), buildJob.getName());
}
示例15: getChoicesAsStringForUI
import org.kohsuke.stapler.bind.JavaScriptMethod; //导入依赖的package包/类
@JavaScriptMethod
public String getChoicesAsStringForUI() {
String result = getChoicesAsString(getParameters());
return result;
}