Search in sources :

Example 1 with Activity

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();
}
Also used : Feature(io.syndesis.server.endpoint.v1.handler.activity.Feature) Test(org.junit.Test)

Example 2 with Activity

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;
}
Also used : ArrayList(java.util.ArrayList) Activity(io.syndesis.server.endpoint.v1.handler.activity.Activity) JsonNode(com.fasterxml.jackson.databind.JsonNode) GetOptions(io.syndesis.server.jsondb.GetOptions) ByteArrayInputStream(java.io.ByteArrayInputStream) ActivityStep(io.syndesis.server.endpoint.v1.handler.activity.ActivityStep) Map(java.util.Map)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Activity (io.syndesis.server.endpoint.v1.handler.activity.Activity)1 ActivityStep (io.syndesis.server.endpoint.v1.handler.activity.ActivityStep)1 Feature (io.syndesis.server.endpoint.v1.handler.activity.Feature)1 GetOptions (io.syndesis.server.jsondb.GetOptions)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1