Saturday, January 31, 2015

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

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>
  DocumentRoot /app/apache/static/

 Alias /files  "/app/apache/static"

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

Now we can access the static file with the following url -<<file name>>

The Apache server referred here is 2.2.15

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: Unable to mount filesystem - Adobe CQ5

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: 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

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

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

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

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

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 CQ5

This post will explain how  to Modify the Node permissions through Java in Adobe CQ5

import java.util.NoSuchElementException;

import javax.jcr.RepositoryException;
import javax.jcr.Session;

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.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

private static final Logger log = LoggerFactory.getLogger(ModifyNodePermissions.class);
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); 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()))

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

acl.addEntry(authorizable.getPrincipal(), allowPrivileges, true);
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);;

} catch (RepositoryException e) {
} catch (Exception e) {
} finally {
if (session != null)

Saturday, January 24, 2015

How to Retrieve/Update the configuration details through Configuration Admin Service - Adobe CQ5

This post will explain how to Retrieve/Update the configuration details through Configuration Admin Service  in Adobe CQ5

//Add the reference
@Reference configAdmin;

//Reterive/Update the configration config = configAdmin.getConfiguration("");
Dictionary d = config.getProperties();
String fromAddress=(String)d.get("from.address");
d.put("from.address", "[email protected]");

Saturday, January 17, 2015

Configuring proxy server details for HttpClient communication in Adobe CQ5

This post will explain how to configure proxy server details for HttpClient communication in Adobe CQ5

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

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", "");
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;