Skip to content

Commit

Permalink
Merge pull request #134 from saidone75/dev
Browse files Browse the repository at this point in the history
get-shared-link
  • Loading branch information
saidone75 authored Mar 30, 2024
2 parents dc8e1f5 + 1134e4d commit 65e39d4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/cral/alfresco/core/shared_links.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@
(format "%s/shared-links" (config/get-url 'core))
ticket
{:query-params query-params}
opts)))

(defn get-shared-link
"Gets minimal information for the file with shared link identifier **shared-id**.
**Note:** No authentication is required to call this endpoint.
More info [here](https://api-explorer.alfresco.com/api-explorer/?urls.primaryName=Core%20API#/shared-links/listSharedLinks)."
([^String shared-id]
(get-shared-link shared-id nil))
([^String shared-id ^ListSharedLinksQueryParams query-params & [^PersistentHashMap opts]]
(utils/call-rest
client/get
(format "%s/shared-links/%s" (config/get-url 'core) shared-id)
nil
{:query-params query-params}
opts)))
3 changes: 3 additions & 0 deletions src/cral/alfresco/model/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@
^PersistentVector include
^PersistentVector fields])

(defrecord GetSharedLinkQueryParams
[^PersistentVector include])

;; sites
(defrecord ListSiteMembershipRequestsQueryParams
[^Integer skip-count
Expand Down
16 changes: 9 additions & 7 deletions test/cral/shared_links_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(def user "admin")
(def password "admin")

(deftest create-then-list-shared-link
(deftest create-then-list-then-get-shared-link
(let [ticket (get-in (auth/create-ticket user password) [:body :entry])
parent-id (:id (tu/get-guest-home ticket))
;; create a node
Expand All @@ -22,11 +22,13 @@
(let [create-shared-link-body (model/map->CreateSharedLinkBody {:node-id (get-in create-node-response [:body :entry :id])})
;; create a shared link
create-shared-link-response (shared-links/create-shared-link ticket create-shared-link-body)]
(= (:status create-shared-link-response) 200))
;; list shared links
(loop [list-shared-link-response (shared-links/list-shared-links ticket)]
(when-not (some #(= (get-in create-node-response [:body :entry :id]) %) (map #(get-in % [:entry :node-id]) (get-in list-shared-link-response [:body :list :entries])))
(Thread/sleep 1000)
(recur (shared-links/list-shared-links ticket))))
(= (:status create-shared-link-response) 200)
;; list shared links
(loop [list-shared-link-response (shared-links/list-shared-links ticket)]
(when-not (some #(= (get-in create-node-response [:body :entry :id]) %) (map #(get-in % [:entry :node-id]) (get-in list-shared-link-response [:body :list :entries])))
(Thread/sleep 1000)
(recur (shared-links/list-shared-links ticket))))
;; get shared link
(is (= (:status (shared-links/get-shared-link (get-in create-shared-link-response [:body :entry :id]))) 200)))
;; clean up
(is (= (:status (nodes/delete-node ticket (get-in create-node-response [:body :entry :id]))) 204))))

0 comments on commit 65e39d4

Please sign in to comment.