use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class Dispatcher method getUsers.
public Access[] getUsers() {
Set<Access> all = new HashSet<>(com.dexels.navajo.server.DispatcherFactory.getInstance().getAccessSet());
Iterator<Access> iter = all.iterator();
List<Access> d = new ArrayList<>();
while (iter.hasNext()) {
Access a = iter.next();
d.add(a);
}
Access[] ams = new Access[d.size()];
return d.toArray(ams);
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class SimpleNode method lazyBiFunction.
public ContextExpression lazyBiFunction(List<String> problems, String expression, BinaryOperator<Operand> func, BiFunction<Optional<String>, Optional<String>, Boolean> acceptTypes, BiFunction<Optional<String>, Optional<String>, Optional<String>> returnTypeResolver, Function<String, FunctionClassification> functionClassifier, Function<String, Optional<Node>> mapResolver) {
ContextExpression expA = jjtGetChild(0).interpretToLambda(problems, expression, functionClassifier, mapResolver);
ContextExpression expB = jjtGetChild(1).interpretToLambda(problems, expression, functionClassifier, mapResolver);
Optional<String> aType = expA.returnType();
Optional<String> bType = expB.returnType();
boolean inputTypesValid = acceptTypes.apply(aType, bType);
if (!inputTypesValid) {
problems.add("Invalid input types in node: " + aType.orElse("unknown") + " and " + bType.orElse("unknown") + " in node type: " + this.getClass());
}
Optional<String> returnType = returnTypeResolver.apply(aType, bType);
return new ContextExpression() {
@Override
public Operand apply(Navajo doc, Message parentMsg, Message parentParamMsg, Selection parentSel, MappableTreeNode mapNode, TipiLink tipiLink, Access access, Optional<ImmutableMessage> immutableMessage, Optional<ImmutableMessage> paramMessage) {
Operand a = expA.apply(doc, parentMsg, parentParamMsg, parentSel, mapNode, tipiLink, access, immutableMessage, paramMessage);
Operand b = expB.apply(doc, parentMsg, parentParamMsg, parentSel, mapNode, tipiLink, access, immutableMessage, paramMessage);
return func.apply(a, b);
}
@Override
public boolean isLiteral() {
return expA.isLiteral() && expB.isLiteral();
}
@Override
public Optional<String> returnType() {
return returnType;
}
@Override
public String expression() {
return expression;
}
};
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class TestHttpResource method setUp.
@Before
public void setUp() throws Exception {
this.access = new Access();
access.setTenant("MYTENANT");
factory = new HttpResourceFactory();
component = new ResourceComponent();
RepositoryInstance instance = createStubInstance("test");
component.setRepositoryInstance(instance);
Map<String, Object> settings = new HashMap<String, Object>();
String url = TestConfig.HTTP_TEST_URL.getValue();
Assert.assertNotNull(url);
settings.put("url", url);
settings.put("name", "binstore");
settings.put("authorization", TestConfig.HTTP_TEST_TOKEN.getValue());
settings.put("secret", TestConfig.HTTP_TEST_SECRET.getValue());
settings.put("expire", "120");
component.activate(settings);
factory.addHttpResource(component, settings);
factory.activate();
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class GetBinaryFromStore method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
String resource = (String) getOperand(0);
if (resource == null) {
throw new TMLExpressionException("No resource defined in GetBinaryFromStore");
}
String bucket = (String) getOperand(1);
if (bucket == null) {
throw new TMLExpressionException("No bucket defined in GetBinaryFromStore");
}
Object idObj = getOperand(2);
String id = null;
if (idObj instanceof String) {
id = (String) idObj;
} else {
id = idObj.toString();
}
if (id == null) {
throw new TMLExpressionException("No id defined in GetBinaryFromStore");
}
Integer expiration = (Integer) super.getOperand(3);
if (expiration == null) {
throw new TMLExpressionException("No expiration defined in GetBinaryFromStore");
}
Access access = this.getAccess();
String tenant = access.getTenant();
HttpResourceFactory instance = HttpResourceFactory.getInstance();
if (instance == null) {
throw new TMLExpressionException("No HttpResourceFactory found in GetBinaryFromStore");
}
HttpResource httpResource = instance.getHttpResource(resource);
if (httpResource == null) {
throw new TMLExpressionException("HttpResource: " + resource + " not found in GetBinaryFromStore");
}
return httpResource.expiringURL(tenant, bucket, id, expiration);
}
use of com.dexels.navajo.script.api.Access in project navajo by Dexels.
the class AsyncMappable method log.
private final void log() {
if (DispatcherFactory.getInstance().getNavajoConfig().getStatisticsRunner() != null && !logged) {
Access a = AsyncStore.getInstance().getAccessObject(this.pointer);
if (a != null) {
// determine total time.
a.setFinished();
UserException ue = null;
if (isKilled()) {
ue = new UserException(-1, "Killed by client");
if (caught != null) {
a.setException(caught);
} else {
a.setException(ue);
}
}
logged = true;
DispatcherFactory.getInstance().getNavajoConfig().getStatisticsRunner().addAccess(a, this);
} else {
AuditLog.log(AuditLog.AUDIT_MESSAGE_ASYNC_RUNNER, "Warning: could not log async access due to missing access object!");
}
}
}
Aggregations