Class XmlToPropertiesConverter

java.lang.Object
com.jalios.jcms.tools.XmlToPropertiesConverter

public class XmlToPropertiesConverter extends Object
Helper class to move I18N strings in XML files (types, templates and workflows) to properties files.

Supported XML files (types, templates and workflows) are processed as follow :

  1. I18N tags and attribute are extracted and saved in the corresponding I18N properties of the plugin, enforcing the properties' naming scheme expected by JCMS.
    Items converted :
    • XML tag with attribute xml:lang such as <label.../>, <title.../> and <description.../>
    • labelList* attributes of enumerate fields
  2. All I18N contained in XML files are removed and updated xml files are saved.
Example through command line, by specifying the root directories of some clean unzipped plugin to convert :
   XmlToPropertiesConverter MyPluginDirectory SomeOtherPluginDirectory 
 
Example through Java code:
      XmlToPropertiesConverter conv = new XmlToPropertiesConverter();

      // Convert plugin XML files
      File pluginRootDir = [...]; // MUST point the root directory of an clean unzipped plugin
      conv.processDirectory(myPluginRootDir);

      // Convert core JCMS XML files - for Jalios only
      File webappRootDir = [...]; // point the root directory of the webapp, which MUST NOT contain any plugin
      conv.processDirectory(myWebappRootDir);
 
Since:
jcms-8.0.0
  • Field Details

    • STATUS_OK

      public static final int STATUS_OK
      XmlToPropertiesConverter exit code when everything went fine
      See Also:
    • STATUS_BAD_PARAMETERS

      public static final int STATUS_BAD_PARAMETERS
      XmlToPropertiesConverter exit code if invalid parameters were specified
      See Also:
    • STATUS_ERROR

      public static final int STATUS_ERROR
      XmlToPropertiesConverter exit code in case any error occurs
      See Also:
  • Constructor Details

    • XmlToPropertiesConverter

      public XmlToPropertiesConverter()
  • Method Details

    • processDirectory

      public boolean processDirectory(File rootDir)
      Process a whole directory to search for XML file to convert.
      Parameters:
      rootDir - the directory in which perform XML file search, MUST be either a
      Returns:
      true if process was sucessful, false otherwise
    • setDryRun

      public void setDryRun(boolean dryRun)
      Enable dryrun mode.

      If set to true, no operation will be performe, just log what would have been done.

      Parameters:
      dryRun - true to enable dryrun mode, false to perform operation normally. default is false
    • setBackupFiles

      public void setBackupFiles(boolean backupFiles)
      Enable or disable backup.

      Set whether XML and properties files should be backed up before any modification is performed.

      Parameters:
      backupFiles - true to create backup, false to overwrite file directly. default is true
    • setAppendComment

      public void setAppendComment(boolean appendComment)
      Enable or disable comment in properties.

      Set whether comment should be appended to properties file before writing I18N properties.

      Parameters:
      appendComment - true to append comment, false to write properties directly. default is true
    • setUpdateXmlFiles

      public void setUpdateXmlFiles(boolean updateXmlFiles)
      Enable or disable update of XML files.

      Set whether XML files should be updated to remove all I18N strings.

      Parameters:
      updateXmlFiles - true to update, false to leave file intact. default is true
    • logConfiguration

      public void logConfiguration()
      Log the current configuration.
    • main

      public static void main(String[] args)
      XmlToPropertiesConverter main entry point.
      Parameters:
      args - command line parameter