We Found the fix to this issue.
The culprit is below piece of code in /libs/dam/gui/components/admin/relation/relation.jsp,
This piece of code is allowing only the user having modify rights to view the relationship.
ModifiableValueMap props = relation.getProperties();
We need to overlay /libs/dam/gui/components/admin/relation/relation.jsp into apps ( /apps/dam/gui/components/admin/relation/relation.jsp ).
Then modify the source code of /apps/dam/gui/components/admin/relation/relation.jsp as per below:
<%@include file="/libs/granite/ui/global.jsp" %>
<%@page session="false"
import="com.day.cq.i18n.I18n,
org.apache.jackrabbit.util.Text,
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.api.resource.ModifiableValueMap,
com.adobe.granite.ui.components.Config,
com.adobe.granite.xss.XSSAPI,
com.day.cq.dam.api.Rendition,
com.adobe.granite.asset.api.Asset,
com.adobe.granite.asset.api.AssetRelation,
com.adobe.granite.ui.components.AttrBuilder,
com.day.cq.dam.commons.util.UIHelper,
java.util.Iterator" %><%
%><%
%>
<%
Config cfg = new Config(resource);
String assetDetailsUrl = request.getContextPath() + "/assetdetails.html";
String[] content = (String[])request.getAttribute("aem.assets.ui.properties.content");
if (null != content && content.length > 1) {
// Return if more that one content. ince it is bulk editor
return;
}
String contentPath = (String)request.getAttribute("granite.ui.form.contentpath");
if (null == contentPath) {
contentPath = slingRequest.getRequestPathInfo().getSuffix();
if (null == contentPath) {
// Return if cannot find content path
return;
}
}
Resource res = slingRequest.getResourceResolver().getResource(contentPath);
Asset asset = (res != null ? res.adaptTo(Asset.class) : null);
AttrBuilder attrs = new AttrBuilder(request, xssAPI);
attrs.addClass(cfg.get("class", String.class));
AttrBuilder head_attrs = new AttrBuilder(request, xssAPI);
head_attrs.addClass(cfg.get("head_class", String.class));
AttrBuilder ref_attrs = new AttrBuilder(request, xssAPI);
ref_attrs.addClass(cfg.get("data_class", String.class));
String fieldLabel = cfg.get("fieldLabel", String.class);
String relationLabel = cfg.get("relationLabel", String.class);
attrs.addOthers(cfg.getProperties(), "id", "class", "rel", "title", "name", "value");
if(asset!= null) {
try {
Iterator<? extends Asset> itr = asset.listRelated(relationLabel);
if(itr.hasNext()) {%>
<div style="margin-top:10px" <%= attrs.build() %>>
<div <%= head_attrs.build() %>> <%
if (fieldLabel != null) {
%><label class="coral-Form-fieldlabel"><%= outVar(xssAPI, i18n, fieldLabel) %></label><%
}
%> </div><%
for(int i = 0;itr.hasNext();i++) {
Asset relation = itr.next();
//ModifiableValueMap props = relation.getProperties();
String resPath = relation.getPath();
if (resPath != null) {
/*String resPath = "";
if(props.get("sling:resource") != null) {
resPath = props.get("sling:resource").toString();
} else if(props.get("dam:resolvedPath") != null) {
resPath = props.get("dam:resolvedPath").toString();
}*/
Resource linkedRes = slingRequest.getResourceResolver().getResource(resPath);
if(linkedRes != null ) {
String title = UIHelper.getTitle(linkedRes);
String assetUrl = assetDetailsUrl + Text.escapePath(linkedRes.getPath());
String relatedAssetPath = relation.getPath();
%>
<div <%= ref_attrs.build() %>>
<a title="<%= xssAPI.encodeForHTMLAttr(resPath) %>" is="coral-anchorbutton" variant="quiet" icon="link" iconsize="XS" href="<%= xssAPI.getValidHref(assetUrl) %>" data-asset-path="<%= xssAPI.encodeForHTMLAttr(relatedAssetPath) %>" data-relation="<%= xssAPI.encodeForHTMLAttr(relationLabel) %>"> <%= xssAPI.encodeForHTML(title) %></a>
</div>
<%
}
}
}
%></div><%
}
}
catch(Exception e) {
;
}
}
%>