Search in sources :

Example 21 with Application

use of tech.aroma.thrift.Application in project aroma-data-operations by RedRoma.

the class CassandraApplicationRepository method getRecentlyCreated.

@Override
public List<Application> getRecentlyCreated() throws TException {
    List<Application> apps = Lists.create();
    Statement query = createQueryForRecentlyCreatedApps();
    ResultSet results = null;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to query for recently created apps", ex);
        throw new OperationFailedException("Could not get recently created apps: " + ex.getMessage());
    }
    for (Row row : results) {
        Application app = createApplicationFromRow(row);
        apps.add(app);
    }
    LOG.debug("Found {} recently created apps", apps.size());
    return apps;
}
Also used : Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException)

Example 22 with Application

use of tech.aroma.thrift.Application in project aroma-data-operations by RedRoma.

the class CassandraApplicationRepository method getApplicationsOwnedBy.

@Override
public List<Application> getApplicationsOwnedBy(String userId) throws TException {
    checkThat(userId).throwing(InvalidArgumentException.class).is(validUserId());
    Statement query = createQueryForAppsOwnedBy(userId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to query for Apps owned by {}", userId, ex);
        throw new OperationFailedException("Could not determine Apps owned by user: " + userId);
    }
    List<Application> apps = Lists.create();
    for (Row row : results) {
        if (row == null) {
            continue;
        }
        Application app = createApplicationFromRow(row);
        apps.add(app);
    }
    LOG.debug("Found {} apps owned by user {}", apps.size(), userId);
    return apps;
}
Also used : Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException)

Aggregations

Application (tech.aroma.thrift.Application)22 Test (org.junit.Test)11 TException (org.apache.thrift.TException)6 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)5 User (tech.aroma.thrift.User)3 StringGenerators.alphabeticString (tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString)3 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)1 OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)1