return getTransactionTemplateRetrying(getMaxRetries()).execute(new TransactionCallback<List<UniqueId>>() {
@Override
public List<UniqueId> doInTransaction(final TransactionStatus status) {
final D storedDocument = get(uniqueId);
if (storedDocument == null) {
throw new DataNotFoundException("Document not found: " + uniqueId.getObjectId());
}
ArgumentChecker.isTrue(storedDocument.getCorrectionToInstant() == null, "we can replace only current document. The " + storedDocument.getUniqueId() + " is not current.");
final Instant storedVersionFrom = storedDocument.getVersionFromInstant();
final Instant storedVersionTo = storedDocument.getVersionToInstant();