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
,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 forFolder
andComputedFolder
.Extending Folders UI
As any otherItem
type, folder types support extension of UI viaAction
s. 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 class
AbstractFolder.ItemListenerImpl
static class
AbstractFolder.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>
items
Child items, keyed byItem.getName()
.-
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFolder(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 void
addProperty(AbstractFolderProperty p)
void
addView(View v)
boolean
canDelete(View view)
protected void
checkRename(String newName)
void
delete()
void
deleteView(View view)
ModelObjectWithContextMenu.ContextMenu
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
doDisable()
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)
FormValidation
doViewExistsCheck(String value)
Checks if a top-level view with the given name exists.Collection<? extends Job>
getAllJobs()
HealthReport
getBuildHealth()
Get the current health report for a folder.List<HealthReport>
getBuildHealthReports()
AbstractFolderDescriptor
getDescriptor()
AbstractFolderViewHolder
getFolderViews()
DescribableList<FolderHealthMetric,FolderHealthMetricDescriptor>
getHealthMetrics()
FolderIcon
getIcon()
Gets the icon used for this folder.FolderIcon
getIconColor()
I
getItem(String name)
ItemGroup<? extends TopLevelItem>
getItemGroup()
Collection<I>
getItems()
Collection<I>
getItems(Predicate<I> pred)
Gets all the items in this collection in a read-only view that matches supplied PredicateI
getJob(String name)
For URL binding.protected File
getJobsDir()
May be overridden, butloadJobTotal()
will be inaccurate in that case.Collection<?>
getOverrides()
Overrides from job properties.View
getPrimaryView()
String
getPronoun()
DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor>
getProperties()
May be used to enumerate or remove properties.File
getRootDirFor(I child)
protected File
getRootDirFor(String name)
View
getStaplerFallback()
Fallback to the primary view.protected String
getSuccessfulDestination()
Where user will be redirected after creating or reconfiguring aAbstractFolder
.String
getUrlChildPrefix()
It is unwise to override this, lest links to children from nondefaultView
s break.View
getView(String name)
List<Action>
getViewActions()
Collection<View>
getViews()
ViewsTabBar
getViewsTabBar()
boolean
hasVisibleItems()
Checks if folder has visible itemsprotected void
init()
protected void
initViews(List<View> views)
void
invalidateBuildHealthReports()
Invalidates the cache of build health reports.boolean
isDisabled()
Is this folder disabled.boolean
isNameEditable()
protected I
itemsPut(String name, I item)
static <K,V extends TopLevelItem>
Map<K,V>loadChildren(AbstractFolder<V> parent, File modulesDir, Function1<? extends K,? super V> key)
Loads all the childItem
s.static void
loadJobTotal()
void
makeDisabled(boolean disabled)
Makes the folder disabled.protected SearchIndexBuilder
makeSearchIndex()
protected FolderIcon
newDefaultFolderIcon()
protected DefaultViewsTabBar
newDefaultViewsTabBar()
protected AbstractFolderViewHolder
newFolderViewHolder()
void
onDeleted(I item)
void
onLoad(ItemGroup<? extends Item> parent, String name)
void
onRenamed(I item, String oldName, String newName)
void
onViewRenamed(View view, String oldName, String newName)
protected String
renameBlocker()
Deprecated.OverridecheckRename(java.lang.String)
instead.void
renameTo(String newName)
Renames this item container.void
resetFolderViews()
void
save()
protected void
setDisabled(boolean disabled)
Sets the folder as disabled.void
setIcon(FolderIcon icon)
void
setPrimaryView(View v)
protected void
submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
boolean
supportsMakeDisabled()
Determines whether the folder supports being made disabled.-
Methods inherited from class hudson.model.AbstractItem
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, 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
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
-
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, Function1<? extends K,? super V> 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.
-
onLoad
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
- Specified by:
onLoad
in interfaceItem
- Overrides:
onLoad
in classAbstractItem
- Throws:
IOException
-
getDescriptor
public AbstractFolderDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<I extends TopLevelItem>
- Specified by:
getDescriptor
in 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:
getRootDirFor
in interfaceItemGroup<I extends TopLevelItem>
-
getUrlChildPrefix
public String 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
public I getJob(String name)
For URL binding.- Parameters:
name
- the name of the child.- Returns:
- the job or
null
if there is no such child. - See Also:
getUrlChildPrefix()
-
getPronoun
public String getPronoun()
- Overrides:
getPronoun
in classAbstractItem
-
getOverrides
public Collection<?> getOverrides()
Overrides from job properties.- Specified by:
getOverrides
in interfaceorg.kohsuke.stapler.StaplerOverridable
-
addView
public void addView(View v) throws IOException
- Specified by:
addView
in interfaceModifiableViewGroup
- Throws:
IOException
-
deleteView
public void deleteView(View view) throws IOException
- Specified by:
deleteView
in interfaceViewGroup
- Throws:
IOException
-
getViews
@Exported public Collection<View> getViews()
-
getFolderViews
public AbstractFolderViewHolder getFolderViews()
-
resetFolderViews
public void resetFolderViews()
-
getPrimaryView
@Exported public View getPrimaryView()
- Specified by:
getPrimaryView
in interfaceViewGroup
-
setPrimaryView
public void setPrimaryView(View v)
-
onViewRenamed
public void onViewRenamed(View view, String oldName, String newName)
- Specified by:
onViewRenamed
in interfaceViewGroup
-
getViewsTabBar
public ViewsTabBar getViewsTabBar()
- Specified by:
getViewsTabBar
in interfaceViewGroup
-
getItemGroup
public ItemGroup<? extends TopLevelItem> getItemGroup()
- Specified by:
getItemGroup
in interfaceViewGroup
-
getViewActions
public List<Action> getViewActions()
- Specified by:
getViewActions
in interfaceViewGroup
-
getStaplerFallback
public View getStaplerFallback()
Fallback to the primary view.- Specified by:
getStaplerFallback
in interfaceorg.kohsuke.stapler.StaplerFallback
-
makeSearchIndex
protected SearchIndexBuilder 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
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:
getAllJobs
in interfaceItem
- Specified by:
getAllJobs
in classAbstractItem
-
getItems
@Exported(name="jobs") public Collection<I> getItems()
- Specified by:
getItems
in interfaceItemGroup<I extends TopLevelItem>
-
getItems
public Collection<I> getItems(Predicate<I> pred)
Gets all the items in this collection in a read-only view that matches supplied Predicate- 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
public I getItem(String name) throws AccessDeniedException
- Specified by:
getItem
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
AccessDeniedException
-
onRenamed
public void onRenamed(I item, String oldName, String newName) throws IOException
- Specified by:
onRenamed
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
IOException
-
onDeleted
public void onDeleted(I item) throws IOException
- Specified by:
onDeleted
in interfaceItemGroup<I extends TopLevelItem>
- Throws:
IOException
-
delete
public void delete() throws IOException, InterruptedException
- Specified by:
delete
in interfaceItem
- Overrides:
delete
in classAbstractItem
- Throws:
IOException
InterruptedException
-
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:
FolderJobQueueDecisionHandler
-
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
public void makeDisabled(boolean disabled) throws IOException
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.ServletException
Stapler 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.ServletException
Stapler 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:
save
in interfaceItem
- Specified by:
save
in interfaceSaveable
- Overrides:
save
in classAbstractItem
- Throws:
IOException
-
renameTo
public void renameTo(String newName) throws IOException
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
protected void checkRename(String newName)
- Overrides:
checkRename
in 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
-
-