org.opends.server.replication.protocol
Class AddMsg

java.lang.Object
  extended by org.opends.server.replication.protocol.ReplicationMsg
      extended by org.opends.server.replication.protocol.UpdateMsg
          extended by org.opends.server.replication.protocol.LDAPUpdateMsg
              extended by org.opends.server.replication.protocol.AddMsg
All Implemented Interfaces:
java.lang.Comparable<UpdateMsg>

public class AddMsg
extends LDAPUpdateMsg

This class is used to exchange Add operation between LDAP servers and replication servers.


Field Summary
 
Fields inherited from class org.opends.server.replication.protocol.LDAPUpdateMsg
bytes, dn, encodedEclIncludes, uniqueId
 
Fields inherited from class org.opends.server.replication.protocol.UpdateMsg
assuredFlag, assuredMode, changeNumber, protocolVersion, safeDataLevel
 
Constructor Summary
AddMsg(byte[] in)
          Creates a new Add message from a byte[].
AddMsg(ChangeNumber cn, java.lang.String dn, java.lang.String uniqueId, java.lang.String parentId, Attribute objectClass, java.util.Collection<Attribute> userAttributes, java.util.Collection<Attribute> operationalAttributes)
          Creates a new AddMessage.
AddMsg(ChangeNumber cn, java.lang.String dn, java.lang.String uniqueId, java.lang.String parentId, java.util.Map<ObjectClass,java.lang.String> objectClasses, java.util.Map<AttributeType,java.util.List<Attribute>> userAttributes, java.util.Map<AttributeType,java.util.List<Attribute>> operationalAttributes)
          Creates a new AddMessage.
AddMsg(PostOperationAddOperation op)
          Creates a new AddMessage.
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Add the specified attribute/attribute value in the entry contained in this AddMsg.
 AddOperationBasis createOperation(InternalClientConnection connection, java.lang.String newDn)
          Create and Operation from the message using the provided DN.
 java.util.List<Attribute> getAttributes()
          Get the attributes of this add msg.
 byte[] getBytes_V1()
          Get the byte array representation of this Message.
 byte[] getBytes_V23()
          Get the byte array representation of this Message.
 byte[] getBytes_V4()
          Get the byte array representation of this Message.
 java.lang.String getParentUid()
          Get the parent unique id of this add msg.
 void setParentUid(java.lang.String uid)
          Set the parent unique id of this add msg.
 int size()
          Return the number of bytes used by this message.
 java.lang.String toString()
          
 
Methods inherited from class org.opends.server.replication.protocol.LDAPUpdateMsg
createOperation, decodeAttributes, decodeHeader_V1, decodeHeader, decodeRawAttributes, encode, encodeHeader_V1, encodeHeader, generateMsg, getBytes, getBytes, getDn, getEclIncludes, getUniqueId, headerSize, setDn, setEclIncludes
 
Methods inherited from class org.opends.server.replication.protocol.UpdateMsg
compareTo, decodeHeader, equals, getAssuredMode, getChangeNumber, getPayload, getSafeDataLevel, getVersion, hashCode, isAssured, setAssured, setAssuredMode, setSafeDataLevel
 
Methods inherited from class org.opends.server.replication.protocol.ReplicationMsg
addByteArray, generateMsg, getNextLength
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AddMsg

public AddMsg(PostOperationAddOperation op)
Creates a new AddMessage.

Parameters:
op - the operation to use when creating the message

AddMsg

public AddMsg(ChangeNumber cn,
              java.lang.String dn,
              java.lang.String uniqueId,
              java.lang.String parentId,
              java.util.Map<ObjectClass,java.lang.String> objectClasses,
              java.util.Map<AttributeType,java.util.List<Attribute>> userAttributes,
              java.util.Map<AttributeType,java.util.List<Attribute>> operationalAttributes)
Creates a new AddMessage.

Parameters:
cn - ChangeNumber of the add.
dn - DN of the added entry.
uniqueId - The Unique identifier of the added entry.
parentId - The unique Id of the parent of the added entry.
objectClasses - objectclass of the added entry.
userAttributes - user attributes of the added entry.
operationalAttributes - operational attributes of the added entry.

AddMsg

public AddMsg(ChangeNumber cn,
              java.lang.String dn,
              java.lang.String uniqueId,
              java.lang.String parentId,
              Attribute objectClass,
              java.util.Collection<Attribute> userAttributes,
              java.util.Collection<Attribute> operationalAttributes)
Creates a new AddMessage.

Parameters:
cn - ChangeNumber of the add.
dn - DN of the added entry.
uniqueId - The Unique identifier of the added entry.
parentId - The unique Id of the parent of the added entry.
objectClass - objectclass of the added entry.
userAttributes - user attributes of the added entry.
operationalAttributes - operational attributes of the added entry.

AddMsg

public AddMsg(byte[] in)
       throws java.util.zip.DataFormatException,
              java.io.UnsupportedEncodingException
Creates a new Add message from a byte[].

Parameters:
in - The byte[] from which the operation must be read.
Throws:
java.util.zip.DataFormatException - The input byte[] is not a valid AddMsg
java.io.UnsupportedEncodingException - If UTF8 is not supported by the jvm
Method Detail

createOperation

public AddOperationBasis createOperation(InternalClientConnection connection,
                                         java.lang.String newDn)
                                  throws LDAPException,
                                         ASN1Exception
Create and Operation from the message using the provided DN.

Specified by:
createOperation in class LDAPUpdateMsg
Parameters:
connection - connection to use when creating the message.
newDn - the DN to use when creating the operation.
Returns:
the created Operation.
Throws:
LDAPException - In case of LDAP decoding exception.
ASN1Exception - In case of ASN1 decoding exception.

getBytes_V1

public byte[] getBytes_V1()
                   throws java.io.UnsupportedEncodingException
Get the byte array representation of this Message. This uses the version 1 of the replication protocol (used for compatibility purpose).

Specified by:
getBytes_V1 in class LDAPUpdateMsg
Returns:
The byte array representation of this Message.
Throws:
java.io.UnsupportedEncodingException - When the encoding of the message failed because the UTF-8 encoding is not supported.

getBytes_V23

public byte[] getBytes_V23()
                    throws java.io.UnsupportedEncodingException
Get the byte array representation of this Message. This uses the version 2 of the replication protocol (used for compatibility purpose).

Specified by:
getBytes_V23 in class LDAPUpdateMsg
Returns:
The byte array representation of this Message.
Throws:
java.io.UnsupportedEncodingException - When the encoding of the message failed because the UTF-8 encoding is not supported.

getBytes_V4

public byte[] getBytes_V4()
                   throws java.io.UnsupportedEncodingException
Get the byte array representation of this Message. This uses the version 4 of the replication protocol (used for compatibility purpose).

Specified by:
getBytes_V4 in class LDAPUpdateMsg
Returns:
The byte array representation of this Message.
Throws:
java.io.UnsupportedEncodingException - When the encoding of the message failed because the UTF-8 encoding is not supported.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
                  throws ASN1Exception
Add the specified attribute/attribute value in the entry contained in this AddMsg.

Parameters:
name - The name of the attribute to add.
value - The value of the attribute to add.
Throws:
ASN1Exception - When this Msg is not valid.

getAttributes

public java.util.List<Attribute> getAttributes()
                                        throws LDAPException,
                                               ASN1Exception
Get the attributes of this add msg.

Returns:
the list of attributes
Throws:
LDAPException - In case of LDAP decoding exception
ASN1Exception - In case of ASN1 decoding exception

setParentUid

public void setParentUid(java.lang.String uid)
Set the parent unique id of this add msg.

Parameters:
uid - the parent unique id.

getParentUid

public java.lang.String getParentUid()
Get the parent unique id of this add msg.

Returns:
the parent unique id.

size

public int size()
Return the number of bytes used by this message.

Specified by:
size in class LDAPUpdateMsg
Returns:
The number of bytes used by this message.