use of com.dexels.navajo.sharedstore.SharedStoreInterface 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.sharedstore.SharedStoreInterface in project navajo by Dexels.
the class StoreBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
if (getOperands().size() != 2) {
throw new TMLExpressionException(this, "Invalid number of operands");
}
if (!(getOperand(0) instanceof String)) {
throw new TMLExpressionException(this, "Invalid operand: " + getOperand(0));
}
if (!(getOperand(1) instanceof Binary)) {
throw new TMLExpressionException(this, "Invalid operand: " + getOperand(1));
}
String id = (String) getOperand(0);
Binary n = (Binary) getOperand(1);
SharedStoreInterface mss = SharedStoreFactory.getInstance();
try {
OutputStream os = mss.getOutputStream(getAccess().getTenant(), GetBinary.PARENT_LOCATION, id, false);
n.write(os);
os.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new TMLExpressionException(this, e.getMessage());
}
return id;
}
Aggregations