001/* 002 * Copyright 2014-2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2014-2020 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) 2015-2020 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.StaticUtils; 047import com.unboundid.util.ThreadSafety; 048import com.unboundid.util.ThreadSafetyLevel; 049import com.unboundid.util.Validator; 050 051import static com.unboundid.ldap.sdk.unboundidds.extensions.ExtOpMessages.*; 052 053 054 055/** 056 * This class provides an implementation of a get changelog batch change 057 * selection criteria value that indicates that the server should only return 058 * changes that are associated with a specified notification destination, as 059 * specified by the entryUUID for the notification destination to target. 060 * <BR> 061 * <BLOCKQUOTE> 062 * <B>NOTE:</B> This class, and other classes within the 063 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 064 * supported for use against Ping Identity, UnboundID, and 065 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 066 * for proprietary functionality or for external specifications that are not 067 * considered stable or mature enough to be guaranteed to work in an 068 * interoperable way with other types of LDAP servers. 069 * </BLOCKQUOTE> 070 */ 071@NotMutable() 072@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 073public final class NotificationDestinationChangeSelectionCriteria 074 extends ChangelogBatchChangeSelectionCriteria 075{ 076 /** 077 * The inner BER type that should be used for encoded elements that represent 078 * a notification destination get changelog batch selection criteria value. 079 */ 080 static final byte TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION = 081 (byte) 0x84; 082 083 084 085 // The entryUUID for the for the notification destination to target. 086 private final String destinationEntryUUID; 087 088 089 090 /** 091 * Creates a new notification destination change selection criteria value with 092 * the specified destination entryUUID. 093 * 094 * @param destinationEntryUUID The entryUUID for the notification 095 * destination to target. It must not be 096 * {@code null}. 097 */ 098 public NotificationDestinationChangeSelectionCriteria( 099 final String destinationEntryUUID) 100 { 101 Validator.ensureNotNull(destinationEntryUUID); 102 103 this.destinationEntryUUID = destinationEntryUUID; 104 } 105 106 107 108 /** 109 * Decodes the provided ASN.1 element, which is the inner element of a 110 * changelog batch change selection criteria element, as an all attributes 111 * change selection criteria value. 112 * 113 * @param innerElement The inner element of a changelog batch change 114 * selection criteria element to be decoded. 115 * 116 * @return The decoded all attributes change selection criteria value. 117 * 118 * @throws LDAPException If a problem is encountered while trying to decode 119 * the provided element as the inner element of an all 120 * attributes change selection criteria value. 121 */ 122 static NotificationDestinationChangeSelectionCriteria decodeInnerElement( 123 final ASN1Element innerElement) 124 throws LDAPException 125 { 126 try 127 { 128 return new NotificationDestinationChangeSelectionCriteria( 129 ASN1OctetString.decodeAsOctetString(innerElement).stringValue()); 130 } 131 catch (final Exception e) 132 { 133 Debug.debugException(e); 134 throw new LDAPException(ResultCode.DECODING_ERROR, 135 ERR_NOT_DEST_CHANGE_SELECTION_CRITERIA_DECODE_ERROR.get( 136 StaticUtils.getExceptionMessage(e)), 137 e); 138 } 139 } 140 141 142 143 /** 144 * Retrieves the entryUUID for the target notification destination. 145 * 146 * @return The entryUUID for the target notification destination. 147 */ 148 public String getDestinationEntryUUID() 149 { 150 return destinationEntryUUID; 151 } 152 153 154 155 /** 156 * {@inheritDoc} 157 */ 158 @Override() 159 public ASN1Element encodeInnerElement() 160 { 161 return new ASN1OctetString(TYPE_SELECTION_CRITERIA_NOTIFICATION_DESTINATION, 162 destinationEntryUUID); 163 } 164 165 166 167 /** 168 * {@inheritDoc} 169 */ 170 @Override() 171 public void toString(final StringBuilder buffer) 172 { 173 buffer.append("NotificationDestinationChangeSelectionCriteria(" + 174 "destinationEntryUUID='"); 175 buffer.append(destinationEntryUUID); 176 buffer.append("')"); 177 } 178}