use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraOrganizationRepository method isMemberInOrganization.
@Override
public boolean isMemberInOrganization(String organizationId, String userId) throws TException {
checkOrganizationId(organizationId);
checkUserId(userId);
Statement query = createQueryToSeeIfMemberOfOrg(organizationId, userId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query for existence of Member [{]] in Organization [{}]", userId, organizationId, ex);
throw new OperationFailedException("Could not query for membership in Organization: " + ex.getMessage());
}
Row row = results.one();
checkRowIsPresent(row);
long count = row.getLong(0);
return count > 0L;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraOrganizationRepository method getOrganizationMembers.
@Override
public List<User> getOrganizationMembers(String organizationId) throws TException {
checkOrganizationId(organizationId);
Statement query = createQueryToGetOrganizationMembers(organizationId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to query for Organization Members: [{}]", organizationId, ex);
throw new OperationFailedException("Could not query for Organization Members: " + ex.getMessage());
}
List<User> members = Lists.create();
for (Row row : results) {
User member = userMapper.apply(row);
members.add(member);
}
LOG.debug("Found {} members in Org [{]]", members.size(), organizationId);
return members;
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraOrganizationRepository method saveMemberInOrganization.
@Override
public void saveMemberInOrganization(String organizationId, User user) throws TException {
checkOrganizationId(organizationId);
checkThat(user).throwing(InvalidArgumentException.class).is(validUser());
Statement insertStatement = createStatementToSaveMember(organizationId, user);
try {
cassandra.execute(insertStatement);
} catch (Exception ex) {
LOG.error("Failed to save Member [{}] in Organization [{}] in Cassandra: [{}]", user, organizationId, ex);
throw new OperationFailedException("Failed to save Member in Organization: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraOrganizationRepository method deleteOrganization.
@Override
public void deleteOrganization(String organizationId) throws TException {
deleteAllMembers(organizationId);
Statement deleteStatement = createStatementToDelete(organizationId);
try {
cassandra.execute(deleteStatement);
} catch (Exception ex) {
LOG.error("Failed to delete Organization in Cassandra: [{}]", organizationId, ex);
throw new OperationFailedException("Failed to delete Organization: " + ex.getMessage());
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraApplicationRepository method containsApplication.
@Override
public boolean containsApplication(String applicationId) throws TException {
checkApplicationId(applicationId);
Statement query = createQueryToCheckIfAppIdExists(applicationId);
ResultSet results;
try {
results = cassandra.execute(query);
} catch (Exception ex) {
LOG.error("Failed to check Application existence for [{}]", applicationId, ex);
throw new OperationFailedException("Could not check for application existence: " + applicationId);
}
Row row = results.one();
checkRowNotMissing(applicationId, row);
long count = row.getLong(0);
return count > 0L;
}
Aggregations