diff --git a/src/weller/config.clj b/src/weller/config.clj index 1cc82b0..35af326 100644 --- a/src/weller/config.clj +++ b/src/weller/config.clj @@ -89,4 +89,11 @@ ;; authenticate on Alfresco and store ticket (swap! config assoc :alfresco (assoc (:alfresco @config) :ticket (get-in (auth/create-ticket (get-in @config [:alfresco :user]) (get-in @config [:alfresco :password])) [:body :entry]))) - (t/log! :trace @config)) \ No newline at end of file + (t/log! :trace @config)) + +(defn ticket + ;; TODO + ;; - validate ticket + ;; - if expired request e new one + [] + (get-in @config [:alfresco :ticket])) \ No newline at end of file diff --git a/src/weller/predicates_extra.clj b/src/weller/predicates_extra.clj new file mode 100644 index 0000000..2634d1f --- /dev/null +++ b/src/weller/predicates_extra.clj @@ -0,0 +1,13 @@ +(ns weller.predicates-extra + (:require [cral.model.core :as model] + [cral.api.core.nodes :as nodes] + [weller.config :as c])) + +(defn in-path? + [path] + (partial + #(= (get-in + (->> (model/map->GetNodeQueryParams {:include "path"}) + (nodes/get-node (c/ticket) (get-in % [:data :resource :id]))) + [:body :entry :path :name]) + path))) \ No newline at end of file diff --git a/test/weller/filters_test.clj b/test/weller/filters_test.clj index 01fd612..6aefb83 100644 --- a/test/weller/filters_test.clj +++ b/test/weller/filters_test.clj @@ -21,6 +21,7 @@ [weller.events :as events] [weller.pipe :as pipe] [weller.predicates :as pred] + [weller.predicates-extra :as xpred] [weller.test-utils :as tu]) (:import (clojure.lang PersistentVector) (java.util UUID))) @@ -152,4 +153,11 @@ pipe (pipe/make-pipe (pred/property-value? cm/prop-publisher value) #(deliver result %))] (tu/change-property cm/prop-publisher value) (is (= (get-in @result [:properties cm/prop-publisher]) value)) + (component/stop pipe))) + +(deftest in-path-test + (let [result (promise) + pipe (pipe/make-pipe (every-pred (pred/event? events/node-created) (xpred/in-path? "/Company Home/Guest Home")) #(deliver result %))] + (tu/create-then-update-then-delete-node) + (println @result) (component/stop pipe))) \ No newline at end of file