May 10, 2020
Estimated Post Reading Time ~

AEM Concept

What are Caching, Frying, and Baking?
Traditionally, the concepts of baking versus frying are an important distinction between different Web Content Management Systems.  In CMS jargon, "baked" refers to the concept of committing data to static files at publish-time, while "fried" refers to the concept of processing data for final presentation at request-time.

How to Execute a Query in CRX Lite?
///element(*, cq:Component)

What is REST:

  • REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.
  • REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC, or SOAP to connect between machines, simple HTTP is used to make calls between machines.
  • In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.
  • RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.
  • REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much more simple REST is.
  • Despite being simple, REST is fully-featured; there's basically nothing you can do in Web Services that can't be done with a RESTful architecture.
  • REST is not a "standard". There will never be a W3C recommendation for REST, for example. And while there are REST programming frameworks, working with REST is so simple that you can often "roll your own" with standard library features in languages like Perl, Java, or C#.

Example in java:
package com.pc;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class RESTGetExample {

       /**
        * @param args
        */
       publicstaticvoid main(String[] args) {
              try{
              String content=httpGet("http://rest.elkstein.org/2008/02/using-rest-in-java.html");
              System.out.println("content is---->"+content);
              }catch(Exception e){e.printStackTrace();}

       }
       publicstatic String httpGet(String urlStr) throws IOException {
                URL url = new URL(urlStr);
                HttpURLConnection conn =
                    (HttpURLConnection) url.openConnection();

              if (conn.getResponseCode() != 200) {
              thrownew IOException(conn.getResponseMessage());
                }

              // Buffer the result into a string
                BufferedReader rd = new BufferedReader(
              new InputStreamReader(conn.getInputStream()));
                StringBuilder sb = new StringBuilder();
                String line;
              while ((line = rd.readLine()) != null) {
                  sb.append(line);
                }
                rd.close();

                conn.disconnect();
              return sb.toString();
              }
       publicstatic String httpPost(String urlStr, String[] paramName,
                     String[] paramVal) throws Exception {
                       URL url = new URL(urlStr);
                       HttpURLConnection conn =
                           (HttpURLConnection) url.openConnection();
                       conn.setRequestMethod("POST");
                       conn.setDoOutput(true);
                       conn.setDoInput(true);
                       conn.setUseCaches(false);
                       conn.setAllowUserInteraction(false);
                       conn.setRequestProperty("Content-Type",
                     "application/x-www-form-urlencoded");

                     // Create the form content
                       OutputStream out = conn.getOutputStream();
                       Writer writer = new OutputStreamWriter(out, "UTF-8");
                     for (int i = 0; i < paramName.length; i++) {
                         writer.write(paramName[i]);
                         writer.write("=");
                         writer.write(URLEncoder.encode(paramVal[i], "UTF-8"));
                         writer.write("&");
                       }
                       writer.close();
                       out.close();

                     if (conn.getResponseCode() != 200) {
                     thrownew IOException(conn.getResponseMessage());
                       }

                     // Buffer the result into a string
                       BufferedReader rd = new BufferedReader(
                     new InputStreamReader(conn.getInputStream()));
                       StringBuilder sb = new StringBuilder();
                       String line;
                     while ((line = rd.readLine()) != null) {
                         sb.append(line);
                       }
                       rd.close();

                       conn.disconnect();
                     return sb.toString();
                     }
}

Difference between dialog,design_dialog,cq:editConfig and cq:childEditConfig

  • cq:editConfig (cq:EditConfig) - Controls author UI aspects; for example, bar or widget appearance, adds custom controls.
  • cq:childEditConfig (cq:EditConfig) - Controls author UI aspects for child components that do not define their own cq:editConfig.
  • dialog (cq:Dialog) - Content editing dialog for this component.
  • design_dialog (cq:Dialog) - Design editing for this component.

Q1. What is a dialog?
Ans: the dialog defines the interface allowing the user to configure the component
the child node cq:editConfig (of type cq:EditConfig) defines the edit properties of the component and enables the component to appear in the Sidekick.
Note: if the component has a dialog, it will automatically appear in the Sidekick, even if the cq:editConfig does not exist.

  • cq:editConfig (cq:EditConfig) - this controls visual aspects; for example, it can define the appearance of a bar or widget, or can add customized controls
  • cq:childEditConfig(cq:EditConfig) - this controls the visual aspects for child components that do not have their own definitions
  • dialog (nt:unstructured) - defines the dialog for editing content of this component
  • design_dialog (nt:unstructured) - specifies the design editing options for this component 

Implicit object of CQ 

  1. slingRequest - The wrapped Request Object (SlingHttpServletRequest).
  2. slingResponse - The wrapped Response Object (SlingHttpServletResponse).
  3. resource - The Sling Resource Object (slingRequest.getResource();).
  4. resourceResolver - The Sling Resource Resolver Object (slingRequest.getResoucreResolver();).
  5. currentNode - The resolved JCR node for the request.
  6. log - The Default logger ().
  7. sling - The Sling script helper.
  8. properties - The properties of the addressed resource (resource.adaptTo(ValueMap.class);).
  9. pageProperties - The properties of the page of the addressed resource.
  10. pageManager - The page manager for accessing CQ content pages (resourceResolver.adaptTo(PageManager.class);).
  11. component - The component object of the current CQ5 component.
  12. designer - The designer object for retrieving design information (resourceResolver.adaptTo(Designer.class);).
  13. currentDesign - The design of the addressed resource.
  14. currentStyle - The style of the addressed resource.

How to use cq:include tag
How to include client lib in CQ
<%-- all: js + theme (theme-js + css) --%>
<%-- only js libs --%>
<%-- theme only (theme-js + css) --%>
<%-- css only --%>
Reference:
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/12/clientlibs-explained-by-example.html

What is the difference between design dialog and a normal dialog?
A design dialog is used to globally store variables through the template properties’ whereas a normal dialog stores all variables inside the page’s properties. One of the major benefits of using the design dialog is that if you have a hundred pages sharing the same template the variables will be shared amongst them. Also, note that you can have both design dialog and normal dialog on a page.

Q What benefit does an OSGi Bundle provide over a conventional Java “jar” file?
While it is true that you can start and stop a “jar” file, the concept of a bundle expands upon the conventional “jar” file by including metadata such as the version and list of services imported and exported by the bundle. This allows an OSGi bundle to be installed, updated, and uninstalled without taking down the entire application. Also, OSGi bundling allows multiple versions to exist, with the OSGi framework assuming the responsibility of matching “service consumers” with “service providers”. The net result is that an OSGi bundle is more of a standalone “software module” than a “jar”, “war”, or “ear” file.

Example of MANIFEST.mf file
Manifest-Version: 1.0
Bnd-LastModified: 1358770065345
Build-Jdk: 1.6.0_12
Built-By: phoolchandra
Bundle-Description: Maven Multimodule project for PC CQ5 Framework.
Bundle-ManifestVersion: 2
Bundle-Name: Virtusa CQ5 Framework Bundle
Bundle-SymbolicName: com.pc.cq.framework.vassets-bundle
e.g Use your application's package prefix as the bundle symbolic name. For example, if all of your Java source code is located in sub-packages Ofcom.virtusa.cq.framework.vassets-bundles the bundle symbolic name
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Always export packages with a version
One of the key advantages of the OSGi framework is its ability to manage bundle versions and the possibility of deploying multiple versions of a bundle in the same container. In order to take advantage of this capability, however, it is essential that you associate a version with any packages that you export.
Export-Package: com.pc.cq.framework.foundationframwork.action;uses:
 ="javax.jcr,org.apache.sling.api.scripting,com.pc.cq.framework.fou
 ndationframwork.manager,com.day.cq.workflow,com.day.cq.workflow.exec";version="1.
 0.0"
Import packages with version ranges
In order to benefit from OSGi version management capabilities, it is important to restrict the range of acceptable versions for imported packages. You can use either of the following approaches:
Import-Package: com.day.cq.commons.jcr,com.day.cq.dam.api,com.day.cq.dam
 .api.handler,org.osgi.framework;version="[1.3
 ,2)",org.osgi.service.component;version="[1.0,2)",org.slf4j;version="[1
 .5,2)"
Service-Component: OSGI-INF/serviceComponents.xml
Tool: Bnd-1.50.0
Use a naming convention for private packages
if you define any private packages in your bundle (packages that you do not want to export), it is recommended that you identify these packages using a strict naming convention. For example, if your bundle includes implementation classes that you do not want to export, you should place these classes in packages prefixed by ${project.artifactId}.impl or ${project.artifactId}.internal.

Note: If you do not specify any Export-Package instruction, the default behavior of the Maven bundle plug-in is to exclude any packages that contain a path segment equal to impl or internal.
References: http://fusesource.com/docs/esb/4.4/esb_deploy_osgi/BestPractices-BuildBundles.html

What is Adobe CQ5?
Adobe CQ5 platform allows you to build compelling content-centric applications that combine Web Content Management, Workflow Management, Digital Asset Management, and Social Collaboration. The product has been completely redesigned from Communiqué 4, allowing Adobe to use new architecture and technologies, thus increasing functionality while reducing complexity. Extensive use of standards helps ensure long-term stability.
Adobe CQ5 is geared specifically for large companies and corporations with substantial -and often global- infrastructures. It combines web content management, digital asset management, and social collaboration to deliver a solution that allows large companies to manage incredible amounts of information, multiple internal and external websites, a myriad of media assets, and detailed workflow

Architectural Changes in CQ 5.5
Earlier versions of CQ were based on a servlet container (CQSE, by default, though others could be used) running with multiple webapps: One for the CRX content repository and one for the OSGi container which itself contained Sling and CQ. The Sling webapp was bound to the root and handled most of the request processing.
With CQ 5.5 the OSGi container is positioned at the root and the OSGi HTTP service, backed by Sling acting as the sole request handling endpoint. The CRX content repository is now just another OSGi service, alongside the various services that comprise the rest of the CQ functionality. These changes do not affect applications built on top of CQ or Sling.
The new architecture means that the quickstart jar installation of CQ can no longer support other web applications running alongside CQ. However, the war version of CQ is intended to be deployed in an application server, where additional web applications can be deployed alongside it.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.