SLING-4007 Prevent NPE if Session is not available. Also don't call any code which makes use
   of the ValueFactory.

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1629608 13f79535-47bb-0310-9956-ffa450edef68