Example usage for com.amazonaws.services.sqs.model GetQueueAttributesRequest getAttributeNames

List of usage examples for com.amazonaws.services.sqs.model GetQueueAttributesRequest getAttributeNames

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model GetQueueAttributesRequest getAttributeNames.

Prototype


public java.util.List<String> getAttributeNames() 

Source Link

Document

A list of attributes for which to retrieve information.

Usage

From source file:org.flite.mock.amazonaws.sqs.AmazonSQSMock.java

License:Open Source License

public GetQueueAttributesResult getQueueAttributes(final GetQueueAttributesRequest request)
        throws AmazonServiceException, AmazonClientException {
    if (request == null) {
        throw new AmazonClientException("Null GetQueueAttributesRequest");
    }//from  w ww  .j  a v  a 2 s .c  om
    final String queueUrl = request.getQueueUrl();
    checkURLForException(queueUrl);
    for (final String attb : request.getAttributeNames()) {
        checkStringForExceptionMarker(attb);
        if (!attbs.contains(attb)) {
            throw new InvalidAttributeNameException("Invalid Attribute Name: " + attb);
        }
    }

    final Map<String, String> results = new ConcurrentHashMap<String, String>();
    final boolean hasAll = request.getAttributeNames().contains(ALL);
    if (hasAll || request.getAttributeNames().contains(NUM_MSGS)) {
        results.put(NUM_MSGS, allQueues.get(queueUrl) == null ? "0" : allQueues.get(queueUrl).size() + "");
    }
    if (hasAll || request.getAttributeNames().contains(NUM_NOT_VISIBLE)) {
        results.put(NUM_NOT_VISIBLE,
                retrievedMessages.get(queueUrl) == null ? "0" : retrievedMessages.get(queueUrl).size() + "");
    }
    if (hasAll || request.getAttributeNames().contains(VIS_TIMEOUT)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(CREATED_TIMESTAMP)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(MODIFIED_TIMESTAMP)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(POLICY)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(MAX_SIZE)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(RETENTION)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(ARN)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(MSGS_DELAYED)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }
    if (hasAll || request.getAttributeNames().contains(DELAY_SEC)) {
        throw new RuntimeException(NYI_EXCEPTION);
    }

    return new GetQueueAttributesResult().withAttributes(results);
}