String sDescriptorFile = getProperty("meta.descfile");
if (sDescriptorFile != null && sDescriptorFile.length() != 0)
{
StringWriter swriter = new StringWriter(0x2000);
XMLWriter writer = new XMLWriter(swriter);
if (s_logger.isDebugEnabled())
{
s_logger.debug("Writing the repository descriptor to file \"" + sDescriptorFile + "\"");
}
writer.openElement("Metadata");
writer.writeAttribute("version", "0");
writer.closeElement();
writer.startElement("Classes");
List metaclassList = new ArrayList(metadata.getMetaclassCount());
for (Iterator itr = metadata.getMetaclassIterator(); itr.hasNext();)
{
metaclassList.add(itr.next());
}
Collections.sort(metaclassList, new Comparator()
{
public int compare(Object o1, Object o2)
{
return ((Metaclass)o1).getName().compareToIgnoreCase(((Metaclass)o2).getName());
}
});
for (int i = 0; i < metaclassList.size(); ++i)
{
writer.openElement("ClassRef");
writer.writeAttribute("resource", "classes/" +
((Metaclass)metaclassList.get(i)).getName() + ".meta");
writer.closeEmptyElement();
}
writer.endElement("Classes");
writer.startElement("DataSources");
writer.openElement("DataSourceRef");
writer.writeAttribute("resource", "datasources/" + m_database.getName() + ".datasource");
writer.closeEmptyElement();
writer.endElement("DataSources");
writer.endElement("Metadata");
Writer fwriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(sDescriptorFile)), XMLUtil.ENCODING);
try
{