Highlighted

Link Rewriter not rewriting the link if the link was added via a model property.

Ram_Atmakur

14-06-2018

Hi Experts,

     We have recently upgraded to 6.3 latest SP2 for 6.1. The issue we are noticing is that in the publishing environment when any link (<a href: "/content/**") generated  using a sling model attribute, those links are not getting re-written after applying the resource resolver mapping rules.

This was not an issue on 6.1. Did anything change? How can this be addressed with out changing all our components to use a resolvedpath?

Rama.

Replies

Highlighted

Jörg_Hoh

Employee

14-06-2018

The rewriting happens at the output level (on the rendered HTML). Is this reproducible on all your environments? And have you checked that all relevant settings for the link-rewriter are set correct?

Jörg

Highlighted

Ram_Atmakur

15-06-2018

Hi Jörg,

         The link-rewriter settings seem to be correct as the re-writing is happening at some places and not at some places and there is no specific pattern on where and when it happens. Also the 'stripHtmlExtention' property also seems to be not respected in some places. But there was no pattern to it. We found what lines of code was causing the issue and handled those lines differently.

@Component(label = " Environment",

        description = " Environment Properties: Any environment related configuration will go here. This is based on runmodes.",

        immediate = true)

@Service(EnvironmentProperties.class)

public class EnvironmentPropertiesImpl implements EnvironmentProperties {

...

...

...

...

    private boolean stripHtmlExtension;

    @Reference

    private ConfigurationAdmin configAdmin;

    public boolean isStripHtmlExtension() {

        return stripHtmlExtension;

    }

   public void setStripHtmlExtension(boolean stripHtmlExtension) {

        this.stripHtmlExtension = stripHtmlExtension;

    }

...

...

...

    @Activate

    protected void activate(final Map<String, Object> config) {

...

...

...

...

        stripHtmlExtension = false;

        try{

            org.osgi.service.cm.Configuration conf = configAdmin.getConfiguration("com.day.cq.rewriter.linkchecker.impl.LinkCheckerTransformerFactory");

            stripHtmlExtension = PropertiesUtil.toBoolean(conf.getProperties().get("linkcheckertransformer.stripHtmltExtension"),false);

        }catch (Exception e){

            e.printStackTrace();

            stripHtmlExtension = false;

        }

...

...

...

...   

    }

}   

In the above lines of code, we are trying to read the property for 'linkcheckertransformer.stripHtmltExtension'. After the execution of this line in the activate method then we are seeing the odd behavior that we were experiencing. It effected the out of the box site, weRetail as well. The links there too were showing up with full content path.  As of now we changed these lines of code.

Rama.