Class AddMsg

  • All Implemented Interfaces:
    Comparable<UpdateMsg>

    public class AddMsg
    extends LDAPUpdateMsg
    This class is used to exchange Add operation between LDAP servers and replication servers.
    • Constructor Detail

      • AddMsg

        public AddMsg​(CSN csn,
                      DN dn,
                      String entryUUID,
                      String parentEntryUUID,
                      Map<ObjectClass,​String> objectClasses,
                      Map<AttributeType,​List<Attribute>> userAttributes,
                      Map<AttributeType,​List<Attribute>> operationalAttributes)
        Creates a new AddMessage.
        Parameters:
        csn - CSN of the add.
        dn - DN of the added entry.
        entryUUID - The Unique identifier of the added entry.
        parentEntryUUID - 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​(CSN csn,
                      DN dn,
                      String uniqueId,
                      String parentId,
                      Attribute objectClass,
                      Iterable<Attribute> userAttributes,
                      Iterable<Attribute> operationalAttributes)
        Creates a new AddMessage.
        Parameters:
        csn - CSN 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 DataFormatException
        Creates a new Add message from a byte[].
        Parameters:
        in - The byte[] from which the operation must be read.
        Throws:
        DataFormatException - The input byte[] is not a valid AddMsg
    • Method Detail

      • getBytes_V1

        public byte[] getBytes_V1()
        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.
      • getBytes_V23

        public byte[] getBytes_V23()
        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.
      • getBytes_V45

        public byte[] getBytes_V45​(short protocolVersion)
        Get the byte array representation of this message. This uses the provided version number which must be version 4 or newer.
        Specified by:
        getBytes_V45 in class LDAPUpdateMsg
        Parameters:
        protocolVersion - the actual protocol version to encode into
        Returns:
        The byte array representation of this Message.
      • addAttribute

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

        A failure to encode the attribute is reported rather than swallowed: the caller adds the attribute because the entry must carry it - addConflict() adds the ds-sync-conflict marker which says why an entry was renamed - and an entry stored without it is a conflict the repair tool has nothing to find it by. The attributes this message already carries are left as they were, so a message which could not take the new attribute still encodes the entry it did before.

        Parameters:
        name - The name of the attribute to add.
        value - The value of the attribute to add.
        Throws:
        IOException - When the attribute could not be encoded.
      • setParentEntryUUID

        public void setParentEntryUUID​(String entryUUID)
        Set the parent unique id of this add msg.
        Parameters:
        entryUUID - the parent unique id.
      • getParentEntryUUID

        public String getParentEntryUUID()
        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.