com.cassinidivision.oce.content
Class XMLSerializationController

java.lang.Object
  extended bycom.cassinidivision.oce.content.XMLSerializationController

public class XMLSerializationController
extends Object

This class controls the XML import/export process for the content framework.

Other classes need only communicate with this one in order to get what they need done (content classes need to implement the methods XMLParser will invoke in them).


Field Summary
 NSDictionary configDict
           
 NSArray contentPaths
           
 String parentContentPath
           
 NSMutableArray topLevelImportedChildren
           
 NSDictionary xmlPipelineConfigDict
           
 
Constructor Summary
XMLSerializationController()
           
 
Method Summary
 void addTopLevelImportedChild(Object child)
          Adds an object to the array of top level imported children, which are tracked so that hyperlink paths can be fixed in the correct parts of the content hierarchy.
 NSDictionary configDict()
          Returns the current configuration dictionary
 void exportXMLToPathForContentArray(String path, NSArray contentArray)
          Exports XML to a file
 void importXMLAtPathIntoParent(String path, C_ContentContainer targetParent)
          Imports xml from a file
 void importXMLFromStringIntoParent(String xmlString, C_ContentContainer targetParent)
          Imports xml from a string
 String mergeOverwriteOrCancel()
          Called automatically by C_ContentContainer when it is importing an object and finds it already has one at that path.
 String newPathForContentPath(String oldPath)
          Calculates paths when exporting content hyperlinks.
 String parentContentPath()
          Reports the parent content path, the path to the root of the current export.
 void setConfigDict(NSDictionary value)
          Sets the configuration dictionary for the target.
static XMLSerializationController sharedInstance()
           
 boolean shouldExportChildrenOfObject(C_Content content)
          Examines the configuration dictionary and decides whether or not to export the children of a given object (according to its class).
 boolean shouldExportObject(C_Content content)
          Examines the configuration dictionary and decides whether or not to export a given object (according to its class).
 boolean shouldExportTagNamed(String name)
          Examines the config dictionary and decides whether or not to include a given tag in the export.
 boolean shouldReportUnexportedChildrenOfObject(C_Content content)
          Examines the configuration dictionary to determine whether or not the XML should mention that children of this object were omitted from the export.
 String xmlForContentArray(NSArray contentArray)
          Calculates the appropriate export XML string for some content
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentPaths

public NSArray contentPaths

parentContentPath

public String parentContentPath

topLevelImportedChildren

public NSMutableArray topLevelImportedChildren

configDict

public NSDictionary configDict

xmlPipelineConfigDict

public NSDictionary xmlPipelineConfigDict
Constructor Detail

XMLSerializationController

public XMLSerializationController()
Method Detail

sharedInstance

public static XMLSerializationController sharedInstance()
Returns:
the single shared instance of the XMLSerlializationController class

importXMLAtPathIntoParent

public void importXMLAtPathIntoParent(String path,
                                      C_ContentContainer targetParent)
Imports xml from a file

Parameters:
path - the path to the xml file
targetParent - the C_ContentContainer into which the content specified in the XML will be imported.

importXMLFromStringIntoParent

public void importXMLFromStringIntoParent(String xmlString,
                                          C_ContentContainer targetParent)
Imports xml from a string

Parameters:
xmlString - the xml string
targetParent - the C_ContentContainer into which the content specified in the XML will be imported.

xmlForContentArray

public String xmlForContentArray(NSArray contentArray)
Calculates the appropriate export XML string for some content

Parameters:
contentArray - an array of content objects to export
Returns:
the XML string representing them

exportXMLToPathForContentArray

public void exportXMLToPathForContentArray(String path,
                                           NSArray contentArray)
                                    throws IOException
Exports XML to a file

Parameters:
path - the path to the xml file
contentArray - an array of content objects to export
Throws:
IOException

newPathForContentPath

public String newPathForContentPath(String oldPath)
Calculates paths when exporting content hyperlinks. The path to the target will be written as an absolute path if it is not part of the export, but as a relative path within the exported block if the target is being exported. This ensures that when a block of content is re-imported in a different location in the content hierarchy links within it will still be correct.

Parameters:
oldPath - the path to the target content
Returns:
the new path to be written in the export

parentContentPath

public String parentContentPath()
Reports the parent content path, the path to the root of the current export.

Returns:
the parent content path

mergeOverwriteOrCancel

public String mergeOverwriteOrCancel()
Called automatically by C_ContentContainer when it is importing an object and finds it already has one at that path. Returns the desired behaviour, as specified in the "mergeOverwriteCancel" key of the config dictionary.

C_ContentContainer understands the following values:

"merge": Keep the existing child object, but apply the new values and child objects from the XML to it. Children of the object which are not mentioned in the XML being imported are kept.

"mergeTop": Keep the existing child object but delete any existing children it already has; then apply the new values and child objects from the XML to it. This was used in the client to import new values for a C_Feature, so that the C_Feature would keep the same primary key for links to navigation, but no old pages etc. would be kept.

"overwrite": Delete the existing child entirely, then proceed with the import as though it had never been there.

"cancel": Ignore this portion of the import XML but continue with the import.

Returns:
"merge", "mergeTop", "overwrite" or "cancel" according to desired behaviour

addTopLevelImportedChild

public void addTopLevelImportedChild(Object child)
Adds an object to the array of top level imported children, which are tracked so that hyperlink paths can be fixed in the correct parts of the content hierarchy.

Parameters:
child - the child to add.

setConfigDict

public void setConfigDict(NSDictionary value)
Sets the configuration dictionary for the target. This is a dictionary containing various key/value pairs customising the export behaviour. The controller simply vends this dictionary out to various objects who are interested, and the objects themselves customise their behaviour appropriately.

Parameters:
value - The dictionary.

configDict

public NSDictionary configDict()
Returns the current configuration dictionary

Returns:
The config dictionary

shouldExportTagNamed

public boolean shouldExportTagNamed(String name)
Examines the config dictionary and decides whether or not to include a given tag in the export.

Parameters:
name - the name of the tag
Returns:
whether or not to include it

shouldExportObject

public boolean shouldExportObject(C_Content content)
Examines the configuration dictionary and decides whether or not to export a given object (according to its class).

Returns:
whether or not to export it

shouldExportChildrenOfObject

public boolean shouldExportChildrenOfObject(C_Content content)
Examines the configuration dictionary and decides whether or not to export the children of a given object (according to its class).

Parameters:
content - the content object in question
Returns:
whether or not to export children

shouldReportUnexportedChildrenOfObject

public boolean shouldReportUnexportedChildrenOfObject(C_Content content)
Examines the configuration dictionary to determine whether or not the XML should mention that children of this object were omitted from the export.

Parameters:
content - the content object in question
Returns:
whether or not to report the unexported children