You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Valery Maslau (Created) (JIRA)" <ji...@apache.org> on 2011/09/28 12:45:45 UTC

[jira] [Created] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
--------------------------------------------------------------------------------------------------------------------

                 Key: DIRAPI-53
                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
             Project: Directory Client API
          Issue Type: Bug
    Affects Versions: 1.0.0-M8
         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
            Reporter: Valery Maslau


There is the code:

public class LDAP_01 {

      public static void main(String[] args) {
        System.out.println("Started.");
        LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
        connection.setTimeOut(30000);
        Dn dn;
        try {
            dn = new Dn("uid=admin,ou=system");
            BindRequest brq = new BindRequestImpl();
            brq.setName(dn);
            brq.setCredentials("somepassword");
            BindResponse br = connection.bind(brq);
            if (connection.isConnected()) {
                System.out.println("Connected.");
                if (connection.isAuthenticated()) {
                    if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
                        System.out.println("Yeah! Binded...");
                        dn = new Dn("uid=mvn,o=ipgo");
                        SearchRequest sr = new SearchRequestImpl();
                        sr.setBase(dn);
                        sr.setFilter("(cn=mvnval)");
                        sr.setScope(SearchScope.SUBTREE);
                        SearchCursor scr = connection.search(sr);
                        scr.next();
                        Response rsp = scr.get();
                        if (rsp != null) {
                            if (rsp instanceof SearchResultEntry) {
                                SearchResultEntry sre = (SearchResultEntry) rsp;
                                Entry entr = sre.getEntry();
                                System.out.println("#### " + entr.toString());
                                Set<AttributeType> attrs = entr.getAttributeTypes();
                                if (attrs.isEmpty()) {
                                    System.out.println("#### Empty Attributes!");
                                }
                                for (AttributeType item : attrs) {
                                    System.out.println("#### " + item.toString());
                                }
                            }
                        }
                    }

                }
            }
        } catch (LdapException e1) {
            e1.printStackTrace();
            System.exit(0);
        } catch (IOException e1) {
            e1.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            connection.close();
            System.out.println("#### Connection closed");
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("Yeah! Finished.");
    }
}

There is the console output:
Connected.
Yeah! Binded...
#### Entry
    dn: uid=mvn,o=ipgo
    objectClass: organizationalPerson
    objectClass: person
    objectClass: inetOrgPerson
    objectClass: top
    uid: mvn
    userPassword: ****************************
    sn: m
    title: cn=SEM,ou=Roles,o=ipgo
    title: cn=Software Engineering Manager,ou=Roles,o=ipgo
    cn: mvnval

#### Empty Attributes!
#### Connection closed
Yeah! Finished.

So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 

The method from the DefaultEntry.class ever returns empty attributeTypes: 
public final class DefaultEntry implements Entry
......
public Set<AttributeType> getAttributeTypes()
    {
        Set<AttributeType> attributeTypes = new HashSet<AttributeType>();

        for ( Attribute attribute : attributes.values() )
        {
            if ( attribute.getAttributeType() != null )
            {
                attributeTypes.add( attribute.getAttributeType() );
            }
        }

        return attributeTypes;
    }


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Pierre-Arnaud Marcelot (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13116413#comment-13116413 ] 

Pierre-Arnaud Marcelot commented on DIRAPI-53:
----------------------------------------------

That was also my thought, Emmanuel.

This would avoid any confusion...
                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Emmanuel Lecharny (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRAPI-53.
-------------------------------------

    Resolution: Fixed

As suggested by Pierre-Arnaud (and not me), the getAttributeTypes() method has been removed, and a getAttributes( method has been added :

http://svn.apache.org/viewvc?rev=1176880&view=rev
                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Pierre-Arnaud Marcelot (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13116410#comment-13116410 ] 

Pierre-Arnaud Marcelot commented on DIRAPI-53:
----------------------------------------------

I think there's also a confusion on the way to get attributes and values (Attribute != AttributeType).

Both Entry (org.apache.directory.shared.ldap.model.entry.Entry) and Attribute (org.apache.directory.shared.ldap.model.entry.Attribute) interfaces are built as iterators implementing the Iterable<T> interface.

In your code example, here's how you should iterate on attributes, and then values, on a given entry entry:
-----------------------------------------------------------
for ( Attribute attribute : entry )
{
    for ( Value<?> value : attribute )
    {
        // Do something with the value
    }
}
-----------------------------------------------------------

Hope this helps...
                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Emmanuel Lecharny (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRAPI-53.
-----------------------------------

    
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>             Fix For: 1.0.0-M9
>
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Emmanuel Lecharny (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny updated DIRAPI-53:
------------------------------------

    Fix Version/s: 1.0.0-M9
    
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>             Fix For: 1.0.0-M9
>
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Kiran Ayyagari (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13116403#comment-13116403 ] 

Kiran Ayyagari commented on DIRAPI-53:
--------------------------------------

The connection need to be schema aware to get the AttributeTypes.
Call connection.loadSchema() or connection.loadSchema( SchemaLoader ) to make the connection schema aware.
(Note: there might be classloader issues with the loadSchema() method when the directory server is run as part of an app server)
                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Emmanuel Lecharny (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13116408#comment-13116408 ] 

Emmanuel Lecharny commented on DIRAPI-53:
-----------------------------------------

I'm not sure that the getAttributeTypes() method is a good idea at all.

We should provide a getAttributes() method which returns a list of all the contained Attributes in the entry (currently, you have to use an iterator for that).

thoughts ?
                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DIRAPI-53) Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values

Posted by "Valery Maslau (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13116513#comment-13116513 ] 

Valery Maslau commented on DIRAPI-53:
-------------------------------------

Hello.

To Kiran Ayyagari :
I've got tried connection.loadSchema() method (connection.loadSchema( SchemaLoader  ) is absent in LDAP API 1.0.0-M8). In fact having a very few entries in LDAP I could not wait to finish this method during 10 mins of running, was cancelled by timeout. The memory grows very fast, CPU usage about 25-30%. This method looks very both memory and CPU consumption.

To Emmanuel Lecharny: I think your idea is very good. The unambiguous method that will allow retrieve Attributes from Entry.

Thanks a lot for your prompt replies.

                
> Method getAttributeTypes() from the org.apache.directory.shared.ldap.model.entry.DefaultEntry does not return values
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-53
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-53
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M8
>         Environment: Win7 64bit, RAM 8Gb, ApacheDS 1.5, LDAP API 1.0.0-M8, JBoss Developer Studio 4, JDK 1.6.0_u27 64bit
>            Reporter: Valery Maslau
>
> There is the code:
> public class LDAP_01 {
>       public static void main(String[] args) {
>         System.out.println("Started.");
>         LdapConnection connection = new LdapNetworkConnection("localhost", 10389);
>         connection.setTimeOut(30000);
>         Dn dn;
>         try {
>             dn = new Dn("uid=admin,ou=system");
>             BindRequest brq = new BindRequestImpl();
>             brq.setName(dn);
>             brq.setCredentials("somepassword");
>             BindResponse br = connection.bind(brq);
>             if (connection.isConnected()) {
>                 System.out.println("Connected.");
>                 if (connection.isAuthenticated()) {
>                     if (ResultCodeEnum.SUCCESS == br.getLdapResult().getResultCode()) {
>                         System.out.println("Yeah! Binded...");
>                         dn = new Dn("uid=mvn,o=ipgo");
>                         SearchRequest sr = new SearchRequestImpl();
>                         sr.setBase(dn);
>                         sr.setFilter("(cn=mvnval)");
>                         sr.setScope(SearchScope.SUBTREE);
>                         SearchCursor scr = connection.search(sr);
>                         scr.next();
>                         Response rsp = scr.get();
>                         if (rsp != null) {
>                             if (rsp instanceof SearchResultEntry) {
>                                 SearchResultEntry sre = (SearchResultEntry) rsp;
>                                 Entry entr = sre.getEntry();
>                                 System.out.println("#### " + entr.toString());
>                                 Set<AttributeType> attrs = entr.getAttributeTypes();
>                                 if (attrs.isEmpty()) {
>                                     System.out.println("#### Empty Attributes!");
>                                 }
>                                 for (AttributeType item : attrs) {
>                                     System.out.println("#### " + item.toString());
>                                 }
>                             }
>                         }
>                     }
>                 }
>             }
>         } catch (LdapException e1) {
>             e1.printStackTrace();
>             System.exit(0);
>         } catch (IOException e1) {
>             e1.printStackTrace();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         try {
>             connection.close();
>             System.out.println("#### Connection closed");
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>         System.out.println("Yeah! Finished.");
>     }
> }
> There is the console output:
> Connected.
> Yeah! Binded...
> #### Entry
>     dn: uid=mvn,o=ipgo
>     objectClass: organizationalPerson
>     objectClass: person
>     objectClass: inetOrgPerson
>     objectClass: top
>     uid: mvn
>     userPassword: ****************************
>     sn: m
>     title: cn=SEM,ou=Roles,o=ipgo
>     title: cn=Software Engineering Manager,ou=Roles,o=ipgo
>     cn: mvnval
> #### Empty Attributes!
> #### Connection closed
> Yeah! Finished.
> So, the method getAttributeTypes returns the empty Set ever; however it can be noticed that the data is present into the Entry object, but can be retrieved only using toString() method. 
> The method from the DefaultEntry.class ever returns empty attributeTypes: 
> public final class DefaultEntry implements Entry
> ......
> public Set<AttributeType> getAttributeTypes()
>     {
>         Set<AttributeType> attributeTypes = new HashSet<AttributeType>();
>         for ( Attribute attribute : attributes.values() )
>         {
>             if ( attribute.getAttributeType() != null )
>             {
>                 attributeTypes.add( attribute.getAttributeType() );
>             }
>         }
>         return attributeTypes;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira