org.apache.directory.api.ldap.model.exception.LdapOperationErrorException Java Examples

The following examples show how to use org.apache.directory.api.ldap.model.exception.LdapOperationErrorException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
private LdapReferralException buildReferralException( Entry parentEntry, Dn childDn ) throws LdapException
{
    // Get the Ref attributeType
    Attribute refs = parentEntry.get( SchemaConstants.REF_AT );

    List<String> urls = new ArrayList<String>();

    try
    {
        // manage each Referral, building the correct URL for each of them
        for ( Value<?> url : refs )
        {
            // we have to replace the parent by the referral
            LdapUrl ldapUrl = new LdapUrl( url.getString() );

            // We have a problem with the Dn : we can't use the UpName,
            // as we may have some spaces around the ',' and '+'.
            // So we have to take the Rdn one by one, and create a
            // new Dn with the type and value UP form

            Dn urlDn = ldapUrl.getDn().add( childDn );

            ldapUrl.setDn( urlDn );
            urls.add( ldapUrl.toString() );
        }
    }
    catch ( LdapURLEncodingException luee )
    {
        throw new LdapOperationErrorException( luee.getMessage(), luee );
    }

    // Return with an exception
    LdapReferralException lre = new LdapReferralException( urls );
    lre.setRemainingDn( childDn );
    lre.setResolvedDn( parentEntry.getDn() );
    lre.setResolvedObject( parentEntry );

    return lre;
}
 
Example #2
Source File: DefaultOperationManager.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
private LdapReferralException buildReferralException( Entry parentEntry, Dn childDn ) throws LdapException
{
    // Get the Ref attributeType
    Attribute refs = parentEntry.get( SchemaConstants.REF_AT );

    List<String> urls = new ArrayList<String>();

    try
    {
        // manage each Referral, building the correct URL for each of them
        for ( Value<?> url : refs )
        {
            // we have to replace the parent by the referral
            LdapUrl ldapUrl = new LdapUrl( url.getString() );

            // We have a problem with the Dn : we can't use the UpName,
            // as we may have some spaces around the ',' and '+'.
            // So we have to take the Rdn one by one, and create a
            // new Dn with the type and value UP form

            Dn urlDn = ldapUrl.getDn().add( childDn );

            ldapUrl.setDn( urlDn );
            urls.add( ldapUrl.toString() );
        }
    }
    catch ( LdapURLEncodingException luee )
    {
        throw new LdapOperationErrorException( luee.getMessage(), luee );
    }

    // Return with an exception
    LdapReferralException lre = new LdapReferralException( urls );
    lre.setRemainingDn( childDn );
    lre.setResolvedDn( parentEntry.getDn() );
    lre.setResolvedObject( parentEntry );

    return lre;
}