Thursday, April 30, 2015

Dispatcher caching issue while displaying the image renditions in AEM

We are using the image renditions to display the images for different devices in Adobe Experience Manager(AEM).

The HTML5 Adaptive image is used as shown below to display the images for different devices.

<img src="/content/dam/Albin/Untitled.jpg" srcset="/content/dam/Albin/Untitled.jpg/jcr:content/renditions/cq5dam.thumbnail.319.319.png 1x,/content/dam/Albin/Untitled.jpg" alt="Sample Image">

/content/dam/Albin/Untitled.jpg - Original image
/content/dam/Albin/Untitled.jpg/jcr:content/renditions/cq5dam.thumbnail.319.319.png - Rendition for 1x devices.

If the image is first accessed from the mobile devices then Untitled.jpg folder is created to cache the renditions image(rendition images will be matched for mobile devices) - /content/dam/Albin/Untitled.jpg/jcr:content/renditions/cq5dam.thumbnail.319.319.png

While the image is getting accessed from desktop browsers then dispatcher will try to return the folder Untitled.jpg as image(/content/dam/Albin/Untitled.jpg - original image will be matched for desktop browsers) so the image link will be broken in browser.

In other hand, if the image is first accessed from desktop browser then dispatcher caches Untitled.jpg as image. The subsequent request to the renditions image will not find the images in dispatcher cache so the image will be retrieved from publisher for rendering(rendition images will not be cached in this scenario as untitled.jpg is created as a image).

 Refer the following post To resolve the issue

Wednesday, April 29, 2015

How to get the audit level settings of a Composite through Java - Oracle SOA Suite

This blog will explain how to get the audit level settings of a Composite through Java in Oracle SOA Suite

import java.util.Hashtable;
import java.util.Set;


import javax.naming.Context;

import oracle.fabric.composite.model.CompositeNameModel;

public class GetCompositeAuditLevel {
    static MBeanServerConnection m_connection = null;

    public static String getCompositeAuditLevel(String compositeName,String version) throws Exception {
        String auditLevel = "";
        String mBeanName = "*:j2eeType=SCAComposite,revision=" + version + ",*,name=\"" + compositeName + "\"";
        Set<ObjectName> mbeans = m_connection.queryNames(new ObjectName(mBeanName), null);
        ObjectName mbean = (ObjectName)mbeans.iterator().next();[] properties =([])m_connection.getAttribute(mbean,"Properties");
        if (properties.length > 0) {
            for (int i = 0; i < properties.length; i++) {
                CompositeDataSupport cds = (CompositeDataSupport)properties[i];
                if (cds.get("name").equals("auditLevel")) {
                    auditLevel = (String)cds.get("value");
        } else {
            auditLevel = "Inherit";
        if (auditLevel.equals("Inherit")) {
            auditLevel = getSOAINFRAAuditLevel();
        return auditLevel;

    public static String getSOAINFRAAuditLevel() throws Exception {
        String auditLevel = "";
        String mBeanName ="*:*,name=soa-infra,type=SoaInfraConfig,Application=soa-infra";
        Set<ObjectName> mbeans = m_connection.queryNames(new ObjectName(mBeanName), null);
        ObjectName mbean = (ObjectName)mbeans.iterator().next();
        auditLevel = (String)m_connection.getAttribute(mbean, "AuditLevel");
        return auditLevel;

    public static String getDefaultCompositeRevision(String partiitionName,
                                                     String compositeName) throws Exception {
        ObjectName compositeLifeCycleMBean = null;
        Set queryResult = m_connection.queryNames(new ObjectName("*:j2eeType=CompositeLifecycleConfig,*"), null);
        if (!queryResult.isEmpty()) {
            compositeLifeCycleMBean =(ObjectName)queryResult.iterator().next();
        //CompositeDN - DomainName/CompositeName
        String compositeDN = partiitionName + '/' + compositeName;
        String revision = null;
        CompositeData deployedComposite =(CompositeData)m_connection.invoke(compositeLifeCycleMBean, "getDefaultComposite",
                                               new Object[] { compositeDN },
                                               new String[] { String.class.getName() });
        if (deployedComposite != null) {
            CompositeNameModel cm = CompositeNameModel.parseDN((String)deployedComposite.get("DN"));
            revision = cm.getRevision();
        return revision;

    public static MBeanServerConnection getMbeanServerConnection(String host,int port,String userName,
                                                                 String password) throws Exception {
        String jndiroot = "/jndi/";
        MBeanServerConnection m_connection = null;
        try {
            Hashtable jndiProps = new Hashtable();
            jndiProps.put(Context.SECURITY_PRINCIPAL, userName);
            jndiProps.put(Context.SECURITY_CREDENTIALS, password);
            jndiProps.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "");

            JMXServiceURL serviceURL =new JMXServiceURL("t3", host, port, jndiroot +"");
            JMXConnector m_connector =JMXConnectorFactory.newJMXConnector(serviceURL, jndiProps);
            m_connection = m_connector.getMBeanServerConnection();

        } catch (Exception e) {
        return m_connection;

    public static void main(String[] args) {
        try {
            m_connection =getMbeanServerConnection("localhost", 7001,"weblogic", "welcome1");
            String defaultVersion =getDefaultCompositeRevision("default", "TestComposite");
            String auditLevel=getCompositeAuditLevel("TestComposite", defaultVersion);
        } catch (Exception e) {


The jar files to be added into the class path

  • SOA Runtime jars 
  • weblogic.jar

Tuesday, April 28, 2015

Multipart Message Support in Oracle BPEL

This post will explain, Multipart Message Support in Oracle SOA Suite BPEL component.


Monday, April 27, 2015

Different approaches to define vanity URL in AEM

This post will explains different approaches to define vanity URL in Adobe Experience Manager(AEM)

Sunday, April 19, 2015

How to send the HTML email using Velocity template in Adobe CQ5

This post will explain the steps required to send HTML email in Adobe CQ5 using Velocity template.

Configure mail service:

Go to the Felix Console - http://localhost:4502/system/console/configMgr
Search for Day CQ Mail Service
Enter the email server details as shown below and Save the data (Here I am using Gmail server details).

Email Template:
Create the email template as html file and store it in repository - /etc/email/template/emailTemplate.html (change the path accordingly)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en" lang="en">
       Hi ${firstName} ${lastName}</br>
       This is the sample mail.
  #foreach( $data in $dataList )

Add the following Maven dependencies to the POM.xml

Configure the below packages as part of Import-Package in POM.xml bundle plugin 

oracle.xml.parser;resolution:=optional, oracle.xml.parser.v2;resolution:=optional,
org.jaxen;resolution:=optional, org.jaxen.jdom;resolution:=optional,

Saturday, April 18, 2015

How to change the SOAINFRA Schema in Oracle SOA Suite 11g?

This post will explains how to change the SOAINFRA schema in Oracle SOA Suite 11g

Tuesday, April 7, 2015

How to enable SSH X11 forwarding in Linux?

The  X11 forwarding from putty using Xming was not working, the DISPLAY variable is not set(echo $DISPLAY) after opening the remote server session in putty(X11 forwarding is enabled in putty and also the display is specified as localhost:0.0)

The actual issue is the X11 forwarding was not enabled in remote linux server.

The following steps can be followed to enable the X11 forwarding in linux server.

Login to linux server through putty

vi /etc/ssh/sshd_config

Enable the following flags

AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes

Execute the following commands

service sshd restart

yum -y update xauth
yum -y install xauth

Now you will be able to perform X11 forwarding.

Saturday, April 4, 2015

How to craete/manage the groups and users through Java API in Adobe CQ5?

This post will explain how to craete/manage the groups and users through Java API in Adobe Experiance Manager.


import javax.jcr.PropertyType;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.servlet.Servlet;

import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service(value = Servlet.class)
@Component(immediate = true, metatype = true)
@Property(name = "sling.servlet.paths", value = "/services/manageGroupsAndUsers"),
@Property(name = "service.description", value = "ManageGroupsAndUsers"),
@Property(name = "label", value = "ManageGroupsAndUsers") })

public class ManageGroupsAndUsers extends SlingAllMethodsServlet{

private static final long serialVersionUID = 1L;

ResourceResolverFactory resolverFactory;

private static Logger logger = LoggerFactory.getLogger(ModifyCartServlet.class);

protected final void doPost(final SlingHttpServletRequest request,
final SlingHttpServletResponse response) throws IOException {

String groupName="sampleGroup";
String userName="sampleUser";
String password="sampleUser";

ResourceResolver adminResolver = null;
Session adminSession=null;
try {
      adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
      adminSession = adminResolver.adaptTo(Session.class);
      final UserManager userManager= adminResolver.adaptTo(UserManager.class);
     Group group=userManager.createGroup(groupName,new SimplePrincipal(groupName),"/home/groups/test");
     Value value=adminSession.getValueFactory().createValue("Sample Group", PropertyType.STRING);
     group.setProperty("./profile/givenName", value);
     value=adminSession.getValueFactory().createValue("Test Group", PropertyType.STRING);
     group.setProperty("./profile/aboutMe", value);
     value=adminSession.getValueFactory().createValue("[email protected]", PropertyType.STRING);
     group.setProperty("./profile/email", value);    
     response.getWriter().write("Group already exist..");
     User user=userManager.createUser(userName, password,new SimplePrincipal(userName),"/home/users/test");
     Value value=adminSession.getValueFactory().createValue("Issac", PropertyType.STRING);
     user.setProperty("./profile/familyName", value);
     value=adminSession.getValueFactory().createValue("Albin", PropertyType.STRING);
     user.setProperty("./profile/givenName", value);
     value=adminSession.getValueFactory().createValue("Test User", PropertyType.STRING);
     user.setProperty("./profile/aboutMe", value);
     value=adminSession.getValueFactory().createValue("[email protected]", PropertyType.STRING);
     user.setProperty("./profile/email", value);    
      response.getWriter().write("User already exist..");
     Group group = (Group)(userManager.getAuthorizable(groupName));
} catch (Exception e) {
response.getWriter().write("Not able to perform User Management.."+resolverFactory);
} finally {
      if (adminResolver != null) adminResolver.close();


protected final void doGet(final SlingHttpServletRequest request,
final SlingHttpServletResponse response) throws IOException {
doPost(request, response);

Friday, April 3, 2015

How to create different renditions for the Image in Adobe CQ5?

While uploading the images to DAM, Adobe CQ5 will create renditions of an image that include different sizes of the same image.This can be helpful when we need to create thumbnails or smaller views of large, high-resolution images.

We can configure the DAM Update Asset workflow to create the different renditions.

  • Login to http://localhost:4502/etc/workflow/models/dam/update_asset.html
  • In the workflow model select the thumbnail creation step and edit, in the process tab of the step we can add custom rendition values.
  • Save the workflow

How to use HTML5 adaptive image in Adobe CQ5?

This post will explain how to use HTML5 adaptive image in Adobe CQ5

The srcset attribute in HTML5 <img> element, allows us to specify different images for varying viewport widths and pixel densities. This allows us to load a larger image for new high resolution devices while displaying lower resolution images for others

<img src="image-src.png" srcset="image-1x.png 1x, image-2x.png 2x,image-3x.png 3x, image-4x.png 4x">

The width also can be specified to select the images.

<img src="small.jpg" srcset="medium.jpg 1000w, large.jpg 2000w" alt="Sample Image">

While uploading the images to DAM, Adobe CQ5 will create renditions of an image that include different sizes of the same image.This can be helpful when we need to create thumbnails or smaller views of large, high-resolution images.

The original or different rendition images can be used in HTML5 Adaptive image to display the images based on pixel density of the device,  browser will serve the image based on the resolution of the client.

<img src="/content/dam/Albin/Untitled.jpg/jcr:content/renditions/original" srcset="/content/dam/Albin/Untitled.jpg/jcr:content/renditions/cq5dam.thumbnail.319.319.png 1x,/content/dam/Albin/Untitled.jpg/jcr:content/renditions/original" alt="Sample Image">