Class CauseManagement
- java.lang.Object
-
- com.sonyericsson.jenkins.plugins.bfa.CauseManagement
-
- All Implemented Interfaces:
ExtensionPoint
,Action
,ModelObject
,RootAction
- Direct Known Subclasses:
TransientCauseManagement
@Extension public class CauseManagement extends Object implements RootAction
Page for managing the failure causes.- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static String
GRAPH_PAGE_TITLE
Title for the page displaying the graphs.static String
NEW_CAUSE_DESCRIPTION
The pre-filled description that a new cause gets.static String
NEW_CAUSE_DYNAMIC_ID
The reserved id for getting a newFailureCause
fromgetDynamic(String, org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)
.static String
NEW_CAUSE_NAME
The pre-filled name that a new cause gets.static String
REQUEST_CAUSE_MANAGEMENT_ERROR
The request attribute key where error messages are added.static String
SESSION_REMOVED_FAILURE_CAUSE
Session key for the last removedFailureCause
by the user.static String
URL_NAME
Where in the Jenkins name space this action will be.
-
Constructor Summary
Constructors Constructor Description CauseManagement()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doRemoveConfirm(String id, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Web call to remove aFailureCause
.String
getDisplayName()
FailureCause
getDynamic(String id, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Dynamic Stapler URL binding.String
getErrorMessage(org.kohsuke.stapler.StaplerRequest request)
Used for getting the error message to show on the page.String
getIconFileName()
String
getImageUrl(String size, String name)
Convenience method for callingPluginImpl.getImageUrl(String, String)
from jelly.ExtensionList<Indication.IndicationDescriptor>
getIndicationDescriptors()
Provides a list of all IndicationDescriptors.static CauseManagement
getInstance()
Provides the singleton instance of this class that Jenkins has loaded.ModelObject
getOwner()
The "owner" of this Action.protected String
getOwnerUrl()
Where to redirect after the form has been saved, probably to the owner.Permission
getPermission()
The permission related to this action.Permission
getRemovePermission()
The permission related to this action.Iterable<FailureCause>
getShallowCauses()
Convenience method forKnowledgeBase.getShallowCauses()
.String
getUrlName()
boolean
isError(org.kohsuke.stapler.StaplerRequest request)
Convenience method for jelly.boolean
isUnderTest()
Checks if Jenkins is run from inside a HudsonTestCase.
-
-
-
Field Detail
-
URL_NAME
public static final String URL_NAME
Where in the Jenkins name space this action will be.- See Also:
getUrlName()
, Constant Field Values
-
NEW_CAUSE_DYNAMIC_ID
public static final String NEW_CAUSE_DYNAMIC_ID
The reserved id for getting a newFailureCause
fromgetDynamic(String, org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)
.- See Also:
- Constant Field Values
-
NEW_CAUSE_NAME
public static final String NEW_CAUSE_NAME
The pre-filled name that a new cause gets.- See Also:
- Constant Field Values
-
NEW_CAUSE_DESCRIPTION
public static final String NEW_CAUSE_DESCRIPTION
The pre-filled description that a new cause gets.- See Also:
- Constant Field Values
-
REQUEST_CAUSE_MANAGEMENT_ERROR
public static final String REQUEST_CAUSE_MANAGEMENT_ERROR
The request attribute key where error messages are added.- See Also:
- Constant Field Values
-
SESSION_REMOVED_FAILURE_CAUSE
public static final String SESSION_REMOVED_FAILURE_CAUSE
Session key for the last removedFailureCause
by the user. Will be removed by the index page when it displays it.- See Also:
- Constant Field Values
-
GRAPH_PAGE_TITLE
public static final String GRAPH_PAGE_TITLE
Title for the page displaying the graphs.- See Also:
- Constant Field Values
-
-
Method Detail
-
getIconFileName
public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrlName
public String getUrlName()
- Specified by:
getUrlName
in interfaceAction
-
getImageUrl
public String getImageUrl(String size, String name)
Convenience method for callingPluginImpl.getImageUrl(String, String)
from jelly.- Parameters:
size
- the sizename
- the name- Returns:
- the url.
- See Also:
PluginImpl.getImageUrl(String, String)
-
getShallowCauses
public Iterable<FailureCause> getShallowCauses() throws Exception
Convenience method forKnowledgeBase.getShallowCauses()
.- Returns:
- the collection of causes.
- Throws:
Exception
- if communication fails.
-
isError
public boolean isError(org.kohsuke.stapler.StaplerRequest request)
Convenience method for jelly.- Parameters:
request
- the request where the message might be.- Returns:
- true if there is an error message to display.
-
getErrorMessage
public String getErrorMessage(org.kohsuke.stapler.StaplerRequest request)
Used for getting the error message to show on the page.- Parameters:
request
- the request where the message might be.- Returns:
- the error message to show.
-
getDynamic
public FailureCause getDynamic(String id, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
Dynamic Stapler URL binding. Provides the ability to navigate to a cause via for example:/jenkins/failure-cause-management/abf123
- Parameters:
id
- the id of the cause of "new" to create a new cause.request
- the requestresponse
- the response- Returns:
- the cause if found or null.
- Throws:
Exception
- if communication with the knowledge base failed.
-
doRemoveConfirm
@POST public void doRemoveConfirm(@QueryParameter String id, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws IOException
Web call to remove aFailureCause
. Does a permission check forPluginImpl.REMOVE_PERMISSION
.- Parameters:
id
- the id of the cause to remove.request
- the stapler request.response
- the stapler response.- Throws:
IOException
- if so during redirect.
-
getOwner
public ModelObject getOwner()
The "owner" of this Action. Default this would beHudson.getInstance()
but if the class is included in some build or something we might want to be able to easier change the side panel for example.- Returns:
- the holder of the beer.
-
getOwnerUrl
protected String getOwnerUrl()
Where to redirect after the form has been saved, probably to the owner.- Returns:
- the owner's URL or some place else to redirect the user after save.
-
getIndicationDescriptors
public ExtensionList<Indication.IndicationDescriptor> getIndicationDescriptors()
Provides a list of all IndicationDescriptors. For Jelly convenience.- Returns:
- a list of descriptors.
- See Also:
Indication.IndicationDescriptor.getAll()
-
getPermission
public Permission getPermission()
The permission related to this action. For Jelly convenience.- Returns:
- the permission.
- See Also:
PluginImpl.UPDATE_PERMISSION
-
getRemovePermission
public Permission getRemovePermission()
The permission related to this action. For Jelly convenience.- Returns:
- the permission.
- See Also:
PluginImpl.UPDATE_PERMISSION
-
isUnderTest
public boolean isUnderTest()
Checks if Jenkins is run from inside a HudsonTestCase. For some reason the buildQueue fails to render when run under test but works fine when run with hpi:run. So the jelly file skips the inclusion of the sidepanel if we are running under test to work around this problem. The check is done via looking at the class name ofJenkins.getPluginManager()
.- Returns:
- true if we are running under test.
-
getInstance
public static CauseManagement getInstance()
Provides the singleton instance of this class that Jenkins has loaded. Throws an IllegalStateException if for some reason the action can't be found.- Returns:
- the instance.
-
-