3 (:use clj-stacktrace.repl)
4 (:require clojure.contrib.string)
5 (:require clojure.contrib.http.agent))
8 " Replacing these characters http encoded ones
18 (clojure.contrib.string/replace-str " " "%20"
19 (clojure.contrib.string/replace-str "'" "%27"
20 (clojure.contrib.string/replace-str ";" "%3B"
21 (clojure.contrib.string/replace-str "[" "%5B"
22 (clojure.contrib.string/replace-str "@" "%40"
23 (clojure.contrib.string/replace-str "=" "%3D"
24 (clojure.contrib.string/replace-str "]" "%5D" text
29 (defn filterSpacesFromXML [text]
31 (clojure.contrib.string/replace-str "< " "<"
32 (clojure.contrib.string/replace-str " : " ":"
33 (clojure.contrib.string/replace-str " / >" " />"
34 (clojure.contrib.string/replace-str "< /" "</"
35 (clojure.contrib.string/replace-str "</ " "</"
36 (clojure.contrib.string/replace-str " / " "/"
37 (clojure.contrib.string/replace-re #"=\"\s" "=\""
38 (clojure.contrib.string/replace-re #"\s\"" "\""
39 (clojure.contrib.string/replace-str " = " "="
45 ;; set get base URL ...TODO - put in config
46 (def db-base-URL "http://localhost:8080/exist/rest/")
49 ;; set root/system dir fragment ...TODO - put in config
50 (def db-system-DIR "rootDir/system.main.system/")
52 ;; working directory lookup ...TODO - put these lookups into config
53 (defn working-dir-lookup [token]
55 ;;(println "DEBUG > 'working-dir-lookup' CALLED > ["(keyword token)"]" )
56 ( { :group "aauthentication.main.authentication/groups.aauth.groups"
57 :user "aauthentication.main.authentication/users.aauth.users"
58 :users "aauthentication.main.authentication/users.aauth.users"
59 :account "groups.main.groups"
60 :journal "groups.main.groups"
61 :entry "groups.main.groups"
62 :entries "groups.main.groups"
63 :debit "groups.main.groups"
64 :credit "groups.main.groups"
65 :bookkeeping "groups.main.groups"
71 (defn namespace-lookup
74 ;;(println "DEBUG > 'namespace-lookup' CALLED > ["token"]" )
75 ( { "group" "com/interrupt/bookkeeping/users"
76 "user" "com/interrupt/bookkeeping/users"
77 "account" "com/interrupt/bookkeeping/account"
78 "journal" "com/interrupt/bookkeeping/journal"
79 "entry" "com/interrupt/bookkeeping/journal"
80 "entries" "com/interrupt/bookkeeping/journal"
81 "debit" "com/interrupt/bookkeeping/account"
82 "credit" "com/interrupt/bookkeeping/account"
88 (defn execute-http-call [ full-URL http-method header-hash xml-content ]
90 ;; from DB, get 'token' for 'option' args & value
91 (println "DEBUG > FINAL http query[" full-URL "] > http-method[" http-method "] > header-hash[" header-hash "] > xml-content[" xml-content "]")
93 (let [agt (clojure.contrib.http.agent/http-agent
95 ;; TODO - parse results, check for i) null or ii) multiple results
101 (if (clojure.contrib.http.agent/error? agt)
102 (str "<error method='GET' query='" full-URL "' errors='" (agent-errors agt) "' />")
103 (clojure.contrib.http.agent/string agt))