001    /*
002     * Copyright 2014-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 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     */
021    package com.unboundid.ldap.sdk.unboundidds.extensions;
022    
023    
024    
025    import com.unboundid.asn1.ASN1Element;
026    import com.unboundid.asn1.ASN1OctetString;
027    import com.unboundid.ldap.sdk.LDAPException;
028    import com.unboundid.ldap.sdk.ResultCode;
029    import com.unboundid.util.Debug;
030    import com.unboundid.util.NotMutable;
031    import com.unboundid.util.StaticUtils;
032    import com.unboundid.util.ThreadSafety;
033    import com.unboundid.util.ThreadSafetyLevel;
034    import com.unboundid.util.Validator;
035    
036    import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*;
037    
038    
039    
040    /**
041     * <BLOCKQUOTE>
042     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
043     *   LDAP SDK for Java.  It is not available for use in applications that
044     *   include only the Standard Edition of the LDAP SDK, and is not supported for
045     *   use in conjunction with non-UnboundID products.
046     * </BLOCKQUOTE>
047     * This class provides an implementation of a get changelog batch change
048     * selection criteria value that indicates that the server should only return
049     * changes that are associated with a specified notification destination, as
050     * specified by the entryUUID for the notification destination to target.
051     */
052    @NotMutable()
053    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
054    public final class NotificationDestinationChangeSelectionCriteria
055           extends ChangelogBatchChangeSelectionCriteria
056    {
057      /**
058       * The inner BER type that should be used for encoded elements that represent
059       * a notification destination get changelog batch selection criteria value.
060       */
061      static final byte TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION =
062           (byte) 0x84;
063    
064    
065    
066      // The entryUUID for the for the notification destination to target.
067      private final String destinationEntryUUID;
068    
069    
070    
071      /**
072       * Creates a new notification destination change selection criteria value with
073       * the specified destination entryUUID.
074       *
075       * @param  destinationEntryUUID  The entryUUID for the notification
076       *                               destination to target.  It must not be
077       *                               {@code null}.
078       */
079      public NotificationDestinationChangeSelectionCriteria(
080                  final String destinationEntryUUID)
081      {
082        Validator.ensureNotNull(destinationEntryUUID);
083    
084        this.destinationEntryUUID = destinationEntryUUID;
085      }
086    
087    
088    
089      /**
090       * Decodes the provided ASN.1 element, which is the inner element of a
091       * changelog batch change selection criteria element, as an all attributes
092       * change selection criteria value.
093       *
094       * @param  innerElement  The inner element of a changelog batch change
095       *                       selection criteria element to be decoded.
096       *
097       * @return  The decoded all attributes change selection criteria value.
098       *
099       * @throws  LDAPException  If a problem is encountered while trying to decode
100       *                         the provided element as the inner element of an all
101       *                         attributes change selection criteria value.
102       */
103      static NotificationDestinationChangeSelectionCriteria decodeInnerElement(
104                  final ASN1Element innerElement)
105             throws LDAPException
106      {
107        try
108        {
109          return new NotificationDestinationChangeSelectionCriteria(
110               ASN1OctetString.decodeAsOctetString(innerElement).stringValue());
111        }
112        catch (final Exception e)
113        {
114          Debug.debugException(e);
115          throw new LDAPException(ResultCode.DECODING_ERROR,
116               ERR_NOT_DEST_CHANGE_SELECTION_CRITERIA_DECODE_ERROR.get(
117                    StaticUtils.getExceptionMessage(e)),
118               e);
119        }
120      }
121    
122    
123    
124      /**
125       * Retrieves the entryUUID for the target notification destination.
126       *
127       * @return  The entryUUID for the target notification destination.
128       */
129      public String getDestinationEntryUUID()
130      {
131        return destinationEntryUUID;
132      }
133    
134    
135    
136      /**
137       * {@inheritDoc}
138       */
139      @Override()
140      public ASN1Element encodeInnerElement()
141      {
142        return new ASN1OctetString(TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION,
143             destinationEntryUUID);
144      }
145    
146    
147    
148      /**
149       * {@inheritDoc}
150       */
151      @Override()
152      public void toString(final StringBuilder buffer)
153      {
154        buffer.append("NotificationDestinationChangeSelectionCriteria(" +
155             "destinationEntryUUID='");
156        buffer.append(destinationEntryUUID);
157        buffer.append("')");
158      }
159    }