Expand my Community achievements bar.

SOLVED

How to get resource resolver in replication preprocessor

Avatar

Level 4

Hi All,

I am trying to create replication preprocessor, which will restrict particular types of template from been replicated. For this I want to check the resource type of page been replicated and I need resource resolver object for it. I wanted to avoid resourceResolverFactory.getAdministrativeResourceResolver(null); rather use param.put(ResourceResolverFactory.SUBSERVICE, "readService"); but it is throwing a login exception any idea how to get resource using subservice?

    @Reference
    private transient ResourceResolverFactory resourceResolverFactory;
    
    @Override
    public void preprocess(ReplicationAction action, ReplicationOptions options) throws ReplicationException
    {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put(ResourceResolverFactory.SUBSERVICE, "readService");
        try
        {
            ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(param);
        } catch (LoginException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Thanks!

Shehjad

1 Accepted Solution

Avatar

Correct answer by
Level 10
2 Replies

Avatar

Correct answer by
Level 10

Hi,

Have you mapped this service in OSGI ? Which version of AEM you are using?

Please take a look at some code base for this :

Avatar

Level 4

Hey Praveen,

Thank you I was missing the felix configuration. I am using AEM 6.0 Sp2.

Thanks again for your quick and accurate reply.

Regards,

Shehjad