Remove deprecated controller EOS APIs and impl
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / DataValidationFailedException.java
index c59c12ec5c3c59314d94094d421ab45c96deb4cb..a7445489d09794bf8695aea6a99560871a5bf016 100644 (file)
@@ -7,38 +7,44 @@
  */
 package org.opendaylight.controller.md.sal.common.api.data;
 
-import org.opendaylight.yangtools.concepts.Path;
-
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 /**
- *
  * Failure of asynchronous transaction commit caused by invalid data.
  *
+ * <p>
  * This exception is raised and returned when transaction commit
- * failed, because other data submitted via transactions
+ * failed, because other data submitted via transactions.
  *
+ * <p>
  *  Clients usually are not able recover from this error condition by
  *  retrieving same transaction, since data introduced by this transaction
  *  are invalid.
- *
  */
 public class DataValidationFailedException extends TransactionCommitFailedException {
 
     private static final long serialVersionUID = 1L;
 
-    private Path<?> path;
+    @SuppressFBWarnings("SE_BAD_FIELD")
+    private final Path<?> path;
 
-    private Class<? extends Path<?>> pathType;
+    private final Class<? extends Path<?>> pathType;
 
-    public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path, final String message, final Throwable cause) {
-        super(message, cause);
+    public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
+                                                             final String message, final Throwable cause) {
+        super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
+                                                        path != null ? path.toString() : null, cause));
         this.pathType = Preconditions.checkNotNull(pathType, "path type must not be null");
         this.path = Preconditions.checkNotNull(path,"path must not be null.");
     }
 
-    public  <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,final String message) {
-        this(pathType,path,message,null);
+    public  <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
+                                                              final String message) {
+        this(pathType, path, message, null);
     }
 
     public final Path<?> getPath() {
@@ -48,5 +54,4 @@ public class DataValidationFailedException extends TransactionCommitFailedExcept
     public final Class<? extends Path<?>> getPathType() {
         return pathType;
     }
-
 }