use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class TestNavajoMap method testSendThroughSetFalse.
@Test
public void testSendThroughSetFalse() throws MappableException, UserException {
Navajo inDoc = NavajoFactory.getInstance().createNavajo();
Property property = NavajoFactory.getInstance().createProperty(inDoc, "Meaning", INTEGER_PROPERTY, "42", 0, "", "out");
Message message = NavajoFactory.getInstance().createMessage(inDoc, "SendThrough");
message.addProperty(property);
inDoc.addMessage(message);
Message global = NavajoFactory.getInstance().createMessage(inDoc, "Global");
global.setScope(Message.MSG_SCOPE_GLOBAL);
inDoc.addMessage(global);
Message local = NavajoFactory.getInstance().createMessage(inDoc, "Local");
local.setScope(Message.MSG_SCOPE_LOCAL);
inDoc.addMessage(local);
// Initialize the navajomap.
DispatcherFactory.createDispatcher(new Dispatcher());
Access access = new Access();
access.setInDoc(inDoc);
access.setOutputDoc(outDoc);
map.load(access);
map.setSendThrough(false);
map.prepareOutDoc();
assertFalse(map.getSendThrough());
assertNull(map.outDoc.getMessage("SendThrough"));
assertEquals(Message.MSG_SCOPE_GLOBAL, map.outDoc.getMessage("Global").getScope());
assertNull(map.outDoc.getMessage("Local"));
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class ExistsBinaryInStore method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String resource = (String) super.getOperand(0);
if (resource == null) {
throw new TMLExpressionException("No resource defined in ExistsBinaryInStore");
}
String bucket = (String) super.getOperand(1);
if (bucket == null) {
throw new TMLExpressionException("No bucket defined in ExistsBinaryInStore");
}
String id = (String) super.getOperand(2);
if (id == null) {
throw new TMLExpressionException("No id defined in ExistsBinaryInStore");
}
Access access = this.getAccess();
if (access == null) {
throw new TMLExpressionException("No access defined in ExistsBinaryInStore");
}
String tenant = access.getTenant();
if (tenant == null) {
throw new TMLExpressionException("No tenant defined in ExistsBinaryInStore");
}
HttpResourceFactory instance = HttpResourceFactory.getInstance();
if (instance == null) {
throw new TMLExpressionException("No HttpResourceFactory found in ExistsBinaryInStore");
}
HttpResource httpResource = instance.getHttpResource(resource);
if (httpResource == null) {
throw new TMLExpressionException("HttpResource: " + resource + " found in ExistsBinaryInStore");
}
return httpResource.head(tenant, bucket, id).blockingGet().status() < 400;
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class StoreBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String resource = (String) super.getOperand(0);
if (resource == null) {
throw new TMLExpressionException("No resource defined in PutBinary");
}
String bucket = (String) super.getOperand(1);
if (bucket == null) {
throw new TMLExpressionException("No bucket defined in PutBinary");
}
Binary binary = (Binary) super.getOperand(2);
if (binary == null) {
throw new TMLExpressionException("No binary defined in PutBinary");
}
Access access = this.getAccess();
if (access == null) {
throw new TMLExpressionException("No access defined in PutBinary");
}
String tenant = access.getTenant();
if (tenant == null) {
throw new TMLExpressionException("No tenant defined in PutBinary");
}
HttpResourceFactory instance = HttpResourceFactory.getInstance();
if (instance == null) {
throw new TMLExpressionException("No HttpResourceFactory found in PutBinary");
}
HttpResource httpResource = instance.getHttpResource(resource);
if (httpResource == null) {
throw new TMLExpressionException("HttpResource: " + resource + " found in PutBinary");
}
return httpResource.put(tenant, bucket, binary.getHexDigest(), binary).blockingGet().status();
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class DeleteBinary method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String resource = (String) super.getOperand(0);
if (resource == null) {
throw new TMLExpressionException("No resource defined in DeleteBinary");
}
String bucket = (String) super.getOperand(1);
if (bucket == null) {
throw new TMLExpressionException("No bucket defined in DeleteBinary");
}
String id = (String) super.getOperand(2);
if (id == null) {
throw new TMLExpressionException("No id defined in GetBinary");
}
Access access = this.getAccess();
if (access == null) {
throw new TMLExpressionException("No access defined in DeleteBinary");
}
String tenant = access.getTenant();
if (tenant == null) {
throw new TMLExpressionException("No tenant defined in DeleteBinary");
}
HttpResourceFactory instance = HttpResourceFactory.getInstance();
if (instance == null) {
throw new TMLExpressionException("No HttpResourceFactory found in DeleteBinary");
}
HttpResource httpResource = instance.getHttpResource(resource);
if (httpResource == null) {
throw new TMLExpressionException("HttpResource: " + resource + " found in DeleteBinary");
}
return httpResource.delete(tenant, bucket, id).blockingGet().status();
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class TestMailResource method testAttach.
@Test
@Ignore
public void testAttach() throws MappableException, UserException {
ResourceMailAdapter rma = new ResourceMailAdapter();
try {
rma.load(new Access());
rma.setRecipients("dexels@gmail.com");
rma.setSender("dexels@gmail.com");
rma.setSubject("Attachment at " + new Date());
AttachementMap am = new AttachementMap();
am.setAttachContentType("image/jpeg");
am.setAttachContentDisposition("inline");
am.setAttachFileContent(new Binary(getClass().getResourceAsStream("monkey.jpeg")));
rma.setAttachment(am);
rma.setResourceName("junit.mail");
rma.store();
} catch (UserException e) {
Assert.assertEquals("javax.mail.AuthenticationFailedException", e.getCause().toString());
}
}
Aggregations