wt.ixb.publicforapps
Class Importer

java.lang.Object
  extended bywt.ixb.publicforapps.ExpImporter
      extended bywt.ixb.publicforapps.Importer

public class Importer
extends ExpImporter

Importer is the container representing import handlers for the context of the import operation. Importer instance is not stateless and there should be only one instance for each importer request.
To construct an instance of Importer use IxbHelper.newImport() with the desired signatures.
There are two major categories of methods in this class to execute import:



Supported API: true

Extendable: true


Field Summary
private  String actorName
           
private  ApplicationImportHandler applicationImportHandler
           
private static String CLASSNAME
           
private  String clientJarFileName
           
 long countFilesImported
           
 long countOfCheckedOutObjects
           
 long countOfIgnoredObjects
           
 long countOfNewObjects
           
 long countOfOldObjects
           
private  String dtdFromXML
           
 ExistObjConflictSet existingObjectsConflictSet
           
private static String FILE_NAME_CONNECT_CHAR
           
 IXBImpConflictSet generalConflictSet
           
private  Hashtable htContainerMapping
           
private  Hashtable htModifiedObjects
          htModifiedObjects is used to store objects in the XML file, but their identities are modified by the import process.
This Hashtable must be initialized before the import process for one jar file takes place, and must be set to null when the import process for one jar file is finished.
private  Vector impList
           
private  boolean importLifeCycleAfterStore
           
private  boolean mustImportLifeCycle
           
private static String NO_CONTAINER
           
private static boolean ONE_TRANSACTION
           
private  boolean performConflictResolution
           
private static String RESOURCE
           
private static int SMALL_JAR_SIZE
           
private  WTContainerRef targetContainer
           
private  String targetContainerId
           
private  boolean validate
           
private  Vector vIgnoredObjects
           
private  Vector vNotCreateLinkObjects
           
static String XML_TAG_CONTAINER
           
static String XML_TAG_SOURCE_CONTAINER
           
static String XML_TAG_TARGET_CONTAINER
           
private  StreamSource xslPolicyFile
           
private  String xslPolicyFileName
           
 
Fields inherited from class wt.ixb.publicforapps.ExpImporter
attributeExporterImporterManager, dtd, generalContext, ixbHandlersManager, tuner
 
Constructor Summary
(package private) Importer(ApplicationImportHandler _applicationImportHandler, WTContainerRef cont, String _dtd, IxbElement _localMappingRules, Boolean _overrideConflicts, Boolean _validate)
           
(package private) Importer(ApplicationImportHandler _applicationImportHandler, WTContainerRef _targetContainer, String _dtd, IxbElement _localMappingRules, Boolean _overrideConflicts, Boolean _validate, Boolean _performConflictResolution)
           
(package private) Importer(ApplicationImportHandler _applicationImportHandler, WTContainerRef _targetContainer, String _dtd, String _ruleFileName, String _xslPolicyFileName, String _containerMappingFileName, String _actorName, Boolean _overrideConflicts, Boolean _validate)
          _ruleFileName is the name of XML file or XSL file that is passed in to Importer as mapping rule.
 
Method Summary
 void addToModifiedObjects(Object oldId, Object newId)
          add new identity of imported object in the hashtable

Supported API: true
 void addToNotCreateLinkObjects(Object objectId)
           
private  void checkConflicts(IxbDocument doc)
           
private  void checkConflicts(Vector fileNames)
           
private  void checkConflictsForOneDocFromJar(IxbDocument doc)
           
private  void closeStream(InputStream is)
           
private  int compareDocs(IxbDocument doc1, IxbDocument doc2)
           
private  void doCheckConflicts()
           
 IxbDocument doImport(InputStream docStream)
          Provides information for import.
 void doImport(InputStream docStream, boolean _validate)
           
 IxbDocument doImport(IxbDocument doc)
          Provides information for import.
 void doImport(IxbElement doc)
          Deprecated.  
 IxbDocument doImport(String docName, String docTag)
          Provides information for import.
 void doPreview(InputStream docStream)
           
 void doPreview(IxbDocument doc)
           
 void doPreview(String docName, String docTag)
           
private  void doRealImport()
           
private  void doRealImport(Vector fileNames)
           
private  void doRealPreview()
           
private  void finalizeCheckConflicts()
           
 void finalizeImport()
          Really performs all work, especially the real import, related to the import based on the information, provided by previous calls of doImport methods: Checks the information from XML files for potential conflicts Creates Windchill objects

Supported API: true
private  void finalizeImportFinalize()
           
 void finalizePreview()
           
 ApplicationImportHandler getApplicationImportHandler()
           
 Hashtable getContainerMapping()
           
 IxbDocument getDocumentByFileName(String fileName)
           
private  String getDTDFromXML(IxbDocument doc)
           
 IxbElement getElementForEndOfLink(IxbElement endXML, String endId)
          A link always has two ends, each end is represented by its ufid in the link's XML file.
 Vector getIgnoredObjects()
           
private  ElementImporter getImportHandler(String tag)
           
private  InputStream getInputStreamFromApplicationHandler(String s)
           
 Object getNewIdFromOldId(Object oldId)
          get new identity of imported object based on its old identity from XML file

Supported API: false
 Vector getNotCreateLinkObjects()
           
 String getTargetContainerId()
           
 WTContainerRef getTargetContainerRef()
          Returns the container reference where the import is launched.
 void importElement(IxbElement doc)
          ATTENTION! This method can not be used directly from application.
 void importFiles(Vector fileNames)
          Checks conflicts and imports data, given the sorted list of metadata file names.
 void importJarFile(IXBJarReader jarReader)
           
private  void importOneDocFromJar(IxbDocument doc)
           
private  void initialize(ApplicationImportHandler _applicationImportHandler, String _dtd, Boolean _overrideConflicts, Boolean _validate)
           
private  void initialize(ApplicationImportHandler _handler, WTContainerRef cont, String _dtd, String _containerMappingFileName, String _actorName, Boolean _overrideConflicts, Boolean _validate)
           
private  void insertExternalNameToList(Vector extFileNames, String stDir, String stKey)
           
private  IxbDocument insertInListForImport(IxbDocument doc, String rootElementTag)
           
private  void insertObjectInHashtable(Hashtable htbObjs, IxbDocument insertDoc, ElementImporter handler)
           
private  void insertObjectInList(Vector vImportList, Object doc, int prio, int subPrio)
           
 boolean isImportLifeCycleAfterStore()
           
 boolean isMustImportLifeCycle()
           
 void logMessage(String resourceBundle, String messageKey, Object[] textInserts)
          Sends log message to export/import application

Supported API: true
 void logMessage(String resourceBundle, String messageKey, Object[] textInserts, int importanceLevel)
          Sends log message to export/import application

Supported API: true
private static void PP(String s)
           
private  IxbDocument prepareDocForImport(IxbDocument doc)
           
private  void prepareForCheckConflicts()
           
private  void prepareForImport()
           
private  void prepareForImportJar()
           
 void previewElement(IxbElement doc)
           
 void previewJarFile(IXBJarReader jarReader)
           
private  void previewOneDocFromJar(IxbDocument doc)
           
 void processBigJarFile(IXBJarReader jarReader, boolean isImportJar)
           
private  void processFromObjectList(Vector vImportList, boolean isImportJar)
           
 void processSmallJarFile(IXBJarReader jarReader, boolean isImportJar)
           
 void setClientJarFileName(String aName)
           
 void setImportLifeCycleAfterStore(boolean bValue)
           
 void SetMustImportLifeCycle(boolean value)
           
 boolean shouldPerformConflictResolution()
           
 
Methods inherited from class wt.ixb.publicforapps.ExpImporter
getDTD
 
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

XML_TAG_CONTAINER

public static final String XML_TAG_CONTAINER
See Also:
Constant Field Values

XML_TAG_SOURCE_CONTAINER

public static final String XML_TAG_SOURCE_CONTAINER
See Also:
Constant Field Values

XML_TAG_TARGET_CONTAINER

public static final String XML_TAG_TARGET_CONTAINER
See Also:
Constant Field Values

NO_CONTAINER

private static final String NO_CONTAINER
See Also:
Constant Field Values

FILE_NAME_CONNECT_CHAR

private static final String FILE_NAME_CONNECT_CHAR
See Also:
Constant Field Values

targetContainer

private WTContainerRef targetContainer

targetContainerId

private String targetContainerId

htContainerMapping

private Hashtable htContainerMapping

countFilesImported

public long countFilesImported

countOfNewObjects

public long countOfNewObjects

countOfOldObjects

public long countOfOldObjects

countOfIgnoredObjects

public long countOfIgnoredObjects

countOfCheckedOutObjects

public long countOfCheckedOutObjects

generalConflictSet

public IXBImpConflictSet generalConflictSet

existingObjectsConflictSet

public ExistObjConflictSet existingObjectsConflictSet

applicationImportHandler

private ApplicationImportHandler applicationImportHandler

impList

private Vector impList

validate

private boolean validate

actorName

private String actorName

xslPolicyFile

private StreamSource xslPolicyFile

xslPolicyFileName

private String xslPolicyFileName

performConflictResolution

private boolean performConflictResolution

clientJarFileName

private String clientJarFileName

mustImportLifeCycle

private boolean mustImportLifeCycle

SMALL_JAR_SIZE

private static final int SMALL_JAR_SIZE
See Also:
Constant Field Values

dtdFromXML

private String dtdFromXML

importLifeCycleAfterStore

private boolean importLifeCycleAfterStore

htModifiedObjects

private Hashtable htModifiedObjects
htModifiedObjects is used to store objects in the XML file, but their identities are modified by the import process.
This Hashtable must be initialized before the import process for one jar file takes place, and must be set to null when the import process for one jar file is finished. The handler or actor that changes identities of object must put the object or its identities in this hashtable , to maintain a list of objects whose identities are changed. In the case of import link, I put only the end's old ufid and new ufid in the hashtable.

Since:
Windchill R6.2.6

vIgnoredObjects

private Vector vIgnoredObjects

vNotCreateLinkObjects

private Vector vNotCreateLinkObjects

ONE_TRANSACTION

private static boolean ONE_TRANSACTION
Constructor Detail

Importer

Importer(ApplicationImportHandler _applicationImportHandler,
         WTContainerRef _targetContainer,
         String _dtd,
         IxbElement _localMappingRules,
         Boolean _overrideConflicts,
         Boolean _validate,
         Boolean _performConflictResolution)
   throws WTException

Importer

Importer(ApplicationImportHandler _applicationImportHandler,
         WTContainerRef _targetContainer,
         String _dtd,
         String _ruleFileName,
         String _xslPolicyFileName,
         String _containerMappingFileName,
         String _actorName,
         Boolean _overrideConflicts,
         Boolean _validate)
   throws WTException
_ruleFileName is the name of XML file or XSL file that is passed in to Importer as mapping rule. Local mapping rule can be null This one is called from StandardIXBService


Importer

Importer(ApplicationImportHandler _applicationImportHandler,
         WTContainerRef cont,
         String _dtd,
         IxbElement _localMappingRules,
         Boolean _overrideConflicts,
         Boolean _validate)
   throws WTException
Method Detail

doImport

public IxbDocument doImport(InputStream docStream)
                     throws WTException
Provides information for import. No real import will be done at that point.

Supported API: true

Parameters:
docStream - InputStream representing content of XML document to de imported
Returns:
IxbDocument
Throws:
WTException

doImport

public IxbDocument doImport(IxbDocument doc)
                     throws WTException
Provides information for import. No real import will be done at that point.

Supported API: true

Parameters:
doc - IxbDocument representing content of XML document to de imported
Returns:
IxbDocument
Throws:
WTException

doImport

public IxbDocument doImport(String docName,
                            String docTag)
                     throws WTException
Provides information for import. No real import will be done at that point.
This is an optimization: application additionally informs IXB service about root tag of XML document. This helps IXB to avoid additional XML parsing.
Replication and export/import application use this optimization

Supported API: true

Parameters:
docName - identifier of XML document to be imported. Application import handler must be able to return the XML document based on this identifier
docTag - tag of root element in this XML document.
Returns:
IxbDocument
Throws:
WTException

finalizeImport

public void finalizeImport()
                    throws WTException
Really performs all work, especially the real import, related to the import based on the information, provided by previous calls of doImport methods:

Supported API: true

Throws:
WTException

logMessage

public void logMessage(String resourceBundle,
                       String messageKey,
                       Object[] textInserts)
                throws WTException
Sends log message to export/import application

Supported API: true

Specified by:
logMessage in class ExpImporter
Parameters:
resourceBundle -
messageKey -
textInserts -
Throws:
WTException

logMessage

public void logMessage(String resourceBundle,
                       String messageKey,
                       Object[] textInserts,
                       int importanceLevel)
                throws WTException
Sends log message to export/import application

Supported API: true

Specified by:
logMessage in class ExpImporter
Parameters:
resourceBundle -
messageKey -
textInserts -
importanceLevel -
Throws:
WTException

initialize

private void initialize(ApplicationImportHandler _handler,
                        WTContainerRef cont,
                        String _dtd,
                        String _containerMappingFileName,
                        String _actorName,
                        Boolean _overrideConflicts,
                        Boolean _validate)
                 throws WTException
Throws:
WTException

initialize

private void initialize(ApplicationImportHandler _applicationImportHandler,
                        String _dtd,
                        Boolean _overrideConflicts,
                        Boolean _validate)
                 throws WTException
Throws:
WTException

doImport

public void doImport(InputStream docStream,
                     boolean _validate)
              throws WTException
Throws:
WTException

importFiles

public void importFiles(Vector fileNames)
                 throws WTException
Checks conflicts and imports data, given the sorted list of metadata file names. This list should be supplied by the application, and ApplicationImportHandler should be able to retrieve IxbDocument by these file names. This method is intended to use for the large amount of data, such as for Restore. As with normal import, all files are imported in a transaction, so nothing will be imported if there is any error.

Parameters:
fileNames - Vector of metadata file names, sorted by import priority
Throws:
WTException

checkConflicts

private void checkConflicts(Vector fileNames)
                     throws WTException
Throws:
WTException

doRealImport

private void doRealImport(Vector fileNames)
                   throws WTException
Throws:
WTException

closeStream

private void closeStream(InputStream is)
                  throws WTException
Throws:
WTException

doPreview

public void doPreview(InputStream docStream)
               throws WTException
Throws:
WTException

doPreview

public void doPreview(IxbDocument doc)
               throws WTException
Throws:
WTException

doPreview

public void doPreview(String docName,
                      String docTag)
               throws WTException
Throws:
WTException

finalizePreview

public void finalizePreview()
                     throws WTException
Throws:
WTException

doRealPreview

private void doRealPreview()
                    throws WTException
Throws:
WTException

previewElement

public void previewElement(IxbElement doc)
                    throws WTException
Throws:
WTException

doCheckConflicts

private void doCheckConflicts()
                       throws WTException
Throws:
WTException

doRealImport

private void doRealImport()
                   throws WTException
Throws:
WTException

prepareForCheckConflicts

private void prepareForCheckConflicts()
                               throws WTException
Throws:
WTException

checkConflicts

private void checkConflicts(IxbDocument doc)
                     throws WTException
Throws:
WTException

finalizeCheckConflicts

private void finalizeCheckConflicts()
                             throws WTException
Throws:
WTException

prepareForImport

private void prepareForImport()
                       throws WTException
Throws:
WTException

getIgnoredObjects

public Vector getIgnoredObjects()

getNotCreateLinkObjects

public Vector getNotCreateLinkObjects()

addToNotCreateLinkObjects

public void addToNotCreateLinkObjects(Object objectId)

importElement

public void importElement(IxbElement doc)
                   throws WTException
ATTENTION! This method can not be used directly from application. Application can use 'doImport (IxbDocument)' only. Method 'importElement (IxbElement doc)'can be used from import handlers only to import inner elements of IxbDocument

Supported API: true

Throws:
WTException

doImport

public void doImport(IxbElement doc)
              throws WTException
Deprecated.  

This method is deprecated. Use importElement (IxbElement doc)

Supported API: false

Throws:
WTException

finalizeImportFinalize

private void finalizeImportFinalize()
                             throws WTException
Throws:
WTException

getInputStreamFromApplicationHandler

private InputStream getInputStreamFromApplicationHandler(String s)
                                                  throws WTException
Throws:
WTException

insertInListForImport

private IxbDocument insertInListForImport(IxbDocument doc,
                                          String rootElementTag)
                                   throws WTException
Throws:
WTException

getApplicationImportHandler

public ApplicationImportHandler getApplicationImportHandler()

getImportHandler

private ElementImporter getImportHandler(String tag)
                                  throws WTException
Throws:
WTException

getDocumentByFileName

public IxbDocument getDocumentByFileName(String fileName)
                                  throws WTException
Throws:
WTException

getDTDFromXML

private String getDTDFromXML(IxbDocument doc)

shouldPerformConflictResolution

public boolean shouldPerformConflictResolution()

addToModifiedObjects

public void addToModifiedObjects(Object oldId,
                                 Object newId)
add new identity of imported object in the hashtable

Supported API: true

Parameters:
oldId - identity of the object in the XML file,such as ufid, local Id... or it can be the object itself
newId - identity of the object that is newly created in the system,such as ufid, local Id... or it canbe the object itself
Since:
Windchill R6.2.6

getNewIdFromOldId

public Object getNewIdFromOldId(Object oldId)
get new identity of imported object based on its old identity from XML file

Supported API: false

Parameters:
oldId - identity of the object in the XML file,such as ufid, local Id... or it can be the object itself
Returns:
new Identity of the object that is newly created in the system
Since:
Windchill R6.2.6

getElementForEndOfLink

public IxbElement getElementForEndOfLink(IxbElement endXML,
                                         String endId)
                                  throws WTException
A link always has two ends, each end is represented by its ufid in the link's XML file. However, the information about the link's ends in the XML file may not be correct, if ufids of those ends are modified when they (the ends) are imported.
This method gets the correct IxbElement that represents for one end of the link in the XML file, no matter the end's ufid is modified or not.

Supported API: true

Parameters:
endXML - the original IxbElement in the XML file that represents one end of a link
endId - the original id (ufid or localId of the end in the XML file (A.K.A. oldId in htModifiedObjects)
Returns:
the IxbElement
Throws:
WTException
Since:
Windchill R6.2.6

getTargetContainerRef

public WTContainerRef getTargetContainerRef()
                                     throws WTException
Returns the container reference where the import is launched.

Supported API: true

Returns:
WTContainerRef
Throws:
WTException

getTargetContainerId

public String getTargetContainerId()
                            throws WTException
Throws:
WTException

SetMustImportLifeCycle

public void SetMustImportLifeCycle(boolean value)

isMustImportLifeCycle

public boolean isMustImportLifeCycle()

getContainerMapping

public Hashtable getContainerMapping()

setClientJarFileName

public void setClientJarFileName(String aName)

importJarFile

public void importJarFile(IXBJarReader jarReader)
                   throws WTException
Throws:
WTException

processSmallJarFile

public void processSmallJarFile(IXBJarReader jarReader,
                                boolean isImportJar)
                         throws WTException
Throws:
WTException

processFromObjectList

private void processFromObjectList(Vector vImportList,
                                   boolean isImportJar)
                            throws WTException
Throws:
WTException

processBigJarFile

public void processBigJarFile(IXBJarReader jarReader,
                              boolean isImportJar)
                       throws WTException
Throws:
WTException

insertExternalNameToList

private void insertExternalNameToList(Vector extFileNames,
                                      String stDir,
                                      String stKey)
                               throws WTException
Throws:
WTException

previewJarFile

public void previewJarFile(IXBJarReader jarReader)
                    throws WTException
Throws:
WTException

importOneDocFromJar

private void importOneDocFromJar(IxbDocument doc)
                          throws WTException
Throws:
WTException

checkConflictsForOneDocFromJar

private void checkConflictsForOneDocFromJar(IxbDocument doc)
                                     throws WTException
Throws:
WTException

previewOneDocFromJar

private void previewOneDocFromJar(IxbDocument doc)
                           throws WTException
Throws:
WTException

prepareDocForImport

private IxbDocument prepareDocForImport(IxbDocument doc)
                                 throws WTException
Throws:
WTException

prepareForImportJar

private void prepareForImportJar()
                          throws WTException
Throws:
WTException

insertObjectInList

private void insertObjectInList(Vector vImportList,
                                Object doc,
                                int prio,
                                int subPrio)
                         throws WTException
Throws:
WTException

insertObjectInHashtable

private void insertObjectInHashtable(Hashtable htbObjs,
                                     IxbDocument insertDoc,
                                     ElementImporter handler)
                              throws WTException
Throws:
WTException

compareDocs

private int compareDocs(IxbDocument doc1,
                        IxbDocument doc2)
                 throws WTException
Throws:
WTException

PP

private static void PP(String s)

setImportLifeCycleAfterStore

public void setImportLifeCycleAfterStore(boolean bValue)

isImportLifeCycleAfterStore

public boolean isImportLifeCycleAfterStore()