Wednesday, July 1, 2015

Programatically Set/Get the metadata of an Asset: Adobe CQ5/Adobe AEM

Programatically Set/Get the metadata of an Asset: Adobe CQ5/Adobe AEM

The Adobe Experience Manager(AEM) version referred here is 5.6.1

@Reference
private ResourceResolverFactory resolverFactory;

ResourceResolver resourceResolver =null;
try
{
String resourcePath = "/content/dam/geometrixx-outdoors/banners/adventure.jpg";
resourceResolver= resolverFactory.getAdministrativeResourceResolver(null);
   Resource res = resourceResolver.getResource(resourcePath);
   
   Resource metadataRes =res.getChild("jcr:content/metadata");
   ModifiableValueMap map = metadataRes.adaptTo(ModifiableValueMap.class);
     
   //set metadata
   map.put("dc:samplemetadata", "sample metadata");
   resourceResolver.commit();
     
   //get metadata  
   String metadata=map.get("dc:samplemetadata").toString();  
     
}catch(Exception e)
{

}finally
{
resourceResolver.close();
}



Dependency in pom.xml

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>

Tuesday, June 30, 2015

How to enable Debugging for OSB modules

How to enable Debugging for Oracle Service Bus(OSB) modules

Make sure server log is set to debug (Weblogic console -> Environment-->Servers -><<OSB Server>>--> Logging -> Advanced)

Stop the servers .
Open file <DOMAIN_HOME>/alsbdebug.xml
Set the value to true for the required modules.


Open file <DOMAIN_HOME>/configfwkdebug.xml
Set the value to true for the required modules.


Restart the server
Server log will have the details.

Thursday, June 25, 2015

Install Adobe Experience Manager(AEM) package through CURL command

Install Adobe Experience Manager(AEM) package through CURL command

curl -u <<User Name>>:<<Password>> -F file=@"<<Package Path>>" -F name="<<Package Name>>" -F force=true -F install=true http://<<Server Host Name>>:<<Port>>/crx/packmgr/service.jsp

e.g

curl -u admin:admin -F file=@"/appserver/package/package-1.0.1-SNAPSHOT.zip" -F name="package-1.0.1-SNAPSHOT" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp


If the Adobe Experience Manager(AEM) server is behind the proxy then execute the below command to set the proxy server

export http_proxy=http://<<Proxy Server Host Name>>:<<Port>>

Wednesday, June 17, 2015

Deploying bundles/packages to different environments through Maven: Adobe AEM/Adobe CQ5

Deploying bundles/packages to different environments through Maven: Adobe AEM/Adobe CQ5

Create a folder cq-sample-all(projectname-all) under cq-sample(parent folder)
Create cq-sample-all/pom.xml and configure the environment specific properties, module dependencies and different profiles - refer the sample below

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLotrion="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
             <groupId>my-group-id</groupId> <!-- Change the groupid and artifactId of the paraent -->
             <artifactId>cq-sample</artifactId>
             <version>1.0-SNAPSHOT</version>
        </parent>

<artifactId>cq-sample-all</artifactId> <!-- Change the artifcatId -->
<packaging>content-package</packaging>
<name>${project.groupId} - ${project.artifactId}</name>

<properties>
<cq.dev.author.server>aem-dev-author</cq.dev.author.server>
<cq.dev.author.host>localhost</cq.dev.author.host>
<cq.dev.author.port>4502</cq.dev.author.port>
<cq.dev.author.protocol>http</cq.dev.author.protocol>
<cq.dev.publisher1.server>aem-dev-publisher</cq.dev.publisher1.server>
<cq.dev.publisher1.host>localhost</cq.dev.publisher1.host>
<cq.dev.publisher1.port>4503</cq.dev.publisher1.port>
<cq.dev.publisher1.protocol>http</cq.dev.publisher1.protocol>
<!-- Add the other server details-->
</properties>
<!-- Add all the  bundle/content modules as part of dependency. Change the artifactId of the modules-->

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-content</artifactId>
<version>${project.version}</version>
<type>content-package</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-bundle</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>maven-vault-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
<configuration>
<embeddedTarget>/apps/cq-sample/install</embeddedTarget> <!-- change the folder name(cq-sample) accordingly -->
<embeddeds>
<embedded>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-bundle</artifactId>
<filter>true</filter>
</embedded>
<!-- Add additional bundle modules here as embedded -->
</embeddeds>
<subPackages>
<subPackage>
<groupId>${project.groupId}</groupId>
<artifactId>cq-sample-content</artifactId>
<filter>true</filter>
</subPackage>
<!-- Add additional content modules here as subPackage -->
</subPackages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<!-- Profile for Development deployments -->
<!--Create the profile for different environments -->
<profile>
<id>Development</id>
<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<executions>
<execution>
<id>install-content-package-author</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<useProxy>false</useProxy>
<packageFile>${project.build.directory}/${project.build.finalName}.zip</packageFile>
<targetURL>${cq.dev.author.protocol}://${cq.dev.author.host}:${cq.dev.author.port}/crx/packmgr/service.jsp</targetURL>
<serverId>${cq.dev.author.server}</serverId>
</configuration>
</execution>
<execution>
<id>install-content-package-publisher1</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<failOnError>true</failOnError>
<useProxy>false</useProxy>
<packageFile>${project.build.directory}/${project.build.finalName}.zip</packageFile>
<targetURL>${cq.dev.publisher1.protocol}://${cq.dev.publisher1.host}:${cq.dev.publisher1.port}/crx/packmgr/service.jsp</targetURL>
<serverId>${cq.dev.publisher1.server}</serverId>
</configuration>
</execution>
<!-- Add execution for additional publisher with different id(increment the last digit)-->
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>


How to disable Geolocation feature : Adobe AEM/Adobe CQ5

How to disable Geolocation feature : Adobe AEM/Adobe CQ5

The Geolocation feature can be disabled for all the sites by renaming the following component to different name

Rename /libs/cq/personalization/components/contextstores/geolocation to /libs/cq/personalization/components/contextstores/geolocation_new


Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' / Unknown packaging: content-package while deploying through Maven : Adobe AEM/Adobe CQ5

Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' / Unknown packaging: content-package while deploying through Maven : Adobe AEM/Adobe CQ5

We are getting the below exception while deploying the package to Adobe AEM/Adobe CQ5 through Maven.

[ERROR] Unresolveable build extension: Error resolving version for plugin 'com.day.jcr.vault:maven-vault-plugin' from the repositories
[local (D:\Albin\Projects\.m2\repository), adobe (http://repo.adobe.com/nexus/content/groups/public/),
central (http://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 2]
[ERROR]     Unknown packaging: content-package @ my-group-id:cq-sample-all:[unknown-version],
D:\Albin\SW\apache-maven-3.2.2-bin\apache-maven-3.2.2\bin\cq-sample\cq-sample-all\pom.xml, line 13, column 13
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginVersionResolutionException

To resolve this issue add the vault plugin to parent pom.xml

<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>maven-vault-plugin</artifactId>
<version>0.0.10</version>
<configuration>
<verbose>true</verbose>
</configuration>
</plugin>