-- in xpath_handler, calculating i. leaf-node and ii. context-dir
[bkell-clj.git] / src / helpers.clj
blob5c155401deade1c5ef7800e50715f95c8c7893c9
1 (ns helpers) 
3 (defn url-encode 
4         " Replacing these characters http encoded ones 
5         <space>         %20
6         '                                       %27
7         ;                                       %3B
8         [                                       %5B
9         @                                       %40
10         =                                       %3D
11         ]                                       %5D "
12   [text]
13   
14   (clojure.contrib.string/replace-str " " "%20"   
15         (clojure.contrib.string/replace-str "'" "%27"   
16                 (clojure.contrib.string/replace-str ";" "%3B"   
17                         (clojure.contrib.string/replace-str "[" "%5B"   
18                                 (clojure.contrib.string/replace-str "@" "%40"   
19                                         (clojure.contrib.string/replace-str "=" "%3D"   
20                                                 (clojure.contrib.string/replace-str "]" "%5D" text 
21                                         )))))   
22   )
25 ;; set get base URL ...TODO - put in config 
26 (def db-base-URL "http://localhost:8080/exist/rest/") 
28 ;; set root/system dir fragment ...TODO - put in config 
29 (def db-system-DIR "rootDir/system.main.system/") 
31 ;; working directory lookup ...TODO - put these lookups into config 
32 (defn working-dir-lookup [token]
33    
34    (println "DEBUG > 'working-dir-lookup' CALLED > ["(keyword token)"]" )
35    
36    (  {  :group "aauthentication.main.authentication/groups.aauth.groups"
37                                  :user "aauthentication.main.authentication/users.aauth.users"
38                                  :account "groups.main.groups"
39                                  :journal "groups.main.groups"
40                                  :entry "groups.main.groups" 
41                                  :entries "groups.main.groups" 
42                                  :debit "groups.main.groups"
43                                  :credit "groups.main.groups" 
44       }
45       (keyword token)
46    )
48 (defn namespace-lookup 
49    [token]
50    
51    (println "DEBUG > 'namespace-lookup' CALLED > ["token"]" )
52    
53    (  {  "group" "com/interrupt/bookkeeping/users"
54          "user" "com/interrupt/bookkeeping/users"
55          "account"  "com/interrupt/bookkeeping/account"
56          "journal"  "com/interrupt/bookkeeping/journal"
57          "entry"  "com/interrupt/bookkeeping/journal"
58          "debit"  "com/interrupt/bookkeeping/account"
59          "credit"  "com/interrupt/bookkeeping/account" 
60       }
61       token
62    )