Category: cq5

AEM/CQ5 e-Commerce and Hybris get Started

It took couple of week for me to get started Adobe CQ5 and Hybris together on my local desktop since Adobe Wiki is very useful but i think has not been updated for some time. Hybris is eCommerce platform now by SAP and to get the license is not easy either you have to be customer or partner. Thanks to Adobe they have created OSGI Package of Hybris server and shared in package share and also Geomtrixx outdoor eCommerce related product content.

Day wiki http://dev.day.com/docs/en/cq/current/ecommerce/eCommerce-hybris.html is usefull but need to be updated with new information.

This is really cool if you want to start up AEM eCommerce Integration framework.
https://seminars.adobeconnect.com/_a227210/p85ixyvw3zp/?launcher=false&fcsContent=true&pbMode=normal

Brief synopsis to get started.

If you have CQ5 running instance  i.e 5.6.1, please create a Adobe CQ share package credentials and login into that and download    Hybris 500 MB+ package that has inbuilt Hybris server and also hybris content that has hybris importer and certain content.

Install both packages in your local package manager and can access hybris  console on this http://localhost:9001/hmc/hybris.and your CQ on 4502.

Image

By default outdoor catalog would be available in hybris, you can manually synchronize that content from here http://localhost:4502/etc/importers/hybris.html that will recreate product catalog here /etc/commerce/products. Remember untill you are not customer or Partner with Hybriss you would not get any resource or document about Hybris for functional knowledge.

Generate MVN Project

mvn -Padobe-public archetype:generate     -DarchetypeRepository=http://repo.adobe.com/nexus/content/groups/public/     -DarchetypeGroupId=com.day.jcr.vault     -DarchetypeArtifactId=multimodule-content-package-archetype     -DarchetypeVersion=1.0.2

Provide all other information i.e artifict id, name, group and folders and say yes in the last and finally your maven structure would be created.

Import Project in Eclipse

Download code from github https://github.com/paolomoz/cq-commerce-impl-sample in this case you don’t need to create archetype and maven project creation etc. build and deploy it to your local CQ.  Changed ecommorce provide in JCR for Geomtrexx_outdoor and your code would work..

 

 

JCR Content Model Some Key Rule

Data Store

The data store holds large binaries. On write, these are streamed directly to the data store and only an identifier referencing the binary is written to the Persistence Manager (PM) store. By providing this level of indirection, the data store ensures that large binaries are only stored once, even is they appear in multiple locations  within the content in the PM store. In effect the data store is an implementation detail of the PM store. Like the PM, the data store can be configured to store its data in a file system (the default) or in a database. The minimum object length default is 100 bytes;; smaller objects are stored inline(not in the data store). The maximum value is 32000 because Java does not support strings longer than 64 KB in writeUTF.

Cluster Journal

Whenever CRX writes data it first records the intended change in the journal. Maintaining the journal helps ensure data consistency and helps the system to recover quickly from crashes. As with the PM and data stores, the journal can be stored in a file system (the default) or in a database.

Persistence Manager
Each workspace in the repository can be separately configured to store its data through a specific persistence manager (the class that manages the reading and writing of the data). Similarly, the repository-wide version store can also be
independently configured to use a particular persistence manager. A number of different persistence managers are available, capable of storing data in a variety of file formats or relational databases.

Query Index

CRX’s inverse index is based on Apache Lucene. This allows for:

Most index updates are synchronous. Long full text extraction tasks are handled in background. Other cluster nodes will update their indexes at next cluster sync Everything indexed by default. You can tweak the indexing configuration for improvements in indexing functionality, performance and disk usage. There is one index per workspace (and one for the shared version store) Indexes are not shared across a cluster, indexes are local to each cluster node.

Jackrabbit
The Apache Jackrabbit™ content repository is a fully conforming implementation of the Content Repository for Java Technology API (JCR, specified in JSR 170 and JSR 283. Note the next release of the JCR specification is JSR 333, which is currently under work.

Sending email Using Apache common and CQ5 mail API — Adobe CQ5

Apache mail common comes as out of box in Adobe CQ5 platform as OSGI bundle and and CQ has its own API on top of that can be used to send all kind of email

  • Plain text
  • HTML Formatted
  • and any kind of attachment.

Code snippets to send email. Please refer to the document

URL http://commons.apache.org/proper/commons-email/userguide.html

When you send email as plain text , you would not see much difference in terms of formatting for different-2 mail client , but when it is HTML formatted you would find it varies across  outlook, Gmail, Yahoo even on Smartphone.

Retest it correct your HTML CSS class etc to ensure it looks uniform across all kind of mail client. Also if you are mail content has java script or long hash based query string data are not going work in email ..remember mail box is not browser, its Application and mail server apply their own set of security.

One of the primary reason why i wrote this blog is that outlook consistently shows this attachment  (ATT00001.htmattachment  when we sent HTML formatted email content but same was not appearing in G-Mail and Yahoo. refer to the below image attached.

Image

I referred multiple post and forum and everybody has their own understand and interpretation but none has worked for us.
Few URL worth sharing here.

http://stackoverflow.com/questions/1821464/attachmentshtml-generated-with-commons-email-doesnt-show-in-some-email-clients

https://discussions.apple.com/message/10966873#10966873

What’s Solution:

it’s code issue and nothing else.

  • Email object was not created on right place.
  • Session object too
  • also email recipients

When finally code was rescanned and arranged that attachment stopped coming in outlook.

Cache static object for better performance AEM 5.6.1

Several contents i.e. CSS, image and icons don’t get changes frequently, therefore the system should be configured so that requested objects does not get expired in client browser and reduce unnecessary HTTP traffic.

This unloads the traffic request from server also improves user experience response time for page and any HTTP request as browser stores the objects in browser cache based on expiration date for the path.

Any HTTP request has header information and HTTP protocol allow browser to cache based on that information.

Apache configuration changes

Uncomment this in httpd.conf.

LoadModule expires_module modules/mod_expires.so

and load this changes where for the content path or any directory/folder that you want caching.

<Location /libs>
ExpiresActive On
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 hour”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 hour”
</Location>

 

<Location /etc/designs>
ExpiresActive On
ExpiresByType image/gif “access plus 1 hour”
ExpiresByType image/png “access plus 1 hour”
ExpiresByType image/svg “access plus 1 hour”
ExpiresByType image/jpeg “access plus 1 hour”
ExpiresByType image/jpg “access plus 1 hour”
ExpiresByType application/x-javascript “access plus 1 hour”
ExpiresByType text/css “access plus 1 hour”
</Location>

 

How to ensure it is effective?

If expiry is not active

We will see such log in access.log of apache for any image objects for each request.
127.0.0.1 – – [11/Apr/2014:16:02:35 -0500] “GET /content/dam/IMAGES/Brand%20Assets/hero-home-1.jpg HTTP/1.1” 200 496832That means image file of size 496832 bytes are being downloaded on each request. 200 is http successful status.

If expiry is active, ideally we should see logs like this
127.0.0.1 – – [11/Apr/2014:16:53:32 -0500] “GET /content/dam/IMAGES/Brand%20Assets/hero-home-1.jpg HTTP/1.1” 304 –

 

That means 304 indicates that browser has cached that image and server has not got any new version so apache is not going to send back to browser a new copy and reducing http traffic.

Run Load test and check logs