use of io.syndesis.server.endpoint.v1.handler.activity.Activity in project syndesis by syndesisio.
the class ActivityITCase method requestFeature.
@Test
public void requestFeature() throws IOException {
ResponseEntity<Feature> re = get("/api/v1/activity/feature", Feature.class);
Feature response = re.getBody();
assertThat(response.isEnabled()).isTrue();
}
use of io.syndesis.server.endpoint.v1.handler.activity.Activity in project syndesis by syndesisio.
the class DBActivityTrackingService method getActivities.
@Override
public List<Activity> getActivities(String integrationId, String from, Integer requestedLimit) throws IOException {
String path = "/activity/exchanges/" + integrationId;
int limit = 10;
if (requestedLimit != null) {
limit = requestedLimit;
}
if (limit > 1000) {
// max out to 1000 per request.
limit = 1000;
}
GetOptions options = new GetOptions().order(// reverse the order since we want most recent exchanges first.
GetOptions.Order.DESC).startAfter(from).limitToFirst(// allow paging
limit);
byte[] data = jsondb.getAsByteArray(path, options);
if (data == null) {
return new ArrayList<>();
}
JsonNode map = Json.reader().readTree(new ByteArrayInputStream(data));
List<Activity> rc = new ArrayList<>();
Iterator<Map.Entry<String, JsonNode>> i = map.fields();
while (i.hasNext()) {
Map.Entry<String, JsonNode> entry = i.next();
try {
String value = entry.getValue().textValue();
Activity activity = Json.reader().forType(Activity.class).readValue(value);
if (activity.getSteps() == null) {
activity.setSteps(new ArrayList<ActivityStep>());
}
rc.add(activity);
} catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") RuntimeException ignored) {
// We could get stuff like class cast exceptions..
LOG.debug("Could convert entry: {}", entry, ignored);
}
}
return rc;
}
Aggregations