Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more Bespin.* refactoring and cleanup

  • Loading branch information...
commit 807d1796fb73e811e9e70c8ff7ad244fe7603dd8 1 parent 09621bd
Dion Almaer authored shoe committed
Showing with 28,773 additions and 0 deletions.
  1. +8 −0 .hgignore
  2. +470 −0 LICENSE.txt
  3. +177 −0 backend/java/backend.iml
  4. +266 −0 backend/java/backend.ipr
  5. +147 −0 backend/java/src/com/mozilla/bespin/BaseServlet.java
  6. +48 −0 backend/java/src/com/mozilla/bespin/Controller.java
  7. +87 −0 backend/java/src/com/mozilla/bespin/Database.java
  8. +18 −0 backend/java/src/com/mozilla/bespin/EditMode.java
  9. +64 −0 backend/java/src/com/mozilla/bespin/EditSession.java
  10. +111 −0 backend/java/src/com/mozilla/bespin/FileSystem.java
  11. +88 −0 backend/java/src/com/mozilla/bespin/RequestContext.java
  12. +7 −0 backend/java/src/com/mozilla/bespin/RequiresLogin.java
  13. +120 −0 backend/java/src/com/mozilla/bespin/SessionTracker.java
  14. +26 −0 backend/java/src/com/mozilla/bespin/UserSession.java
  15. +16 −0 backend/java/src/com/mozilla/bespin/auth/Authenticator.java
  16. +20 −0 backend/java/src/com/mozilla/bespin/auth/NoPasswordNeededAuth.java
  17. +174 −0 backend/java/src/com/mozilla/bespin/auth/OpenIDAuth.java
  18. +93 −0 backend/java/src/com/mozilla/bespin/controllers/BespinController.java
  19. +101 −0 backend/java/src/com/mozilla/bespin/controllers/Edit.java
  20. +201 −0 backend/java/src/com/mozilla/bespin/controllers/File.java
  21. +105 −0 backend/java/src/com/mozilla/bespin/controllers/Register.java
  22. +51 −0 backend/java/src/com/mozilla/bespin/controllers/Settings.java
  23. +37 −0 backend/java/tests/com/mozilla/bespin/db/TestSQLite.java
  24. BIN  backend/java/web/WEB-INF/lib/commons-codec-1.3.jar
  25. BIN  backend/java/web/WEB-INF/lib/commons-httpclient-3.0.1.jar
  26. BIN  backend/java/web/WEB-INF/lib/commons-io-1.4.jar
  27. BIN  backend/java/web/WEB-INF/lib/commons-lang-2.4.jar
  28. BIN  backend/java/web/WEB-INF/lib/commons-logging-1.03.jar
  29. BIN  backend/java/web/WEB-INF/lib/htmlparser.jar
  30. BIN  backend/java/web/WEB-INF/lib/icu4j_3_4_1.jar
  31. BIN  backend/java/web/WEB-INF/lib/java-openid-sxip-0.9.4.jar
  32. BIN  backend/java/web/WEB-INF/lib/json_simple.jar
  33. BIN  backend/java/web/WEB-INF/lib/jug-1.1.jar
  34. BIN  backend/java/web/WEB-INF/lib/openxri-client.jar
  35. BIN  backend/java/web/WEB-INF/lib/openxri-syntax.jar
  36. BIN  backend/java/web/WEB-INF/lib/sqlitejdbc-v054.jar
  37. BIN  backend/java/web/WEB-INF/lib/xmlsec-1.1.jar
  38. +26 −0 backend/java/web/WEB-INF/web.xml
  39. +12 −0 backend/java/web/index.jsp
  40. +78 −0 backend/python/README.txt
  41. +29 −0 backend/python/bespin/__init__.py
  42. +47 −0 backend/python/bespin/backend.py
  43. +99 −0 backend/python/bespin/config.py
  44. +333 −0 backend/python/bespin/controllers.py
  45. +111 −0 backend/python/bespin/framework.py
  46. +605 −0 backend/python/bespin/model.py
  47. +29 −0 backend/python/bespin/template/example.js
  48. +1 −0  backend/python/bespin/template/readme.txt
  49. +29 −0 backend/python/bespin/tests/__init__.py
  50. BIN  backend/python/bespin/tests/other_import.tgz
  51. +620 −0 backend/python/bespin/tests/test_files.py
  52. +82 −0 backend/python/bespin/tests/test_settings.py
  53. +159 −0 backend/python/bespin/tests/test_users.py
  54. BIN  backend/python/bespin/tests/ut.tgz
  55. BIN  backend/python/bespin/tests/ut.zip
  56. +45 −0 backend/python/bespin/tests/util.py
  57. 0  backend/python/bespin/usertemplate/commands/yourcommands.js
  58. 0  backend/python/bespin/usertemplate/config.js
  59. 0  backend/python/bespin/usertemplate/scratchpad/README
  60. +1,224 −0 backend/python/bootstrap.py
  61. +75 −0 backend/python/pavement.py
  62. +9 −0 backend/python/requirements.txt
  63. +111 −0 bespin.iml
  64. +522 −0 bespin.ipr
  65. +318 −0 frontend/css/dashboard.css
  66. +356 −0 frontend/css/editor.css
  67. +150 −0 frontend/css/index.css
  68. +73 −0 frontend/dashboard.html
  69. +199 −0 frontend/editor.html
  70. BIN  frontend/images/collab_categorybar_bg.gif
  71. BIN  frontend/images/collab_hdr_bg.gif
  72. BIN  frontend/images/collab_icn_user.png
  73. BIN  frontend/images/collab_pane_bg.png
  74. BIN  frontend/images/collab_user_bg.gif
  75. BIN  frontend/images/dash_column_hdr.gif
  76. BIN  frontend/images/dash_entry_staticgraph_01.png
  77. BIN  frontend/images/dash_entry_staticgraph_02.png
  78. BIN  frontend/images/dash_icn_more.png
  79. BIN  frontend/images/dash_proj_bg_off.gif
  80. BIN  frontend/images/dash_proj_bg_on.gif
  81. BIN  frontend/images/files_hdr_off.gif
  82. BIN  frontend/images/files_icn_file.png
  83. BIN  frontend/images/files_icn_folder.png
  84. BIN  frontend/images/files_icn_projectdropdown.png
  85. BIN  frontend/images/files_pane_bg.png
  86. BIN  frontend/images/files_quickfind_hdr.gif
  87. BIN  frontend/images/footer_bg.png
  88. BIN  frontend/images/icn_browser_div.png
  89. BIN  frontend/images/icn_browser_ff.png
  90. BIN  frontend/images/icn_browser_ie.png
  91. BIN  frontend/images/icn_browser_opera.png
  92. BIN  frontend/images/icn_browser_safari.png
  93. BIN  frontend/images/icn_browser_w3c.png
  94. BIN  frontend/images/icn_collab_dim.png
  95. BIN  frontend/images/icn_collab_off.png
  96. BIN  frontend/images/icn_collab_on.png
  97. BIN  frontend/images/icn_collab_watching.png
  98. BIN  frontend/images/icn_command.png
  99. BIN  frontend/images/icn_command_on.png
  100. BIN  frontend/images/icn_copy.png
  101. BIN  frontend/images/icn_copy_on.png
  102. BIN  frontend/images/icn_cut.png
  103. BIN  frontend/images/icn_cut_on.png
  104. BIN  frontend/images/icn_error.png
  105. BIN  frontend/images/icn_error_on.png
  106. BIN  frontend/images/icn_files_off.png
  107. BIN  frontend/images/icn_files_on.png
  108. BIN  frontend/images/icn_findincode.png
  109. BIN  frontend/images/icn_findincode_on.png
  110. BIN  frontend/images/icn_fontsize.png
  111. BIN  frontend/images/icn_fontsize_on.png
  112. BIN  frontend/images/icn_graphs_off.png
  113. BIN  frontend/images/icn_graphs_on.png
  114. BIN  frontend/images/icn_history.png
  115. BIN  frontend/images/icn_history_on.png
  116. BIN  frontend/images/icn_paste.png
  117. BIN  frontend/images/icn_paste_on.png
  118. BIN  frontend/images/icn_preview.png
  119. BIN  frontend/images/icn_preview_on.png
  120. BIN  frontend/images/icn_redo.png
  121. BIN  frontend/images/icn_redo_on.png
  122. BIN  frontend/images/icn_target_off.png
  123. BIN  frontend/images/icn_target_on.png
  124. BIN  frontend/images/icn_undo.png
  125. BIN  frontend/images/icn_undo_on.png
  126. BIN  frontend/images/info_popup.png
  127. BIN  frontend/images/logo.png
  128. BIN  frontend/images/quick_find_background.png
  129. BIN  frontend/images/search_background.png
  130. BIN  frontend/images/splash_btn_begin.gif
  131. BIN  frontend/images/splash_btn_editnow.gif
  132. BIN  frontend/images/splash_btn_login.gif
  133. BIN  frontend/images/splash_editnow_bg.gif
  134. BIN  frontend/images/splash_editnow_input.png
  135. BIN  frontend/images/splash_inputs.png
  136. BIN  frontend/images/splash_logo copy.jpg
  137. BIN  frontend/images/splash_logo.jpg
  138. BIN  frontend/images/splash_logo_bg.jpg
  139. BIN  frontend/images/splash_lowertoolbar_bg.png
  140. BIN  frontend/images/splash_toolbar_bg.png
  141. BIN  frontend/images/targ-browser_bg.png
  142. BIN  frontend/images/team_mock.png
  143. BIN  frontend/images/toolbar_main_bg.gif
  144. BIN  frontend/images/toolbar_sub_bg.png
  145. BIN  frontend/images/zebra_files.png
  146. +133 −0 frontend/index.html
  147. +35 −0 frontend/js/bespin.js
  148. +125 −0 frontend/js/bootstrap.js
  149. +216 −0 frontend/js/client/dashboard.js
  150. +269 −0 frontend/js/client/dashboard_components.js
  151. +103 −0 frontend/js/client/filesystem.js
  152. +252 −0 frontend/js/client/server.js
  153. +189 −0 frontend/js/client/session.js
  154. +447 −0 frontend/js/client/settings.js
  155. +66 −0 frontend/js/client/status.js
  156. +416 −0 frontend/js/commandline/commandline.js
  157. +77 −0 frontend/js/commandline/dashboardcommands.js
  158. +509 −0 frontend/js/commandline/defaultcommands.js
  159. +555 −0 frontend/js/editor/actions.js
  160. +117 −0 frontend/js/editor/clipboard.js
  161. +1,221 −0 frontend/js/editor/editor.js
  162. +311 −0 frontend/js/editor/model.js
  163. +149 −0 frontend/js/editor/syntaxhighlighter.js
  164. +170 −0 frontend/js/editor/themes.js
  165. +215 −0 frontend/js/editor/toolbar.js
  166. +89 −0 frontend/js/editor/undo.js
  167. +145 −0 frontend/js/events.js
  168. +152 −0 frontend/js/external/cookiejar-0.4.js
  169. +185 −0 frontend/js/external/dp.SyntaxHighlighter/SyntaxHighlighter.css
  170. +32 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushCSharp.js
  171. +73 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushCpp.js
  172. +67 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushCss.js
  173. +34 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushDelphi.js
  174. +25 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushJScript.js
  175. +28 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushJava.js
  176. +60 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushPhp.js
  177. +30 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushPython.js
  178. +28 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushRuby.js
  179. +42 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushSql.js
  180. +29 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushVb.js
  181. +91 −0 frontend/js/external/dp.SyntaxHighlighter/shBrushXml.js
  182. +747 −0 frontend/js/external/dp.SyntaxHighlighter/shCore.js
  183. +276 −0 frontend/js/external/gears_db.js
  184. +475 −0 frontend/js/external/json2.js
  185. +759 −0 frontend/js/external/jstraits.js
  186. +4,320 −0 frontend/js/external/prototype-1.6.0.3.js
  187. +136 −0 frontend/js/external/scriptaculous-1.8.2/builder.js
  188. +965 −0 frontend/js/external/scriptaculous-1.8.2/controls.js
  189. +975 −0 frontend/js/external/scriptaculous-1.8.2/dragdrop.js
  190. +1,130 −0 frontend/js/external/scriptaculous-1.8.2/effects.js
  191. +60 −0 frontend/js/external/scriptaculous-1.8.2/scriptaculous.js
  192. +275 −0 frontend/js/external/scriptaculous-1.8.2/slider.js
  193. +55 −0 frontend/js/external/scriptaculous-1.8.2/sound.js
  194. +568 −0 frontend/js/external/scriptaculous-1.8.2/unittest.js
  195. +72 −0 frontend/js/th/borders.js
  196. +859 −0 frontend/js/th/components.js
  197. +23 −0 frontend/js/th/docs.txt
  198. +442 −0 frontend/js/th/gtk.js
  199. +53 −0 frontend/js/th/models.js
  200. +141 −0 frontend/js/th/traits.js
  201. +100 −0 frontend/js/util/keys.js
  202. +65 −0 frontend/js/util/navigate.js
  203. +56 −0 frontend/js/util/path.js
  204. +45 −0 frontend/js/util/textselection.js
  205. +61 −0 frontend/js/util/tokenobject.js
  206. +51 −0 frontend/js/util/urlbar.js
  207. 0  frontend/layout/test.layout
  208. +26 −0 frontend/tests/syntaxhighlighter/testhtml.html
  209. +29 −0 frontend/tests/syntaxhighlighter/testjs.html
  210. +27 −0 frontend/tests/syntaxhighlighter/testoneline.html
  211. +28 −0 frontend/tests/util/test_eval.html
  212. +30 −0 frontend/tests/util/test_path.html
  213. +26 −0 frontend/tests/util/test_selection.html
  214. +48 −0 frontend/tests/util/test_tokenobject.html
  215. BIN  mocks/Bespin.Dashboard_Entry.png
  216. BIN  mocks/Bespin.Dashboard_Project.png
  217. BIN  mocks/Bespin.Editor_01.png
  218. BIN  mocks/Bespin.Editor_Collaboration_01b.png
  219. BIN  mocks/Bespin.Editor_Files_01b.png
  220. BIN  mocks/Bespin.Editor_TargBrowsers_01.png
  221. BIN  mocks/Bespin.landing_0.1e.png
  222. BIN  mocks/Landing and Dashboard Concepts.pdf
  223. +194 −0 pavement.py
  224. +17 −0 research/fraction_canvas_test.html
  225. +338 −0 research/gtk_test.html
  226. +46 −0 research/syntaxhighlighting/taxsin/class.js
  227. +282 −0 research/syntaxhighlighting/taxsin/config/css.vim
  228. +292 −0 research/syntaxhighlighting/taxsin/config/html.vim
  229. +137 −0 research/syntaxhighlighting/taxsin/config/javascript.vim
  230. +32 −0 research/syntaxhighlighting/taxsin/configloader.js
  231. +50 −0 research/syntaxhighlighting/taxsin/driver.js
  232. BIN  slices/collab_categorybar_div.gif
  233. BIN  slices/collab_categorybar_off.gif
  234. BIN  slices/collab_categorybar_on.gif
  235. BIN  slices/collab_hdr_bg.png
  236. BIN  slices/collab_icn_collapse.png
  237. BIN  slices/collab_icn_expand.png
  238. BIN  slices/collab_icn_user.png
  239. BIN  slices/collab_pane_bg.png
  240. BIN  slices/collab_user_bg.gif
  241. BIN  slices/dash_column_hdr.gif
  242. BIN  slices/dash_entry_staticgraph_01.png
  243. BIN  slices/dash_entry_staticgraph_02.png
  244. BIN  slices/dash_icn_more.png
  245. BIN  slices/dash_proj_bg_off.gif
  246. BIN  slices/dash_project_staticgraph_01.png
  247. BIN  slices/files_hdr_div.gif
  248. BIN  slices/files_hdr_off.gif
  249. BIN  slices/files_hdr_on.gif
  250. BIN  slices/files_icn_beingedited.png
  251. BIN  slices/files_icn_favorite.png
  252. BIN  slices/files_icn_file.png
  253. BIN  slices/files_icn_folder.png
  254. BIN  slices/files_icn_projectdropdown.png
  255. BIN  slices/files_pane_bg.png
  256. BIN  slices/files_quickfind_hdr.gif
  257. BIN  slices/icn_browser_div.png
  258. BIN  slices/icn_browser_ff.png
  259. BIN  slices/icn_browser_ie.png
  260. BIN  slices/icn_browser_opera.png
  261. BIN  slices/icn_browser_safari.png
  262. BIN  slices/icn_browser_w3c.png
  263. BIN  slices/icn_collab_off.png
  264. BIN  slices/icn_collab_on.png
  265. BIN  slices/icn_command.png
  266. BIN  slices/icn_command_on.png
  267. BIN  slices/icn_error.png
  268. BIN  slices/icn_error_on.png
  269. BIN  slices/icn_files_off.png
  270. BIN  slices/icn_files_on.png
  271. BIN  slices/icn_findincode.png
  272. BIN  slices/icn_findincode_on.png
  273. BIN  slices/icn_fontsize.png
  274. BIN  slices/icn_fontsize_on.png
  275. BIN  slices/icn_graphs_off.png
  276. BIN  slices/icn_graphs_on.png
  277. BIN  slices/icn_history.png
  278. BIN  slices/icn_history_on.png
  279. BIN  slices/icn_lower_div.png
  280. BIN  slices/icn_preview.png
  281. BIN  slices/icn_preview_on.png
  282. BIN  slices/icn_redo.png
  283. BIN  slices/icn_redo_on.png
  284. BIN  slices/icn_target_off.png
  285. BIN  slices/icn_target_on.png
  286. BIN  slices/icn_undo.png
  287. BIN  slices/icn_undo_on.png
  288. BIN  slices/icn_upper_div.png
  289. BIN  slices/info_popup.png
  290. BIN  slices/logo.png
  291. BIN  slices/splash_btn_begin.gif
  292. BIN  slices/splash_btn_editnow.gif
  293. BIN  slices/splash_btn_login.gif
  294. BIN  slices/splash_editnow_bg.gif
  295. BIN  slices/splash_logo.jpg
  296. BIN  slices/splash_logo_bg.jpg
  297. BIN  slices/splash_lowertoolbar_bg.png
  298. BIN  slices/splash_toolbar_bg.png
  299. BIN  slices/targ-browser_bg.png
  300. BIN  slices/team_mock.png
Sorry, we could not display the entire diff because too many files (305) changed.
View
8 .hgignore
@@ -0,0 +1,8 @@
+syntax: glob
+backend/python/lib
+backend/python/include
+backend/python/bin
+backend/python/devdata
+*.pyc
+backend/python/.Python
+backend/python/BespinServer.egg-info
View
470 LICENSE.txt
@@ -0,0 +1,470 @@
+ MOZILLA PUBLIC LICENSE
+ Version 1.1
+
+ ---------------
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+ Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+ Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified
+ as the Initial Developer in the Source Code notice required by Exhibit
+ A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this
+ License is not already Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus
+ any associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of, this
+ License or a future version of this License issued under Section 6.1.
+ For legal entities, "You" includes any entity which controls, is
+ controlled by, or is under common control with You. For purposes of
+ this definition, "control" means (a) the power, direct or indirect,
+ to cause the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty percent
+ (50%) of the outstanding shares or beneficial ownership of such
+ entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Code (or portions thereof) with or without Modifications, and/or
+ as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or
+ selling of Original Code, to make, have made, use, practice,
+ sell, and offer for sale, and/or otherwise dispose of the
+ Original Code (or portions thereof).
+
+ (c) the licenses granted in this Section 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ Original Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: 1) for code that You delete from the Original Code; 2)
+ separate from the Original Code; or 3) for infringements caused
+ by: i) the modification of the Original Code or ii) the
+ combination of the Original Code with other software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+ hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor, to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof) either on an
+ unmodified basis, with other Modifications, as Covered Code
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: 1) Modifications made by that
+ Contributor (or portions thereof); and 2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first makes Commercial Use of
+ the Covered Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: 1) for any code that Contributor has deleted from the
+ Contributor Version; 2) separate from the Contributor Version;
+ 3) for infringements caused by: i) third party modifications of
+ Contributor Version or ii) the combination of Modifications made
+ by that Contributor with other software (except as part of the
+ Contributor Version) or other devices; or 4) under Patent Claims
+ infringed by Covered Code in the absence of Modifications made by
+ that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be
+ distributed only under the terms of this License or a future version
+ of this License released under Section 6.1, and You must include a
+ copy of this License with every copy of the Source Code You
+ distribute. You may not offer or impose any terms on any Source Code
+ version that alters or restricts the applicable version of this
+ License or the recipients' rights hereunder. However, You may include
+ an additional document offering the additional rights described in
+ Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that
+ the Modification is derived, directly or indirectly, from Original
+ Code provided by the Initial Developer and including the name of the
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+ intellectual property rights is required to exercise the rights
+ granted by such Contributor under Sections 2.1 or 2.2,
+ Contributor must include a text file with the Source Code
+ distribution titled "LEGAL" which describes the claim and the
+ party making the claim in sufficient detail that a recipient will
+ know whom to contact. If Contributor obtains such knowledge after
+ the Modification is made available as described in Section 3.2,
+ Contributor shall promptly modify the LEGAL file in all copies
+ Contributor makes available thereafter and shall take other steps
+ (such as notifying appropriate mailing lists or newsgroups)
+ reasonably calculated to inform those who received the Covered
+ Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+ interface and Contributor has knowledge of patent licenses which
+ are reasonably necessary to implement that API, Contributor must
+ also include this information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+ Section 3.4(a) above, Contributor believes that Contributor's
+ Modifications are Contributor's original creation(s) and/or
+ Contributor has sufficient rights to grant the rights conveyed by
+ this License.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code. If it is not possible to put such notice in a particular Source
+ Code file due to its structure, then You must include such notice in a
+ location (such as a relevant directory) where a user would be likely
+ to look for such a notice. If You created one or more Modification(s)
+ You may add your name as a Contributor to the notice described in
+ Exhibit A. You must also duplicate this License in any documentation
+ for the Source Code where You describe recipients' rights or ownership
+ rights relating to Covered Code. You may choose to offer, and to
+ charge a fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Code. However, You
+ may do so only on Your own behalf, and not on behalf of the Initial
+ Developer or any Contributor. You must make it absolutely clear than
+ any such warranty, support, indemnity or liability obligation is
+ offered by You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred by the
+ Initial Developer or such Contributor as a result of warranty,
+ support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of
+ the Covered Code is available under the terms of this License,
+ including a description of how and where You have fulfilled the
+ obligations of Section 3.2. The notice must be conspicuously included
+ in any notice in an Executable version, related documentation or
+ collateral in which You describe recipients' rights relating to the
+ Covered Code. You may distribute the Executable version of Covered
+ Code or ownership rights under a license of Your choice, which may
+ contain terms different from this License, provided that You are in
+ compliance with the terms of this License and that the license for the
+ Executable version does not attempt to limit or alter the recipient's
+ rights in the Source Code version from the rights set forth in this
+ License. If You distribute the Executable version under a different
+ license You must make it absolutely clear that any terms which differ
+ from this License are offered by You alone, not by the Initial
+ Developer or any Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred by
+ the Initial Developer or such Contributor as a result of any such
+ terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description
+ must be included in the LEGAL file described in Section 3.4 and must
+ be included with all distributions of the Source Code. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+ and/or new versions of the License from time to time. Each version
+ will be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), You must (a) rename Your license so that
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
+ license (except to note that your license differs from this License)
+ and (b) otherwise make it clear that Your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial
+ Developer, Original Code or Contributor in the notice described in
+ Exhibit A shall not of themselves be deemed to be modifications of
+ this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+ claim (excluding declatory judgment actions) against Initial Developer
+ or a Contributor (the Initial Developer or Contributor against whom
+ You file such action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+ infringes any patent, then any and all rights granted by such
+ Participant to You under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate prospectively,
+ unless if within 60 days after receipt of notice You either: (i)
+ agree in writing to pay Participant a mutually agreeable reasonable
+ royalty for Your past and future use of Modifications made by such
+ Participant, or (ii) withdraw Your litigation claim with respect to
+ the Contributor Version against such Participant. If within 60 days
+ of notice, a reasonable royalty and payment arrangement are not
+ mutually agreed upon in writing by the parties or the litigation claim
+ is not withdrawn, the rights granted by Participant to You under
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+ the 60 day notice period specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+ Contributor Version, directly or indirectly infringes any patent, then
+ any rights granted to You by such Participant under Sections 2.1(b)
+ and 2.2(b) are revoked effective as of the date You first made, used,
+ sold, distributed, or had made, Modifications made by that
+ Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+ alleging that such Participant's Contributor Version directly or
+ indirectly infringes any patent where such claim is resolved (such as
+ by license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
+ all end user license agreements (excluding distributors and resellers)
+ which have been validly granted by You or any distributor hereunder
+ prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+ software" and "commercial computer software documentation," as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if
+ any, provides otherwise), excluding its conflict-of-law provisions.
+ With respect to disputes in which at least one party is a citizen of,
+ or an entity chartered or registered to do business in the United
+ States of America, any litigation relating to this License shall be
+ subject to the jurisdiction of the Federal Courts of the Northern
+ District of California, with venue lying in Santa Clara County,
+ California, with the losing party responsible for costs, including
+ without limitation, court costs and reasonable attorneys' fees and
+ expenses. The application of the United Nations Convention on
+ Contracts for the International Sale of Goods is expressly excluded.
+ Any law or regulation which provides that the language of a contract
+ shall be construed against the drafter shall not apply to this
+ License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or indirectly,
+ out of its utilization of rights under this License and You agree to
+ work with Initial Developer and Contributors to distribute such
+ responsibility on an equitable basis. Nothing herein is intended or
+ shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
+ Developer permits you to utilize portions of the Covered Code under
+ Your choice of the NPL or the alternative licenses, if any, specified
+ by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the _____ license (the "[___] License"), in which case the
+ provisions of [______] License are applicable instead of those
+ above. If you wish to allow use of your version of this file only
+ under the terms of the [____] License and not to allow others to use
+ your version of this file under the MPL, indicate your decision by
+ deleting the provisions above and replace them with the notice and
+ other provisions required by the [___] License. If you do not delete
+ the provisions above, a recipient may use your version of this file
+ under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+ the notices in the Source Code files of the Original Code. You should
+ use the text of this Exhibit A rather than the text found in the
+ Original Code Source Code for Your Modifications.]
+
View
177 backend/java/backend.iml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="web" name="Web">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" optional="false" version="2.5" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/web" relative="/" />
+ </webroots>
+ <sourceRoots>
+ <root url="file://$MODULE_DIR$/src" />
+ </sourceRoots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/out/exploded/backendWeb" />
+ <setting name="EXPLODED_ENABLED" value="true" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="backend">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" name="Bespin" level="project">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/commons-codec-1.3.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/commons-httpclient-3.0.1.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/commons-logging-1.03.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/htmlparser.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="&lt;N/A&gt;" />
+ <url>jar://$APPLICATION_HOME_DIR$/lib/javaee.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/json_simple.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/openxri-client.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/openxri-syntax.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/lib" />
+ <url>jar://$MODULE_DIR$/web/WEB-INF/lib/sqlitejdbc-v054.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/htmlparser.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/openxri-client.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/sqlitejdbc-v054.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/commons-httpclient-3.0.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/commons-codec-1.3.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/json_simple.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/commons-logging-1.03.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/web/WEB-INF/lib/openxri-syntax.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$APPLICATION_HOME_DIR$/lib/javaee.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="Bespin" level="project" />
+ <orderEntryProperties />
+ </component>
+</module>
+
View
266 backend/java/backend.ipr
@@ -0,0 +1,266 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project relativePaths="true" version="4">
+ <component name="AntConfiguration">
+ <defaultAnt bundledAnt="true" />
+ </component>
+ <component name="BuildJarProjectSettings">
+ <option name="BUILD_JARS_ON_MAKE" value="false" />
+ </component>
+ <component name="CodeStyleProjectProfileManger">
+ <option name="PROJECT_PROFILE" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ </component>
+ <component name="CodeStyleSettingsManager">
+ <option name="PER_PROJECT_SETTINGS" />
+ <option name="USE_PER_PROJECT_SETTINGS" value="false" />
+ </component>
+ <component name="CompilerConfiguration">
+ <option name="DEFAULT_COMPILER" value="Javac" />
+ <option name="DEPLOY_AFTER_MAKE" value="0" />
+ <resourceExtensions>
+ <entry name=".+\.(properties|xml|html|dtd|tld)" />
+ <entry name=".+\.(gif|png|jpeg|jpg)" />
+ </resourceExtensions>
+ <wildcardResourcePatterns>
+ <entry name="?*.properties" />
+ <entry name="?*.xml" />
+ <entry name="?*.gif" />
+ <entry name="?*.png" />
+ <entry name="?*.jpeg" />
+ <entry name="?*.jpg" />
+ <entry name="?*.html" />
+ <entry name="?*.dtd" />
+ <entry name="?*.tld" />
+ </wildcardResourcePatterns>
+ </component>
+ <component name="DependenciesAnalyzeManager">
+ <option name="myForwardDirection" value="false" />
+ </component>
+ <component name="DependencyValidationManager">
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+ </component>
+ <component name="EclipseCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EclipseEmbeddedCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EntryPointsManager">
+ <entry_points version="2.0" />
+ </component>
+ <component name="IdProvider" IDEtalkID="438ECE4D116DCC048F9794685BDA4D4D" />
+ <component name="InspectionProjectProfileManager">
+ <option name="PROJECT_PROFILE" value="Project Default" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ <scopes />
+ <profiles>
+ <profile version="1.0" is_locked="false">
+ <option name="myName" value="Project Default" />
+ <option name="myLocal" value="false" />
+ </profile>
+ </profiles>
+ <list size="0" />
+ </component>
+ <component name="JavacSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="DEPRECATION" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="JavadocGenerationManager">
+ <option name="OUTPUT_DIRECTORY" />
+ <option name="OPTION_SCOPE" value="protected" />
+ <option name="OPTION_HIERARCHY" value="true" />
+ <option name="OPTION_NAVIGATOR" value="true" />
+ <option name="OPTION_INDEX" value="true" />
+ <option name="OPTION_SEPARATE_INDEX" value="true" />
+ <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
+ <option name="OPTION_DEPRECATED_LIST" value="true" />
+ <option name="OTHER_OPTIONS" value="" />
+ <option name="HEAP_SIZE" />
+ <option name="LOCALE" />
+ <option name="OPEN_IN_BROWSER" value="true" />
+ </component>
+ <component name="JikesSettings">
+ <option name="JIKES_PATH" value="" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="DEPRECATION" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="IS_EMACS_ERRORS_MODE" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="Palette2">
+ <group name="Swing">
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+ </item>
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+ <initial-values>
+ <property name="text" value="Button" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="RadioButton" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="CheckBox" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="Label" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+ <preferred-size width="-1" height="20" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+ </item>
+ </group>
+ </component>
+ <component name="ProjectFileVersion" converted="true" />
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/backend.iml" filepath="$PROJECT_DIR$/backend.iml" />
+ </modules>
+ </component>
+ <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/out" />
+ </component>
+ <component name="ResourceManagerContainer">
+ <option name="myResourceBundles">
+ <value>
+ <list size="0" />
+ </value>
+ </option>
+ </component>
+ <component name="RmicSettings">
+ <option name="IS_EANABLED" value="false" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="GENERATE_IIOP_STUBS" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="SvnBranchConfigurationManager">
+ <option name="myVersion" value="123" />
+ </component>
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="svn" />
+ </component>
+ <component name="WebServicesPlugin" addRequiredLibraries="true" />
+ <component name="libraryTable">
+ <library name="Bespin">
+ <CLASSES>
+ <root url="file://$PROJECT_DIR$/web/WEB-INF/lib" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ <jarDirectory url="file://$PROJECT_DIR$/web/WEB-INF/lib" recursive="false" />
+ </library>
+ </component>
+</project>
+
View
147 backend/java/src/com/mozilla/bespin/BaseServlet.java
@@ -0,0 +1,147 @@
+package com.mozilla.bespin;
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class BaseServlet extends HttpServlet {
+ private Map<MethodCacheKey, Method> methodCache = new HashMap<MethodCacheKey, Method>();
+
+ /**
+ * Dispatches a request to the appropriate handler method.
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ List<String> paths = new ArrayList<String>(Arrays.asList(request.getRequestURI().toLowerCase().substring(1).split("/")));
+ String controllerName = StringUtils.capitalize(paths.remove(0));
+
+ Controller controller;
+ try {
+ Class controllerClazz = Class.forName("com.mozilla.bespin.controllers." + controllerName);
+ controller = (Controller) controllerClazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ response.sendError(404, String.format("Controller \"%1$s\" not found", controllerName));
+ return;
+ } catch (Exception e) {
+ response.sendError(500, String.format("Controller \"%1$s\" could not be instantiated (%2$s)", controllerName, e.getClass() + ": " + e.getMessage()));
+ return;
+ }
+
+ // if there's a path element, check for a method with that name
+ Method method = null;
+ if (!paths.isEmpty()) {
+ method = getMethod(paths.get(0), controller.getClass());
+ if (method != null) paths.remove(0); // if the method was found, remove that path element from the list b/c it is not an arg
+ }
+
+ // if the method is still null, check for a method with the name of the HTTP method
+ if (method == null) method = getMethod(request.getMethod().toLowerCase(), controller.getClass());
+
+ // if the method is still null, check for a default method
+ if (method == null) method = getMethod("handler", controller.getClass());
+
+ if (method != null) {
+ RequestContext ctx = new RequestContext(this, request, response, paths);
+ controller.setCtx(ctx);
+ try {
+ if (method.isAnnotationPresent(RequiresLogin.class)) {
+ if (!controller.isAuthenticated()) {
+ response.sendError(401, "You're not logged in, and this request requires you to be");
+ return;
+ }
+ }
+
+ // if there are any parameters, it'll be for a single RequestContext instance
+ if (method.getParameterTypes().length != 0) {
+ method.invoke(controller, ctx);
+ } else {
+ method.invoke(controller);
+ }
+ } catch (Exception e) {
+ response.sendError(500, String.format("Error invoking method for request"));
+ return;
+ }
+ } else {
+ response.sendError(400, String.format("Couldn't map request \"%1$s\" to a controller/method", request.getRequestURI()));
+ }
+ }
+
+ private Method getMethod(String methodName, Class<? extends Object> controllerClass) {
+ MethodCacheKey key = new MethodCacheKey(controllerClass, methodName);
+ Method m = methodCache.get(key);
+ if (m != null) return m;
+
+ m = getMethodReflectively(methodName, controllerClass);
+ if (m != null) methodCache.put(key, m);
+
+ return m;
+ }
+
+ private Method getMethodReflectively(String method, Class clazz) {
+ try {
+ return clazz.getMethod(method);
+ } catch (NoSuchMethodException e) {
+ // fall through to next attempt
+ } catch (Exception e) {
+ System.err.println("Unexpected exception in hasMethod");
+ e.printStackTrace();
+ return null;
+ }
+
+ // try a method that has a RequestContext arg
+ try {
+ return clazz.getMethod(method, RequestContext.class);
+ } catch (NoSuchMethodException e) {
+ return null;
+ } catch (Exception e) {
+ System.err.println("Unexpected exception in hasMethod");
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private class MethodCacheKey {
+ private Class controller;
+ private String method;
+
+ private MethodCacheKey(Class controller, String method) {
+ this.controller = controller;
+ this.method = method;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ MethodCacheKey that = (MethodCacheKey) o;
+
+ if (!controller.equals(that.controller)) return false;
+ if (!method.equals(that.method)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = controller.hashCode();
+ result = 31 * result + method.hashCode();
+ return result;
+ }
+ }
+}
View
48 backend/java/src/com/mozilla/bespin/Controller.java
@@ -0,0 +1,48 @@
+package com.mozilla.bespin;
+
+import java.io.IOException;
+import java.io.Reader;
+
+public class Controller {
+ private RequestContext ctx;
+
+ public RequestContext getCtx() {
+ return ctx;
+ }
+
+ public void setCtx(RequestContext ctx) {
+ this.ctx = ctx;
+ }
+
+ /**
+ * Convenience method that catches the exception and prints it out
+ *
+ * @param message
+ */
+ protected void print(String message) {
+ try {
+ getCtx().getResp().setHeader("Content-Type", "text/plain");
+ getCtx().getResp().getWriter().print(message);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Convenience method for returning the body stream as a single string.
+ *
+ * @return
+ * @throws IOException
+ */
+ protected String getBody() throws IOException {
+ Reader reader = getCtx().getReq().getReader();
+ StringBuffer sb = new StringBuffer();
+ int i = 0;
+ while ((i = reader.read()) != -1) sb.append((char) i);
+ return sb.toString();
+ }
+
+ protected boolean isAuthenticated() {
+ throw new UnsupportedOperationException("You must implement the isAuthenticated() method in your Controller subclass");
+ }
+}
View
87 backend/java/src/com/mozilla/bespin/Database.java
@@ -0,0 +1,87 @@
+package com.mozilla.bespin;
+
+import java.sql.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dion
+ * Date: Dec 10, 2008
+ * Time: 12:15:28 PM
+ */
+public class Database {
+ private static Database DB = null;
+
+ private Database() {
+ }
+
+ public static Database getInstance() {
+ if (DB == null) {
+ DB = new Database();
+ DB.init();
+ }
+ return DB;
+ }
+
+ private Connection conn;
+
+ public Connection getDB() {
+ if (this.conn == null) {
+ try {
+ this.conn = DriverManager.getConnection("jdbc:sqlite:/bespin/db/backend.db");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+ return this.conn;
+ }
+
+ public void init() {
+ try {
+ Class.forName("org.sqlite.JDBC");
+ Connection conn = this.getDB();
+
+ Statement stat = conn.createStatement();
+ //stat.executeUpdate("drop table if exists users;");
+ stat.executeUpdate("create table users (username, password);");
+ PreparedStatement prep = conn.prepareStatement("insert into users values (?, ?);");
+
+ prep.setString(1, "dion");
+ prep.setString(2, "dion");
+ prep.addBatch();
+
+ prep.setString(1, "ben");
+ prep.setString(2, "ben");
+ prep.addBatch();
+
+ prep.setString(1, "demo");
+ prep.setString(2, "demo");
+ prep.addBatch();
+
+ conn.setAutoCommit(false);
+ prep.executeBatch();
+ conn.setAutoCommit(true);
+
+ conn.close();
+
+ } catch (Exception e) {
+ e.printStackTrace(); // gulp!
+ }
+ }
+
+ public String users() {
+ String users = "";
+ try {
+ Statement stat = this.getDB().createStatement();
+
+ ResultSet rs = stat.executeQuery("select * from users;");
+ while (rs.next()) {
+ users += "username = " + rs.getString("username") + "," + "password = " + rs.getString("password") + "\n";
+ }
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return users;
+ }
+}
View
18 backend/java/src/com/mozilla/bespin/EditMode.java
@@ -0,0 +1,18 @@
+package com.mozilla.bespin;
+
+// uses an enum to reserve space for future modes, like owner, collaborator, etc.
+public enum EditMode {
+ Read ("r"),
+ ReadWrite ("rw");
+
+ private String code;
+
+ EditMode(String code) {
+ this.code = code;
+ }
+
+ @Override
+ public String toString() {
+ return code;
+ }
+}
View
64 backend/java/src/com/mozilla/bespin/EditSession.java
@@ -0,0 +1,64 @@
+package com.mozilla.bespin;
+
+import org.json.simple.JSONObject;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class EditSession {
+ private File file;
+ private UserSession session;
+ private EditMode editMode;
+ private List<JSONObject> edits;
+ private int lastEditBeforeSave = -1;
+
+ EditSession(File file, UserSession session, EditMode editMode) {
+ this.file = file;
+ this.session = session;
+ this.editMode = editMode;
+
+ if (editMode == EditMode.ReadWrite) edits = new ArrayList<JSONObject>();
+ }
+
+ public UserSession getUser() {
+ return session;
+ }
+
+ public EditMode getEditMode() {
+ return editMode;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public List<JSONObject> getEdits() {
+ return (edits == null) ? new ArrayList<JSONObject>(0) : new ArrayList<JSONObject>(edits);
+ }
+
+ public List<JSONObject> getEditsSinceLastSave() {
+ if (edits == null) return new ArrayList<JSONObject>(0);
+ if (lastEditBeforeSave > edits.size() - 1) throw new IllegalStateException("lastEditBeforeSave set too high!");
+ if (lastEditBeforeSave == edits.size() - 1) return new ArrayList<JSONObject>(0);
+ return new ArrayList<JSONObject>(edits.subList(lastEditBeforeSave + 1, edits.size()));
+ }
+
+ public void addEdits(JSONObject... edits) {
+ if (editMode != EditMode.ReadWrite) throw new IllegalStateException("Edit session is read-only; can't add edits");
+ this.edits.addAll(Arrays.asList(edits));
+ }
+
+ public void clearEdits() {
+ if (edits != null) edits.clear();
+ }
+
+ public int getLastEditBeforeSave() {
+ return lastEditBeforeSave;
+ }
+
+ public void setLastEditBeforeSave(int lastEditBeforeSave) {
+ this.lastEditBeforeSave = lastEditBeforeSave;
+ }
+}
View
111 backend/java/src/com/mozilla/bespin/FileSystem.java
@@ -0,0 +1,111 @@
+package com.mozilla.bespin;
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.nio.charset.Charset;
+
+/**
+ * Abstraction for file I/O.
+ */
+public class FileSystem {
+ private File base;
+ private File template;
+
+ public FileSystem(File base, File template) {
+ this.base = base;
+ this.template = template;
+ }
+
+ /**
+ *
+ * @param path relative to the base directory
+ * @return
+ */
+ public File[] list(UserSession session, String path) {
+ return new File(getUserHome(session), path).listFiles();
+ }
+
+ /**
+ * Returns a file as a String.
+ *
+ * @param path
+ * @param session the user requesting the file
+ * @return
+ * @throws FileNotFoundException
+ */
+ public String read(UserSession session, String path) throws FileNotFoundException {
+ File file = getFileHandle(session, path);
+
+ if (file.isDirectory()) throw new FileNotFoundException(String.format("Passed file %1$s is a directory not a file", file));
+ if (!file.exists()) throw new FileNotFoundException(String.format("Passed file %1$s does not exist", file));
+
+ try {
+ FileInputStream in = new FileInputStream(file);
+ byte[] bytes = new byte[(int) file.length()];
+ in.read(bytes);
+ in.close();
+
+ return new String(bytes, Charset.forName("UTF-8"));
+ } catch (IOException e) {
+ System.err.println("Obscure I/O error encountered (stack trace to follow)");
+ e.printStackTrace();
+ return "IO ERROR";
+ }
+ }
+
+ public void write(UserSession session, String path, String contents) throws IOException {
+ File file = getFileHandle(session, path);
+
+ if (file.isDirectory()) throw new FileNotFoundException(String.format("Passed file %1$s is a directory not a file", file));
+
+ if (!file.exists()) file.getParentFile().mkdirs();
+
+ byte[] bytes = contents.getBytes(Charset.forName("UTF-8"));
+ FileOutputStream out = new FileOutputStream(file);
+ out.write(bytes);
+ out.close();
+ }
+
+ public void delete(UserSession session, String path) throws FileNotFoundException {
+ File file = getFileHandle(session, path);
+
+ if (file.equals(base)) return;
+ if (file.isDirectory()) return; // TODO: implement this
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
+
+ public File getFileHandle(UserSession session, String path) throws FileNotFoundException {
+ return new File(getUserHome(session), path);
+ }
+
+
+ public File getUserHome(UserSession session) {
+ File userHome = new File(base, session.username);
+
+ if (userHome.exists()) {
+ userHome.mkdirs();
+
+ // try to copy the template directory to the newly-created user home directory
+ try {
+ FileUtils.copyDirectory(template, userHome);
+ } catch (IOException e) {
+ System.err.println(String.format("Couldn't copy template \"%1$s\" directory to new user directory \"%2$s\"; stacktrace follows", template, userHome));
+ e.printStackTrace();
+ }
+ }
+
+ return userHome;
+ }
+}
View
88 backend/java/src/com/mozilla/bespin/RequestContext.java
@@ -0,0 +1,88 @@
+package com.mozilla.bespin;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletConfig;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Bag for state managed by {@link BaseServlet}. Used in place of a {@link java.util.Map} to obviate need to cast for
+ * common state types.
+ */
+public class RequestContext {
+ private HttpServletRequest req;
+ private HttpServletResponse resp;
+ private HttpServlet servlet;
+ private List<String> parameters = new ArrayList<String>();
+
+ public RequestContext(HttpServlet servlet, HttpServletRequest req, HttpServletResponse resp) {
+ this.servlet = servlet;
+ this.req = req;
+ this.resp = resp;
+ }
+
+ public RequestContext(HttpServlet servlet, HttpServletRequest req, HttpServletResponse resp, List<String> parameters) {
+ this.servlet = servlet;
+ this.req = req;
+ this.resp = resp;
+ this.parameters.addAll(parameters);
+ }
+
+ public HttpServlet getServlet() {
+ return servlet;
+ }
+
+ public HttpServletRequest getReq() {
+ return req;
+ }
+
+ public HttpServletResponse getResp() {
+ return resp;
+ }
+
+ // -- Convenience
+ public ServletContext getServletContext() {
+ return servlet.getServletContext();
+ }
+
+ public ServletConfig getServletConfig() {
+ return servlet.getServletConfig();
+ }
+
+ public HttpSession getSession() {
+ return req.getSession();
+ }
+
+ /**
+ * Guards against index out of bounds exceptions; returns null if the index is out of bounds
+ *
+ * @param index
+ * @return
+ */
+ public String parameter(int index) {
+ return (parameters.size() > index) ? parameters.get(index) : null;
+ }
+
+ /**
+ * Returns an unmodifiable wrapper around the parameter list
+ *
+ * @return
+ */
+ public List<String> getParameterList() {
+ return Collections.unmodifiableList(parameters);
+ }
+
+ /**
+ * Pops the first item off the parameter list
+ *
+ * @return
+ */
+ public String popParam() {
+ return (parameters.isEmpty()) ? null : parameters.remove(0);
+ }
+}
View
7 backend/java/src/com/mozilla/bespin/RequiresLogin.java
@@ -0,0 +1,7 @@
+package com.mozilla.bespin;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RequiresLogin {}
View
120 backend/java/src/com/mozilla/bespin/SessionTracker.java
@@ -0,0 +1,120 @@
+package com.mozilla.bespin;
+
+import org.json.simple.JSONObject;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class SessionTracker {
+
+ private Map<File, List<EditSession>> sessionsByFile = new HashMap<File, List<EditSession>>();
+ private Map<UserSession, List<EditSession>> sessionsByUser = new HashMap<UserSession, List<EditSession>>();
+
+
+ /**
+ * Returns the edits that a user has applied to a specified file.
+ *
+ * @param file
+ * @param session
+ * @return always returns a list; if no edits have been applied, an empty list is returned. The returned list is not live.
+ */
+ public synchronized List<JSONObject> getEdits(File file, UserSession session) {
+ EditSession editSession = getSession(file, session);
+ return (editSession != null) ? editSession.getEdits() : Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Returns any edit sessions that may be open for this file; returned list is not live
+ *
+ * @return
+ */
+ public synchronized List<EditSession> getSessions(File file) {
+ return new ArrayList<EditSession>(getLiveSessions(file));
+ }
+
+ /**
+ * Returns any edit sessions open by the passed user; returned list is not live
+ * @param user
+ * @return
+ */
+ public synchronized List<EditSession> getSessions(UserSession user) {
+ return new ArrayList<EditSession>(getLiveSessions(user));
+ }
+
+ /**
+ * Returns the EditSession corresponding to the passed UserSession, or null if one does not exist
+ *
+ * @param file
+ * @param session
+ * @return
+ */
+ public synchronized EditSession getSession(File file, UserSession session) {
+ List<EditSession> editSessions = sessionsByFile.get(file);
+ if (editSessions == null) return null;
+
+ for (EditSession editSession : editSessions) {
+ if (editSession.getUser().equals(session)) return editSession;
+ }
+
+ return null;
+ }
+
+ public synchronized EditSession openSession(File file, UserSession session, EditMode mode) {
+ if (getSession(file, session) != null) throw new ConcurrentModificationException("Edit session already exists");
+
+ EditSession editSession = new EditSession(file, session, mode);
+ getLiveSessions(file).add(editSession);
+ getLiveSessions(session).add(editSession);
+ return editSession;
+ }
+
+ public synchronized void closeSession(File file, UserSession session) {
+ EditSession edit = getSession(file, session);
+ if (edit != null) {
+ getLiveSessions(file).remove(edit);
+ getLiveSessions(session).remove(edit);
+ }
+ }
+
+ public synchronized void resetEdits(File file) {
+ List<EditSession> edits = getLiveSessions(file);
+ for (EditSession edit : edits) {
+ edit.clearEdits();
+ }
+ }
+
+ public synchronized void resetEdits() {
+ Collection<List<EditSession>> edits = sessionsByFile.values();
+ for (Iterator<List<EditSession>> iterator = edits.iterator(); iterator.hasNext();) {
+ List<EditSession> lists = iterator.next();
+ for (EditSession edit : lists) {
+ edit.clearEdits();
+ }
+ }
+ }
+
+ private synchronized List<EditSession> getLiveSessions(UserSession user) {
+ List<EditSession> sessions = this.sessionsByUser.get(user);
+ if (sessions == null) {
+ sessions = new ArrayList<EditSession>();
+ this.sessionsByUser.put(user, sessions);
+ }
+ return sessions;
+ }
+
+ private synchronized List<EditSession> getLiveSessions(File file) {
+ List<EditSession> sessions = this.sessionsByFile.get(file);
+ if (sessions == null) {
+ sessions = new ArrayList<EditSession>();
+ this.sessionsByFile.put(file, sessions);
+ }
+ return sessions;
+ }
+}
View
26 backend/java/src/com/mozilla/bespin/UserSession.java
@@ -0,0 +1,26 @@
+package com.mozilla.bespin;
+
+public class UserSession {
+ public static final String MESSAGE_NOT_LOGGED_IN = "You are not logged in";
+ public static final String MESSAGE_LOGGED_IN = "You are logged in as %1$s";
+ public static final String MESSAGE_LOGGED_OUT = "You are logged out";
+
+ public String username;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ UserSession that = (UserSession) o;
+
+ if (!username.equals(that.username)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return username.hashCode();
+ }
+}
View
16 backend/java/src/com/mozilla/bespin/auth/Authenticator.java
@@ -0,0 +1,16 @@
+package com.mozilla.bespin.auth;
+
+import com.mozilla.bespin.RequestContext;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dion
+ * Date: Jan 5, 2009
+ * Time: 11:33:54 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface Authenticator {
+ public String authenticate(RequestContext ctx, String username, String password);
+
+ public Object verify(RequestContext ctx);
+}
View
20 backend/java/src/com/mozilla/bespin/auth/NoPasswordNeededAuth.java
@@ -0,0 +1,20 @@
+package com.mozilla.bespin.auth;
+
+import com.mozilla.bespin.RequestContext;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dion
+ * Date: Jan 5, 2009
+ * Time: 11:52:59 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class NoPasswordNeededAuth implements Authenticator {
+ public String authenticate(RequestContext ctx, String username, String password) {
+ return username;
+ }
+
+ public Object verify(RequestContext ctx) {
+ return null; // No need to verify in this scheme
+ }
+}
View
174 backend/java/src/com/mozilla/bespin/auth/OpenIDAuth.java
@@ -0,0 +1,174 @@
+package com.mozilla.bespin.auth;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dion
+ * Date: Dec 17, 2008
+ * Time: 9:57:17 AM
+ */
+
+import org.openid4java.discovery.Identifier;
+import org.openid4java.discovery.DiscoveryInformation;
+import org.openid4java.message.ax.FetchRequest;
+import org.openid4java.message.ax.FetchResponse;
+import org.openid4java.message.ax.AxMessage;
+import org.openid4java.message.*;
+import org.openid4java.OpenIDException;
+import org.openid4java.server.RealmVerifier;
+import org.openid4java.consumer.ConsumerManager;
+import org.openid4java.consumer.ConsumerException;
+import org.openid4java.consumer.VerificationResult;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletConfig;
+import java.util.List;
+import java.io.IOException;
+
+import com.mozilla.bespin.RequestContext;
+
+/**
+ * Sample Consumer (Relying Party) implementation.
+ */
+public class OpenIDAuth implements Authenticator
+{
+ public ConsumerManager manager;
+
+ public OpenIDAuth() throws ConsumerException {
+ // instantiate a ConsumerManager object
+ // Don't try to enforce the realm at all
+ manager = new ConsumerManager();
+ RealmVerifier rv = new RealmVerifier();
+ rv.setEnforceRpId(false);
+ manager.setRealmVerifier(rv);
+ }
+
+ // --- placing the authentication request ---
+ public String authenticate(RequestContext ctx, String userSuppliedString, String password)
+ {
+ try
+ {
+ // configure the return_to URL where your application will receive
+ // the authentication responses from the OpenID provider
+ String returnToUrl = "http://localhost:8080/register/verify";
+
+ // --- Forward proxy setup (only if needed) ---
+ // ProxyProperties proxyProps = new ProxyProperties();
+ // proxyProps.setProxyName("proxy.example.com");
+ // proxyProps.setProxyPort(8080);
+ // HttpClientFactory.setProxyProperties(proxyProps);
+
+ // perform discovery on the user-supplied identifier
+ List discoveries = manager.discover(userSuppliedString);
+
+ // attempt to associate with the OpenID provider
+ // and retrieve one service endpoint for authentication
+ DiscoveryInformation discovered = manager.associate(discoveries);
+
+ // store the discovery information in the user's session
+ ctx.getSession().setAttribute("openid-disc", discovered);
+
+ // obtain a AuthRequest message to be sent to the OpenID provider
+ AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
+
+ // Attribute Exchange example: fetching the 'email' attribute
+ FetchRequest fetch = FetchRequest.createFetchRequest();
+ fetch.addAttribute("email",
+ // attribute alias
+ "http://schema.openid.net/contact/email", // type URI
+ true); // required
+
+ // attach the extension to the authentication request
+ authReq.addExtension(fetch);
+
+
+ if (! discovered.isVersion2() )
+ {
+ // Option 1: GET HTTP-redirect to the OpenID Provider endpoint
+ // The only method supported in OpenID 1.x
+ // redirect-URL usually limited ~2048 bytes
+ try {
+ ctx.getResp().sendRedirect(authReq.getDestinationUrl(true));
+ } catch (IOException e) {
+
+ }
+ return null;
+ }
+ else
+ {
+ // Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)
+/*
+ RequestDispatcher dispatcher =
+ getServletContext().getRequestDispatcher("formredirection.jsp");
+ httpReq.setAttribute("parameterMap", authReq.getParameterMap());
+ httpReq.setAttribute("destinationUrl", authReq.getDestinationUrl(false));
+ dispatcher.forward(httpReq, httpResp);
+ */
+ }
+ }
+ catch (OpenIDException e)
+ {
+ // present error to the user
+ }
+
+ return null;
+ }
+
+ // --- processing the authentication response ---
+ public Identifier verify(RequestContext ctx)
+ {
+ HttpServletRequest httpReq = ctx.getReq();
+ try
+ {
+ // extract the parameters from the authentication response
+ // (which comes in as a HTTP request from the OpenID provider)
+ ParameterList response =
+ new ParameterList(httpReq.getParameterMap());
+
+ // retrieve the previously stored discovery information
+ DiscoveryInformation discovered = (DiscoveryInformation)
+ httpReq.getSession().getAttribute("openid-disc");
+
+ // extract the receiving URL from the HTTP request
+ StringBuffer receivingURL = httpReq.getRequestURL();
+ String queryString = httpReq.getQueryString();
+ if (queryString != null && queryString.length() > 0)
+ receivingURL.append("?").append(httpReq.getQueryString());
+
+ // verify the response; ConsumerManager needs to be the same
+ // (static) instance used to place the authentication request
+ VerificationResult verification = manager.verify(
+ receivingURL.toString(),
+ response, discovered);
+
+ // examine the verification result and extract the verified identifier
+ Identifier verified = verification.getVerifiedId();
+ if (verified != null)
+ {
+ AuthSuccess authSuccess =
+ (AuthSuccess) verification.getAuthResponse();
+
+ if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX))
+ {
+ FetchResponse fetchResp = (FetchResponse) authSuccess
+ .getExtension(AxMessage.OPENID_NS_AX);
+
+ List emails = fetchResp.getAttributeValues("email");
+ String email = (String) emails.get(0);
+ }
+
+ return verified; // success
+ }
+ }
+ catch (OpenIDException e)
+ {
+ // present error to the user
+ }
+
+ return null;
+ }
+}
View
93 backend/java/src/com/mozilla/bespin/controllers/BespinController.java
@@ -0,0 +1,93 @@
+package com.mozilla.bespin.controllers;
+
+import com.mozilla.bespin.Controller;
+import com.mozilla.bespin.FileSystem;
+import com.mozilla.bespin.UserSession;
+import com.mozilla.bespin.SessionTracker;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+
+public class BespinController extends Controller {
+ private static final String KEY_SESSION_TRACKER = "bespin.controller.session_tracker";
+ private static final String KEY_FILESYSTEM = "bespin.controller.filesystem";
+ private static final String KEY_USER_SETTINGS = "bespin.controller.usersettings";
+
+ @Override
+ protected boolean isAuthenticated() {
+ return getCtx().getReq().getSession(true).getAttribute("userSession") != null;
+ }
+
+ protected synchronized FileSystem getFilesystem() throws IOException {
+ FileSystem filesys = (FileSystem) getCtx().getServletContext().getAttribute(KEY_FILESYSTEM);
+ if (filesys == null) {
+ createFileSystemAndSessionTracker();
+ filesys = (FileSystem) getCtx().getServletContext().getAttribute(KEY_FILESYSTEM);
+ }
+ return filesys;
+ }
+
+ protected void createFileSystemAndSessionTracker() throws IOException {
+ String base = getCtx().getServletConfig().getInitParameter("base");
+ if (base == null) throw new IOException("File system not seeded with base directory and could not be mounted (this is for you, Netbeans)");
+
+ String template = getCtx().getServletConfig().getInitParameter("template");
+ if (template == null) throw new IOException("Template directory not provided");
+
+ java.io.File baseDir = new java.io.File(base);
+ java.io.File templateDir = new java.io.File(template);
+
+ FileSystem filesys = new FileSystem(baseDir, templateDir);
+ getCtx().getServletContext().setAttribute(KEY_FILESYSTEM, filesys);
+
+ SessionTracker sessions = new SessionTracker();
+ getCtx().getServletContext().setAttribute(KEY_SESSION_TRACKER, sessions);
+ }
+
+ protected synchronized SessionTracker getSessionTracker() throws IOException {
+ SessionTracker sessions = (SessionTracker) getCtx().getServletContext().getAttribute(KEY_SESSION_TRACKER);
+ if (sessions == null) {
+ createFileSystemAndSessionTracker();
+ sessions = (SessionTracker) getCtx().getServletContext().getAttribute(KEY_SESSION_TRACKER);
+ }
+ return sessions;
+ }
+
+ /**
+ * Return the settings for the current user; returns null if there is no current user
+ * @return
+ */
+ protected synchronized Map<String, String> getUserSettings() {
+ UserSession session = (UserSession) getCtx().getReq().getSession(true).getAttribute("userSession");
+ if (session == null) return null;
+ Map<UserSession, Map<String, String>> settingsMap = (Map<UserSession, Map<String, String>>) getCtx().getServletContext().getAttribute(KEY_USER_SETTINGS);
+ if (settingsMap == null) {
+ settingsMap = new HashMap<UserSession, Map<String, String>>();
+ getCtx().getServletContext().setAttribute(KEY_USER_SETTINGS, settingsMap);
+ }
+
+ Map<String, String> settings = settingsMap.get(session);
+ if (settings == null) {
+ settings = new HashMap<String, String>();
+ settingsMap.put(session, settings);
+ }
+
+ return settings;
+ }
+
+ protected String getPath() {
+ StringBuilder builder = new StringBuilder();
+ for (String pathItem : getCtx().getParameterList()) {
+ if (builder.length() != 0) builder.append("/"); // using "/" instead of File.separator because these paths are used as keys in hashes that may cross OS boundaries
+ builder.append(pathItem);
+ }
+ return builder.toString();
+ }
+
+ protected UserSession getUser() {
+ return (UserSession) getCtx().getReq().getSession(true).getAttribute("userSession");
+ }
+}
View
101 backend/java/src/com/mozilla/bespin/controllers/Edit.java
@@ -0,0 +1,101 @@
+package com.mozilla.bespin.controllers;
+
+import com.mozilla.bespin.EditSession;
+import com.mozilla.bespin.RequiresLogin;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Edit extends BespinController {
+ @RequiresLogin
+ public void list() throws IOException {
+ JSONArray array = new JSONArray();
+ String path = getPath();
+
+ List<JSONObject> edits = getEdits(path);
+
+ array.addAll(edits);
+ print(array.toString());
+ }
+
+ @RequiresLogin
+ public void recent() throws IOException {
+ int editIndex;
+ try {
+ editIndex = Integer.parseInt(getCtx().popParam());
+ } catch (Exception e) {
+ getCtx().getResp().sendError(400, "Couldn't get index of recent edit");
+ return;
+ }
+
+ String path = getPath();
+
+ List<JSONObject> editList = getEdits(path);
+
+ JSONArray array = new JSONArray();
+ array.addAll(editList.subList(editIndex, editList.size()));
+ print(array.toString());
+ }
+
+ @RequiresLogin
+ public void put() throws IOException {
+ String path = getPath();
+ String json = getBody();
+ Object obj = JSONValue.parse(json);
+
+ if (obj instanceof JSONArray) {
+ JSONArray array = (JSONArray) obj;
+ addEdits(path, (JSONObject[]) array.toArray(new JSONObject[0]));
+ } else {