org.apache.cocoon.webapps.portal.context
Class SessionContextImpl

java.lang.Object
  extended by org.apache.cocoon.webapps.portal.context.SessionContextImpl
All Implemented Interfaces:
Serializable, SessionContext

public final class SessionContextImpl
extends Object
implements SessionContext

The portal context This context allows access to various parts of a portal profile. The context provides reading of the following xml, if the current resource is running inside a portal module: <layout> <portal> ... </portal> <coplets> ... </coplets> </layout> <configuration> ... </configuration>

Version:
CVS $Id: SessionContextImpl.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Carsten Ziegeler
See Also:
Serialized Form

Field Summary
static ThreadLocal copletInfo
           
 
Constructor Summary
SessionContextImpl(String name, Map objectModel, PortalManager portal, XPathProcessor xpathProcessor)
           
 
Method Summary
 void appendXML(String path, DocumentFragment fragment)
          Append a document fragment at the given path.
 Object getAttribute(String key)
          Get a context attribute.
 Object getAttribute(String key, Object defaultObject)
          Get a context attribute.
 String getName()
          Get the name of the context
 NodeList getNodeList(String path)
          Get a copy all the nodes specified by the path.
 Request getRequest()
           
 Node getSingleNode(String path)
          Get a copy the first node specified by the path.
 String getValueOfNode(String path)
          Get the value of this node.
 DocumentFragment getXML(String path)
          Get the xml fragment
 void loadXML(String path, SourceParameters parameters)
          Try to load XML into the context.
 void removeXML(String path)
          Remove nodes
 void saveXML(String path, SourceParameters parameters)
          Try to save XML from the context.
 void setAttribute(String key, Object value)
          Set a context attribute.
 void setNode(String path, Node node)
          Set the value of a node.
 void setup(String value, String load, String save)
          Set the name of the context.
 void setValueOfNode(String path, String value)
          Set the value of a node.
 void setXML(String path, DocumentFragment fragment)
          Set the xml
 boolean streamXML(String path, ContentHandler contentHandler, LexicalHandler lexicalHandler)
          Stream the XML directly to the handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copletInfo

public static ThreadLocal copletInfo
Constructor Detail

SessionContextImpl

public SessionContextImpl(String name,
                          Map objectModel,
                          PortalManager portal,
                          XPathProcessor xpathProcessor)
                   throws IOException,
                          SAXException,
                          ProcessingException
Throws:
IOException
SAXException
ProcessingException
Method Detail

getName

public String getName()
Get the name of the context

Specified by:
getName in interface SessionContext

getRequest

public Request getRequest()

setup

public void setup(String value,
                  String load,
                  String save)
Description copied from interface: SessionContext
Set the name of the context. This method must be invoked in the init phase. In addition a load and a save resource can be provided.

Specified by:
setup in interface SessionContext

getXML

public DocumentFragment getXML(String path)
                        throws ProcessingException
Get the xml fragment

Specified by:
getXML in interface SessionContext
Throws:
ProcessingException

setXML

public void setXML(String path,
                   DocumentFragment fragment)
            throws ProcessingException
Set the xml

Specified by:
setXML in interface SessionContext
Throws:
ProcessingException

appendXML

public void appendXML(String path,
                      DocumentFragment fragment)
               throws ProcessingException
Append a document fragment at the given path. The implementation of this method is context specific. Usually the children of the fragment are appended as new children of the node specified by the path. If the path is not existent it is created.

Specified by:
appendXML in interface SessionContext
Throws:
ProcessingException

removeXML

public void removeXML(String path)
               throws ProcessingException
Remove nodes

Specified by:
removeXML in interface SessionContext
Throws:
ProcessingException

getSingleNode

public Node getSingleNode(String path)
                   throws ProcessingException
Get a copy the first node specified by the path.

Specified by:
getSingleNode in interface SessionContext
Throws:
ProcessingException

getNodeList

public NodeList getNodeList(String path)
                     throws ProcessingException
Get a copy all the nodes specified by the path.

Specified by:
getNodeList in interface SessionContext
Throws:
ProcessingException

setNode

public void setNode(String path,
                    Node node)
             throws ProcessingException
Set the value of a node. The node is copied before insertion.

Specified by:
setNode in interface SessionContext
Throws:
ProcessingException

setAttribute

public void setAttribute(String key,
                         Object value)
Set a context attribute. If value is null the attribute is removed.

Specified by:
setAttribute in interface SessionContext

getAttribute

public Object getAttribute(String key)
Get a context attribute. If the attribute is not available return null

Specified by:
getAttribute in interface SessionContext

getAttribute

public Object getAttribute(String key,
                           Object defaultObject)
Get a context attribute. If the attribute is not available the defaultObject is returned

Specified by:
getAttribute in interface SessionContext

getValueOfNode

public String getValueOfNode(String path)
                      throws ProcessingException
Get the value of this node. This is similiar to the xsl:value-of function. If the node does not exist, null is returned.

Specified by:
getValueOfNode in interface SessionContext
Throws:
ProcessingException

setValueOfNode

public void setValueOfNode(String path,
                           String value)
                    throws ProcessingException
Set the value of a node.

Specified by:
setValueOfNode in interface SessionContext
Throws:
ProcessingException

streamXML

public boolean streamXML(String path,
                         ContentHandler contentHandler,
                         LexicalHandler lexicalHandler)
                  throws SAXException,
                         ProcessingException
Stream the XML directly to the handler. This streams the contents of getXML() to the given handler without creating a DocumentFragment containing a copy of the data

Specified by:
streamXML in interface SessionContext
Throws:
SAXException
ProcessingException

loadXML

public void loadXML(String path,
                    SourceParameters parameters)
             throws SAXException,
                    ProcessingException,
                    IOException
Try to load XML into the context. If the context does not provide the ability of loading, an exception is thrown.

Specified by:
loadXML in interface SessionContext
Throws:
SAXException
ProcessingException
IOException

saveXML

public void saveXML(String path,
                    SourceParameters parameters)
             throws SAXException,
                    ProcessingException,
                    IOException
Try to save XML from the context. If the context does not provide the ability of saving, an exception is thrown.

Specified by:
saveXML in interface SessionContext
Throws:
SAXException
ProcessingException
IOException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.