org.apache.cocoon.transformation
Class RoleFilterTransformer

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.xml.AbstractXMLPipe
              extended byorg.apache.cocoon.transformation.AbstractTransformer
                  extended byorg.apache.cocoon.transformation.RoleFilterTransformer
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, ContentHandler, LexicalHandler, Poolable, Recyclable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, XMLConsumer, org.apache.cocoon.xml.XMLConsumer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer

public class RoleFilterTransformer
extends org.apache.cocoon.transformation.AbstractTransformer
implements org.apache.cocoon.caching.CacheableProcessingComponent

Filter XML fragments based on a user's role. This will help in the development of smart forms that must only show information to people who are logged in and have the correct role. The Role is specified by the Request semantics. You can specify multiple roles by using comma delimiting.

   <root xmlns:roles="http://apache.org/cocoon/role-filter/1.0">
     <textbox name="identifier" roles:restricted="admin,boss"/>
     <textbox name="name" roles:read-only="admin,boss"/>
   </root>
 
The previous example will only show the "identifier" textbox for the roles "admin" and "boss". It will pass role:read-only="" if the roles "admin" or "boss" are accessing the page. That way you can specify any special processing by testing for the read-only attribute. This filter does not care about the prefix, only the namespace URI. That means you can reassign the namespace to another prefix and all will work as expected.

Version:
$Id: RoleFilterTransformer.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
RoleFilterTransformer()
           
 
Method Summary
 void characters(char[] c, int start, int len)
           
 void comment(char[] ch, int start, int len)
           
 void endCDATA()
           
 void endElement(String uri, String loc, String raw)
           
 void endEntity(String name)
           
 Serializable getKey()
          Disable caching
 SourceValidity getValidity()
           
 void processingInstruction(String target, String data)
           
 void recycle()
           
 void setup(org.apache.cocoon.environment.SourceResolver resolver, Map objectModel, String src, Parameters params)
           
 void startCDATA()
           
 void startElement(String uri, String loc, String raw, Attributes a)
           
 void startEntity(String name)
           
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
endDocument, endDTD, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startDocument, startDTD, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
endDTD, startDTD
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Constructor Detail

RoleFilterTransformer

public RoleFilterTransformer()
Method Detail

setup

public final void setup(org.apache.cocoon.environment.SourceResolver resolver,
                        Map objectModel,
                        String src,
                        Parameters params)
                 throws org.apache.cocoon.ProcessingException,
                        SAXException,
                        IOException
Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
Throws:
org.apache.cocoon.ProcessingException
SAXException
IOException

getKey

public Serializable getKey()
Disable caching

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent

startElement

public final void startElement(String uri,
                               String loc,
                               String raw,
                               Attributes a)
                        throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public final void endElement(String uri,
                             String loc,
                             String raw)
                      throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

recycle

public void recycle()
Specified by:
recycle in interface Recyclable

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int len)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

characters

public void characters(char[] c,
                       int start,
                       int len)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

getValidity

public SourceValidity getValidity()
Specified by:
getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.