Package com.jalios.jcms.tools
Class XmlToPropertiesConverter
java.lang.Object
com.jalios.jcms.tools.XmlToPropertiesConverter
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 :
- 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:langsuch as<label.../>,<title.../>and<description.../> labelList*attributes of enumerate fields
- XML tag with attribute
- All I18N contained in XML files are removed and updated xml files are saved.
XmlToPropertiesConverter MyPluginDirectory SomeOtherPluginDirectoryExample 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intXmlToPropertiesConverter exit code if invalid parameters were specifiedstatic final intXmlToPropertiesConverter exit code in case any error occursstatic final intXmlToPropertiesConverter exit code when everything went fine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLog the current configuration.static voidXmlToPropertiesConverter main entry point.booleanprocessDirectory(File rootDir) Process a whole directory to search for XML file to convert.voidsetAppendComment(boolean appendComment) Enable or disable comment in properties.voidsetBackupFiles(boolean backupFiles) Enable or disable backup.voidsetDryRun(boolean dryRun) Enable dryrun mode.voidsetUpdateXmlFiles(boolean updateXmlFiles) Enable or disable update of XML files.
-
Field Details
-
STATUS_OK
public static final int STATUS_OKXmlToPropertiesConverter exit code when everything went fine- See Also:
-
STATUS_BAD_PARAMETERS
public static final int STATUS_BAD_PARAMETERSXmlToPropertiesConverter exit code if invalid parameters were specified- See Also:
-
STATUS_ERROR
public static final int STATUS_ERRORXmlToPropertiesConverter exit code in case any error occurs- See Also:
-
-
Constructor Details
-
XmlToPropertiesConverter
public XmlToPropertiesConverter()
-
-
Method Details
-
processDirectory
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
XmlToPropertiesConverter main entry point.- Parameters:
args- command line parameter
-