Esri Geoportal Server
1.0

com.esri.gpt.framework.jsf
Class BaseActionListener

java.lang.Object
  extended by com.esri.gpt.framework.jsf.BaseActionListener
All Implemented Interfaces:
EventListener, ActionListener, FacesListener
Direct Known Subclasses:
BaseHarvestController, DownloadController, EditMetadataController, LiveDataController, LoginController, ManageMetadataController, SampleController, SearchController, SelfCareController, UploadMetadataController, ValidateMetadataController

public class BaseActionListener
extends Object
implements ActionListener

Super-class for a JSF based action listener.


Constructor Summary
BaseActionListener()
          Default constructor.
 
Method Summary
protected  void assertLoggedIn(RequestContext context)
          Asserts that the active user is logged in.
protected  void authorizeAction(RequestContext context)
          Authorizes an action.
protected  MessageBroker extractMessageBroker()
          Extract the MessageBroker from the Faces context instance.
 RequestContext extractRequestContext()
          Extract the request context from the Faces context instance.
protected  FacesContextBroker getContextBroker()
          Gets the Faces context broker.
 String getKey()
          Gets the key associated with the action listener.
 Logger getLogger()
          Gets the logger.
 String getNavigationOutcome()
          Gets the navigation outcome.
 String getPrepareView()
          Provides an interface to prepare the view for a page.
 String getSecurityRoles()
          Gets the security roles string associated with the action listener.
protected  RoleSet getSecurityRoleSet()
          Gets the security role set associated with the action listener.
protected  void handleException(Throwable t)
          Handles an exception.
protected  void onExecutionPhaseCompleted()
          Fired when the execution phase has completed.
protected  RequestContext onExecutionPhaseStarted()
          Fired when the execution phase has started.
protected  void onPrepareView(RequestContext context)
          Fired when the getPrepareView() property is accessed.
protected  void onPrepareViewCompleted()
          Fired when the onPrepareView() event has completed.
protected  RequestContext onPrepareViewStarted()
          Fired when the onPrepareView()event has started.
 void processAction(ActionEvent event)
          Processes the JSF based action.
protected  void processSubAction(ActionEvent event, RequestContext context)
          This is the default entry point for a sub-class of this ActionListener.
 void setKey(String key)
          Sets the key associated with the action listener.
protected  void setNavigationOutcome(String outcome)
          Sets the navigation outcome.
 void setPrepareView(String ignored)
          Provides the setter for the prepareView property.
 void setSecurityRoles(String roles)
          Gets the security roles string associated with the action listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseActionListener

public BaseActionListener()
Default constructor.

Method Detail

getContextBroker

protected FacesContextBroker getContextBroker()
Gets the Faces context broker.

Returns:
the Faces context broker

getKey

public String getKey()
Gets the key associated with the action listener.

Returns:
the key

setKey

public void setKey(String key)
Sets the key associated with the action listener.

Parameters:
key - the key

getLogger

public Logger getLogger()
Gets the logger.

Returns:
the logger

getNavigationOutcome

public String getNavigationOutcome()
Gets the navigation outcome.

Returns:
the navigation outcome

setNavigationOutcome

protected void setNavigationOutcome(String outcome)
Sets the navigation outcome.

Parameters:
outcome - the navigation outcome

getPrepareView

public String getPrepareView()
Provides an interface to prepare the view for a page.

Some pages may require preparation during the render response phase of the JSF cycle. In such cases, the page should include a hidden variable to trigger view preparation. Example: <h:inputHidden value="#{SomeController.prepareView}"/>

Once triggered, the onPrepareView() method for the controller will be invoked. Override the onPrepareView() method to provide controller specific behavior.

Returns:
always an empty string

setPrepareView

public void setPrepareView(String ignored)
Provides the setter for the prepareView property.

Parameters:
ignored - always ignored

getSecurityRoles

public String getSecurityRoles()
Gets the security roles string associated with the action listener.

Returns:
the security roles string

setSecurityRoles

public void setSecurityRoles(String roles)
Gets the security roles string associated with the action listener.

Parameters:
roles - the security roles string

getSecurityRoleSet

protected RoleSet getSecurityRoleSet()
Gets the security role set associated with the action listener.

Returns:
the security role set

assertLoggedIn

protected void assertLoggedIn(RequestContext context)
                       throws NotAuthorizedException
Asserts that the active user is logged in.

Parameters:
context - the request context associated with this execution thread
Throws:
NotAuthorizedException - if the user does not have a required role

authorizeAction

protected void authorizeAction(RequestContext context)
                        throws NotAuthorizedException
Authorizes an action.
Authorization is based upon the security roles for this action listener and the authenticated roles for the user associated with the supplied request context.
If the security roles for this action are empty, the action is authorized.

Parameters:
context - the request context associated with this execution thread
Throws:
NotAuthorizedException - if the user does not have a required role

extractMessageBroker

protected MessageBroker extractMessageBroker()
Extract the MessageBroker from the Faces context instance.

Returns:
the MessageBroker

extractRequestContext

public RequestContext extractRequestContext()
Extract the request context from the Faces context instance.

Returns:
the request context

handleException

protected void handleException(Throwable t)
Handles an exception.

Parameters:
t - the exception

onExecutionPhaseCompleted

protected void onExecutionPhaseCompleted()
Fired when the execution phase has completed.


onExecutionPhaseStarted

protected RequestContext onExecutionPhaseStarted()
Fired when the execution phase has started.


onPrepareView

protected void onPrepareView(RequestContext context)
                      throws Exception
Fired when the getPrepareView() property is accessed.
This event is triggered from the page during the render response phase of the JSF cycle.

Parameters:
context - the context associated with the active request
Throws:
Exception - if an exception occurs

onPrepareViewCompleted

protected void onPrepareViewCompleted()
Fired when the onPrepareView() event has completed.


onPrepareViewStarted

protected RequestContext onPrepareViewStarted()
Fired when the onPrepareView()event has started.


processAction

public void processAction(ActionEvent event)
                   throws AbortProcessingException
Processes the JSF based action.
This is the default entry point for a JSF ActionListener.
The default behavior is: flag the start of the execution phase, authorize the action, invoke the processPreparedAction() method, handle exceptions, flag the completion of the execution phase.

Specified by:
processAction in interface ActionListener
Parameters:
event - the associated JSF action event
Throws:
AbortProcessingException - if processing should be aborted

processSubAction

protected void processSubAction(ActionEvent event,
                                RequestContext context)
                         throws AbortProcessingException,
                                Exception
This is the default entry point for a sub-class of this ActionListener.
This BaseActionListener handles the JSF processAction method and invokes the processSubAction method of the sub-class.

Parameters:
event - the associated JSF action event
context - the context associated with the active request
Throws:
AbortProcessingException - if processing should be aborted
Exception - if an exception occurs

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.