spacemanager: Add missing rollback in liquibase

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Acked-by: Dmitry Litvtinsev <litvinse@fnal.gov>
Patch: http://rb.dcache.org/r/6392/
Use ajc to compile aspects

The AspectJ language is cleaner than the annotation based style. This
patch adds an invocation of the AspectJ compile to the build process.
The patch also changes EofExceptionAspect from the annotation style to
the AspectJ language.

Target: trunk
Require-notes: no
Require-book: no
Per ApplicationContext @Transactional configuration

Spring's AspectJ @Transactional implementation is limited to a singleton that
only allows one ApplicationContext to configure the aspect, thus only
supporting a single transaction manager for the entire ClassLoader.

This patch introduces a modified version of Spring's
AnnotationTransactionAspect, which instantiates the aspect for each
transactional bean. A BeanPostProcesser is used to inject the appropriate
transaction manager into the aspect instances.

With this patch we can begin to use @Transactional outside pin manager (and
have multiple pin manager services in the same dCache domain).

Target: trunk
Require-notes: no
Require-book: no
spacemanager: Use JdbcTemplate and annotation based transaction demarcation

JdbcTemplate is similar to our custom DBManager class. JdbcTemplate is however
much more feature complete. It is also much more well known. This patch replaces
DBManager with JdbcTemplate in space manager.

The patch also changes space manager to Spring's annotation based transaction
demarcation. This removes the need to pass around a Connection object between
methods. It makes it easier to ensure that all processing done for a message is
in a single transaction.

Note that I in some cases have annotated methods with @Transactional even
though they are already called from a transactional context. By default Spring
will simply let the method be part of the outer transaction. I use this for
methods that would not be correct if run outside a transactional context (eg
methods that do select for update).

The patch changes the space manager schema such that primary keys are flagged
as auto increment fields. Thus we no longer need to maintain the counter logic
ourself (the counter logic is tricky in the pressence of transactions as it
must not be rolled back in case of an aborted transaction). How this is
implemented is however database specific and the changeset thus contains some
special cases for PostgreSQL. The liquibase changelog defines rollback logic.
Upon downgrading dCache, the schema changes must be rolled back.

The patch adds unique constraint to pnfsid field of srmspacefile table. An
index on this field already existed, so making it unique does not add any extra
overhead. The column type is changed to varchar(36) to match the type used in
the rest of dCache.

Since JdbcTemplate translates all SQLException instances to a more detailed
exception hierarchy, the patch also updates lots of exception handlers to
catch the more detailed exceptions.

Target: trunk
Require-notes: yes
Require-book: no
Convert tabs to spaces.

Require-notes: no
Require-book: no
Patch: none
spacemanager: Split space manager into service layer and data access layer

Introduces a clean data access object interface, separating the space manager
into a data access layer and a service layer.

Since all JDBC related code is now in a single class, I have chosen to inline
SQL expressions. I feel this makes the code easier to read as one does not
need to lookup the expressions all the time.

Given the size of the change, it is difficult not to sneak in some minor
janitorial changes in that is touched anyway.

Target: trunk
Require-notes: no
Require-book: no
spacemanager: Retry on transient errors

Besides allowing the space manager to recover from various transient errors,
this change also enables us to use serializable transaction isolation.

Target: trunk
Require-notes: no
Require-book: no
spacemanager: Add changeset to install plpgsql

Target: trunk
Require-notes: no
Require-book: no