use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class GetBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
if (getOperands().size() != 1) {
throw new TMLExpressionException(this, "Invalid number of operands");
}
if (!(getOperand(0) instanceof String)) {
throw new TMLExpressionException(this, "Invalid operand: " + getOperand(0));
}
Binary b = null;
String id = (String) getOperand(0);
SharedStoreInterface mss = SharedStoreFactory.getInstance();
try {
InputStream is = mss.getStream(PARENT_LOCATION, id);
b = new Binary(is);
is.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new TMLExpressionException(this, e.getMessage());
}
return b;
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class DecryptBinary method main.
public static void main(String[] args) throws Exception {
String s = "34PIf6+W/rTMIaGjBHVI4Q==";
DecryptBinary e = new DecryptBinary();
e.reset();
e.insertStringOperand("BBFW06E");
e.insertStringOperand(s);
Binary result = (Binary) e.evaluate();
System.err.println("result: " + new String(result.getData()));
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class GetReportFile method evaluate.
@Override
public Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
String script = DispatcherFactory.getInstance().getNavajoConfig().getScriptPath();
String reportName = getStringOperand(0);
java.io.File scriptDir = new java.io.File(script);
java.io.File report = new java.io.File(scriptDir, reportName + ".rptdesign");
try {
Binary b = new Binary(report);
return b;
} catch (Exception e) {
logger.error("File issue: {}", report.getAbsolutePath());
logger.error("Error resolving report: " + reportName + " from script path: " + script, e);
throw new TMLExpressionException("Wrapping: " + script, e);
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class IsValidXMLFile method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
if (getOperands().size() != 1) {
throw new TMLExpressionException(this, "One operand expected. ");
}
Object o = getOperand(0);
if (!(o instanceof Binary)) {
return Boolean.FALSE;
}
Binary b = (Binary) getOperand(0);
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
// the "parse" method also validates XML, will throw an exception if misformatted
@SuppressWarnings("unused") Document document = builder.parse(new InputSource(b.getDataAsStream()));
return Boolean.TRUE;
} catch (Throwable e) {
logger.info("Invalid XML file", e);
return Boolean.FALSE;
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class IsValidXMLFile method main.
public static void main(String[] args) throws Exception {
// FileInputStream fs = new FileInputStream((new File("c:/users/erik/appdata/local/temp/_aaacamt.xml")));
FileInputStream fs = new FileInputStream((new File("/home/chris/camt.xml")));
Binary b = new Binary(fs);
fs.close();
IsValidXMLFile i = new IsValidXMLFile();
i.reset();
i.insertBinaryOperand(b);
Object o = i.evaluate();
System.err.println("result valid xml file = " + o);
}
Aggregations