Before this commit,
log4j logfile name was hardcoded to puppetdb. This broke logrotation
which used @name and so was pe-puppetdb on pe installations.
(maint) Lift variables out of conditionals

These variables (initscriptname, log_dir) are always composed of a string
followed by the @name variable, so it makes little sense to repeat their
definition in each branch of the if @pe conditional. This commit moves them
below the conditional, where @name is defined and they can be safely defined.
(maint) Make the use of @log_dir consistent

Previously, /var/log/@name, @log_dir, and @log_dir || /var/log/puppetdb were
all in use. As @log_dir is always defined when the templates get evaluated,
they don't need a default case to fall back to. This commit makes the use of
@log_dir and @log_dir/@name consistent in the templates.
Merge pull request #683 from haus/ticket/1.5.x/logging_and_more_logging

logging fixes
Log errors when invoking a subcommand

The main dispatcher scans available namespaces and dispatches to the
specified "-main" function. For example, running the "services"
subcommand would trigger loading of the "-main" function in the
"com.puppetlabs.puppetdb.cli.services" namespace.

However, if there was an error during the attempt to "require" that
namespace, it wouldn't be logged properly. This commit adds the
"require" step to the existing try/catch block.
Fix broken require
Merge branch 'namespace-fix' into 1.5.x

* namespace-fix:
  Fix broken require
  Log errors when invoking a subcommand
Validate facts order-by against strings
Validate nodes order-by against strings
Merge pull request #686 from shakedown/bug/1.5.x/paging-order-by-strings

Bug: validate order-by against strings for facts/fact-names/nodes
Ensure parameters that contain maps are sorted (recursively)

Sometimes parameters contain hashes, these hashes may be randomly ordered by
Ruby before they hit PuppetDB. This patch ensures those structures are sorted
recursively first to ensure the duplicates that are just suffering from
different ordering are matched properly.

This patch achieves this by provided a new function 'sort-nested-maps' into
utils that is utilised by a set of functions now provide for generically
preparing strings for hashing and an all in one that uses the string
function and hashes it: 'generic-identity-hash' and 'generic-identity-string'.

Now all the -hash and -string functions use those methodologies we have
hopefully centralised our logic and cleaned it up at the same time. We also
have good tests around these generic methods to prove (at least somewhat)
ordering is preserved so we can avoid this issue going forward.

I've also added tests to the other hash functions so we can preserve their
individual hash generation methodologies in unit test form.

Signed-off-by: Ken Barber <ken@bob.sh>
Add reverse sorted PersistentTreeMap in tests for generic-identity-*

This includes a comparison test using a reverse ordered PersistentTreeMap
compared to a PersistentHashMap.

Signed-off-by: Ken Barber <ken@bob.sh>