From 330f1cb56cfafd1508438139dadc7cc645262ec6 Mon Sep 17 00:00:00 2001 From: Adrian Batos-Parac Date: Fri, 27 Apr 2018 10:24:33 -0400 Subject: Fix truth assertion creation Fixes the issue where the truth dimension required the create query parameter when it did not need it. Change-Id: Ic810e81210d2087b8e48f69ae8316f9ebb963dad Issue-ID: AAI-797 Signed-off-by: abatos --- src/gallifrey/handler.clj | 27 ++++++++++++++------------- src/gallifrey/store.clj | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gallifrey/handler.clj b/src/gallifrey/handler.clj index 61bdd16..cef8f0d 100644 --- a/src/gallifrey/handler.clj +++ b/src/gallifrey/handler.clj @@ -40,14 +40,15 @@ (when (#{:put :delete} (-> ctx :request :request-method)) (-> ctx :request :params :actor empty?))) :exists? (fn [ctx] - (if-let [resource (store/get-entity @the-store type id - :t-t (parse-ts ctx :t-t) :t-k (parse-ts ctx :t-k))] - {::resource ((case type - "entity" serialize-entity - "relationship" serialize-relationship) resource)} - (when (and (= :put (-> ctx :request :request-method)) - (-> ctx :request :params :create not-empty)) - true))) + (let [put? (= :put (-> ctx :request :request-method))] + (if-let [resource (if put? + (store/get-entity @the-store type id :t-k (parse-ts ctx :t-k)) + (store/get-entity @the-store type id + :t-t (parse-ts ctx :t-t) :t-k (parse-ts ctx :t-k)))] + {::resource ((case type + "entity" serialize-entity + "relationship" serialize-relationship) resource)} + (when (and put? (-> ctx :request :params :create not-empty)) true)))) :existed? (fn [ctx] (entity-existed? type id :t-k (parse-ts ctx :t-k))) :handle-ok ::resource :can-put-to-missing? false @@ -80,11 +81,11 @@ (when-let [resource (not-empty (store/entity-history @the-store type id))] {::resource (map-vals (partial map #(-> % - (update :k-start str) - (update :k-end str) - (update :t-start str) - (update :t-end str) - compact)) resource)})) + (update :k-start str) + (update :k-end str) + (update :t-start str) + (update :t-end str) + compact)) resource)})) :handle-ok ::resource) (defresource entity-lifespan-endpoint [type id] diff --git a/src/gallifrey/store.clj b/src/gallifrey/store.clj index 4f10f7c..05ac202 100644 --- a/src/gallifrey/store.clj +++ b/src/gallifrey/store.clj @@ -1,4 +1,3 @@ - (ns gallifrey.store (:require [utilis.map :refer [compact map-keys map-vals]] [utilis.types.keyword :refer [->keyword]] -- cgit 1.2.3-korg