Expand my Community achievements bar.

SOLVED

Unable to get key/value using Query Builder API

Avatar

Level 3

I am trying to get the cq:name and dam:relativePath of PDFs found within a dam content folder. I followed this tutorial:

Adobe Experience Manager Help | Querying Adobe Experience Manager 6.4 JCR data using the QueryBuilde...

I have everything plugged in, debugged and working except that when I click my button to submit my AJAX call it says that no data is available. Here is my hashmap:

Map<String, String> map = new HashMap<String, String>();

map.put("type", "dam:AssetContent");
map.put("path", "/content/dam/formsanddocuments/provider-forms");
map.put("p.limit", "20");

Query query = builder.createQuery(PredicateGroup.create(map), session);

query.setStart(0);
query.setHitsPerPage(20);

SearchResult result = query.getResult();
int hitsPerPage = result.getHits().size();

Here is my AJAX call:

$(document).ready(function() {
   var table = $('.forms-table').DataTable();
   var submit = $('.submit');

   submit.on('click', function() {
   $.ajax({
   type: 'GET',
   url:'/bin/myCustData',
   data:'type='+ 'data',
   success: function(msg) {
   var xml = msg;

   var oTable = $('.forms-table').dataTable();
   oTable.fnClearTable(true);

   $(xml).find('Form').each(function() {
   var $field = $(this);
   var Title = $field.find('Title').text();
   var Path = $field.find('Path').text();

   oTable.fnAddData( [
   Title,
   Path
   ]);
  });
  }
  });
  });
});

I tested the query in the debugger and am able to yield the right properties so I'm not sure what I'm doing wrong here. Does anyone have an idea? Thank you so much in advance for your help!

1 Accepted Solution

Avatar

Correct answer by
Level 10

That error means that the POM file was not properly setup. Can you build your bundle - including the POM dependencies as shown in the artilce. You also have to setup the system user and permissions as stated. If you would like - we can setup a BLUEJEAN call and i wcan walk you through  the process.

View solution in original post

10 Replies

Avatar

Level 10

When you click the button - look at the network tab in chrome - are you getting 200 as the HTTP response.

Client2.png

When you follow that tutorial and pull in Employee data -- as shown in the example (install the package) - do you see the component populated with data?

This works - watch the video at end of article.

Avatar

Level 10

Also - make sure you OSGi bundle is in active state - check that HTTP Response code.

Avatar

Level 10

Did you create a system user and setup the Sling Mapping Service config too. You need to do that!

Avatar

Level 10

Just retested - if you follow the article - you will get this result:

Client.png

Avatar

Community Advisor

As Scott mentioned , could you please check if the service is returning 200 OK in the network tab ? If no, please pull the error logs.Your error log should be able to tell you what is failing in your case. If hyou can share the same we can guide you what went wrong

Thanks

Veena

Avatar

Level 10

For now - follow the article to see if you can pull a result set, etc. Once you know its working - you can try and modify the Query Builder code.

Avatar

Level 3

So, I received a 200 HTTP response for that implementation, but I went ahead made the code consistent with the tutorial verbatim. I am still getting a 200 HTTP response but no data.

I checked and everything is consistent down to the 'data' user and User Service Mapping.

I did validate my package and received this error:

1 unsatisfied OSGi package import in 1 bundle.

1. Unsatisfied package import javax.inject-[0.0.0,1.0.0) in bundle Demo_Site.Demo.core-1.0.0.SNAPSHOT present at OSGi

Following 1 bundle will go from 'Active' to 'Installed' state if you install this content package.

1. Demo_Site.Demo.core-1.0.0.SNAPSHOT

The javax.inject is referring to the HelloWord java model though I'm not sure if this is relevant.

Thanks again for your help!

EDIT:

Also, I see the employee data under /content/employees and, I did confirm, the bundle is in an active state.

Avatar

Level 3

Does the bundle location matter? Mine is found at

`jcrinstall:/apps/QUeryJCR64/install/QUeryJCR64.core-1.0-SNAPSHOT.jar`

Avatar

Correct answer by
Level 10

That error means that the POM file was not properly setup. Can you build your bundle - including the POM dependencies as shown in the artilce. You also have to setup the system user and permissions as stated. If you would like - we can setup a BLUEJEAN call and i wcan walk you through  the process.

Avatar

Level 3

That was it! As always, thank you so much for sharing your expertise and helping me solve this issue!