Skip to content

Instantly share code, notes, and snippets.

@skuro
Created April 6, 2010 11:04
Show Gist options
  • Save skuro/357476 to your computer and use it in GitHub Desktop.
Save skuro/357476 to your computer and use it in GitHub Desktop.
(ns skuro.alfresco.clojure
:import (org.alfresco.util ApplicationContextHelper ApplicationContextHelper$RunAsWork)
(org.alfresco.repo.transaction RetryingTransactionHelper RetryingTransactionHelper$RetryingTransactionCallback))
;; this is problematic: it looks like swank is launched in a separated class loader!
;; this usually results in the spring ctx to be recreated
(def ctx (. ApplicationContextHelper getApplicationContext))
(defn run-as [user work]
(. AuthenticationUtil runAs
(proxy [AuthenticationUtil$RunAsWork] []
(doWork []
(work))) user))
(defn get-root-node [store]
(let [nodeService (. ctx getBean "nodeService")]
(. nodeService getRootNode store)))
(defn in-transaction [callback]
(let [callback-impl (proxy [RetryingTransactionHelper$RetryingTransactionCallback] []
(execute []
(callback)))]
(. RetryingTransactionHelper doInTransaction callback-impl)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment