Search in sources :

Example 6 with MappableException

use of com.dexels.navajo.script.api.MappableException in project navajo by Dexels.

the class BIRTXmlMap method load.

/**
 * A Mappable class is executed by the Navajo Mapping Environment.
 *
 * @param parms
 *            Parameters
 * @param inMessage
 *            Navajo
 * @param access
 *            Access
 * @param config
 *            NavajoConfig
 * @throws MappableException
 * @throws UserException
 */
@Override
public void load(Access access) throws MappableException, UserException {
    // paths
    inNavajo = access.getInDoc();
    InputStream in = null;
    try {
        in = DispatcherFactory.getInstance().getNavajoConfig().getConfig("birt.xml");
    } catch (IOException e) {
        throw new MappableException("No birt.xml configuration file found!");
    }
    if (in == null) {
        throw new MappableException("No birt.xml configuration file found!");
    }
    try {
        Document d = XMLDocumentUtils.createDocument(in, false);
        Element a = (Element) XMLutils.findNode(d, "viewerReportDir");
        if (a != null) {
            viewerReportDir = a.getAttribute("value");
            File f = new File(viewerReportDir);
            if (!f.exists()) {
                throw new MappableException("viewerReportDir:" + viewerReportDir + " not found!");
            }
        } else {
            throw new MappableException("No tag: viewerReportDir found in birt.xml");
        }
        Element b = (Element) XMLutils.findNode(d, "viewerUrl");
        if (b != null) {
            viewerUrl = b.getAttribute("value");
        // check url?
        } else {
            throw new MappableException("No tag: viewerUrl found in birt.xml");
        }
        Element c = (Element) XMLutils.findNode(d, "reportDir");
        if (c != null) {
            reportDir = c.getAttribute("value");
            File f = new File(reportDir);
            if (!f.exists()) {
                throw new MappableException("reportDir:" + reportDir + " not found!");
            }
        } else {
            throw new MappableException("No tag: reportDir found in birt.xml");
        }
        logger.debug("Birt configured succesfully!");
    } catch (NavajoException e1) {
        throw new MappableException("Error reading birt.xml configuration file!");
    } finally {
        try {
            in.close();
        } catch (IOException e) {
            logger.error("Error: ", e);
        }
    }
}
Also used : MappableException(com.dexels.navajo.script.api.MappableException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) NavajoException(com.dexels.navajo.document.NavajoException) IOException(java.io.IOException) Document(org.w3c.dom.Document) File(java.io.File)

Example 7 with MappableException

use of com.dexels.navajo.script.api.MappableException in project navajo by Dexels.

the class ElasticSearchQueryAdapter method getEsrarray.

public ElasticSearchResult[] getEsrarray() throws MappableException {
    try {
        result = ElasticSearchQueryFactory.getInstance().search(keyword);
        for (ElasticSearchResult element : result) {
            System.out.println("id: " + element.id);
            System.out.println("score: " + element.score);
            System.out.println("filename: " + element.fileName);
        }
    } catch (IOException e) {
        throw new MappableException("error " + e);
    }
    return result;
}
Also used : ElasticSearchResult(com.dexels.navajo.elasticsearch.impl.ElasticSearchResult) MappableException(com.dexels.navajo.script.api.MappableException) IOException(java.io.IOException)

Example 8 with MappableException

use of com.dexels.navajo.script.api.MappableException in project navajo by Dexels.

the class XMLStreamMap method load.

// @Override
@Override
public void load(Access access) throws MappableException, UserException {
    try {
        content = new Binary();
        OutputStream ob = content.getOutputStream();
        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        OutputStreamWriter out = new OutputStreamWriter(ob, "UTF8");
        xtw = xof.createXMLStreamWriter(out);
        xtw.writeStartDocument("UTF-8", "1.0");
        xtw.setPrefix("", docSpecUrl);
        xtw.writeCharacters("\n");
    } catch (Exception e) {
        throw new UserException(450, e.getMessage());
    }
}
Also used : XMLOutputFactory(javax.xml.stream.XMLOutputFactory) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Binary(com.dexels.navajo.document.types.Binary) UserException(com.dexels.navajo.script.api.UserException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException)

Example 9 with MappableException

use of com.dexels.navajo.script.api.MappableException in project navajo by Dexels.

the class SQLMaintenanceMap method setDatasources.

@SuppressWarnings("deprecation")
public synchronized void setDatasources(SQLMapDatasourceMap[] datasources) throws UserException, NavajoException, MappableException {
    if (noAccess)
        throw new MappableException("Cannot enter maintenance object in write mode, already in use");
    saveConfigFile(true);
    for (int i = 0; i < datasources.length; i++) {
        SQLMapDatasourceMap datasource = datasources[i];
        this.dirty = true;
        Message msg = sqlMapConfigFile.getMessage("datasources").getMessage(datasource.getDatasourceName());
        if (msg == null) {
            msg = NavajoFactory.getInstance().createMessage(sqlMapConfigFile, datasource.getDatasourceName());
            sqlMapConfigFile.getMessage("datasources").addMessage(msg);
            Property prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "url", Property.STRING_PROPERTY, datasource.url, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "logfile", Property.STRING_PROPERTY, datasource.logfile, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "max_connections", Property.INTEGER_PROPERTY, "" + datasource.max_connections, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "min_connections", Property.INTEGER_PROPERTY, "" + datasource.min_connections, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "password", Property.STRING_PROPERTY, datasource.password, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "refresh", Property.STRING_PROPERTY, datasource.refresh + "", 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "username", Property.STRING_PROPERTY, datasource.username, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
            prop = NavajoFactory.getInstance().createProperty(sqlMapConfigFile, "driver", Property.STRING_PROPERTY, datasource.driver, 0, "", Property.DIR_IN);
            msg.addProperty(prop);
        } else {
            msg.getProperty("url").setValue(datasource.getUrl());
            msg.getProperty("logfile").setValue(datasource.getLogfile());
            msg.getProperty("max_connections").setValue(datasource.max_connections + "");
            msg.getProperty("min_connections").setValue(datasource.min_connections + "");
            msg.getProperty("password").setValue(datasource.password);
            msg.getProperty("refresh").setValue(datasource.refresh + "");
            msg.getProperty("username").setValue(datasource.username);
            msg.getProperty("driver").setValue(datasource.driver);
        }
        if (dirty) {
            saveConfigFile(false);
            // reload sqlmap.xml
            SQLMap sqlMap = new SQLMap();
            sqlMap.load(access);
            sqlMap.setReload(datasource.datasourceName);
        }
    }
}
Also used : MappableException(com.dexels.navajo.script.api.MappableException) Message(com.dexels.navajo.document.Message) SQLMapDatasourceMap(com.dexels.navajo.adapter.sqlmap.SQLMapDatasourceMap) Property(com.dexels.navajo.document.Property)

Example 10 with MappableException

use of com.dexels.navajo.script.api.MappableException in project navajo by Dexels.

the class SQLMaintenanceMap method load.

@Override
public void load(Access access) throws MappableException, UserException {
    // if (noAccess)
    // throw new MappableException("Cannot enter maintenance object, already in use");
    setNoAccess(true);
    logger.debug("In SQLMaintenanceMap");
    this.access = access;
    this.config = DispatcherFactory.getInstance().getNavajoConfig();
    try {
        // sqlMapConfigFile = XMLutils.createNavajoInstance(config. getConfigPath() + "/sqlmap.xml");
        sqlMapConfigFile = config.readConfig("/sqlmap.xml");
    } catch (Exception e) {
        throw new MappableException(e.getMessage());
    }
// logger.debug(sqlMapConfigFile.toString());
}
Also used : MappableException(com.dexels.navajo.script.api.MappableException) IOException(java.io.IOException) NavajoException(com.dexels.navajo.document.NavajoException) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException)

Aggregations

MappableException (com.dexels.navajo.script.api.MappableException)16 UserException (com.dexels.navajo.script.api.UserException)10 Message (com.dexels.navajo.document.Message)8 NavajoException (com.dexels.navajo.document.NavajoException)5 IOException (java.io.IOException)5 Property (com.dexels.navajo.document.Property)4 Navajo (com.dexels.navajo.document.Navajo)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 ArrayList (java.util.ArrayList)2 FileLineMap (com.dexels.navajo.adapter.filemap.FileLineMap)1 AttachmentMapInterface (com.dexels.navajo.adapter.mailmap.AttachmentMapInterface)1 ConnectionBrokerManager (com.dexels.navajo.adapter.sqlmap.ConnectionBrokerManager)1 RecordMap (com.dexels.navajo.adapter.sqlmap.RecordMap)1 ResultSetMap (com.dexels.navajo.adapter.sqlmap.ResultSetMap)1 SQLMapDatasourceMap (com.dexels.navajo.adapter.sqlmap.SQLMapDatasourceMap)1 ClientInterface (com.dexels.navajo.client.ClientInterface)1 Selection (com.dexels.navajo.document.Selection)1 Binary (com.dexels.navajo.document.types.Binary)1 ElasticSearchResult (com.dexels.navajo.elasticsearch.impl.ElasticSearchResult)1