| 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: |
| 11 |
* |
| 12 |
* The above copyright notice and this permission notice shall be included in |
| 13 |
* all copies or substantial portions of the Software. |
| 14 |
* |
| 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 |
*******************************************************************************/ |
| 23 |
// |
| 24 |
// Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse.cs |
| 25 |
// |
| 26 |
// Author: |
| 27 |
// Sunil Kumar ([email protected]) |
| 28 |
// |
| 29 |
// (C) 2003 Novell, Inc (http://www.novell.com) |
| 30 |
// |
| 31 |
|
| 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; |
| 37 |
|
| 38 |
namespace Novell.Directory.Ldap.Extensions |
| 39 |
{ |
| 40 |
|
| 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 |
| 51 |
{ |
| 52 |
|
| 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; |
| 62 |
|
| 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) |
| 82 |
{ |
| 83 |
|
| 84 |
if (ResultCode == LdapException.SUCCESS) |
| 85 |
{ |
| 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"); |
| 90 |
|
| 91 |
// Create a decoder object |
| 92 |
LBERDecoder decoder = new LBERDecoder(); |
| 93 |
if (decoder == null) |
| 94 |
throw new System.IO.IOException("Decoding error"); |
| 95 |
|
| 96 |
// Parse the parameters in the order |
| 97 |
|
| 98 |
System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue)); |
| 99 |
|
| 100 |
// Parse partitionID |
| 101 |
Asn1Integer asn1_partitionID = (Asn1Integer) decoder.decode(currentPtr); |
| 102 |
if (asn1_partitionID == null) |
| 103 |
throw new System.IO.IOException("Decoding error"); |
| 104 |
|
| 105 |
partitionID = asn1_partitionID.intValue(); |
| 106 |
|
| 107 |
|
| 108 |
// Parse replicaState |
| 109 |
Asn1Integer asn1_replicaState = (Asn1Integer) decoder.decode(currentPtr); |
| 110 |
if (asn1_replicaState == null) |
| 111 |
throw new System.IO.IOException("Decoding error"); |
| 112 |
|
| 113 |
replicaState = asn1_replicaState.intValue(); |
| 114 |
|
| 115 |
// Parse modificationTime |
| 116 |
Asn1Integer asn1_modificationTime = (Asn1Integer) decoder.decode(currentPtr); |
| 117 |
if (asn1_modificationTime == null) |
| 118 |
throw new System.IO.IOException("Decoding error"); |
| 119 |
|
| 120 |
modificationTime = asn1_modificationTime.intValue(); |
| 121 |
|
| 122 |
// Parse purgeTime |
| 123 |
Asn1Integer asn1_purgeTime = (Asn1Integer) decoder.decode(currentPtr); |
| 124 |
if (asn1_purgeTime == null) |
| 125 |
throw new System.IO.IOException("Decoding error"); |
| 126 |
|
| 127 |
purgeTime = asn1_purgeTime.intValue(); |
| 128 |
|
| 129 |
// Parse localPartitionID |
| 130 |
Asn1Integer asn1_localPartitionID = (Asn1Integer) decoder.decode(currentPtr); |
| 131 |
if (asn1_localPartitionID == null) |
| 132 |
throw new System.IO.IOException("Decoding error"); |
| 133 |
|
| 134 |
localPartitionID = asn1_localPartitionID.intValue(); |
| 135 |
|
| 136 |
// Parse partitionDN |
| 137 |
Asn1OctetString asn1_partitionDN = (Asn1OctetString) decoder.decode(currentPtr); |
| 138 |
if (asn1_partitionDN == null) |
| 139 |
throw new System.IO.IOException("Decoding error"); |
| 140 |
|
| 141 |
partitionDN = asn1_partitionDN.stringValue(); |
| 142 |
if ((System.Object) partitionDN == null) |
| 143 |
throw new System.IO.IOException("Decoding error"); |
| 144 |
|
| 145 |
|
| 146 |
// Parse replicaType |
| 147 |
Asn1Integer asn1_replicaType = (Asn1Integer) decoder.decode(currentPtr); |
| 148 |
if (asn1_replicaType == null) |
| 149 |
throw new System.IO.IOException("Decoding error"); |
| 150 |
|
| 151 |
replicaType = asn1_replicaType.intValue(); |
| 152 |
|
| 153 |
|
| 154 |
// Parse flags |
| 155 |
Asn1Integer asn1_flags = (Asn1Integer) decoder.decode(currentPtr); |
| 156 |
if (asn1_flags == null) |
| 157 |
throw new System.IO.IOException("Decoding error"); |
| 158 |
|
| 159 |
flags = asn1_flags.intValue(); |
| 160 |
} |
| 161 |
else |
| 162 |
{ |
| 163 |
partitionID = 0; |
| 164 |
replicaState = 0; |
| 165 |
modificationTime = 0; |
| 166 |
purgeTime = 0; |
| 167 |
localPartitionID = 0; |
| 168 |
partitionDN = ""; |
| 169 |
replicaType = 0; |
| 170 |
flags = 0; |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
|
| 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() |
| 181 |
{ |
| 182 |
return partitionID; |
| 183 |
} |
| 184 |
|
| 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() |
| 215 |
{ |
| 216 |
return replicaState; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 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() |
| 227 |
{ |
| 228 |
return modificationTime; |
| 229 |
} |
| 230 |
|
| 231 |
|
| 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() |
| 238 |
{ |
| 239 |
return purgeTime; |
| 240 |
} |
| 241 |
|
| 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() |
| 248 |
{ |
| 249 |
return localPartitionID; |
| 250 |
} |
| 251 |
|
| 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() |
| 258 |
{ |
| 259 |
return partitionDN; |
| 260 |
} |
| 261 |
|
| 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() |
| 284 |
{ |
| 285 |
return replicaType; |
| 286 |
} |
| 287 |
|
| 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() |
| 302 |
{ |
| 303 |
return flags; |
| 304 |
} |
| 305 |
} |
| 306 |
} |