com.ptc.windchill.structconf.migrate
Class MigratePropsToXconf

java.lang.Object
  extended bycom.ptc.windchill.structconf.migrate.MigratePropsToXconf

public final class MigratePropsToXconf
extends Object

Tool to convert exsiting .properties files to .xconf files.

Usage:

    java com.ptc.windchill.structconf.migrate.MigratePropsToXconf {-m|-mine} property-files (space separated)

For each property file specified create an xconf file containing its XML representation. The migrator will do its best to preserve formatting of all comments.


Field Summary
private static String CONSPICUOUS_BAR
           
private  boolean isSiteFile_
           
private  File propertiesFile_
           
private  HashMap serviceEntryElements_
           
private  HashMap serviceEntryOptionExtraComments_
           
private  HashMap serviceResourceCache_
           
 
Constructor Summary
MigratePropsToXconf(File properties_file, boolean is_site_file)
          Create an instance to generate an xconf file for the specified properties file.
 
Method Summary
private  void addDoNotModifyComment(Element root)
           
private  String cleanup(String str)
          Trim the string and remove lines that contain multiple ###, ===, or --- as line separators.
private  void clearCaches()
           
 void convert()
          Convert the properties file to it's corresponding xconf format.
private  void convertPropsToDom(Document doc)
          An ugly method that does the conversion from property file to DOM.
private  ArrayList getOptionsFor(ServiceOrResourceEntryKey key)
          Get an array to store all the optional implementations for a service or resource.
static void main(String[] args)
          Main entry point.
private  Document newDoc()
          Create a new DOM Document instance.
private static void showHelp(String error_message)
           
private  void writeXconfFile(Document doc, File file)
          Output the given DOM document to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertiesFile_

private File propertiesFile_

isSiteFile_

private boolean isSiteFile_

serviceResourceCache_

private HashMap serviceResourceCache_

serviceEntryElements_

private HashMap serviceEntryElements_

serviceEntryOptionExtraComments_

private HashMap serviceEntryOptionExtraComments_

CONSPICUOUS_BAR

private static final String CONSPICUOUS_BAR
See Also:
Constant Field Values
Constructor Detail

MigratePropsToXconf

public MigratePropsToXconf(File properties_file,
                           boolean is_site_file)
Create an instance to generate an xconf file for the specified properties file.

Method Detail

clearCaches

private void clearCaches()

convert

public void convert()
             throws IOException,
                    ParserConfigurationException,
                    TransformerConfigurationException,
                    TransformerException
Convert the properties file to it's corresponding xconf format.

This method is threadsafe within a single process. Note this signature will change to consolidate these exceptions into a single exception or two.

Throws:
IllegalArgumentException - if the file is a directory
FileNotFoundException - if the specified file cannot be located.
IOException - if there's a problem reading the properties file or writing the xconf file
IllegalArgumentException - if the file is a directory
ParserConfigurationException - if a JAXP document builder cannot be created
TransformerConfigurationException - if a JAXP transformer factory or transformer cannot be created
TransformerException - if there's a problem converting the XML DOM to a stream via an XSLT identity transform

getOptionsFor

private ArrayList getOptionsFor(ServiceOrResourceEntryKey key)
Get an array to store all the optional implementations for a service or resource. Creates the array if it does not yet exist.

Returns:
non-null ArrayList

convertPropsToDom

private void convertPropsToDom(Document doc)
                        throws IOException
An ugly method that does the conversion from property file to DOM.

Throws:
IOException

addDoNotModifyComment

private void addDoNotModifyComment(Element root)

cleanup

private String cleanup(String str)
Trim the string and remove lines that contain multiple ###, ===, or --- as line separators.

Returns:
non-null String

newDoc

private Document newDoc()
                 throws ParserConfigurationException
Create a new DOM Document instance.

Throws:
ParserConfigurationException - if there's no valid JAXP DocumentBuilder implementation.

writeXconfFile

private void writeXconfFile(Document doc,
                            File file)
                     throws TransformerConfigurationException,
                            TransformerException
Output the given DOM document to the file.

Throws:
TransformerConfigurationException - if a JAXP transformer factory or transformer cannot be created
TransformerException - if there's a problem converting the XML DOM to a stream via an XSLT identity transform

showHelp

private static void showHelp(String error_message)

main

public static void main(String[] args)
Main entry point.