throw new AmazonServiceException(errors.toString());
}
// get information
String tableName = request.getTableName();
Key key = request.getKey();
Map<String, ExpectedAttributeValue> expected = request.getExpected();
Map<String, AttributeValueUpdate> attributesToUpdate = request.getAttributeUpdates();
String returnValues = request.getReturnValues();
UpdateItemResult result = new UpdateItemResult();
result.setConsumedCapacityUnits(0.5);
// Check to make sure table exists
if (!this.tables.containsKey(tableName)) {
throw new ResourceNotFoundException("The table you're currently trying to access (" + tableName + ") doesn't exists.");
}
// Check to make sure Key is valid
String hashKeyValue = getKeyValue(key.getHashKeyElement());
String rangeKeyValue = getKeyValue(key.getRangeKeyElement());
Map<String, AttributeValue> item = this.tables.get(tableName).getItem(hashKeyValue, rangeKeyValue);
// Check conditional put
validateExpected(request.getExpected(), item);
if (item == null) {
item = new HashMap<String, AttributeValue>();
item.put(this.tables.get(tableName).getHashKeyName(), key.getHashKeyElement());
if (key.getRangeKeyElement() != null) {
item.put(this.tables.get(tableName).getRangeKeyName(), key.getRangeKeyElement());
}
for (String sKey : attributesToUpdate.keySet()) {
if (attributesToUpdate.get(sKey).getValue() != null) {
item.put(sKey, attributesToUpdate.get(sKey).getValue());
}