if (puzzleInfo.getId() != null) {
throw new ObjectAlreadyCreatedException("Puzzle info already has an id: " + puzzleInfo.getId());
}
Objectify ofyTxn = newOfyTransaction();
try {
ofyTxn.put(puzzleInfo);
puzzleDetails.attachToPuzzleInfo(puzzleInfo);
ofyTxn.put(puzzleDetails);
puzzleInfo.setPuzzleDetailsId(puzzleDetails.getId());
ofyTxn.put(puzzleInfo);
puzzle.attachToPuzzleDetails(puzzleDetails);
ofyTxn.put(puzzle);
puzzleDetails.setPuzzleId(puzzle.getId());
ofyTxn.put(puzzleDetails);
ofyTxn.getTxn().commit();
} finally {
if (ofyTxn.getTxn().isActive()) {
ofyTxn.getTxn().rollback();
throw new TransactionFailedException("Cannot create puzzle, title = \"" + puzzleInfo.getTitle() + "\"");
}
}
}