SOLVED: SearchService and iso9075 problem

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 05:17 AM
Hi!
I have following piece of code and it does very interesting things:
When I'm logged in as an Administrator, it works as expected. When I'm logged in as normal user, it does not work:
So I found that I need to encode it as an ISO9075, I did:
But it doesn't work, it finds nothing :-(. Where can be problem?
Thanks in advance!
I have following piece of code and it does very interesting things:
private Node getReportNode(Node noda) { String path = noda.getPath(); path = path.replaceAll("\\{http://www.alfresco.org/model/application/1.0\\}", "app:"); path = path.replaceAll("\\{http://www.alfresco.org/model/content/1.0\\}", "cm:"); String query = "PATH:\"" + path + ".xml\""; StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); ResultSet resultSet = getSearchService().query(storeRef, SearchService.LANGUAGE_LUCENE, query); for (ResultSetRow row : resultSet) { Node foundNode = new Node(row.getNodeRef()); if (foundNode.hasAspect(ArchivaceModel.archProfileDescription)) return foundNode; } return null; }
When I'm logged in as an Administrator, it works as expected. When I'm logged in as normal user, it does not work:
Unable to delete File due to system error: Failed to parse query: PATH:"/app:company_home/app:user_homes/{http://www.alfresco.org/model/system/1.0}xbalak00/cm:Profile/cm:kcab.png.xml"
So I found that I need to encode it as an ISO9075, I did:
String query = org.alfresco.util.ISO9075.encode("PATH:\"" + path + ".xml\"");
But it doesn't work, it finds nothing :-(. Where can be problem?
Thanks in advance!
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 06:25 AM
Try
Mike
String query = "PATH:\"" + org.alfresco.util.ISO9075.encode(path + ".xml") + "\"";
As you only need to encode the parameters.Mike

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 08:05 AM
Hi, Mike, thanks for reply!
I tried to encode parameters, as you wrote:
But it still doesn't work. Whole query now looks like this:
(note: that double extension - .png.xml is ok)
I tried to encode parameters, as you wrote:
String query = "PATH:\"" + org.alfresco.util.ISO9075.encode(path + ".xml") + "\"";
But it still doesn't work. Whole query now looks like this:
PATH:"_x002f_app_x003a_company_home_x002f_cm_x003a_Profile_x002f_cm_x003a_kcab.png.xml"
(note: that double extension - .png.xml is ok)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 08:11 AM
Sorry, ignore the previous comment.
Change "{http://www.alfresco.org/model/system/1.0}" to "sys:" and try again.
Mike
Change "{http://www.alfresco.org/model/system/1.0}" to "sys:" and try again.
Mike

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 08:30 AM
Heey, that's it!!! 🙂
Many thanks, Mike! And before I click on yes on your profile I have to ask one more question: really don't I need to ISO9075.encode() anywhere?
path = path.replaceAll("\\{http://www.alfresco.org/model/system/1.0\\}", "sys:");
Many thanks, Mike! And before I click on yes on your profile I have to ask one more question: really don't I need to ISO9075.encode() anywhere?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 08:37 AM
Technically, each part after the "cm:" or "app:" or "sys:" parts of the path should be run though the ISO9075.encode() function.
e.g. the Office Add-in webscripts when searching for tags or keywords:
Thanks,
Mike
e.g. the Office Add-in webscripts when searching for tags or keywords:
searchString = search.ISO9075Encode(searchString);if (searchType == "tag"){ queryString = "PATH:\"/cm:categoryRoot/cm:taggable/cm:" + searchString + "/member\"";}else{ queryString = "(TEXT:\"" + searchString + "\") OR (@cm\\:name:*" + searchString + "*)";}
Thanks,
Mike

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 08:49 AM
Ok, I'll experiment with that, now it works, thank you!
