use of tech.aroma.thrift.exceptions.OperationFailedException 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;
}
use of tech.aroma.thrift.exceptions.OperationFailedException 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;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraApplicationRepository method getApplicationsByOrg.
@Override
public List<Application> getApplicationsByOrg(String orgId) throws TException {
checkThat(orgId).throwing(InvalidArgumentException.class).is(validOrgId());
Statement query = createQueryForAppsWithOrg(orgId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to find Apps by Org with ID [{}]", orgId, ex);
throw new OperationFailedException("Could not find Org's Apps: " + orgId);
}
List<Application> apps = Lists.create();
for (Row row : results) {
Application app = createApplicationFromRow(row);
apps.add(app);
}
LOG.debug("Found {} apps in Org {}", apps.size(), orgId);
return apps;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraFollowerRepository method saveFollowing.
@Override
public void saveFollowing(User user, Application application) throws TException {
checkThat(user).throwing(InvalidArgumentException.class).is(validUser());
checkThat(application).throwing(InvalidArgumentException.class).is(validApplication());
Statement insertStatement = createStatementToSaveFollowing(user, application);
try {
cassandra.execute(insertStatement);
} catch (Exception ex) {
LOG.error("Failed to save following: User: [{}] App: [{}]", user.userId, application.applicationId, ex);
throw new OperationFailedException("Could not save following in Cassandra: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraFollowerRepository method getApplicationFollowers.
@Override
public List<User> getApplicationFollowers(String applicationId) throws TException {
checkAppId(applicationId);
Statement query = createQueryForFollowersOfApp(applicationId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query for App's followed: App: [{}]", applicationId, ex);
throw new OperationFailedException("Could not query for App's Followers: " + ex.getMessage());
}
List<User> followers = Lists.create();
for (Row row : results) {
User follower = createUserFromRow(row);
followers.add(follower);
}
LOG.debug("Found {} Users followed App [{}]", followers.size(), applicationId);
return followers;
}
Aggregations