Search in sources :

Example 6 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class BaseContextImpl method writeArticleMeta.

@Override
public void writeArticleMeta(String name, ObjectNode w, ObjectMapper mapper, boolean extended) throws APIException {
    File in = resolveArticle(name);
    try (FileReader fr = new FileReader(in)) {
        ObjectNode article = mapper.createObjectNode();
        w.set(name, article);
        XMLElement x = new CaseSensitiveXMLElement();
        x.parseFromReader(fr);
        article.put("name", name);
        interpretMeta(x, mapper, article, extended);
    } catch (FileNotFoundException e) {
        throw new APIException("Article " + name + " not found", e, APIErrorCode.ArticleNotFound);
    } catch (XMLParseException e) {
        throw new APIException("Article " + name + " is not valid XML", e, APIErrorCode.InternalError);
    } catch (IOException e) {
        throw new APIException("Autoclose on filereader failed", e, APIErrorCode.InternalError);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) APIException(com.dexels.navajo.article.APIException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) XMLParseException(com.dexels.navajo.document.nanoimpl.XMLParseException) File(java.io.File)

Example 7 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class BaseContextImpl method interpretArticle.

@Override
public void interpretArticle(File article, ArticleRuntime ac) throws APIException, NoJSONOutputException {
    XMLElement articleXml = new CaseSensitiveXMLElement();
    Reader r = null;
    try {
        r = new FileReader(article);
        articleXml.parseFromReader(r);
        ac.execute(this);
    } catch (IOException e) {
        throw new APIException(e.getMessage(), e, APIErrorCode.InternalError);
    } finally {
        if (r != null) {
            try {
                r.close();
            } catch (IOException e) {
                logger.error("Error: ", e);
            }
        }
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) APIException(com.dexels.navajo.article.APIException) Reader(java.io.Reader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 8 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method addCalledBy.

/**
 * @param xn
 * @param element
 */
private void addCalledBy(XMLElement xn, String element) {
    TreeSet<String> s = calledByScriptMap.get(element);
    if (s == null) {
        return;
    }
    for (Iterator<String> iter = s.iterator(); iter.hasNext(); ) {
        String include = iter.next();
        XMLElement xnincl = new CaseSensitiveXMLElement();
        xnincl.setName("calledby");
        xnincl.setAttribute("name", include);
        xn.addChild(xnincl);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 9 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method createTotalXML.

public XMLElement createTotalXML() {
    XMLElement x = new CaseSensitiveXMLElement();
    x.setName("metadata");
    for (Iterator<String> iter = scriptList.iterator(); iter.hasNext(); ) {
        String element = iter.next();
        addScriptElement(x, element);
    }
    return x;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 10 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class TslMetaDataHandler method toXml.

private XMLElement toXml(Map<String, TreeSet<String>> m, String topTagName, String tagname, String elementName, String attribute) {
    XMLElement x = new CaseSensitiveXMLElement();
    x.setName(topTagName);
    Set<Entry<String, TreeSet<String>>> s = m.entrySet();
    for (Iterator<Entry<String, TreeSet<String>>> iter = s.iterator(); iter.hasNext(); ) {
        Entry<String, TreeSet<String>> e = iter.next();
        String element = e.getKey();
        TreeSet<String> value = e.getValue();
        XMLElement xc = new CaseSensitiveXMLElement();
        xc.setName(tagname);
        xc.setAttribute("name", element);
        x.addChild(xc);
        for (Iterator<String> iterator = value.iterator(); iterator.hasNext(); ) {
            String ee = iterator.next();
            XMLElement xce = new CaseSensitiveXMLElement();
            xce.setName(elementName);
            xce.setAttribute(attribute, ee);
            xc.addChild(xce);
        }
    }
    return x;
}
Also used : Entry(java.util.Map.Entry) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) TreeSet(java.util.TreeSet) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Aggregations

CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)53 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)49 IOException (java.io.IOException)10 InputStreamReader (java.io.InputStreamReader)7 FileReader (java.io.FileReader)5 HashMap (java.util.HashMap)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 APIException (com.dexels.navajo.article.APIException)2 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 AdapterFieldDependency (com.dexels.navajo.mapping.compiler.meta.AdapterFieldDependency)1