com.gentics.api.portalnode.plugin
Class AbstractGenticsPlugin

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by com.gentics.api.portalnode.plugin.AbstractGenticsPlugin
All Implemented Interfaces:
Resolvable, EventBrokerProvider, EventHandler, GenticsPlugin, GenticsPluginServer, javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet
Direct Known Subclasses:
ViewPlugin

public abstract class AbstractGenticsPlugin
extends javax.portlet.GenericPortlet
implements GenticsPlugin, GenticsPluginServer, EventBrokerProvider

Abstract class that provides a default implementation of the most important plugin methods and should be used as base class for creating new plugins


Nested Class Summary
protected  class AbstractGenticsPlugin.SubPluginEventBrokerProvider
          Internal helper class to provide the event broker for nested plugins
 
Field Summary
protected  org.apache.log4j.Logger logger
          logger object
 
Constructor Summary
AbstractGenticsPlugin()
           
 
Method Summary
 void addEventListener(EventHandler handler, java.lang.String eventPath)
          Add the given event handler as listener for the given event path
 void afterProcessAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          This method is called by the portal after calling Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse) on this plugin.
 void afterProcessPluginAction(java.lang.String PluginID, javax.portlet.ActionRequest actionRequest, javax.portlet.ActionResponse actionResponse)
          process the afterProcessAction of the given plugin
 boolean canResolve()
          Check whether the resolvable is capable of resolving properties right now.
 java.lang.Object get(java.lang.String key)
          Get the property named by key or null if the property does not exist or is not set.
 java.util.Map getContainerRuntimeOptions()
           
 EventBroker getEventBroker()
          Returns the current event broker of this plugin
 FileUploadProvider getFileUploadProvider()
          Get an instance of a FileUploadProvider.
 java.lang.String getFullPluginName()
          Get the full plugin name (including the portletapplication prefix)
 GenticsPortletContext getGenticsPortletContext()
          Returns the specific GenticsPortletContext of this plugin
 java.lang.String getId()
          Get the plugin id
 GenticsImpInterface getImp(java.lang.String impId)
          Get an imp
 GenticsPortlet getModule()
          Get the module which registeres and uses this plugin
 java.lang.Object getParameter(java.lang.String parameter)
          Get a parameter of this plugin
 GenticsPlugin getPlugin(java.lang.String Id)
          returns a plugin from the server (if registered), or else null
 java.lang.Object getProperty(java.lang.String key)
          Get the property named by key or null if the property does not exist or is not set.
protected  java.lang.String getSessionPropertyName(java.lang.String propertyName)
          Get the session property name for the given property name (prefix it with the form name)
 TemplateProcessor getTemplateProcessor(javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          Get a template processor that can be used to render the plugin based on the given renderRequest and renderResponse.
 void handleEvent(ActionEvent e)
          Method to handle the given actionevent
 I18nString i18n(java.lang.String key)
          Get a localized string.
protected  void initSessionPropertyNames()
          Initialize the session property names
 void logdebug(java.lang.Object message)
          log fine-grained informational events that are most useful to debug an application.
 void logdebug(java.lang.Object message, java.lang.Throwable t)
          log fine-grained informational events that are most useful to debug an application.
 void logerror(java.lang.Object message)
          log error events that might still allow the application to continue running.
 void logError(java.lang.Object message, java.lang.Throwable t)
          log error events that might still allow the application to continue running.
 void logFatal(java.lang.Object message)
          log very severe error events that will presumably lead the application to abort.
 void logFatal(java.lang.Object message, java.lang.Throwable t)
          log very severe error events that will presumably lead the application to abort.
 void loginfo(java.lang.Object message)
          log informational messages that highlight the progress of the application at coarse-grained level.
 void loginfo(java.lang.Object message, java.lang.Throwable t)
          log informational messages that highlight the progress of the application at coarse-grained level.
 void logwarn(java.lang.Object message)
          log potentially harmful situations.
 void logwarn(java.lang.Object message, java.lang.Throwable t)
          log potentially harmful situations.
 void onPluginEvent(EventRequest eventRequest, EventResponse eventResponse)
          onPluginEvent will be called everytime a plugin triggers an event
 void processAction(javax.portlet.ActionRequest actionRequest, javax.portlet.ActionResponse actionResponse)
          Copied from Java Portlet API: Called by the portlet container to allow the portlet to process an action request.
 void processPluginAction(java.lang.String pluginID, javax.portlet.ActionRequest actionRequest, javax.portlet.ActionResponse actionResponse)
          processes a plugin action the pluginserver needs to distribute actions to its plugins
 void registerPlugin(java.lang.String Id, GenticsPlugin plugin)
          allows to register plugins to the server so he can further distribute events and forward actions as well as provide rendering facility
 java.lang.String renderPlugin(java.lang.String Id, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          renders a plugin specified by the pluginid it provides the plugin with a adapted request and response so it can only see its own variables
 void returnFileUploadProvider()
          Return the FileUploadProvider which was previously fetched with getFileUploadProvider() to its source (the context)
 void returnTemplateProcessor(TemplateProcessor proc)
          Return the template processor previously fetched via getTemplateProcessor(RenderRequest, RenderResponse).
 void setEventBrokerProvider(EventBrokerProvider eventBrokerProvider)
          Set the event broker provider
 void setId(java.lang.String ID)
          Set the id of the plugin.
 void setModule(GenticsPortlet module)
          Set the module which registeres and uses this plugin.
 void setParameter(java.lang.String parameter, java.lang.Object value)
          Sets a parameter of this plugin
 void setPluginName(java.lang.String applicationPrefix, java.lang.String pluginName)
          Set the plugin name
 java.lang.String toString()
           
protected  void triggerPluginEvent(ActionEvent e)
          Trigger a plugin event using the event broker
 void unregisterPlugin(java.lang.String id)
          Unregister the plugin with the given id.
 
Methods inherited from class javax.portlet.GenericPortlet
destroy, doDispatch, doEdit, doHeaders, doHelp, doView, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, init, processEvent, render, serveResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.portlet.Portlet
destroy, init, render
 
Methods inherited from interface javax.portlet.PortletConfig
getDefaultNamespace, getInitParameter, getInitParameterNames, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales
 

Field Detail

logger

protected org.apache.log4j.Logger logger
logger object

Constructor Detail

AbstractGenticsPlugin

public AbstractGenticsPlugin()
Method Detail

initSessionPropertyNames

protected void initSessionPropertyNames()
Initialize the session property names


getSessionPropertyName

protected java.lang.String getSessionPropertyName(java.lang.String propertyName)
Get the session property name for the given property name (prefix it with the form name)

Parameters:
propertyName - property name
Returns:
prefixed property name

canResolve

public boolean canResolve()
Description copied from interface: Resolvable
Check whether the resolvable is capable of resolving properties right now.
if this method returns false all calls to Resolvable.getProperty(String) or Resolvable.get(String) will return null.

Specified by:
canResolve in interface Resolvable
Returns:
true when the resolvable can resolve properties. false if not

getProperty

public java.lang.Object getProperty(java.lang.String key)
Description copied from interface: Resolvable
Get the property named by key or null if the property does not exist or is not set. Alias for Resolvable.get(String).

Specified by:
getProperty in interface Resolvable
Parameters:
key - key of the property
Returns:
value of the property or null

get

public java.lang.Object get(java.lang.String key)
Description copied from interface: Resolvable
Get the property named by key or null if the property does not exist or is not set.

Specified by:
get in interface Resolvable
Parameters:
key - key of the property
Returns:
value of the property or null

handleEvent

public void handleEvent(ActionEvent e)
Description copied from interface: EventHandler
Method to handle the given actionevent

Specified by:
handleEvent in interface EventHandler
Parameters:
e - event to be handled

addEventListener

public void addEventListener(EventHandler handler,
                             java.lang.String eventPath)
Add the given event handler as listener for the given event path

Parameters:
handler - event handler
eventPath - event path the handler is listening

getEventBroker

public EventBroker getEventBroker()
Returns the current event broker of this plugin

Specified by:
getEventBroker in interface EventBrokerProvider
Specified by:
getEventBroker in interface GenticsPlugin
Returns:
event broker

setEventBrokerProvider

public void setEventBrokerProvider(EventBrokerProvider eventBrokerProvider)
Description copied from interface: GenticsPlugin
Set the event broker provider

Specified by:
setEventBrokerProvider in interface GenticsPlugin

setParameter

public void setParameter(java.lang.String parameter,
                         java.lang.Object value)
Sets a parameter of this plugin

Parameters:
parameter - name of the parameter
value - parameter value

getParameter

public java.lang.Object getParameter(java.lang.String parameter)
Get a parameter of this plugin

Parameters:
parameter - name of the parameter
Returns:
the parameter value (null if the parameter is not set)

processAction

public void processAction(javax.portlet.ActionRequest actionRequest,
                          javax.portlet.ActionResponse actionResponse)
                   throws javax.portlet.PortletException,
                          java.io.IOException
Copied from Java Portlet API: Called by the portlet container to allow the portlet to process an action request. This method is called if the client request was originated by a URL created (by the portlet) with the RenderResponse.createActionURL() method.

This default implementation triggers an event if the parameter 'action' was set in the ActionRequest. - E.g. if parameter was 'myEvent' it will trigger the plugin event 'onMyEvent'.

Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
java.io.IOException
See Also:
Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)

afterProcessAction

public void afterProcessAction(javax.portlet.ActionRequest request,
                               javax.portlet.ActionResponse response)
Description copied from interface: GenticsPlugin
This method is called by the portal after calling Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse) on this plugin. The plugin implementation of this method may do some cleanup after processing the action.

Specified by:
afterProcessAction in interface GenticsPlugin
Parameters:
request - action request
response - action response

triggerPluginEvent

protected void triggerPluginEvent(ActionEvent e)
Trigger a plugin event using the event broker

Parameters:
e - the event to be triggered

processPluginAction

public void processPluginAction(java.lang.String pluginID,
                                javax.portlet.ActionRequest actionRequest,
                                javax.portlet.ActionResponse actionResponse)
                         throws javax.portlet.PortletException,
                                java.io.IOException
Description copied from interface: GenticsPluginServer
processes a plugin action the pluginserver needs to distribute actions to its plugins

Specified by:
processPluginAction in interface GenticsPluginServer
Parameters:
pluginID - pluginid
actionRequest - request
actionResponse - response
Throws:
javax.portlet.PortletException - any processing problem
java.io.IOException - any i/o problem

afterProcessPluginAction

public void afterProcessPluginAction(java.lang.String PluginID,
                                     javax.portlet.ActionRequest actionRequest,
                                     javax.portlet.ActionResponse actionResponse)
                              throws javax.portlet.PortletException,
                                     java.io.IOException
Description copied from interface: GenticsPluginServer
process the afterProcessAction of the given plugin

Specified by:
afterProcessPluginAction in interface GenticsPluginServer
Parameters:
PluginID - pluginid
actionRequest - request
actionResponse - response
Throws:
javax.portlet.PortletException
java.io.IOException

registerPlugin

public void registerPlugin(java.lang.String Id,
                           GenticsPlugin plugin)
Description copied from interface: GenticsPluginServer
allows to register plugins to the server so he can further distribute events and forward actions as well as provide rendering facility

Specified by:
registerPlugin in interface GenticsPluginServer
Parameters:
Id - the pluginid
plugin - the plugin

unregisterPlugin

public void unregisterPlugin(java.lang.String id)
Description copied from interface: GenticsPluginServer
Unregister the plugin with the given id.

Specified by:
unregisterPlugin in interface GenticsPluginServer
Parameters:
id - id of the plugin to unregister

onPluginEvent

public void onPluginEvent(EventRequest eventRequest,
                          EventResponse eventResponse)
Description copied from interface: GenticsPluginServer
onPluginEvent will be called everytime a plugin triggers an event

Specified by:
onPluginEvent in interface GenticsPluginServer
Parameters:
eventRequest - the event request
eventResponse - the event response

getPlugin

public GenticsPlugin getPlugin(java.lang.String Id)
Description copied from interface: GenticsPluginServer
returns a plugin from the server (if registered), or else null

Specified by:
getPlugin in interface GenticsPluginServer
Parameters:
Id - pluginid
Returns:
found plugin or null

renderPlugin

public java.lang.String renderPlugin(java.lang.String Id,
                                     javax.portlet.RenderRequest request,
                                     javax.portlet.RenderResponse response)
                              throws javax.portlet.PortletException,
                                     java.io.IOException
Description copied from interface: GenticsPluginServer
renders a plugin specified by the pluginid it provides the plugin with a adapted request and response so it can only see its own variables

Specified by:
renderPlugin in interface GenticsPluginServer
Parameters:
Id - plugin id
request - the request of the module calling
response - the response of the calling module
Returns:
the snippet generated by the plugin
Throws:
javax.portlet.PortletException - an exception if anything in terms of processing goes wrong
java.io.IOException - any i/o problems

setId

public void setId(java.lang.String ID)
Description copied from interface: GenticsPlugin
Set the id of the plugin.

Specified by:
setId in interface GenticsPlugin
Parameters:
ID - id of the plugin

getImp

public GenticsImpInterface getImp(java.lang.String impId)
Get an imp

Parameters:
impId - id of the imp
Returns:
the imp or null if no imp defined for the given impId

getId

public java.lang.String getId()
Get the plugin id

Returns:
plugin id

getGenticsPortletContext

public GenticsPortletContext getGenticsPortletContext()
Returns the specific GenticsPortletContext of this plugin

Returns:
GenticsPortletContext

getFileUploadProvider

public FileUploadProvider getFileUploadProvider()
Get an instance of a FileUploadProvider. Multiple calls to this method will return the same instance. When a FileUploadProvider was fetched using this method, it should be returned after usage using the method returnFileUploadProvider().

Specified by:
getFileUploadProvider in interface GenticsPlugin
Returns:
an instance of FileUploadProvider

returnFileUploadProvider

public void returnFileUploadProvider()
Return the FileUploadProvider which was previously fetched with getFileUploadProvider() to its source (the context)

Specified by:
returnFileUploadProvider in interface GenticsPlugin

setModule

public void setModule(GenticsPortlet module)
Description copied from interface: GenticsPlugin
Set the module which registeres and uses this plugin. This is typically done when the plugin is registered with the module via AbstractGenticsPortlet.registerPlugin(String, GenticsPlugin) and need not be called from outside.

Specified by:
setModule in interface GenticsPlugin
Parameters:
module - module using this plugin

getModule

public GenticsPortlet getModule()
Description copied from interface: GenticsPlugin
Get the module which registeres and uses this plugin

Specified by:
getModule in interface GenticsPlugin
Returns:
module using this plugin

getTemplateProcessor

public TemplateProcessor getTemplateProcessor(javax.portlet.RenderRequest renderRequest,
                                              javax.portlet.RenderResponse renderResponse)
Get a template processor that can be used to render the plugin based on the given renderRequest and renderResponse. The instance of the template processor must be returned via returnTemplateProcessor(TemplateProcessor) after usage.

Parameters:
renderRequest - render request
renderResponse - render response
Returns:
a template processor

returnTemplateProcessor

public void returnTemplateProcessor(TemplateProcessor proc)
Return the template processor previously fetched via getTemplateProcessor(RenderRequest, RenderResponse).

Parameters:
proc - template processor

logFatal

public void logFatal(java.lang.Object message,
                     java.lang.Throwable t)
log very severe error events that will presumably lead the application to abort.

Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

logFatal

public void logFatal(java.lang.Object message)
log very severe error events that will presumably lead the application to abort.

Parameters:
message - the message object to log.

logError

public void logError(java.lang.Object message,
                     java.lang.Throwable t)
log error events that might still allow the application to continue running.

Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

logerror

public void logerror(java.lang.Object message)
log error events that might still allow the application to continue running.

Parameters:
message - the message object to log.

logwarn

public void logwarn(java.lang.Object message,
                    java.lang.Throwable t)
log potentially harmful situations.

Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

logwarn

public void logwarn(java.lang.Object message)
log potentially harmful situations.

Parameters:
message - the message object to log.

loginfo

public void loginfo(java.lang.Object message,
                    java.lang.Throwable t)
log informational messages that highlight the progress of the application at coarse-grained level.

Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

loginfo

public void loginfo(java.lang.Object message)
log informational messages that highlight the progress of the application at coarse-grained level.

Parameters:
message - the message object to log.

logdebug

public void logdebug(java.lang.Object message,
                     java.lang.Throwable t)
log fine-grained informational events that are most useful to debug an application.

Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

logdebug

public void logdebug(java.lang.Object message)
log fine-grained informational events that are most useful to debug an application.

Parameters:
message - the message object to log.

i18n

public I18nString i18n(java.lang.String key)
Get a localized string.

Parameters:
key - the key of the i18n item. the syntax is [a-z0-9.]+, and will generate a warning if violated.
Returns:
the localized string object.

getFullPluginName

public java.lang.String getFullPluginName()
Description copied from interface: GenticsPlugin
Get the full plugin name (including the portletapplication prefix)

Specified by:
getFullPluginName in interface GenticsPlugin
Returns:
full plugin name

setPluginName

public void setPluginName(java.lang.String applicationPrefix,
                          java.lang.String pluginName)
Description copied from interface: GenticsPlugin
Set the plugin name

Specified by:
setPluginName in interface GenticsPlugin
Parameters:
applicationPrefix - application prefix
pluginName - plugin name

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getContainerRuntimeOptions

public java.util.Map getContainerRuntimeOptions()
Specified by:
getContainerRuntimeOptions in interface javax.portlet.PortletConfig
Overrides:
getContainerRuntimeOptions in class javax.portlet.GenericPortlet


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.