/** * Encode the Referral message to a PDU. * * @param buffer The buffer where to put the PDU * @param referral The referral to encode * @exception EncoderException If the encoding failed */ public static void encodeReferral( ByteBuffer buffer, Referral referral ) throws EncoderException { Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes(); if ( ( ldapUrlsBytes != null ) && ( !ldapUrlsBytes.isEmpty() ) ) { // Encode the referrals sequence // The referrals length MUST have been computed before ! buffer.put( ( byte ) LdapCodecConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG ); buffer.put( TLV.getBytes( referral.getReferralLength() ) ); // Each referral for ( byte[] ldapUrlBytes : ldapUrlsBytes ) { // Encode the current referral BerValue.encode( buffer, ldapUrlBytes ); } } }
/** * Encode the Referral message to a PDU. * * @param buffer The buffer where to put the PDU * @param referral The referral to encode * @exception EncoderException If the encoding failed */ public static void encodeReferral( ByteBuffer buffer, Referral referral ) throws EncoderException { Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes(); if ( ( ldapUrlsBytes != null ) && ( !ldapUrlsBytes.isEmpty() ) ) { // Encode the referrals sequence // The referrals length MUST have been computed before ! buffer.put( ( byte ) LdapCodecConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG ); buffer.put( TLV.getBytes( referral.getReferralLength() ) ); // Each referral for ( byte[] ldapUrlBytes : ldapUrlsBytes ) { // Encode the current referral BerValue.encode( buffer, ldapUrlBytes ); } } }
/** * Encode the Referral message to a PDU. * * @param buffer The buffer where to put the PDU * @param referral The referral to encode * @exception EncoderException If the encoding failed */ public static void encodeReferral( ByteBuffer buffer, Referral referral ) throws EncoderException { Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes(); if ( ( ldapUrlsBytes != null ) && ( !ldapUrlsBytes.isEmpty() ) ) { // Encode the referrals sequence // The referrals length MUST have been computed before ! buffer.put( ( byte ) LdapCodecConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG ); buffer.put( TLV.getBytes( referral.getReferralLength() ) ); // Each referral for ( byte[] ldapUrlBytes : ldapUrlsBytes ) { // Encode the current referral BerValue.encode( buffer, ldapUrlBytes ); } } }
/** * Determines if the supplied response should result in an operation retry. * * @param request that produced the exception * @param resultResponse provider response * * @throws LdapException wrapping the ldap exception */ protected void throwOperationException(final Request request, final ResultResponse resultResponse) throws LdapException { final LdapResult ldapResult = resultResponse.getLdapResult(); final Referral ref = ldapResult.getReferral(); ProviderUtils.throwOperationException( config.getOperationExceptionResultCodes(), String.format("Ldap returned result code: %s", ldapResult.getResultCode()), ldapResult.getResultCode().getResultCode(), ldapResult.getMatchedDn() != null ? ldapResult.getMatchedDn().getName() : null, processResponseControls(config.getControlProcessor(), request.getControls(), resultResponse), ref != null ? ref.getLdapUrls().toArray(new String[ref.getReferralLength()]) : null, false); }
/** * Creates an operation response with the supplied response data. * * @param <T> type of response * @param request containing controls * @param result of the operation * @param resultResponse provider response * * @return operation response */ protected <T> Response<T> createResponse(final Request request, final T result, final ResultResponse resultResponse) { final LdapResult ldapResult = resultResponse.getLdapResult(); final Referral ref = ldapResult.getReferral(); return new Response<>( result, ResultCode.valueOf(ldapResult.getResultCode().getValue()), ldapResult.getDiagnosticMessage(), ldapResult.getMatchedDn() != null ? ldapResult.getMatchedDn().getName() : null, processResponseControls(config.getControlProcessor(), request.getControls(), resultResponse), ref != null ? ref.getLdapUrls().toArray(new String[ref.getReferralLength()]) : null, resultResponse.getMessageId()); }