hudson
Class Functions

java.lang.Object
  extended by hudson.Functions

public class Functions
extends Object

Utility functions used in views.

An instance of this class is created for each request and made accessible from view pages via the variable 'h' (h stands for Hudson.)

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class Functions.RunUrl
          URL decomposed for easier computation of relevant URLs.
static class Functions.ThreadGroupMap
           
 
Field Summary
static boolean DEBUG_YUI
          Set to true if you need to use the debug version of YUI.
 
Constructor Summary
Functions()
           
 
Method Summary
static String addSuffix(int n, String singular, String plural)
          Adds the proper suffix.
static void adminCheck(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, Object required, Permission permission)
           
static String appendIfNotNull(String text, String suffix, String nullText)
           
static String appendSpaceIfNotNull(String n)
           
static String capitalize(String s)
          Converts "abc" to "Abc".
static void checkPermission(AccessControlled object, Permission permission)
           
static void checkPermission(Object object, Permission permission)
          This version is so that the 'checkPermission' on layout.jelly degrades gracefully if "it" is not an AccessControlled object.
static void checkPermission(Permission permission)
           
static void configureAutoRefresh(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean noAutoRefresh)
          Used by layout.jelly to control the auto refresh behavior.
static String createRenderOnDemandProxy(org.apache.commons.jelly.JellyContext context, String attributesToCapture)
           
static Functions.RunUrl decompose(org.kohsuke.stapler.StaplerRequest req)
           
static
<T> T
defaulted(T value, T defaultValue)
          If the value exists, return that value.
static boolean defaultToTrue(Boolean b)
          Can be used to check a checkbox by default.
static int determineRows(String s)
          Counts the number of rows needed for textarea to fit the content.
static Map<Thread,StackTraceElement[]> dumpAllThreads()
           
static String dumpThreadInfo(ThreadInfo ti, Functions.ThreadGroupMap map)
           
static
<T> Collection<T>
emptyList()
           
static String encode(String s)
           
static String escape(String s)
           
static
<V> SortedMap<Integer,V>
filter(SortedMap<Integer,V> map, String from, String to)
          Creates a sub map by using the given range (both ends inclusive).
 List filterDescriptors(Object context, Iterable descriptors)
           
static String generateConsoleAnnotationScriptAndStylesheet()
          Generate a series of <script> tags to include script.js from ConsoleAnnotatorFactorys and ConsoleAnnotationDescriptors.
 String generateId()
          Generates an unique ID.
static String getActionUrl(String itUrl, Action action)
          Computes the hyperlink to actions, to handle the situation when the Action.getUrlName() returns absolute URL.
static List<TopLevelItem> getAllTopLevelItems(ItemGroup root)
          Gets all the TopLevelItems recursively in the ItemGroup tree.
static List<Descriptor<AuthorizationStrategy>> getAuthorizationStrategyDescriptors()
           
static String getAvatar(User user, String avatarSize)
          Returns an avatar image URL for the specified user and preferred image size
static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project)
           
static List<Descriptor<BuildWrapper>> getBuildWrapperDescriptors(AbstractProject<?,?> project)
           
static List<Descriptor<CaptchaSupport>> getCaptchaSupportDescriptors()
           
 String getCheckUrl(String userDefined, Object descriptor, String field)
          Determines the form validation check URL.
static ArrayList<CLICommand> getCLICommands()
           
static List<Descriptor<Cloud>> getCloudDescriptors()
           
static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors()
           
static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest req, String name)
           
static String getCookie(javax.servlet.http.HttpServletRequest req, String name, String defaultValue)
           
static String getCrumb(org.kohsuke.stapler.StaplerRequest req)
           
static List<Descriptor<CrumbIssuer>> getCrumbIssuerDescriptors()
           
static String getCrumbRequestField()
           
static String getCurrentDescriptorByNameUrl()
           
static org.apache.commons.jelly.JellyContext getCurrentJellyContext()
          When called from within JEXL expression evaluation, this method returns the current JellyContext used to evaluate the script.
static Locale getCurrentLocale()
           
static Date getCurrentTime()
           
static String getDiffString(int i)
          Prints the integer as a string that represents difference, like "-5", "+/-0", "+3".
static String getDiffString2(int i)
          getDiffString(int) that doesn't show anything for +/-0
static String getDiffString2(String prefix, int i, String suffix)
          getDiffString2(int) that puts the result into prefix and suffix if there's something to print
static Map getEnvVars()
           
static String getFooterURL()
          Returns the link to be displayed in the footer of the UI.
static String getIconFilePath(Action a)
          Computes the path to the icon of the given action from the context path.
static boolean getIsUnitTest()
          Returns true if we are running unit tests.
 JDK.DescriptorImpl getJDKDescriptor()
           
static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz)
           
 List<String> getLoggerNames()
          Work around for bug 6935026.
static List<LogRecord> getLogRecords()
           
static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors()
           
static String getNearestAncestorUrl(org.kohsuke.stapler.StaplerRequest req, Object it)
          Finds the given object in the ancestor list and returns its URL.
static Node.Mode[] getNodeModes()
           
static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz)
           
static List<PageDecorator> getPageDecorators()
          Gets all the PageDecorators.
static List<ParameterDefinition.ParameterDescriptor> getParameterDescriptors()
           
 String getPasswordValue(Object o)
          Used by <f:password/> so that we send an encrypted value to the client.
static String getProjectListString(List<Project> projects)
           
static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project)
           
static String getRelativeDisplayNameFrom(Item p, ItemGroup g)
          Gets the relative display name to the given item from the specified group.
static String getRelativeLinkTo(Item p)
          Computes the relative path from the current page to the given item.
static List<String> getRequestHeaders(String name)
           
static String getResourcePath()
          Resoruce path prefix.
static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors()
           
static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?,?> project)
           
static Area getScreenResolution()
          If we know the user's screen resolution, return it.
static String getSearchURL()
          Finds the inner-most SearchableModelObject in scope.
static List<Descriptor<SecurityRealm>> getSecurityRealmDescriptors()
           
 String getServerName()
          Obtains the host name of the Hudson server that clients can use to talk back to.
static Collection<Descriptor> getSortedDescriptorsForGlobalConfig()
          Like getSortedDescriptorsForGlobalConfig(Predicate) but with a constant truth predicate, to include all descriptors.
static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(com.google.common.base.Predicate<GlobalConfigurationCategory> predicate)
          Gets all the descriptors sorted by their inheritance tree of Describable so that descriptors of similar types come nearby.
static Collection<Descriptor> getSortedDescriptorsForGlobalConfigNoSecurity()
          Deprecated. This is rather meaningless.
static Collection<Descriptor> getSortedDescriptorsForGlobalConfigUnclassified()
          Like getSortedDescriptorsForGlobalConfig(Predicate) but for unclassified descriptors only.
static Map getSystemProperties()
           
 String getSystemProperty(String key)
           
static ThreadInfo[] getThreadInfos()
           
static
<B> Class
getTypeParameter(Class<? extends B> c, Class<B> base, int n)
          Given c=MyList (extends ArrayList<Foo>), base=List, compute the parameterization of 'base' that's assignable from 'c' (in this case List<Foo>), and return its n-th type parameter (n=0 would return Foo).
 String getUserAvatar(User user, String avatarSize)
          Deprecated. as of 1.451 Use getAvatar(hudson.model.User, java.lang.String)
static String getVersion()
           
static String getViewResource(Object it, String path)
           
static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors()
           
static String getWin32ErrorMessage(IOException e)
           
static String getYuiSuffix()
          Gets the suffix to use for YUI JavaScript.
static boolean hasPermission(Object object, Permission permission)
          This version is so that the 'hasPermission' can degrade gracefully if "it" is not an AccessControlled object.
static boolean hasPermission(Permission permission)
          Returns true if the current user has the given permission.
static boolean hasView(Object it, String path)
           
static String htmlAttributeEscape(String text)
           
static String humanReadableByteSize(long size)
          Returns human readable information about file size
 boolean hyperlinkMatchesCurrentPage(String href)
          If the given href link is matching the current page, return true.
static Object ifThenElse(boolean cond, Object thenValue, Object elseValue)
          Deprecated. as of 1.294 JEXL now supports the real ternary operator "x?y:z", so this work around is no longer necessary.
static String inferHudsonURL(org.kohsuke.stapler.StaplerRequest req)
          Infers the hudson installation URL from the given request.
static void initPageVariables(org.apache.commons.jelly.JellyContext context)
           
static boolean isAnonymous()
          Checks if the current user is anonymous.
static boolean isArtifactsPermissionEnabled()
          Returns true if the Run.ARTIFACTS permission is enabled, false otherwise.
static boolean isAutoRefresh(javax.servlet.http.HttpServletRequest request)
           
static boolean isModel(Object o)
           
static boolean isModelWithContextMenu(Object o)
           
static boolean isMultiline(String s)
           
static boolean isMustangOrAbove()
          Are we running on JRE6 or above?
static boolean isWindows()
           
static boolean isWipeOutPermissionEnabled()
          Returns true if the Item.WIPEOUT permission is enabled, false otherwise.
static String joinPath(String... components)
          Combine path components via '/' while handling leading/trailing '/' to avoid duplicates.
static String jsStringEscape(String s)
           
static String nbspIndent(String size)
          One nbsp per 10 pixels in given size, which may be a plain number or "NxN" (like an iconSize).
 String prepend(String prefix, String body)
          Prepend a prefix only when there's the specified body.
static String printLogRecord(LogRecord r)
           
static String printThrowable(Throwable t)
           
static Object rawHtml(Object o)
          Used for arguments to internationalized expressions to avoid escape
static void restoreCurrentDescriptorByNameUrl(String old)
           
static String rfc822Date(Calendar cal)
           
static String runScript(org.apache.commons.jelly.Script script)
          Evaluate a Jelly script and return output as a String.
static String setCurrentDescriptorByNameUrl(String value)
           
<T> List<T>
singletonList(T t)
           
static int size2(Object o)
          Works like JSTL build-in size(x) function, but handle null gracefully.
static Functions.ThreadGroupMap sortThreadsAndGetGroupMap(ThreadInfo[] list)
           
static
<T> List<T>
subList(List<T> base, int maxSize)
          Returns a sub-list if the given list is bigger than the specified 'maxSize'
static String toCCStatus(Item i)
          Converts the Hudson build status to CruiseControl build status, which is either Success, Failure, Exception, or Unknown.
static String toEmailSafeString(String projectName)
          Escapes the character unsafe for e-mail address.
static String xmlEscape(String s)
           
static String xmlUnescape(String s)
           
static String xsDate(Calendar cal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_YUI

public static boolean DEBUG_YUI
Set to true if you need to use the debug version of YUI.

Constructor Detail

Functions

public Functions()
Method Detail

generateId

public String generateId()
Generates an unique ID.


isModel

public static boolean isModel(Object o)

isModelWithContextMenu

public static boolean isModelWithContextMenu(Object o)

xsDate

public static String xsDate(Calendar cal)

rfc822Date

public static String rfc822Date(Calendar cal)

initPageVariables

public static void initPageVariables(org.apache.commons.jelly.JellyContext context)

getTypeParameter

public static <B> Class getTypeParameter(Class<? extends B> c,
                                         Class<B> base,
                                         int n)
Given c=MyList (extends ArrayList<Foo>), base=List, compute the parameterization of 'base' that's assignable from 'c' (in this case List<Foo>), and return its n-th type parameter (n=0 would return Foo).

This method is useful for doing type arithmetic.

Throws:
AssertionError - if c' is not parameterized.

getJDKDescriptor

public JDK.DescriptorImpl getJDKDescriptor()

getDiffString

public static String getDiffString(int i)
Prints the integer as a string that represents difference, like "-5", "+/-0", "+3".


getDiffString2

public static String getDiffString2(int i)
getDiffString(int) that doesn't show anything for +/-0


getDiffString2

public static String getDiffString2(String prefix,
                                    int i,
                                    String suffix)
getDiffString2(int) that puts the result into prefix and suffix if there's something to print


addSuffix

public static String addSuffix(int n,
                               String singular,
                               String plural)
Adds the proper suffix.


decompose

public static Functions.RunUrl decompose(org.kohsuke.stapler.StaplerRequest req)

getScreenResolution

public static Area getScreenResolution()
If we know the user's screen resolution, return it. Otherwise null.

Since:
1.213

getNodeModes

public static Node.Mode[] getNodeModes()

getProjectListString

public static String getProjectListString(List<Project> projects)

ifThenElse

public static Object ifThenElse(boolean cond,
                                Object thenValue,
                                Object elseValue)
Deprecated. as of 1.294 JEXL now supports the real ternary operator "x?y:z", so this work around is no longer necessary.


appendIfNotNull

public static String appendIfNotNull(String text,
                                     String suffix,
                                     String nullText)

getSystemProperties

public static Map getSystemProperties()

getEnvVars

public static Map getEnvVars()

isWindows

public static boolean isWindows()

getLogRecords

public static List<LogRecord> getLogRecords()

printLogRecord

public static String printLogRecord(LogRecord r)

getCookie

public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest req,
                                                  String name)

getCookie

public static String getCookie(javax.servlet.http.HttpServletRequest req,
                               String name,
                               String defaultValue)

getYuiSuffix

public static String getYuiSuffix()
Gets the suffix to use for YUI JavaScript.


filter

public static <V> SortedMap<Integer,V> filter(SortedMap<Integer,V> map,
                                              String from,
                                              String to)
Creates a sub map by using the given range (both ends inclusive).


configureAutoRefresh

public static void configureAutoRefresh(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        boolean noAutoRefresh)
Used by layout.jelly to control the auto refresh behavior.

Parameters:
noAutoRefresh - On certain pages, like a page with forms, will have annoying interference with auto refresh. On those pages, disable auto-refresh.

isAutoRefresh

public static boolean isAutoRefresh(javax.servlet.http.HttpServletRequest request)

getNearestAncestorUrl

public static String getNearestAncestorUrl(org.kohsuke.stapler.StaplerRequest req,
                                           Object it)
Finds the given object in the ancestor list and returns its URL. This is used to determine the "current" URL assigned to the given object, so that one can compute relative URLs from it.


getSearchURL

public static String getSearchURL()
Finds the inner-most SearchableModelObject in scope.


appendSpaceIfNotNull

public static String appendSpaceIfNotNull(String n)

nbspIndent

public static String nbspIndent(String size)
One nbsp per 10 pixels in given size, which may be a plain number or "NxN" (like an iconSize). Useful in a sortable table heading.


getWin32ErrorMessage

public static String getWin32ErrorMessage(IOException e)

isMultiline

public static boolean isMultiline(String s)

encode

public static String encode(String s)

escape

public static String escape(String s)

xmlEscape

public static String xmlEscape(String s)

xmlUnescape

public static String xmlUnescape(String s)

htmlAttributeEscape

public static String htmlAttributeEscape(String text)

checkPermission

public static void checkPermission(Permission permission)
                            throws IOException,
                                   javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

checkPermission

public static void checkPermission(AccessControlled object,
                                   Permission permission)
                            throws IOException,
                                   javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

checkPermission

public static void checkPermission(Object object,
                                   Permission permission)
                            throws IOException,
                                   javax.servlet.ServletException
This version is so that the 'checkPermission' on layout.jelly degrades gracefully if "it" is not an AccessControlled object. Otherwise it will perform no check and that problem is hard to notice.

Throws:
IOException
javax.servlet.ServletException

hasPermission

public static boolean hasPermission(Permission permission)
                             throws IOException,
                                    javax.servlet.ServletException
Returns true if the current user has the given permission.

Parameters:
permission - If null, returns true. This defaulting is convenient in making the use of this method terse.
Throws:
IOException
javax.servlet.ServletException

hasPermission

public static boolean hasPermission(Object object,
                                    Permission permission)
                             throws IOException,
                                    javax.servlet.ServletException
This version is so that the 'hasPermission' can degrade gracefully if "it" is not an AccessControlled object.

Throws:
IOException
javax.servlet.ServletException

adminCheck

public static void adminCheck(org.kohsuke.stapler.StaplerRequest req,
                              org.kohsuke.stapler.StaplerResponse rsp,
                              Object required,
                              Permission permission)
                       throws IOException,
                              javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

inferHudsonURL

public static String inferHudsonURL(org.kohsuke.stapler.StaplerRequest req)
Infers the hudson installation URL from the given request.


getFooterURL

public static String getFooterURL()
Returns the link to be displayed in the footer of the UI.


getJobPropertyDescriptors

public static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz)

getBuildWrapperDescriptors

public static List<Descriptor<BuildWrapper>> getBuildWrapperDescriptors(AbstractProject<?,?> project)

getSecurityRealmDescriptors

public static List<Descriptor<SecurityRealm>> getSecurityRealmDescriptors()

getAuthorizationStrategyDescriptors

public static List<Descriptor<AuthorizationStrategy>> getAuthorizationStrategyDescriptors()

getBuilderDescriptors

public static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project)

getPublisherDescriptors

public static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project)

getSCMDescriptors

public static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?,?> project)

getComputerLauncherDescriptors

public static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors()

getRetentionStrategyDescriptors

public static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors()

getParameterDescriptors

public static List<ParameterDefinition.ParameterDescriptor> getParameterDescriptors()

getCaptchaSupportDescriptors

public static List<Descriptor<CaptchaSupport>> getCaptchaSupportDescriptors()

getViewsTabBarDescriptors

public static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors()

getMyViewsTabBarDescriptors

public static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors()

getNodePropertyDescriptors

public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz)

getSortedDescriptorsForGlobalConfig

public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(com.google.common.base.Predicate<GlobalConfigurationCategory> predicate)
Gets all the descriptors sorted by their inheritance tree of Describable so that descriptors of similar types come nearby.

We sort them by Extension.ordinal() but only for GlobalConfigurations, as the value is normally used to compare similar kinds of extensions, and we needed GlobalConfigurations to be able to position themselves in a layer above. This however creates some asymmetry between regular Descriptors and GlobalConfigurations. Perhaps it is better to introduce another annotation element? But then, extensions shouldn't normally concern themselves about ordering too much, and the only reason we needed this for GlobalConfigurations are for backward compatibility.

Parameters:
predicate - Filter the descriptors based on GlobalConfigurationCategory
Since:
1.494

getSortedDescriptorsForGlobalConfig

public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig()
Like getSortedDescriptorsForGlobalConfig(Predicate) but with a constant truth predicate, to include all descriptors.


getSortedDescriptorsForGlobalConfigNoSecurity

@Deprecated
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigNoSecurity()
Deprecated. This is rather meaningless.


getSortedDescriptorsForGlobalConfigUnclassified

public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigUnclassified()
Like getSortedDescriptorsForGlobalConfig(Predicate) but for unclassified descriptors only.

Since:
1.506

getIconFilePath

public static String getIconFilePath(Action a)
Computes the path to the icon of the given action from the context path.


size2

public static int size2(Object o)
                 throws Exception
Works like JSTL build-in size(x) function, but handle null gracefully.

Throws:
Exception

getRelativeLinkTo

public static String getRelativeLinkTo(Item p)
Computes the relative path from the current page to the given item.


getAllTopLevelItems

public static List<TopLevelItem> getAllTopLevelItems(ItemGroup root)
Gets all the TopLevelItems recursively in the ItemGroup tree.

Since:
1.512

getRelativeDisplayNameFrom

public static String getRelativeDisplayNameFrom(Item p,
                                                ItemGroup g)
Gets the relative display name to the given item from the specified group.

Parameters:
p - the Item we want the relative display name
g - the ItemGroup used as point of reference for the item
Returns:
String like "foo ยป bar"
Since:
1.512

dumpAllThreads

public static Map<Thread,StackTraceElement[]> dumpAllThreads()

getThreadInfos

@IgnoreJRERequirement
public static ThreadInfo[] getThreadInfos()

sortThreadsAndGetGroupMap

public static Functions.ThreadGroupMap sortThreadsAndGetGroupMap(ThreadInfo[] list)

isMustangOrAbove

@IgnoreJRERequirement
public static boolean isMustangOrAbove()
Are we running on JRE6 or above?


dumpThreadInfo

@IgnoreJRERequirement
public static String dumpThreadInfo(ThreadInfo ti,
                                                         Functions.ThreadGroupMap map)

emptyList

public static <T> Collection<T> emptyList()

jsStringEscape

public static String jsStringEscape(String s)

capitalize

public static String capitalize(String s)
Converts "abc" to "Abc".


getVersion

public static String getVersion()

getResourcePath

public static String getResourcePath()
Resoruce path prefix.


getViewResource

public static String getViewResource(Object it,
                                     String path)

hasView

public static boolean hasView(Object it,
                              String path)
                       throws IOException
Throws:
IOException

defaultToTrue

public static boolean defaultToTrue(Boolean b)
Can be used to check a checkbox by default. Used from views like h.defaultToTrue(scm.useUpdate). The expression will evaluate to true if scm is null.


defaulted

public static <T> T defaulted(T value,
                              T defaultValue)
If the value exists, return that value. Otherwise return the default value.

Starting 1.294, JEXL supports the elvis operator "x?:y" that supercedes this.

Since:
1.150

printThrowable

public static String printThrowable(Throwable t)

determineRows

public static int determineRows(String s)
Counts the number of rows needed for textarea to fit the content. Minimum 5 rows.


toCCStatus

public static String toCCStatus(Item i)
Converts the Hudson build status to CruiseControl build status, which is either Success, Failure, Exception, or Unknown.


isAnonymous

public static boolean isAnonymous()
Checks if the current user is anonymous.


getCurrentJellyContext

public static org.apache.commons.jelly.JellyContext getCurrentJellyContext()
When called from within JEXL expression evaluation, this method returns the current JellyContext used to evaluate the script.

Since:
1.164

runScript

public static String runScript(org.apache.commons.jelly.Script script)
                        throws org.apache.commons.jelly.JellyTagException
Evaluate a Jelly script and return output as a String.

Throws:
org.apache.commons.jelly.JellyTagException
Since:
1.267

subList

public static <T> List<T> subList(List<T> base,
                                  int maxSize)
Returns a sub-list if the given list is bigger than the specified 'maxSize'


joinPath

public static String joinPath(String... components)
Combine path components via '/' while handling leading/trailing '/' to avoid duplicates.


getActionUrl

public static String getActionUrl(String itUrl,
                                  Action action)
Computes the hyperlink to actions, to handle the situation when the Action.getUrlName() returns absolute URL.


toEmailSafeString

public static String toEmailSafeString(String projectName)
Escapes the character unsafe for e-mail address. See http://en.wikipedia.org/wiki/E-mail_address for the details, but here the vocabulary is even more restricted.


getSystemProperty

public String getSystemProperty(String key)

getServerName

public String getServerName()
Obtains the host name of the Hudson server that clients can use to talk back to.

This is primarily used in slave-agent.jnlp.jelly to specify the destination that the slaves talk to.


getCheckUrl

public String getCheckUrl(String userDefined,
                          Object descriptor,
                          String field)
Determines the form validation check URL. See textbox.jelly


hyperlinkMatchesCurrentPage

public boolean hyperlinkMatchesCurrentPage(String href)
                                    throws UnsupportedEncodingException
If the given href link is matching the current page, return true. Used in task.jelly to decide if the page should be highlighted.

Throws:
UnsupportedEncodingException

singletonList

public <T> List<T> singletonList(T t)

getPageDecorators

public static List<PageDecorator> getPageDecorators()
Gets all the PageDecorators.


getCloudDescriptors

public static List<Descriptor<Cloud>> getCloudDescriptors()

prepend

public String prepend(String prefix,
                      String body)
Prepend a prefix only when there's the specified body.


getCrumbIssuerDescriptors

public static List<Descriptor<CrumbIssuer>> getCrumbIssuerDescriptors()

getCrumb

public static String getCrumb(org.kohsuke.stapler.StaplerRequest req)

getCrumbRequestField

public static String getCrumbRequestField()

getCurrentTime

public static Date getCurrentTime()

getCurrentLocale

public static Locale getCurrentLocale()

generateConsoleAnnotationScriptAndStylesheet

public static String generateConsoleAnnotationScriptAndStylesheet()
Generate a series of <script> tags to include script.js from ConsoleAnnotatorFactorys and ConsoleAnnotationDescriptors.


getLoggerNames

public List<String> getLoggerNames()
Work around for bug 6935026.


getPasswordValue

public String getPasswordValue(Object o)
Used by <f:password/> so that we send an encrypted value to the client.


filterDescriptors

public List filterDescriptors(Object context,
                              Iterable descriptors)

getIsUnitTest

public static boolean getIsUnitTest()
Returns true if we are running unit tests.


isArtifactsPermissionEnabled

public static boolean isArtifactsPermissionEnabled()
Returns true if the Run.ARTIFACTS permission is enabled, false otherwise.

When the Run.ARTIFACTS permission is not turned on using the hudson.security.ArtifactsPermission system property, this permission must not be considered to be set to false for every user. It must rather be like if the permission doesn't exist at all (which means that every user has to have an access to the artifacts but the permission can't be configured in the security screen). Got it?


isWipeOutPermissionEnabled

public static boolean isWipeOutPermissionEnabled()
Returns true if the Item.WIPEOUT permission is enabled, false otherwise.

The "Wipe Out Workspace" action available on jobs is controlled by the Item.BUILD permission. For some specific projects, however, it is not acceptable to let users have this possibility, even it they can trigger builds. As such, when enabling the hudson.security.WipeOutPermission system property, a new "WipeOut" permission will allow to have greater control on the "Wipe Out Workspace" action.


createRenderOnDemandProxy

public static String createRenderOnDemandProxy(org.apache.commons.jelly.JellyContext context,
                                               String attributesToCapture)

getCurrentDescriptorByNameUrl

public static String getCurrentDescriptorByNameUrl()

setCurrentDescriptorByNameUrl

public static String setCurrentDescriptorByNameUrl(String value)

restoreCurrentDescriptorByNameUrl

public static void restoreCurrentDescriptorByNameUrl(String old)

getRequestHeaders

public static List<String> getRequestHeaders(String name)

rawHtml

public static Object rawHtml(Object o)
Used for arguments to internationalized expressions to avoid escape


getCLICommands

public static ArrayList<CLICommand> getCLICommands()

getAvatar

public static String getAvatar(User user,
                               String avatarSize)
Returns an avatar image URL for the specified user and preferred image size

Parameters:
user - the user
avatarSize - the preferred size of the avatar image
Returns:
a URL string
Since:
1.433

getUserAvatar

public String getUserAvatar(User user,
                            String avatarSize)
Deprecated. as of 1.451 Use getAvatar(hudson.model.User, java.lang.String)


humanReadableByteSize

public static String humanReadableByteSize(long size)
Returns human readable information about file size

Parameters:
file - size in bytes
Returns:
file size in appropriate unit


Copyright © 2004-2013. All Rights Reserved.