Wednesday, June 10, 2020

Update Dispatcher Configuration in bulk remotely with Help of Batch/ Shell Script

Many times we need to ssh remote servers to run specific linux commands manually. If you have to run it quite often and run the same command on multiple servers doing it manually becomes hectic. Below is sample code which you can use to create a shell script (In Linux) or a Batch program (In Windows).

1. The first file is the executable batch file- I have wrote it for windows but it can be written in shell script for Linux as well.

2. The second file - "sample-dispatcher-update-config-commands.cmd" - lists all the commands that you want to run as a group.

Thursday, June 4, 2020

Clear Dispatcher cache remotely via shell script | Windows BAT script

There are number of ways to clear dispatcher cache- This article talks about how to clear it using batch or shell script.

Read the following article for other options e.g. curl script, replication agent etc.- https://aem6solutions.blogspot.com/2019/11/cache-clearance-in-dispatcher.html

Many times we need to ssh remote servers to run specific linux commands manually. If you have to run it quite often and run the same command on multiple servers doing it manually becomes hectic. Below is sample code which you can use to create a shell script (In Linux) or a Batch program (In Windows).

1. The first file is the executable batch file- I have wrote it for windows but it can be written in shell script for Linux as well.

2. The second file - clear-cache-remote.cmd - lists all the commands that you want to run as a group.

Friday, April 3, 2020

AEM6.5 | Tools for Content Migration



Data Importer - https://adobe-consulting-services.github.io/acs-aem-commons/features/mcp-tools/data-importer/index.html

Metadata Export and Import- https://docs.adobe.com/content/help/en/experience-manager-learn/assets/metadata/metadata-import-feature-video-use.html

You can use cyberduck to synchronize folders on your local AEM instance to the s3 bucket. 


Cyberduck has the S3 transport as an option. 


Wednesday, March 25, 2020

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps:

1. Develop Custom TransportHandler

Develop a custom Transport handler to send the test and purge requests to Cloudflare API server. The handler sets up basic authentication with the user/pass from the replication agent's transport config and sends a GET request as a test and POST as purge request. A valid test response is 200 while a valid purge response is 201.

Sample code is here:

2. Create custom dispatcher flush agent

The transport handler builds the POST request body in accordance with Cloudflare's REST APIs using the replication agent properties.

A. Create New Replication Agent at-

      http://localhost:4503/miscadmin#/etc/replication/agents.publish

B. Agent Configuration:

     The Flush agent must be configured with following 3 properties:
     1. The transport handler is triggered by setting agent's transport URL's protocol to "cloudflare://".
        E.g. - cloudflare://api.cloudflare.com/client/v4/zones/{zone-id}/purge_cache
     2. User: The X-Auth-Email value of cloudflare account
     3. Password: X-Auth-Key value of cloudflare account

C. Agent User Id in AEM:


Create a custom service user to control permission what should be allowed to flush CDN cache: cloudflare-flush

Reference: https://api.cloudflare.com/#zone-purge-files-by-url/

AEM6 | Enable component programmatically

Problem:

An OSGi component is disabled by default, need to enable it programmatically in AEM6.x.

Solution:

Use SCR API to enable it. Sample code here:
for (Bundle bundle : bundleContext.getBundles()) {
    ComponentDescriptionDTO dto = scr.getComponentDescriptionDTO(bundle, componentName);
    if (dto != null && !scr.isComponentEnabled(dto)) {
        LOGGER.info("Component {} disabled by configuration.", dto.implementationClass);
        scr.enableComponent(dto);
    }
}
Complete code can be found here:

Use Case:

Sample use case is to enable "com.day.cq.dam.core.impl.MissingMetadataNotificationJob" component in https://helpx.adobe.com/experience-manager/6-3/assets/using/metadata-schemas.html#Definemandatorymetadata

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...