diff --git a/src/liberator/graph.clj b/src/liberator/graph.clj index 6197708..7e1927f 100644 --- a/src/liberator/graph.clj +++ b/src/liberator/graph.clj @@ -22,7 +22,7 @@ (format (str "\"%s\" [id = \"%s\" %s] \n " "\"%s\" -> \"%s\" [label = \"true\", id = \"%s\"] \n" "\"%s\" -> \"%s\" [label=\"false\", id = \"%s\"]\n") - name (clean-id name) (if internal? "style=\"filled\" fillcolor=\"#CCCCCC\"" "") + name (clean-id name) (if internal? "shape=\"octagon\" style=\"filled\" fillcolor=\"#CCCCCC\"" "") name then (clean-id (str name "_" then)) name else (clean-id (str name "_" else )))) 'defaction @@ -57,6 +57,7 @@ (defn rank-handler-groups [handlers] (->> handlers (group-by (fn [[name status]] (int (/ status 100)))) + (remove #(#{4 5} (first %))) vals (map (fn [sg] (map first sg))) (map rank-same) @@ -71,6 +72,8 @@ decisions (->> nodes (filter #(= 'defdecision (first %))) (map second)) + conneg-decisions (filter #(.endsWith (name %) "available?") + decisions) handlers (->> nodes (filter #(= 'defhandler (first %))) (map (fn [[_ name status _]] [name status]))) @@ -79,16 +82,19 @@ (map second))] {:nodes nodes :decisions decisions + :conneg-decisions conneg-decisions :handlers handlers :actions actions})) (defn generate-graph-dot [] - (let [{:keys [nodes handlers actions]} (parse-source-definitions)] + (let [{:keys [nodes conneg-decisions handlers actions]} (parse-source-definitions)] + (prn conneg-decisions) (->> nodes (map to-graph) (remove nil?) (concat (rank-handler-groups handlers)) (concat (rank-same (remove #{'initialize-context} actions))) + (concat (rank-same (remove #{'initialize-context} conneg-decisions))) (apply str) (format (str "digraph{\nid=\"trace\"; size=\"1000,1000\"; page=\"1000,1000\";\n\n" "edge[fontname=\"sans-serif\"]\n" diff --git a/src/liberator/trace.svg b/src/liberator/trace.svg index 9fa3a25..ca12666 100644 --- a/src/liberator/trace.svg +++ b/src/liberator/trace.svg @@ -4,953 +4,953 @@ - - + + %3 - + + +encoding-available? + +encoding-available? + + +processable? + +processable? + + +encoding-available?->processable? + + +true + + +handle-not-acceptable + +406 +not-acceptable + + +encoding-available?->handle-not-acceptable + + +false + + +charset-available? + +charset-available? + + +charset-available?->encoding-available? + + +true + + +charset-available?->handle-not-acceptable + + +false + + +language-available? + +language-available? + + +language-available?->charset-available? + + +true + + +language-available?->handle-not-acceptable + + +false + + +media-type-available? + +media-type-available? + + +media-type-available?->language-available? + + +true + + +media-type-available?->handle-not-acceptable + + +false + + +service-available? + +service-available? + + +known-method? + +known-method? + + +service-available?->known-method? + + +true + + +handle-service-not-available + +503 +service-not-available + + +service-available?->handle-service-not-available + + +false + post! - -post! + +post! post-redirect? - -post-redirect? + +post-redirect? post!->post-redirect? - - + + patch! - -patch! + +patch! respond-with-entity? - -respond-with-entity? + +respond-with-entity? patch!->respond-with-entity? - - + + put! - -put! + +put! new? - -new? + +new? put!->new? - - + + delete! - -delete! + +delete! delete-enacted? - -delete-enacted? + +delete-enacted? delete!->delete-enacted? - - + + handle-see-other - -303 -see-other + +303 +see-other handle-multiple-representations - -300 -multiple-representations + +300 +multiple-representations handle-moved-permanently - -301 -moved-permanently + +301 +moved-permanently handle-moved-temporarily - -307 -moved-temporarily + +307 +moved-temporarily handle-not-modified - -304 -not-modified + +304 +not-modified handle-ok - -200 -ok + +200 +ok handle-no-content - -204 -no-content + +204 +no-content handle-created - -201 -created + +201 +created handle-accepted - -202 -accepted + +202 +accepted handle-options - -200 -options - - -handle-not-found - -404 -not-found - - -handle-gone - -410 -gone - - -handle-conflict - -409 -conflict - - -handle-precondition-failed - -412 -precondition-failed - - -handle-unprocessable-entity - -422 -unprocessable-entity - - -handle-not-acceptable - -406 -not-acceptable - - -handle-request-entity-too-large - -413 -request-entity-too-large - - -handle-unsupported-media-type - -415 -unsupported-media-type - - -handle-forbidden - -403 -forbidden - - -handle-unauthorized - -401 -unauthorized - - -handle-malformed - -400 -malformed - - -handle-method-not-allowed - -405 -method-not-allowed - - -handle-uri-too-long - -414 -uri-too-long - - -handle-not-implemented - -501 -not-implemented - - -handle-unknown-method - -501 -unknown-method - - -handle-service-not-available - -503 -service-not-available - - -handle-exception - -500 -exception + +200 +options multiple-representations? - -multiple-representations? + +multiple-representations? multiple-representations?->handle-multiple-representations - - -true + + +true multiple-representations?->handle-ok - - -false + + +false respond-with-entity?->handle-no-content - - -false + + +false respond-with-entity?->multiple-representations? - - -true + + +true new?->handle-created - - -true + + +true new?->respond-with-entity? - - -false + + +false post-redirect?->handle-see-other - - -true + + +true post-redirect?->new? - - -false + + +false + + +handle-not-found + +404 +not-found + + +handle-gone + +410 +gone can-post-to-missing? - -can-post-to-missing? + +can-post-to-missing? can-post-to-missing?->post! - - -true + + +true can-post-to-missing?->handle-not-found - - -false + + +false post-to-missing? - -post-to-missing? + +post-to-missing? post-to-missing?->handle-not-found - - -false + + +false post-to-missing?->can-post-to-missing? - - -true + + +true can-post-to-gone? - -can-post-to-gone? + +can-post-to-gone? can-post-to-gone?->post! - - -true + + +true can-post-to-gone?->handle-gone - - -false + + +false post-to-gone? - -post-to-gone? + +post-to-gone? post-to-gone?->handle-gone - - -false + + +false post-to-gone?->can-post-to-gone? - - -true + + +true moved-temporarily? - -moved-temporarily? + +moved-temporarily? moved-temporarily?->handle-moved-temporarily - - -true + + +true moved-temporarily?->post-to-gone? - - -false + + +false moved-permanently? - -moved-permanently? + +moved-permanently? moved-permanently?->handle-moved-permanently - - -true + + +true moved-permanently?->moved-temporarily? - - -false + + +false existed? - -existed? + +existed? existed?->post-to-missing? - - -false + + +false existed?->moved-permanently? - - -true + + +true + + +handle-conflict + +409 +conflict conflict? - -conflict? + +conflict? conflict?->put! - - -false + + +false conflict?->handle-conflict - - -true + + +true + + +handle-not-implemented + +501 +not-implemented can-put-to-missing? - -can-put-to-missing? - - -can-put-to-missing?->handle-not-implemented - - -false + +can-put-to-missing? can-put-to-missing?->conflict? - - -true + + +true + + +can-put-to-missing?->handle-not-implemented + + +false put-to-different-url? - -put-to-different-url? + +put-to-different-url? put-to-different-url?->handle-moved-permanently - - -true + + +true put-to-different-url?->can-put-to-missing? - - -false + + +false method-put? - -method-put? + +method-put? method-put?->existed? - - -false + + +false method-put?->put-to-different-url? - - -true + + +true + + +handle-precondition-failed + +412 +precondition-failed if-match-star-exists-for-missing? - -if-match-star-exists-for-missing? - - -if-match-star-exists-for-missing?->handle-precondition-failed - - -true + +if-match-star-exists-for-missing? if-match-star-exists-for-missing?->method-put? - - -false + + +false + + +if-match-star-exists-for-missing?->handle-precondition-failed + + +true if-none-match? - -if-none-match? + +if-none-match? if-none-match?->handle-not-modified - - -true + + +true if-none-match?->handle-precondition-failed - - -false + + +false put-to-existing? - -put-to-existing? + +put-to-existing? put-to-existing?->multiple-representations? - - -false + + +false put-to-existing?->conflict? - - -true + + +true post-to-existing? - -post-to-existing? + +post-to-existing? post-to-existing?->post! - - -true + + +true post-to-existing?->put-to-existing? - - -false + + +false delete-enacted?->handle-accepted - - -false + + +false delete-enacted?->respond-with-entity? - - -true + + +true method-patch? - -method-patch? + +method-patch? method-patch?->patch! - - -true + + +true method-patch?->post-to-existing? - - -false + + +false method-delete? - -method-delete? + +method-delete? method-delete?->delete! - - -true + + +true method-delete?->method-patch? - - -false + + +false modified-since? - -modified-since? + +modified-since? modified-since?->handle-not-modified - - -false + + +false modified-since?->method-delete? - - -true + + +true etag-matches-for-if-none? - -etag-matches-for-if-none? + +etag-matches-for-if-none? etag-matches-for-if-none?->if-none-match? - - -true + + +true etag-matches-for-if-none?->modified-since? - - -false + + +false unmodified-since? - -unmodified-since? + +unmodified-since? unmodified-since?->handle-precondition-failed - - -true + + +true unmodified-since?->etag-matches-for-if-none? - - -false + + +false etag-matches-for-if-match? - -etag-matches-for-if-match? + +etag-matches-for-if-match? etag-matches-for-if-match?->handle-precondition-failed - - -false + + +false etag-matches-for-if-match?->unmodified-since? - - -true + + +true exists? - -exists? + +exists? exists?->if-match-star-exists-for-missing? - - -false + + +false exists?->etag-matches-for-if-match? - - -true + + +true - -processable? - -processable? - - -processable?->handle-unprocessable-entity - - -false + +handle-unprocessable-entity + +422 +unprocessable-entity processable?->exists? - - -true - - -encoding-available? - -encoding-available? - - -encoding-available?->handle-not-acceptable - - -false - - -encoding-available?->processable? - - -true - - -charset-available? - -charset-available? - - -charset-available?->handle-not-acceptable - - -false - - -charset-available?->encoding-available? - - -true - - -language-available? - -language-available? - - -language-available?->handle-not-acceptable - - -false - - -language-available?->charset-available? - - -true - - -media-type-available? - -media-type-available? - - -media-type-available?->handle-not-acceptable - - -false + + +true - -media-type-available?->language-available? - - -true + +processable?->handle-unprocessable-entity + + +false is-options? - -is-options? + +is-options? + + +is-options?->media-type-available? + + +false is-options?->handle-options - - -true + + +true - -is-options?->media-type-available? - - -false + +handle-request-entity-too-large + +413 +request-entity-too-large valid-entity-length? - -valid-entity-length? + +valid-entity-length? + + +valid-entity-length?->is-options? + + +true valid-entity-length?->handle-request-entity-too-large - - -false + + +false - -valid-entity-length?->is-options? - - -true + +handle-unsupported-media-type + +415 +unsupported-media-type known-content-type? - -known-content-type? - - -known-content-type?->handle-unsupported-media-type - - -false + +known-content-type? known-content-type?->valid-entity-length? - - -true + + +true + + +known-content-type?->handle-unsupported-media-type + + +false valid-content-header? - -valid-content-header? + +valid-content-header? valid-content-header?->handle-not-implemented - - -false + + +false valid-content-header?->known-content-type? - - -true + + +true + + +handle-forbidden + +403 +forbidden allowed? - -allowed? + +allowed? + + +allowed?->valid-content-header? + + +true allowed?->handle-forbidden - - -false + + +false - -allowed?->valid-content-header? - - -true + +handle-unauthorized + +401 +unauthorized authorized? - -authorized? + +authorized? + + +authorized?->allowed? + + +true authorized?->handle-unauthorized - - -false + + +false - -authorized?->allowed? - - -true + +handle-malformed + +400 +malformed malformed? - -malformed? + +malformed? + + +malformed?->authorized? + + +false malformed?->handle-malformed - - -true + + +true - -malformed?->authorized? - - -false + +handle-method-not-allowed + +405 +method-not-allowed method-allowed? - -method-allowed? + +method-allowed? + + +method-allowed?->malformed? + + +true method-allowed?->handle-method-not-allowed - - -false + + +false - -method-allowed?->malformed? - - -true + +handle-uri-too-long + +414 +uri-too-long uri-too-long? - -uri-too-long? - - -uri-too-long?->handle-uri-too-long - - -true + +uri-too-long? uri-too-long?->method-allowed? - - -false + + +false - -known-method? - -known-method? + +uri-too-long?->handle-uri-too-long + + +true - -known-method?->handle-unknown-method - - -false + +handle-unknown-method + +501 +unknown-method known-method?->uri-too-long? - - -true - - -service-available? - -service-available? - - -service-available?->handle-service-not-available - - -false + + +true - -service-available?->known-method? - - -true + +known-method?->handle-unknown-method + + +false initialize-context - -initialize-context + +initialize-context initialize-context->service-available? - - + + + + +handle-exception + +500 +exception