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-purposeItemGroup. Base forFolderandComputedFolder.Extending Folders UI
As any otherItemtype, folder types support extension of UI viaActions. These actions can be persisted or added viaTransientActionFactory. 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 Classes Modifier and Type Class Description static classAbstractFolder.ItemListenerImplstatic classAbstractFolder.RunListenerImpl-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,I>itemsChild items, keyed byItem.getName().protected static ThreadLocal<Boolean>reloadingThisWhether execution is currently insidereloadThis().-
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFolder(ItemGroup parent, String name)Subclasses should also callinit().
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddLoadedChild(I item, String name)Adds an item to be the folder which was already loaded viaItems.load(hudson.model.ItemGroup, java.io.File).voidaddProperty(AbstractFolderProperty p)voidaddView(View v)booleancanDelete(View view)protected voidcheckRename(String newName)voiddeleteView(View view)ModelObjectWithContextMenu.ContextMenudoChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)voiddoConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)org.kohsuke.stapler.HttpResponsedoDisable()Stapler 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)voiddoSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)FormValidationdoViewExistsCheck(String value)Checks if a top-level view with the given name exists.Collection<? extends Job>getAllJobs()HealthReportgetBuildHealth()Get the current health report for a folder.List<HealthReport>getBuildHealthReports()AbstractFolderDescriptorgetDescriptor()AbstractFolderViewHoldergetFolderViews()DescribableList<FolderHealthMetric,FolderHealthMetricDescriptor>getHealthMetrics()FolderIcongetIcon()Gets the icon used for this folder.FolderIcongetIconColor()IgetItem(String name)ItemGroup<? extends TopLevelItem>getItemGroup()StringgetItemName(File dir, I item)Collection<I>getItems()Collection<I>getItems(Predicate<I> pred)IgetJob(String name)For URL binding.protected FilegetJobsDir()May be overridden, butloadJobTotal()will be inaccurate in that case.Collection<?>getOverrides()Overrides from job properties.ViewgetPrimaryView()StringgetPronoun()DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor>getProperties()May be used to enumerate or remove properties.FilegetRootDirFor(I child)protected FilegetRootDirFor(String name)ViewgetStaplerFallback()Fallback to the primary view.protected StringgetSuccessfulDestination()Where user will be redirected after creating or reconfiguring aAbstractFolder.StringgetUrlChildPrefix()It is unwise to override this, lest links to children from nondefaultViews break.ViewgetView(String name)List<Action>getViewActions()Collection<View>getViews()ViewsTabBargetViewsTabBar()booleanhasVisibleItems()Checks if folder has visible itemsprotected voidinit()protected voidinitViews(List<View> views)voidinvalidateBuildHealthReports()Invalidates the cache of build health reports.booleanisDisabled()Is this folder disabled.booleanisNameEditable()protected IitemsPut(String name, I item)static <K,V extends TopLevelItem>
Map<K,V>loadChildren(AbstractFolder<V> parent, File modulesDir, Function<? super V,? extends K> key)Loads all the childItems.static voidloadJobTotal()voidmakeDisabled(boolean disabled)Makes the folder disabled.protected SearchIndexBuildermakeSearchIndex()protected FolderIconnewDefaultFolderIcon()protected DefaultViewsTabBarnewDefaultViewsTabBar()protected AbstractFolderViewHoldernewFolderViewHolder()voidonDeleted(I item)voidonLoad(ItemGroup<? extends Item> parent, String name)voidonRenamed(I item, String oldName, String newName)voidonViewRenamed(View view, String oldName, String newName)voidreloadThis()Reloads this folder itself.protected StringrenameBlocker()Deprecated.OverridecheckRename(java.lang.String)instead.voidrenameTo(String newName)Renames this item container.voidresetFolderViews()voidsave()protected voidsetDisabled(boolean disabled)Sets the folder as disabled.voidsetIcon(FolderIcon icon)voidsetPrimaryView(View v)protected voidsubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)booleansupportsMakeDisabled()Determines whether the folder supports being made disabled.-
Methods inherited from class hudson.model.AbstractItem
delete, delete, doCheckNewName, doConfigDotXml, doConfirmRename, 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, writeReplace
-
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
-
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, requirePOST, 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 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 Detail
-
reloadingThis
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected static final ThreadLocal<Boolean> reloadingThis
Whether execution is currently insidereloadThis().
-
items
protected transient Map<String,I extends TopLevelItem> items
Child items, keyed byItem.getName().
-
-
Method Detail
-
loadJobTotal
@Initializer(before=JOB_LOADED, fatal=false) public static void loadJobTotal()
-
init
protected void init()
-
newDefaultViewsTabBar
protected DefaultViewsTabBar newDefaultViewsTabBar()
-
newFolderViewHolder
protected AbstractFolderViewHolder newFolderViewHolder()
-
newDefaultFolderIcon
protected FolderIcon newDefaultFolderIcon()
-
initViews
protected void initViews(List<View> views) throws IOException
- 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
public String getItemName(File dir, I item)
- Specified by:
getItemNamein interfaceItemGroup<I extends TopLevelItem>
-
reloadThis
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public void reloadThis() throws IOExceptionReloads 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
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
- Specified by:
onLoadin interfaceItem- Overrides:
onLoadin classAbstractItem- Throws:
IOException
-
getDescriptor
public AbstractFolderDescriptor getDescriptor()
- Specified by:
getDescriptorin interfaceDescribable<I extends TopLevelItem>- Specified by:
getDescriptorin interfaceTopLevelItem
-
getProperties
public DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor> 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
public void addProperty(AbstractFolderProperty p) throws IOException
- Throws:
IOException
-
getJobsDir
protected File getJobsDir()
May be overridden, butloadJobTotal()will be inaccurate in that case.- Returns:
- the jobs directory.
-
getRootDirFor
public File getRootDirFor(I child)
- Specified by:
getRootDirForin interfaceItemGroup<I extends TopLevelItem>
-
getUrlChildPrefix
public String 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
public I getJob(String name)
For URL binding.- Parameters:
name- the name of the child.- Returns:
- the job or
nullif there is no such child. - See Also:
getUrlChildPrefix()
-
getPronoun
public String getPronoun()
- Overrides:
getPronounin classAbstractItem
-
getOverrides
public Collection<?> getOverrides()
Overrides from job properties.- Specified by:
getOverridesin interfaceorg.kohsuke.stapler.StaplerOverridable
-
addView
public void addView(View v) throws IOException
- Specified by:
addViewin interfaceModifiableViewGroup- Throws:
IOException
-
deleteView
public void deleteView(View view) throws IOException
- Specified by:
deleteViewin interfaceViewGroup- Throws:
IOException
-
getViews
@Exported public Collection<View> getViews()
-
getFolderViews
public AbstractFolderViewHolder getFolderViews()
-
resetFolderViews
public void resetFolderViews()
-
getPrimaryView
@Exported public View getPrimaryView()
- Specified by:
getPrimaryViewin interfaceViewGroup
-
setPrimaryView
public void setPrimaryView(View v)
-
onViewRenamed
public void onViewRenamed(View view, String oldName, String newName)
- Specified by:
onViewRenamedin interfaceViewGroup
-
getViewsTabBar
public ViewsTabBar getViewsTabBar()
- Specified by:
getViewsTabBarin interfaceViewGroup
-
getItemGroup
public ItemGroup<? extends TopLevelItem> getItemGroup()
- Specified by:
getItemGroupin interfaceViewGroup
-
getViewActions
public List<Action> getViewActions()
- Specified by:
getViewActionsin interfaceViewGroup
-
getStaplerFallback
public View getStaplerFallback()
Fallback to the primary view.- Specified by:
getStaplerFallbackin interfaceorg.kohsuke.stapler.StaplerFallback
-
makeSearchIndex
protected SearchIndexBuilder makeSearchIndex()
- Overrides:
makeSearchIndexin classAbstractModelObject
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
- Specified by:
doChildrenContextMenuin 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:
IOExceptionjavax.servlet.ServletExceptionParseExceptionDescriptor.FormException
-
doViewExistsCheck
public FormValidation doViewExistsCheck(@QueryParameter String value)
Checks if a top-level view with the given name exists.- Parameters:
value- the name of the child.- Returns:
- the validation results.
-
getBuildHealth
public HealthReport 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
@Exported(name="healthReport") public List<HealthReport> getBuildHealthReports()
-
getHealthMetrics
public DescribableList<FolderHealthMetric,FolderHealthMetricDescriptor> getHealthMetrics()
-
doLastBuild
public org.kohsuke.stapler.HttpResponse doLastBuild(org.kohsuke.stapler.StaplerRequest req)
-
getIcon
public FolderIcon getIcon()
Gets the icon used for this folder.- Returns:
- the icon.
-
setIcon
public void setIcon(FolderIcon icon)
-
getIconColor
public FolderIcon getIconColor()
-
getAllJobs
public Collection<? extends Job> getAllJobs()
- Specified by:
getAllJobsin interfaceItem- Specified by:
getAllJobsin classAbstractItem
-
getItems
@Exported(name="jobs") public Collection<I> getItems()
- Specified by:
getItemsin interfaceItemGroup<I extends TopLevelItem>
-
getItems
public Collection<I> getItems(Predicate<I> pred)
- 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
public I getItem(String name) throws org.springframework.security.access.AccessDeniedException
- Specified by:
getItemin interfaceItemGroup<I extends TopLevelItem>- Throws:
org.springframework.security.access.AccessDeniedException
-
onRenamed
public void onRenamed(I item, String oldName, String newName) throws IOException
- Specified by:
onRenamedin interfaceItemGroup<I extends TopLevelItem>- Throws:
IOException
-
onDeleted
public void onDeleted(I item) throws IOException
- 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:
FolderJobQueueDecisionHandler
-
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
public void makeDisabled(boolean disabled) throws IOExceptionMakes 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, 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
public void save() throws IOException- Specified by:
savein interfaceItem- Specified by:
savein interfaceSaveable- Overrides:
savein classAbstractItem- Throws:
IOException
-
renameTo
public void renameTo(String newName) throws IOException
Renames this item container.- Overrides:
renameToin classAbstractItem- Throws:
IOException
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Overrides:
doSubmitDescriptionin classAbstractItem- Throws:
IOExceptionjavax.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:
IOExceptionjavax.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.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
isNameEditable
public boolean isNameEditable()
- Overrides:
isNameEditablein classAbstractItem
-
checkRename
protected void checkRename(String newName)
- Overrides:
checkRenamein classAbstractItem
-
renameBlocker
@Deprecated @CheckForNull protected String 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
-
-