Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import javax.jcr.Node
  2. import javax.jcr.query.*
  3.  
  4. private checkCountry(country) {
  5. QueryManager queryManager = session.workspace.queryManager;
  6. Query query = queryManager.createQuery("SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/b2b/" + country + "/category]) AND [sling:resourceType] = 'bose/common/components/text'", "JCR-SQL2");
  7. QueryResult queryResult = query.execute();
  8. RowIterator rowIterator = queryResult.rows;
  9. while (rowIterator.hasNext()) {
  10. Row row = rowIterator.nextRow();
  11. Node fieldSetNode = row.getNode();
  12.  
  13. if (fieldSetNode.hasProperty("text")) {
  14. String text = fieldSetNode.getProperty("text").value.toString();
  15.  
  16.  
  17.  
  18. int start = text.indexOf("href=\"");
  19. int end = text.indexOf("\" target");
  20.  
  21. if (start != -1) {
  22. if (end != -1) {
  23. text = text.substring(start + 6, end);
  24. } else {
  25. text = text.substring(start + 6);
  26. }
  27. }
  28.  
  29. if (text.contains("parsys")) {
  30. println(text);
  31. }
  32. }
  33. }
  34. }
  35.  
  36. checkCountry("fr_ca");
  37. checkCountry("en_gb");
  38. checkCountry("es_mx");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement