Search in sources :

Example 1 with UpdateCenter

use of hudson.model.UpdateCenter in project hudson-2.x by hudson.

the class PluginManager method doSiteConfigure.

/**
     * Bare-minimum configuration mechanism to change the update center.
     */
public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException {
    Hudson hudson = Hudson.getInstance();
    hudson.checkPermission(Hudson.ADMINISTER);
    UpdateCenter uc = hudson.getUpdateCenter();
    PersistedList<UpdateSite> sites = uc.getSites();
    for (UpdateSite s : sites) {
        if (s.getId().equals("default"))
            sites.remove(s);
    }
    sites.add(new UpdateSite("default", site));
    return HttpResponses.redirectToContextRoot();
}
Also used : UpdateCenter(hudson.model.UpdateCenter) Hudson(hudson.model.Hudson) UpdateSite(hudson.model.UpdateSite)

Example 2 with UpdateCenter

use of hudson.model.UpdateCenter in project hudson-2.x by hudson.

the class PluginManager method doUpdateSources.

public HttpResponse doUpdateSources(StaplerRequest req) throws IOException {
    Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
    if (req.hasParameter("remove")) {
        UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
        BulkChange bc = new BulkChange(uc);
        try {
            for (String id : req.getParameterValues("sources")) uc.getSites().remove(uc.getById(id));
        } finally {
            bc.commit();
        }
    } else if (req.hasParameter("add"))
        return new HttpRedirect("addSite");
    return new HttpRedirect("./sites");
}
Also used : HttpRedirect(org.kohsuke.stapler.HttpRedirect) UpdateCenter(hudson.model.UpdateCenter)

Example 3 with UpdateCenter

use of hudson.model.UpdateCenter in project hudson-2.x by hudson.

the class PluginWrapper method getUpdateInfo.

/**
     * If the plugin has {@link #getUpdateInfo() an update},
     * returns the {@link UpdateSite.Plugin} object.
     *
     * @return
     *      This method may return null &mdash; for example,
     *      the user may have installed a plugin locally developed.
     */
public UpdateSite.Plugin getUpdateInfo() {
    UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
    UpdateSite.Plugin p = uc.getPlugin(getShortName());
    if (p != null && p.isNewerThan(getVersion()))
        return p;
    return null;
}
Also used : UpdateCenter(hudson.model.UpdateCenter) UpdateSite(hudson.model.UpdateSite)

Aggregations

UpdateCenter (hudson.model.UpdateCenter)3 UpdateSite (hudson.model.UpdateSite)2 Hudson (hudson.model.Hudson)1 HttpRedirect (org.kohsuke.stapler.HttpRedirect)1