Saturday, February 7, 2015

How to retrieve the pages created with particular template using Query Builder API - AEM/Adobe CQ5

How to retrieve the pages created with particular template using Query Builder API - AEM/Adobe CQ5

This post will explain how to retrieve the pages created with particular template using Query Builder API in Adobe Experience Manager(AEM)/Adobe CQ5

API Reference:

@Reference
QueryBuilder queryBuilder;

Session session = repository.loginAdministrative(null);

String resourcePath="/content/sample/site-demo/en";

Map<String, String> searchMap = new HashMap<String, String>();
searchMap.put("type", "cq:Page");
searchMap.put("path", resourcePath);
searchMap.put("property", "jcr:content/cq:template");
searchMap.put("property.value", "/apps/common/templates/sampleview");
searchMap.put("p.limit", "-1");

Query query = queryBuilder.createQuery(PredicateGroup.create(searchMap),session);

SearchResult result = query.getResult();
for(Hit hit:result.getHits()) {

    String pagePath = hit.getPath();
    Node pageNode = hit.getNode
}


How to activate the Campaign in Eloqua through java

How to activate the Campaign in Eloqua through java

This post explains how to activate the Eloqua campaign through java.

RestClient class to connect to Eloqua:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class RestClient
{
    private String authToken;
    private String baseUrl;       
    public RestClient(String user, String password, String url)
    {
       baseUrl = url;             
       String authString = user + ":" + password;
      authToken = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes());           
    }             
                          
    public String execute(String uri, String method, String body)  throws Exception
    {
       String response ="";
       try
       {           
          URL url = new URL(baseUrl + uri);
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();                         
          conn.setInstanceFollowRedirects(false);
          conn.setRequestMethod(method.toString());
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setRequestProperty("Accept", "application/json");
          conn.setRequestProperty("Authorization", authToken);         
                  
          if (method == "POST" || method == "PUT")
          {
              if(null != body){
                  conn.setDoOutput(true);
                  final OutputStream os = conn.getOutputStream();
                  os.write(body.getBytes());
                  os.flush();
                  os.close();
               }
           }
                      
           InputStream is = conn.getInputStream();
           BufferedReader rd = new BufferedReader(new InputStreamReader( is));
           String line; 
           while ((line = rd.readLine()) != null)
           {
               response += line;
           }           
           rd.close();
           conn.disconnect();
         }
         catch (Exception e)
         {
            throw e;
         }
       return response;
      }
}



Friday, February 6, 2015

How to update the html content of Email template in Eloqua through java

How to update the html content of Email template in Eloqua through java

This post explains how to update the html content of the Eloqua email through java.

Create the model class for Email:

public class Email
{            
public int emailGroupId;
public RawHtmlContent htmlContent;
public Integer id;
public boolean isPlainTextEditable;
public String name;
public String plainText;
public boolean sendPlainTextOnly;
public String subject;
}
public class RawHtmlContent
{
 public String type;
 public String html;
}

Create the html template with place holder for dynamic content and place the template in the same location of the below java classes.

sample-template.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <body>
      ${content}
   </body>
</html>

RestClient class to connect to Eloqua

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class RestClient
{
    private String authToken;
    private String baseUrl;      
    public RestClient(String user, String password, String url)
    {
       baseUrl = url;            
       String authString = user + ":" + password;
      authToken = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes());          
    }            
                         
    public String execute(String uri, String method, String body)  throws Exception
    {
       String response ="";
       try
       {          
          URL url = new URL(baseUrl + uri);
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();                        
          conn.setInstanceFollowRedirects(false);
          conn.setRequestMethod(method.toString());
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setRequestProperty("Accept", "application/json");
          conn.setRequestProperty("Authorization", authToken);        
                 
          if (method == "POST" || method == "PUT")
          {
              if(null != body){
                  conn.setDoOutput(true);
                  final OutputStream os = conn.getOutputStream();
                  os.write(body.getBytes());
                  os.flush();
                  os.close();
               }
           }
                     
           InputStream is = conn.getInputStream();
           BufferedReader rd = new BufferedReader(new InputStreamReader( is));
           String line;
           while ((line = rd.readLine()) != null)
           {
               response += line;
           }          
           rd.close();
           conn.disconnect();
         }
         catch (Exception e)
         {
            throw e;
         }
       return response;
      }
}



Monday, February 2, 2015

Console Exception:Error opening /com/bea/alsb/console/oam/module/Module.jpf - Oracle OSB

Console Exception:Error opening /com/bea/alsb/console/oam/module/Module.jpf - Oracle OSB

We were getting the exception "Error opening /com/bea/alsb/console/oam/module/Module.jpf. An unexpected error occurred" while opening OSB console.


The following exception was displayed in the AdminServer error log.

<02-Feb-2015 09:53:42 o'clock GMT> <Error> <netuix> <BEA-423137> <There was an error loading the requested URI /com/bea/alsb/console/oam/module/Module.jpf.>
<02-Feb-2015 09:53:42 o'clock GMT> <Error> <netuix> <BEA-423223> <There was an error while running a lifecycle stage :: Lifecycle: UIControl.render :: for the control :: null ::.
com.bea.netuix.nf.UIControlException: com.bea.portlet.adapter.scopedcontent.ActionLookupFailedException: javax.servlet.ServletException: com.bea.alsb.console.common.base.SBConsoleAccessException: The current login role is not authorized to use the console action: "/sbSubModules"
        at com.bea.netuix.servlets.controls.content.PageFlowContent.checkPreRenderExceptions(PageFlowContent.java:130)
        at com.bea.netuix.servlets.controls.content.NetuiContent.beginRender(NetuiContent.java:343)
        at com.bea.netuix.nf.ControlLifecycle$7.visit(ControlLifecycle.java:485)
        at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:518)
        at com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        Truncated. see log file for complete stacktrace

<02-Feb-2015 09:55:56 o'clock GMT> <Error> <ALSB Console> <BEA-494002> <Internal error occured in OSBConsole : The current login role is not authorized to use the console action: "/ViewChangeCenter"
com.bea.alsb.console.common.base.SBConsoleAccessException: The current login role is not authorized to use the console action: "/ViewChangeCenter"
        at com.bea.alsb.console.common.base.SBConsoleRequestProcessor.processActionPerform(SBConsoleRequestProcessor.java:88)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
        at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
        at com.bea.alsb.console.common.base.SBConsoleRequestProcessor.process(SBConsoleRequestProcessor.java:191)
        Truncated. see log file for complete stacktrace

The OSB console page was opening properly and stopped working suddenly.

The root cause of the problem is corruption of the embedded LDAP user store.

Steps to resolve the issue:

Stop all servers in the domain and backup the <<SERVER_HOME>>/data/ldap for all the servers including managed server.

Copy the ldap folder from the previous server backup or other working environment from same location to all the servers.

Restart the servers.


Sunday, February 1, 2015

Changing the log level for a package - Adobe Experience Manager(AEM)

Changing the log level for a package - Adobe Experience Manager(AEM)

This post explains the steps required to change the log level for a package in Adobe Experience Manager(AEM)(the version referred here is 5.6.1)

We can enable the log level of a package in two level - Global level, Package level.

Global level:

Login to /system/console/configMgr and go to OSGI -->Configuration
Search for "Apache Sling Logging Configuration"
Change the log level accordingly


Save the configuration

Package level:

Login to /system/console/configMgr and go to OSGI -->Configuration
Search for "Apache Sling Logging Logger Configuration" and click on "+" to add new configuration.