wt.ixb.pdx
Class PDXExportHandler

java.lang.Object
  extended bywt.ixb.publicforapps.ApplicationExportHandlerTemplate
      extended bywt.ixb.pdx.PDXExportHandler
All Implemented Interfaces:
ApplicationExpImportHandler, ApplicationExportHandler

public class PDXExportHandler
extends ApplicationExportHandlerTemplate

Public handler for export in PDX format.


Field Summary
private static int BUFFER_SIZE
           
protected  IxbDomElement exportPackageElement
           
protected  IxbDomDocument finalDoc
           
private  int fnum
           
private  String m_attachmentsOption
           
private  ExportPackageForPDX m_package
           
private  File m_tempDir
           
static String PDX_EXTENSION
           
static String XML_ATTR_ATTACHMENTS_OPTION
           
static String XML_ATTR_DESCRIPTION
           
static String XML_ATTR_EXPORT_PACKAGE_ID
           
static String XML_ATTR_GENERATION_TIME
           
static String XML_ATTR_IS_ROOT
           
static String XML_ATTR_MODIFICATION_TIME
           
static String XML_ATTR_ORIGINATOR
           
 String XML_DECLARATION
           
static String XML_EXPORT_PACKAGE
           
static String XML_VALUE_ATTACHMENTS
           
static String XML_VALUE_ATTACHMENTS_AS_FILE_NAMES
           
static String XML_VALUE_NO
           
static String XML_VALUE_NO_ATTACHMENTS
           
static String XML_VALUE_YES
           
 
Fields inherited from class wt.ixb.publicforapps.ApplicationExportHandlerTemplate
 
Fields inherited from interface wt.ixb.publicforapps.ApplicationExpImportHandler
IMPORTANCE_LEVEL_DEFAULT
 
Constructor Summary
PDXExportHandler(ExportPackageForPDX ep, String attachmentOption)
           
 
Method Summary
private  void cleanTempDir()
           
protected  void createZip(File dirToSave, String zipName)
          Creates PDX package, which is zip of pdx.xml file and content files.
private  String getCurrentDateTime()
           
private  String getPackageId(ExportPackageForPDX ep)
           
 String getXML()
          Normally should be used only for debugging purposes
private  void PP(String s)
           
private  void setAttachmentOption(String option)
           
private  void setAttributeIsRoot(IxbElement doc)
          Adds attribute isRoot=yes|no indicating whether this element represents a seed WTObject (that is, object which was used as a seed for generating this export package) NB! This method sets isRoot=yes if the object was selected for export BOTH as a seed object and as a child object of some structure.
 String storeContent(Object contentAttr)
          Stores the given content of exported object.
 String storeDocument(IxbElement doc, String dtd)
          Stores the given XML element, which is the XML representation of exported object, based on the provided DTD.
protected  void transformToPDXFormat(String xslPath, String xmlResultFileName)
          Transforms XML Document to PDX format and saves it to temporary directory
 
Methods inherited from class wt.ixb.publicforapps.ApplicationExportHandlerTemplate
finalizeAdditionalInfo, reallyStoreContent, storeAdditionalInfo, storeContent, storeDocument, storeLogMessage, storeLogMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_EXPORT_PACKAGE

public static final String XML_EXPORT_PACKAGE
See Also:
Constant Field Values

XML_ATTR_EXPORT_PACKAGE_ID

public static final String XML_ATTR_EXPORT_PACKAGE_ID
See Also:
Constant Field Values

XML_ATTR_GENERATION_TIME

public static final String XML_ATTR_GENERATION_TIME
See Also:
Constant Field Values

XML_ATTR_MODIFICATION_TIME

public static final String XML_ATTR_MODIFICATION_TIME
See Also:
Constant Field Values

XML_ATTR_ORIGINATOR

public static final String XML_ATTR_ORIGINATOR
See Also:
Constant Field Values

XML_ATTR_ATTACHMENTS_OPTION

public static final String XML_ATTR_ATTACHMENTS_OPTION
See Also:
Constant Field Values

XML_ATTR_DESCRIPTION

public static final String XML_ATTR_DESCRIPTION
See Also:
Constant Field Values

XML_ATTR_IS_ROOT

public static final String XML_ATTR_IS_ROOT
See Also:
Constant Field Values

XML_VALUE_YES

public static final String XML_VALUE_YES
See Also:
Constant Field Values

XML_VALUE_NO

public static final String XML_VALUE_NO
See Also:
Constant Field Values

XML_VALUE_ATTACHMENTS

public static final String XML_VALUE_ATTACHMENTS
See Also:
Constant Field Values

XML_VALUE_NO_ATTACHMENTS

public static final String XML_VALUE_NO_ATTACHMENTS
See Also:
Constant Field Values

XML_VALUE_ATTACHMENTS_AS_FILE_NAMES

public static final String XML_VALUE_ATTACHMENTS_AS_FILE_NAMES
See Also:
Constant Field Values

PDX_EXTENSION

public static final String PDX_EXTENSION
See Also:
Constant Field Values

XML_DECLARATION

public final String XML_DECLARATION
See Also:
Constant Field Values

m_package

private final ExportPackageForPDX m_package

m_tempDir

private final File m_tempDir

finalDoc

protected IxbDomDocument finalDoc

exportPackageElement

protected IxbDomElement exportPackageElement

m_attachmentsOption

private String m_attachmentsOption

fnum

private int fnum

BUFFER_SIZE

private static int BUFFER_SIZE
Constructor Detail

PDXExportHandler

public PDXExportHandler(ExportPackageForPDX ep,
                        String attachmentOption)
                 throws WTException
Parameters:
ep - export package
attachmentOption - Attachments option. Possible values are: a)XML_VALUE_ATTACHMENTS - content files are included into pdx package (default option) b)XML_VALUE_NO_ATTACHMENTS - content files are ignored (not mentioned in pdx.xml and not included into package) c)XML_VALUE_ATTACHMENTS_AS_FILE_NAMES - content files are mentioned in pdx.xml but are not included into package
Method Detail

setAttachmentOption

private void setAttachmentOption(String option)

storeDocument

public String storeDocument(IxbElement doc,
                            String dtd)
                     throws WTException
Description copied from class: ApplicationExportHandlerTemplate
Stores the given XML element, which is the XML representation of exported object, based on the provided DTD. If parameter dtd is null, Windchill's default DTD is assumed. Return XML file name or some other string identifier for the stored element.

Supported API: true

Specified by:
storeDocument in interface ApplicationExportHandler
Overrides:
storeDocument in class ApplicationExportHandlerTemplate
Parameters:
doc -
dtd -
Returns:
String
Throws:
WTException
See Also:
storeDocument (IxbElement elem)

setAttributeIsRoot

private void setAttributeIsRoot(IxbElement doc)
                         throws WTException
Adds attribute isRoot=yes|no indicating whether this element represents a seed WTObject (that is, object which was used as a seed for generating this export package) NB! This method sets isRoot=yes if the object was selected for export BOTH as a seed object and as a child object of some structure.

Throws:
WTException

storeContent

public String storeContent(Object contentAttr)
                    throws WTException
Description copied from class: ApplicationExportHandlerTemplate
Stores the given content of exported object. The return value is String, that will be used in XML file as an identifier of this content. Application should be able to find the content during the import process by this identifier. The content of the associated object might not be saved, depending on the implementation of the this interface.

Supported API: true

Specified by:
storeContent in interface ApplicationExportHandler
Overrides:
storeContent in class ApplicationExportHandlerTemplate
Parameters:
contentAttr - The content attribute which is related to InputStream or BLOB. e.g. it can be ApplicationData , File or String (full path of a file), etc
Returns:
String
Throws:
WTException

getXML

public String getXML()
              throws WTException
Normally should be used only for debugging purposes

Returns:
String representation of XML document, which is used as input source for XSL transformation
Throws:
WTException

transformToPDXFormat

protected void transformToPDXFormat(String xslPath,
                                    String xmlResultFileName)
                             throws WTException
Transforms XML Document to PDX format and saves it to temporary directory

Parameters:
xslPath - path to the XSL file used for transformation
xmlResultFileName - name under which the resulting PDX XML file should be stored (according to PDX 1.0 specification it should be "pdx.xml", but, unfortunately, some PDX implementations (Agile eXpress) do not understand it)
Throws:
WTException

createZip

protected void createZip(File dirToSave,
                         String zipName)
                  throws WTException
Creates PDX package, which is zip of pdx.xml file and content files. The resulting file should have extension .pdx.

Parameters:
dirToSave - directory on server where *.pdx file will be created
Throws:
WTException

cleanTempDir

private void cleanTempDir()

getPackageId

private String getPackageId(ExportPackageForPDX ep)

getCurrentDateTime

private String getCurrentDateTime()

PP

private void PP(String s)