in src/main/java/com/amazonaws/services/dynamodbv2/transactions/TransactionItem.java [87:134]
protected TransactionItem(String txId, TransactionManager txManager, boolean insert, Map<String, AttributeValue> txItem) throws TransactionNotFoundException {
this.txManager = txManager;
// Initialize txId, txKey, and txItem
if(txId != null) {
// Validate mutual exclusivity of inputs
if(txItem != null) {
throw new TransactionException(txId, "When providing txId, txItem must be null");
}
this.txId = txId;
Map<String, AttributeValue> txKeyMap = new HashMap<String, AttributeValue>(1);
txKeyMap.put(AttributeName.TXID.toString(), new AttributeValue(txId));
this.txKey = Collections.unmodifiableMap(txKeyMap);
if(insert) {
this.txItem = insert();
} else {
this.txItem = get();
if(this.txItem == null) {
throw new TransactionNotFoundException(this.txId);
}
}
} else if(txItem != null) {
// Validate mutual exclusivity of inputs
if(insert) {
throw new TransactionException(txId, "When providing a txItem, insert must be false");
}
this.txItem = txItem;
if(! isTransactionItem(txItem)) {
throw new TransactionException(txId, "txItem is not a transaction item");
}
this.txId = txItem.get(AttributeName.TXID.toString()).getS();
Map<String, AttributeValue> txKeyMap = new HashMap<String, AttributeValue>(1);
txKeyMap.put(AttributeName.TXID.toString(), new AttributeValue(this.txId));
this.txKey = Collections.unmodifiableMap(txKeyMap);
} else {
throw new TransactionException(null, "Either txId or txItem must be specified");
}
// Initialize the version
AttributeValue txVersionVal = this.txItem.get(AttributeName.VERSION.toString());
if(txVersionVal == null || txVersionVal.getN() == null) {
throw new TransactionException(this.txId, "Version number is not present in TX record");
}
version = Integer.parseInt(txVersionVal.getN());
// Build the requests structure
loadRequests();
}