001/*
002 * Copyright 2009-2014 UnboundID Corp.
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2009-2014 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk;
022
023
024
025import com.unboundid.util.NotMutable;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This class defines an exception that may be thrown if a search result
033 * reference is received from the directory server while using the
034 * {@link EntrySource} API (e.g., an {@link LDAPEntrySource} object).
035 */
036@NotMutable()
037@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
038public final class SearchResultReferenceEntrySourceException
039       extends EntrySourceException
040{
041  /**
042   * The serial version UID for this serializable class.
043   */
044  private static final long serialVersionUID = 4389660042011914324L;
045
046
047
048  // The search result reference returned from the server.
049  private final SearchResultReference searchReference;
050
051
052
053  /**
054   * Creates a new search result reference entry source exception with the
055   * provided search result reference.
056   *
057   * @param  searchReference  The search result reference returned by the
058   *                          directory server.  It must not be {@code null}.
059   */
060  public SearchResultReferenceEntrySourceException(
061              final SearchResultReference searchReference)
062  {
063    super(true, new LDAPException(ResultCode.REFERRAL, null, null,
064         searchReference.getReferralURLs(), searchReference.getControls(),
065         null));
066
067    this.searchReference = searchReference;
068  }
069
070
071
072  /**
073   * Retrieves the search result reference for this entry source exception.
074   *
075   * @return  The search result reference for this entry source exception.
076   */
077  public SearchResultReference getSearchReference()
078  {
079    return searchReference;
080  }
081
082
083
084  /**
085   * {@inheritDoc}
086   */
087  @Override()
088  public void toString(final StringBuilder buffer)
089  {
090    buffer.append("SearchResultReferenceEntrySourceException(searchReference=");
091    searchReference.toString(buffer);
092    buffer.append("')");
093  }
094}