Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to compare aem author env pages and AEM Publish Env page

Avatar

Level 2

Hi Team,

Please help fory below query.

How to compare aem author env pages and AEM Publish Env page like ''content/mysite/ under pages

1 Accepted Solution

Avatar

Correct answer by
Level 4
13 Replies

Avatar

Community Advisor

Hi @sanjay91 ,

 

Do you mean visual comparison of HTML pages on author against publish?

 

Thanks,

Ritesh Mittal

Avatar

Level 4

Hi ,

You can write sql query to find the number of pages in both environment.

select * from [cq:PageContent] AS s where s.[cq:lastReplicated] IS NOT NULL AND ISDESCENDANTNODE(s,[/content])

 And also try custom reports for your requirement.

https://aem.redquark.org/2019/06/create-custom-reports-in-aem-component.html 

Thanks

Avatar

Level 2

Hi Haris,

I am writing same code

cq:PageContent] AS s where s.[cq:lastReplicated] IS NOT NULL AND ISDESCENDANTNODE(s,[/content])

 

But I can get all author page count but i did not count publish page and also when I was putting hole url in query got error message so how to connect url https and port number in query. 

Avatar

Level 4

Hi ,

If you are running query in publish server after login it should work .

Also try query builder 

Step 1: Go to the below mention URL. Adjust the domain according to your domain name.

http://localhost:4502/libs/cq/search/content/querydebug.html

Step 2: Put the following query in the "Query Builder Debugger" section

type=cq:Page

path=/content/sample/en/en_us

p.limit =-1

Avatar

Level 2

My Requirement is compare publisher page count and author page count if find page number is not equal so send the mail. but my problem is same time count page number author and publisher.  

Avatar

Level 4

In the query builder ,you can query and get Json query link and use in the java code to call the link and return the results to compare.

 

http://localhost:4502/bin/querybuilder.json?p.limit=-1&path=%2fcontent%2fwe-retail%2fus%2fen%2fmen&t...  (add authorization)

 

 

"success":true,"results":17,"total":17,"more":false,

 

 

 

Avatar

Level 2

Could you please share the example of code how to get data from publisher url like https://4503/content/path

Avatar

Level 4

Please try this sample code 

 

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;


public class HttpBasicAuth {

    public static void main(String[] args) {

        try {
            URL url = new URL ("json url");
            String encoding = Base64.getEncoder().encodeToString(("test1:test1").getBytes(‌"UTF‌​-8"​));

            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setDoOutput(true);
            connection.setRequestProperty  ("Authorization", "Basic " + encoding);
            InputStream content = (InputStream)connection.getInputStream();
            BufferedReader in   = 
                new BufferedReader (new InputStreamReader (content));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}

try scheduler to trigger mail after getting both env results.

 

Thanks 

Avatar

Level 2
String encoding = Base64.getEncoder().encodeToString(("test1:test1").getBytes(‌"UTF‌​-8"​));

 

In this code what is "test1:test1"

Avatar

Level 4

Hi Sanjay ,

 You can go with below approaches to compare or find count number of pages

1. Query builder

2. Site admin - parent page - count

3. Query debugger - localhost:4502/libs/cq/search/content/querydebug.html 

4. download package and compare content using beyond compare tool. 

 

Avatar

Level 2

I want automation bro so if count is different so send remider mail to business owner 

Avatar

Correct answer by
Level 4