All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.novell.ldap.extensions.PartitionEntryCountResponse Maven / Gradle / Ivy

/* **************************************************************************
 * $OpenLDAP$
 *
 * Copyright (C) 2001 Novell, Inc. All Rights Reserved.
 *
 * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
 * TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
 * TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
 * AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
 * IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
 * OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
 * PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
 ******************************************************************************/
package com.novell.ldap.extensions;

import com.novell.ldap.LDAPExtendedResponse;
import com.novell.ldap.LDAPException;
import com.novell.ldap.asn1.LBERDecoder;
import com.novell.ldap.asn1.ASN1Integer;
import com.novell.ldap.rfc2251.RfcLDAPMessage;
import java.io.IOException;

/**
 * Returns the number of entries in the partition.
 *
 *  

An object in this class is generated from an ExtendedResponse object * using the ExtendedResponseFactory class.

* *

The PartitionEntryCountResponse extension uses the following * OID:
*    2.16.840.1.113719.1.27.100.14

* */ public class PartitionEntryCountResponse extends LDAPExtendedResponse { //The count of the objects returned by the server is saved here private int count; /** * Constructs an object from the responseValue which contains the * entry count. * *

The constructor parses the responseValue which has the following * format:
* responseValue ::=
*      count     INTEGER

* * @exception IOException The response value could not be decoded. */ public PartitionEntryCountResponse (RfcLDAPMessage rfcMessage) throws IOException { super(rfcMessage); if (getResultCode() == LDAPException.SUCCESS) { // parse the contents of the reply byte [] returnedValue = this.getValue(); if (returnedValue == null) throw new IOException("No returned value"); // Create a decoder object LBERDecoder decoder = new LBERDecoder(); if (decoder == null) throw new IOException("Decoding error"); ASN1Integer asn1_count = (ASN1Integer)decoder.decode(returnedValue); if (asn1_count == null) throw new IOException("Decoding error"); count = asn1_count.intValue(); } else { count = -1; } } /** * Returns the number of entries in the naming context. * * @return The count of the number of objects returned. */ public int getCount() { return count; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy