Пример #1
0
 /**
  * Encodes an entry to the raw tree format, with optional compression.
  *
  * @param entry The entry to encode.
  * @param dataConfig Compression and cryptographic options.
  * @return A ByteSTring containing the encoded tree value.
  * @throws DirectoryException If a problem occurs while attempting to encode the entry.
  */
 static ByteString entryToDatabase(Entry entry, DataConfig dataConfig) throws DirectoryException {
   EntryCodec codec = acquireEntryCodec();
   try {
     return codec.encode(entry, dataConfig);
   } finally {
     codec.release();
   }
 }
Пример #2
0
 /**
  * Decodes an entry from its tree representation.
  *
  * <p>An entry on disk is ASN1 encoded in this format:
  *
  * <pre>
  * ByteString ::= [APPLICATION 0] IMPLICIT SEQUENCE {
  *  uncompressedSize      INTEGER,      -- A zero value means not compressed.
  *  dataBytes             OCTET STRING  -- Optionally compressed encoding of
  *                                         the data bytes.
  * }
  *
  * ID2EntryValue ::= ByteString
  *  -- Where dataBytes contains an encoding of DirectoryServerEntry.
  *
  * DirectoryServerEntry ::= [APPLICATION 1] IMPLICIT SEQUENCE {
  *  dn                      LDAPDN,
  *  objectClasses           SET OF LDAPString,
  *  userAttributes          AttributeList,
  *  operationalAttributes   AttributeList
  * }
  * </pre>
  *
  * @param bytes A byte array containing the encoded tree value.
  * @param compressedSchema The compressed schema manager to use when decoding.
  * @return The decoded entry.
  * @throws DecodeException If the data is not in the expected ASN.1 encoding format.
  * @throws LDAPException If the data is not in the expected ASN.1 encoding format.
  * @throws DataFormatException If an error occurs while trying to decompress compressed data.
  * @throws DirectoryException If a Directory Server error occurs.
  * @throws IOException if an error occurs while reading the ASN1 sequence.
  */
 static Entry entryFromDatabase(ByteString bytes, CompressedSchema compressedSchema)
     throws DirectoryException, DecodeException, LDAPException, DataFormatException, IOException {
   EntryCodec codec = acquireEntryCodec();
   try {
     return codec.decode(bytes, compressedSchema);
   } finally {
     codec.release();
   }
 }