use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraFollowerRepository method getApplicationsFollowedBy.
@Override
public List<Application> getApplicationsFollowedBy(String userId) throws TException {
checkUserId(userId);
Statement query = createQueryForAppsFollowedBy(userId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query Cassandra for apps followed by User: [{}]", userId, ex);
throw new OperationFailedException("Could not find apps followed by user: " + ex.getMessage());
}
List<Application> apps = Lists.create();
for (Row row : results) {
Application app = createAppFromRow(row);
apps.add(app);
}
LOG.debug("Found {} apps followed by {}", apps.size(), userId);
return apps;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraFollowerRepository method deleteFollowing.
@Override
public void deleteFollowing(String userId, String applicationId) throws TException {
checkUserId(userId);
checkAppId(applicationId);
Statement deleteStatement = createDeleteStatementFor(userId, applicationId);
try {
cassandra.execute(deleteStatement);
} catch (Exception ex) {
LOG.error("Failed to delete the following between User: [{}] App: [{}]", userId, applicationId, ex);
throw new OperationFailedException("Could not delete following: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraInboxRepository method deleteAllMessagesForUser.
@Override
public void deleteAllMessagesForUser(String userId) throws TException {
checkUserId(userId);
Statement deleteStatement = createDeleteAllStatementFor(userId);
try {
cassandra.execute(deleteStatement);
} catch (Exception ex) {
LOG.error("Failed to delete all messages for User [{}] from Inbox", userId, ex);
throw new OperationFailedException("Could not delete message: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraInboxRepository method deleteMessageForUser.
@Override
public void deleteMessageForUser(String userId, String messageId) throws TException {
checkUserId(userId);
checkMessageId(messageId);
Statement deleteStatement = createDeleteStatementFor(userId, messageId);
try {
cassandra.execute(deleteStatement);
} catch (Exception ex) {
LOG.error("Failed to delete message [{}] for User [{}] from Inbox", messageId, userId, ex);
throw new OperationFailedException("Could not delete message: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraInboxRepository method containsMessageInInbox.
@Override
public boolean containsMessageInInbox(String userId, Message message) throws TException {
checkUserId(userId);
checkThat(message).throwing(InvalidArgumentException.class).is(validMessage());
Statement query = createQueryToCheckIfInInboxOf(userId, message);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query Cassandra for presence of message [{}] for User [{}]", message.messageId, userId, ex);
throw new OperationFailedException("Could not check if message exists: " + ex.getMessage());
}
Row row = results.one();
checkThat(row).throwing(OperationFailedException.class).usingMessage("Query for message failed").is(notNull());
long count = row.getLong(0);
return count > 0;
}
Aggregations