use of com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec in project athenz by yahoo.
the class DynamoDBSSHRecordStoreConnection method deleteSSHCertRecord.
@Override
public boolean deleteSSHCertRecord(String instanceId, String service) {
final String primaryKey = getPrimaryKey(instanceId, service);
try {
DeleteItemSpec deleteItemSpec = new DeleteItemSpec().withPrimaryKey(KEY_PRIMARY, primaryKey);
table.deleteItem(deleteItemSpec);
return true;
} catch (Exception ex) {
LOGGER.error("DynamoDB Delete Error for {}: {}/{}", primaryKey, ex.getClass(), ex.getMessage());
return false;
}
}
use of com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec in project spring-integration-aws by spring-projects.
the class DynamoDbMetaDataStore method remove.
@Override
public String remove(String key) {
Assert.hasText(key, "'key' must not be empty.");
awaitForActive();
Item item = this.table.deleteItem(new DeleteItemSpec().withPrimaryKey(KEY, key).withReturnValues(ReturnValue.ALL_OLD)).getItem();
return getValueIfAny(item);
}
use of com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec in project thunder by RohanNagar.
the class UsersDao method delete.
/**
* Delete a PilotUser in the data store.
*
* @param email The email of the user to delete.
* @return The PilotUser object that was deleted or {@code null} if the delete failed.
* @throws DatabaseException If the user is not found or if the database is down.
*/
public PilotUser delete(String email) {
checkNotNull(email);
// Get the item that will be deleted to return it
Item item;
try {
item = table.getItem("email", email);
} catch (AmazonClientException e) {
LOG.error("The database is currently unresponsive.", e);
throw new DatabaseException("The database is currently unavailable.", DatabaseError.DATABASE_DOWN);
}
DeleteItemSpec deleteItemSpec = new DeleteItemSpec().withPrimaryKey("email", email).withExpected(new Expected("email").exists());
try {
table.deleteItem(deleteItemSpec);
} catch (ConditionalCheckFailedException e) {
LOG.warn("The email {} was not found in the database.", email, e);
throw new DatabaseException("The user to delete was not found.", DatabaseError.USER_NOT_FOUND);
} catch (AmazonClientException e) {
LOG.error("The database is currently unresponsive.", e);
throw new DatabaseException("The database is currently unavailable.", DatabaseError.DATABASE_DOWN);
}
return fromJson(mapper, item.getJSON("document"));
}
Aggregations