001/*
002 * Copyright 2014-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2014-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2014-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.extensions;
037
038
039
040import com.unboundid.asn1.ASN1Element;
041import com.unboundid.asn1.ASN1OctetString;
042import com.unboundid.ldap.sdk.LDAPException;
043import com.unboundid.ldap.sdk.ResultCode;
044import com.unboundid.util.Debug;
045import com.unboundid.util.NotMutable;
046import com.unboundid.util.NotNull;
047import com.unboundid.util.StaticUtils;
048import com.unboundid.util.ThreadSafety;
049import com.unboundid.util.ThreadSafetyLevel;
050import com.unboundid.util.Validator;
051
052import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
053
054
055
056/**
057 * This class provides an implementation of a get changelog batch change
058 * selection criteria value that indicates that the server should only return
059 * changes that are associated with a specified notification destination, as
060 * specified by the entryUUID for the notification destination to target.
061 * <BR>
062 * <BLOCKQUOTE>
063 *   <B>NOTE:</B>  This class, and other classes within the
064 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
065 *   supported for use against Ping Identity, UnboundID, and
066 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
067 *   for proprietary functionality or for external specifications that are not
068 *   considered stable or mature enough to be guaranteed to work in an
069 *   interoperable way with other types of LDAP servers.
070 * </BLOCKQUOTE>
071 */
072@NotMutable()
073@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
074public final class NotificationDestinationChangeSelectionCriteria
075       extends ChangelogBatchChangeSelectionCriteria
076{
077  /**
078   * The inner BER type that should be used for encoded elements that represent
079   * a notification destination get changelog batch selection criteria value.
080   */
081  static final byte TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION =
082       (byte) 0x84;
083
084
085
086  // The entryUUID for the for the notification destination to target.
087  @NotNull private final String destinationEntryUUID;
088
089
090
091  /**
092   * Creates a new notification destination change selection criteria value with
093   * the specified destination entryUUID.
094   *
095   * @param  destinationEntryUUID  The entryUUID for the notification
096   *                               destination to target.  It must not be
097   *                               {@code null}.
098   */
099  public NotificationDestinationChangeSelectionCriteria(
100              @NotNull final String destinationEntryUUID)
101  {
102    Validator.ensureNotNull(destinationEntryUUID);
103
104    this.destinationEntryUUID = destinationEntryUUID;
105  }
106
107
108
109  /**
110   * Decodes the provided ASN.1 element, which is the inner element of a
111   * changelog batch change selection criteria element, as an all attributes
112   * change selection criteria value.
113   *
114   * @param  innerElement  The inner element of a changelog batch change
115   *                       selection criteria element to be decoded.
116   *
117   * @return  The decoded all attributes change selection criteria value.
118   *
119   * @throws  LDAPException  If a problem is encountered while trying to decode
120   *                         the provided element as the inner element of an all
121   *                         attributes change selection criteria value.
122   */
123  @NotNull()
124  static NotificationDestinationChangeSelectionCriteria decodeInnerElement(
125              @NotNull final ASN1Element innerElement)
126         throws LDAPException
127  {
128    try
129    {
130      return new NotificationDestinationChangeSelectionCriteria(
131           ASN1OctetString.decodeAsOctetString(innerElement).stringValue());
132    }
133    catch (final Exception e)
134    {
135      Debug.debugException(e);
136      throw new LDAPException(ResultCode.DECODING_ERROR,
137           ERR_NOT_DEST_CHANGE_SELECTION_CRITERIA_DECODE_ERROR.get(
138                StaticUtils.getExceptionMessage(e)),
139           e);
140    }
141  }
142
143
144
145  /**
146   * Retrieves the entryUUID for the target notification destination.
147   *
148   * @return  The entryUUID for the target notification destination.
149   */
150  @NotNull()
151  public String getDestinationEntryUUID()
152  {
153    return destinationEntryUUID;
154  }
155
156
157
158  /**
159   * {@inheritDoc}
160   */
161  @Override()
162  @NotNull()
163  public ASN1Element encodeInnerElement()
164  {
165    return new ASN1OctetString(TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION,
166         destinationEntryUUID);
167  }
168
169
170
171  /**
172   * {@inheritDoc}
173   */
174  @Override()
175  public void toString(@NotNull final StringBuilder buffer)
176  {
177    buffer.append("NotificationDestinationChangeSelectionCriteria(" +
178         "destinationEntryUUID='");
179    buffer.append(destinationEntryUUID);
180    buffer.append("')");
181  }
182}