cancel
Showing results for 
Search instead for 
Did you mean: 

SOLVED: SearchService and iso9075 problem

shmoula
Champ in-the-making
Champ in-the-making
Hi!
  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!
6 REPLIES 6

mikeh
Star Contributor
Star Contributor
Try
String query = "PATH:\"" + org.alfresco.util.ISO9075.encode(path + ".xml") + "\"";
As you only need to encode the parameters.

Mike

shmoula
Champ in-the-making
Champ in-the-making
Hi, Mike, thanks for reply!
  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)

mikeh
Star Contributor
Star Contributor
Sorry, ignore the previous comment.

Change "{http://www.alfresco.org/model/system/1.0}" to "sys:" and try again.

Mike

shmoula
Champ in-the-making
Champ in-the-making
Heey, that's it!!! 🙂
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?

mikeh
Star Contributor
Star Contributor
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:
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

shmoula
Champ in-the-making
Champ in-the-making
Ok, I'll  experiment with that, now it works, thank you!
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.