3 (:import com.interrupt.bookkeeping.cc.analysis.DepthFirstAdapter)
5 (:require clojure.contrib.str-utils2)
6 (:require clojure.contrib.http.agent)
7 (:require clojure.contrib.io)
8 (:require clojure.contrib.string)
12 (:require xml_handler)
13 (:require opts_handler)
14 (:require xpath_handler)
19 (use 'clj-stacktrace.repl)
23 (clj-stacktrace.repl/pst e)))
26 (defn operate-dep-inputtype
27 [node handler_block] ;; input args ; for now we are going to load by ID
29 (let [ checks [ xml_handler option_handler xpath_handler/xpath_handler ] ]
31 (doseq [ each_check checks ]
33 (println "DEBUG > each... " each_check)
34 (each_check node handler_block)
42 (defn get-depth-adapter []
44 (proxy [DepthFirstAdapter] []
47 (caseAExitCommand4 [node]
49 (println (str "DEBUG > caseAExitCommand4: " node))
51 (proxy-super inAExitCommand4 node)
52 (proxy-super outAExitCommand4 node)
59 (caseALoginCommand3 [node]
60 (println "DEBUG > caseALoginCommand3: " node)
63 (proxy-super inALoginCommand3 node)
65 (if (not= (. node getLogin ) nil)
66 (.. node getLogin (apply this) ) )
68 (if (not= (. node getLbracket ) nil)
69 (.. node getLbracket (apply this) ) )
71 (if (not= (. node getCommandInput ) nil)
75 (.. node getCommandInput (apply this) )
78 (operate-dep-inputtype node
81 (dosync (alter com.interrupt.bookkeeping/shell conj { :logged-in-user result_seq } ))
82 (println "DEBUG > logged-in-user > " ((deref com.interrupt.bookkeeping/shell) :logged-in-user))
87 (if (not= (. node getRbracket ) nil)
88 (.. node getRbracket (apply this) ) )
90 (proxy-super outALoginCommand3 node)
95 (caseAPrintCommand6 [node]
96 (println (str "caseAPrintCommand6: " node)) )
100 (caseALoadCommand3 [node]
101 (println "DEBUG > caseALoadCommand3 [" (class (. node getCommandInput)) "]: " node)
103 (comment "replicating java calls in the 'DepthFirstAdapter.caseALoadCommand3'")
106 (proxy-super inALoadCommand3 node)
108 (if (not= (. node getLoad ) nil)
109 (.. node getLoad (apply this) ) )
111 (if (not= (. node getLbracket ) nil)
112 (.. node getLbracket (apply this) ) )
114 (if (not= (. node getCommandInput ) nil)
116 (do ;; execute 'if' block
117 (.. node getCommandInput (apply this) )
120 (if (not (contains? (deref com.interrupt.bookkeeping/shell) :logged-in-user )) ;; check if there is a 'logged-in-user'
122 ;;throw an error if no 'logged-in-user'
123 (println "ERROR - NO logged-in-user")
126 (operate-dep-inputtype node (fn [result_seq]
128 (println "loading... " result_seq)
137 (if (not= (. node getRbracket ) nil)
138 (.. node getRbracket (apply this) ) )
141 (proxy-super outALoadCommand3 node)
145 ;; TODO - 'load' based on xpath
146 ;; TODO - handle variables
147 ;; TODO - ADD command (for registering users too)
148 ;; 1. check that there's not an existing user
149 ;; 2. add corresponding default group to the new user
150 ;; 3. add to aauth.groups
151 ;; 4. add to aauth.users
152 ;; 5. add Associated Bookkeeping to Group
153 ;; TODO - finish 'print' command