0 Replies Latest reply on Jul 19, 2013 5:45 AM by Max_Salah

    How to collect new urls which has been found in new version


      I would like to get the urls that the author added in new Version of some page.

      Example: author adds www.url1.com in myPage and activate myPage. --> version 1.0 is generated

                     author adds www.url2.com in myPage and activate myPage. --> version 1.2 is generated -> myPage version 1.2 has bouth  www.url1.com and www.url2.com


      The function has to return www.url2.com in this case.


      I wrote a function getNewUrls(Set>String> urls) which collects the urls from the old version and the new version and deletes the old found urls from the new found urls as follow.


      private Set<String> getNewUrls(Set<String> urls){
         Set<String> newUrls = collectUrlsFromNodes(newVersionNode.getNodes());
         Set<String> oldUrls = collectUrlsFromNodes(oldVersionNode.getNodes());
         Set<String> myNewUrls newUrls.removeAll(oldUrls);
      private Set<String> collectUrlsFromNodes(final NodeIterator nodeIter) {
              Set<String> urlSet = new HashSet<String>();
              while (nodeIter.hasNext()) {
                  Node subNode = nodeIter.nextNode();
                  if (subNode.hasProperty("fileReference")) {
                      String url = subNode.getProperty("fileReference").getString();
              return urlSet;

      Prolbem is that this function find also the urls, that the author already deleted too (mybe because they still stored in content even when the author delete/edit urls from the page). Any idea how to solve this problem?