com.ptc.windchill.structconf
Class StructConfManager

java.lang.Object
  extended bycom.ptc.windchill.structconf.StructConfManager

public class StructConfManager
extends Object

Tools for manipulating declarative and site xconf settings, propagating xconfs into property files, updating property documentation, and locating property specifications in xconf files.

This class has a main interface which provides for all facilities on the command line. To see how to use the class via this interface invoke the command:

   java com.ptc.windchill.structconf.StructConfManager -h

For programmatic usage, see the documentation for the method execute.


Field Summary
private static String BREAK_AND_INDENT
           
private  TargetFileContentsCollector collector_
           
private  boolean lenientValidation_
           
private static int MAX_WRAPPED_MESSAGE_WIDTH
           
private  RebuildAnalyzer rebuildAnalyzer_
           
private  boolean targetUnix_
           
private  HashMap updaters_
           
 
Constructor Summary
StructConfManager()
          Create instance that will use the JVM's file separator to determine the target platform.
StructConfManager(boolean target_unix)
          A configurable constructor.
 
Method Summary
static void convertLeadingLongDashesToRegularDashes(String[] args)
           
 void execute(Collection commands)
          See execute(StructConfManagerCommand[]).
 void execute(StructConfManagerCommand[] commands)
          Execute a sequence of StructConfManagerCommands.
(package private)  TargetFileContentsCollector getCollector()
           
(package private)  UpdateXconf getDeclarativeUpdater()
           
(package private)  UpdateXconf getSiteUpdater()
           
(package private)  UpdateXconf getUpdater(File file, int xconf_parser_mode)
           
private static boolean isPlatformUnix()
           
private static String localize(String key)
           
static void main(String[] args)
          Command line interface to the StructConfManager.
private static ArrayList parsePropertyNames(String value)
           
private static String[] parsePropertyNameValuePair(String arg)
           
 XconfAnalysis propagate(boolean force_propagate, boolean force_xconf_scan)
          Shorthand for creating and executing a Propagate command.
private  void saveSettings()
           
private  void saveUpdaterSettings(UpdateXconf updater, String updater_desc)
           
 void setLenientValidation(boolean lenient)
          Configure whether validation of xconf data is lenient.
private static void showHelp()
           
private static void showHelp(String error_message)
           
private static ArrayList split(String message)
           
private static File validateFile(String opt, String key_for_does_not_exist, String key_for_cannot_be_read)
           
private static String wrap(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lenientValidation_

private boolean lenientValidation_

targetUnix_

private boolean targetUnix_

rebuildAnalyzer_

private RebuildAnalyzer rebuildAnalyzer_

collector_

private TargetFileContentsCollector collector_

updaters_

private HashMap updaters_

BREAK_AND_INDENT

private static final String BREAK_AND_INDENT

MAX_WRAPPED_MESSAGE_WIDTH

private static final int MAX_WRAPPED_MESSAGE_WIDTH
See Also:
Constant Field Values
Constructor Detail

StructConfManager

public StructConfManager()
Create instance that will use the JVM's file separator to determine the target platform.


StructConfManager

public StructConfManager(boolean target_unix)
A configurable constructor.

Parameters:
target_unix - Set whether or not to generate properties in unix or windows format. This is useful when cross propagating, i.e. generating properties for a different platform than that which the propagator is running on.
Method Detail

isPlatformUnix

private static boolean isPlatformUnix()

getCollector

TargetFileContentsCollector getCollector()
                                   throws StructConfManagerException
Throws:
StructConfManagerException

setLenientValidation

public void setLenientValidation(boolean lenient)
Configure whether validation of xconf data is lenient. By default, it is not lenient. When changed to lenient certain errors are demoted to warnings.


getDeclarativeUpdater

UpdateXconf getDeclarativeUpdater()

getSiteUpdater

UpdateXconf getSiteUpdater()

getUpdater

UpdateXconf getUpdater(File file,
                       int xconf_parser_mode)

propagate

public XconfAnalysis propagate(boolean force_propagate,
                               boolean force_xconf_scan)
                        throws InvalidXconfException,
                               PartialPropagationException,
                               TargetFilesWriteProtectedException,
                               StructConfManagerException
Shorthand for creating and executing a Propagate command. i.e. it is the equivalent of:
    StructConfManager manager = ...;
   manager.execute(new StructConfManagerCommand[]
      {
         new Propagate(...)
      });

Returns:
an XconfAnalysis if a propagation was needed because xconfs and properties were not in sync and there were no errors preventing. Null will be returned if propagation does not occur because files are in sync.
Throws:
InvalidXconfException - if the xconf's contain errors that prevent propagation from occurring (see InvalidXconfException.getXconfAnalysis() for warnings and errors)
PartialPropagationException - if propgation updates one or more, but not all target files and fails - this exception contains detailed information about what files need to be restored and which backup files to use
TargetFilesWriteProtectedException - if propagation cannot be started because one or more target files are not writable - this exception will contain the list of files that are write protected.
StructConfManagerException - all other exceptions related to illogical date or IO errors

execute

public void execute(StructConfManagerCommand[] commands)
             throws StructConfManagerException
Execute a sequence of StructConfManagerCommands. All commands will be executed and any changes made to xconf files will be saved.

If Propagate command are encountered, all modified xconf files will be saved before propagation occurs. It is valid to intersperse Propagate commands with other commands, although this will take more time.

Example Usage:

The following examples will install a new declarative xconf file, set a site-specific value for a property, and propate the changes to properties files:

   StructConfManager manager = new StructConfManager();
    
   StructConfManagerCommand[] commands = new StructConfManagerCommand[]
   {
      new IncludeXconfFile(
                  "codebase/com/ptc/windchill/myassembly/mycomponent/foo.xconf", true),
      new SetSiteProperty("foo.dir", "/opt/foo"),
      new Propagate()
   };
    
   manager.execute(commands);
Alternatively, you may provide a collection rather than an array:
   StructConfManager manager = new StructConfManager();
    
   ArrayList commands = new ArrayList();
   commands.add(new IncludeXconfFile(
                "codebase/com/ptc/windchill/myassembly/mycomponent/foo.xconf", true));
   commands.add(new SetSiteProperty("foo.dir", "/opt/foo"));
   commands.add(new Propagate());
    
   manager.execute(commands);

Throws:
StructConfManagerException
See Also:
StructConfManagerCommand

execute

public void execute(Collection commands)
             throws StructConfManagerException
See execute(StructConfManagerCommand[]).

Throws:
StructConfManagerException

saveSettings

private void saveSettings()
                   throws StructConfManagerException
Throws:
StructConfManagerException

saveUpdaterSettings

private void saveUpdaterSettings(UpdateXconf updater,
                                 String updater_desc)
                          throws StructConfManagerException
Throws:
StructConfManagerException

showHelp

private static void showHelp()

localize

private static String localize(String key)

wrap

private static String wrap(String message)

split

private static ArrayList split(String message)

showHelp

private static void showHelp(String error_message)

parsePropertyNames

private static ArrayList parsePropertyNames(String value)

parsePropertyNameValuePair

private static String[] parsePropertyNameValuePair(String arg)
                                            throws IOException
Throws:
IOException

convertLeadingLongDashesToRegularDashes

public static void convertLeadingLongDashesToRegularDashes(String[] args)

validateFile

private static File validateFile(String opt,
                                 String key_for_does_not_exist,
                                 String key_for_cannot_be_read)

main

public static void main(String[] args)
Command line interface to the StructConfManager.

For usage information, execute:

  java -cp ... com.ptc.windchill.structconf.propagate.Propagate -h
at the command prompt.