Saturday, January 31, 2015

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", "albin.issac1@gmail.com");
config.update(d);