Search in sources :

Example 1 with XMLParseException

use of com.dexels.navajo.document.nanoimpl.XMLParseException 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 2 with XMLParseException

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

the class KMLMap method getKmlData.

/**
 * TODO: Make thread safe
 * @return
 */
public Binary getKmlData() {
    try {
        if (!isPointFile()) {
            File kmz = createKmlFile(inMessage);
            myKmzData = new Binary(kmz, false);
            kmz.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kmz");
            fd.addMimeType("application/vnd.google-earth.kmz");
            myKmzData.setMimeType("application/vnd.google-earth.kmz");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        } else {
            File kml = createPointKmlFile(inMessage, messagePath);
            myKmzData = new Binary(kml, false);
            kml.delete();
            FormatDescription fd = new FormatDescription();
            fd.addFileExtension("kml");
            fd.addMimeType("application/vnd.google-earth.kml");
            myKmzData.setMimeType("application/vnd.google-earth.kml");
            myKmzData.setFormatDescriptor(fd);
            return myKmzData;
        }
    } catch (XMLParseException e) {
        logger.error("Error: ", e);
    } catch (IOException e) {
        logger.error("Error: ", e);
    }
    return null;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) IOException(java.io.IOException) FormatDescription(com.dexels.navajo.document.metadata.FormatDescription) XMLParseException(com.dexels.navajo.document.nanoimpl.XMLParseException) File(java.io.File)

Example 3 with XMLParseException

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

the class KMLMap method main.

public static void main(String[] args) {
    KMLMap hm = new KMLMap();
    hm.setColorizer("whiteorange");
    hm.setLegendHeight(250);
    hm.setLegendSteps(7);
    hm.setTitle("Aantal mannekes (Per 1000)");
    // hm.setMin(0.05);
    // hm.setMax(0.11);
    hm.setMinLegend(0);
    hm.setMaxLegend(1000);
    Gemeente2Population.init();
    try {
        // Test t = new Test();
        // hm.inMessage = t.createTestMessage();
        FileInputStream fis = new FileInputStream("InitGenerateClubDataKnvb.tml");
        Navajo n = NavajoFactory.getInstance().createNavajo(fis);
        fis.close();
        hm.inMessage = n;
        // try{
        // n.write(System.err);
        // }catch(Exception e){
        // System.err.println("Null navajo");
        // }
        File xxx = hm.createPointKmlFile(hm.inMessage, "Clubs");
        logger.info("Saved file: " + xxx.getAbsolutePath());
    // File res = new File("c:/clubs.kml");
    // FileWriter fw = new FileWriter(res);
    // xxx.write(fw);
    // fw.flush();
    // fw.close();
    // System.err.println("KML Run finished...: "+res);
    } catch (XMLParseException e) {
        logger.error("Error: ", e);
    } catch (IOException e) {
        logger.error("Error: ", e);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) IOException(java.io.IOException) XMLParseException(com.dexels.navajo.document.nanoimpl.XMLParseException) File(java.io.File) AbstractKMLMap(com.dexels.navajo.geo.impl.AbstractKMLMap) FileInputStream(java.io.FileInputStream)

Aggregations

XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)3 File (java.io.File)3 IOException (java.io.IOException)3 APIException (com.dexels.navajo.article.APIException)1 Navajo (com.dexels.navajo.document.Navajo)1 FormatDescription (com.dexels.navajo.document.metadata.FormatDescription)1 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)1 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)1 Binary (com.dexels.navajo.document.types.Binary)1 AbstractKMLMap (com.dexels.navajo.geo.impl.AbstractKMLMap)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1