Class ComputedFolder<I extends TopLevelItem>
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.model.AbstractItem
-
- com.cloudbees.hudson.plugins.folder.AbstractFolder<I>
-
- com.cloudbees.hudson.plugins.folder.computed.ComputedFolder<I>
-
- Type Parameters:
I
- the child item type
- All Implemented Interfaces:
ExtensionPoint
,BuildableItem
,Describable<TopLevelItem>
,DescriptorByNameOwner
,Item
,ItemGroup<I>
,ModelObject
,ModifiableViewGroup
,PersistenceRoot
,Queue.FlyweightTask
,SubTask
,Queue.Task
,ResourceActivity
,Saveable
,TopLevelItem
,ViewGroup
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithChildren
,ModelObjectWithContextMenu
,TriggeredItem
,OnMaster
,org.kohsuke.stapler.HttpDeletable
,org.kohsuke.stapler.StaplerFallback
,org.kohsuke.stapler.StaplerOverridable
,org.kohsuke.stapler.StaplerProxy
public abstract class ComputedFolder<I extends TopLevelItem> extends AbstractFolder<I> implements BuildableItem, TriggeredItem, Queue.FlyweightTask
A folder-like item whose children are computed. Users cannot directly add or remove (or rename) children. The children should also not offerItem.CONFIGURE
to anyone.- Since:
- 4.11-beta-1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.cloudbees.hudson.plugins.folder.AbstractFolder
AbstractFolder.ItemListenerImpl, 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 inherited from class com.cloudbees.hudson.plugins.folder.AbstractFolder
items
-
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN, SKIP_PERMISSION_CHECK, TASK_NOUN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComputedFolder(ItemGroup parent, String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addTrigger(Trigger trigger)
Update an existing trigger or add a new one.void
checkAbortPermission()
protected void
checkRename(String newName)
protected abstract void
computeChildren(ChildObserver<I> observer, TaskListener listener)
Called to (re-)compute the set of children of this folder.protected FolderComputation<I>
createComputation(FolderComputation<I> previous)
protected ChildObserver<I>
createEventsChildObserver()
Deprecated.FolderComputation<I>
createExecutable()
org.kohsuke.stapler.HttpResponse
doBuild(TimeDuration delay)
void
doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
List<Action>
getActions()
Label
getAssignedLabel()
CauseOfBlockage
getCauseOfBlockage()
FolderComputation<I>
getComputation()
URL binding and other purposes.protected File
getComputationDir()
long
getEstimatedDuration()
Node
getLastBuiltOn()
PseudoRun<I>
getLastFailedBuild()
PseudoRun<I>
getLastStableBuild()
PseudoRun<I>
getLastSuccessfulBuild()
OrphanedItemStrategy
getOrphanedItemStrategy()
List<OrphanedItemStrategyDescriptor>
getOrphanedItemStrategyDescriptors()
Gets theOrphanedItemStrategyDescriptor
s applicable to this folder.protected String
getSuccessfulDestination()
Where user will be redirected after creating or reconfiguring aAbstractFolder
.List<TriggerDescriptor>
getTriggerDescriptors()
Map<TriggerDescriptor,Trigger<?>>
getTriggers()
boolean
hasAbortPermission()
protected void
init()
boolean
isBuildable()
Whether it is permissible to recompute this folder at this time.boolean
isDisabled()
Is this folder disabled.boolean
isHasEvents()
Identifies if thisComputedFolder
has a separate out of band events log.void
onCreatedFromScratch()
void
onLoad(ItemGroup<? extends Item> parent, String name)
protected ChildObserver<I>
openEventsChildObserver()
Opens a newChildObserver
that subclasses can use when handling events that might create new / update existing child items.protected Collection<I>
orphanedItems(Collection<I> orphaned, TaskListener listener)
Hook called when some items are no longer in the list.protected void
recalculateAfterSubmitted(boolean recalculate)
Method for child classes to use if they want to suppress/confirm the automatic recalculation provided indoConfigSubmit(StaplerRequest, StaplerResponse)
.void
removeTrigger(Trigger trigger)
Remove an existing trigger.boolean
scheduleBuild(int quietPeriod, Cause c)
boolean
scheduleBuild(Cause c)
Queue.Item
scheduleBuild2(int quietPeriod, Action... actions)
protected void
setDisabled(boolean disabled)
Sets the folder as disabled.void
setOrphanedItemStrategy(OrphanedItemStrategy strategy)
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 com.cloudbees.hudson.plugins.folder.AbstractFolder
addProperty, addView, canDelete, delete, deleteView, doChildrenContextMenu, doCreateView, doDisable, doEnable, doLastBuild, doSubmitDescription, doViewExistsCheck, getAllJobs, getBuildHealth, getBuildHealthReports, getDescriptor, getFolderViews, getHealthMetrics, getIcon, getIconColor, getItem, getItemGroup, getItems, getItems, getJob, getJobsDir, getOverrides, getPrimaryView, getPronoun, getProperties, getRootDirFor, getRootDirFor, getStaplerFallback, getUrlChildPrefix, getView, getViewActions, getViews, getViewsTabBar, hasVisibleItems, initViews, invalidateBuildHealthReports, isNameEditable, itemsPut, loadChildren, loadJobTotal, makeDisabled, makeSearchIndex, newDefaultFolderIcon, newDefaultViewsTabBar, newFolderViewHolder, onDeleted, onRenamed, onViewRenamed, renameBlocker, renameTo, resetFolderViews, save, setIcon, setPrimaryView
-
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, 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.BuildableItem
scheduleBuild, scheduleBuild
-
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
-
Methods inherited from interface hudson.model.Item
delete, getAbsoluteUrl, getAllJobs, getDisplayName, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom, save
-
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.model.Queue.Task
getAffinityKey, getDefaultAuthentication, getDefaultAuthentication, getDefaultAuthentication2, getDefaultAuthentication2, getFullDisplayName, getName, getSubTasks, getUrl, getWhyBlocked, isBuildBlocked, isConcurrentBuild
-
Methods inherited from interface hudson.model.ResourceActivity
getDisplayName, getResourceList
-
Methods inherited from interface hudson.search.SearchableModelObject
getSearch
-
Methods inherited from interface hudson.search.SearchItem
getSearchIndex, getSearchName, getSearchUrl
-
Methods inherited from interface hudson.model.queue.SubTask
getOwnerTask, getSameNodeConstraint
-
Methods inherited from interface hudson.model.ViewGroup
getAllViews, getUrl
-
-
-
-
Method Detail
-
init
protected void init()
- Overrides:
init
in classAbstractFolder<I extends TopLevelItem>
-
onCreatedFromScratch
public void onCreatedFromScratch()
- Specified by:
onCreatedFromScratch
in interfaceItem
-
onLoad
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
Description copied from class:AbstractFolder
- Specified by:
onLoad
in interfaceItem
- Overrides:
onLoad
in classAbstractFolder<I extends TopLevelItem>
- Throws:
IOException
-
computeChildren
protected abstract void computeChildren(ChildObserver<I> observer, TaskListener listener) throws IOException, InterruptedException
Called to (re-)compute the set of children of this folder. It is recommended that the computation checks theThread.interrupted()
status and throws aInterruptedException
if set at least once every 5 seconds to allow the user to interrupt a computation..- Parameters:
observer
- how to indicate which children should be seenlistener
- a way to report progress- Throws:
IOException
- if there was anIOException
during the computation.InterruptedException
- if the computation was interrupted.
-
orphanedItems
protected Collection<I> orphanedItems(Collection<I> orphaned, TaskListener listener) throws IOException, InterruptedException
Hook called when some items are no longer in the list. Do not callItem.delete()
orItemGroup.onDeleted(T)
orItemListener.fireOnDeleted(hudson.model.Item)
yourself. By default, usesgetOrphanedItemStrategy()
.- Parameters:
orphaned
- a nonempty set of items which no longer are supposed to be herelistener
- the listener to report decisions to.- Returns:
- any subset of
orphaned
, representing those children which ought to be removed from the folder now; items not listed will be left alone for the time - Throws:
IOException
- if there was an I/O issue processing the items.InterruptedException
- if interrupted while processing the items.
-
setOrphanedItemStrategy
public void setOrphanedItemStrategy(@NonNull OrphanedItemStrategy strategy)
-
createEventsChildObserver
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected final ChildObserver<I> createEventsChildObserver()
Deprecated.Creates aChildObserver
that subclasses can use when handling events that might create new / update existing child items. The handling of orphaned items is a responsibility of theOrphanedItemStrategy
which is only applied as part of a full computation.- Returns:
- a
ChildObserver
for event handling.
-
openEventsChildObserver
protected final ChildObserver<I> openEventsChildObserver()
Opens a newChildObserver
that subclasses can use when handling events that might create new / update existing child items. The handling of orphaned items is a responsibility of theOrphanedItemStrategy
which is only applied as part of a full computation.- Returns:
- a
ChildObserver
for event handling. The caller mustChildObserver.close()
when done. - Since:
- 6.0.0
-
isDisabled
public boolean isDisabled()
Is this folder disabled. A disabled folder should have all child items disabled.- Overrides:
isDisabled
in classAbstractFolder<I extends TopLevelItem>
- Returns:
true
if and only if the folder is disabled.- See Also:
FolderJobQueueDecisionHandler
-
setDisabled
protected void setDisabled(boolean disabled)
Sets the folder as disabled.- Overrides:
setDisabled
in classAbstractFolder<I extends TopLevelItem>
- Parameters:
disabled
-true
if and only if the folder is to be disabled.
-
supportsMakeDisabled
public boolean supportsMakeDisabled()
Determines whether the folder supports being made disabled.- Overrides:
supportsMakeDisabled
in classAbstractFolder<I extends TopLevelItem>
- Returns:
true
if and only ifAbstractFolder.setDisabled(boolean)
is implemented
-
doConfigSubmit
public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
- Overrides:
doConfigSubmit
in classAbstractFolder<I extends TopLevelItem>
- Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
-
recalculateAfterSubmitted
protected final void recalculateAfterSubmitted(boolean recalculate)
Method for child classes to use if they want to suppress/confirm the automatic recalculation provided indoConfigSubmit(StaplerRequest, StaplerResponse)
. This method should only be called fromsubmit(StaplerRequest, StaplerResponse)
. If called multiple times fromsubmit(StaplerRequest, StaplerResponse)
then all calls must be with thefalse
parameter to suppress recalculation.- Parameters:
recalculate
-true
to require recalculation,false
to suppress recalculation.- See Also:
submit(StaplerRequest, StaplerResponse)
-
submit
protected void submit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormException
- Overrides:
submit
in classAbstractFolder<I extends TopLevelItem>
- Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
- See Also:
recalculateAfterSubmitted(boolean)
-
getSuccessfulDestination
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull protected final String getSuccessfulDestination()
Where user will be redirected after creating or reconfiguring aAbstractFolder
.- Overrides:
getSuccessfulDestination
in classAbstractFolder<I extends TopLevelItem>
- Returns:
- A string that represents the redirect location URL.
- See Also:
HttpServletResponse.sendRedirect(String)
-
getTriggers
public Map<TriggerDescriptor,Trigger<?>> getTriggers()
- Specified by:
getTriggers
in interfaceTriggeredItem
-
getTriggerDescriptors
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<TriggerDescriptor> getTriggerDescriptors()
-
addTrigger
public void addTrigger(Trigger trigger)
Update an existing trigger or add a new one.- Parameters:
trigger
- Target trigger instance.
-
removeTrigger
public void removeTrigger(Trigger trigger)
Remove an existing trigger.- Parameters:
trigger
- Target trigger instance.
-
getActions
public List<Action> getActions()
- Overrides:
getActions
in classActionable
-
isBuildable
public boolean isBuildable()
Whether it is permissible to recompute this folder at this time.- Returns:
true
if this folder can currently be recomputed.
-
doBuild
public org.kohsuke.stapler.HttpResponse doBuild(@QueryParameter TimeDuration delay)
-
scheduleBuild2
@CheckForNull public Queue.Item scheduleBuild2(int quietPeriod, Action... actions)
- Parameters:
quietPeriod
- seconds to wait before starting (normally 0)actions
- various actions to associate with the scheduling, such asParametersAction
orCauseAction
- Returns:
- a handle by which you may wait for the build to complete (or just start); or null if the build was not actually scheduled for some reason
-
scheduleBuild
public boolean scheduleBuild(Cause c)
- Specified by:
scheduleBuild
in interfaceBuildableItem
-
scheduleBuild
public boolean scheduleBuild(int quietPeriod, Cause c)
- Specified by:
scheduleBuild
in interfaceBuildableItem
-
getCauseOfBlockage
public CauseOfBlockage getCauseOfBlockage()
- Specified by:
getCauseOfBlockage
in interfaceQueue.Task
-
checkAbortPermission
public void checkAbortPermission()
- Specified by:
checkAbortPermission
in interfaceQueue.Task
-
hasAbortPermission
public boolean hasAbortPermission()
- Specified by:
hasAbortPermission
in interfaceQueue.Task
-
getAssignedLabel
public Label getAssignedLabel()
- Specified by:
getAssignedLabel
in interfaceSubTask
-
getLastBuiltOn
public Node getLastBuiltOn()
- Specified by:
getLastBuiltOn
in interfaceSubTask
-
getEstimatedDuration
public long getEstimatedDuration()
- Specified by:
getEstimatedDuration
in interfaceSubTask
-
createExecutable
public final FolderComputation<I> createExecutable() throws IOException
- Specified by:
createExecutable
in interfaceSubTask
- Throws:
IOException
-
createComputation
@NonNull protected FolderComputation<I> createComputation(@CheckForNull FolderComputation<I> previous)
-
getComputationDir
protected File getComputationDir()
-
isHasEvents
public boolean isHasEvents()
Identifies if thisComputedFolder
has a separate out of band events log. Default implementation just checks if the events log has content. Subclasses can override this method to force the events log always present in the UI.- Returns:
true
if thisComputedFolder
has a separate out of band events log.
-
getComputation
@NonNull public FolderComputation<I> getComputation()
URL binding and other purposes. It may benull
temporarily inside the constructor, so beware if you extend this class.- Returns:
- the computation.
-
getLastSuccessfulBuild
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public PseudoRun<I> getLastSuccessfulBuild()
-
getLastStableBuild
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public PseudoRun<I> getLastStableBuild()
-
getLastFailedBuild
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public PseudoRun<I> getLastFailedBuild()
-
checkRename
protected void checkRename(String newName)
- Overrides:
checkRename
in classAbstractFolder<I extends TopLevelItem>
-
getOrphanedItemStrategy
@NonNull public OrphanedItemStrategy getOrphanedItemStrategy()
-
getOrphanedItemStrategyDescriptors
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @NonNull public List<OrphanedItemStrategyDescriptor> getOrphanedItemStrategyDescriptors()
Gets theOrphanedItemStrategyDescriptor
s applicable to this folder.- Returns:
- the
OrphanedItemStrategyDescriptor
s applicable to this folder.
-
-