Example usage for com.amazonaws.services.dynamodbv2.document.spec DeleteItemSpec DeleteItemSpec

List of usage examples for com.amazonaws.services.dynamodbv2.document.spec DeleteItemSpec DeleteItemSpec

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document.spec DeleteItemSpec DeleteItemSpec.

Prototype

public DeleteItemSpec() 

Source Link

Usage

From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.DynamoDocumentStoreTemplate.java

License:Apache License

@Override
public void delete(final Item item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers) {
    final ItemConfiguration itemConfiguration = getItemConfiguration(item.getClass());
    final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName();
    final DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
            .withPrimaryKey(getPrimaryKey(itemConfiguration.getItemId(item), itemConfiguration));

    final Table table = dynamoDBClient.getTable(tableName);
    table.deleteItem(deleteItemSpec);// ww  w.  j  a  v a  2  s .  c  o  m

    deleteUniqueConstraintIndexes(item, itemConfiguration);

}

From source file:com.exorath.service.party.service.DynamoDatabaseProvider.java

License:Apache License

/**
 * Removes a party from the database using its party_uuid
 *
 * @param uuid The party unique id/* w ww .jav  a 2 s  . c  om*/
 */
public void removeParty(String uuid) {
    if (getPartyFromId(uuid) != null) {
        DeleteItemSpec deleteItemSpec = new DeleteItemSpec();
        deleteItemSpec.withPrimaryKey(new KeyAttribute(PARTY_UUID, uuid));
        table.deleteItem(deleteItemSpec);
    }
}

From source file:com.yahoo.athenz.zts.cert.impl.DynamoDBCertRecordStoreConnection.java

License:Apache License

@Override
public boolean deleteX509CertRecord(String provider, String instanceId, String service) {

    final String primaryKey = getPrimaryKey(provider, instanceId, service);
    try {//  ww w.  jav  a 2  s . com
        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;
    }
}

From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java

License:Open Source License

@Override
public E getAndDelete(K key, long version) {
    Preconditions.checkNotNull(key, "keys must not be null");
    Preconditions.checkArgument(version >= -1L, "version must be greater than or equal to -1");
    final PrimaryKey pk = createKeys(key);
    final boolean conditioning = version >= 0;
    final String actualCondition;
    final Map<String, Object> valueMap;
    final Map<String, String> nameMap;

    if (conditioning) {
        Preconditions.checkState(versionProperty != null);
        actualCondition = String.format(Locale.ENGLISH, "%s and #version = :v", conditionalDeleteCondition);
        valueMap = Collections.singletonMap(":v", version);
        nameMap = Collections.singletonMap("#version", versionProperty);
    } else {// w  ww.  ja  v  a2s  . com
        actualCondition = conditionalDeleteCondition;
        valueMap = null;
        nameMap = null;
    }
    final DeleteItemSpec spec = new DeleteItemSpec().withPrimaryKey(pk).withNameMap(nameMap)
            .withValueMap(valueMap).withConditionExpression(actualCondition)
            .withReturnValues(ReturnValue.ALL_OLD);
    final Item item;
    try {
        item = table.deleteItem(spec).getItem();
    } catch (AmazonClientException e) {
        throw convertDynamoDBException(e, "delete",
                () -> convertConditionalCheckFailedExceptionForDelete(e, version, key));
    }
    return convertItemToDomain(item);
}

From source file:org.chodavarapu.jgitaws.repositories.RefRepository.java

License:Eclipse Distribution License

public Observable<Boolean> compareAndRemove(String repositoryName, Ref ref) {
    String expected = ref.isSymbolic() ? ref.getTarget().getName() : ref.getObjectId().name();
    logger.debug("Removing ref {} -> {} from repository {}", ref.getName(), expected, repositoryName);

    return configuration.getDynamoClient()
            .deleteItem(configuration.getRefsTableName(), new DeleteItemSpec()
                    .withPrimaryKey(new PrimaryKey(new KeyAttribute(REPOSITORY_NAME_ATTRIBUTE, repositoryName),
                            new KeyAttribute(NAME_ATTRIBUTE, ref.getName())))
                    .withConditionExpression("#target = :expected")
                    .withNameMap(new NameMap().with("#target", TARGET_ATTRIBUTE))
                    .withValueMap(new ValueMap().with(":expected", expected)))
            .map(v -> true).doOnNext(v -> logger.debug("Removed ref {} -> {} from repository {}", ref.getName(),
                    expected, repositoryName))
            .onErrorReturn(t -> false);
}

From source file:org.springframework.integration.aws.metadata.DynamoDbMetaDataStore.java

License:Apache License

@Override
public String remove(String key) {
    Assert.hasText(key, "'key' must not be empty.");

    awaitForActive();/*w  ww  . j  a v a2 s . c o m*/

    Item item = this.table
            .deleteItem(new DeleteItemSpec().withPrimaryKey(KEY, key).withReturnValues(ReturnValue.ALL_OLD))
            .getItem();

    return getValueIfAny(item);
}