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
BedrockMission!

Learn More

View all

Sign in to view all badges

Replication

Avatar

Avatar
Validate 10
Level 2
rk39193348
Level 2

Like

1 like

Total Posts

92 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
rk39193348
Level 2

Like

1 like

Total Posts

92 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
rk39193348
Level 2

26-02-2021

Hi 

I want to activate page through workflow in aem 6.5. I have created a java class and added following line:

"replicator.replicate(session, ReplicationActionType.ACTIVATE, payloadPath);"

still page is not activating. Any idea what needs to be done?

 

Regards

RK

View Entire Topic

Avatar

Avatar
Validate 1
Level 7
KiranVedantam1992
Level 7

Likes

161 likes

Total Posts

164 posts

Correct Reply

48 solutions
Top badges earned
Validate 1
Establish
Give Back 3
Give Back
Boost 50
View profile

Avatar
Validate 1
Level 7
KiranVedantam1992
Level 7

Likes

161 likes

Total Posts

164 posts

Correct Reply

48 solutions
Top badges earned
Validate 1
Establish
Give Back 3
Give Back
Boost 50
View profile
KiranVedantam1992
Level 7

27-02-2021

Hi @rk39193348,

 

As per your code, you are using scr annotations which are outdated. Please use the R7 annotations. Try this updated code from my end:

 

import javax.jcr.Node;
import com.day.cq.replication.Replicator;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.workflow.WorkflowSession;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
import javax.jcr.Session;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;

@Component(service = WorkflowProcess.class, property = { "process.label = Replicate Workflow" })
public class ReplicateWorkflow implements WorkflowProcess {
/** * Logger */
private static final Logger log = LoggerFactory.getLogger(ReplicateWorkflow.class);
private String payloadPath = "";
Node node = null;
Page newPage;
private Session session;
@Reference
protected Replicator replicator;
@Reference
private ResourceResolverFactory resourceResolverFactory;
ResourceResolver resolver;

/** * Overridden method which executes when the workflow is invoked */
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) {
try {
payloadPath = workItem.getWorkflowData().getPayload().toString();
log.info("payloadPath**" + payloadPath);
node = (Node) workflowSession.getSession().getItem(payloadPath);
session = node.getSession();
log.info("session**" + session);
replicator.replicate(session, ReplicationActionType.ACTIVATE, payloadPath);
replicator.replicate(session, ReplicationActionType.ACTIVATE, payloadPath);
} catch (Exception e) {
log.error("error***" + e.getMessage(), e);
}
}
}

 

Hope this helps!

 

Thanks,

Kiran Vedantam