CQ5 Self Prepared Notes
CQ5 Self Prepared Notes
CQ5 Self Prepared Notes
Adobe CQ5 platform allows you to build content-centric applications that combine Web
Content Management, Workflow Management, Digital Asset Management and Social
Collaboration.
That is how, it deliver a global solution that allows companies to manage incredible
amounts of information, multiple internal and external websites, a myriad of media
assets, and detailed workflow
This product is used for increasing functionality while reducing complexity and use of
standards helps to ensure long-term stability.
Apache Sling – RESTful framework to access a jcr over http protocol. It maps the
request url to the node in jcr.
OSGi – framework for modular application development using java. Each module called
bundle can be independently started and stopped.
4- What is a content repository? What is JCR?
A Content repository is basically a place where digital content is stored. The structure of
the content repository is hierarchial and represented as a tree structure where each
node of the tree is used to store content.
It provides some wrapper classes and interfaces specific for many more functionalities
on top of jcr.
One more thing which differentiates as RESTful framework from other web-development frameworks is
that generally all web-development frameworks rely heavily only on HTTP Get and Post Requests. While
a restful leverages the maximum of http protocol. It uses all the types of http request (HEAD, GET, POST,
PUT, DELETE).
For example - consider a scenario where you want to delete a product from a product list with
product_id=111;
The server side code for the same will be somewhat like this if a HTTP GET request is sent from
client-browser with product_id=111 appended to the url.
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
Statement st = con.createStatement();
As you can see in the above piece of code, we are using a GET request to perform a delete
operation on a resource. Therefore we are not using the real power of HTTP protocol. According
to REST principles, the same could have been done by sending a HTTP DELETE request from
client browser and at server side.
Statement st = con.createStatement();
According to the REST architecture, there are 6 constraints which should be followed:
Client–server
There should be a clear separation between a client and server.
Stateless
The client–server communication is further constrained by no client context being stored on the
server between requests. Each request from any client contains all of the information necessary
to service the request, and any session state is held in the client.
Cacheable
As on the World Wide Web, clients can cache responses. Responses must therefore, implicitly or
explicitly, define themselves as cacheable, or not, to prevent clients reusing stale or
inappropriate data in response to further requests. Well-managed caching partially or
completely eliminates some client–server interactions, further improving scalability and
performance.
Layered system
A client cannot ordinarily tell whether it is connected directly to the end server, or to an
intermediary along the way. Intermediary servers may improve system scalability by enabling
load-balancing and by providing shared caches. They may also enforce security policies.
Servers can temporarily extend or customize the functionality of a client by the transfer of
executable code. Examples of this may include compiled components such as Java applets and
client-side scripts such as JavaScript.
Uniform interface
The uniform interface between clients and servers, discussed below, simplifies and decouples
the architecture, which enables each part to evolve independently. The four guiding principles
of this interface are detailed below.
The only optional constraint of REST architecture is "code on demand". One can characterise
applications conforming to the REST constraints described in this section as "RESTful".[8] If a
service violates any of the required constraints, it cannot be considered RESTful.
Complying with these constraints, and thus conforming to the REST architectural-style, enables
any kind of distributed hypermedia system to have desirable emergent properties, such as
performance, scalability, simplicity, modifiability, visibility, portability, and reliability.
6- What is Sling? How is it different from other web-
development frameworks?
Apache Sling is RESTful framework to access a java content repository over http
protocol.
It is a content driven framework that is it maps the incoming user request based on URI
to the corresponding node in the content repository and depending on the type of the
request(GET,POST, etc) executes the corresponding dynamic script.
For example - consider a scenario where admin is hitting a Indian website admin page
and getting the details of admin.
www.example.com/pages/admin.html
This would be mapped by the sling resource resolver to a node in the JCR
/content/example/pages/admin
Now the Sling resource resolver will check the properties of this node and check the
sling:resourceType property of this node, which will tell the script that will be used to
render the content of this page.
Then for all the incoming GET requests on the admin node, the above script will be
used to render the content.
The main advantages of sling are: it maps the url directly to the content. it is restful.
GET – www.mywebsite.com/products/product1.printable.a4.html/a/b?x=12
In Apache Sling each (http) request is mapped onto a JCR resource, i.e. a repository node. This
is very different from other web frameworks you might be familiar with, say, Struts or Rails. In
these frameworks a request is mapped onto a controller, i.e. a url really addresses application
code, so the application developer usually implements some application logic that retrieves
model data and passes it on to the view.
Node selection
So, how does this work in detail? Consider an http GET request for the url:
/content/corporate/jobs/developer.html
First, Sling will look in the repository for a file located at exactly this location. If such a file is
found, it will be streamed into the response as is. This behavior allows you to use Sling as a
web server and store your web application's binary data in the repository as well.
However, if there is no file to be found Sling will look for a repository node located at:
/content/corporate/jobs/developer
(i.e. it drops the file extension). If this node cannot be found Sling will return the http code 404.
Script folders
The scripts that Sling uses to process http requests are stored in subfolders of "/apps". Those
subfolders are usually of type nt:folder, but that's not a requirement.
Script selection
Nodes can have a special property named "sling:resourceType" that determines the resource
type. assume that the resource type is, say, "hr/job". The selected script will then be
"/apps/hr/job/job.esp" (the last part of the resource type will have to be the file name). This
works for GET requests and URLs ending in ".html".
Requests using other request methods, say POST, will cause Sling to look for the script at
"/apps/hr/job/job.POST.esp". Request URLs ending in something else than ".html", say
".pdf", will make Sling look at "/apps/hr/job/job.pdf.esp". The convention to distinguish the
two cases is that http methods are all uppercase and the extension of the request is all
lowercase.
In a content-centric application the same content must often be displayed in different variations,
e.g. as a teaser view and as a detail view. In Sling this is achieved through selectors. The
selector is specified in the URL like e.g.
/content/corporate/jobs/developer.detail.html
If the selected resource has no special resource type a script will be looked up based on
the content path. For example, the script for /content/corporate/jobs.html will be
searched in /apps/corporate.
Script engine
The ".esp"(Encapsulated PostScript) extension of the scripts used in the examples above
indicates script engine to use. ".esp" stands for Ecma script and internally uses Rhino, Mozilla's
Javascript engine. Other supported extensions are ".rb" for JRuby scripts, ".jsp" for JSPs or
".jst" for client-side execution (".jst" denotes Javascript template).
The examples above describe rendering nodes as html or as a pdf. Howevere, there are also
some built-in renderers for json and txt. The corresponding node presentations are located at
(using the example form above):
/content/corporate/jobs/developer.json
and
/content/corporate/jobs/developer.txt
respectively.
For http error handling (404 or 500) Sling will look for a script at
"/libs/sling/servlet/errorhandler/404.esp" and 500.esp, respectively.
{scriptPathPrefix}/{resourceTypePath}
Example: Given the search path [ "/apps", "/libs" ] and a resource type of sling:sample,
the following locations will be searched for scripts:
* /aps/sling/sample
* /libs/sling/sample
(2) Within the location(s) found through above mechanism a script is searched whose
script name matches the pattern
{resourceTypeLabel}.{selectorString}.{requestMethod}.{requestExtension}.{scriptExte
nsion}
If multiple scripts would apply for a given request, the script with the best match is
selected. Generally speaking a match is better if it is more specific. More in detail, a
match with more selector matches is better than a match with less selector
matches, regardless of any request extension or method name match.
(1) sample.esp
(2) sample.GET.esp
(3) sample.GET.html.esp
(4) sample.html.esp
(5) sample.print.esp
(6) sample.print.a4.esp
(7) sample.print.html.esp
(8) sample.print.GET.html.esp
(9) sample.print.a4.html.esp
(10) sample.print.a4.GET.html.esp
It would probably be (10) - (9) - (6) - (8) - (7) - (5) - (3) - (4) - (2) - (1). Note that (6) is a
better match than (8) because it matches more selectors even though (8) has a method
name and extension match where (6) does not.
If there is a catch, e.g. between print.esp and print.jsp, the first script in the listing would
be selected (of course, there should not be a catch...)
Consider a scenario where you have a large application which uses a logging
framework. This logging framework can be deployed as an OSGi Bundle, which can be
managed independently. Therefore, it can be started when required by our application
and can be stopped when not in use.
Also the OSGi container makes these bundles available as services, which can be
subscribed by other parts of application.
The main advantages of using OSGi :
1) reduces the complexity of the system.
2) Makes the components loosely couples and easy to manage.
3) Increases the performance of the system, since parts of application which are not in
use,need not to be loaded in the memory.
The OSGi Framework is made up of three layers -- Module, Lifecycle, and Services --
that define how extensible applications are built and deployed. The responsibilities of
the layers are:
Bundle = jar + OSGI information (specified in the JAR manifest file – META-INF/MANIFEST.MF)
If you want your template to be displayed in the Create Page dialog when
creating a page right under Websites from the Websites console, set the
allowedPaths property of the template node to: /content(/.*)?
Templates are used to create Pages of type cq:Page (as mentioned earlier, a Page
is a special type of Component). Each CQ Page has a structured node jcr:content.
This:
• is of type cq:PageContent
• is a structured node-type holding a defined content-definition
• has a property sling:resourceType to reference the component holding the sling
scripts used for rendering the content
1) Publish (activate) content from author to publish environment using replication agent.
2) Explicitly flush content from the dispatcher cache.
3) Return user input from the publish environment to the author environment.
REPLICATION PROCESS:
If any content is updated, then it flushes the older content from dispatcher cache, but it
won't put new content at the same time. New content will be fetched into cache, when the
next time it is requested.
In this post I’ll try to show the benefit of using client libs feature to reduce the page size. Let’s
consider a scenario where we have a web application built using CQ and it has multiple pages
that are composed of many component. Each component needs a set of JS, CSS and images
which might not be needed on other pages so, it does not make sense to load all those
irrelevant resources on other pages where that component is not present.
For example we have a login page and a home page that user sees after successful login. The
login page is composed of a login component (with a form) to enter username and password
and we are using a jQuery validation plugin to validate form before submitting it to server. Once
user is validated we redirect user to home page which does not have any form (i.e. we don’t
need validation jQuery
plugin) on this page and there is no point in including validation plugin and we only need jQuery
javascript file.
Normally, we include resource (like JS, CSS) in section of a page (in CQ it’s a template). If
jQuery and jQuery validation plugin is included in head section of template then it’ll be included
on every page no matters whether that page actually needs them or not and hence the page
size is increased unnecessarily. There is better way to handle this in CQ and load the resources
when they are actually needed and this is where CQ’s clientlib feature comes in to play.
What is client lib feature?
With client lib feature we can categorize every JS and CSS file as a library (with a specific
name) and can include/import them in individual component or template (if it is used globally).
For the time being consider this as java import feature. If on a page there are multiple
component that needs the same library then CQ will make sure that the library is loaded only
once. We can also define dependencies while creating clientlibs, e.g. jQuery validation plugin is
dependent on base jQuery JS file.
2) Create a new node under clientlibs folder called as jqvalidate with type as
cq:ClientLibraryFolder (as shown below):
3) Copy/Put your JS (jq.validate-min-XXX.js) file in jqvalidate folder (we can also copy and css
file to this folder if there is any).
4) Create a file js.txt in jqvalidate folder (also create another file css.txt if you have copied any
css file in jqvalidate folder).
5) Add name of JS file (e.g. jq.validate-min-XXX.js) in js.txt (also add name of CSS file in
css.txt) file and save it.
6) Click on jqvalidate folder node in crxde and open the Properties tab and update/add 2 new
properties as shown below and save the node:
NOTE: both properties are of type String Array (String[])
a) categories: This is the name using which we’ll be referencing our jQuery validation client lib in
our components and templates.
b) dependencies: Using this property we define the dependency of current library (in this case
jQuery validation) on another client lib (in this case cq.jquery).
At this point we are done with creation of a validation library now, we’ll see how to use for
developing components and templates.
1. <cq:includeclientlib categories="jquery.validate">
2. </cq:includeclientlib>
If you want to load multiple client libs then provide comma separated names against categories
attribute in above tag e.g.
2. </cq:includeclientlib>
The "clientlib" functionality will manage all your Javascript and CSS resources in your
application. It takes cares of dependency management, merging files and minifying content.
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/12/clientlibs-
explained-by-example.html
16. 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.
A dialog saves content relative to the given page. In comparison, a 'design' dialog saves
content globally (at a template level).
Dialog is a key element of your component as they provide an interface for authors to
configure and provide input to that component. The user input will be stored at page level.
Design dialog will share the content at the template level. Also we can dynamically change
the content in design mode.
Within CQ, there are some key folder structures. For example, you may have a page at the
following path:
/content/your-site/en_HK/your-page
Within that page you have a component that has both a dialog and a design dialog. When you
save content in the dialog, it is saved to a node beneath the given page. Something like:
/content/your-site/en_HK/your-page/jcr_content/some-par-sys/your-component
However, when you save content to the design dialog, it is saved to a 'global' design
path. Something like:
/etc/design/your-site/en_HK/your-template/jcr_content/your-component
This mechanism allows the content that has been saved in the design dialog for the GIVEN
TEMPLATE to be available in all templates of the same type (basically).
http://daycq.blogspot.in/2011/12/dialog-designdialog.html
Use of the Overlay component is , when you want to use the out-of-box component and
you want to add some extra feature in it , so instead of changing the code from
“libs/foundation/components/component-name.jsp” just follow the below process and
use it. By using this we can use the out-of-box feature with our extra feature without
changing behaviour of out-of-box component . So that other projects which are using it
can't be affected.
<div style="border-width:1px;border-style:solid;border-
color:black;width:100%;background:grey;color:white">
Overlaid text component
</div>
Figure 1 : create the foundation/components folder under apps.
Figure 2 : The text component used by geometrixx page will now use the code from
“apps/foundation/components/text” instead of
“libs/foundation/components/text”
This will CHANGE how the foundation component behaves in all instances. And the
existing sidekick component remains, but behaves differently.
It is not ignored. Both components can show up in the authors' sidekick -- one will
say flash (foundation), the other flash (myproject).
2.
Add the below properties to the component.
EXAMPLE 2 :
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.
Sling is based on OSGi. OSGi (Open Services Gateway Initiative) defines an architecture for
developing and deploying modular applications and libraries. As such, extending Sling with
application-specific components ("bundles" as they are called in OSGi lingo) essentially means
creating a bundle
A bundle is a jar file plus some meta information. Let us start with a simple service interface
class. In OSGi development it is common practice to use interfaces and implementing classes.
package com.day.samples;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
This is really just a plain old Java interface, nothing OSGi- or Sling-specific to be seen here, just
some JCR classes are imported. I chose these four methods because they provide some
insights how to develop OSGi bundles on top of Sling. However, they are not "required" in the
sense that e.g. EJB 2 would require a certain structure of your classes. The implementing class
looks like:
package com.day.samples.impl;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.samples.HelloService;
public class HelloServiceImpl implements
HelloService{
LoggerFactory.getLogger(HelloServiceImpl.class);
throws RepositoryException {
return new
StringBuffer(node.getPath()).reverse().
toString();
return
repository.getDescriptor(
SlingRepository.REP_NAME_DESC);
repository) {
this.repository = repository;
repository) {
this.repository = null;
log.error(text);
The implementation imports the SlingRepository class and a logger class that comes with Sling.
In order to compile this class you will need to have the Sling jars on your classpath. If you use
CRX Quickstart find them in launchpad/felix/bundleXX.
For the bundle description we will need a descriptor file called MANIFEST.MF located in META-
INF and contains:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: HelloWorld
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework;version="1.3.0",
org.apache.sling.jcr.api,org.slf4j
Export-Package: com.day.samples;version="1.0.0"
Private-Package: com.day.samples.impl
Service-Component: OSGI-INF/serviceComponents.xml
Note that the packages that are used in the implementing class above must be imported.
Also, the packages that shall be exposed from our bundle to other bundles must be
marked as "exported". Further, there must be a reference to the second needed descriptor file
OSGI-INF/serviceComponents.xml. This file contains:
<components
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
name="com.day.samples.impl.HelloServiceImpl">
<scr:implementation
class="com.day.samples.impl.HelloServiceImpl"/>
<scr:service servicefactory="false">
<scr:provide
interface="com.day.samples.HelloService"/>
</scr:service>
<scr:property name="service.description"
<scr:property name="service.vendor"
value="Day"/>
<scr:property name="service.pid"
value="com.day.samples.impl.HelloServiceImpl"/>
<scr:reference name="repository"
interface="org.apache.sling.jcr.api.
SlingRepository"
cardinality="1..1" policy="static"
bind="bindRepository"
unbind="unbindRepository"/>
</scr:component>
</components>
This file configures which implementation of the interface shall be used. It also configures the
"injection" of the repository variable into the HelloServiceImpl class (highlighted). The "setter" is
configured in the "bind" attribute. HelloServiceImpl must implement this method.
For creating an OSGi bundle you just need to compile these classes and package them in a jar
file together with the descriptors (the complete bundle is attached).
Upload your bundle jar file, press "Install or Update" and "Refresh Packages". Your bundle
should now show up in the list of bundles. If it has not been started start it yourself by pressing
"start".
sling.getService(
Packages.com.day.samples.HelloService);
%>
The HelloService also contains a method getReversedNodePath(Node node) that takes a JCR
node as a parameter (it diabolically returns the node's path as a reversed string). For passing
the currently processed node to this method use:
<%= service.getReversedNodePath(currentNode)%>
The method log(String text) in HelloService writes into Sling's log file. This can come in handy
for debugging purposes. Note again that the logger package needs to be imported in
MANIFEST.MF in order to be visible.
In the method getRepository() the name of the current repository is returned. This method
illustrates how to access the repository from within the bundle and thus perform manipulations
or queries on the repository.
Final remarks
If you care to look at Sling's source code to learn more you will notice the lack of configuration
files like serviceComponents.xml. The reason for this is that the Sling develpers use a Maven
plugin that automatically generates these artifacts. You can still find them in the generated jar
files, of course.
9.Building-workflows-in-adobe-cq5
--http://blog.navigationarts.com/building-workflows-in-adobe-cq5/
you are free to add whatever property you want in a sling:folder (not in a nt:folder)
- you are free to add whatever nodetype you want in a sling:folder (not in a nt:folder)
The "nt" means "Node Type", and a "node type: folder. The "sling" prefix means that this one special
folder belongs to the type "Sling",
nt:folder represents a plain file system folder (it can have nt:folder and nt:file children and only a
few restricted meta data properties).
Error 409 “could not save changes” come when we save a node of nt:unstructured type under
nt:folder
1) OSGi bundles are jar files with metadata inside manifest file, found at META-
INF/MANIFEST.MF. This metadata, when read by an OSGi runtime container, is what gives
the bundle its power.
2) With OSGi, just because a class is public doesn't mean you can get to it. All bundles
include an export list of package names, and if a package isn't in the export list, it doesn't
exist to the outside world. This allows developers to build an extensive internal class
hierarchy and minimize the surface area of the bundle's API without abusing the notion of
package-private visibility. A common pattern, for instance, is to put interfaces in one
package and implementations in another, and only export the interface package.
3) All OSGi bundles are given a version number, so it's possible for an application to
simultaneously access different versions of the same bundle (eg: junit 3.8.1 and junit 4.0.).
Since each bundle has its own classloader, both bundles classes can coexist in the same
JVM.
4) OSGi bundles declare which other bundles they depend upon. This allows them to
ensure that any dependencies are met before the bundle is resolved. Only resolved bundles
can be activated. Because bundles have versions, versioning can be included in the
dependency specification, so one bundle can depend on version junit version 3.8.1 and
another bundle depend on junit version 4.0.
The below images tells us how a URL is resolved and mapped to a resource.
Consider the URL
GET – www.mywebsite.com/products/product1.printable.a4.html/a/b?x=12
http://docs.adobe.com/docs/en/cq/5-6-1/developing/developmenttools/how-to-build-aem-
projects-using-apache-maven.html
It created two folder “bundle” and “content” for OSGI and CQ Content. We imported in eclipse
IDE for development and modified the pom file with dependency and configuration. For detail
read the link given.
3- For build process, created a batch file. Mvn build cmd was there and cURL commands
were there for downloading, uploading and installing the packages on the other local
server QA. This was done for the automation. On build success on QA server then build
was deployed on the dev and staging server of client by batch file.
mvn clean install -PautoInstallPackage > build_deploy_local.log
For cURL, see below in file.
4- There are two flows (EPS and CSR) in the projects with almost same pages. So dialogs
were having most of the fields same. For the different fields, we have created the
different tabs in the dialog, on the basis of the tags of the page; it shows the tab
associated with that page.
Explanation: - we have given the tag on the page from page property. It got save at jcr:content
node. We read it in jsp and set it in html hidden type field. In listener of the dialog, we fetched
this variable and on the basis of it, we did hide and show of the tabs.
https://docs.adobe.com/docs/en/cq/5-6-1/developing/tagging.html
http://cq5experiences.blogspot.in/2014/02/hide-and-show-tab-in-dialog-depending.html
5- Complex dialog was written in extended JS. Which is having some common field at the
top, then some no of fields on left hand side, when we click add, it move all the data on
the right hand side of the dialog in the tabular format. So we can add any no of data set
in the dialog. We can also update the data of the row by right click on that row and click
update. So all data were moved to LHS for update.
Explanation: - We have created a theme config component. This component was included in
EPS template. In dialog, path field for home page was there. Then, at LHS, we were having path
field for css, dropdown for themes. Theme names were created in tags. In the jsp we fetched
the tags and created JSON and set this JSON object value in html hidden type field. The same
we fetched in extended JS for populating the dropdown for this dialog. It was also having
corresponding image field for logo.
After adding these values, it goes to RHS. So we can add themes css and logo for all the themes.
At the time of opening of the page URL, on the basis of the selector, we applied the theme for
the site.
if(res!=null){
node= res.adaptTo(Node.class);
theams = node.getNodes();
while(theams.hasNext()){
themeNode = theams.nextNode();
logoPath.add(themeNode.getProperty("image").getString());
theme.add(themeNode.getProperty("theme").getString());
cssPath.add(themeNode.getProperty("cssPath").getString());
}
}
%>
6- One more complex component was there. Grid component. We were having lots of
table in the project for the different reports.
So we created one multi-field label comp for table header. It was saving the header name as
label and all small, without space and special character key.
Then we created component for configuring the table for the page by selecting the labels from
dropdown. We have to select the user type to which that label should be shown, these user
type are tags. So we are accessing tags in the extended JS file for the dialog.
Configured table can be selected in the dropdown by the name in the grid component.
Tag path for themes and user type, Home page path for EPS and CSR and theme page path
etc., we have given in configuration.
7- Wrote the controller or u can say helper bean java class for the component for fetching
the values from the content level node and processed on them before showing them on
the page.
Explanation: -
Abstract component and component helper class.
AbstractComponent.java StoreDataPopulationBean.java
<li><strong><fmt:message key="store-details-phone"/></strong>
<p>${phone}</p></li>
<li><strong><fmt:message key="store-details-hours"/></strong>
<p>${openingHrs}</p></li>
</ul>
</div>
This annotation can be applied on the component class level or on a field defining a constant with the
name of the property. We can see this component is registered in system/console/component
The @Property annotation defines properties which are made available to the component through
the ComponentContext.getProperties() method. These tags are not strictly required but may be
used by components to defined initial configuration.
We have written activate method to get and set all the properties from the dialog by
componentcontext (org.osgi.service.component.ComponentContext).
protected void activate(final ComponentContext context) {
final Dictionary properties = context.getProperties();
this.themeConfigPath = properties.get(THEME_CONFIG_PATH).toString();
this.gridConfigPath = properties.get(GRID_CONFIG_PATH).toString();
this.labelConfigPath = properties.get(LABEL_CONFIG_PATH).toString();
this.restWebServiceBaseURL =
properties.get(REST_WEBSERVICE_BASE_URL).toString();
this.homePageEPS = properties.get(HOME_PAGE_EPS).toString();
this.homePageCSR = properties.get(HOME_PAGE_CSR).toString();
this.themeTagsNs = properties.get(TAGS_THEME_NS).toString();
this.userTypeTagsNs = properties.get(TAGS_USERTYPE_NS).toString();
}
OptumConfigService.java OptumConfigServiceImpl.java
HelloService hs = sling.getService(HelloService.class);
out.println("HELLO:::::" + repositoryName);
%>
If you look carefully you will come to know that these are properties of the node. Sling is
providing the node data in json format when we append the url with “.json”. In the same way the
same is true for xml, txt, pdf.
Let me tell you that .json is enabled by default and .xml, .txt and .pdf are not enabled by default.
To enable/disable the renderer go to felix console configuration tab and search for Apache Sling
GET Servlet and check/uncheck the boxes to enable/disable the renderers.
To explain how this concept can be used in our application, let me take an example of populating
a Dialog drop down with some dynamic values. I can do this in two ways:
1. By using a servlet.
2. By using the concept of .json (renders)
By using a servlet:
In dialog, create a dropdown widget (xtype: selection, type:select) and add a property as below:
Property name: “options”
(Note that this property should be added to the dropdown widget in the dialog)
Then I write a servlet which gets the dynamic data, forms a json object and populates the
dropdown.
This is a simple case. Using this approach may be difficult when we need to pass a query
parameter to the servlet. Now we need some different approach which makes it easy when
dealing with situation like this.
By using .json:
In dialog, create a dropdown widget (xtype: selection, type:select) and add options property as
below:
Create a jsp file with name “optionsprovider.json.jsp” (it can be any name, but make sure you
provide the same name in the options property as well) and write a json rendering code in your
jsp, then the drop down will be populated by the output of the “optionsprovider.json.jsp”.
Usertypes.json.jsp
<%
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
String val="";
String delim = "";
Value values[] = null;
Node node = null;
Node tempnode = null;
NodeIterator it = null;
ArrayList<String> configs = new ArrayList<String>();
ArrayList<String> configsValue = new ArrayList<String>();
String tagsPath = "/etc/tags/optum/usertypes";
TagManager tagManager =
slingRequest.getResourceResolver().adaptTo(TagManager.class);
if (null != tagManager) {
Tag parent = tagManager.resolve(tagsPath);
Iterator<Tag> iter = parent.listChildren();
while (iter.hasNext()) {
Tag child = iter.next();
configs.add(child.getName());
configsValue.add(child.getTitle());
}
}
%>
[<%
for(int i=0; i<configs.size();i++){
%><%= delim %>
{"text":"<%= configsValue.get(i)
%>","value":"<%=configs.get(i)%>"<%
%>}<%
if ("".equals(delim)) delim = ",";
}
%>]
<%@page import="com.mongodb.*"%>
<%
Mongo mongo = new Mongo("localhost", 27017);
%>
WSDL defines contract between client and service and is static by its nature.
SOAP is a successor of XML-RPC and is very similar, but describes a standard way
to communicate.
Feed it a web service URL and you can call its web service functions without the need
of specific code.
Binary data that is sent must be encoded first into a format such as base64 encoded.
Has several protocols and technologies relating to it: WSDL, XSDs, SOAP, WS-
Addressing
REST (REpresentational state transfer):
Rest is a simple way of sending and receiving data between client and server and it doesn’t
have very many standards defined. You can send and receive data as JSON, XML or even
plain text. It is lightweight compared to SOAP.
In case of REST contract between client and service is somewhat complicated and is
defined by HTTP, URI, Media Formats and Application Specific Coordination Protocol.
It’s highly dynamic unlike WSDL.
Typically uses normal HTTP methods instead of a big XML format describing
everything. For example to obtain a resource you use HTTP GET, to put a resource
on the server you use HTTP PUT. To delete a resource on the server you use HTTP
DELETE.
REST is a very simple in that it uses HTTP GET, POST and PUT methods to update
resources on the server.
REST typically is best used with Resource Oriented Architecture (ROA). In this mode
of thinking everything is a resource, and you would operate on these resources.
Binary data or binary resources can simply be delivered upon their request.
We can also use windows scheduler for this batch file. So all process will run
automatically at the scheduled time.( http://www.sevenforums.com/tutorials/12444-
task-scheduler-create-new-task.html)
DOS Command –
ECHO – the “print” statement for BAT files. Anything following the word ECHO will be
displayed in the command prompt as text, on its own line.
ECHO OFF – BAT writers typically put this at the beginning of their files. It means that the
program won’t show the command that you told it to run while it’s running – it’ll just run the
command.
PAUSE – This outputs the “press any key to continue…” message that you’ve seen all too
many times. It’s helpful because it pauses the BAT file execution until the user tells it to go
again. If you don’t put this in your program, everything will speed by and end before you can
see it.
CLS – Clears the DOS window (helpful if things get too cluttered!).
IPCONFIG – Outputs a lot of network information into your DOS box
PING – Pings an IP, letting you know if your computer was able to contact it. This command
also returns the latency (ping time) and by default pings three times.
Commands:-
1- curl –help
Install the manual for all the default cURL commands
2- curl --manual > <curlManual.txt>
For creating a file of curl manual
3- curl -u admin:admin
http://localhost:4502/crx/packmgr/service.jsp?cmd=help
Help Menu for useful AEM commands
4- curl -u admin:admin
http://localhost:4502/crx/packmgr/service.jsp?cmd=ls
List all the package
5- curl -u admin:admin -X POST
http://localhost:4502/crx/packmgr/service/.json/etc/packa
ges/my_packages/samplepackage.zip?cmd=build
Build the package.
2. Check out the repository by typing the following (substituting your port number for 4502 and your admin
passwords):
http://docs.adobe.com/docs/en/cq/5-6-1/core/how_to/how_to_use_the_vlttool.html
These properties allows you to set some contract of structure of pages in you project. For
example: you have 3 templates (and corresponding pages with this templates):
template-1: allowedChildren="[template-2]"
template-2: allowedChildren="[template-3]"
template-3: allowedChildren="[]"
Then in siteadmin, you will be able to create:
under page with template "template-1" only pages with template "template-2",
under page with template "template-2" only pages with template "template-3",
under page with template "template-3" you will not be able to create any page.
If template-1:allowedparent="[template2]"
http://docs.adobe.com/docs/en/cq/5-6-1/developing/templates.html#Template%20Availability
http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/
http://www.ronaldwidha.net/2008/06/16/a-good-example-of-abstract-class-vs-interface/
Eval--- http://www.w3schools.com/jsref/jsref_eval.asp
Over loading/overriding
http://www.javatpoint.com/method-overloading-vs-method-overriding-in-java
To be study---
https://docs.adobe.com/docs/en/cq/5-6-1/administering/multi_site_manager.html
Not sure if you have noticed but when an author types in anything inside the rich text editor
(even if you are in the HTML Editor mode) it gets encapsulated by a P tag. I came across a
situation in which the requirement was to get rid of the default p tag so the rendering engine
consuming the content does not have to parse it out. Please note that you will still get a bunch of
P tags when you have a line break. This is how I got it working.
2. No go back to your content page and refresh it. Add a single line of text while in RichText
mode and then toggle between SourceEdit mode and Rich Text mode. You should not see the P
tags wrapping your line of content.
Disabling the "Target" context menu item in AEM v5.6
https://forums.adobe.com/message/5334713
libs/cq/ui/widgets/source/widgets/wcm/EditBase.js in
/apps/cq/ui/widgets/source/widgets/wcm/EditBase.js and then I just added one line of code. If
you search the js file for addTargetingActions you will find the function that adds the button to
the toolbar. A config object is passed into the function. If you add one line at the beginning of
the funtion just below line 1728...
config.disableTargeting = true;
"jcr:title":"Paragraph System",
"sling:resourceSuperType":"/libs/foundation/components/parsys",
"componentGroup":".hidden",
"cq:isContainer":"true",
"jcr:primaryType":"cq:Component",
"cq:childEditConfig": {
"cq:disableTargeting": true,
"jcr:primaryType": "cq:EditConfig"
},
"cq:editConfig": {
"cq:disableTargeting": true,
"jcr:primaryType": "cq:EditConfig"
}}
https://docs.adobe.com/docs/en/cq/5-6-1/developing/components/dev-targeted.html
https://docs.adobe.com/content/docs/en/aem/6-0/develop/personalization/target.pdf
http://docs.adobe.com/docs/en/aem/6-0/administer/integration/marketing-cloud/target.html
http://docs.adobe.com/docs/en/aem/6-0/author/personalization/target.html