Example usage for com.amazonaws.services.dynamodbv2.model GetItemRequest withAttributesToGet

List of usage examples for com.amazonaws.services.dynamodbv2.model GetItemRequest withAttributesToGet

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model GetItemRequest withAttributesToGet.

Prototype


public GetItemRequest withAttributesToGet(java.util.Collection<String> attributesToGet) 

Source Link

Document

This is a legacy parameter.

Usage

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

License:Apache License

private Map<String, AttributeValue> readRaw(final ItemId itemId, final Class<? extends Item> itemClass,
        final Collection<String> attributes) {
    final ItemConfiguration itemConfiguration = getItemConfiguration(itemClass);
    final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName();
    final GetItemRequest getItemRequest = new GetItemRequest(tableName, generateKey(itemId, itemConfiguration));
    if (attributes.size() > 0) {
        getItemRequest.withAttributesToGet(attributes);

    }//from w  ww. ja v  a  2 s  . c o m

    final GetItemResult getItemResult;
    try {
        getItemResult = amazonDynamoDbClient.getItem(getItemRequest);
    } catch (final AmazonServiceException e) {
        throw new PersistenceResourceFailureException("Failure while attempting to read from DynamoDB table",
                e);
    }

    if (getItemResult == null || getItemResult.getItem() == null) {
        throw new NonExistentItemException(String.format("The item of type [%s] with id [%s] does not exist",
                itemClass.getName(), itemId));
    } else {
        return getItemResult.getItem();
    }
}