While using ReplicationPathTransformer interface in AEM 6.3.2 version I am getting cannot 'resolve symbol ' for this interface so what should i do, to replicate the asset from one path to another path like I am tring for content/dam/error.jpg to content/development/error.jpg .
Views
Replies
Total Likes
Hi Saurabh,
Can you share more informations like
which API version, AEM version and a sample class you have written along with the error log details ?
Thanks,
Lokesh
Views
Replies
Total Likes
I am using AEM 6.3.2 version and API also
following is my class
package com.intel.cm.workflow;
import com.day.cq.replication.Agent;
import com.day.cq.replication.ReplicationAction;
import com.day.cq.replication.ReplicationLog;
import com.day.cq.replication.
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.Session;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
@Component(metatype = false, immediate = true)
@Service({ReplicationPathTransformer.class})
public class ReplicationPathTransformerWorkflow implements ReplicationPathTransformer {
@Override
public String transform(Session session, String replicationPath, ReplicationAction replicationAction, Agent agent) {
/*
* transform the replicationPath
*/
// for the sake of simplicity, and as this is an example return the replicationPath as is.
return replicationPath;
}
@Override
public boolean accepts(Session session, ReplicationAction replicationAction, Agent agent) {
/* Check if the agent is a dispatcher agent
* if it is the agent you are targeting, return true
*/
// transform all urls
return true;
}
}
Views
Replies
Total Likes
Hi,
Please check your imports, for me it works with osgi annotations but you are using Felix annotations
Thanks
Arun
Views
Replies
Total Likes
Hello Arun i have tried with osgi annotation package for component,but my issue is related to ReplicationPathTransformer package which is not importing
Views
Replies
Total Likes
Hi,
Can you check Adobe Granite Replication bundle , check if service is there or not, if there you can go for deployment it should work.
Adobe Granite Replication(com.day.cq.cq-replication)
Symbolic Name | com.day.cq.cq-replication |
Version | 6.2.26 |
Bundle Location | launchpad:resources/install/0/com.adobe.granite.replication.core-6.2.26.jar |
Service ID 1681 | Types: com.day.cq.replication.impl.ReplicationPathTransformerProvider Component Name: com.day.cq.replication.impl.ReplicationPathTransformerProviderImpl Component ID: 690 Vendor: Adobe Systems Incorporated |
Views
Replies
Total Likes
Hi Arun,
but still i am getting importing error
Views
Replies
Total Likes
means bundles are their but i m getting impotingberror
Views
Replies
Total Likes
Hi,
You need to import service but not implementation like below
import com.day.cq.replication.ReplicationPathTransformer;
Which über Jar you've include in Pom?
Should be 6.3 for AEM 6.3
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.3.0</version>
<classifier>apis</classifier>
</dependency>
below is classes from uber jar in eclipse, can you check jar in your editor
Views
Replies
Total Likes
Hi Arun,
I checked without impl also its not importing all jar are available
Views
Replies
Total Likes
Hi,
Then could be issue with your project setup or editor.
Can you try to create new Test Project with archetype 11 or try with another editor.
Views
Replies
Total Likes
Hi,
Arun this was not working so I have used ReplicationOptions class for replicating asset ,only problem was it can replicate same path so first I moved it in same server in that folder where I have to replicate than I am taking that asset and replicating in different server my code is following
package com.intel.cm.workflow;
import com.adobe.granite.asset.api.AssetManager;
import com.day.cq.replication.*;
import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowSession;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowData;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
import com.intel.cm.largefileassetintelbox.utils.interfaces.SessionService;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.resource.ResourceResolver;
import javax.jcr.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
@Service(value = WorkflowProcess.class)
@Properties(value = {
@Property(name = "service.description", value = "Test Replication Approvals Workflow"),
@Property(name = "service.vendor", value = "Test Replication Approvals Workflow"),
@Property(name = "process.label", value = "Test Replication Approvals Workflow")
})
public class TestReplicationApproveWorkflow implements WorkflowProcess {
private static final Logger LOGGER = LoggerFactory.getLogger(TestReplicationApproveWorkflow.class);
@Reference
private Replicator replicator;
@Reference
public SessionService sessionService;
private ResourceResolver resourceResolverMetadata;
private Session session;
public Replicator getReplicator() {
return replicator;
}
public SessionService getSessionService() {
return sessionService;
}
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
String destinationPeyload=null;
WorkflowData workflowData = workItem.getWorkflowData();
String sourcePayloads = workflowData.getPayload().toString();
String workflowDetails = workflowData.getMetaData().toString();
String workflowValues[] = workflowDetails.split(",");
for (int l = 0; l < workflowValues.length; l++) {
if (workflowValues[l].contains("5000_path=")) {
String[] pathDetails = workflowValues[l].split("=");
for (int j = 0; j < pathDetails.length; j++) {
if (pathDetails[j] != "5000_path") {
destinationPeyload = pathDetails[j].replaceAll("[{}:,]","").trim();
}
}
}
}
try {
ReplicationOptions opts = new ReplicationOptions();
opts.setFilter(new AgentFilter() {
@Override
public boolean isIncluded(Agent agent) {
return "publish_dam".equals(agent.getId());
}
});
String sourcePayloadsArrays[]=sourcePayloads.split("/");
String sourcePayloadPageName=sourcePayloadsArrays[sourcePayloadsArrays.length-1];
String destinationPeyloadPath=destinationPeyload+"/"+sourcePayloadPageName;
moveAssetToDifferentFolder(sourcePayloads,destinationPeyloadPath,workflowSession,opts);
} catch (Exception e) {
e.printStackTrace();
}
}
public void moveAssetToDifferentFolder(String sourcePayloads ,String destinationPeyloadPath,WorkflowSession workflowSession,ReplicationOptions opts) throws WorkflowException {
try {
ResourceResolver resourceResolver = getSessionService().getReadServiceResourceResolver();
AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);
session = resourceResolver.adaptTo(Session.class);
assetManager.moveAsset(sourcePayloads,destinationPeyloadPath);
session.save();
getReplicator().replicate(workflowSession.getSession(), ReplicationActionType.ACTIVATE, destinationPeyloadPath, opts);
}catch(ReplicationException e){
e.printStackTrace();
}
catch (Exception x) {
LOGGER.error("An Exception occurred while adding tag to Asset!! {}");
}
}
}
Views
Replies
Total Likes