You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by "pub.cog" <pu...@gmail.com> on 2010/02/02 14:46:56 UTC
Deleting a node and it's children
Hi,
I'm trying to delete a node of my apacheds using following code:
final CoreSession adminSession = service.getAdminSession();
final LdapDN ldapDnTmp = new LdapDN(dnTmp);
if (adminSession.exists(ldapDnTmp)) {
adminSession.delete(ldapDnTmp);
}
where service is a DirectoryService object.
The node I want to delete is not empty so I get a
LdapContextNotEmptyException.
Is there any existing method that can delete a node and it's children ?
Or do I have to iterate and delete them one by one ?
If I have to iterate, do you have some code sample I could use ? (my
node only have objectClass=person)...
thanks
--
Benjamin Francisoud
Re: Deleting a node and it's children
Posted by "pub.cog" <pu...@gmail.com>.
Le 02/02/2010 14:59, Emmanuel Lcharny a écrit :
> You have to iterate. Deletion of a leaf when it has children is
> forbidden by the protocol.
>
> You may find hundreds of sample on google.
>
Ok thanks
Re: Deleting a node and it's children
Posted by Emmanuel Lcharny <el...@gmail.com>.
pub.cog a écrit :
> Hi,
>
> I'm trying to delete a node of my apacheds using following code:
>
> final CoreSession adminSession = service.getAdminSession();
> final LdapDN ldapDnTmp = new LdapDN(dnTmp);
> if (adminSession.exists(ldapDnTmp)) {
> adminSession.delete(ldapDnTmp);
> }
>
> where service is a DirectoryService object.
>
> The node I want to delete is not empty so I get a
> LdapContextNotEmptyException.
>
> Is there any existing method that can delete a node and it's children
> ? Or do I have to iterate and delete them one by one ?
>
> If I have to iterate, do you have some code sample I could use ? (my
> node only have objectClass=person)...
You have to iterate. Deletion of a leaf when it has children is
forbidden by the protocol.
You may find hundreds of sample on google.
Re: Deleting a node and it's children
Posted by "pub.cog" <pu...@gmail.com>.
Thanks I'll take a look :)
Le 02/02/2010 16:41, Kiran Ayyagari a écrit :
>
>
>> Is there any existing method that can delete a node and it's children
>> ? Or do I have to iterate and delete them one by one ?
>>
>> If I have to iterate, do you have some code sample I could use ? (my
>> node only have objectClass=person)...
>
> take a look at the deleteTree(LdapDN) and deleteRecursive() methods in
> [1].
> Note that this class is part of the new ApacheDS client-api which is
> under development.
>
> [1] -
> http://svn.apache.org/repos/asf/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
>
>
> HTH
> Kiran Ayyagari
Re: Deleting a node and it's children
Posted by Kiran Ayyagari <ay...@gmail.com>.
> Is there any existing method that can delete a node and it's children ?
> Or do I have to iterate and delete them one by one ?
>
> If I have to iterate, do you have some code sample I could use ? (my
> node only have objectClass=person)...
take a look at the deleteTree(LdapDN) and deleteRecursive() methods in [1].
Note that this class is part of the new ApacheDS client-api which is under development.
[1] -
http://svn.apache.org/repos/asf/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
HTH
Kiran Ayyagari