public class Functions extends Object
An instance of this class is created for each request and made accessible from view pages via the variable 'h' (h stands for Hudson.)
Modifier and Type | Class and Description |
---|---|
static class |
Functions.RunUrl
URL decomposed for easier computation of relevant URLs.
|
static class |
Functions.ThreadGroupMap |
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG_YUI
Set to true if you need to use the debug version of YUI.
|
Constructor and Description |
---|
Functions() |
Modifier and Type | Method and Description |
---|---|
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 void |
advertiseHeaders(javax.servlet.http.HttpServletResponse rsp)
Advertises the minimum set of HTTP headers that assist programmatic
discovery of Jenkins.
|
static String |
appendIfNotNull(String text,
String suffix,
String nullText) |
static String |
appendSpaceIfNotNull(String n) |
static String |
breakableString(String plain)
Get a string that can be safely broken to several lines when necessary.
|
void |
calcCheckUrl(Map attributes,
String userDefined,
Object descriptor,
String field)
Determines the parameters that client-side needs for a form validation check.
|
static String |
capitalize(String s)
Converts "abc" to "Abc".
|
static void |
checkAnyPermission(AccessControlled ac,
Permission[] permissions)
Checks if the current security principal has one of the supplied permissions.
|
static void |
checkAnyPermission(Object object,
Permission[] permissions)
This version is so that the 'checkAnyPermission' on
layout.jelly
degrades gracefully if "it" is not an AccessControlled object. |
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)
Deprecated.
auto refresh has been removed
|
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 String |
extractPluginNameFromIconSrc(String iconSrc) |
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 <V> SortedMap<Integer,V> |
filterExcludingFrom(SortedMap<Integer,V> map,
String from,
String to)
Creates a sub map by using the given range (upper end inclusive).
|
static String |
generateConsoleAnnotationScriptAndStylesheet()
Generate a series of
<script> tags to include script.js
from ConsoleAnnotatorFactory s and ConsoleAnnotationDescriptor s. |
String |
generateId()
Generates an unique ID.
|
static String |
generateItemId() |
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
TopLevelItem s 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)
|
static ArrayList<CLICommand> |
getCLICommands() |
static List<Descriptor<Cloud>> |
getCloudDescriptors() |
static List<Descriptor<ComputerLauncher>> |
getComputerLauncherDescriptors()
Deprecated.
replaced by
Slave.SlaveDescriptor#computerLauncherDescriptors(Slave) |
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 List<NodePropertyDescriptor> |
getGlobalNodePropertyDescriptors()
Returns those node properties which can be configured as global node properties.
|
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) |
static List<JobPropertyDescriptor> |
getJobPropertyDescriptors(Job job) |
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)
Deprecated.
replaced by
Slave.SlaveDescriptor#nodePropertyDescriptors(Slave) |
static List<PageDecorator> |
getPageDecorators()
Gets all the
PageDecorator s. |
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<AbstractProject> 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 String |
getRelativeNameFrom(Item p,
ItemGroup g)
Gets the name to the given item relative to given group.
|
static String |
getRelativeNameFrom(Item p,
ItemGroup g,
boolean useDisplayName)
Gets the relative name or display name to the given item from the specified group.
|
static List<String> |
getRequestHeaders(String name) |
static String |
getResourcePath()
Resource path prefix.
|
static List<Descriptor<RetentionStrategy<?>>> |
getRetentionStrategyDescriptors()
Deprecated.
replaced by
Slave.SlaveDescriptor#retentionStrategyDescriptors(Slave) |
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()
Deprecated.
|
static SimplePageDecorator |
getSimplePageDecorator()
Gets only one
SimplePageDecorator . |
static List<SimplePageDecorator> |
getSimplePageDecorators() |
static Collection<Descriptor> |
getSortedDescriptorsForGlobalConfig(com.google.common.base.Predicate<GlobalConfigurationCategory> predicate)
Deprecated.
|
static Collection<Descriptor> |
getSortedDescriptorsForGlobalConfigByDescriptor()
Like
getSortedDescriptorsForGlobalConfigByDescriptor(Predicate) but with a constant truth predicate, to include all descriptors. |
static Collection<Descriptor> |
getSortedDescriptorsForGlobalConfigByDescriptor(Predicate<Descriptor> 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()
Descriptors in the global configuration form that users with
Jenkins.MANAGE permission can configure. |
static Collection<Descriptor> |
getSortedDescriptorsForGlobalConfigUnclassifiedReadable()
Descriptors shown in the global configuration form to users with
Jenkins.SYSTEM_READ permission. |
static Map |
getSystemProperties() |
static String |
getSystemProperty(String key)
Gets the system property indicated by the specified key.
|
static ThreadInfo[] |
getThreadInfos() |
static String |
getTimeSpanString(Date date)
Returns a human-readable string describing the time difference between now and the specified date.
|
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 |
getUserTimeZone() |
static String |
getUserTimeZonePostfix() |
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 |
hasAnyPermission(AccessControlled ac,
Permission[] permissions)
Checks if the current security principal has one of the supplied permissions.
|
static boolean |
hasAnyPermission(Object object,
Permission[] permissions)
This version is so that the 'hasAnyPermission'
degrades gracefully if "it" is not an
AccessControlled object. |
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()
|
static boolean |
isAutoRefresh(javax.servlet.http.HttpServletRequest request)
Deprecated.
|
static boolean |
isCollapsed(String paneId) |
static boolean |
isContextMenuVisible(Action a) |
static boolean |
isExtensionsAvailable()
During Jenkins start-up, before
InitMilestone.PLUGINS_STARTED the extensions lists will be empty
and they are not guaranteed to be fully populated until after InitMilestone.EXTENSIONS_AUGMENTED ,
similarly, during termination after Jenkins.isTerminating() is set, it is no longer safe to access
the extensions lists. |
static boolean |
isGlibcSupported() |
static boolean |
isMatrixProject(Object o)
Deprecated.
|
static boolean |
isModel(Object o) |
static boolean |
isModelWithChildren(Object o) |
static boolean |
isModelWithContextMenu(Object o) |
static boolean |
isMultiline(String s) |
static boolean |
isMustangOrAbove()
Deprecated.
Now always true.
|
static String |
iso8601DateTime(Date date) |
static boolean |
isUserTimeZoneOverride() |
static boolean |
isWindows() |
static boolean |
isWipeOutPermissionEnabled()
|
static String |
joinPath(String... components)
Combine path components via '/' while handling leading/trailing '/' to avoid duplicates.
|
static String |
jsStringEscape(String s) |
static String |
localDate(Date date)
Returns a localized string for the specified date, not including time.
|
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[] |
printLogRecordHtml(LogRecord r,
LogRecord prior) |
static void |
printStackTrace(Throwable t,
PrintStream ps)
Like
Throwable.printStackTrace(PrintStream) but using printThrowable(java.lang.Throwable) format. |
static void |
printStackTrace(Throwable t,
PrintWriter pw)
Like
Throwable.printStackTrace(PrintWriter) but using printThrowable(java.lang.Throwable) format. |
static String |
printThrowable(Throwable t)
Prints a stack trace from an exception into a readable form.
|
static Object |
rawHtml(Object o)
Used for arguments to internationalized expressions to avoid escape
|
static void |
restoreCurrentDescriptorByNameUrl(String old) |
static <T> Iterable<T> |
reverse(Collection<T> collection)
Reverses a collection so that it can be easily walked in reverse order.
|
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)
Deprecated.
This functionality has been moved to ccxml plugin.
|
static String |
toEmailSafeString(String projectName)
Escapes the character unsafe for e-mail address.
|
static Icon |
tryGetIcon(String iconGuess) |
static String |
tryGetIconPath(String iconGuess,
org.apache.commons.jelly.JellyContext context) |
static String |
urlEncode(String s)
Shortcut function for calling
URLEncoder.encode(String,String) (with UTF-8 encoding).Useful for encoding URL query parameters in jelly code (as in "...?param=${h.urlEncode(something)}" ).For convenience in jelly code, it also accepts null parameter, and then returns an empty string. |
static boolean |
useHidingPasswordFields() |
static String |
validateIconSize(String iconSize) |
static String |
xmlEscape(String s) |
static String |
xmlUnescape(String s) |
static String |
xsDate(Calendar cal) |
public static boolean DEBUG_YUI
public String generateId()
public static boolean isModel(Object o)
public static boolean isModelWithContextMenu(Object o)
public static boolean isModelWithChildren(Object o)
@Deprecated public static boolean isMatrixProject(Object o)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String iso8601DateTime(Date date)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String localDate(Date date)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String getTimeSpanString(Date date)
public static boolean isExtensionsAvailable()
InitMilestone.PLUGINS_STARTED
the extensions lists will be empty
and they are not guaranteed to be fully populated until after InitMilestone.EXTENSIONS_AUGMENTED
,
similarly, during termination after Jenkins.isTerminating()
is set, it is no longer safe to access
the extensions lists.
If you attempt to access the extensions list from a UI thread while the extensions are being loaded you will
hit a big honking great monitor lock that will block until the effective extension list has been determined
(as if a plugin fails to start, all of the failed plugin's extensions and any dependent plugins' extensions
will have to be evicted from the list of extensions. In practical terms this only affects the
"Jenkins is loading" screen, but as that screen uses the generic layouts we provide this utility method
so that the generic layouts can avoid iterating extension lists while Jenkins is starting up.
If you attempt to access the extensions list from a UI thread while Jenkins is being shut down, the extensions
themselves may no longer be in a valid state and could attempt to revive themselves and block termination.
In actual terms the termination only affects those views required to render HudsonIsRestarting
's
index.jelly
which is the same set as the HudsonIsLoading
pages so it makes sense to
use both checks here.true
if the extensions lists have been populated.public static void initPageVariables(org.apache.commons.jelly.JellyContext context)
public static <B> Class getTypeParameter(Class<? extends B> c, Class<B> base, int n)
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.
AssertionError
- if c' is not parameterized.public JDK.DescriptorImpl getJDKDescriptor()
public static String getDiffString(int i)
public static String getDiffString2(int i)
getDiffString(int)
that doesn't show anything for +/-0public static String getDiffString2(String prefix, int i, String suffix)
getDiffString2(int)
that puts the result into prefix and suffix
if there's something to printpublic static String addSuffix(int n, String singular, String plural)
public static Functions.RunUrl decompose(org.kohsuke.stapler.StaplerRequest req)
public static Area getScreenResolution()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean useHidingPasswordFields()
public static Node.Mode[] getNodeModes()
public static String getProjectListString(List<AbstractProject> projects)
@Deprecated public static Object ifThenElse(boolean cond, Object thenValue, Object elseValue)
public static Map getSystemProperties()
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public static String getSystemProperty(String key)
SystemProperties.getString(String)
.public static Map getEnvVars()
public static boolean isWindows()
public static boolean isGlibcSupported()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String[] printLogRecordHtml(LogRecord r, LogRecord prior)
public static <T> Iterable<T> reverse(Collection<T> collection)
public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest req, String name)
public static String getCookie(javax.servlet.http.HttpServletRequest req, String name, String defaultValue)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String validateIconSize(String iconSize) throws SecurityException
SecurityException
public static String getYuiSuffix()
public static <V> SortedMap<Integer,V> filter(SortedMap<Integer,V> map, String from, String to)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static <V> SortedMap<Integer,V> filterExcludingFrom(SortedMap<Integer,V> map, String from, String to)
@Deprecated public static void configureAutoRefresh(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean noAutoRefresh)
@Deprecated public static boolean isAutoRefresh(javax.servlet.http.HttpServletRequest request)
public static boolean isCollapsed(String paneId)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean isUserTimeZoneOverride()
@CheckForNull @Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String getUserTimeZone()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String getUserTimeZonePostfix()
public static String getNearestAncestorUrl(org.kohsuke.stapler.StaplerRequest req, Object it)
public static String getSearchURL()
SearchableModelObject
in scope.public static String nbspIndent(String size)
public static String getWin32ErrorMessage(IOException e)
public static boolean isMultiline(String s)
public static String urlEncode(String s)
URLEncoder.encode(String,String)
(with UTF-8 encoding)."...?param=${h.urlEncode(something)}"
).public static void checkPermission(Permission permission) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public static void checkPermission(AccessControlled object, Permission permission) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public static void checkPermission(Object object, Permission permission) throws IOException, javax.servlet.ServletException
layout.jelly
degrades gracefully if "it" is not an AccessControlled
object.
Otherwise it will perform no check and that problem is hard to notice.IOException
javax.servlet.ServletException
public static boolean hasPermission(Permission permission) throws IOException, javax.servlet.ServletException
permission
- If null, returns true. This defaulting is convenient in making the use of this method terse.IOException
javax.servlet.ServletException
public static boolean hasPermission(Object object, Permission permission) throws IOException, javax.servlet.ServletException
AccessControlled
object.IOException
javax.servlet.ServletException
public static void adminCheck(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, Object required, Permission permission) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public static String inferHudsonURL(org.kohsuke.stapler.StaplerRequest req)
public static String getFooterURL()
public static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz)
public static List<JobPropertyDescriptor> getJobPropertyDescriptors(Job job)
public static List<Descriptor<BuildWrapper>> getBuildWrapperDescriptors(AbstractProject<?,?> project)
public static List<Descriptor<SecurityRealm>> getSecurityRealmDescriptors()
public static List<Descriptor<AuthorizationStrategy>> getAuthorizationStrategyDescriptors()
public static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project)
public static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project)
public static List<SCMDescriptor<?>> getSCMDescriptors(AbstractProject<?,?> project)
@Deprecated @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince(value="2.12") public static List<Descriptor<ComputerLauncher>> getComputerLauncherDescriptors()
Slave.SlaveDescriptor#computerLauncherDescriptors(Slave)
@Deprecated @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince(value="2.12") public static List<Descriptor<RetentionStrategy<?>>> getRetentionStrategyDescriptors()
Slave.SlaveDescriptor#retentionStrategyDescriptors(Slave)
public static List<ParameterDefinition.ParameterDescriptor> getParameterDescriptors()
public static List<Descriptor<CaptchaSupport>> getCaptchaSupportDescriptors()
public static List<Descriptor<ViewsTabBar>> getViewsTabBarDescriptors()
public static List<Descriptor<MyViewsTabBar>> getMyViewsTabBarDescriptors()
@Deprecated @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince(value="2.12") public static List<NodePropertyDescriptor> getNodePropertyDescriptors(Class<? extends Node> clazz)
Slave.SlaveDescriptor#nodePropertyDescriptors(Slave)
public static List<NodePropertyDescriptor> getGlobalNodePropertyDescriptors()
@Deprecated @Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Collection<Descriptor> getSortedDescriptorsForGlobalConfig(com.google.common.base.Predicate<GlobalConfigurationCategory> predicate)
getSortedDescriptorsForGlobalConfigByDescriptor(Predicate)
Describable
so that descriptors of similar types come nearby.
We sort them by Extension.ordinal()
but only for GlobalConfiguration
s,
as the value is normally used to compare similar kinds of extensions, and we needed
GlobalConfiguration
s to be able to position themselves in a layer above.
This however creates some asymmetry between regular Descriptor
s and GlobalConfiguration
s.
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 GlobalConfiguration
s are for backward compatibility.
predicate
- Filter the descriptors based on this predicatepublic static Collection<Descriptor> getSortedDescriptorsForGlobalConfigByDescriptor(Predicate<Descriptor> predicate)
Describable
so that descriptors of similar types come nearby.
We sort them by Extension.ordinal()
but only for GlobalConfiguration
s,
as the value is normally used to compare similar kinds of extensions, and we needed
GlobalConfiguration
s to be able to position themselves in a layer above.
This however creates some asymmetry between regular Descriptor
s and GlobalConfiguration
s.
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 GlobalConfiguration
s are for backward compatibility.
predicate
- Filter the descriptors based on this predicatepublic static Collection<Descriptor> getSortedDescriptorsForGlobalConfigByDescriptor()
getSortedDescriptorsForGlobalConfigByDescriptor(Predicate)
but with a constant truth predicate, to include all descriptors.@Deprecated public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigNoSecurity()
public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigUnclassified()
Jenkins.MANAGE
permission can configure.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Collection<Descriptor> getSortedDescriptorsForGlobalConfigUnclassifiedReadable()
Jenkins.SYSTEM_READ
permission.public static boolean hasAnyPermission(AccessControlled ac, Permission[] permissions)
public static boolean hasAnyPermission(Object object, Permission[] permissions) throws IOException, javax.servlet.ServletException
AccessControlled
object.
Otherwise it will perform no check and that problem is hard to notice.IOException
javax.servlet.ServletException
public static void checkAnyPermission(AccessControlled ac, Permission[] permissions)
org.springframework.security.access.AccessDeniedException
- if the user doesn't have the permission.public static void checkAnyPermission(Object object, Permission[] permissions) throws IOException, javax.servlet.ServletException
layout.jelly
degrades gracefully if "it" is not an AccessControlled
object.
Otherwise it will perform no check and that problem is hard to notice.IOException
javax.servlet.ServletException
public static String getIconFilePath(Action a)
public static int size2(Object o) throws Exception
Exception
public static String getRelativeLinkTo(Item p)
public static List<TopLevelItem> getAllTopLevelItems(ItemGroup root)
TopLevelItem
s recursively in the ItemGroup
tree.@Nullable public static String getRelativeNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g, boolean useDisplayName)
p
- the Item we want the relative display name.
If null
, a null
will be returned by the methodg
- the ItemGroup used as point of reference for the item.
If the group is not specified, item's path will be used.useDisplayName
- if true, returns a display name, otherwise returns a namenull
if item is null or if one of its parents is not an Item
.@Nullable public static String getRelativeNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g)
p
- the Item we want the relative display name
If null
, the method will immediately return null
.g
- the ItemGroup used as point of reference for the itemnull
if the item is null
or if one of its parents is not an Item
.@Nullable public static String getRelativeDisplayNameFrom(@CheckForNull Item p, @CheckForNull ItemGroup g)
p
- the Item we want the relative display name.
If null
, the method will immediately return null
.g
- the ItemGroup used as point of reference for the itemnull
if the item is null
or if one of its parents is not an Item
.public static Map<Thread,StackTraceElement[]> dumpAllThreads()
public static ThreadInfo[] getThreadInfos()
public static Functions.ThreadGroupMap sortThreadsAndGetGroupMap(ThreadInfo[] list)
@Deprecated public static boolean isMustangOrAbove()
public static String dumpThreadInfo(ThreadInfo ti, Functions.ThreadGroupMap map)
public static <T> Collection<T> emptyList()
public static String getVersion()
public static String getResourcePath()
public static boolean hasView(Object it, String path) throws IOException
IOException
public static boolean defaultToTrue(Boolean b)
h.defaultToTrue(scm.useUpdate)
.
The expression will evaluate to true if scm is null.public static <T> T defaulted(T value, T defaultValue)
Starting 1.294, JEXL supports the elvis operator "x?:y" that supersedes this.
@NonNull public static String printThrowable(@CheckForNull Throwable t)
Throwable.printStackTrace(PrintWriter)
, this implementation follows the suggestion of JDK-6507809
to produce a linear trace even when Throwable.getCause()
is used.t
- Input Throwable
t
is not null, generally a multiline string ending in a (platform-specific) newline;
otherwise, the method returns a default
"No exception details" string.public static void printStackTrace(@CheckForNull Throwable t, @NonNull PrintWriter pw)
Throwable.printStackTrace(PrintWriter)
but using printThrowable(java.lang.Throwable)
format.t
- an exception to printpw
- the logpublic static void printStackTrace(@CheckForNull Throwable t, @NonNull PrintStream ps)
Throwable.printStackTrace(PrintStream)
but using printThrowable(java.lang.Throwable)
format.t
- an exception to printps
- the logpublic static int determineRows(String s)
@Deprecated @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince(value="2.173") public static String toCCStatus(Item i)
public static boolean isAnonymous()
public static org.apache.commons.jelly.JellyContext getCurrentJellyContext()
JellyContext
used
to evaluate the script.public static String runScript(org.apache.commons.jelly.Script script) throws org.apache.commons.jelly.JellyTagException
org.apache.commons.jelly.JellyTagException
public static <T> List<T> subList(List<T> base, int maxSize)
maxSize
.
Warning: do not call this with a RunList
, or you will break lazy loading!public static String joinPath(String... components)
@CheckForNull public static String getActionUrl(String itUrl, Action action)
Action.getUrlName()
returns absolute URL.public static String toEmailSafeString(String projectName)
@Deprecated public String getServerName()
JNLPLauncher.getInboundAgentUrl()
This was primarily used in jenkins-agent.jnlp.jelly
to specify the destination
that the agents talk to.
@Deprecated public String getCheckUrl(String userDefined, Object descriptor, String field)
public void calcCheckUrl(Map attributes, String userDefined, Object descriptor, String field)
public boolean hyperlinkMatchesCurrentPage(String href) throws UnsupportedEncodingException
task.jelly
to decide if the page should be highlighted.UnsupportedEncodingException
public <T> List<T> singletonList(T t)
public static List<PageDecorator> getPageDecorators()
PageDecorator
s.public static SimplePageDecorator getSimplePageDecorator()
SimplePageDecorator
.public static List<SimplePageDecorator> getSimplePageDecorators()
public static List<Descriptor<Cloud>> getCloudDescriptors()
public String prepend(String prefix, String body)
public static List<Descriptor<CrumbIssuer>> getCrumbIssuerDescriptors()
public static String getCrumb(org.kohsuke.stapler.StaplerRequest req)
public static String getCrumbRequestField()
public static Date getCurrentTime()
public static Locale getCurrentLocale()
public static String generateConsoleAnnotationScriptAndStylesheet()
<script>
tags to include script.js
from ConsoleAnnotatorFactory
s and ConsoleAnnotationDescriptor
s.public String getPasswordValue(Object o)
<f:password/>
so that we send an encrypted value to the client.public static boolean getIsUnitTest()
public static boolean isArtifactsPermissionEnabled()
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?
public static boolean isWipeOutPermissionEnabled()
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.
public static String createRenderOnDemandProxy(org.apache.commons.jelly.JellyContext context, String attributesToCapture)
public static String getCurrentDescriptorByNameUrl()
public static void restoreCurrentDescriptorByNameUrl(String old)
public static Object rawHtml(Object o)
public static ArrayList<CLICommand> getCLICommands()
public static String getAvatar(User user, String avatarSize)
user
- the useravatarSize
- the preferred size of the avatar image@Deprecated public String getUserAvatar(User user, String avatarSize)
getAvatar(hudson.model.User, java.lang.String)
public static String humanReadableByteSize(long size)
size
- file size in bytespublic static String breakableString(String plain)
<wbr>
tags into string. It allows browsers
to wrap line before any sequence of punctuation characters or anywhere
in the middle of prolonged sequences of word characters.public static void advertiseHeaders(javax.servlet.http.HttpServletResponse rsp)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean isContextMenuVisible(Action a)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Icon tryGetIcon(String iconGuess)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String extractPluginNameFromIconSrc(String iconSrc)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String tryGetIconPath(String iconGuess, org.apache.commons.jelly.JellyContext context)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String generateItemId()
Copyright © 2004–2022. All rights reserved.