热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

hudson.model.UpdateSite类的使用及代码示例

本文整理了Java中hudson.model.UpdateSite类的一些代码示例,展示了UpdateSite类的具体用法。这些代码示例主要来

本文整理了Java中hudson.model.UpdateSite类的一些代码示例,展示了UpdateSite类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UpdateSite类的具体详情如下:
包路径:hudson.model.UpdateSite
类名称:UpdateSite

UpdateSite介绍

[英]Source of the update center information, like "http://hudson-ci.org/update-center.json"

Hudson can have multiple UpdateSites registered in the system, so that it can pick up plugins from different locations.
[中]更新中心信息的来源,如“http://hudson-ci.org/update-center.json"
Hudson可以在系统中注册多个UpdateSite,这样它就可以从不同的位置获取插件。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
* Bare-minimum configuration mechanism to change the update center.
*/
@RequirePOST
public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException {
Jenkins hudson = Jenkins.getInstance();
hudson.checkPermission(CONFIGURE_UPDATECENTER);
UpdateCenter uc = hudson.getUpdateCenter();
PersistedList sites = uc.getSites();
for (UpdateSite s : sites) {
if (s.getId().equals(UpdateCenter.ID_DEFAULT))
sites.remove(s);
}
sites.add(new UpdateSite(UpdateCenter.ID_DEFAULT, site));
return new HttpRedirect("advanced");
}

代码示例来源:origin: jenkinsci/jenkins

@Exported
public List getAvailables() {
Map pluginMap = new LinkedHashMap();
for (UpdateSite site : sites) {
for (Plugin plugin: site.getAvailables()) {
final Plugin existing = pluginMap.get(plugin.name);
if (existing == null) {
pluginMap.put(plugin.name, plugin);
} else if (!existing.version.equals(plugin.version)) {
// allow secondary update centers to publish different versions
// TODO refactor to consolidate multiple versions of the same plugin within the one row
final String altKey = plugin.name + ":" + plugin.version;
if (!pluginMap.containsKey(altKey)) {
pluginMap.put(altKey, plugin);
}
}
}
}
return new ArrayList(pluginMap.values());
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

private void writeShrinkwrapFile(Jenkins jenkins, File shrinkwrap, PluginManager pluginManager) throws ConfiguratorException {
logger.fine("Writing shrinkwrap file: " + shrinkwrap);
try (PrintWriter w = new PrintWriter(shrinkwrap, UTF_8.name())) {
for (PluginWrapper pw : pluginManager.getPlugins()) {
if (pw.getShortName().equals("configuration-as-code")) continue;
String from = UpdateCenter.PREDEFINED_UPDATE_SITE_ID;
for (UpdateSite site : jenkins.getUpdateCenter().getSites()) {
if (site.getPlugin(pw.getShortName()) != null) {
from = site.getId();
break;
}
}
w.println(pw.getShortName() + ':' + pw.getVersionNumber().toString() + '@' + from);
}
} catch (IOException e) {
throw new ConfiguratorException("failed to write plugins.txt shrinkwrap file", e);
}
}

代码示例来源:origin: jenkinsci/jenkins

@Restricted(NoExternalUse.class)
public @Nonnull FormValidation updateDirectlyNow(boolean signatureCheck) throws IOException {
return updateData(DownloadService.loadJSON(new URL(getUrl() + "?id=" + URLEncoder.encode(getId(), "UTF-8") + "&version=" + URLEncoder.encode(Jenkins.VERSION, "UTF-8"))), signatureCheck);
}

代码示例来源:origin: jenkinsci/jenkins

/**
* Update the data file from the given URL if the file
* does not exist, or is otherwise due for update.
* Accepted formats are JSONP or HTML with {@code postMessage}, not raw JSON.
* @param signatureCheck whether to enforce the signature (may be off only for testing!)
* @return null if no updates are necessary, or the future result
* @since 1.502
*/
public @CheckForNull Future updateDirectly(final boolean signatureCheck) {
if (! getDataFile().exists() || isDue()) {
return Jenkins.getInstance().getUpdateCenter().updateService.submit(new Callable() {
@Override public FormValidation call() throws Exception {
return updateDirectlyNow(signatureCheck);
}
});
} else {
return null;
}
}

代码示例来源:origin: jenkinsci/jenkins

private FormValidation updateData(String json, boolean signatureCheck)
throws IOException {
dataTimestamp = System.currentTimeMillis();
JSONObject o = JSONObject.fromObject(json);
try {
int v = o.getInt("updateCenterVersion");
if (v != 1) {
throw new IllegalArgumentException("Unrecognized update center version: " + v);
}
} catch (JSONException x) {
throw new IllegalArgumentException("Could not find (numeric) updateCenterVersion in " + json, x);
}
if (signatureCheck) {
FormValidation e = verifySignature(o);
if (e.kind!=Kind.OK) {
LOGGER.severe(e.toString());
return e;
}
}
LOGGER.info("Obtained the latest update center data file for UpdateSource " + id);
retryWindow = 0;
getDataFile().write(json);
data = new Data(o);
return FormValidation.ok();
}

代码示例来源:origin: jenkinsci/jenkins

protected UpdateSite createDefaultUpdateSite() {
return new UpdateSite(PREDEFINED_UPDATE_SITE_ID, config.getUpdateCenterUrl() + "update-center.json");
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

@CheckForNull
@Override
public CNode describe(UpdateSite instance, ConfigurationContext context) throws Exception {
final Mapping mapping = new Mapping();
// TODO would need to compare with hudson.model.UpdateCenter.createDefaultUpdateSite
// so we return null if default update site is in use.
mapping.put("id", instance.getId());
mapping.put("url", instance.getUrl());
return mapping;
}
}

代码示例来源:origin: jenkinsci/jenkins

public void run() {
connectionStates.put(ConnectionStatus.INTERNET, ConnectionStatus.UNCHECKED);
connectionStates.put(ConnectionStatus.UPDATE_SITE, ConnectionStatus.UNCHECKED);
if (ID_UPLOAD.equals(site.getId())) {
return;
Future internetCheck = null;
try {
final String cOnnectionCheckUrl= site.getConnectionCheckUrl();
if (connectionCheckUrl!=null) {
connectionStates.put(ConnectionStatus.INTERNET, ConnectionStatus.CHECKING);
} else {
LOGGER.log(WARNING, "Update site ''{0}'' does not declare the connection check URL. "
+ "Skipping the network availability check.", site.getId());
connectionStates.put(ConnectionStatus.INTERNET, ConnectionStatus.SKIPPED);
statuses.add(Messages.UpdateCenter_Status_CheckingJavaNet());
config.checkUpdateCenter(this, site.getUrl());

代码示例来源:origin: jenkinsci/jenkins

for (UpdateSite.Plugin plugin: site.getAvailables()) {
JSONObject pluginInfo = allPlugins.get(plugin.name);
if(pluginInfo == null) {
pluginInfo.put("title", plugin.getDisplayName());
pluginInfo.put("excerpt", plugin.excerpt);
pluginInfo.put("site", site.getId());
pluginInfo.put("dependencies", plugin.dependencies);
pluginInfo.put("website", plugin.wiki);

代码示例来源:origin: org.eclipse.hudson/hudson-core

public void run() {
LOGGER.fine("Doing a connectivity check");
try {
String cOnnectionCheckUrl= site.getConnectionCheckUrl();
if (connectionCheckUrl != null) {
statuses.add(Messages.UpdateCenter_Status_CheckingInternet());
try {
config.checkConnection(this, connectionCheckUrl);
} catch (IOException e) {
if (e.getMessage().contains("Connection timed out")) {
// Google can't be down, so this is probably a proxy issue
statuses.add(Messages.UpdateCenter_Status_ConnectionFailed(connectionCheckUrl));
return;
}
}
}
statuses.add(Messages.UpdateCenter_Status_CheckingJavaNet());
config.checkUpdateCenter(this, site.getUrl());
statuses.add(Messages.UpdateCenter_Status_Success());
} catch (UnknownHostException e) {
statuses.add(Messages.UpdateCenter_Status_UnknownHostException(e.getMessage()));
addStatus(e);
} catch (IOException e) {
statuses.add(Functions.printThrowable(e));
}
}

代码示例来源:origin: jenkinsci/jenkins

/**
* Gets the plugin with the given name from the first {@link UpdateSite} to contain it.
* @return Discovered {@link Plugin}. {@code null} if it cannot be found
*/
public @CheckForNull Plugin getPlugin(String artifactId) {
for (UpdateSite s : sites) {
Plugin p = s.getPlugin(artifactId);
if (p!=null) return p;
}
return null;
}

代码示例来源:origin: jenkinsci/jenkins

/**
* Gets the information about a specific plugin.
*
* @param artifactId
* The short name of the plugin. Corresponds to {@link PluginWrapper#getShortName()}.
*
* @return
* null if no such information is found.
*/
public Plugin getPlugin(String artifactId) {
Data dt = getData();
if(dt==null) return null;
return dt.plugins.get(artifactId);
}

代码示例来源:origin: jenkinsci/jenkins

for (UpdateSite site : sites) {
if (site.isLegacyDefault()) {
sites.remove(site);
} else if (ID_DEFAULT.equals(site.getId())) {
defaultSiteExists = true;

代码示例来源:origin: jenkinsci/jenkins

private @CheckForNull ConnectionCheckJob getConnectionCheckJob(@Nonnull UpdateSite site) {
synchronized (jobs) {
for (UpdateCenterJob job : jobs) {
if (job instanceof ConnectionCheckJob && job.site.getId().equals(site.getId())) {
return (ConnectionCheckJob) job;
}
}
}
return null;
}

代码示例来源:origin: jenkinsci/jenkins

Set candidates = new HashSet<>();
for (UpdateSite s : h.getUpdateCenter().getSites()) {
Data dt = s.getData();
if (dt==null)
stdout.println(Messages.InstallPluginCommand_NoUpdateDataRetrieved(s.getUrl()));
else
candidates.addAll(dt.plugins.keySet());

代码示例来源:origin: jenkinsci/jenkins

/**
* Returns true if it's time for us to check for new version.
*/
public boolean isDue() {
if(neverUpdate) return false;
if(dataTimestamp == 0)
dataTimestamp = getDataFile().file.lastModified();
long now = System.currentTimeMillis();

retryWindow = Math.max(retryWindow,SECONDS.toMillis(15));

boolean due = now - dataTimestamp > DAY && now - lastAttempt > retryWindow;
if(due) {
lastAttempt = now;
retryWindow = Math.min(retryWindow*2, HOURS.toMillis(1)); // exponential back off but at most 1 hour
}
return due;
}

代码示例来源:origin: jenkinsci/jenkins

/**
* URL which exposes the metadata location in a specific update site.
* @param downloadable, the downloadable id of a specific metatadata json (e.g. hudson.tasks.Maven.MavenInstaller.json)
* @return the location
* @since 2.20
*/
@CheckForNull
@Restricted(NoExternalUse.class)
public String getMetadataUrlForDownloadable(String downloadable) {
String siteUrl = getUrl();
String updateSiteMetadataUrl = null;
int baseUrlEnd = siteUrl.indexOf("update-center.json");
if (baseUrlEnd != -1) {
String siteBaseUrl = siteUrl.substring(0, baseUrlEnd);
updateSiteMetadataUrl = siteBaseUrl + "updates/" + downloadable;
} else {
LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl);
}
return updateSiteMetadataUrl;
}

代码示例来源:origin: jenkinsci/jenkins

/**
* Gets the string representing how long ago the data was obtained.
* Will be the newest of all {@link UpdateSite}s.
*/
public String getLastUpdatedString() {
long newestTs = 0;
for (UpdateSite s : sites) {
if (s.getDataTimestamp()>newestTs) {
newestTs = s.getDataTimestamp();
}
}
if (newestTs == 0) {
return Messages.UpdateCenter_n_a();
}
return Util.getPastTimeString(System.currentTimeMillis()-newestTs);
}

代码示例来源:origin: jenkinsci/jenkins

public List getUpdates() {
Map pluginMap = new LinkedHashMap();
for (UpdateSite site : sites) {
for (Plugin plugin: site.getUpdates()) {
final Plugin existing = pluginMap.get(plugin.name);
if (existing == null) {
pluginMap.put(plugin.name, plugin);
} else if (!existing.version.equals(plugin.version)) {
// allow secondary update centers to publish different versions
// TODO refactor to consolidate multiple versions of the same plugin within the one row
final String altKey = plugin.name + ":" + plugin.version;
if (!pluginMap.containsKey(altKey)) {
pluginMap.put(altKey, plugin);
}
}
}
}
return new ArrayList(pluginMap.values());
}

推荐阅读
author-avatar
restVerify
这个人,怎么说呢,有上进,有头脑
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有