(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Extensions / GetReplicaInfoResponse.cs
blob9ec5a333a5287636955bfb0bfe12e0dc50cc2fc5
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc. www.novell.com
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
33 using Novell.Directory.Ldap;
34 using Novell.Directory.Ldap.Asn1;
35 using Novell.Directory.Ldap.Utilclass;
36 using Novell.Directory.Ldap.Rfc2251;
38 namespace Novell.Directory.Ldap.Extensions
41 /// <summary> Retrieves the replica information from a GetReplicaInfoResponse object.
42 ///
43 /// An object in this class is generated from an ExtendedResponse using the
44 /// ExtendedResponseFactory class.
45 ///
46 /// The getReplicaInfoResponse extension uses the following OID:
47 /// 2.16.840.1.113719.1.27.100.18
48 ///
49 /// </summary>
50 public class GetReplicaInfoResponse:LdapExtendedResponse
53 // Other info as returned by the server
54 private int partitionID;
55 private int replicaState;
56 private int modificationTime;
57 private int purgeTime;
58 private int localPartitionID;
59 private System.String partitionDN;
60 private int replicaType;
61 private int flags;
63 /// <summary> Constructs an object from the responseValue which contains the
64 /// replica information.
65 ///
66 /// The constructor parses the responseValue which has the following
67 /// format:
68 /// responseValue ::=
69 /// partitionID INTEGER
70 /// replicaState INTEGER
71 /// modificationTime INTEGER
72 /// purgeTime INTEGER
73 /// localPartitionID INTEGER
74 /// partitionDN OCTET STRING
75 /// replicaType INTEGER
76 /// flags INTEGER
77 ///
78 /// </summary>
79 /// <exception> IOException The response value could not be decoded.
80 /// </exception>
81 public GetReplicaInfoResponse(RfcLdapMessage rfcMessage):base(rfcMessage)
84 if (ResultCode == LdapException.SUCCESS)
86 // parse the contents of the reply
87 sbyte[] returnedValue = this.Value;
88 if (returnedValue == null)
89 throw new System.IO.IOException("No returned value");
91 // Create a decoder object
92 LBERDecoder decoder = new LBERDecoder();
93 if (decoder == null)
94 throw new System.IO.IOException("Decoding error");
96 // Parse the parameters in the order
98 System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue));
100 // Parse partitionID
101 Asn1Integer asn1_partitionID = (Asn1Integer) decoder.decode(currentPtr);
102 if (asn1_partitionID == null)
103 throw new System.IO.IOException("Decoding error");
105 partitionID = asn1_partitionID.intValue();
108 // Parse replicaState
109 Asn1Integer asn1_replicaState = (Asn1Integer) decoder.decode(currentPtr);
110 if (asn1_replicaState == null)
111 throw new System.IO.IOException("Decoding error");
113 replicaState = asn1_replicaState.intValue();
115 // Parse modificationTime
116 Asn1Integer asn1_modificationTime = (Asn1Integer) decoder.decode(currentPtr);
117 if (asn1_modificationTime == null)
118 throw new System.IO.IOException("Decoding error");
120 modificationTime = asn1_modificationTime.intValue();
122 // Parse purgeTime
123 Asn1Integer asn1_purgeTime = (Asn1Integer) decoder.decode(currentPtr);
124 if (asn1_purgeTime == null)
125 throw new System.IO.IOException("Decoding error");
127 purgeTime = asn1_purgeTime.intValue();
129 // Parse localPartitionID
130 Asn1Integer asn1_localPartitionID = (Asn1Integer) decoder.decode(currentPtr);
131 if (asn1_localPartitionID == null)
132 throw new System.IO.IOException("Decoding error");
134 localPartitionID = asn1_localPartitionID.intValue();
136 // Parse partitionDN
137 Asn1OctetString asn1_partitionDN = (Asn1OctetString) decoder.decode(currentPtr);
138 if (asn1_partitionDN == null)
139 throw new System.IO.IOException("Decoding error");
141 partitionDN = asn1_partitionDN.stringValue();
142 if ((System.Object) partitionDN == null)
143 throw new System.IO.IOException("Decoding error");
146 // Parse replicaType
147 Asn1Integer asn1_replicaType = (Asn1Integer) decoder.decode(currentPtr);
148 if (asn1_replicaType == null)
149 throw new System.IO.IOException("Decoding error");
151 replicaType = asn1_replicaType.intValue();
154 // Parse flags
155 Asn1Integer asn1_flags = (Asn1Integer) decoder.decode(currentPtr);
156 if (asn1_flags == null)
157 throw new System.IO.IOException("Decoding error");
159 flags = asn1_flags.intValue();
161 else
163 partitionID = 0;
164 replicaState = 0;
165 modificationTime = 0;
166 purgeTime = 0;
167 localPartitionID = 0;
168 partitionDN = "";
169 replicaType = 0;
170 flags = 0;
175 /// <summary> Returns the numeric identifier for the partition.
176 ///
177 /// </summary>
178 /// <returns> Integer value specifying the partition ID.
179 /// </returns>
180 public virtual int getpartitionID()
182 return partitionID;
185 /// <summary> Returns the current state of the replica.
186 ///
187 /// </summary>
188 /// <returns> Integer value specifying the current state of the replica. See
189 /// ReplicationConstants class for possible values for this field.
190 ///
191 /// </returns>
192 /// <seealso cref="ReplicationConstants.Ldap_RS_BEGIN_ADD">
193 /// </seealso>
194 /// <seealso cref="ReplicationConstants.Ldap_RS_DEAD_REPLICA">
195 /// </seealso>
196 /// <seealso cref="ReplicationConstants.Ldap_RS_DYING_REPLICA">
197 /// </seealso>
198 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_0">
199 /// </seealso>
200 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_1">
201 /// </seealso>
202 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_2">
203 /// </seealso>
204 /// <seealso cref="ReplicationConstants.Ldap_RS_LOCKED">
205 /// </seealso>
206 /// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_DONE">
207 /// </seealso>
208 /// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_START">
209 /// </seealso>
210 /// <seealso cref="ReplicationConstants.Ldap_RS_SS_0">
211 /// </seealso>
212 /// <seealso cref="ReplicationConstants.Ldap_RS_TRANSITION_ON">
213 /// </seealso>
214 public virtual int getreplicaState()
216 return replicaState;
221 /// <summary> Returns the time of the most recent modification.
222 ///
223 /// </summary>
224 /// <returns> Integer value specifying the last modification time.
225 /// </returns>
226 public virtual int getmodificationTime()
228 return modificationTime;
232 /// <summary> Returns the most recent time in which all data has been synchronized.
233 ///
234 /// </summary>
235 /// <returns> Integer value specifying the last purge time.
236 /// </returns>
237 public virtual int getpurgeTime()
239 return purgeTime;
242 /// <summary> Returns the local numeric identifier for the replica.
243 ///
244 /// </summary>
245 /// <returns> Integer value specifying the local ID of the partition.
246 /// </returns>
247 public virtual int getlocalPartitionID()
249 return localPartitionID;
252 /// <summary> Returns the distinguished name of the partition.
253 ///
254 /// </summary>
255 /// <returns> String value specifying the name of the partition read.
256 /// </returns>
257 public virtual System.String getpartitionDN()
259 return partitionDN;
262 /// <summary> Returns the replica type.
263 ///
264 /// See the ReplicationConstants class for possible values for
265 /// this field.
266 ///
267 /// </summary>
268 /// <returns> Integer identifying the type of the replica.
269 ///
270 /// </returns>
271 /// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
272 /// </seealso>
273 /// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
274 /// </seealso>
275 /// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
276 /// </seealso>
277 /// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
278 /// </seealso>
279 /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
280 /// </seealso>
281 /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
282 /// </seealso>
283 public virtual int getreplicaType()
285 return replicaType;
288 /// <summary> Returns flags that specify whether the replica is busy or is a boundary.
289 ///
290 /// See the ReplicationConstants class for possible values for
291 /// this field.
292 ///
293 /// </summary>
294 /// <returns> Integer value specifying the flags for the replica.
295 ///
296 /// </returns>
297 /// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BUSY">
298 /// </seealso>
299 /// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BOUNDARY">
300 /// </seealso>
301 public virtual int getflags()
303 return flags;