Package com.jalios.jcms.tools
Class XmlToPropertiesConverter
- java.lang.Object
-
- com.jalios.jcms.tools.XmlToPropertiesConverter
-
public class XmlToPropertiesConverter extends java.lang.ObjectHelper 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 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
- I18N tags and attribute are extracted and saved in the corresponding I18N properties of
the plugin, enforcing the properties' naming scheme expected by JCMS.
-
-
Field Summary
Fields Modifier and Type Field Description static intSTATUS_BAD_PARAMETERSXmlToPropertiesConverter exit code if invalid parameters were specifiedstatic intSTATUS_ERRORXmlToPropertiesConverter exit code in case any error occursstatic intSTATUS_OKXmlToPropertiesConverter exit code when everything went fine
-
Constructor Summary
Constructors Constructor Description XmlToPropertiesConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidlogConfiguration()Log the current configuration.static voidmain(java.lang.String[] args)XmlToPropertiesConverter main entry point.booleanprocessDirectory(java.io.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 Detail
-
STATUS_OK
public static final int STATUS_OK
XmlToPropertiesConverter exit code when everything went fine- See Also:
- Constant Field Values
-
STATUS_BAD_PARAMETERS
public static final int STATUS_BAD_PARAMETERS
XmlToPropertiesConverter exit code if invalid parameters were specified- See Also:
- Constant Field Values
-
STATUS_ERROR
public static final int STATUS_ERROR
XmlToPropertiesConverter exit code in case any error occurs- See Also:
- Constant Field Values
-
-
Method Detail
-
processDirectory
public boolean processDirectory(java.io.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(java.lang.String[] args)
XmlToPropertiesConverter main entry point.- Parameters:
args- command line parameter
-
-