use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraMessageRepository method tryToExecute.
private ResultSet tryToExecute(Statement statement, String errorMessage) throws OperationFailedException {
ResultSet results;
try {
results = cassandra.execute(statement);
} catch (Exception ex) {
LOG.error("Failed to execute Cassandra statement: {}", statement, ex);
throw new OperationFailedException(errorMessage + " | " + ex.getMessage());
}
checkThat(results).throwing(OperationFailedException.class).usingMessage("Cassandra returned null response").is(notNull());
return results;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraApplicationRepository method deleteApplication.
@Override
public void deleteApplication(String applicationId) throws TException {
checkApplicationId(applicationId);
// Must fetch the full Application first
Application app = this.getById(applicationId);
Statement statement = createDeleteStatementFor(app);
try {
cassandra.execute(statement);
LOG.debug("Successfully deleted Application with ID {}", applicationId);
} catch (Exception ex) {
LOG.error("Failed to delete application with ID [{}] from Cassandra", applicationId, ex);
throw new OperationFailedException("Could not delete Application with ID: " + applicationId);
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraApplicationRepository method saveApplication.
@Override
public void saveApplication(Application application) throws TException {
checkThat(application).throwing(InvalidArgumentException.class).is(validApplication());
Statement statement = createStatementToSave(application);
try {
cassandra.execute(statement);
LOG.debug("Successfully saved Application in Cassandra: {}", application);
} catch (Exception ex) {
LOG.error("Failed to store Application in Cassandra: {}", application, ex);
throw new OperationFailedException("Could not save Application: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraApplicationRepository method getById.
@Override
public Application getById(String applicationId) throws TException {
checkApplicationId(applicationId);
Statement query = createQueryForAppWithId(applicationId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query for application with ID {}", applicationId, ex);
throw new OperationFailedException("Could not Query Application with ID: " + applicationId);
}
Row row = results.one();
checkRowNotMissing(applicationId, row);
Application app = createApplicationFromRow(row);
return app;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraFollowerRepository method followingExists.
@Override
public boolean followingExists(String userId, String applicationId) throws TException {
checkUserId(userId);
checkAppId(applicationId);
Statement query = createStatementToCheckIfFollowingExists(userId, applicationId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query for following between User: [{}] App: [{}]", userId, applicationId, ex);
throw new OperationFailedException("Could not query for following: " + ex.getMessage());
}
Row row = results.one();
checkRowExists(row);
long count = row.getLong(0);
return count > 0;
}
Aggregations