wt.ixb.publicforapps
Class ApplicationExportHandlerForJar

java.lang.Object
  extended bywt.ixb.publicforapps.ApplicationExportHandlerTemplate
      extended bywt.ixb.publicforapps.ApplicationExportHandlerForJar
All Implemented Interfaces:
ApplicationExpImportHandler, ApplicationExportHandler
Direct Known Subclasses:
ExportHandler, IXArchiveRestoreApplication.ArchiveExportHandler, ObjectcolExportHandlerForJar, StandardIXBService.ExportHandler

public class ApplicationExportHandlerForJar
extends ApplicationExportHandlerTemplate

This class provides methods for storing XML and content files in export jar file. It handles both ApplicationData content and content residing in local file system.

Supported API: true

Extendable: false


Field Summary
private static String CLASSNAME
           
private  Map containerMap
           
private  HashSet contentFileNames
           
static String CONTENTS_DIR_NAME
          

Supported API: false
private  int fileNum
           
private  TreeMap filesMap
           
private  File jarFile
           
private  IXBJarWriter jarWriter
           
private  HashSet manifestInfos
           
static String NAME_IS_TAG
          

Supported API: false
private static String RESOURCE
           
private  File saveDir
           
 
Fields inherited from interface wt.ixb.publicforapps.ApplicationExpImportHandler
IMPORTANCE_LEVEL_DEFAULT
 
Constructor Summary
ApplicationExportHandlerForJar(File fileToSave, File dirToSave)
          

Supported API: true
 
Method Summary
private  void addFileNameToImportList(IxbElement doc, String fn)
           
 void addObjectToManifest(String userObjImage)
          Add the localized object identifier of the object (userObjImage) to the manifest.
 void cleanTempDir()
          Delete all files in the directory (including this directory) where is used to save the jar file.
protected  String computeUniqueFileName(String fn)
           
 void createManifest()
          Create the manifest file in the jar.
 void createManifest(File manifestFile)
          Create the manifest file in the jar.
 void finalizeAdditionalInfo()
          

Supported API: true
private  void finalizeContainerInfo()
           
private  void finalizeImportList()
           
 File getJarFile()
          Gets the value of the attribute: jarFile; The jar file to store exportedinformation (meta data and content data)

Supported API: true
 IXBJarWriter getJarWriter()
          Gets the value of the attribute: jarWriter.
protected  File getSaveDir()
          Gets the value of the attribute: saveDir; Directory where the jar file will be stored.
protected  String prepareStoreApplicationData(ApplicationData ad)
           
private  String prepareStoreExternalFile(String externalFileName)
           
private  String prepareStoreImageHolder(ImageHolder contentAttr)
           
 void reallyStoreContent(Object contentHolder, Exporter exporter, InputStream content, String contentId)
          Stores the given content of the content parameter "contentAttr".
 void storeAdditionalInfo(Object object, IxbDocument fileXML, String fileId)
          Stores additional information related to object and its XML representation.
 String storeContent(File contentFile)
          Stores content files residing in the local file system (as in the case of Representation objects).
protected  String storeContent(InputStream is, String fn)
           
 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.
 
Methods inherited from class wt.ixb.publicforapps.ApplicationExportHandlerTemplate
storeDocument, storeLogMessage, storeLogMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

NAME_IS_TAG

public static final String NAME_IS_TAG


Supported API: false

See Also:
Constant Field Values

CONTENTS_DIR_NAME

public static final String CONTENTS_DIR_NAME


Supported API: false

See Also:
Constant Field Values

jarFile

private File jarFile

jarWriter

private IXBJarWriter jarWriter

saveDir

private File saveDir

fileNum

private int fileNum

contentFileNames

private HashSet contentFileNames

manifestInfos

private HashSet manifestInfos

containerMap

private Map containerMap

filesMap

private TreeMap filesMap
Constructor Detail

ApplicationExportHandlerForJar

public ApplicationExportHandlerForJar(File fileToSave,
                                      File dirToSave)
                               throws WTException


Supported API: true

Parameters:
fileToSave - The jar file to store exportedinformation (meta data and content data)
dirToSave - Directory where the jar file will be stored.
Throws:
WTException
Method Detail

getJarFile

public File getJarFile()
Gets the value of the attribute: jarFile; The jar file to store exportedinformation (meta data and content data)

Supported API: true

Returns:
File

getJarWriter

public IXBJarWriter getJarWriter()
Gets the value of the attribute: jarWriter.

Supported API: false

Returns:
IXBJarWriter

getSaveDir

protected File getSaveDir()
Gets the value of the attribute: saveDir; Directory where the jar file will be stored.

Supported API: true

Returns:
File

reallyStoreContent

public void reallyStoreContent(Object contentHolder,
                               Exporter exporter,
                               InputStream content,
                               String contentId)
                        throws WTException
Stores the given content of the content parameter "contentAttr". The parameter "contentId" is the unique content ID which was previously computed and returned by storeContent (Object contentAttr).

Supported API: true

Specified by:
reallyStoreContent in interface ApplicationExportHandler
Overrides:
reallyStoreContent in class ApplicationExportHandlerTemplate
Parameters:
contentHolder - The object holding the attribute (directly or indirectly) "contentAttr".
exporter -
content - The content as InputStream which is associated with the contentId.
contentId - The unique content ID which was previously computed by calling "storeContent (Object contentAttr)"
Throws:
WTException

storeContent

public String storeContent(File contentFile)
                    throws WTException
Stores content files residing in the local file system (as in the case of Representation objects).

Supported API: true

Specified by:
storeContent in interface ApplicationExportHandler
Overrides:
storeContent in class ApplicationExportHandlerTemplate
Parameters:
contentFile -
Returns:
String
Throws:
WTException

storeContent

public String storeContent(Object contentAttr)
                    throws WTException
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

storeDocument

public String storeDocument(IxbElement doc,
                            String dtd)
                     throws WTException
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:
dtd -
doc -
Returns:
String
Throws:
WTException
See Also:
storeDocument (IxbElement elem)

addFileNameToImportList

private void addFileNameToImportList(IxbElement doc,
                                     String fn)
                              throws WTException
Throws:
WTException

finalizeAdditionalInfo

public void finalizeAdditionalInfo()
                            throws WTException
Description copied from class: ApplicationExportHandlerTemplate


Supported API: true

Specified by:
finalizeAdditionalInfo in interface ApplicationExportHandler
Overrides:
finalizeAdditionalInfo in class ApplicationExportHandlerTemplate
Throws:
WTException

storeAdditionalInfo

public void storeAdditionalInfo(Object object,
                                IxbDocument fileXML,
                                String fileId)
                         throws WTException
Stores additional information related to object and its XML representation. Currently it stores information regarding the source container of the object. This method is called from the handler after object is exported.

Supported API: true

Specified by:
storeAdditionalInfo in interface ApplicationExportHandler
Overrides:
storeAdditionalInfo in class ApplicationExportHandlerTemplate
Parameters:
object -
fileXML -
fileId -
Throws:
WTException

addObjectToManifest

public void addObjectToManifest(String userObjImage)
Add the localized object identifier of the object (userObjImage) to the manifest.

Supported API: true

Parameters:
userObjImage - The localized object identifier of the object

cleanTempDir

public void cleanTempDir()
                  throws WTException
Delete all files in the directory (including this directory) where is used to save the jar file. The directory was the one from the constructor ApplicationExportHandlerForJar( File fileToSave, File dirToSave ).

Supported API: true * @exception wt.util.WTException

Throws:
WTException

createManifest

public void createManifest()
                    throws WTException
Create the manifest file in the jar. The content of the manifest file will copy the information as accumulated by calling the method addObjectToManifest (String userObjImage).

Supported API: true * @exception wt.util.WTException

Throws:
WTException

createManifest

public void createManifest(File manifestFile)
                    throws WTException
Create the manifest file in the jar. The manifest file will copy the contents in the File file.

Supported API: true * @exception wt.util.WTException

Throws:
WTException

computeUniqueFileName

protected String computeUniqueFileName(String fn)
                                throws IOException
Throws:
IOException

storeContent

protected String storeContent(InputStream is,
                              String fn)
                       throws IOException
Throws:
IOException

finalizeImportList

private void finalizeImportList()
                         throws WTException
Throws:
WTException

finalizeContainerInfo

private void finalizeContainerInfo()
                            throws WTException
Throws:
WTException

prepareStoreApplicationData

protected String prepareStoreApplicationData(ApplicationData ad)
                                      throws WTException
Throws:
WTException

prepareStoreExternalFile

private String prepareStoreExternalFile(String externalFileName)
                                 throws WTException
Throws:
WTException

prepareStoreImageHolder

private String prepareStoreImageHolder(ImageHolder contentAttr)
                                throws WTException
Throws:
WTException