hudson.model
Class View

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.View
All Implemented Interfaces:
ExtensionPoint, Describable<View>, ModelObject, SearchableModelObject, SearchItem, AccessControlled
Direct Known Subclasses:
AllView, ListView, MyView, ProxyView, TreeView

@ExportedBean
public abstract class View
extends AbstractModelObject
implements AccessControlled, Describable<View>, ExtensionPoint

Encapsulates the rendering of the list of TopLevelItems that Hudson owns.

This is an extension point in Hudson, allowing different kind of rendering to be added as plugins.

Note for implementors

Author:
Kohsuke Kawaguchi
See Also:
ViewDescriptor, ViewGroup

Nested Class Summary
static class View.People
           
static class View.UserInfo
           
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static Permission CONFIGURE
           
static Permission CREATE
          Permission to create new jobs.
static Permission DELETE
           
static DescriptorList<View> LIST
          Deprecated. as of 1.286 Use all() for read access, and use Extension for registration.
static PermissionGroup PERMISSIONS
           
static Comparator<View> SORTER
           
 
Method Summary
static DescriptorExtensionList<View,ViewDescriptor> all()
          Returns all the registered ViewDescriptors.
 void checkPermission(Permission p)
          Convenient short-cut for getACL().checkPermission(permission)
abstract  boolean contains(TopLevelItem item)
          Checks if the job is in this collection.
static View create(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, ViewGroup owner)
           
 void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts submission from the configuration page.
abstract  Item doCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Creates a new Item in this collection.
 void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Deletes this view.
 void doRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts the new description.
 String getAbsoluteUrl()
          Gets the absolute URL of this view.
 ACL getACL()
          Returns the ACL for this object.
 List<Action> getActions()
          Returns the transient Actions associated with the top page.
 Api getApi()
           
 RunList getBuilds()
           
 List<Computer> getComputers()
           
 String getDescription()
          Message displayed in the top page.
 ViewDescriptor getDescriptor()
          Gets the descriptor for this instance.
 String getDisplayName()
           
 Object getDynamic(String token)
           
 TopLevelItem getItem(String name)
          Gets the TopLevelItem of the given name.
static Permission getItemCreatePermission()
           
abstract  Collection<TopLevelItem> getItems()
          Gets all the items in this collection in a read-only view.
 TopLevelItem getJob(String name)
          Alias for getItem(String).
 ViewGroup getOwner()
          Gets the ViewGroup that this view belongs to.
 View.People getPeople()
          Gets the users that show up in the changelog of this job collection.
 String getPostConstructLandingPage()
          Returns the page to redirect the user to, after the view is created.
 List<Queue.Item> getQueueItems()
           
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
 BuildTimelineWidget getTimeline()
           
 String getUrl()
          Returns the path relative to the context root.
 String getViewName()
          Gets the name of all this collection.
 String getViewUrl()
          Same as getUrl() except this returns a view/{name} path even for the default view.
 List<Widget> getWidgets()
          Gets the Widgets registered on this object.
 boolean hasPeople()
          Does this View has any associated user information recorded?
 boolean hasPermission(Permission p)
          Convenient short-cut for getACL().hasPermission(permission)
 boolean isDefault()
          If true, this is a view that renders the top page of Hudson.
 boolean isEditable()
          By default, return true to render the "Edit view" link on the page.
 boolean isFilterExecutors()
          If true, only show relevant executors
 boolean isFilterQueue()
          If true, only show relevant queue items
 SearchIndexBuilder makeSearchIndex()
          Default implementation that returns empty index.
abstract  void onJobRenamed(Item item, String oldName, String newName)
          Called when a job name is changed or deleted.
 void rename(String newName)
          Renames this view.
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST

public static final DescriptorList<View> LIST
Deprecated. as of 1.286 Use all() for read access, and use Extension for registration.
A list of available view types.


SORTER

public static final Comparator<View> SORTER

PERMISSIONS

public static final PermissionGroup PERMISSIONS

CREATE

public static final Permission CREATE
Permission to create new jobs.


DELETE

public static final Permission DELETE

CONFIGURE

public static final Permission CONFIGURE
Method Detail

getItems

@Exported(name="jobs")
public abstract Collection<TopLevelItem> getItems()
Gets all the items in this collection in a read-only view.


getItem

public TopLevelItem getItem(String name)
Gets the TopLevelItem of the given name.


getJob

public final TopLevelItem getJob(String name)
Alias for getItem(String). This is the one used in the URL binding.


contains

public abstract boolean contains(TopLevelItem item)
Checks if the job is in this collection.


getViewName

@Exported(visibility=2,
          name="name")
public String getViewName()
Gets the name of all this collection.

See Also:
rename(String)

rename

public void rename(String newName)
            throws Failure,
                   Descriptor.FormException
Renames this view.

Throws:
Failure
Descriptor.FormException

getOwner

public ViewGroup getOwner()
Gets the ViewGroup that this view belongs to.


getDescription

@Exported
public String getDescription()
Message displayed in the top page. Can be null. Includes HTML.


getDescriptor

public ViewDescriptor getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<View>

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface ModelObject

isEditable

public boolean isEditable()
By default, return true to render the "Edit view" link on the page. This method is really just for the default "All" view to hide the edit link so that the default Hudson top page remains the same as before 1.316.

Since:
1.316

isFilterExecutors

public boolean isFilterExecutors()
If true, only show relevant executors


isFilterQueue

public boolean isFilterQueue()
If true, only show relevant queue items


getWidgets

public List<Widget> getWidgets()
Gets the Widgets registered on this object.

For now, this just returns the widgets registered to Hudson.


isDefault

public boolean isDefault()
If true, this is a view that renders the top page of Hudson.


getComputers

public List<Computer> getComputers()

getQueueItems

public List<Queue.Item> getQueueItems()

getUrl

public String getUrl()
Returns the path relative to the context root. Doesn't start with '/' but ends with '/' (except returns empty string when this is the default view).


getViewUrl

public String getViewUrl()
Same as getUrl() except this returns a view/{name} path even for the default view.


getSearchUrl

public String getSearchUrl()
Description copied from interface: SearchItem
Returns the URL of this item relative to the parent SearchItem.

Specified by:
getSearchUrl in interface SearchItem
Returns:
URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Hudson.)

getActions

public List<Action> getActions()
Returns the transient Actions associated with the top page.

If views don't want to show top-level actions, this method can be overridden to return different objects.

See Also:
Hudson.getActions()

getDynamic

public Object getDynamic(String token)

getAbsoluteUrl

@Exported(visibility=2,
          name="url")
public String getAbsoluteUrl()
Gets the absolute URL of this view.


getApi

public Api getApi()

getPostConstructLandingPage

public String getPostConstructLandingPage()
Returns the page to redirect the user to, after the view is created. The returned string is appended to "/view/foobar/", so for example to direct the user to the top page of the view, return "", etc.


getACL

public ACL getACL()
Returns the ACL for this object.

Specified by:
getACL in interface AccessControlled
Returns:
never null.

checkPermission

public void checkPermission(Permission p)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().checkPermission(permission)

Specified by:
checkPermission in interface AccessControlled

hasPermission

public boolean hasPermission(Permission p)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().hasPermission(permission)

Specified by:
hasPermission in interface AccessControlled

onJobRenamed

public abstract void onJobRenamed(Item item,
                                  String oldName,
                                  String newName)
Called when a job name is changed or deleted.

If this view contains this job, it should update the view membership so that the renamed job will remain in the view, and the deleted job is removed.

Parameters:
item - The item whose name is being changed.
oldName - Old name of the item. Always non-null.
newName - New name of the item, if the item is renamed. Or null, if the item is removed.

hasPeople

public final boolean hasPeople()
Does this View has any associated user information recorded?


getPeople

public final View.People getPeople()
Gets the users that show up in the changelog of this job collection.


makeSearchIndex

public SearchIndexBuilder makeSearchIndex()
Description copied from class: AbstractModelObject
Default implementation that returns empty index.


doSubmitDescription

public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req,
                                org.kohsuke.stapler.StaplerResponse rsp)
                         throws IOException,
                                javax.servlet.ServletException
Accepts the new description.

Throws:
IOException
javax.servlet.ServletException

doConfigSubmit

public final void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp)
                          throws IOException,
                                 javax.servlet.ServletException,
                                 Descriptor.FormException
Accepts submission from the configuration page. Subtypes should override the submit(StaplerRequest) method.

Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException

doDoDelete

public void doDoDelete(org.kohsuke.stapler.StaplerRequest req,
                       org.kohsuke.stapler.StaplerResponse rsp)
                throws IOException,
                       javax.servlet.ServletException
Deletes this view.

Throws:
IOException
javax.servlet.ServletException

doCreateItem

public abstract Item doCreateItem(org.kohsuke.stapler.StaplerRequest req,
                                  org.kohsuke.stapler.StaplerResponse rsp)
                           throws IOException,
                                  javax.servlet.ServletException
Creates a new Item in this collection.

This method should call Hudson.doCreateItem(StaplerRequest, StaplerResponse) and then add the newly created item to this view.

Returns:
null if fails.
Throws:
IOException
javax.servlet.ServletException

doRssAll

public void doRssAll(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp)
              throws IOException,
                     javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doRssFailed

public void doRssFailed(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp)
                 throws IOException,
                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

getBuilds

public RunList getBuilds()

getTimeline

public BuildTimelineWidget getTimeline()

doRssLatest

public void doRssLatest(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp)
                 throws IOException,
                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

all

public static DescriptorExtensionList<View,ViewDescriptor> all()
Returns all the registered ViewDescriptors.


getItemCreatePermission

public static Permission getItemCreatePermission()

create

public static View create(org.kohsuke.stapler.StaplerRequest req,
                          org.kohsuke.stapler.StaplerResponse rsp,
                          ViewGroup owner)
                   throws Descriptor.FormException,
                          IOException,
                          javax.servlet.ServletException
Throws:
Descriptor.FormException
IOException
javax.servlet.ServletException


Copyright © 2004-2013 Hudson. All Rights Reserved.