Tuesday, July 26, 2011

jcr:content and

these are commonly used in jsp after <cq:defineObjects/> and <sling:defineObjects/>:

  • resource
  • currentNode
  • currentPage
resource.getPath()  is the node that has sling:resourceType  (usually /foo/bar/jcr:content)

currentNode.getPath() is the node that has sling:resourceType

currentPage.getPath() is actual Page (usually, /foo/bar).

so, if you have something like:
<%
iter = queryResult.getNodes(); //returns  cq:Page nodes
while (iter.hasNext()) {
    sling.include(iter.nextNode().getPath());// resource of the script included will be jcr:content
}
%>

However, if you specify resourceType for include, 
For example,  SlingScriptHelper
with RequestDispatcherOptions.setForceResourceType()  or,  <sling:include resourceType="..."/>, the included script (handler)'s  resource is NOT jcr:content but the resource itself. (Not  /foo/bar/jcr:content,  but /foo/bar..  where included resource was /foo/bar).

Okay this is hairy.

Let's work an example. 

Client request was:

GET /x/y.html


/x/y's resourceType (handler) is /apps/a/handler.
In /apps/a/handler/handler.jsp,  you include /foo/bar (a cq:Page).  /foo/bar's resourceType is /apps/b/handler.

You include:
  1. <sling:include path="/foo/bar.html"/>
    1. then /apps/b/handler will be used.
    2. resource is /foo/bar/jcr:content
    3. currentNode is /foo/bar/jcr:content
    4. currentPage is /foo/bar
  2. <sling:include path="/foo/bar" resourceType="c/handler'/>
    1. /apps/c/handler is used
    2. resource is /foo/bar
    3. currentNode is /foo/bar
    4. currentPage is /x/y




Friday, July 15, 2011

crxde classpath

You must include /etc  because there are jars under /etc/crxde/profiles/default/libs/*

So, /etc/crxde/profiles/default/@crxde:paths = /apps, /libs, /etc/crxde

I explicitly did not include /etc because /etc/tags was huge and CRXDE could not handle it.


Here is script to install custom jars to the libs folder:

#!/bin/bash

function usage() {
    echo "installs jar files for CRXDE (/etc/crxde/profiles/default/libs) to given hosts"
    echo "usage: $0 project-home-directory hostname1 hostname2 ..."
}

function err() {
    msg="$1"
    echo "$msg"
    exit 1
}

if (( $# < 2 ))
then
    usage
    exit 1
fi

d="$1"
cred="admin:admin"
shift 1

ver="1.0-0"
bundles=(
    #LIST YOUR JARS HERE
    "$d/sub-project-1/target/sub-project-1-$ver.jar"
    "$d/sub-project-2/target/sub-project-2-$ver.jar"
    ...
)
for x in "${bundles[@]}"
do
    for host in $*
    do
        f="${x##*/}"
        echo "install $x to $host"
        curl -f -u "$cred" -T "$x" "http://$host/etc/crxde/profiles/default/libs/$f" || err "fail on crxde libs install $x -> $host"
    done
done

Monday, July 11, 2011

disabling link checker

http://dev.day.com/content/kb/home/cq5/CQ5Troubleshooting/DisableLinkChecker.html

Of course the above isn't complete.

You also need the following property:

service.special_link_patterns = .*

/etc/workflow/instances

I wanted to clean up workflow archives.

So, I moved /etc/workflow/instances to /tmp/foo. Created sling:Folder, /etc/workflow/instances. And Recursively Deleted /tmp/foo (through /crx  Content Explorer).

Problems are:
  1. There could be RUNNING or STALE workflow. You really need to remove COMPLETED workflows only.
  2. When you create new /etc/workflow/instances sling:Folder, you need jcr:mixinTypes = ["rep:AccessControllable"]
  3. and, set sling:resourceType = cq/workflow/components/instances

There is http://dev.day.com/content/kb/home/cq5/CQ5SystemAdministration/howtopurgewf.html

But use it with caution. It can kill the instance.