Hi Experts,
AEM 6.5.10
1) Is there any way to create Replication agent through some APIs?
2) Is there any way programmatically to enable/disable Replication agent?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @arvind,
Replication agents configuration are represented as a normal pages in AEM stored under specific location. Base on that please find answers for your questions:
1) Is there any way to create Replication agent through some APIs?
There is no specific API, however you can create replication agent using one of following options:
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ModifiableValueMap;
PageManager pm = resourceResolver.adaptTo(PageManager.class);
Page p = pm.create("/etc/replication/agents.author", "custom-agent", "/libs/cq/replication/templates/agent", "Custom agent", true);
ModifiableValueMap mvm = p.getContentResource().adaptTo(ModifiableValueMap.class);
// all props are String type
mvm.put("enabled", "false");
mvm.put("logLevel", "info");
mvm.put("retryDelay", "60000");
mvm.put("serializationType", "durbo");
// encrypted admin password
mvm.put("transportPassword", "{DES}8aadb625ced91ac483390ebc10640cdf");
mvm.put("transportUri", "http://localhost:4503/bin/receive?sling:authRequestLogin=1");
mvm.put("transportUser", "admin");
// ... place for other props, depending on agent type
resourceResolver.commit();
2) Is there any way programmatically to enable/disable Replication agent?
Yes, it is possible. Similar to above case you can utilize JCR, Sling and/or AEM java API, like that:
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ModifiableValueMap;
PageManager pm = resourceResolver.adaptTo(PageManager.class);
Page p = pm.getPage("/etc/replication/agents.author/publish");
ModifiableValueMap mvm = p.getContentResource().adaptTo(ModifiableValueMap.class);
// boolean value, but in this specific case it is stored as a String
mvm.put("enabled", "false");
resourceResolver.commit();
) Is there any way to create Replication agent through some APIs?--- what do you mean?
2) Is there any way programmatically to enable/disable Replication agent?
Yes you can, but will be helpful if you can refine your requirement.
Views
Replies
Total Likes
Hi @arvind,
Replication agents configuration are represented as a normal pages in AEM stored under specific location. Base on that please find answers for your questions:
1) Is there any way to create Replication agent through some APIs?
There is no specific API, however you can create replication agent using one of following options:
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ModifiableValueMap;
PageManager pm = resourceResolver.adaptTo(PageManager.class);
Page p = pm.create("/etc/replication/agents.author", "custom-agent", "/libs/cq/replication/templates/agent", "Custom agent", true);
ModifiableValueMap mvm = p.getContentResource().adaptTo(ModifiableValueMap.class);
// all props are String type
mvm.put("enabled", "false");
mvm.put("logLevel", "info");
mvm.put("retryDelay", "60000");
mvm.put("serializationType", "durbo");
// encrypted admin password
mvm.put("transportPassword", "{DES}8aadb625ced91ac483390ebc10640cdf");
mvm.put("transportUri", "http://localhost:4503/bin/receive?sling:authRequestLogin=1");
mvm.put("transportUser", "admin");
// ... place for other props, depending on agent type
resourceResolver.commit();
2) Is there any way programmatically to enable/disable Replication agent?
Yes, it is possible. Similar to above case you can utilize JCR, Sling and/or AEM java API, like that:
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ModifiableValueMap;
PageManager pm = resourceResolver.adaptTo(PageManager.class);
Page p = pm.getPage("/etc/replication/agents.author/publish");
ModifiableValueMap mvm = p.getContentResource().adaptTo(ModifiableValueMap.class);
// boolean value, but in this specific case it is stored as a String
mvm.put("enabled", "false");
resourceResolver.commit();
Views
Likes
Replies