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,FullyNamed,FullyNamedModelObject,Loadable,ModelObjectWithChildren,ModelObjectWithContextMenu,Named,OnMaster,IconSpec,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, IconSpec
A general-purpose
ItemGroup.
Base for Folder and ComputedFolder.
Extending Folders UI
As any other Item type, folder types support extension of UI via Actions.
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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudsonNested classes/interfaces inherited from interface org.kohsuke.stapler.HttpDeletable
org.kohsuke.stapler.HttpDeletable.HttpDeletableDispatcherNested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType -
Field Summary
FieldsModifier 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
ConstructorsModifierConstructorDescriptionprotectedAbstractFolder(ItemGroup parent, String name) Subclasses should also callinit(). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLoadedChild(I item, String name) Adds an item to be the folder which was already loaded viaItems.load(hudson.model.ItemGroup, java.io.File).voidvoidbooleanprotected voidcheckRename(String newName) voiddeleteView(View view) doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) Deprecated.voiddoConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) voiddoCreateView(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) voiddoCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.org.kohsuke.stapler.HttpResponseStapler action method to disable the folder.org.kohsuke.stapler.HttpResponsedoEnable()Stapler action method to enable the folder.org.kohsuke.stapler.HttpResponsedoLastBuild(org.kohsuke.stapler.StaplerRequest req) Deprecated.org.kohsuke.stapler.HttpResponsedoLastBuild(org.kohsuke.stapler.StaplerRequest2 req) voiddoSubmitDescription(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) voiddoSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.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 FileMay 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 FilegetRootDirFor(String name) Fallback to the primary view.protected StringWhere user will be redirected after creating or reconfiguring aAbstractFolder.It is unwise to override this, lest links to children from nondefaultViews break.getViews()booleanChecks if folder has visible itemsprotected voidinit()protected voidvoidInvalidates the cache of build health reports.booleanIs this folder disabled.booleanprotected final Istatic <K,V extends TopLevelItem>
Map<K,V> loadChildren(AbstractFolder<V> parent, File modulesDir, Function<? super V, ? extends K> key) Loads all the childItems.static voidvoidmakeDisabled(boolean disabled) Makes the folder disabled.protected SearchIndexBuilderprotected FolderIconprotected DefaultViewsTabBarprotected AbstractFolderViewHoldervoidvoidvoidvoidonViewRenamed(View view, String oldName, String newName) voidReloads this folder itself.protected StringDeprecated.OverridecheckRename(java.lang.String)instead.voidRenames this item container.voidvoidsave()protected voidsetDisabled(boolean disabled) Sets the folder as disabled.voidsetIcon(FolderIcon icon) voidprotected voidsubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) protected voidsubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.booleanDetermines 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, 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, writeReplaceMethods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActionsMethods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, getACL, hasAnyPermission, hasPermission, hasPermission, hasPermission2Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByNameMethods inherited from interface jenkins.model.FullyNamedModelObject
getFullDisplayNameMethods inherited from interface hudson.model.Item
delete, getAbsoluteUrl, getDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getSearchGroup, getShortUrl, getUrl, onCopiedFrom, onCreatedFromScratchMethods inherited from interface hudson.model.ItemGroup
allItems, allItems, allItems, getAllItems, getAllItems, getAllItems, getItemsStream, getItemsStream, getUrlMethods inherited from interface hudson.model.PersistenceRoot
getRootDirMethods inherited from interface hudson.search.SearchableModelObject
getSearchMethods inherited from interface hudson.search.SearchItem
getSearchIcon, getSearchIndex, getSearchName, getSearchUrlMethods inherited from interface hudson.model.ViewGroup
getAllViews, getUrl, getUserViewsTabBar
-
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
-
getIconClassName
- Specified by:
getIconClassNamein interfaceIconSpec
-
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 childItems.- 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:
getItemNamein 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 aComputedFolderit 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:
IOExceptionIllegalArgumentException
-
onLoad
- Specified by:
onLoadin interfaceItem- Overrides:
onLoadin classAbstractItem- Throws:
IOException
-
getDescriptor
- Specified by:
getDescriptorin interfaceDescribable<I extends TopLevelItem>- Specified by:
getDescriptorin 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:
getRootDirForin interfaceItemGroup<I extends TopLevelItem>
-
getUrlChildPrefix
It is unwise to override this, lest links to children from nondefaultViews break. TODO remove this warning if and when JENKINS-35243 is fixed in the baseline.- Specified by:
getUrlChildPrefixin interfaceItemGroup<I extends TopLevelItem>
-
getJob
For URL binding.- Parameters:
name- the name of the child.- Returns:
- the job or
nullif there is no such child. - See Also:
-
getPronoun
- Overrides:
getPronounin classAbstractItem
-
getOverrides
Overrides from job properties.- Specified by:
getOverridesin interfaceorg.kohsuke.stapler.StaplerOverridable
-
addView
- Specified by:
addViewin interfaceModifiableViewGroup- Throws:
IOException
-
canDelete
-
deleteView
- Specified by:
deleteViewin interfaceViewGroup- Throws:
IOException
-
getView
-
getViews
-
getFolderViews
-
resetFolderViews
public void resetFolderViews() -
getPrimaryView
- Specified by:
getPrimaryViewin interfaceViewGroup
-
setPrimaryView
-
onViewRenamed
- Specified by:
onViewRenamedin interfaceViewGroup
-
getViewsTabBar
- Specified by:
getViewsTabBarin interfaceViewGroup
-
getItemGroup
- Specified by:
getItemGroupin interfaceViewGroup
-
getViewActions
- Specified by:
getViewActionsin interfaceViewGroup
-
getStaplerFallback
Fallback to the primary view.- Specified by:
getStaplerFallbackin interfaceorg.kohsuke.stapler.StaplerFallback
-
makeSearchIndex
- Overrides:
makeSearchIndexin classAbstractModelObject
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) - Specified by:
doChildrenContextMenuin interfaceModelObjectWithChildren
-
doChildrenContextMenu
@Deprecated @StaplerNotDispatchable public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) Deprecated.- Specified by:
doChildrenContextMenuin interfaceModelObjectWithChildren
-
doCreateView
@POST public void doCreateView(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException, ParseException, Descriptor.FormException - Throws:
IOExceptionjakarta.servlet.ServletExceptionParseExceptionDescriptor.FormException
-
doCreateView
@Deprecated @StaplerNotDispatchable public void doCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, ParseException, Descriptor.FormException Deprecated.- Throws:
IOExceptionjavax.servlet.ServletExceptionParseExceptionDescriptor.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.StaplerRequest2 req) -
doLastBuild
@Deprecated @StaplerNotDispatchable public org.kohsuke.stapler.HttpResponse doLastBuild(org.kohsuke.stapler.StaplerRequest req) Deprecated. -
getIcon
Gets the icon used for this folder.- Returns:
- the icon.
-
setIcon
-
getIconColor
-
getAllJobs
- Specified by:
getAllJobsin interfaceItem- Specified by:
getAllJobsin classAbstractItem
-
getItems
- Specified by:
getItemsin interfaceItemGroup<I extends TopLevelItem>
-
getItems
- Specified by:
getItemsin 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:
getItemin interfaceItemGroup<I extends TopLevelItem>- Throws:
org.springframework.security.access.AccessDeniedException
-
onRenamed
- Specified by:
onRenamedin interfaceItemGroup<I extends TopLevelItem>- Throws:
IOException
-
onDeleted
- Specified by:
onDeletedin interfaceItemGroup<I extends TopLevelItem>- Throws:
IOException
-
isDisabled
public boolean isDisabled()Is this folder disabled. A disabled folder should have all child items disabled.- Returns:
trueif 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-trueif 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:
trueif 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-trueif 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, jakarta.servlet.ServletExceptionStapler action method to disable the folder.- Returns:
- the response.
- Throws:
IOException- if the folder could not be disabled.jakarta.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, jakarta.servlet.ServletExceptionStapler action method to enable the folder.- Returns:
- the response.
- Throws:
IOException- if the folder could not be disabled.jakarta.servlet.ServletException- if something goes wrong.- Since:
- 6.1.0
-
save
- Specified by:
savein interfaceItem- Specified by:
savein interfaceSaveable- Overrides:
savein classAbstractItem- Throws:
IOException
-
renameTo
Renames this item container.- Overrides:
renameToin classAbstractItem- Throws:
IOException
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Overrides:
doSubmitDescriptionin classAbstractItem- Throws:
IOExceptionjakarta.servlet.ServletException
-
doSubmitDescription
@Deprecated @StaplerNotDispatchable public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException Deprecated.- Overrides:
doSubmitDescriptionin classAbstractItem- Throws:
IOExceptionjavax.servlet.ServletException
-
doConfigSubmit
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException - Throws:
IOExceptionjakarta.servlet.ServletExceptionDescriptor.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.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException - Throws:
IOExceptionjakarta.servlet.ServletExceptionDescriptor.FormException
-
submit
@Deprecated protected void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException Deprecated.- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
isNameEditable
public boolean isNameEditable()- Overrides:
isNameEditablein classAbstractItem
-
checkRename
- Overrides:
checkRenamein 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
-
doChildrenContextMenu(StaplerRequest2, StaplerResponse2)