public abstract class AbstractFolder<I extends TopLevelItem> extends AbstractItem implements TopLevelItem, ItemGroup<I>, ModifiableViewGroup, org.kohsuke.stapler.StaplerFallback, ModelObjectWithChildren, org.kohsuke.stapler.StaplerOverridable
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:
index.jelly
.summary.jelly
.Modifier and Type | Class and Description |
---|---|
static class |
AbstractFolder.ItemListenerImpl |
static class |
AbstractFolder.RunListenerImpl |
ExtensionPoint.LegacyInstancesAreScopedToHudson
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem
Modifier and Type | Field and Description |
---|---|
protected Map<String,I> |
items
Child items, keyed by
Item.getName() . |
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
Modifier | Constructor and Description |
---|---|
protected |
AbstractFolder(ItemGroup parent,
String name)
Subclasses should also call
init() . |
Modifier and Type | Method and 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 Predicate
|
I |
getJob(String name)
For URL binding.
|
protected File |
getJobsDir()
May be overridden, but
loadJobTotal() 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 a
AbstractFolder . |
String |
getUrlChildPrefix()
It is unwise to override this, lest links to children from nondefault
View s break. |
View |
getView(String name) |
List<Action> |
getViewActions() |
Collection<View> |
getViews() |
ViewsTabBar |
getViewsTabBar() |
boolean |
hasVisibleItems()
Checks if folder has visible items
|
protected 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> |
loadChildren(AbstractFolder<V> parent,
File modulesDir,
Function1<? extends K,? super V> key)
Loads all the child
Item 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.
Override
checkRename(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.
|
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
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAbsoluteUrl, getDisplayName, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom, onCreatedFromScratch
getRootDir
getSearch
getSearchIndex, getSearchName, getSearchUrl
allItems, allItems, getAllItems, getAllItems, getFullDisplayName, getFullName, getUrl
getAllViews, getUrl
checkPermission, getACL, hasPermission, hasPermission
getDescriptorByName
protected transient Map<String,I extends TopLevelItem> items
Item.getName()
.@Initializer(before=JOB_LOADED, fatal=false) public static void loadJobTotal()
protected void init()
protected DefaultViewsTabBar newDefaultViewsTabBar()
protected AbstractFolderViewHolder newFolderViewHolder()
protected FolderIcon newDefaultFolderIcon()
protected void initViews(List<View> views) throws IOException
IOException
public static <K,V extends TopLevelItem> Map<K,V> loadChildren(AbstractFolder<V> parent, File modulesDir, Function1<? extends K,? super V> key)
Item
s.K
- the key typeV
- the child type.parent
- the parent of the children.modulesDir
- Directory that contains sub-directories for each child item.key
- the key generating function.public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
onLoad
in interface Item
onLoad
in class AbstractItem
IOException
public AbstractFolderDescriptor getDescriptor()
getDescriptor
in interface Describable<TopLevelItem>
getDescriptor
in interface TopLevelItem
public DescribableList<AbstractFolderProperty<?>,AbstractFolderPropertyDescriptor> getProperties()
addProperty(com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)
.public void addProperty(AbstractFolderProperty p) throws IOException
IOException
protected File getJobsDir()
loadJobTotal()
will be inaccurate in that case.public File getRootDirFor(I child)
getRootDirFor
in interface ItemGroup<I extends TopLevelItem>
public String getUrlChildPrefix()
View
s break.
TODO remove this warning if and when JENKINS-35243 is fixed in the baseline.
getUrlChildPrefix
in interface ItemGroup<I extends TopLevelItem>
public I getJob(String name)
name
- the name of the child.null
if there is no such child.getUrlChildPrefix()
public String getPronoun()
getPronoun
in class AbstractItem
public Collection<?> getOverrides()
getOverrides
in interface org.kohsuke.stapler.StaplerOverridable
public void addView(View v) throws IOException
addView
in interface ModifiableViewGroup
IOException
public void deleteView(View view) throws IOException
deleteView
in interface ViewGroup
IOException
@Exported public Collection<View> getViews()
public AbstractFolderViewHolder getFolderViews()
public void resetFolderViews()
@Exported public View getPrimaryView()
getPrimaryView
in interface ViewGroup
public void setPrimaryView(View v)
public void onViewRenamed(View view, String oldName, String newName)
onViewRenamed
in interface ViewGroup
public ViewsTabBar getViewsTabBar()
getViewsTabBar
in interface ViewGroup
public ItemGroup<? extends TopLevelItem> getItemGroup()
getItemGroup
in interface ViewGroup
public List<Action> getViewActions()
getViewActions
in interface ViewGroup
public View getStaplerFallback()
getStaplerFallback
in interface org.kohsuke.stapler.StaplerFallback
protected SearchIndexBuilder makeSearchIndex()
makeSearchIndex
in class AbstractModelObject
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
doChildrenContextMenu
in interface ModelObjectWithChildren
public void doCreateView(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, ParseException, Descriptor.FormException
IOException
javax.servlet.ServletException
ParseException
Descriptor.FormException
public FormValidation doViewExistsCheck(@QueryParameter String value)
value
- the name of the child.public HealthReport getBuildHealth()
public void invalidateBuildHealthReports()
@Exported(name="healthReport") public List<HealthReport> getBuildHealthReports()
public DescribableList<FolderHealthMetric,FolderHealthMetricDescriptor> getHealthMetrics()
public org.kohsuke.stapler.HttpResponse doLastBuild(org.kohsuke.stapler.StaplerRequest req)
public FolderIcon getIcon()
public void setIcon(FolderIcon icon)
public FolderIcon getIconColor()
public Collection<? extends Job> getAllJobs()
getAllJobs
in interface Item
getAllJobs
in class AbstractItem
@Exported(name="jobs") public Collection<I> getItems()
getItems
in interface ItemGroup<I extends TopLevelItem>
public Collection<I> getItems(Predicate<I> pred)
public boolean hasVisibleItems()
public I getItem(String name) throws org.acegisecurity.AccessDeniedException
getItem
in interface ItemGroup<I extends TopLevelItem>
org.acegisecurity.AccessDeniedException
public void onRenamed(I item, String oldName, String newName) throws IOException
onRenamed
in interface ItemGroup<I extends TopLevelItem>
IOException
public void onDeleted(I item) throws IOException
onDeleted
in interface ItemGroup<I extends TopLevelItem>
IOException
public void delete() throws IOException, InterruptedException
delete
in interface Item
delete
in class AbstractItem
IOException
InterruptedException
public boolean isDisabled()
true
if and only if the folder is disabled.FolderJobQueueDecisionHandler
protected void setDisabled(boolean disabled)
disabled
- true
if and only if the folder is to be disabled.public boolean supportsMakeDisabled()
true
if and only if setDisabled(boolean)
is implementedpublic void makeDisabled(boolean disabled) throws IOException
disabled
- true
if the folder should be disabled.IOException
- if the operation could not complete.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doDisable() throws IOException, javax.servlet.ServletException
IOException
- if the folder could not be disabled.javax.servlet.ServletException
- if something goes wrong.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doEnable() throws IOException, javax.servlet.ServletException
IOException
- if the folder could not be disabled.javax.servlet.ServletException
- if something goes wrong.public void save() throws IOException
save
in interface Item
save
in interface Saveable
save
in class AbstractItem
IOException
public void renameTo(String newName) throws IOException
renameTo
in class AbstractItem
IOException
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
doSubmitDescription
in class AbstractItem
IOException
javax.servlet.ServletException
@Restricted(value=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
IOException
javax.servlet.ServletException
Descriptor.FormException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @Nonnull protected String getSuccessfulDestination()
AbstractFolder
.HttpServletResponse.sendRedirect(String)
protected void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
public boolean isNameEditable()
isNameEditable
in class AbstractItem
protected void checkRename(String newName)
checkRename
in class AbstractItem
@Deprecated @CheckForNull protected String renameBlocker()
checkRename(java.lang.String)
instead.Copyright © 2016–2020. All rights reserved.