public String innerHandle()

in dynamodb-api/src/main/java/com/awssamples/iot/dynamodb/api/handlers/HandleIotGetEvent.java [23:58]


    public String innerHandle(String responseToken, final Map input, Option<String> uuidOption, Option<String> messageIdOption, Option<String> recipientIdOption) {
        String messageId = messageIdOption.get();
        String uuid = uuidOption.get();

        // Get the row with the exact UUID and message ID values
        HashMap<String, AttributeValue> key = HashMap.of(
                SharedHelper.UUID_DYNAMO_DB_COLUMN_NAME, AttributeValue.builder().s(uuid).build(),
                SharedHelper.MESSAGE_ID_DYNAMO_DB_COLUMN_NAME, AttributeValue.builder().s(messageId).build());

        DynamoDbClient dynamoDbClient = DynamoDbClient.create();

        GetItemRequest getItemRequest = GetItemRequest.builder()
                .tableName(SharedHelper.getTableName())
                .key(key.toJavaMap())
                .build();
        GetItemResponse getItemResponse = dynamoDbClient.getItem(getItemRequest);

        HashMap<String, AttributeValue> item = HashMap.ofAll(getItemResponse.item());

        // Return a payload on the response topic that contains the UUID and message ID
        HashMap<String, Object> payloadMap = HashMap.of(
                SharedHelper.UUID_DYNAMO_DB_COLUMN_NAME, uuidOption,
                SharedHelper.MESSAGE_ID_DYNAMO_DB_COLUMN_NAME, messageId);

        if (item.isEmpty()) {
            // The message was not found, include an error message
            payloadMap = payloadMap.put(SharedHelper.ERROR_KEY, MESSAGE_NOT_AVAILABLE);
        } else {
            // The message was found, merge it into our payload
            payloadMap = payloadMap.merge(item);
        }

        publishResponse(uuidOption, messageIdOption, Option.none(), responseToken, payloadMap);

        return "done";
    }