Java Code Examples for org.apache.directory.api.ldap.model.exception.LdapException#getLocalizedMessage()
The following examples show how to use
org.apache.directory.api.ldap.model.exception.LdapException#getLocalizedMessage() .
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: DefaultEntry.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Attribute get( String alias ) { try { String id = getId( alias ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); return attributes.get( attributeType.getOid() ); } catch ( LdapException ne ) { String message = ne.getLocalizedMessage(); LOG.error( message ); return null; } } else { return attributes.get( id ); } } catch ( IllegalArgumentException iea ) { LOG.error( I18n.err( I18n.ERR_13217_FAILED_LOOKUP_AT, alias ) ); return null; } }
Example 2
Source File: DefaultEntry.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the Dn dn = new Dn( schemaManager ); dn.readExternal( in ); // Read the number of attributes int nbAttributes = in.readInt(); // Read the attributes for ( int i = 0; i < nbAttributes; i++ ) { // Read each attribute Attribute attribute = new DefaultAttribute(); attribute.readExternal( in ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( attribute.getId() ); attribute.apply( attributeType ); attributes.put( attributeType.getOid(), attribute ); } catch ( LdapException le ) { String message = le.getLocalizedMessage(); LOG.error( message ); throw new IOException( message, le ); } } else { attributes.put( attribute.getId(), attribute ); } } }
Example 3
Source File: DefaultEntry.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Attribute get( String alias ) { try { String id = getId( alias ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); return attributes.get( attributeType.getOid() ); } catch ( LdapException ne ) { String message = ne.getLocalizedMessage(); LOG.error( message ); return null; } } else { return attributes.get( id ); } } catch ( IllegalArgumentException iea ) { LOG.error( I18n.err( I18n.ERR_04134, alias ) ); return null; } }
Example 4
Source File: DefaultEntry.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the Dn dn = new Dn( schemaManager ); dn.readExternal( in ); // Read the number of attributes int nbAttributes = in.readInt(); // Read the attributes for ( int i = 0; i < nbAttributes; i++ ) { // Read each attribute Attribute attribute = new DefaultAttribute(); attribute.readExternal( in ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( attribute.getId() ); attribute.apply( attributeType ); attributes.put( attributeType.getOid(), attribute ); } catch ( LdapException le ) { String message = le.getLocalizedMessage(); LOG.error( message ); throw new IOException( message ); } } else { attributes.put( attribute.getId(), attribute ); } } }
Example 5
Source File: ServerEntryUtils.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Convert a BasicAttributes or a AttributesImpl to a ServerEntry * * @param attributes the BasicAttributes or AttributesImpl instance to convert * @param registries The registries, needed ro build a ServerEntry * @param dn The Dn which is needed by the ServerEntry * @return An instance of a ServerEntry object * * @throws LdapInvalidAttributeTypeException If we get an invalid attribute */ public static Entry toServerEntry( Attributes attributes, Dn dn, SchemaManager schemaManager ) throws LdapInvalidAttributeTypeException { if ( attributes instanceof BasicAttributes ) { try { Entry entry = new DefaultEntry( schemaManager, dn ); for ( NamingEnumeration<? extends javax.naming.directory.Attribute> attrs = attributes.getAll(); attrs .hasMoreElements(); ) { javax.naming.directory.Attribute attr = attrs.nextElement(); String attributeId = attr.getID(); String id = SchemaUtils.stripOptions( attributeId ); Set<String> options = SchemaUtils.getOptions( attributeId ); // TODO : handle options. AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); Attribute serverAttribute = ServerEntryUtils.toServerAttribute( attr, attributeType ); if ( serverAttribute != null ) { entry.put( serverAttribute ); } } return entry; } catch ( LdapException ne ) { throw new LdapInvalidAttributeTypeException( ne.getLocalizedMessage() ); } } else { return null; } }
Example 6
Source File: DefaultEntry.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public Attribute get( String alias ) { try { String id = getId( alias ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); return attributes.get( attributeType.getOid() ); } catch ( LdapException ne ) { String message = ne.getLocalizedMessage(); LOG.error( message ); return null; } } else { return attributes.get( id ); } } catch ( IllegalArgumentException iea ) { LOG.error( I18n.err( I18n.ERR_04134, alias ) ); return null; } }
Example 7
Source File: DefaultEntry.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // Read the Dn dn = new Dn( schemaManager ); dn.readExternal( in ); // Read the number of attributes int nbAttributes = in.readInt(); // Read the attributes for ( int i = 0; i < nbAttributes; i++ ) { // Read each attribute Attribute attribute = new DefaultAttribute(); attribute.readExternal( in ); if ( schemaManager != null ) { try { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( attribute.getId() ); attribute.apply( attributeType ); attributes.put( attributeType.getOid(), attribute ); } catch ( LdapException le ) { String message = le.getLocalizedMessage(); LOG.error( message ); throw new IOException( message ); } } else { attributes.put( attribute.getId(), attribute ); } } }
Example 8
Source File: ServerEntryUtils.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Convert a BasicAttributes or a AttributesImpl to a ServerEntry * * @param attributes the BasicAttributes or AttributesImpl instance to convert * @param registries The registries, needed ro build a ServerEntry * @param dn The Dn which is needed by the ServerEntry * @return An instance of a ServerEntry object * * @throws LdapInvalidAttributeTypeException If we get an invalid attribute */ public static Entry toServerEntry( Attributes attributes, Dn dn, SchemaManager schemaManager ) throws LdapInvalidAttributeTypeException { if ( attributes instanceof BasicAttributes ) { try { Entry entry = new DefaultEntry( schemaManager, dn ); for ( NamingEnumeration<? extends javax.naming.directory.Attribute> attrs = attributes.getAll(); attrs .hasMoreElements(); ) { javax.naming.directory.Attribute attr = attrs.nextElement(); String attributeId = attr.getID(); String id = SchemaUtils.stripOptions( attributeId ); Set<String> options = SchemaUtils.getOptions( attributeId ); // TODO : handle options. AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); Attribute serverAttribute = ServerEntryUtils.toServerAttribute( attr, attributeType ); if ( serverAttribute != null ) { entry.put( serverAttribute ); } } return entry; } catch ( LdapException ne ) { throw new LdapInvalidAttributeTypeException( ne.getLocalizedMessage() ); } } else { return null; } }