Search in sources :

Example 1 with JaxenException

use of org.jaxen.JaxenException in project Asqatasun by Asqatasun.

the class KbCsvMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        FileReader fin = new FileReader(inCsv);
        BufferedReader reader = new BufferedReader(fin);
        if (!outCsv.getParentFile().exists()) {
            outCsv.getParentFile().mkdirs();
        }
        PrintWriter writer = new PrintWriter(outCsv);
        writer.println(formatCsvLine("name", "url", "campain", "test", "result"));
        String readed;
        while ((readed = reader.readLine()) != null) {
            // CSV params: 0=campain, 1=test
            String[] params = readed.split(";");
            if (params.length != 2) {
                getLog().warn("Incorrect line: " + readed);
                continue;
            }
            String ruleUrl = baseUrl + params[0] + "/" + params[1] + "/";
            for (int i = 0; i < KB_TEST_RESULTS.length; i++) {
                String url = ruleUrl + KB_TEST_RESULTS[i] + "/?lang=en";
                try {
                    for (String result : getUrls(url)) {
                        // Substring 28 to remove URL beginning
                        String targetName = sanitizeClassName(result.substring(28));
                        writer.println(formatCsvLine(targetName, result, params[0], params[1], TG_TEST_RESULTS[i]));
                    }
                } catch (JaxenException ex) {
                    getLog().warn("Unable to select URLs for address " + url, ex);
                } catch (JDOMException ex) {
                    getLog().warn("Invalid XML at " + url, ex);
                }
            }
        }
        writer.close();
        reader.close();
        fin.close();
    } catch (IOException ex) {
        throw new MojoExecutionException("Unexpected IO Exception", ex);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) JaxenException(org.jaxen.JaxenException) JDOMException(org.jdom.JDOMException)

Aggregations

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 JaxenException (org.jaxen.JaxenException)1 JDOMException (org.jdom.JDOMException)1