Wednesday, July 26, 2017

Tagging mechanism in AEM

Taxonomy Root Node:
Generally all tags in the repository are stored in Taxonomy Root Node.
The taxonomy root node must be a node of type cq:Tag
In AEM base path is /etc/tags and root node of type cq:Folder

Tag Characterstics:
·       node type is cq:Tag
·       node name is a component of the TagID
·       the TagID always includes a namespace
·       optional jcr:title property (the Title to display in the UI)
·       optional jcr:description property
·       when containing child nodes, is referred to as a container tag
·       is stored in the repository below a base path called the taxonomy root node

Understanding of the Tagging structure in tabe format:

TagID
Namespace
Local ID
Container tag(s)
Leaf tag
Repository
Absolute tag path
dam:fruit/apple/braeburn
dam
fruit/apple/braeburn
fruit, apple
braeburn
/etc/tags/dam/fruit/apple/braeburn
color/red
default
color/red
color
red
/etc/tags/default/color/red
sky
default
sky
(none)
sky
/etc/tags/default/sky
dam:
dam
(none)
(none)
(none, the namespace)
/etc/tags/dam
/etc/tags/category/car
category
car
car
car
/etc/tags/category/car

Moving and Merging Tags(Important point to be understood):
·       When a tag A is moved or merged into tag B under /etc/tags:
·       tag A is not deleted and gets a cq:movedTo property.
·       tag B is created (in case of a move) and gets a cq:backlinks property.
·       cq:movedTo points to tag B.
This property means that tag A has been moved or merged into tag B. Moving tag B will update this property accordingly. Tag A is thus hidden and is only kept in the repository to resolve tag IDs in content nodes pointing to tag A. The tag garbage collector removes tags like tag A once no more content nodes point to them.
A special value for the 
cq:movedTo property is nirvana: it is applied when the tag is deleted but cannot be removed from the repository because there are subtags with a cq:movedTo that must be kept.
·       cq:backlinks keeps the references in the other direction, i.e. it keeps a list of all the tags that have been moved to or merged with tag B. This is mostly required to keep cq:movedTo properties up to date when tag B is moved/merged/deleted as well or when tag B is activated, in which case all its backlinks tags must be activated as well.
·       Reading a cq:tags property of a content node involves the following resolving:
1.    If there is no match under /etc/tags, no tag is returned.
2.     If the tag has a cq:movedTo property set, the referenced tag ID is followed.
This step is repeated as long as the followed tag has a 
cq:movedTo property.
3.     If the followed tag does not have a cq:movedTo property, the tag is read.
·       To publish the change when a tag has been moved or merged, the cq:Tag node and all its backlinks must be replicated: this is automatically done when the tag is activated in the tag administration console.
·       Later updates to the page's cq:tags property automatically clean up the "old" references. This is triggered because resolving a moved tag through the API returns the destination tag, thus providing the destination tag ID

TAGGING API AND TAGGING FRAMEWORK:

Tagging Framework implementation in AEM allows management of the tags andtag conten using JCR API.
·       JcrTagManagerFactory - returns a JCR-based implementation of a TagManager. It is the reference implementation of the Tagging API.
           Ex: To retrieve a TagManager instance, you need to have a JCR Session and to    
                  call getTagManager(Session):
1
2
3
4
@Reference
JcrTagManagerFactory jcrTagManagerFactory;
TagManager tagManager = jcrTagManagerFactory.getTagManager(session);

·       TagManager -  allows for resolving and creating tags by paths and names.
Ex:  In the typical Sling context you can also adapt to a TagManager from         the ResourceResolver:
1
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);

·       Tag - defines the tag object.
Retriving Tag Object
EX:  A Tag can be retrieved through the TagManager, by either resolving an existing tag or creating a new one:
1
2
3
Tag tag = tagManager.resolve("my/tag"); // for existing tags

Tag tag = tagManager.createTag("my/tag"); // for new tags
For the JCR-based implementation, which maps Tags onto JCR Nodes, you can directly use Sling's adaptTo mechanism if you have the resource (e.g. such as /etc/tags/default/my/tag):
1
Tag tag = resource.adaptTo(Tag.class);
While a tag may only be converted from a resource (not a node), a tag can be converted to both a node and a resource :
1
2
Node node = tag.adaptTo(Node.class);
Resource node = tag.adaptTo(Resource.class);













Monday, July 17, 2017

Basic customization steps, that should be done, when setting up AEM freshly for any organisation.

By default, when we first install AEM and run it, it will take us to projects.html or Content.html in Author and Publish environments. We can customize this to different paths, depending on organizational needs.

We can observe this in AEM content path  and  ConfigMgr  of  Felix console.
Under Content node properties, we can observe two properties sling:resourceType and sling:target, which will decide where it has to go.

  • For sling:target property,  we can update the path on where it has to go.  For example, if we have a content package like content/xyzmobile and if we wanna redirect to that particular content, then update the sling:target with respective content package like /xyzmobile.

  •  From the above step, the behaviour of the sling:resourceType with value sling:redirect will decide  and redirect it to value that was set with sling:target.  Go to ConfigMgr of the felix console and search for Day CQ Root Mapping and look for the target path and update according to your requirements.

   For ClientLibs:
           ClientLibs in AEM can be managed through Adobe Granite HTML Library
           Manager(Previously called as of Day CQ HTML Library Manager)
           the  OSGI configurations. There we can define the minification, packaging, library paths etc.. 
           This has to be set accordingly to the organizational level requirements.


                                                                                          (More points are coming up..)














Citations:
https://docs.adobe.com/docs/en/aem/6-3/deploy/best-practices/best-practices-for-queries-and-indexing.html
https://docs.adobe.com/docs/en/aem/6-3/deploy/platform/queries-and-indexing.html