com.arsdigita.cms.installer.xml
Class XMLContentItemHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.arsdigita.cms.installer.xml.XMLContentItemHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XMLContentItemHandler
extends org.xml.sax.helpers.DefaultHandler

Parses and XML file definition of content items in a folder. the XML configuration should look like this:

 <ccm:content-items> <!-- The Document Node -->
      <ccm:folder clone="1"
                     depth="3"
                     label="testFolder" >
          <!-- Folders can be nested to any level. clone, depth and label are
               all required properties. Clone and depth minimum values are 1
               which result in no action. The entire nested subtree is cloned
               and replicated to the specified depth -->
          <ccm:content-item
                          clone="2"
                          helperClass="com.arsdigita.cms.installer.xml.TextPageHelper">
              <!-- ContentItems can be cloned but cannot have a depth. The
                   helperClass is used to create the object described here -->
              <ccm:content-type
                      classname="com.arsdigita.cms.contenttypes.Article"
                      objectType="com.arsdigita.cms.contenttypes.Article"/>
              <ccm:item-properties title="ArticleItem" language="en" >
                  <!-- Item properties are set here. A few tags may be supported
                       example,Body-text, but the set tags are usually used to
                       to call appropriate methods through the helper class on
                       the ContentItem. language is an optional attribute and
                       defaults to en. -->
                  <ccm:body-text>
                      Optional Body Text
                  </ccm:body-text>
                  <ccm:item-property method="setSpecies"
                                     argClass="java.lang.String"
                                     argValue="TestSpecies"/>

                  <ccm:item-property method="setWingspan"
                                     argClass="java.lang.Double"
                                     argValue="10.0"/>
              </ccm:item-properties>

              <ccm:content-item
                                helperClass="com.arsdigita.cms.installer.xml.ContentBundleHelper"
                                association-name="birdWatch" >
                  <!-- Nested ContentItems (nested within another content-item)
                       are created and associated with the encapsulating item.
                       These are defined as regular content-items, except for a
                       few notable differences:
                       1) They must have an association-name tag that is the
                       name of the encapsulating item's association.
                       2) They do not have a clone field, they are cloned as
                       often as the encapsulating item.

                       Content-items can be nested any number of times -->
              </ccm:content-item>

          </ccm:content-item>
    </ccm:folder>
 </ccm:content-items>
 


Field Summary
static String ASSOCIATED_ITEM
           
static String BODY_TEXT
           
static String CONTENT_ITEM
           
static String CONTENT_ITEMS
           
static String CONTENT_TYPE
           
static String FOLDER
           
static String ITEM_PROPERTIES
           
static String ITEM_PROPERTY
           
 
Constructor Summary
XMLContentItemHandler(ContentSection section)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
protected  void cloneFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree toClone, Folder toAttachTo, Folder parent, int cloneTime, boolean firstTime, boolean mainline, boolean clone, int depthTime)
          This recursive method traverses the FolderTree toClone from top to bottom, expanding out nodes to clone, replicating nodes to their specified depth, and then expanding out these new trees as well.
 void endElement(String uri, String name, String qName)
           
protected  void expandFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree toClone, Folder toAttachTo)
          This convenience method calls cloneFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree, com.arsdigita.cms.Folder, com.arsdigita.cms.Folder, int, boolean, boolean, boolean, int) with the parameters required to expand the FolderTree toClone with the parent folder toAttachTo.
 ContentType getContentType(String typeName)
           
 void startElement(String uri, String name, String qName, org.xml.sax.Attributes atts)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_ITEMS

public static final String CONTENT_ITEMS
See Also:
Constant Field Values

CONTENT_ITEM

public static final String CONTENT_ITEM
See Also:
Constant Field Values

ASSOCIATED_ITEM

public static final String ASSOCIATED_ITEM
See Also:
Constant Field Values

CONTENT_TYPE

public static final String CONTENT_TYPE
See Also:
Constant Field Values

ITEM_PROPERTIES

public static final String ITEM_PROPERTIES
See Also:
Constant Field Values

ITEM_PROPERTY

public static final String ITEM_PROPERTY
See Also:
Constant Field Values

FOLDER

public static final String FOLDER
See Also:
Constant Field Values

BODY_TEXT

public static final String BODY_TEXT
See Also:
Constant Field Values
Constructor Detail

XMLContentItemHandler

public XMLContentItemHandler(ContentSection section)
Parameters:
section - the ContentSection where the items will be created
Method Detail

startElement

public void startElement(String uri,
                         String name,
                         String qName,
                         org.xml.sax.Attributes atts)

characters

public void characters(char[] ch,
                       int start,
                       int length)

endElement

public void endElement(String uri,
                       String name,
                       String qName)

getContentType

public ContentType getContentType(String typeName)
                           throws com.arsdigita.util.UncheckedWrapperException
Throws:
com.arsdigita.util.UncheckedWrapperException

expandFolderTree

protected void expandFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree toClone,
                                Folder toAttachTo)
This convenience method calls cloneFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree, com.arsdigita.cms.Folder, com.arsdigita.cms.Folder, int, boolean, boolean, boolean, int) with the parameters required to expand the FolderTree toClone with the parent folder toAttachTo.

See Also:
cloneFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree, com.arsdigita.cms.Folder, com.arsdigita.cms.Folder, int, boolean, boolean, boolean, int)

cloneFolderTree

protected void cloneFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree toClone,
                               Folder toAttachTo,
                               Folder parent,
                               int cloneTime,
                               boolean firstTime,
                               boolean mainline,
                               boolean clone,
                               int depthTime)
This recursive method traverses the FolderTree toClone from top to bottom, expanding out nodes to clone, replicating nodes to their specified depth, and then expanding out these new trees as well. This is a fairly complicated method for a number of reasons, you should never need to call it directly, use expandFolderTree(com.arsdigita.cms.installer.xml.XMLContentItemHandler.FolderTree, com.arsdigita.cms.Folder)

Parameters:
toClone - The FolderTree to clone and expand
toAttachTo - The Folder to attach the result of the expansion to
parent - The parent of the node to attach to
cloneTime - The clone number for this particular folder
firstTime - If this is the first time the method is being called . ie. not a recursive call. If so it will not attempt to clone toClone's root folder.
mainline - If the parent node is no the mainlin, ie. the orignal folder tree and not along one of the branches created via cloning or depth expansion. If it is along the mainline, it will not attempt to replicate it's subfolders.
clone - Whether this Folder should attempt to clone itself. False if it is iteslf a clone and thus should not attempt to clone itself
depthTime - The depth level that this folder is at. If it is at it's maximum depth, don't replicate itself as a child of itself any further.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 19 2004:2352 UTC