001/*
002 * Copyright 2012-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
020import com.unboundid.scim.sdk.BulkOperation.Method;
021
022/**
023 * A wrapper exception for SCIMException for individual bulk operations.
024 */
025public class BulkException extends Exception
026{
027  private static final long serialVersionUID = -734244253288139013L;
028
029  private final Method method;
030  private final String bulkId;
031  private final String path;
032
033  /**
034   *
035   * @param throwable The SCIMException that caused the bulk operation to fail.
036   * @param method The original HTTP method of the operation.
037   * @param bulkId The bulk operation identifier.
038   * @param path   The relative path of the resource from the bulk operation
039   *               request.
040   */
041  public BulkException(final SCIMException throwable, final Method method,
042                       final String bulkId, final String path)
043  {
044    super(throwable);
045    this.method = method;
046    this.bulkId = bulkId;
047    this.path   = path;
048  }
049
050
051
052  /**
053   * Retrieve HTTP method of the operation. Possible values are POST, PUT,
054   * PATCH or DELETE.
055   * @return  The HTTP method of the operation. Possible values are POST, PUT,
056   *          PATCH or DELETE.
057   */
058  public Method getMethod()
059  {
060    return method;
061  }
062
063
064
065  /**
066   * Retrieve the bulk operation identifier, required when the method is POST.
067   * @return  The bulk operation identifier, required when the method is POST.
068   */
069  public String getBulkId()
070  {
071    return bulkId;
072  }
073
074
075
076  /**
077   * Retrieve the relative path of the resource from the bulk operation request.
078   * Could be {@code null} if no path was specified.
079   *
080   * @return  The relative path of the resource from the bulk operation request,
081   *          or {@code null} if no path was specified.
082   */
083  public String getPath()
084  {
085    return path;
086  }
087
088
089
090  /**
091   * {@inheritDoc}
092   */
093  @Override
094  public SCIMException getCause()
095  {
096    return (SCIMException)super.getCause();
097  }
098}