source: branches/new-datamodel/src/rest_interface/publish_feeds.lisp

Last change on this file was 90, checked in by lgiessmann, 15 years ago

isidorus (core): reimplemented the threading module -> all private function of hunchentoot are replaced by public functions of the package bordeaux-threads which is internally used by hunchentoot; the macors with-reader-lock and witrh-writer-lock are mostly used at the "top-layer" of all calls, e.g. RESTful-interface - with one exception the xml-im/exporter. In this module are with locks used in the main import-calls, e.g. init-isidorus, importer-xtm1.0, import-only-topics, importer, export-xtm, export-xtm-to-string and export-xtm-fragment; ajax-client: fixed a problem when creating a associaitons in the section "create topics"

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1;;+-----------------------------------------------------------------------------
2;;+  Isidorus
3;;+  (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann
4;;+
5;;+  Isidorus is freely distributable under the LGPL license.
6;;+  You can find a detailed description in trunk/docs/LGPL-LICENSE.txt.
7;;+-----------------------------------------------------------------------------
8
9
10(in-package :rest-interface)
11
12(defgeneric publish-feed (feed)
13  (:documentation "Register feed urls with hunchentoot"))
14
15(defmacro as-feed (feed)
16  `(setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
17  `(cxml:with-xml-output (cxml:make-string-sink :canonical t)
18     (atom:feed-to-elem ,feed)))
19
20(defun overview-feed ()
21  "Interface function to the corresponding Atom method"
22  (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
23  (as-feed atom:*tm-feed*))
24
25
26(defmethod publish-feed ((feed atom:feed))
27  (push 
28   (create-regex-dispatcher
29    (format nil "~a~a" (path feed) "/?$") #'overview-feed)
30   hunchentoot:*dispatch-table*)
31  (mapc #'publish-feed (atom:subfeeds feed)))
32
33(defmethod publish-feed ((feed atom:collection-feed))
34  (push 
35   (create-regex-dispatcher 
36    (format nil "~a~a" (path feed) "/?$") 
37    (lambda () 
38      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
39      (as-feed feed)))
40   hunchentoot:*dispatch-table*)
41  (mapc #'publish-feed (atom:subfeeds feed)))
42
43(defmethod publish-feed ((feed atom:fragments-feed))
44  (push 
45   (create-regex-dispatcher 
46    (format nil "~a~a" (path feed) "/?$") 
47    (lambda () 
48      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
49      (as-feed feed)))
50   hunchentoot:*dispatch-table*)
51  ;and now register the general fragments method
52  (push 
53   (create-regex-dispatcher 
54    (format nil "~a~a" (path feed) "/([0-9]+)$") 
55    (lambda (&optional unique-id) 
56      (setf (hunchentoot:content-type*) "application/x-tm+xml;version=1.0; charset=utf-8")
57      (let 
58          ((fragment 
59            (with-reader-lock
60              (d:get-fragment (parse-integer unique-id)))))
61        (if fragment
62            (exporter:export-xtm-fragment fragment :xtm-format '1.0)
63            (format nil "<t:topicMap xmlns:t=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/>")))))
64   hunchentoot:*dispatch-table*))
65
66(defmethod publish-feed ((feed snapshots-feed))
67  (push 
68   (create-regex-dispatcher 
69    (format nil "~a~a" (path feed) "/?$") 
70    (lambda () 
71      (setf (hunchentoot:content-type*) "application/atom+xml; charset=UTF-8")
72      (as-feed feed)))
73   hunchentoot:*dispatch-table*)
74  ;and now register the general snapshots method
75  (push 
76   (create-regex-dispatcher 
77    (format nil "~a~a" (path feed) "/([0-9]+)$") 
78    (lambda (&optional revision) 
79      (setf (hunchentoot:content-type*) "application/x-tm+xml;version=1.0; charset=utf-8")
80      (exporter:export-xtm-to-string 
81       :revision (parse-integer revision) 
82       :tm-id (atom:tm-id feed)
83       :xtm-format '1.0)))
84   hunchentoot:*dispatch-table*))
85
86
87
88
Note: See TracBrowser for help on using the repository browser.