+ public synchronized <T> T doInAdminSession(Function<Session, T> toDo) {
+ try {
+ return toDo.apply(adminSession);
+ } finally {
+ try {
+ if (adminSession.hasPendingChanges())
+ adminSession.save();
+ } catch (RepositoryException e) {
+ throw new JcrException("Cannot save admin session", e);
+ }
+ }
+ }
+