cancel
Showing results for 
Search instead for 
Did you mean: 

lucene query to check if folder exists

aurora7795
Champ in-the-making
Champ in-the-making
Hi there,
I'm trying to write a method that interacts with the WebServices to see if a folder exists in a workspace. Can anyone point me at a lucene query that will do something like this?

Thanks!
Martin BG
4 REPLIES 4

andy
Champ on-the-rise
Champ on-the-rise
Hi

See
http://wiki.alfresco.com/wiki/Search#Path_Queries

You should be able to get the path of the folder from the node service and then add     /*:woof        to find the folder called woof. You may have to escape the path (http://wiki.alfresco.com/wiki/Search#ISO_9075_encoding).

Regards

Andy

sergio
Champ in-the-making
Champ in-the-making
Hi Andy.

I have the same problem and I am not able to resolve it. I spent much time for this task but all my tests failed….

The getPath() method bot for the ParentRefence class and the Refence class does not work: it always returns a null value, so I cannot use the path value to create a query correctly.

Could you kindly provide me with an example of code to resolve this problem?

I have the ID of the node….

Thanks for anything.

Sergio

andy
Champ on-the-rise
Champ on-the-rise
Hi

Maybe I was a bit naive or missed the web service reference ….

The path is not filled in on references returned from the web service API.
It is likely to be filled in in the future.

It is not easy to get paths via the web services.

So you could check for an existing doc in a folder using a lucene query ..


+PARENT:"FolderNodeRef"  +@cm\:name:"name"

You will have to build the FolderNodeRef string as it is not exposed via the WS reference. See NodeRef.toString() for what to do given the store, protocol and uuid. You will only be able to query for immediate children.

Regards

Andy

cludt
Champ in-the-making
Champ in-the-making
Hi,


+PARENT:"FolderNodeRef"  +@cm\:name:"name"

but this will also find partial matches. At least, it's better than to step through all subfolders and to compare the names. Now, you have only to compare the names that are returned by that query.

Best regards
  Christian