1. What is Adobe CQ5? (now Onwards AEM5.6-Adobe Experience Manager 5.6 )
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
2. New in CQ 5.5 ?
- Creative Suite: Adobe’s flagship software now integrates seamlessly with CQ5.5’s Digital Asset Management (DAM) via Drive or Bridge. Creative teams can now adjust a photo, push it directly to the web, and then get analytic feedback on how photo versions are performing—all without ever leaving Creative Suite. The move allows Adobe to start interesting WCM conversations with every company that uses Adobe’s Creative Suite. And last I checked, that was every company on the planet.
- Scene7: At first this cloud-based digital asset management system was awkwardly competitive with CQ5’s own DAM, and even Adobe seemed unclear when they should suggest a given product to customers. But the integration has made it much easier for companies in retail, hospitality, travel, or CPG to take advantage of Scene7’s dynamic personalization capabilities.
- Search&Promote: Site search components now come out-of-the-box—as long as you’ve bought a Search&Promote license, of course. This is an interesting integration since Adobe’s search product hasn’t been a category leader as a standalone, but the convenience of adding faceted search to your site via a drag and drop user interface (UI) is pretty tempting. The integration also challenges Autonomy/Interwoven right on its home turf.
- SiteCatalyst and Test&Target: While the new version of the integration with these two former Omniture products doesn’t appear to add much new functionality from the CQ5.4 iteration, the presentation layer is much more intuitive and plays very nicely with the personalization features.
- eCommerce Capabilities: WCM and eCommerce platforms have become more competitive in recent years. WCM systems often claim to handle product catalogues seamlessly and eCommerce software makes the same flawed case about handling complex digital marketing messaging. Adobe seems to have recognized that the market demands a unified approach, so they’ve partnered with hybris software to add some nice eCommerce capabilities just in their out-of-the-box demo site. Of course, if you want to use these features on your site, there are additional licensing costs.
- Mobile: CQ5.4 already had a sophisticated mobile Web solution; CQ5.5 adds the ability for content authors to work directly on mobile apps. After Adobe’s PhoneGap acquisition, adding this functionality was clearly on Adobe’s roadmap, but to incorporate the integration in the first post-acquisition release is impressive.
- Undo/Redo: Ok, admittedly, multi-step undo/redo with control-Z and control-Y isn’t really a theme, but you’ve got to give this feature its due. This is super-cool Web tech for the geeks, got-to-have-it-now sexiness for CQ5 demonstrators, and the savior from careless keystrokes for countless grateful content authors.
- Technical Improvements: One of the things Day did best pre-acquisition was take a two-pronged approach at appealing to both technical and business buyers of WCM. It’s nice to see that Adobe hasn’t abandoned that philosophy by coupling some eye-candy for marketers with brain-candy for the tech geeks. Key technical improvements focus on easier cloud deployments, better monitoring and automation, scalability for multi-site management, improved fault tolerance for clustering.
- Clearer Product Branding: Like all enterprise software companies, Adobe loves renaming products, but this past year, we confess we couldn’t understand where they were going at times between CQ5, Web Experience Management (WEM), and Adobe Digital Enterprise Platform (ADEP). It may just be a name, but we're very glad that they’ve recently decided to retain the CQ5 name for the product and designate WEM as the umbrella designation for all their enterprise products for Web including CQ5, Scene7, SiteCatalyst, Test&Target, etc.
- Licensing/Pricing: If there’s one thing that enterprise software companies like to do more than changing their product names, it’s changing their pricing model. Fortunately, CQ5.5 only involves a small change: instead of Basic, Standard, and Premium editions, Adobe now only sells Basic and Standard editions. And since the DAM functionality is only included in the Standard pricing, we suspect the Standard edition will be most popular with Adobe’s customers. The bottom line is that while CQ5.5 isn’t a revolutionary advance over CQ5.4, it’s an extremely solid release that takes great strides towards proving Adobe’s corporate vision and leadership position in the WCM market.
- The Page Exporter
CQ allows you to export a page as a complete web page including images, .js and .css files.
Using a Proxy to Integrate with InDesign Server
INDESIGN
This allows you design page layouts for print and/or digital distribution.
INDESIGN SERVER
This engine enables you to programmatically create automated documents based on what you have created with InDesign. It operates as a service offering an interface to its ExtendScript engine.
The scripts are written in extendscript, which is similar to javascript.
CQ DAM PROXIES
A proxy is used to enable the two-way communication between a CQ instance(s) and a proxy worker (for example, for communicating with an InDesign Server). Any CQ instance can be used as a proxy and can communicate with any number of other CQ instances.
PROXY WORKERA proxy worker is a processor responsible for handling a job and creating a result. A proxy worker can be used for a wide variety of tasks, for example using an InDesign Server to process files.
3. What is the difference between
1. <c:import url="layout-link.jsp" />
2. <sling:include path="layout-link.jsp" />
3. <cq:include script="layout-link.jsp" />
What is the advantage of each tag? When should each be used?
CQ Include is most appropriate when you are doing standard component/template development.
Sling include is most appropriate when you are trying to include a piece of content as based strictly on sling resource resolution and not CQ component type logic.
1. <c:import url="layout-link.jsp" />
I assume this is the import tag of the Standard Tag Library. This tag is documented athttp://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/import.html and does not know about Sling directly.
But -- asuming -- this tag is using a RequestDispatcher to dispatch the request, this tag will also pass Sling and the Sling resource resolver.
2. <sling:include path="layout-link.jsp" />
This is the include tag of the Sling JSP Tag library. This tag knows about Sling and also supportsRequestDispatcherOptions.
3. <cq:include script="layout-link.jsp" />
This tag is Communiqué specific extension of the Sling JSP Tag library include tag. IIRC it supports callings scripts in addition to just including renderings of resources.
What is the advantage of each tag? When should each be used?
In a Communiqué application, I would suggest to generally use the Communiqué or Sling include tag since this provides you more Sling support.
You may use the JSTL import tag if you don't have specific requirements for Sling extended features, plan to use the JSP (fragment) outside of Communiqué or if you want to further process the generated (imported) content with a reader or a variable.
In the future, it is conceivable that the Sling and/or Communique tag library will also provide an import tag similar to the JSTL import tag to be able to further process the imported result.
http://dev.day.com/discussion-groups/content/lists/cq-google/2009-10/2009-10-06__day_communique_tag_difference_cq_sling_c__zambak.html
4. What is Clientlibs?
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
5. 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).
Within CQ/AEM, 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).
This can come in handy with headers, footers, and (as the name implies) in cases where a consistent design should be used
6.What is the Dispatcher?
The Dispatcher is the Adobe caching and/or load balancing tool that helps realize a fast and dynamic Web authoring environment. For caching, the Dispatcher works as part of an HTTP server, such as Apache, with the aim of storing (or "caching") as much of the static website content as possible and accessing the website's layout engine as infrequently as possible. In a load balancing role, the Dispatcher distributes user requests (load) across different clustered CQ instances (renders).
For caching, the Dispatcher module uses the Web server's ability to serve static content. The Dispatcher places the cached documents in the document root of the Web server.
How does the Dispatcher perform caching?
The Dispatcher uses the web server's ability to serve static content. The Dispatcher stores cached documents in the web server’s document root. The Dispatcher has two primary methods for updating the cache content when changes are made to the website.
- Content Updates remove the pages that have changed, as well as files that are directly associated with them.
- Auto-Invalidation automatically invalidates those parts of the cache that may be out of date after an update. For example, it effectively flags relevant pages as being out of date, without deleting anything.
How does CQ perform load balancing?
Load Balancing distributes user requests (load) across different clustered CQ instances.The following list describes the advantages for load balancing:
- In practice this means that the Dispatcher shares document requests between several instances of CQ. Because each instance has fewer documents to process, you have faster response times. The Dispatcher keeps internal statistics for each document category, so it can estimate the load and distribute the queries efficiently.
- If the Dispatcher does not receive responses from an instance, it will automatically relay requests to one of the other instance(s). Thus, if an instance becomes unavailable, the only effect is a slowdown of the site, proportionate to the computational power lost.
7. What is Personalization?
Personalization provides your users with a customized environment that displays dynamic content selected according to their specific needs.There is an ever-increasing volume of content available today, be it on internet, extranet, or intranet websites.Personalization centers on providing the user with a tailor-made environment displaying dynamic content that is selected according to their specific needs; be this on the basis of predefined profiles, user selection, or interactive user behavior.
Teaser Component used in Personalization
8. Multi-Site Management
Multi-Site Management handles multilingual and multinational content, helping your company balance centralized branding with localized content.
9.Building-workflows-in-adobe-cq5
--http://blog.navigationarts.com/building-workflows-in-adobe-cq5/
10. What is a CQ5 overlay/override component?
I've been asked to create a CQ5 "overlay" component by simply copying the out-of-box component from /libs/foundation/components/flash to /apps/myproject/components/flash. My question is: what happens to the original - is it just ignored?
Overlay /override component is Universally across the WEM.
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.
Example : Overlaying the TEXT component.
- Create the “foundation/components” folder under apps as in figure 1.
- Copy the text component from “libs/foundation/components/text”
- Append the below code in text.jsp
- Change the jcr:title to Text Overlayed.
<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.
- Now open the “http://localhost:7502/cf#/content/geometrixx/en.html” page, you will see the
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). When one of these is used by an author CQ will instantiate appropriately. The usual rules apply for what shows up in the sidekick (group name, selected in design mode, etc.)
a CQ5 "overlay" leverages sling rules for resource resolving.
if/libs/foundation/components/flash needs an overlay, you "overlay" the corresponding file at location /apps/foundation/components/flash/filename This will CHANGE how the foundation component behaves in all instances. And the existing sidekick component remains, but behaves differently.
If you have a NEW component at /apps/myproject/components/flash, it can inherit from the foundation component via sling:resourceSuperType on the new component. In that case, you have a new component in the sidekick. In your new component, you could use the same values forjcr:title, componentGroup, or you could change them to distinguish your component in the sidekick. If the title, componentGroups are the same, the sidekick can distinguish them with parenthesis around the webapp (foundation) vs (myproject). However, I have seen situations where it is impossible as an author to distinguish them.
11. How to extend/inherit the components ?
Difference between the Overlay components and Extended Components is -
Overlay/Overrided Component
|
Extended/Inherited Components
|
1. Universally available across the WEM.
|
1.Not universally available across WEM as they are inherited for specific project.
|
2. They are copied from “/libs/foundation/components/ ” to “/apps/foundation/components/”
|
2. They are extended by using “ sling:resourceSuperType ” property
|
Example 1 : Extending the text component.
1. Create the project under apps folder. As in figure.
- Add the below properties to the component.
- Open “newtext.jsp” add the below code in it
<%--
New Text Component component.
--%><% %><%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><div style="border-width:1px;border-style:solid;border-color:black;width:100%;background:red;color:white"> Inherited text component </div>
<% %><cq:text property="text"/>
|
EXAMPLE 2 :
1. Page Component inherting the behaviour of foundation/components/page
Figure 1 : page component is using sling:resourceSuperType – foundation/components/page
2.
Figure 2 : blog component is using sling:resourceSuperType – Test/components/page
- Test/page/body.jsp
<%@ include file="/libs/foundation/global.jsp" %>
<div><cq:include script="header.jsp"/></div> <div><cq:include script="content.jsp"/></div> <div><cq:include script="footer.jsp"/></div>
|
4. Test/page/content.jsp
<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><% // TODO add you code here %>
<h1> Base content <h1>
|
5. Test/page/footer.jsp
<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><% // TODO add you code here %> This is the Footer
|
6. Test/page/header.jsp
<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><%
%>
This is Header
<cq:include path="header" resourceType="foundation/components/iparsys"/>
|
6. Test/blog/content.jsp
<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><% %>
<h1>Blog Content</h1>
|
If you have a NEW component at /apps/myproject/components/flash, it can inherit from the foundation component via sling:resourceSuperType on the new component. In that case, you have a new component in the sidekick. In your new component, you could use the same values for jcr:title, componentGroup, or you could change them to distinguish your component in the sidekick. If the title, componentGroups are the same, the sidekick can distinguish them with parenthesis around the webapp (foundation) vs (myproject). However, I have seen situations where it is impossible as an author to distinguish them.
11. “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.
If you build web applications with Apache Sling or CRX Quickstart you might want to extend the core functionality, e.g. for starting a background process or connecting to some legacy system.
Fortunately, this is easy as 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. In this post I will walk you through the complete process. All code and configuration is attached to this post as a deployable bundle.
One disclaimer before we start, though: if have no clue at all about OSGi you should get some basic understanding from TheServerSide, or JavaWorld (the TSS article uses the terms "repository" and "node" in a generic way, not for JCR repositories and nodes as in this post).
Once you have a basic notion what a bundle is you're good to go.
Create 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;
public interface HelloService {
public String sayHello();
public String getReversedNodePath(Node
node) throws RepositoryException;
public String getRepository();
public void log(String text);
}
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{
private SlingRepository repository;
private static final Logger log =
LoggerFactory.getLogger(HelloServiceImpl.class);
public String sayHello() {
return ("Hello World!!");
}
public String getReversedNodePath(Node node)
throws RepositoryException {
return new
StringBuffer(node.getPath()).reverse().
toString();
}
public String getRepository() {
return
repository.getDescriptor(
SlingRepository.REP_NAME_DESC);
}
protected void bindRepository(SlingRepository
repository) {
this.repository = repository;
}
protected void unbindRepository(SlingRepository
repository) {
this.repository = null;
}
public void log(String text) {
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-Name: HelloWorld Plug-in
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:
<?xml version="1.0" encoding="UTF-8"?>
<components
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
<scr:component enabled="true" immediate="true"
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"
value="Say hello sample service"/>
<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).
The Sling console
The Sling console is a web application that comes with Sling and CRX Quickstart that allows you (among other things) to deploy new bundles. It is located at http://localhost:7402/system/console/list. Bundle details can be seen by clicking on a bundle name. This reveals e.g. the bundle version and the exported packages. For example, note that the org.slf4j package imported by HelloServiceImpl is exported by a bundle named "Sling-OSGi LogService Implementation".
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".
Accessing the service
In order to be useful the deployed OSGi service should be accessible from esp templates. That works like this:
<%
var service =
sling.getService(
Packages.com.day.samples.HelloService);
%>
<%= service.sayHallo() %>
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.
To learn more have a look at the sample applications that come with Sling. Find them in samples/simple-demo and samples/webloader. The webloader demo implements a background service that fills the repository with publicly available files.
Difference between Parbase and parsys?
Parbase
|
Parsys
|
Parbase is a key component as it allows components to inherit attributes from other components, similar to subclasses in object oriented languages such as Java, C++, and so on. For example, when you open the/libs/foundation/components/text node in the CRXDE Lite, you see that it has a property namedsling:resourceSuperType, which references the parbase component. The parbase here defines tree scripts to render images, titles, and so on, so that all components subclassed from this parbase can use this script.
Users do not need access to the parbase.
|
The paragraph system (parsys) is a compound component that allows authors to add components of different types to a page and contains all other paragraph components. Each paragraph type is represented as a component. The paragraph system itself is also a component, which contains the other paragraph components.
|
Difference between Parsys and Iparsys?
Parsys is a placeholder where we can drag and drop the component and the script (or content) inside the component will be rendered to that place.
Iparsys or Inherited Paragraph System is similar to parsys except it allows you to inherit the created paragraphs from the parent.
What is REST?
REST is nothing but using the current features of the “Web” in a simple and effective way. If you see, some of the amazing features of the Web are:
- 40 years old matured and widely accepted HTTP protocol.
- Standard and Unified methods like
POST
, GET
, PUT
and DELETE
.
- Stateless nature of HTTP protocol.
- Easy to use URI (Uniform resource identifier) format to locate any web resource.
REST leverages these amazing features of the web with some constraints.
Let’s define REST in official words, REST is an architectural style built on certain principles using the current “Web” fundamentals.
There are 5 basic fundamentals of web which are leveraged to create REST services.
Principle 1: Everything is a Resource
Internet is all about getting data. This data can be in a format of web page, image, video, file, etc. It can also be a dynamic output like get customers who are newly subscribed. The first important point in REST is start thinking in terms of resources rather than physical files.
Below are some examples of resources with URI:
So the first thing is, visualize everything as resource.
Principle 2: Every Resource is Identified by a Unique Identifier
The old web identifies all resources by a URI. For instance, if you want to display customer with their orders, you can use www.questpond.com/DisplayCustomerandOrder.aspx. In REST, we add one more constraint to the current URI, every URI should uniquely represent every RESOURCE data.
For instance, you can see the below unique URI format for customer and orders fetched.
Customer data
|
URI
|
Get Customer details with name “Shiv”
|
http://www.questpond.com/Customer/Shiv
|
Get Customer details with name “Raju”
|
http://www.questpond.com/Customer/Raju
|
Get orders placed by customer "Shiv"
|
http://www.questpond.com/Customer/Shiv/Orders
|
Get orders placed by customer “Raju”
|
http://www.questpond.com/Customer/Raju/Orders
|
Principle 3: Use Simple and Uniform Interfaces
Simplification is the way to success and that’s what exactly the goal of uniform interfaces is. When external clients are interacting with web resources, they expect simplified interfaces.
For instance, let’s say you have exposed customer and orders data / resource on the web. Let’s assume below are the methods / function names by which external clients can communicate to your application.
AddCustomer
InsertOrders
SelectCustomer
getOrders
DeleteCustomer
RemoveOrders
UpdateCustomers
Do the above method names look inconsistent and difficult to remember? Yes they do. Now what REST says is keep your interfaces uniform and simple. This can be achieved by using the uniform methods of HTTP protocol and combining the same with your resource operation.
Below is the list of HTTP methods for getting, creating, updating and deleting a resource on the web.
Methods
|
Description
|
GET
|
Get a resource
|
PUT
|
Create and Update a resource
|
DELETE
|
Deletes a resource
|
POST
|
Submits data the resource
|
Now by combining the standard HTTP methods and your resource names, you can have uniform interfaces and thus leading to simplified communication. You can see from the below table how we have created uniform REST URL using standard HTTP methods.
Normal Method names
|
HTTP methods
|
REST Uniform URL
|
AddCustomer
|
PUT
|
Customer/Shiv
|
InsertOrders
|
PUT
|
Orders/1001
|
SelectCustomer
|
GET
|
Customer/Shiv
|
getOrders
|
GET
|
Customer/Shiv/Orders
|
DeleteCustomer
|
DELETE
|
Customer/Shiv
|
RemoveOrders
|
DELETE
|
Customer/Shiv
|
UpdateCustomers
|
PUT
|
Customer/Shiv
|
Principle 4: Communication is Done by Representation
When you send any request or you get any response, you are actually sending representations.
For example, let’s say you want to create a new customer
record, you would send some kind of representation as shown below using HTTP PUT
.
<Customer>
<Name>Questpond.com</Name>
<Address>Mulund Mumbai</Address>
</Customer>
Once the resource is created, you would get a representation as shown below. The below representation says the customer questpond has been successfully created and if you wish, you can use “http://www.questpond.com/Customer/Questpond/Orders” defined in the “Next” tag to create orders for the “questpond
” customer
.
<Customer>
<Name>Questpond.com</Name>
<Next>http://www.questpond.com/Customer/Questpond/Orders</Next>
</Customer>
The above representation was in XML format. If you wish, you can also send and receive other presentations like JSON. For instance, below is a simple JSON snippet for creating a new customer record with name and address.
{Customer :{ Name:'Questpond.com', Address:'Mulund Mumbai'}}
Principle 5: Be Stateless
Every request should be an independent request so that we can scale up using load balancing techniques. Independent request means with the data also send the state of the request so that the server can carry forward the same from that level to the next level.
For instance, below are two simple representations, the first representation is sent for logging in.
<Login>
<Name>Questpond.com</Name>
<Password>sdkj#43445</Password>
</Login>
If you are logged in successfully you receive the below representation.
<Login>
<Success>true</Success>
</Login>
If you want to search for customer
, you would send him the below representation stating that you are in a state of successful logging in and would like to search all customer
s.
<Customer>
<Filter>All</Filter>
<Success>true</Success>
</Customer>
In other words, every request is independent and the server does not need to remember your previous request and states.
1) What is CQ5? What is a Content Management System?
CQ5 is a java based content management system from adobe, previously Day CQ5.
1) It is based on a content repository(i.e it uses a content repository to store the content of a website) and use JCR(java content repository) specification to access the content repository.
2) It uses RESTful Apache Sling framework to map request url to the corresponding node in content repository
3) it uses powerful OSGi framework internally to allow modular application development. It means individual pieces of your application(called bundles in terms of OSGi) can be independently started and stopped. CQ5 uses Apache Felix as the OSGi container. Therefore different parts of cq5 can be independently started and stopped.
Coming to why a content management system is required? Some websites are very dynamic in nature, content needs to be updated frequently, so it is easier to manage the content of such websites using a CMS.