1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
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
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
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.
43 /// An object in this class is generated from an ExtendedResponse using the
44 /// ExtendedResponseFactory class.
46 /// The getReplicaInfoResponse extension uses the following OID:
47 /// 2.16.840.1.113719.1.27.100.18
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
;
63 /// <summary> Constructs an object from the responseValue which contains the
64 /// replica information.
66 /// The constructor parses the responseValue which has the following
69 /// partitionID INTEGER
70 /// replicaState INTEGER
71 /// modificationTime INTEGER
73 /// localPartitionID INTEGER
74 /// partitionDN OCTET STRING
75 /// replicaType INTEGER
79 /// <exception> IOException The response value could not be decoded.
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();
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
));
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();
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();
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");
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();
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();
165 modificationTime
= 0;
167 localPartitionID
= 0;
175 /// <summary> Returns the numeric identifier for the partition.
178 /// <returns> Integer value specifying the partition ID.
180 public virtual int getpartitionID()
185 /// <summary> Returns the current state of the replica.
188 /// <returns> Integer value specifying the current state of the replica. See
189 /// ReplicationConstants class for possible values for this field.
192 /// <seealso cref="ReplicationConstants.Ldap_RS_BEGIN_ADD">
194 /// <seealso cref="ReplicationConstants.Ldap_RS_DEAD_REPLICA">
196 /// <seealso cref="ReplicationConstants.Ldap_RS_DYING_REPLICA">
198 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_0">
200 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_1">
202 /// <seealso cref="ReplicationConstants.Ldap_RS_JS_2">
204 /// <seealso cref="ReplicationConstants.Ldap_RS_LOCKED">
206 /// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_DONE">
208 /// <seealso cref="ReplicationConstants.Ldap_RS_MASTER_START">
210 /// <seealso cref="ReplicationConstants.Ldap_RS_SS_0">
212 /// <seealso cref="ReplicationConstants.Ldap_RS_TRANSITION_ON">
214 public virtual int getreplicaState()
221 /// <summary> Returns the time of the most recent modification.
224 /// <returns> Integer value specifying the last modification time.
226 public virtual int getmodificationTime()
228 return modificationTime
;
232 /// <summary> Returns the most recent time in which all data has been synchronized.
235 /// <returns> Integer value specifying the last purge time.
237 public virtual int getpurgeTime()
242 /// <summary> Returns the local numeric identifier for the replica.
245 /// <returns> Integer value specifying the local ID of the partition.
247 public virtual int getlocalPartitionID()
249 return localPartitionID
;
252 /// <summary> Returns the distinguished name of the partition.
255 /// <returns> String value specifying the name of the partition read.
257 public virtual System
.String
getpartitionDN()
262 /// <summary> Returns the replica type.
264 /// See the ReplicationConstants class for possible values for
268 /// <returns> Integer identifying the type of the replica.
271 /// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
273 /// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
275 /// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
277 /// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
279 /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
281 /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
283 public virtual int getreplicaType()
288 /// <summary> Returns flags that specify whether the replica is busy or is a boundary.
290 /// See the ReplicationConstants class for possible values for
294 /// <returns> Integer value specifying the flags for the replica.
297 /// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BUSY">
299 /// <seealso cref="ReplicationConstants.Ldap_DS_FLAG_BOUNDARY">
301 public virtual int getflags()