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);
}
}
}
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;
}
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());
}
}
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);
}
}
}
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());
}
Aggregations