Wednesday, July 31, 2013

How to get Resource?

In OSGI Service/Compoment
You can access a resource through the JcrResourceResolverFactory service:

private SlingRepository repository;

private JcrResourceResolverFactory resolverFactory;

public void myMethod() {
    Session adminSession = null;   
    try {       
         String resourcePath = "path/to/resource";       
         adminSession = repository.loginAdministrative(null);       
         ResourceResolver resourceResolver = resolverFactory.getResourceResolver(adminSession);       
         Resource res = resourceResolver.getResource(resourcePath);    
    } catch (RepositoryException e) {
        log.error("RepositoryException: " + e);   
    } finally {       
        if (adminSession != null && adminSession.isLive()) {
                adminSession = null;       

String resourcePath = "path/to/resource";
Resource res = resourceResolver.getResource(resourcePath);

Monday, July 29, 2013

What is the notation of translation site to be created? (Managing Different Language Versions of a Website)

1. In the Websites tab, in the left pane, select the site.

2. Add a new language branch to the site:

    a. Click New..

    b. In the dialog, specify the Title and the Name.

        The Name needs to have the following format:
<language-code> or <language-code>_<country-code>
        - the supported language code is lower-case, two-letter code as defined by ISO-639-1
        - the supported country code is lower-case or upper-case, two-letter code as defined by ISO 3166
Examples: en, en_US, en_us, en_GB, en_gb.

        Select the Template and click Create.   


3. In the Websites tab, in the left pane, select the site.

4. In the Tools menu, select Language Copy.


5. The Language Copy dialog opens. It displays a matrix of the language versions available for individual pages. An x in a language column means that the page is available within the language tree.


6. To copy an existing page or page tree to a specific language first select the appropriate empty cell. Then click the arrow and select the type of copy in the drop-down menu.

Type of language copy

Uses the behavior from parent pages

Cancels the copy for this page and its children

<language>+ (e.g. French+)
Copies the page and all its children from that language

<language> (e.g. French)
Copies only the page from that language


7. Click OK to close the dialog.

8. In the next dialog, click Yes to confirm the copy.

Wednesday, July 24, 2013

How to create AEM Groups package including ACLs?

Download the custom package from :
1) Install package using package manager
2) go to <host>:<port>/apps/tools/components/createPackage/run.html
3) Give your Xpath in xpath value
4) You can also add comma separate exclude path that you don't want to add to package.
5) Click on Create config package
6) Now Download the package and also be saved under /etc/packages/CQSupportTool
For example if you have to create package of all ACL to migrate from one CQ instance to another you can use xpath query for package as //element(*,rep:ACL)



Wednesday, July 10, 2013

How can we hide the CMS Console Buttons


How can we hide some of the CMS consoles / tabs (like the Site Admin, DAM Admin, Tools, Security, Workflow and Tagging) via permissions?

Answer:  Uncheck the READ permission for groups/users on the corresponding console node.


Monday, July 8, 2013

Syntax while executing Shell Script in windows

Error Type:

./ line 1: syntax error near unexpected token '$'do\r''

Or ...

./ line 1: $'\r': command not found


How to take Thread Dumps from a JVM

Step 1: Get the PID of your java process

The java JDK ships with the jps command which lists all java process ids.

You can run this command like this: jps –l

3576 crx-quickstart\app\cq-quickstart-5.6.0-standalone.jar

Step 2 : Request a Thread Dump from the JVM

In windows:

1. Install cygwin to run shell script

2. set path to the environment variable list.

3. Add following script in the <name>.sh

if [ $# -eq 0 ]; then
    echo >&2 "Usage: jstackSeries <pid> <run_user> [ <count> [ <delay> ] ]"
    echo >&2 "    Defaults: count = 10, delay = 0.5 (seconds)"
    exit 1
pid=$1          # required
user=$2         # required
count=${3:-10}  # defaults to 10 times
delay=${4:-0.5} # defaults to 0.5 seconds
while [ $count -gt 0 ]
    jstack -F $pid >jstack.$pid.$(date +%H%M%S.%N)
    sleep $delay
    count=`expr $count - 1`
    echo -n "."

          4. You can run this shell script like:

               sh  <name>.sh <Process Id of AEM> <Intervals> <No.of Threads>

              Eg:  sh  4321 10 5

              Result: It takes 5 thread dumps at an intervals of 10 sec.

Note: Running CQ on UNIX ?