@ExportedBean public abstract class AbstractItem extends Actionable implements Item, org.kohsuke.stapler.HttpDeletable, AccessControlled, DescriptorByNameOwner, org.kohsuke.stapler.StaplerProxy
Item
.ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
Modifier and Type | Field and Description |
---|---|
protected String |
description
Project description.
|
protected String |
displayName |
protected String |
name
Project name.
|
static AlternativeUiTextProvider.Message<AbstractItem> |
PRONOUN
Replaceable pronoun of that points to a job.
|
static boolean |
SKIP_PERMISSION_CHECK
Escape hatch for StaplerProxy-based access control
|
static AlternativeUiTextProvider.Message<AbstractItem> |
TASK_NOUN
Replaceable noun for describing the kind of task that this item represents.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractItem(ItemGroup parent,
String name) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkRename(String newName)
Allows subclasses to block renames for domain-specific reasons.
|
void |
delete()
Deletes this item.
|
void |
delete(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
FormValidation |
doCheckNewName(String newName)
Called by
doConfirmRename(java.lang.String) and rename.jelly to validate renames. |
void |
doConfigDotXml(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts
config.xml submission, as well as serve it. |
org.kohsuke.stapler.HttpResponse |
doConfirmRename(String newName)
Renames this item
|
void |
doDoDelete(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Deletes this item.
|
void |
doReload()
Reloads this job from the disk.
|
protected void |
doSetName(String name)
Just update
name without performing the rename operation,
which would involve copying files and etc. |
void |
doSubmitDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts the new description.
|
String |
getAbsoluteUrl()
Returns the absolute URL of this item.
|
ACL |
getACL()
Returns the
ACL for this object. |
abstract Collection<? extends Job> |
getAllJobs()
Gets all the jobs that this
Item contains as descendants. |
Api |
getApi()
Remote API access.
|
XmlFile |
getConfigFile() |
String |
getDescription()
Gets the project description HTML.
|
String |
getDisplayName()
Gets the human readable short name of this item.
|
String |
getDisplayNameOrNull()
This is intended to be used by the Job configuration pages where
we want to return null if the display name is not set.
|
String |
getFullDisplayName()
Works like
Item.getDisplayName() but return
the full path that includes all the display names
of the ancestors. |
String |
getFullName()
Gets the full name of this item, like "abc/def/ghi".
|
String |
getName()
Gets the name of the item.
|
ItemGroup |
getParent()
This bridge method is to maintain binary compatibility with
Item.getParent() . |
String |
getPronoun()
Get the term used in the UI to represent this kind of
Item . |
String |
getRelativeDisplayNameFrom(ItemGroup p)
Gets the display name of the current item relative to the given group.
|
String |
getRelativeNameFromGroup(ItemGroup p)
This method only exists to disambiguate
Item.getRelativeNameFrom(ItemGroup) and Item.getRelativeNameFrom(Item) |
File |
getRootDir()
Gets the root directory on the file system that this
Item can use freely for storing the configuration data. |
String |
getSearchName()
Default implementation that returns the display name.
|
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
String |
getShortUrl()
Returns the URL of this item relative to the parent
ItemGroup . |
Object |
getTarget() |
String |
getTaskNoun()
Gets the term used in the UI to represent the kind of
Queue.Task associated with this kind of
Item . |
String |
getUrl()
Returns the URL of this item relative to the context root of the application.
|
boolean |
isNameEditable()
Controls whether the default rename action is available for this item.
|
void |
movedTo(DirectlyModifiableTopLevelItemGroup destination,
AbstractItem newItem,
File destDir)
Notify this item it's been moved to another location, replaced by newItem (might be the same object, but not guaranteed).
|
void |
onCopiedFrom(Item src)
When a
Item is copied from existing one,
the files are first copied on the file system,
then it will be loaded, then this method will be invoked
to perform any implementation-specific work. |
void |
onLoad(ItemGroup<? extends Item> parent,
String name)
Called right after when a
Item is loaded from disk. |
protected void |
performDelete()
Does the real job of deleting the item.
|
protected void |
renameTo(String newName)
Renames this item.
|
static AbstractItem |
resolveForCLI(String name)
Used for CLI binding.
|
void |
save()
Save the settings to a file.
|
void |
setDescription(String description)
Sets the project description HTML.
|
void |
setDisplayName(String displayName) |
void |
setDisplayNameOrNull(String displayName)
This method exists so that the Job configuration pages can use
getDisplayNameOrNull so that nothing is shown in the display name text
box if the display name is not set.
|
String |
toString() |
void |
updateByXml(Source source)
Updates an Item by its XML definition.
|
void |
updateByXml(StreamSource source)
Deprecated.
as of 1.473
Use
updateByXml(Source) |
void |
writeConfigDotXml(OutputStream os)
Writes
config.xml to the specified output stream. |
protected Object |
writeReplace() |
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
getSearch, getSearchIndex, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRelativeNameFrom, getRelativeNameFrom, onCreatedFromScratch
getSearch
getSearchIndex
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
getDescriptorByName
protected transient String name
protected volatile String description
protected String displayName
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECK
public static final AlternativeUiTextProvider.Message<AbstractItem> PRONOUN
public static final AlternativeUiTextProvider.Message<AbstractItem> TASK_NOUN
@Exported(visibility=999) public String getName()
Item
The name must be unique among other Item
s that belong
to the same parent.
This name is also used for directory name, so it cannot contain any character that's not allowed on the file system.
getName
in interface Item
Item.getFullName()
public String getPronoun()
Item
. Must start with a capital letter.public String getTaskNoun()
Queue.Task
associated with this kind of
Item
. Must start with a capital letter. Defaults to "Build".@Exported public String getDisplayName()
Item
This method should try to return a short concise human readable string that describes this item. The string need not be unique.
The returned string should not include the display names
of ancestor items
.
getDisplayName
in interface Item
getDisplayName
in interface ModelObject
@Exported public String getDisplayNameOrNull()
public void setDisplayNameOrNull(String displayName) throws IOException
IOException
public void setDisplayName(String displayName) throws IOException
IOException
public File getRootDir()
PersistenceRoot
Item
can use freely for storing the configuration data.
This parameter is given by the ItemGroup
when
Item
is loaded from memory.
getRootDir
in interface PersistenceRoot
@WithBridgeMethods(value=Jenkins.class, castRequired=true) @NonNull public ItemGroup getParent()
Item.getParent()
.@Exported public String getDescription()
public void setDescription(String description) throws IOException
IOException
protected void doSetName(String name)
name
without performing the rename operation,
which would involve copying files and etc.public boolean isNameEditable()
name
can be modified by a usercheckRename(java.lang.String)
,
renameTo(java.lang.String)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doConfirmRename(@QueryParameter String newName) throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public FormValidation doCheckNewName(@QueryParameter String newName)
doConfirmRename(java.lang.String)
and rename.jelly
to validate renames.FormValidation.ok(java.lang.String)
if this item can be renamed as specified, otherwise
FormValidation.error(java.lang.String)
with a message explaining the problem.protected void checkRename(@NonNull String newName) throws Failure
newName
- the new name for the itemFailure
- if the rename should be blockedJob.checkRename(java.lang.String)
protected void renameTo(String newName) throws IOException
IOException
public void movedTo(DirectlyModifiableTopLevelItemGroup destination, AbstractItem newItem, File destDir) throws IOException
Derived classes can override this method to add some specific behavior on move, but have to call parent method so the item is actually setup within it's new parent.
public abstract Collection<? extends Job> getAllJobs()
Item
contains as descendants.getAllJobs
in interface Item
@Exported public final String getFullName()
Item
Full name consists of name
s of Item
s
that lead from the root Jenkins
to this Item
,
separated by '/'. This is the unique name that identifies this
Item
inside the whole Jenkins
.
getFullName
in interface Item
Jenkins.getItemByFullName(String,Class)
@Exported public final String getFullDisplayName()
Item
Item.getDisplayName()
but return
the full path that includes all the display names
of the ancestors.getFullDisplayName
in interface Item
public String getRelativeDisplayNameFrom(ItemGroup p)
p
- the ItemGroup used as point of reference for the itempublic String getRelativeNameFromGroup(ItemGroup p)
Item.getRelativeNameFrom(ItemGroup)
and Item.getRelativeNameFrom(Item)
Item.getRelativeNameFrom(ItemGroup)
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
Item
is loaded from disk.
This is an opportunity to do a post load processing.onLoad
in interface Item
name
- Name of the directory (not a path --- just the name portion) from
which the configuration was loaded. This usually becomes the
name
of this item.IOException
public void onCopiedFrom(Item src)
Item
is copied from existing one,
the files are first copied on the file system,
then it will be loaded, then this method will be invoked
to perform any implementation-specific work.onCopiedFrom
in interface Item
src
- Item from which it's copied from. The same type as this
. Never null.public final String getUrl()
Item
getUrl
in interface Item
for how to implement this.
public String getShortUrl()
Item
ItemGroup
.getShortUrl
in interface Item
for how to implement this.
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
@Exported(visibility=999, name="url") public final String getAbsoluteUrl()
Item
StaplerRequest
to figure out what the host name is,
so can be used only during processing client requests.getAbsoluteUrl
in interface Item
public final Api getApi()
@NonNull public ACL getACL()
ACL
for this object.getACL
in interface AccessControlled
public void save() throws IOException
save
in interface Item
save
in interface Saveable
IOException
- if the persistence failed.public final XmlFile getConfigFile()
protected Object writeReplace()
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, InterruptedException
/doDelete
since it predates <l:confirmationLink>
. /delete
goes to a Jelly page
which should now be unused by core but is left in case plugins are still using it.IOException
javax.servlet.ServletException
InterruptedException
public void delete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
delete
in interface org.kohsuke.stapler.HttpDeletable
IOException
javax.servlet.ServletException
public void delete() throws IOException, InterruptedException
Any exception indicates the deletion has failed, but AbortException
would prevent the caller
from showing the stack trace. This
delete
in interface Item
IOException
InterruptedException
protected void performDelete() throws IOException, InterruptedException
IOException
InterruptedException
@WebMethod(name="config.xml") public void doConfigDotXml(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
config.xml
submission, as well as serve it.IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void writeConfigDotXml(OutputStream os) throws IOException
config.xml
to the specified output stream.
The user must have at least Item.EXTENDED_READ
.
If he lacks Item.CONFIGURE
, then any Secret
s detected will be masked out.IOException
@Deprecated public void updateByXml(StreamSource source) throws IOException
updateByXml(Source)
IOException
public void updateByXml(Source source) throws IOException
source
- source of the Item's new definition.
The source should be either a StreamSource
or a SAXSource
, other
sources may not be handled.IOException
public void doReload() throws IOException
IOException
public String getSearchName()
AbstractModelObject
getSearchName
in interface SearchItem
getSearchName
in class AbstractModelObject
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
getTarget
in interface org.kohsuke.stapler.StaplerProxy
@CLIResolver public static AbstractItem resolveForCLI(String name) throws org.kohsuke.args4j.CmdLineException
org.kohsuke.args4j.CmdLineException
Copyright © 2004–2022. All rights reserved.