--- /dev/null
+/*
+ * Copyright
+ * 2011 axYus - http://www.axyus.com
+ * 2011 C.Marchand - christophe.marchand@axyus.com
+ *
+ * This file is part of XEMELIOS_NB.
+ *
+ * XEMELIOS_NB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS_NB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS_NB; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+package fr.gouv.finances.cp.buildtools.components;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.w3c.dom.Document;
+
+/**
+ * Construit le fichier installed-components pour le web.
+ * Syntaxe :
+ * <target-file> module-dir[ module-dir[ module-dir...]]
+ * @author cmarchand
+ */
+public class MakeInstalledComponents {
+
+ public static void main(String[] args) throws Exception {
+ DocumentBuilderFactory domFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
+ domFactory.setNamespaceAware(true);
+ XPathFactory xpathFactory = new net.sf.saxon.xpath.XPathFactoryImpl();
+ XPath xp = xpathFactory.newXPath();
+ Charset cs = Charset.forName("UTF-8");
+ OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(args[0]),cs);
+ osw.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xemelios-installed>\n");
+ for(int i=1;i<args.length;i++) {
+ String dirName = args[i];
+ File componentDefFile = new File(new File(dirName),"component-definition-properties.xml");
+ Document dom = domFactory.newDocumentBuilder().parse(componentDefFile);
+ String componentUri = xp.evaluate("/component/url/text()", dom);
+ String componentRelease = xp.evaluate("/component/release/text()", dom);
+ String componentDescription = xp.evaluate("/component/description/text()", dom);
+ osw.append(" <component uri=\"").append(componentUri).append("\" version=\"").append(componentRelease).append("\" description=\"").append(StringEscapeUtils.escapeXml(componentDescription)).append("\"/>\n");
+ }
+ osw.append("</xemelios-installed>\n");
+ osw.flush();
+ osw.close();
+ }
+
+}