KeySchemaElement hashKey = table.getKeySchema().getHashKeyElement();
KeySchemaElement rangeKey = table.getKeySchema().getRangeKeyElement();
AttributeValue hashItem = request.getItem().get(hashKey.getAttributeName());
AttributeValueType hashItemType = getAttributeValueType(hashItem);
if (hashItem == null || hashItemType != AttributeValueType.fromString(hashKey.getAttributeType())) {
throw new InternalServerErrorException("Missing hash key (" + hashKey.getAttributeName() + ") from item: " + request.getItem());
}
if (rangeKey != null) {
AttributeValue rangeItem = request.getItem().get(rangeKey.getAttributeName());
AttributeValueType rangeItemType = getAttributeValueType(rangeItem);
if (rangeItem == null || rangeItemType != AttributeValueType.fromString(rangeKey.getAttributeType())) {
throw new InternalServerErrorException("Missing range key (" + rangeKey.getAttributeName() + ") from item: " + request.getItem());
}
}
// Get current item if it exists
// Map<String, AttributeValue> item = table.getItem(getKeyValue(request.getItem().get(table.getHashKeyName())));