+ public synchronized void validateTransaction() throws DocumentedException {
+ if (transactionValidator == null) {
+ LOG.error("Validate capability is not supported");
+ throw new DocumentedException("Validate capability is not supported",
+ ErrorType.PROTOCOL, ErrorTag.OPERATION_NOT_SUPPORTED, ErrorSeverity.ERROR);
+ }
+
+ if (getCandidateTransaction().isEmpty()) {
+ // Validating empty transaction, just return true
+ LOG.debug("Validating empty candidate transaction for session {}", netconfSessionIdForReporting);
+ return;
+ }
+
+ try {
+ transactionValidator.validate(candidateTransaction).get();
+ } catch (final InterruptedException | ExecutionException e) {
+ LOG.debug("Candidate transaction validation {} failed on session {}", candidateTransaction,
+ netconfSessionIdForReporting, e);
+ final String cause = e.getCause() != null ? " Cause: " + e.getCause().getMessage() : "";
+ throw new DocumentedException("Candidate transaction validate failed [sessionId="
+ + netconfSessionIdForReporting + "]: " + e.getMessage() + cause, e, ErrorType.APPLICATION,
+ ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
+ }
+ }
+