Sunday, March 1, 2015

How to send the email through Java API in Eloqua

How to send the email through Java API in Eloqua

This post explains how to send the email through Eloqua API.

Create the required model classes:

public class EmailTestDeployment 

    public String contactId ;
    public String sendFromUserId ;
    public Email email;
    public String name;
    public String type;       

}

public class Email 
{
public int emailGroupId;
public RawHtmlContent htmlContent; 
public int 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;

}

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");
          System.out.println(authToken);
          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;
      }

}



How to find the id of the existing contact in Eloqua

How to find the id of the existing contact in Eloqua

This post will explain How to find the id of the existing contact in Eloqua

Login to Eloqua
Click on Contacts in main page
Search by entering *, this will return all the contacts.
Open the particular contact.
Select Field Details tab and select All Contact Fields in the drop down.


In the Eloqua Contact ID field ignore CTHOM and all the zeros, consider the last digits as contact id(e.g 109)


Saturday, February 28, 2015

How to subscribe the Contact to a EmailGroup through Java API in Eloqua

How to subscribe the Contact to a EmailGroup through Java API in Eloqua

This post explains how to create the contact in Eloqua through java.

Create the required model classes:

public class EmailGroup
{
public String type;
public String id;
public String depth;
public String description;
public String name;
public String updatedAt;
public String updatedBy;
}

public class Subscription
{
public EmailGroup emailGroup;
public String isSubscribed;
public String contactId;
public String  type;
}

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");
          System.out.println(authToken);
          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;
      }
}



How to get the Subscriptions of a Contact through through Java API in Eloqua

How to get the Subscriptions of a Contact through through Java API in Eloqua

This post explains how to create the contact in Eloqua through java.

Create the required  model classes:

public class SubscriptionResponse
{
public List<Subscription> elements;
}

public class Subscription
{
public EmailGroup emailGroup;
public String isSubscribed;
}

public class EmailGroup
{
public String type;
public String id;
public String depth;
public String description;
public String name;
public String updatedAt;
public String updatedBy;
}

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");
          System.out.println(authToken);
          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;
      }
}



Thursday, February 19, 2015

How to check the replication status through java API in AEM/Adobe CQ5

How to check the replication status through java API in AEM/Adobe CQ5

This post will explain how to check the replication status through java API in Adobe Experiance Manager(AEM)/Adobe CQ5

Maven dependency:

Add the following dependency to the pom.xml

<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.replication.core</artifactId>
<version>5.12.2</version>
<scope>provided</scope>
</dependency>

API's:

@Reference
Replicator replicator;

@Reference
SlingRepository repository;

Session  session = repository.loginAdministrative(null);
ReplicationStatus status=replicator.getReplicationStatus(session, “nodepath”);

status.isDelivered();//Checks if the content is delivered

Other methods to get the different status

isActivated()
isDeactivated
isPending()


Wednesday, February 18, 2015

How to execute the Quartz scheduler job only in master author node - AEM/Adobe CQ5

How to execute the Quartz scheduler job only in master author node -  AEM/Adobe CQ5

While we are deploying the scheduler in Adobe Experience Manager(AEM), the scheduler will be active in master/slave author nodes and all the publish nodes(based on our deployment configuration).

But sometimes there will be scenario the scheduled job should be only executed in master author node.

The below code snippet can be used to restrict the job getting executed only in master author node.

@Reference
SlingRepository repository;
private void sampleScheduledJob() {
       if(isRunMode("author") && isMasterRepository()){
            //execute the job functionality here
       }
}

private Boolean isRunMode(String mode) {
        Set<String> runModes = slingSettings.getRunModes();
        for (String runMode : runModes) {
                if (runMode.equalsIgnoreCase(mode)) {
                         log.debug("Current Runmode is : " + runMode);
                         return true;
                 }
        }
        return false;
}
               
public boolean isMasterRepository(){
          final String isMaster = repository.getDescriptor("crx.cluster.master");
          log.debug("isMaster.."+isMaster);
          return StringUtils.isNotBlank(isMaster) && Boolean.parseBoolean(isMaster);
}
               


  


The Admin console is not up/accessible – Oracle SOA Suite

The Admin console is not up/accessible –  Oracle SOA Suite

We were facing a strange issue in our Oracle SOA Suite production server in Solaris, we could not able to access the admin console even though the server is started properly and there is no error in the log file.

We were able to telnet the admin server listen address from Admin server node but not able to do it from other nodes.

The root cause of the issue is with Gateway server, the admin server listen address is not listed on the Gateway - the gateway server is not online (the servers listen address is configured in Gateway).

After Solaris admin team made the Gateway server online, we were able to see the admin server listen address listed on the gateway.

After restarting the admin server we were able to access the console page.

The following command can be used for checking the Gateway server status

 netstat –r  


Sunday, February 15, 2015

org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet - Adobe Experience Manager(AEM)

org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet - Adobe Experience Manager(AEM)

I was getting the below exception while invoking the servlet from Adobe Experience Manager(AEM) bundle.

15.02.2015 20:58:11.615 *ERROR* [FelixDispatchQueue] FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet) org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet
at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:332)
at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)
at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:320)
at org.apache.felix.framework.Felix.getService(Felix.java:3556)
at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)

 The root cause of the problem is different versions of servlet API classes are loaded by two different class-loaders.

To fix the issue make sure <scope>provided</scope> is added for the Servlet API dependency in POM.xml

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.4</version>
      <scope>provided</scope>
</dependency>






Saturday, February 14, 2015

com.google.gson,version=[2.2,3) -- Cannot be resolved in bundle - Adobe Experience Manager(AEM)

com.google.gson,version=[2.2,3) -- Cannot be resolved in bundle - Adobe Experience Manager(AEM)

I was able compile and  deploy the bundle successfully with gson dependency but the bundle is not getting started with the error "com.google.gson,version=[2.2,3) -- Cannot be resolved in bundle" in Adobe Experience Manager(AEM)

The root cause of the problem is the gson jar is not available in the server for bundle access.

This issue can be resolved  by following any of the below approach.

1. Export the gson  package - com.google.gson.*

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>com.sample.activator.Activator</Bundle-Activator>
<Import-Package>*,com.sample.*</Import-Package>
<Export-Package>com.sample.*,com.google.gson.*</Export-Package>
<Bundle-SymbolicName>com.sample</Bundle-SymbolicName>
<Bundle-Vendor>Sample</Bundle-Vendor>
<Bundle-Category>Sample</Bundle-Category>
<Embed-Directory>dependencies</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>

2. Add the gson jar in the bundle class path

Specify the gson dependency scpes as compile or runtime(compile is the default scope)

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<scope>compile</scope>
</dependency

The gson jar will be included in the bundle classpath.

The dependencies with what are all the scopes are included in the bundle classpath is configured in maven-bundle-plugin

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>



How to create the contact in Eloqua through java

How to create the contact in Eloqua through java

This post explains how to create the contact in Eloqua through java.

Create the model class for Contact:

public class Contact
{
 public String accountName;
 public String address1;
 public String address2;
 public String address3;
 public String businessPhone;
 public String city;
 public String country;
 public String firstName;
 public String emailAddress;
 public String id;
 public boolean isBounceback;
 public boolean isSubscribed;
 public String lastName;
 public String salesPerson;
 public String title;
 public String type;
 public String name;

}

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;
 }
}




Tuesday, February 10, 2015

Expected a string but was BEGIN_ARRAY at line 1 column - Gson

Expected a string but was BEGIN_ARRAY at line 1 column 

I was receiving "Expected a string but was BEGIN_ARRAY at line 1 column" error while deserializing the json string to java object using Gson.

Model class:

public class EmailGroup{
private String type;
private String id;
private String name;
private String permissions;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPermissions() {
return permissions;
}
public void setPermissions(String permissions) {
this.permissions = permissions;
}
}

JSON Response:

{"emailGroup":{"type":"EmailGroup","id":"1","depth":"minimal","description":"","name":"sample","permissions":[2,5,4,3]}}

Gson gson = new Gson();
EmailGroup obj = gson.fromJson(jsonstring, EmailGroup.class)

The root cause of the exception is the permissions attribute defined in the model class is of type String but the type of permissions in the jsonstring is List.

To fix the issue convert the type of permissions in the model class to List<String>(type string will change based on the type of the list entries)

public class EmailGroup{
private String type;
private String id;
private String name;
private List<String> permissions;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(List<String> permissions) {
this.permissions = permissions;
}
}



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.




Saturday, January 31, 2015

Accessing static files through Apache HTTP Server in Linux

Accessing static files through Apache HTTP Server in Linux

This post will explain accessing static files through Apache HTTP Server in Linux

Create  a folder in server to store the static files  e.g. /app/apache/static/

Copy all the static files to /app/apache/static/ folder

Add the below contents to httpd.conf file

##Grant the access to unix user that will access the static folder
<IfModule unixd_module>
      User apacheuser
      Group apacheuser
</IfModule>

DirectoryIndex index.htm index.html

ErrorDocument 400 /error.html
ErrorDocument 401 /error.html
ErrorDocument 403 /error.html
ErrorDocument 404 /error.html
ErrorDocument 405 /error.html
ErrorDocument 408 /error.html
ErrorDocument 414 /error.html
ErrorDocument 500 /error.html
ErrorDocument 502 /error.html
ErrorDocument 504 /error.html

<VirtualHost *:80>
  ServerName staticfiles.com:80
  DocumentRoot /app/apache/static/

 Alias /files  "/app/apache/static"

<Directory /app/apache/static>
    Order deny,allow
    Allow from all
    SetHandler default-handler
</Directory>
</VirtualHost>

Now we can access the static file with the following url - http://staticfiles.com/files/<<file name>>

The Apache server referred here is 2.2.15


403 Forbidden/403 XSRF Protection Failure error while invoking Eloqua Send mail API

403 Forbidden/403 XSRF Protection Failure error while invoking Eloqua Send mail API

We will be receiving 403 Forbidden/ 403 XSRF Protection Failure error while invoking the Eloqua Send mail API - /api/rest/1.0/assets/email/deployment

Verify whether the user has the role "Engage Users", if not add the "Engage Users" security group to the user and Save the changes.


If the Engage Users role is already added then clear the browser cookies and try again.


Wednesday, January 28, 2015

checkout: com.day.jcr.vault.vlt.VltException: Unable to mount filesystem -Adobe Experience Manager(AEM)

Checkout: com.day.jcr.vault.vlt.VltException: Unable to mount filesystem - Adobe Experience Manager(AEM)

Sometimes you may receive the following exception while exporting the  repository content to eclipse through vault.

Jcr File Vault [version 2.4.34] Copyright 2011 by Adobe Systems Incorporated
[ERROR] checkout: com.day.jcr.vault.vlt.VltException: Unable to mount filesystem
caused by: javax.jcr.RepositoryException: URL scheme http not supported. only

For me the issue got fixed after clearing the temp folder contents.




Tuesday, January 27, 2015

How to configure Hybris Server to use Oracle Data Base

How to configure Hybris Server to use Oracle Data Base

The following steps can be followed to configure the Hybris server to use Oracle database.

Configure database user:

Login to Oracle database and create the required user and provide the grants.
create user <username> identified by <password> default tablespace <table space name> temporary tablespace <table space name>;
grant connect, resource to <username>;

Configure Hybris server

Copy the oracle driver (e.g. ojdbc6.jar) to /hybris/bin/platform/lib/dbdriver

Go to /hybris/config and edit local.properties by adding the following:
db.url=jdbc:oracle:thin:Username/password//servername:port-id/database name
db.driver=oracle.jdbc.OracleDriver
db.username=xxxxxxx
db.password=xxxxxxx

Verify the configuration details and initialize

Access the Hybris server URL and check the following details:
                   a) Database Name displayed
                   b) User name Displayed
                   c) Database Driver Displayed.
                   d) Check for the default objects (e.g. product, cart etc) already selected.

Click on initialize button on the top of the page. It will take some time and initialize all the tables, table spaces and schemas required.

After successful completion of initialization the server gets automatically restarted, or else it will display errors which need to be rectified.


Sunday, January 25, 2015

How to Modify the Node permissions through Java - Adobe Experience Manager(AEM)

How to Modify the Node permissions through Java - Adobe Experience Manager(AEM)

This post will explain how  to Modify the Node permissions through Java in Adobe Experience Manager(AEM)

Java API:

import java.util.NoSuchElementException;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.security.AccessControlEntry;
import javax.jcr.security.AccessControlManager;
import javax.jcr.security.AccessControlPolicyIterator;
import javax.jcr.security.Privilege;

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.apache.jackrabbit.api.security.JackrabbitAccessControlList;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(label = "ModifyNodePermissions", metatype = false, immediate = true)
@Properties({
@Property(name = Constants.SERVICE_DESCRIPTION, value = "ModifyNodePermissions") })
@Service(value = ModifyNodePermissions.class)
public class ModifyNodePermissions {

private static final Logger log = LoggerFactory.getLogger(ModifyNodePermissions.class);
@Reference
private SlingRepository repository;

public void modifyNodePermissions(String nodePath,String groupName)
{
Session session = null;
try {

session = repository.loginAdministrative(null);

UserManager userMgr = ((org.apache.jackrabbit.api.JackrabbitSession) session).getUserManager();
AccessControlManager accessControlManager = session.getAccessControlManager();
Authorizable authorizable  = userMgr.getAuthorizable(groupName);
AccessControlPolicyIterator policyIterator = accessControlManager.getApplicablePolicies(nodePath);

org.apache.jackrabbit.api.security.JackrabbitAccessControlList acl = null;

try {
acl = (JackrabbitAccessControlList) policyIterator.nextAccessControlPolicy();              

} catch (NoSuchElementException nse) {
acl = (JackrabbitAccessControlList) accessControlManager.getPolicies(nodePath)[0];
}

//Remove the Access Control Entry
 /*for (AccessControlEntry e : acl.getAccessControlEntries()) {
  if (e.getPrincipal().equals(authorizable.getPrincipal()))
 {
      acl.removeAccessControlEntry(e);
 }
                }*/

//Allow
/*Privilege[] allowPrivileges = {accessControlManager.privilegeFromName(Privilege.JCR_REMOVE_NODE),
accessControlManager.privilegeFromName(Privilege.JCR_REMOVE_CHILD_NODES) };

acl.addEntry(authorizable.getPrincipal(), allowPrivileges, true);
  */
//Deny
Privilege[] denyPrivileges = {accessControlManager.privilegeFromName(Privilege.JCR_REMOVE_NODE),
accessControlManager.privilegeFromName(Privilege.JCR_REMOVE_CHILD_NODES) };

acl.addEntry(authorizable.getPrincipal(), denyPrivileges, false);

//Add Policy
accessControlManager.setPolicy(nodePath, acl);
//Remove Policy
//accessControlManager.removePolicy(nodePath, acl);
session.save();

} catch (RepositoryException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null)
session.logout();
}
}
}




Saturday, January 24, 2015

How to Retrieve/Update the configuration details through Configuration Admin Service - Adobe Experience Manager(AEM)

How to Retrieve/Update the configuration details through Configuration Admin Service  - Adobe Experience Manager(AEM)

This post will explain how to Retrieve/Update the configuration details through Configuration Admin Service  in Adobe Experience Manager(AEM)

Java API

//Add the reference
@Reference
org.osgi.service.cm.ConfigurationAdmin configAdmin;

//Reterive/Update the configration

org.osgi.service.cm.Configuration config = configAdmin.getConfiguration("com.day.cq.mailer.DefaultMailService");
Dictionary d = config.getProperties();
String fromAddress=(String)d.get("from.address");
d.put("from.address", "[email protected]");
config.update(d);


Saturday, January 17, 2015

Configuring proxy server details for HttpClient communication in Adobe Experience Manager(AEM)

Configuring proxy server details for HttpClient communication in Adobe Experience Manager(AEM)

This post will explain how to configure proxy server details for HttpClient communication in Adobe Experience Manager(AEM)

Go to config manager - http://localhot:4502/system/console/configMgr
Open Day Commons HTTP Client 3.1 and provide the proxy server details.


Check "Enable HTTP Proxy" and provide the HTTP Proxy Host and Port details.
If authentication required provide the proxy server user name and password.

Provide the host name and ip address for which the proxy is not required.

This proxy details will be used for all the communication happens via Apache HTTP commons. Client
This details will be used upon replication, if the proxy is not required to connect to publisher then add the publisher host name to No Proxy For list.

This proxy details will not be used if we are using HttpURLConnection for http communication.


Wednesday, January 14, 2015

Invoking NTLM authentication enabled service through Java

Invoking NTLM authentication enabled service through Java

Java API

The below program help us to invoke NTLM authentication enabled services.

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.HttpStatus;

public class NTLMAuthentication {

public String invokeService(String url, String soapMessage) {
String responseString = null;
try {

HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(url);
postMethod.setRequestEntity(new StringRequestEntity(soapMessage,"text/xml","utf-8"));
postMethod.setRequestHeader("SOAPAction", "http://www.service.com/GetEmployeeData");
postMethod.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
NTCredentials credentials = new NTCredentials("username","password", "hostName", "domain");
client.getState().setCredentials(new AuthScope(null, -1, null), credentials);
int status = client.executeMethod(postMethod);
if (status == HttpStatus.SC_OK)
{
responseString = postMethod.getResponseBodyAsString();
}
} catch (Exception e) {

}
return responseString;

}

}