Example usage for com.amazonaws.services.simpledb.model GetAttributesRequest GetAttributesRequest

List of usage examples for com.amazonaws.services.simpledb.model GetAttributesRequest GetAttributesRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.simpledb.model GetAttributesRequest GetAttributesRequest.

Prototype

public GetAttributesRequest() 

Source Link

Document

Default constructor for GetAttributesRequest object.

Usage

From source file:com.aipo.aws.simpledb.SimpleDB.java

License:Open Source License

private static Integer counterJob(String domain) {
    AmazonSimpleDB client = getClient();
    GetAttributesRequest getAttributesRequest = new GetAttributesRequest();
    getAttributesRequest.setDomainName(DEFAULT_COUNTER_DOMAIN);
    getAttributesRequest.setItemName(domain);
    getAttributesRequest.setConsistentRead(true);
    Integer count = null;//from w  ww  .j  a  va 2  s .  c om
    try {
        GetAttributesResult attributes = client.getAttributes(getAttributesRequest);
        List<Attribute> list = attributes.getAttributes();
        for (Attribute item : list) {
            if ("c".equals(item.getName())) {
                try {
                    count = Integer.valueOf(item.getValue());
                } catch (Throwable ignore) {

                }
            }
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }

    if (count == null) {
        CreateDomainRequest createDomainRequest = new CreateDomainRequest(DEFAULT_COUNTER_DOMAIN);
        client.createDomain(createDomainRequest);
        count = 0;
    }

    int next = count + 1;
    PutAttributesRequest putAttributesRequest = new PutAttributesRequest();
    putAttributesRequest.setDomainName(DEFAULT_COUNTER_DOMAIN);
    putAttributesRequest.setItemName(domain);
    List<ReplaceableAttribute> attr = new ArrayList<ReplaceableAttribute>();
    attr.add(new ReplaceableAttribute("c", String.valueOf(next), true));
    putAttributesRequest.setAttributes(attr);
    UpdateCondition updateCondition = new UpdateCondition();
    if (next == 1) {
        updateCondition.setExists(false);
        updateCondition.setName("c");
    } else {
        updateCondition.setExists(true);
        updateCondition.setName("c");
        updateCondition.setValue(String.valueOf(count));
    }
    putAttributesRequest.setExpected(updateCondition);

    client.putAttributes(putAttributesRequest);

    return next;
}

From source file:com.zotoh.cloudapi.aws.SDB.java

License:Open Source License

@Override
public Iterable<KeyValuePair> getKeyValuePairs(String domain, String item, boolean consistentRead)
        throws CloudException, InternalException {
    tstEStrArg("domain-name", domain);
    tstEStrArg("item-name", item);
    GetAttributesResult res = _svc.getCloud().getSDB().getAttributes(new GetAttributesRequest()
            .withDomainName(domain).withItemName(item).withConsistentRead(consistentRead));
    List<Attribute> lst = res == null ? null : res.getAttributes();
    return toKPs(lst);
}

From source file:org.apache.camel.component.aws.sdb.GetAttributesCommand.java

License:Apache License

public void execute() {
    GetAttributesRequest request = new GetAttributesRequest().withDomainName(determineDomainName())
            .withItemName(determineItemName()).withConsistentRead(determineConsistentRead())
            .withAttributeNames(determineAttributeNames());
    log.trace("Sending request [{}] for exchange [{}]...", request, exchange);

    GetAttributesResult result = this.sdbClient.getAttributes(request);

    log.trace("Received result [{}]", result);

    Message msg = getMessageForResponse(exchange);
    msg.setHeader(SdbConstants.ATTRIBUTES, result.getAttributes());
}