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(ReplicationActionType.DELETE) doesn't work

Avatar

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Validate 25
Level 4
jayv25585659
Level 4

Likes

46 likes

Total Posts

117 posts

Correct Reply

0 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 5
View profile
jayv25585659
Level 4

26-03-2018

So I'm trying to import some content from an Excel spreadsheet and save this to AEM.

After saving it to author, the data gets replicated to the publisher.

As part of the pre-import processes, I am deleting the destination folder and then recreate it.

The issue is that while the destination folder gets deleted in author, it doesn't get deleted in publisher.

Any ideas what I could be doing wrong? Thanks

    @Override

    public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {

        try {

            Session session = workflowSession.getSession();

            ResourceResolver resourceResolver = getResourceResolver(session);

            deleteNodes(session, resourceResolver);

        } catch (Exception e) {

            log.error("fish importer: Error in Fish Import Service", e);

        }

    }

    private void deleteNodes(Session session, ResourceResolver resolver) throws RepositoryException, ReplicationException, PersistenceException {

        Resource resource = resolver.getResource(rootPath); //rootPath = /content/data/fishes

        if (resource != null){

            Node node = resource.adaptTo(Node.class);

            String name  = node.getName();

            Node parent = node.getParent();

           

            node.remove();

            replicate(rootPath, session, ReplicationActionType.DELETE);

            resolver.commit();

        }

    }

   

    protected void replicate(String path, Session jcrSession, ReplicationActionType activateType) throws ReplicationException {

        if (activateType.equals(ReplicationActionType.ACTIVATE)) {

            replicator.replicate(jcrSession, activateType, path);

        } else {

            ReplicationStatus status = replicator.getReplicationStatus(jcrSession, path);

            if (status != null && status.isActivated()) {

                replicator.replicate(jcrSession, activateType, path);

            }

        }

    }

Replies

Avatar

Avatar
Validate 1
Level 2
dylanr72808383
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Validate 1
Level 2
dylanr72808383
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
dylanr72808383
Level 2

27-03-2018

And you're certain that the replicator gets triggered to delete it? Because you have an if-statement that surrounds that replicate method. Perhaps check in your debugger if it actually gets triggered or not.