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
82 (alter com.interrupt.bookkeeping/shell conj
83 { :logged-in-user result_seq } )
84 (alter com.interrupt.bookkeeping/shell conj
85 { :previous result_seq }))
86 (println "DEBUG > logged-in-user > " ((deref com.interrupt.bookkeeping/shell) :logged-in-user))
91 (if (not= (. node getRbracket ) nil)
92 (.. node getRbracket (apply this) ) )
94 (proxy-super outALoginCommand3 node)
99 (caseAPrintCommand6 [node]
100 (println (str "caseAPrintCommand6: " node)) )
104 (caseALoadCommand3 [node]
105 (println "DEBUG > caseALoadCommand3 [" (class (. node getCommandInput)) "]: " node)
107 (comment "replicating java calls in the 'DepthFirstAdapter.caseALoadCommand3'")
110 (proxy-super inALoadCommand3 node)
112 (if (not= (. node getLoad ) nil)
113 (.. node getLoad (apply this) ) )
115 (if (not= (. node getLbracket ) nil)
116 (.. node getLbracket (apply this) ) )
118 (if (not= (. node getCommandInput ) nil)
120 (do ;; execute 'if' block
121 (.. node getCommandInput (apply this) )
124 (if (not (contains? (deref com.interrupt.bookkeeping/shell) :logged-in-user )) ;; check if there is a 'logged-in-user'
126 ;;throw an error if no 'logged-in-user'
127 (println "ERROR - NO logged-in-user")
130 (operate-dep-inputtype node (fn [result_seq]
132 (println "loading... " result_seq)
133 (dosync (alter com.interrupt.bookkeeping/shell conj
134 { :previous result_seq }))
142 (if (not= (. node getRbracket ) nil)
143 (.. node getRbracket (apply this) ) )
146 (proxy-super outALoadCommand3 node)
152 (println "DEBUG > caseStart CALLED > com.interrupt.bookkeeping/shell[" (deref com.interrupt.bookkeeping/shell) "]")
154 (proxy-super inStart node)
156 (.. node getPExpr (apply this) )
157 (.. node getEOF (apply this) )
159 (proxy-super outStart node)
163 (caseAAddCommand1 [node] ;; public void caseAAddCommand1(AAddCommand1 node)
165 (println "DEBUG > caseAAddCommand1 [" (class (. node getCommandInput)) "]: " node)
168 (proxy-super inAAddCommand1 node)
170 (if (not= (. node getAdd ) nil)
171 (.. node getAdd (apply this) ) )
173 (if (not= (. node getLbdepth1 ) nil)
174 (.. node getLbdepth1 (apply this) ) )
176 (if (not= (. node getLbdepth2 ) nil)
177 (.. node getLbdepth2 (apply this) ) )
179 (if (not= (. node getCommandInput ) nil)
180 (.. node getCommandInput (apply this) ) ;; any i) 'load' ii) direct XML or iii) variable should be in the shell's :previous
184 (if (not= (. node getRbdepth2 ) nil)
185 (.. node getRbdepth2 (apply this) ) )
187 (let [ copy (. node getIlist) ]
189 (doseq [ each_copy copy ]
192 ;; apply each element in the list
193 (. each_copy apply this)
195 ;; check if we are dealing with a 'User'
202 (if (not= (. node getRbdepth1 ) nil)
203 (.. node getRbdepth1 (apply this) ) )
207 (proxy-super outAAddCommand1 node)
211 ;; TODO - handle variables
213 ;; TODO - ADD command (for registering users too)
214 ;; 1. check that there's not an existing user
215 ;; 2. add corresponding default group to the new user
216 ;; 3. add to aauth.groups
217 ;; 4. add to aauth.users
218 ;; 5. add Associated Bookkeeping to Group
220 ;; TODO - finish 'print' command