Class AbstractFolder<I extends TopLevelItem>
java.lang.Object
hudson.model.AbstractModelObject
hudson.model.Actionable
hudson.model.AbstractItem
com.cloudbees.hudson.plugins.folder.AbstractFolder<I>
- All Implemented Interfaces:
ExtensionPoint
,Describable<TopLevelItem>
,DescriptorByNameOwner
,Item
,ItemGroup<I>
,ModelObject
,ModifiableViewGroup
,PersistenceRoot
,Saveable
,TopLevelItem
,ViewGroup
,SearchableModelObject
,SearchItem
,AccessControlled
,Loadable
,ModelObjectWithChildren
,ModelObjectWithContextMenu
,OnMaster
,org.kohsuke.stapler.HttpDeletable
,org.kohsuke.stapler.StaplerFallback
,org.kohsuke.stapler.StaplerOverridable
,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
ComputedFolder
,Folder
public abstract class AbstractFolder<I extends TopLevelItem>
extends AbstractItem
implements TopLevelItem, ItemGroup<I>, ModifiableViewGroup, org.kohsuke.stapler.StaplerFallback, ModelObjectWithChildren, org.kohsuke.stapler.StaplerOverridable
A general-purpose
ItemGroup
.
Base for Folder
and ComputedFolder
.
Extending Folders UI
As any other Item
type, folder types support extension of UI via Action
s.
These actions can be persisted or added via TransientActionFactory
.
See this page
for more details about actions.
In folders actions provide the following features:
- Left sidepanel hyperlink, which opens the page specified by action's
index.jelly
. - Optional summary boxes on the main panel, which may be defined by
summary.jelly
.
- Since:
- 4.11-beta-1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Nested classes/interfaces inherited from interface org.kohsuke.stapler.HttpDeletable
org.kohsuke.stapler.HttpDeletable.HttpDeletableDispatcher
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
Field Summary
Modifier and TypeFieldDescriptionChild items, keyed byItem.getName()
.protected static final ThreadLocal<Boolean>
Whether execution is currently insidereloadThis()
.Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractFolder
(ItemGroup parent, String name) Subclasses should also callinit()
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLoadedChild
(I item, String name) Adds an item to be the folder which was already loaded viaItems.load(hudson.model.ItemGroup, java.io.File)
.void
void
boolean
protected void
checkRename
(String newName) void
deleteView
(View view) doChildrenContextMenu
(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) void
doConfigSubmit
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) void
doCreateView
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) org.kohsuke.stapler.HttpResponse
Stapler action method to disable the folder.org.kohsuke.stapler.HttpResponse
doEnable()
Stapler action method to enable the folder.org.kohsuke.stapler.HttpResponse
doLastBuild
(org.kohsuke.stapler.StaplerRequest req) void
doSubmitDescription
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) doViewExistsCheck
(String value) Checks if a top-level view with the given name exists.Collection<? extends Job>
Get the current health report for a folder.getIcon()
Gets the icon used for this folder.ItemGroup<? extends TopLevelItem>
getItemName
(File dir, I item) getItems()
For URL binding.protected File
May be overridden, butloadJobTotal()
will be inaccurate in that case.Collection<?>
Overrides from job properties.May be used to enumerate or remove properties.getRootDirFor
(I child) protected final File
getRootDirFor
(String name) Fallback to the primary view.protected String
Where user will be redirected after creating or reconfiguring aAbstractFolder
.It is unwise to override this, lest links to children from nondefaultView
s break.getViews()
boolean
Checks if folder has visible itemsprotected void
init()
protected void
void
Invalidates the cache of build health reports.boolean
Is this folder disabled.boolean
protected final I
static <K,
V extends TopLevelItem>
Map<K,V> loadChildren
(AbstractFolder<V> parent, File modulesDir, Function<? super V, ? extends K> key) Loads all the childItem
s.static void
void
makeDisabled
(boolean disabled) Makes the folder disabled.protected SearchIndexBuilder
protected FolderIcon
protected DefaultViewsTabBar
protected AbstractFolderViewHolder
void
void
void
void
onViewRenamed
(View view, String oldName, String newName) void
Reloads this folder itself.protected String
Deprecated.void
Renames this item container.void
void
save()
protected void
setDisabled
(boolean disabled) Sets the folder as disabled.void
setIcon
(FolderIcon icon) void
protected void
submit
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) boolean
Determines whether the folder supports being made disabled.Methods inherited from class hudson.model.AbstractItem
delete, delete, delete, doCheckNewName, doConfigDotXml, doConfigDotXml, doConfirmRename, doDoDelete, doDoDelete, doReload, doSetName, doSubmitDescription, getAbsoluteUrl, getACL, getApi, getConfigFile, getDescription, getDisplayName, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getRelativeDisplayNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getTarget, getTaskNoun, getUrl, load, movedTo, onCopiedFrom, performDelete, resolveForCLI, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml, writeConfigDotXml, writeReplace
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActions
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, getACL, hasAnyPermission, hasPermission, hasPermission, hasPermission2
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
Methods inherited from interface hudson.model.Item
delete, getAbsoluteUrl, getDisplayName, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom, onCreatedFromScratch
Methods inherited from interface hudson.model.ItemGroup
allItems, allItems, allItems, getAllItems, getAllItems, getAllItems, getFullDisplayName, getFullName, getItemsStream, getItemsStream, getUrl
Methods inherited from interface jenkins.model.ModelObjectWithChildren
doChildrenContextMenu
Methods inherited from interface hudson.model.PersistenceRoot
getRootDir
Methods inherited from interface hudson.search.SearchableModelObject
getSearch
Methods inherited from interface hudson.search.SearchItem
getSearchIndex, getSearchName, getSearchUrl
Methods inherited from interface hudson.model.ViewGroup
getAllViews, getUrl
-
Field Details
-
reloadingThis
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected static final ThreadLocal<Boolean> reloadingThisWhether execution is currently insidereloadThis()
. -
items
Child items, keyed byItem.getName()
.
-
-
Constructor Details
-
AbstractFolder
Subclasses should also callinit()
.- Parameters:
parent
- the parent of this folder.name
- the name
-
-
Method Details
-
loadJobTotal
-
init
protected void init() -
newDefaultViewsTabBar
-
newFolderViewHolder
-
newDefaultFolderIcon
-
initViews
- Throws:
IOException
-
loadChildren
public static <K,V extends TopLevelItem> Map<K,V> loadChildren(AbstractFolder<V> parent, File modulesDir, Function<? super V, ? extends K> key) Loads all the childItem
s.- Type Parameters:
K
- the key typeV
- the child type.- Parameters:
parent
- the parent of the children.modulesDir
- Directory that contains sub-directories for each child item.key
- the key generating function.- Returns:
- a map of the children keyed by the generated keys.
-
getItemName
- Specified by:
getItemName
in interfaceItemGroup<I extends TopLevelItem>
-
itemsPut
-
reloadThis
Reloads this folder itself. Compared toAbstractItem.load()
, this method skips parts ofonLoad(hudson.model.ItemGroup<? extends hudson.model.Item>, java.lang.String)
such as the call toloadChildren(com.cloudbees.hudson.plugins.folder.AbstractFolder<V>, java.io.File, java.util.function.Function<? super V, ? extends K>)
. Nor will it setItems.whileUpdatingByXml(hudson.remoting.Callable<V, T>)
. In the case of aComputedFolder
it also will not callFolderComputation.load()
.- Throws:
IOException
-
addLoadedChild
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public void addLoadedChild(I item, String name) throws IOException, IllegalArgumentException Adds an item to be the folder which was already loaded viaItems.load(hudson.model.ItemGroup, java.io.File)
. UnlikeDirectlyModifiableTopLevelItemGroup.add(I, java.lang.String)
this can be used even on aComputedFolder
.- Throws:
IOException
IllegalArgumentException
-
onLoad
- Specified by:
onLoad
in interfaceItem
- Overrides:
onLoad
in classAbstractItem
- Throws:
IOException
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<I extends TopLevelItem>
- Specified by:
getDescriptor
in interfaceTopLevelItem
-
getProperties
May be used to enumerate or remove properties. To add properties, useaddProperty(com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)
.- Returns:
- the list of properties.
-
addProperty
- Throws:
IOException
-
getJobsDir
May be overridden, butloadJobTotal()
will be inaccurate in that case.- Returns:
- the jobs directory.
-
getRootDirFor
-
getRootDirFor
- Specified by:
getRootDirFor
in interfaceItemGroup<I extends TopLevelItem>
-
getUrlChildPrefix
It is unwise to override this, lest links to children from nondefaultView
s break. TODO remove this warning if and when JENKINS-35243 is fixed in the baseline.- Specified by:
getUrlChildPrefix
in interfaceItemGroup<I extends TopLevelItem>
-
getJob
For URL binding.- Parameters:
name
- the name of the child.- Returns:
- the job or
null
if there is no such child. - See Also:
-
getPronoun
- Overrides:
getPronoun
in classAbstractItem
-
getOverrides
Overrides from job properties.- Specified by:
getOverrides
in interfaceorg.kohsuke.stapler.StaplerOverridable
-
addView
- Specified by:
addView
in interfaceModifiableViewGroup
- Throws:
IOException
-
canDelete
-
deleteView
- Specified by:
deleteView
in interfaceViewGroup
- Throws:
IOException
-
getView
-
getViews
-
getFolderViews
-
resetFolderViews
public void resetFolderViews() -
getPrimaryView
- Specified by:
getPrimaryView
in interfaceViewGroup
-
setPrimaryView
-
onViewRenamed
- Specified by:
onViewRenamed
in interfaceViewGroup
-
getViewsTabBar
- Specified by:
getViewsTabBar
in interfaceViewGroup
-
getItemGroup
- Specified by:
getItemGroup
in interfaceViewGroup
-
getViewActions
- Specified by:
getViewActions
in interfaceViewGroup
-
getStaplerFallback
Fallback to the primary view.- Specified by:
getStaplerFallback
in interfaceorg.kohsuke.stapler.StaplerFallback
-
makeSearchIndex
- Overrides:
makeSearchIndex
in classAbstractModelObject
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) - Specified by:
doChildrenContextMenu
in interfaceModelObjectWithChildren
-
doCreateView
@POST public void doCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, ParseException, Descriptor.FormException - Throws:
IOException
javax.servlet.ServletException
ParseException
Descriptor.FormException
-
doViewExistsCheck
Checks if a top-level view with the given name exists.- Parameters:
value
- the name of the child.- Returns:
- the validation results.
-
getBuildHealth
Get the current health report for a folder.- Returns:
- the health report. Never returns null
-
invalidateBuildHealthReports
public void invalidateBuildHealthReports()Invalidates the cache of build health reports.- Since:
- FIXME
-
getBuildHealthReports
-
getHealthMetrics
-
doLastBuild
public org.kohsuke.stapler.HttpResponse doLastBuild(org.kohsuke.stapler.StaplerRequest req) -
getIcon
Gets the icon used for this folder.- Returns:
- the icon.
-
setIcon
-
getIconColor
-
getAllJobs
- Specified by:
getAllJobs
in interfaceItem
- Specified by:
getAllJobs
in classAbstractItem
-
getItems
- Specified by:
getItems
in interfaceItemGroup<I extends TopLevelItem>
-
getItems
- Specified by:
getItems
in interfaceItemGroup<I extends TopLevelItem>
-
hasVisibleItems
public boolean hasVisibleItems()Checks if folder has visible items- Returns:
- true if folder has visible items false otherwise
-
getItem
- Specified by:
getItem
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
org.springframework.security.access.AccessDeniedException
-
onRenamed
- Specified by:
onRenamed
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
IOException
-
onDeleted
- Specified by:
onDeleted
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
IOException
-
isDisabled
public boolean isDisabled()Is this folder disabled. A disabled folder should have all child items disabled.- Returns:
true
if and only if the folder is disabled.- Since:
- 6.1.0
- See Also:
-
setDisabled
protected void setDisabled(boolean disabled) Sets the folder as disabled.- Parameters:
disabled
-true
if and only if the folder is to be disabled.- Since:
- 6.1.0
-
supportsMakeDisabled
public boolean supportsMakeDisabled()Determines whether the folder supports being made disabled.- Returns:
true
if and only ifsetDisabled(boolean)
is implemented- Since:
- 6.1.0
-
makeDisabled
Makes the folder disabled. Will have no effect if the folder type does not supportsMakeDisabled().- Parameters:
disabled
-true
if the folder should be disabled.- Throws:
IOException
- if the operation could not complete.- Since:
- 6.1.0
-
doDisable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doDisable() throws IOException, javax.servlet.ServletExceptionStapler action method to disable the folder.- Returns:
- the response.
- Throws:
IOException
- if the folder could not be disabled.javax.servlet.ServletException
- if something goes wrong.- Since:
- 6.1.0
-
doEnable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doEnable() throws IOException, javax.servlet.ServletExceptionStapler action method to enable the folder.- Returns:
- the response.
- Throws:
IOException
- if the folder could not be disabled.javax.servlet.ServletException
- if something goes wrong.- Since:
- 6.1.0
-
save
- Specified by:
save
in interfaceItem
- Specified by:
save
in interfaceSaveable
- Overrides:
save
in classAbstractItem
- Throws:
IOException
-
renameTo
Renames this item container.- Overrides:
renameTo
in classAbstractItem
- Throws:
IOException
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException - Overrides:
doSubmitDescription
in classAbstractItem
- Throws:
IOException
javax.servlet.ServletException
-
doConfigSubmit
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException - Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
-
getSuccessfulDestination
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull protected String getSuccessfulDestination()Where user will be redirected after creating or reconfiguring aAbstractFolder
.- Returns:
- A string that represents the redirect location URL.
- See Also:
-
HttpServletResponse.sendRedirect(String)
-
submit
protected void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException - Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
-
isNameEditable
public boolean isNameEditable()- Overrides:
isNameEditable
in classAbstractItem
-
checkRename
- Overrides:
checkRename
in classAbstractItem
-
renameBlocker
Deprecated.OverridecheckRename(java.lang.String)
instead.Allows a subclass to block renames under dynamic conditions.- Returns:
- a message if rename should currently be prohibited, or null to allow
-
checkRename(java.lang.String)
instead.