@ExportedBean public abstract class AbstractItem extends Actionable implements Item, org.kohsuke.stapler.HttpDeletable, AccessControlled, DescriptorByNameOwner
Item
.ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem
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.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractItem(ItemGroup parent,
String name) |
Modifier and Type | Method and Description |
---|---|
void |
checkPermission(Permission p)
Short for
getACL().checkPermission(p) |
void |
delete()
Deletes this item.
|
void |
delete(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
void |
doConfigDotXml(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts config.xml submission, as well as serve it.
|
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.
|
Descriptor |
getDescriptorByName(String className)
Exposes all
Descriptor s by its name to URL. |
String |
getDisplayName()
Gets the human readable short name of this item.
|
String |
getDisplayNameOrNull() |
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 |
getRelativeNameFrom(Item item)
Short for
getRelativeNameFrom(item.getParent()) |
String |
getRelativeNameFrom(ItemGroup p)
Gets the relative name to this item from the specified group.
|
String |
getRelativeNameFromGroup(ItemGroup p)
This method only exists to disambiguate
getRelativeNameFrom(ItemGroup) and 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 . |
String |
getUrl()
Returns the URL of this item relative to the context root of the application.
|
boolean |
hasPermission(Permission p)
Short for
getACL().hasPermission(p) |
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 |
onCreatedFromScratch()
When an item is created from scratch (instead of copied),
this method will be invoked.
|
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. |
addAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, replaceAction
getSearch, getSearchIndex, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSearch
getSearchIndex
protected transient String name
protected volatile String description
protected String displayName
public static final AlternativeUiTextProvider.Message<AbstractItem> PRONOUN
public void onCreatedFromScratch()
Item
onCreatedFromScratch
in interface Item
@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.@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
displayName
- 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.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
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)
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)
getRelativeNameFrom(ItemGroup)
and getRelativeNameFrom(Item)
getRelativeNameFrom(ItemGroup)
public String getRelativeNameFrom(ItemGroup p)
Item
getRelativeNameFrom
in interface Item
p
- The ItemGroup instance used as context to evaluate the relative name of this AbstractItempublic String getRelativeNameFrom(Item item)
Item
getRelativeNameFrom(item.getParent())
getRelativeNameFrom
in interface Item
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()
public ACL getACL()
ACL
for this object.getACL
in interface AccessControlled
public void checkPermission(Permission p)
getACL().checkPermission(p)
checkPermission
in interface AccessControlled
public boolean hasPermission(Permission p)
getACL().hasPermission(p)
hasPermission
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()
public Descriptor getDescriptorByName(String className)
DescriptorByNameOwner
Descriptor
s by its name to URL.
Implementation should always delegate to Jenkins.getDescriptorByName(String)
.
getDescriptorByName
in interface DescriptorByNameOwner
className
- Either Descriptor.getId()
(recommended) or the short name.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
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
@CLIMethod(name="reload-job") public void doReload() throws IOException
IOException
public String getSearchName()
AbstractModelObject
getSearchName
in interface SearchItem
getSearchName
in class AbstractModelObject
@CLIResolver public static AbstractItem resolveForCLI(String name) throws org.kohsuke.args4j.CmdLineException
org.kohsuke.args4j.CmdLineException
Copyright © 2016. All rights reserved.