com.gentics.api.portalnode.portlet
Class GenticsPortletContext

java.lang.Object
  extended by com.gentics.api.portalnode.portlet.GenticsPortletContext
All Implemented Interfaces:
Resolvable, javax.portlet.PortletContext

public class GenticsPortletContext
extends Object
implements javax.portlet.PortletContext, Resolvable

Implementation of the PortletContext. Adds specific functionality that Gentics portlets can use.


Field Summary
protected  javax.servlet.ServletContext servletContext
          servlet context this portlet context builds on
 
Constructor Summary
protected GenticsPortletContext(String moduleId, String moduleType, javax.servlet.ServletContext servletContext)
          Create an instance of the GenticsPortletContext.
 
Method Summary
 boolean canResolve()
          Check whether the resolvable is capable of resolving properties right now.
 javax.portlet.PortletURL createActionURL()
          Deprecated. actionURLs must be created using the RenderResponse (according to portlet specification 1.0 JSR 168). actionURLs created with this method will not hold to correct/total information
 GenticsPlugin createPlugin(String pluginType, String parameterPrefix, javax.portlet.PortletConfig portletConfig)
          create and initialize an instance of a plugin (defined by its pluginType)
 RuleTree createPortalRuleTree()
           
 javax.portlet.PortletURL createRenderURL()
          Deprecated. renderURLs must be created using the RenderResponse (according to portlet specification 1.0 JSR 168). renderURLs created with this method will not hold to correct/total information
 Object get(String key)
          Get the property named by key or null if the property does not exist or is not set.
 String getAbsoluteServerURL()
          Get the absolute URL to the portal server
 Object getAttribute(String s)
           
 Enumeration getAttributeNames()
           
 com.gentics.portalnode.auth.AuthenticationSystem getAuthenticationSystem()
          returns the AuthenticationSystem used for this portal Instance.
 Collection getAvailableDatasources()
          Get a collection of the ids of all available datasources
 Collection getAvailableDatasources(Class datasourceClass)
          Get a collection of the ids of all available datasources (of the specified type)
 Collection getAvailableImps()
          get a collection of available imps (their ids)
 boolean getBooleanModuleParameter(String name)
           
 Enumeration getContainerRuntimeOptions()
           
 Datasource getDatasource()
          returns default datasource which is the first found datasource of a specific type.
 Datasource getDatasource(String id)
           
 EventBroker getEventBroker()
          Get the event broker.
 FileUploadProvider getFileUploadProvider()
           
 com.gentics.portalnode.formatter.FormatterManager getFormatterManager()
           
 GenticsImpInterface getImp(Class impClass)
          Get the (first available) imp of the given class.
 GenticsImpInterface getImp(String impId)
          get the imp with given id from its dungeon.
 String getInitParameter(String s)
           
 Enumeration getInitParameterNames()
           
 int getIntegerModuleParameter(String name)
           
 Language getLanguage()
          get the current portal language
 List getListOfObjectsModuleParameter(String name)
           
 int getMajorVersion()
           
 String getMimeType(String s)
           
 int getMinorVersion()
           
 String getModuleId()
          get the module id
 com.gentics.portalnode.module.ModuleParameter getModuleParameter(String key)
          Return a module parameter - for a convenient way to retrieve the value as string see getStringModuleParameter(String)
 Map getModuleParameterMap()
           
 Iterator getModuleParameterNames()
          Deprecated. this method will be removed in the future
 javax.portlet.PortletRequestDispatcher getNamedDispatcher(String s)
           
 Node getNodeModuleParameter(String name)
          get a module parameter of type node
 String getPLink(String contentId)
          get a plink to the content with given contentid
 String getPNodeCode()
           
 Object getPortalParameter(String parameterKey)
          Helper method to access portal parameters
 Properties getPortalProperties()
          Returns all Configuration Properties from the Portal
 PropertySetter getPortalPropertySetter()
          get a property setter for setting portal properties
 PropertyResolver getPortalResolver()
           
 String getPortletContextName()
           
 Object getProperty(String key)
          Get the property named by key or null if the property does not exist or is not set.
 HashMap getPropertyNames()
           
 String getRealPath(String s)
           
 javax.portlet.PortletRequestDispatcher getRequestDispatcher(String s)
           
 URL getResource(String s)
           
 InputStream getResourceAsStream(String s)
           
 Set getResourcePaths(String s)
           
 Rule getRuleModuleParameter(String name)
           
 org.quartz.Scheduler getScheduler()
          get the scheduler for timed jobs
 String getServerInfo()
           
 String getStringModuleParameter(String name)
          Returns a module parameter (= pnode parameter) as string if available (null otherwise).
 TemplateProcessor getTemplateProcessor(GenticsPortlet portlet, javax.portlet.PortletConfig portletConfig)
          Get an instance of a template processor.
 TemplateProcessor getTemplateProcessor(GenticsPortlet module, javax.portlet.PortletConfig portletConfig, javax.portlet.RenderRequest renderRequest, javax.portlet.RenderResponse renderResponse)
          Deprecated. use getTemplateProcessor(GenticsPortlet, PortletConfig) instead.
 GenticsUser getUser()
           
 I18nString i18n(String key)
          get a localized string.
 I18nString i18n(String key, String languageId)
          get a localized string in the given language
 void log(String s)
           
 void log(String s, Throwable throwable)
           
 void overwritePNode(String overWriteString, GenticsPortlet module)
           
 void removeAttribute(String s)
           
 Object resolvePortalProperty(String propertyPath)
          resolve a property from the GenticsPortletContext via a path provided
 void returnFileUploadProvider(FileUploadProvider fileUploadProvider)
           
 void returnImp(GenticsImpInterface imp)
          release the captured imp to its dungeon
 void returnTemplateProcessor(TemplateProcessor templateProcessor)
          return the template processor
 void setAttribute(String s, Object o)
           
 void setLanguage(String language)
           
 void setModuleParameter(String name, Object value)
           
 void setPortalProperty(String propertyPath, Object value)
          sets the portal property identified via propertyPath to a certain value provided
 void setRenderParameters(Map parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletContext

protected javax.servlet.ServletContext servletContext
servlet context this portlet context builds on

Constructor Detail

GenticsPortletContext

protected GenticsPortletContext(String moduleId,
                                String moduleType,
                                javax.servlet.ServletContext servletContext)
Create an instance of the GenticsPortletContext. This constructor is protected since instances of the GenticsPortletContext are always generated within the portal.

Parameters:
moduleId - id of the module
moduleType - type of the module
servletContext - underlying servlet context
Method Detail

getEventBroker

public EventBroker getEventBroker()
Get the event broker. The event broker can be used to register event listeners or to trigger events.

Returns:
instance of the event broker

getServerInfo

public String getServerInfo()
Specified by:
getServerInfo in interface javax.portlet.PortletContext

getRequestDispatcher

public javax.portlet.PortletRequestDispatcher getRequestDispatcher(String s)
Specified by:
getRequestDispatcher in interface javax.portlet.PortletContext

getNamedDispatcher

public javax.portlet.PortletRequestDispatcher getNamedDispatcher(String s)
Specified by:
getNamedDispatcher in interface javax.portlet.PortletContext

getResourceAsStream

public InputStream getResourceAsStream(String s)
Specified by:
getResourceAsStream in interface javax.portlet.PortletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface javax.portlet.PortletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface javax.portlet.PortletContext

getMimeType

public String getMimeType(String s)
Specified by:
getMimeType in interface javax.portlet.PortletContext

getRealPath

public String getRealPath(String s)
Specified by:
getRealPath in interface javax.portlet.PortletContext

getResourcePaths

public Set getResourcePaths(String s)
Specified by:
getResourcePaths in interface javax.portlet.PortletContext

getResource

public URL getResource(String s)
                throws MalformedURLException
Specified by:
getResource in interface javax.portlet.PortletContext
Throws:
MalformedURLException

getAttribute

public Object getAttribute(String s)
Specified by:
getAttribute in interface javax.portlet.PortletContext

getAttributeNames

public Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.portlet.PortletContext

getInitParameter

public String getInitParameter(String s)
Specified by:
getInitParameter in interface javax.portlet.PortletContext

getInitParameterNames

public Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.portlet.PortletContext

log

public void log(String s)
Specified by:
log in interface javax.portlet.PortletContext

log

public void log(String s,
                Throwable throwable)
Specified by:
log in interface javax.portlet.PortletContext

removeAttribute

public void removeAttribute(String s)
Specified by:
removeAttribute in interface javax.portlet.PortletContext

setAttribute

public void setAttribute(String s,
                         Object o)
Specified by:
setAttribute in interface javax.portlet.PortletContext

getPortletContextName

public String getPortletContextName()
Specified by:
getPortletContextName in interface javax.portlet.PortletContext

getModuleId

public String getModuleId()
get the module id

Returns:
module id

setRenderParameters

public void setRenderParameters(Map parameters)
Parameters:
parameters -

getModuleParameter

public com.gentics.portalnode.module.ModuleParameter getModuleParameter(String key)
Return a module parameter - for a convenient way to retrieve the value as string see getStringModuleParameter(String)


getModuleParameterMap

public Map getModuleParameterMap()

getModuleParameterNames

public Iterator getModuleParameterNames()
Deprecated. this method will be removed in the future

Returns:
this method always returns null

getListOfObjectsModuleParameter

public List getListOfObjectsModuleParameter(String name)

getStringModuleParameter

public String getStringModuleParameter(String name)
Returns a module parameter (= pnode parameter) as string if available (null otherwise).


getRuleModuleParameter

public Rule getRuleModuleParameter(String name)

getBooleanModuleParameter

public boolean getBooleanModuleParameter(String name)

getIntegerModuleParameter

public int getIntegerModuleParameter(String name)

getNodeModuleParameter

public Node getNodeModuleParameter(String name)
get a module parameter of type node

Parameters:
name - name of the module parameter
Returns:
Node containing the xml structure or null

setModuleParameter

public void setModuleParameter(String name,
                               Object value)

getUser

public GenticsUser getUser()

createPortalRuleTree

public RuleTree createPortalRuleTree()

resolvePortalProperty

public Object resolvePortalProperty(String propertyPath)
                             throws UnknownPropertyException
resolve a property from the GenticsPortletContext via a path provided

Parameters:
propertyPath - to identify the property
Returns:
the propertie's value
Throws:
UnknownPropertyException - if the property path leads straight to nowhere

getPortalPropertySetter

public PropertySetter getPortalPropertySetter()
get a property setter for setting portal properties

Returns:
property setter for the portal

setPortalProperty

public void setPortalProperty(String propertyPath,
                              Object value)
                       throws InsufficientPrivilegesException,
                              UnknownPropertyException
sets the portal property identified via propertyPath to a certain value provided

Parameters:
propertyPath - to identify the portal property
value - to be set
Throws:
InsufficientPrivilegesException - if property may not be set due to privilege restrictions
UnknownPropertyException - if the property is not known

getDatasource

public Datasource getDatasource(String id)

getDatasource

public Datasource getDatasource()
returns default datasource which is the first found datasource of a specific type. this type must be specified in the module-configuration (module.xml)

Returns:

getAvailableDatasources

public Collection getAvailableDatasources()
Get a collection of the ids of all available datasources

Returns:
collection of datasource ids

getAvailableDatasources

public Collection getAvailableDatasources(Class datasourceClass)
Get a collection of the ids of all available datasources (of the specified type)

Parameters:
datasourceClass - class/interface the datasource implementation must implenent/extend or null for all datasources
Returns:
collection of datasource ids

createActionURL

public javax.portlet.PortletURL createActionURL()
Deprecated. actionURLs must be created using the RenderResponse (according to portlet specification 1.0 JSR 168). actionURLs created with this method will not hold to correct/total information

create an action url. DO NOT USE THIS METHOD!

Returns:
action url

createRenderURL

public javax.portlet.PortletURL createRenderURL()
Deprecated. renderURLs must be created using the RenderResponse (according to portlet specification 1.0 JSR 168). renderURLs created with this method will not hold to correct/total information

create a render url. DO NOT USE THIS METHOD!

Returns:
render url

getPropertyNames

public HashMap getPropertyNames()

getProperty

public Object getProperty(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 Object get(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

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

getPortalResolver

public PropertyResolver getPortalResolver()

createPlugin

public GenticsPlugin createPlugin(String pluginType,
                                  String parameterPrefix,
                                  javax.portlet.PortletConfig portletConfig)
create and initialize an instance of a plugin (defined by its pluginType)

Parameters:
pluginType - type of the plugin
parameterPrefix - prefix of the module parameters which configure the plugin
portletConfig - portlet config from the module of this context
Returns:
the created instance or null

getPNodeCode

public String getPNodeCode()

overwritePNode

public void overwritePNode(String overWriteString,
                           GenticsPortlet module)
                    throws SAXException
Throws:
SAXException

returnFileUploadProvider

public void returnFileUploadProvider(FileUploadProvider fileUploadProvider)
Parameters:
fileUploadProvider -

getFileUploadProvider

public FileUploadProvider getFileUploadProvider()
Returns:

getTemplateProcessor

public TemplateProcessor getTemplateProcessor(GenticsPortlet portlet,
                                              javax.portlet.PortletConfig portletConfig)
Get an instance of a template processor. The returned instance may only be used in the render phase of the portlet during the current request and must be returned via returnTemplateProcessor(TemplateProcessor) after usage.

Parameters:
portlet - portlet instance
portletConfig - portlet configuration
Returns:
an instance of the template processor

getTemplateProcessor

public TemplateProcessor getTemplateProcessor(GenticsPortlet module,
                                              javax.portlet.PortletConfig portletConfig,
                                              javax.portlet.RenderRequest renderRequest,
                                              javax.portlet.RenderResponse renderResponse)
Deprecated. use getTemplateProcessor(GenticsPortlet, PortletConfig) instead.

Get an instance of a template processor

Parameters:
module - module
portletConfig - portlet configuration
renderRequest - render request
renderResponse - render response
Returns:
an instance of the template processor

returnTemplateProcessor

public void returnTemplateProcessor(TemplateProcessor templateProcessor)
return the template processor

Parameters:
templateProcessor - template process that is not longer used

getPortalProperties

public final Properties getPortalProperties()
Returns all Configuration Properties from the Portal

Returns:
Portal Properties

getFormatterManager

public com.gentics.portalnode.formatter.FormatterManager getFormatterManager()

getImp

public GenticsImpInterface getImp(String impId)
get the imp with given id from its dungeon. the imp must be returned with returnImp(GenticsImpInterface)after usage

Parameters:
impId - id of the imp to get
Returns:
the imp, or null if no such imp exists

getImp

public GenticsImpInterface getImp(Class impClass)
Get the (first available) imp of the given class. The imp must be returned with returnImp(GenticsImpInterface) after usage.

Parameters:
impClass - class of the imp
Returns:
the imp, or null if no such imp exists

returnImp

public void returnImp(GenticsImpInterface imp)
release the captured imp to its dungeon

Parameters:
imp - imp happily returning to its dungeon

setLanguage

public void setLanguage(String language)

i18n

public I18nString i18n(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.

i18n

public I18nString i18n(String key,
                       String languageId)
get a localized string in the given language

Parameters:
key - the key of the i18n item.
languageId - language id
Returns:
the localized string object.

getAvailableImps

public Collection getAvailableImps()
get a collection of available imps (their ids)

Returns:
collection of imp ids

getLanguage

public Language getLanguage()
get the current portal language

Returns:
current portal language

getPLink

public String getPLink(String contentId)
get a plink to the content with given contentid

Parameters:
contentId - id of the content to link to
Returns:
plink to the given content

getScheduler

public org.quartz.Scheduler getScheduler()
get the scheduler for timed jobs

Returns:
scheduler

getAuthenticationSystem

public com.gentics.portalnode.auth.AuthenticationSystem getAuthenticationSystem()
returns the AuthenticationSystem used for this portal Instance.

Returns:

getAbsoluteServerURL

public String getAbsoluteServerURL()
Get the absolute URL to the portal server

Returns:
absolute server url

getPortalParameter

public Object getPortalParameter(String parameterKey)
Helper method to access portal parameters

Parameters:
parameterKey - key of the portal parameter
Returns:
value of the parameter or null if not set

getContainerRuntimeOptions

public Enumeration getContainerRuntimeOptions()
Specified by:
getContainerRuntimeOptions in interface javax.portlet.PortletContext


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.