use of org.kohsuke.stapler.HttpRedirect in project hudson-2.x by hudson.
the class PluginManager method doUploadPlugin.
/**
* Uploads a plugin.
*/
public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, ServletException {
try {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
// Parse the request
FileItem fileItem = (FileItem) upload.parseRequest(req).get(0);
String fileName = Util.getFileName(fileItem.getName());
if ("".equals(fileName))
return new HttpRedirect("advanced");
if (!fileName.endsWith(".hpi"))
throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName));
fileItem.write(new File(rootDir, fileName));
fileItem.delete();
pluginUploaded = true;
return new HttpRedirect(".");
} catch (IOException e) {
throw e;
} catch (Exception e) {
// grrr. fileItem.write throws this
throw new ServletException(e);
}
}
use of org.kohsuke.stapler.HttpRedirect in project hudson-2.x by hudson.
the class PluginManager method doProxyConfigure.
public HttpResponse doProxyConfigure(@QueryParameter("proxy.server") String server, @QueryParameter("proxy.port") String port, @QueryParameter("proxy.noProxyFor") String noProxyFor, @QueryParameter("proxy.userName") String userName, @QueryParameter("proxy.password") String password, @QueryParameter("proxy.authNeeded") String authNeeded) throws IOException {
Hudson hudson = Hudson.getInstance();
hudson.checkPermission(Hudson.ADMINISTER);
server = Util.fixEmptyAndTrim(server);
if ((server != null) && !"".equals(server)) {
// If port is not specified assume it is port 80 (usual default for HTTP port)
int portNumber = 80;
if (!"".equals(Util.fixNull(port))) {
portNumber = Integer.parseInt(Util.fixNull(port));
}
boolean proxyAuthNeeded = "on".equals(Util.fixNull(authNeeded));
if (!proxyAuthNeeded) {
userName = "";
password = "";
}
hudson.proxy = new ProxyConfiguration(server, portNumber, Util.fixEmptyAndTrim(noProxyFor), Util.fixEmptyAndTrim(userName), Util.fixEmptyAndTrim(password), "on".equals(Util.fixNull(authNeeded)));
hudson.proxy.save();
} else {
hudson.proxy = null;
ProxyConfiguration.getXmlFile().delete();
}
return new HttpRedirect("advanced");
}
use of org.kohsuke.stapler.HttpRedirect 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");
}
use of org.kohsuke.stapler.HttpRedirect in project hudson-2.x by hudson.
the class LogRecorderManager method doConfigLogger.
/**
* Configure the logging level.
*/
public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
Level lv;
if (level.equals("inherit"))
lv = null;
else
lv = Level.parse(level.toUpperCase(Locale.ENGLISH));
Logger.getLogger(name).setLevel(lv);
return new HttpRedirect("levels");
}
Aggregations