Expand my Community achievements bar.

SOLVED

[CQ5] - Publisher enviornment is having stale/old content

Avatar

Level 3

Due to some reason , we need to bring our few publisher down. Now when i am trying to bring those back it is having old data or stale data which was published before we brought them down.

 

Can you please help me, how we can have the latest data on the publisher server.

 

Also, how i can setup parallel author instance and move content from one server to other.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hey @niks1 you need to republish that content(if you know the pages/paths/assets) again.

 

If you don't know the exact path(s) then you may need to run query to figure out the content (cq:Page/dam:Asset etc) which got added/modified and ten create a package using the same script(from groovyscript) and then getting it installed on publish server. I have not mentioned replicating those pages through programmatically replicating them because if the number of paths are way too many then it might slow down your instance(too many in replication queue), so I'd recommend creating a package and installing it on publish.

 

One drawback would be - that you'd end up losing the version in package creation.

 

Thanks,

Bilal.

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hey @niks1 you need to republish that content(if you know the pages/paths/assets) again.

 

If you don't know the exact path(s) then you may need to run query to figure out the content (cq:Page/dam:Asset etc) which got added/modified and ten create a package using the same script(from groovyscript) and then getting it installed on publish server. I have not mentioned replicating those pages through programmatically replicating them because if the number of paths are way too many then it might slow down your instance(too many in replication queue), so I'd recommend creating a package and installing it on publish.

 

One drawback would be - that you'd end up losing the version in package creation.

 

Thanks,

Bilal.

Avatar

Level 3
Thanks for the reply @bilal_ahmad. I tried updating one of the page and publish it but still on the server it is showing old data. Package creation - as in whole site package ? If Yes, how to do it in CQ5 . I know how to do it in AEM but not sure on CQ5

Avatar

Community Advisor

hey @niks1 CQ5 and AEM are the same things. Just that before Adobe procured Communique back in 2010, it was knows as CQ5, post procurement it was called Adobe Experience Manager.
Also, the content should/must get replicated to your publishers. Please take a look at your replication agent(s) if they are working fine(you can hit 'test' and it'd let you know).

I'm sharing a sample script with you, you should modify it based on your requirements and then package creation through the script will be super easy.

Please install Groovy Console  in your instance and then run(customize first!) this script:

 

 

import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import org.apache.jackrabbit.vault.packaging.JcrPackage;
import org.apache.jackrabbit.vault.packaging.PackagingService;
import org.apache.jackrabbit.vault.packaging.JcrPackageManager;
import org.apache.jackrabbit.vault.packaging.JcrPackageDefinition;
import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;

PACKAGE_GROUP_NAME="Test-Package-Group";
PACKAGE_NAME="Test-Package-Name"

checkIfPackageExists()
def checkIfPackageExists(){
    if(getNode("/etc/packages").hasNode(PACKAGE_GROUP_NAME)){
        getNode("/etc/packages/"+PACKAGE_GROUP_NAME).remove();
        save();
    }
    doQuery();
}
def doQuery(){
    String sqlStatement = 'SELECT * FROM [dam:Asset] AS asset WHERE ISDESCENDANTNODE ([/content/dam/myProject]) AND (asset.[jcr:created] >= CAST("2020-10-29T00:00:00.000+05:30" AS DATE) OR asset.[jcr:lastModified] >= CAST("2020-10-29T00:00:00.000+05:30" AS DATE)) ORDER BY asset.[jcr:created] DESC';
    QueryManager queryManager = session.getWorkspace().getQueryManager();
    Query query = queryManager.createQuery(sqlStatement, "JCR-SQL2");
    QueryResult result = query.execute();
    nodeIter = result.getNodes();
    
    DefaultWorkspaceFilter filters = new DefaultWorkspaceFilter();
    int counter;
        while(nodeIter.hasNext()){
            filters.add(new PathFilterSet(nodeIter.nextNode().getPath()));
            counter++;
        }
    println "Number of nodes added in filter path(s): "+counter;
    createPackage(filters);
}

def createPackage(DefaultWorkspaceFilter filters){
    JcrPackageManager packMgr = PackagingService.getPackageManager(session);
    JcrPackage pack = packMgr.create(PACKAGE_GROUP_NAME,PACKAGE_NAME,null);
    JcrPackageDefinition jcrPackageDefinition = pack.getDefinition();
    jcrPackageDefinition.setFilter(filters, true);
    jcrPackageDefinition.set("acHandling","acHandling",false);
    packMgr.assemble(pack, null);
    println "Package created successful";
}

 

 


Thanks,

Bilal.

Avatar

Level 3

Thanks @bilal_ahmad . Sorry for late reply. I was out sick from last couple of weeks due to this unable to check the response. Here is what i tried in query builder but it is not giving all pages :

type=cq:Page
path=/content
daterange.property=jcr:content/cq:lastModified
daterange.lowerBound=2020-10-01
orderby=@jcr:content/cq:lastModified
orderby.index=true
orderby.sort=asc

 

I want list of all pages which got published after  1st Oct'2020.

Avatar

Community Advisor

Hi @niks1 for pages that got published on/after 1'Oct 2020 you can replace the existing query in the snippet I provided with this:

 

SELECT * FROM [cq:Page] AS page WHERE ISDESCENDANTNODE ([/content]) AND page.[cq:lastReplicated] >= CAST("2020-10-01T00:00:00.000+05:30" AS DATE)  ORDER BY page.[cq:lastReplicated] DESC

 

 

It worked for me.

 

Thanks,

Bilal.