Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

ReplicationPathTransformer interface in AEM 6.3.2 version not supporting

saurabh08tiwari
Level 1
Level 1

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  .

11 Replies
Lokesh_Shivalingaiah
Community Advisor
Community Advisor

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

saurabh08tiwari
Level 1
Level 1

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;

    }

}

Arun_Patidar
Community Advisor
Community Advisor

Hi,

Please check your imports, for me it works with osgi annotations but you are using Felix annotations

aem63app-repo/ReplicationPathTransformerWorkflow.java at master · arunpatidar02/aem63app-repo · GitH...

Thanks

Arun

saurabh08tiwari
Level 1
Level 1

Hello Arun  i have tried with osgi annotation package for component,but my issue is related to ReplicationPathTransformer package which is not importing

1539102_pastedImage_1.png

Arun_Patidar
Community Advisor
Community Advisor

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 Namecom.day.cq.cq-replication
Version6.2.26
Bundle Locationlaunchpad:resources/install/0/com.adobe.granite.replication.core-6.2.26.jar

Service ID 1681Types: com.day.cq.replication.impl.ReplicationPathTransformerProvider
Component Name: com.day.cq.replication.impl.ReplicationPathTransformerProviderImpl
Component ID: 690
Vendor: Adobe Systems Incorporated
saurabh08tiwari
Level 1
Level 1

Hi Arun,

               1539103_pastedImage_0.png

                  but still i am getting importing error

             1539117_pastedImage_2.png

saurabh08tiwari
Level 1
Level 1

means bundles are their but i m getting impotingberror

Arun_Patidar
Community Advisor
Community Advisor

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

Screen Shot 2018-07-31 at 2.04.28 PM.png

saurabh08tiwari
Level 1
Level 1

Hi Arun,

             I checked without impl also its not importing all jar are available

Arun_Patidar
Community Advisor
Community Advisor

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.

saurabh08tiwari
Level 1
Level 1

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!! {}");

  }

  }

}