2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.common.api;
10 import static java.util.Objects.requireNonNull;
12 import org.opendaylight.yangtools.concepts.Path;
13 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
14 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
17 * Failure of asynchronous transaction commit caused by invalid data. This exception is raised and returned when
18 * a transaction commit failed, because other data submitted via transactions.
21 * Clients usually are not able recover from this error condition by retrieving same transaction, since data introduced
22 * by this transaction is invalid.
24 public class DataValidationFailedException extends TransactionCommitFailedException {
26 private static final long serialVersionUID = 1L;
28 private final Path<?> path;
30 private final Class<? extends Path<?>> pathType;
32 public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType, final P path,
33 final String message, final Throwable cause) {
34 super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
35 path != null ? path.toString() : null, cause));
36 this.pathType = requireNonNull(pathType, "path type must not be null");
37 this.path = requireNonNull(path, "path must not be null.");
40 public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType, final P path,
41 final String message) {
42 this(pathType, path, message, null);
45 public final Path<?> getPath() {
49 public final Class<? extends Path<?>> getPathType() {