Bug 629: Introduction of Configuration Commit Handler
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / DataValidationFailedException.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.common.api.data;
9
10 import org.opendaylight.yangtools.concepts.Path;
11
12 import com.google.common.base.Preconditions;
13
14 /**
15  *
16  * Failure of asynchronous transaction commit caused by invalid data.
17  *
18  * This exception is raised and returned when transaction commit
19  * failed, because other data submitted via transactions
20  *
21  *  Clients usually are not able recover from this error condition by
22  *  retrieving same transaction, since data introduced by this transaction
23  *  are invalid.
24  *
25  */
26 public class DataValidationFailedException extends TransactionCommitFailedException {
27
28     private static final long serialVersionUID = 1L;
29
30     private Path<?> path;
31
32     private Class<? extends Path<?>> pathType;
33
34     public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path, final String message, final Throwable cause) {
35         super(message, cause);
36         this.pathType = Preconditions.checkNotNull(pathType, "path type must not be null");
37         this.path = Preconditions.checkNotNull(path,"path must not be null.");
38     }
39
40     public  <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,final String message) {
41         this(pathType,path,message,null);
42     }
43
44     public final Path<?> getPath() {
45         return path;
46     }
47
48     public final Class<? extends Path<?>> getPathType() {
49         return pathType;
50     }
51
52 }