made tooltip support reusable.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2398 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-03-10 22:43:16 +00:00
1 parent 3372a3258d
commit 08e79738eb
5 files changed
+38 -14

No files matched your search

+14 -1
View File
@@ -328,10 +328,23 @@ public class Functions {
return Util.encode(s);
}
public void adminCheck(StaplerRequest req, StaplerResponse rsp,boolean required) throws IOException, ServletException {
public static void adminCheck(StaplerRequest req, StaplerResponse rsp,boolean required) throws IOException, ServletException {
if(required && !Hudson.adminCheck(req,rsp)) {
// check failed
throw new ServletException("Unauthorized access");
}
}
/**
* Infers the hudson installation URL from the given request.
*/
public static String inferHudsonURL(StaplerRequest req) {
StringBuilder buf = new StringBuilder();
buf.append(req.getScheme()).append("://");
buf.append(req.getServerName());
if(req.getLocalPort()!=80)
buf.append(':').append(req.getLocalPort());
buf.append('/').append(req.getContextPath());
return buf.toString();
}
}