Example usage for com.amazonaws.services.sqs.model InvalidAttributeNameException InvalidAttributeNameException

List of usage examples for com.amazonaws.services.sqs.model InvalidAttributeNameException InvalidAttributeNameException

Introduction

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

Prototype

public InvalidAttributeNameException(String message) 

Source Link

Document

Constructs a new InvalidAttributeNameException with the specified error message.

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  .  jav  a2 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);
}