use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class OutVariablesProjectIT method testReject.
@Test
public void testReject() throws Exception {
ProjectsApi projectsApi = new ProjectsApi(getApiClient());
String orgName = "Default";
String projectName = "project_" + System.currentTimeMillis();
projectsApi.createOrUpdate(orgName, new ProjectEntry().setName(projectName));
// ---
byte[] payload = archive(ProcessIT.class.getResource("example").toURI());
try {
Map<String, Object> input = new HashMap<>();
input.put("org", orgName);
input.put("project", projectName);
input.put("archive", payload);
input.put("out", "x,y,z");
start(input);
fail("should fail");
} catch (ApiException e) {
}
}
use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class EventRecordingExecutionListener method afterCommand.
@Override
public Result afterCommand(Runtime runtime, VM vm, State state, ThreadId threadId, Command cmd) {
if (!eventConfiguration.recordEvents()) {
return Result.CONTINUE;
}
if (!(cmd instanceof StepCommand)) {
return Result.CONTINUE;
}
StepCommand<?> s = (StepCommand<?>) cmd;
if (s.getStep() instanceof TaskCall || s.getStep() instanceof Expression) {
return Result.CONTINUE;
}
ProcessDefinition pd = runtime.getService(ProcessDefinition.class);
Location loc = s.getStep().getLocation();
Map<String, Object> m = new HashMap<>();
m.put("processDefinitionId", ProcessDefinitionUtils.getCurrentFlowName(pd, s.getStep()));
m.put("fileName", loc.fileName());
m.put("line", loc.lineNum());
m.put("column", loc.column());
m.put("description", getDescription(s.getStep()));
m.put("correlationId", s.getCorrelationId());
ProcessEventRequest req = new ProcessEventRequest();
// TODO constants
req.setEventType("ELEMENT");
req.setData(m);
req.setEventDate(Instant.now().atOffset(ZoneOffset.UTC));
try {
eventsApi.event(processInstanceId.getValue(), req);
} catch (ApiException e) {
log.warn("afterCommand [{}] -> error while sending an event to the server: {}", cmd, e.getMessage());
}
return Result.CONTINUE;
}
use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class TaskCallEventRecordingListener method send.
private void send(Map<String, Object> event) {
ProcessEventRequest req = new ProcessEventRequest();
// TODO should it be in the constants?
req.setEventType("ELEMENT");
req.setData(event);
req.setEventDate(Instant.now().atOffset(ZoneOffset.UTC));
try {
eventsApi.event(processInstanceId.getValue(), req);
} catch (ApiException e) {
log.warn("send [{}] -> error while sending an event to the server: {}", event, e.getMessage());
}
}
use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class SecretServiceImpl method encryptString.
@Override
public String encryptString(Context ctx, String instanceId, String orgName, String projectName, String value) throws Exception {
ApiClientConfiguration cfg = ApiClientConfiguration.builder().sessionToken(ContextUtils.getSessionToken(ctx)).txId(UUID.fromString(instanceId)).build();
ApiClient c = clientFactory.create(cfg);
String path = "/api/v1/org/" + orgName + "/project/" + projectName + "/encrypt";
Map<String, String> headerParams = new HashMap<>();
headerParams.put("Content-Type", "text/plain;charset=UTF-8");
ApiResponse<EncryptValueResponse> r = ClientUtils.postData(c, path, value, headerParams, EncryptValueResponse.class);
if (r.getStatusCode() == 200 && r.getData().isOk()) {
return r.getData().getData();
}
throw new ApiException("Error encrypting string. Status code:" + r.getStatusCode() + " Data: " + r.getData());
}
use of com.walmartlabs.concord.ApiException in project concord by walmartlabs.
the class ConcordTaskCommon method getOutVars.
@SuppressWarnings("unchecked")
private Map<String, Object> getOutVars(String baseUrl, String apiKey, UUID processId) throws Exception {
return withClient(baseUrl, apiKey, client -> {
ProcessApi api = new ProcessApi(client);
File f = null;
try {
f = api.downloadAttachment(processId, "out.json");
ObjectMapper om = new ObjectMapper();
return om.readValue(f, Map.class);
} catch (ApiException e) {
if (e.getCode() == 404) {
return Collections.emptyMap();
}
log.error("Error while reading the out variables", e);
throw e;
} finally {
IOUtils.delete(f);
}
});
}
Aggregations