-- converted 'add' command to NOT auto- commit
[bkell-clj.git] / src / xml_handler.clj
blobb6d30a09a8b1c92135c1513da7f01ba5e2242b97
2 (use 'helpers) 
4 (import 'java.io.ByteArrayInputStream) 
5 (require 'clojure.xml)
9 (defmulti xml_handler   (fn [input handler] 
10                           [
11                             (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput input ) 
12                               :AXmlCommandInput   ;; com.interrupt.bookkeeping.cc.node.AXmlCommandInput
13                               :Node   ;;com.interrupt.bookkeeping.cc.node.Node
14                             )
15                             :handler 
16                           ])
21 (defmethod xml_handler [:Node :handler] [node handler] 
22     
23             (println "xml_handler CALLED[:Node :handler] > AXmlCommandInput instance? > " 
24               (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput (. node getCommandInput) ))
25    
26    (try 
27       (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput (. node getCommandInput) )
28         (xml_handler (. node getCommandInput) handler)
29         (println "EEeee.. xml_hanlder not processing")
30       )
31       (catch Exception e 
32         (println "EEeee.. xml_hanlder not processing > Error Message[" (. e getMessage) "] > StackTrace[" (. e printStackTrace) "]"))
33    ) 
36 (defmethod xml_handler [:AXmlCommandInput :handler] [xinput handler]
37   
38    (if (instance? com.interrupt.bookkeeping.cc.node.AXmlCommandInput xinput )
39                         (do 
40                            
41                            (println "XML input[" xinput "]")
42                            (let [xml-string (filterSpacesFromXML (. xinput toString))] 
43                                         
44                                         (println "XML filtered[" xml-string "]")
45                                         (handler (clojure.xml/parse (ByteArrayInputStream. (.getBytes xml-string "UTF-8"))))
46                                         
47                            )
48                            
49                         )
50    )