2 (defn option_handler [node handler]
5 (if (instance? com.interrupt.bookkeeping.cc.node.AOptsCommandInput (. node getCommandInput) )
7 (println "DEBUG > OPTIONS input > token[" (.. node getCommandInput getInputOption getCommandtoken) "] > options[" (.. node getCommandInput getInputOption getCommandoption) "]")
9 ;; get token string (ie user, entry, etc) ->
10 (def token (.. node getCommandInput getInputOption getCommandtoken))
12 ;; get option args & value -> use a 'CommandOptionVisitor'
13 (def options (seq (.. node getCommandInput getInputOption getCommandoption)))
18 (if (instance? com.interrupt.bookkeeping.cc.node.AIdCommandoption input )
26 (println "Hello World >> " (.. (nth option-id 0) getIdOpt getText) " >> " (type (.. (nth option-id 0) getIdOpt getText)) )
28 (def db-id-ID ;; TODO - chain this to look for other options if 'id' is not there
30 (clojure.contrib.string/trim
32 (clojure.contrib.string/split #"-[a-z]+" (.. (nth option-id 0) ;; class 'com.interrupt.bookkeeping.cc.node.AIdCommandoption'
39 (println "DEBUG > extracted > [" token "] > [" options "] > [" db-id-ID "]")
41 ;; from HASH -> find containing folder for token
42 (def db-working-DIR (working-dir-lookup (.. token toString trim)))
44 ;; build another <my.group> to end of db-working-DIR
45 (def db-leaf (str (.. token toString trim) "." db-id-ID ) )
46 (def db-full-PARENT (str db-base-URL db-system-DIR db-working-DIR "/" db-leaf ))
48 (def db-document-NAME db-leaf)
51 (println "DEBUG > db-base-URL["db-base-URL"] > db-system-DIR["db-system-DIR"] > db-working-DIR["db-working-DIR"] > leaf["db-leaf"]")
52 (println "DEBUG > db-base-URL[" db-full-PARENT "]")
55 ;; this will find all <SPEECH> elements in the collection /db/shakespeare with "Juliet" as the <SPEAKER>
56 ;; http://localhost:8080/exist/rest/db/shakespeare?_query=//SPEECH[SPEAKER=%22JULIET%22]
58 ;; build XPATH expression to find 'token' based on option
59 ;; http://localhost:8080/exist/rest/db/two.xml?_query=
60 ;; declare default element namespace 'com/interrupt/bookkeeping/users'
61 ;; declare namespace aauth='com/interrupt/bookkeeping/cc/bkell/aauth';
62 ;; //system/aauth:aauthentication
64 ;; TODO - a check if we even need a query
65 (def db-query (str "_wrap=no&_query="
66 "declare default element namespace '"(namespace-lookup (.. token toString trim)) "';"
67 ;;"declare namespace users='com/interrupt/bookkeeping/users'; declare namespace bkell='com/interrupt/bookkeeping/cc/bkell'; declare namespace command='com/interrupt/bookkeeping/cc/bkell/command'; declare namespace interpret='com/interrupt/bookkeeping/interpret'; declare namespace aauth='com/interrupt/bookkeeping/cc/bkell/aauth'; "
69 ;; TODO - check if we need 'and' conditions
70 ;; "**/<token>[ @option='option_value' [ and @option='option_value' ] ]"
71 "//"(.. token toString trim)"[ @"
72 (. (nth (re-seq #"-[a-z]+" (.. (nth option-id 0) getIdOpt getText)) 0) substring 1) ;; TODO - put this part into a function (being re-used)
81 (helpers/parse-xml-to-hash
83 (execute-http-call (str db-full-PARENT "/" db-leaf (str "?" (url-encode db-query)))
85 {"Content-Type" "text/xml"}
94 (catch Exception e (println "EEeee.. opts_hanlder not processing"))