001/*
002 * Copyright 2011-2016 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018package com.unboundid.scim.sdk;
019
020/**
021 * Signals server failed to update as Resource changed on the server since last
022 * retrieved
023 *
024 * This exception corresponds to HTTP response code
025 * 412 PRECONDITION FAILED.
026 */
027public class PreconditionFailedException extends SCIMException
028{
029  private final String version;
030
031  /**
032   * Create a new <code>PreconditionFailedException</code> from the provided
033   * information.
034   *
035   * @param errorMessage  The error message for this SCIM exception.
036   */
037  public PreconditionFailedException(final String errorMessage) {
038    super(412, errorMessage);
039    this.version = null;
040  }
041
042  /**
043   * Create a new <code>PreconditionFailedException</code> from the provided
044   * information.
045   *
046   * @param errorMessage  The error message for this SCIM exception.
047   * @param cause         The cause (which is saved for later retrieval by the
048   *                      {@link #getCause()} method).  (A <tt>null</tt> value
049   *                      is permitted, and indicates that the cause is
050   *                      nonexistent or unknown.)
051   */
052  public PreconditionFailedException(final String errorMessage,
053                                     final Throwable cause) {
054    super(412, errorMessage, cause);
055    this.version = null;
056  }
057
058  /**
059   * Create a new <code>PreconditionFailedException</code> from the provided
060   * information.
061   *
062   * @param errorMessage  The error message for this SCIM exception.
063   * @param version       The current version of the Resource.
064   * @param cause         The cause (which is saved for later retrieval by the
065   *                      {@link #getCause()} method).  (A <tt>null</tt> value
066   *                      is permitted, and indicates that the cause is
067   *                      nonexistent or unknown.)
068   */
069  public PreconditionFailedException(final String errorMessage,
070                                     final String version,
071                                     final Throwable cause) {
072    super(412, errorMessage, cause);
073    this.version = version;
074  }
075
076  /**
077   * Retrieves the current version of the Resource.
078   *
079   * @return The current version of the Resource.
080   */
081  public String getVersion() {
082    return version;
083  }
084}