Adopt odlparent-10.0.0/yangtools-8.0.0-SNAPSHOT
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / OptimisticLockFailedException.java
1 /*
2  * Copyright (c) 2014, 2015 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.mdsal.common.api;
9
10 import org.opendaylight.yangtools.yang.common.ErrorTag;
11 import org.opendaylight.yangtools.yang.common.ErrorType;
12 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
13
14 /**
15 * Failure of asynchronous transaction commit caused by failure of optimistic locking. This exception is raised and
16 * returned when transaction commit failed, because other transaction finished successfully and modified same data as
17 * failed transaction. Clients may recover from this error condition by retrieving current state and submitting a new
18 * updated transaction.
19 */
20 public class OptimisticLockFailedException extends TransactionCommitFailedException {
21     private static final long serialVersionUID = 1L;
22
23     public OptimisticLockFailedException(final String message, final Throwable cause) {
24         super(message, cause,
25             RpcResultBuilder.newError(ErrorType.APPLICATION, ErrorTag.RESOURCE_DENIED, message, null, null, cause));
26     }
27
28     public OptimisticLockFailedException(final String message) {
29         this(message, null);
30     }
31 }