Skip to content
This repository
Browse code

Initial commit

  • Loading branch information...
commit df65a085a13c4efe5c00ace81d45d1a91b12bc11 0 parents
Ben Hood authored October 07, 2010

Showing 233 changed files with 35,354 additions and 0 deletions. Show diff stats Hide diff stats

  1. 30  .gitignore
  2. 3  .gitmodules
  3. 202  LICENSE
  4. 5  NOTICE
  5. 13  README
  6. 21  README.maven_opts.txt
  7. 15  agent/README.docgen
  8. 330  agent/pom.xml
  9. 20  agent/src/main/resources/diffa.properties
  10. 18  agent/src/main/resources/docgen/md/rest_collections.st
  11. 13  agent/src/main/resources/docgen/md/rest_menu.st
  12. 61  agent/src/main/resources/docgen/md/rest_resource.st
  13. 34  agent/src/main/resources/logback.xml
  14. 9  agent/src/main/resources/notifications/mail_body.st
  15. 1  agent/src/main/resources/notifications/mail_subject.st
  16. 84  agent/src/main/scala/net/lshift/diffa/agent/http/FrontendRequestHandler.scala
  17. 95  agent/src/main/scala/net/lshift/diffa/agent/notifications/SmtpNotifier.scala
  18. 80  agent/src/main/scala/net/lshift/diffa/agent/rest/AbstractRestResource.scala
  19. 57  agent/src/main/scala/net/lshift/diffa/agent/rest/ActionsResource.scala
  20. 133  agent/src/main/scala/net/lshift/diffa/agent/rest/ConfigurationResource.scala
  21. 127  agent/src/main/scala/net/lshift/diffa/agent/rest/DifferencesResource.scala
  22. 69  agent/src/main/scala/net/lshift/diffa/agent/rest/UsersResource.scala
  23. 38  agent/src/main/scala/net/lshift/diffa/agent/util/HibernatePropertiesFactory.scala
  24. 31  agent/src/main/webapp/WEB-INF/RESTful-context.xml
  25. 256  agent/src/main/webapp/WEB-INF/applicationContext.xml
  26. 115  agent/src/main/webapp/WEB-INF/web.xml
  27. 101  agent/src/main/webapp/css/grid.css
  28. 140  agent/src/main/webapp/css/grid24.css
  29. 305  agent/src/main/webapp/css/jbase.css
  30. 318  agent/src/main/webapp/css/jquery-ui-slider.1.8.5.css
  31. 63  agent/src/main/webapp/css/reset.css
  32. 30  agent/src/main/webapp/css/stickyfooter.css
  33. 152  agent/src/main/webapp/css/style.css
  34. 101  agent/src/main/webapp/css/styles.css
  35. 0  agent/src/main/webapp/images/sample
  36. 136  agent/src/main/webapp/index.jsp
  37. 878  agent/src/main/webapp/js/app.js
  38. 6,078  agent/src/main/webapp/js/jquery-1.4.1.js
  39. 83  agent/src/main/webapp/js/jquery-ui-slider.1.8.5.min.js
  40. 329  agent/src/main/webapp/js/jquery.ajax.js
  41. 123  agent/src/main/webapp/js/jquery.color.js
  42. 3,725  agent/src/main/webapp/js/raphael.js
  43. 79  agent/src/main/webapp/js/test_data.js
  44. 88  agent/src/test/conf/jetty-env.xml
  45. 67  agent/src/test/conf/jetty.xml
  46. 39  agent/src/test/js-client/crud-test-new.html
  47. 124  agent/src/test/js-client/crud-test.html
  48. 144  agent/src/test/js-client/crud-test.js
  49. 52  agent/src/test/js-client/diffa-rest.js
  50. 6,240  agent/src/test/js-client/jquery-1.4.2.js
  51. 44  agent/src/test/js-client/json2.js
  52. 155  agent/src/test/js-client/qunit.css
  53. 1,261  agent/src/test/js-client/qunit.js
  54. 20  agent/src/test/resources/diffa.itest.properties
  55. 21  agent/src/test/resources/log4j.properties
  56. 43  agent/src/test/resources/logback-test.xml
  57. 35  agent/src/test/scala/net/lshift/diffa/agent/itest/AbstractEnvironmentTest.scala
  58. 50  agent/src/test/scala/net/lshift/diffa/agent/itest/CommonActionTests.scala
  59. 175  agent/src/test/scala/net/lshift/diffa/agent/itest/CommonDifferenceTests.scala
  60. 31  agent/src/test/scala/net/lshift/diffa/agent/itest/CommonMatchingTests.scala
  61. 30  agent/src/test/scala/net/lshift/diffa/agent/itest/CorrelatedEnvironmentTest.scala
  62. 29  agent/src/test/scala/net/lshift/diffa/agent/itest/SameEnvironmentTest.scala
  63. 38  agent/src/test/scala/net/lshift/diffa/agent/itest/SmokeTest.scala
  64. 51  agent/src/test/scala/net/lshift/diffa/agent/itest/support/Participants.scala
  65. 28  agent/src/test/scala/net/lshift/diffa/agent/itest/support/TestConstants.scala
  66. 110  agent/src/test/scala/net/lshift/diffa/agent/itest/support/TestEnvironment.scala
  67. 25  agent/src/test/scala/net/lshift/diffa/agent/itest/support/TestEnvironments.scala
  68. 132  dist/pom.xml
  69. 131  dist/src/main/assembly/jetty-bundle.xml
  70. 24  dist/src/main/assembly/resources/bin/agent.sh
  71. 29  dist/src/main/assembly/resources/bin/configure-sample.sh
  72. 24  dist/src/main/assembly/resources/bin/declare.sh
  73. 24  dist/src/main/assembly/resources/bin/diff.sh
  74. 176  dist/src/main/assembly/resources/etc/jetty.xml
  75. 1  dist/src/main/assembly/resources/start.ini
  76. 55  docgen-maven-plugin/pom.xml
  77. 142  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/DocGenMojo.java
  78. 41  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/MandatoryParameter.java
  79. 41  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/OptionalParameter.java
  80. 60  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/ResourceCollection.java
  81. 140  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/ResourceDescriptor.java
  82. 166  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/RestGen.java
  83. 29  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/annotations/Description.java
  84. 34  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/annotations/MandatoryParams.java
  85. 34  docgen-maven-plugin/src/main/java/net/lshift/diffa/docgen/annotations/OptionalParams.java
  86. 13  etc/header.txt
  87. 1  javamail-file-transport
  88. 70  json-messaging/pom.xml
  89. 102  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/AbstractJSONHandler.scala
  90. 70  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/AbstractRestClient.scala
  91. 37  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ActionsRestClient.scala
  92. 51  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ChangesHandler.scala
  93. 49  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ChangesRestClient.scala
  94. 54  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ConfigurationRestClient.scala
  95. 104  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/DifferencesRestClient.scala
  96. 44  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/JSONEncodingUtils.scala
  97. 34  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/JSONRestParticipantProtocolFactory.scala
  98. 98  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ParticipantHandler.scala
  99. 94  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/ParticipantRestClient.scala
  100. 30  json-messaging/src/main/scala/net/lshift/diffa/messaging/json/UsersRestClient.scala
  101. 140  kernel/pom.xml
  102. 21  kernel/src/main/java/net/lshift/diffa/kernel/differencing/MatchState.java
  103. 80  kernel/src/main/resources/net/lshift/diffa/kernel/config/Config.hbm.xml
  104. 47  kernel/src/main/resources/net/lshift/diffa/kernel/differencing/Correlations.hbm.xml
  105. 26  kernel/src/main/scala/net/lshift/diffa/kernel/alerting/AlertKey.scala
  106. 45  kernel/src/main/scala/net/lshift/diffa/kernel/alerting/Alerter.scala
  107. 30  kernel/src/main/scala/net/lshift/diffa/kernel/alerting/KernelAlerts.scala
  108. 59  kernel/src/main/scala/net/lshift/diffa/kernel/client/ActionsClient.scala
  109. 29  kernel/src/main/scala/net/lshift/diffa/kernel/client/ChangesClient.scala
  110. 29  kernel/src/main/scala/net/lshift/diffa/kernel/client/ConfigurationClient.scala
  111. 81  kernel/src/main/scala/net/lshift/diffa/kernel/client/DifferencesClient.scala
  112. 25  kernel/src/main/scala/net/lshift/diffa/kernel/client/UsersClient.scala
  113. 94  kernel/src/main/scala/net/lshift/diffa/kernel/config/ConfigStore.scala
  114. 117  kernel/src/main/scala/net/lshift/diffa/kernel/config/HibernateConfigStore.scala
  115. 133  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/BaseSynchingVersionPolicy.scala
  116. 64  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/CorrelatedVersionPolicy.scala
  117. 42  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/Correlation.scala
  118. 73  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DateConstraint.scala
  119. 320  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DefaultSessionManager.scala
  120. 23  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DifferenceHandler.scala
  121. 44  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DifferencingListener.scala
  122. 97  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DigestBuilder.scala
  123. 121  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/DigestDifferencingUtils.scala
  124. 178  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/HibernateVersionCorrelationStore.scala
  125. 112  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/LocalSessionCache.scala
  126. 62  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/SameVersionPolicy.scala
  127. 107  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/SessionCache.scala
  128. 132  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/SessionManager.scala
  129. 43  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/SessionScope.scala
  130. 71  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/VersionCorrelationStore.scala
  131. 38  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/VersionPolicy.scala
  132. 43  kernel/src/main/scala/net/lshift/diffa/kernel/differencing/VersionPolicyManager.scala
  133. 50  kernel/src/main/scala/net/lshift/diffa/kernel/events/ChangeEvent.scala
  134. 48  kernel/src/main/scala/net/lshift/diffa/kernel/events/PairChangeEvent.scala
  135. 29  kernel/src/main/scala/net/lshift/diffa/kernel/events/VersionID.scala
  136. 57  kernel/src/main/scala/net/lshift/diffa/kernel/frontend/ActionsProxy.scala
  137. 64  kernel/src/main/scala/net/lshift/diffa/kernel/frontend/Changes.scala
  138. 120  kernel/src/main/scala/net/lshift/diffa/kernel/frontend/Configuration.scala
  139. 56  kernel/src/main/scala/net/lshift/diffa/kernel/frontend/Matches.scala
  140. 57  kernel/src/main/scala/net/lshift/diffa/kernel/matching/EventMatcher.scala
  141. 251  kernel/src/main/scala/net/lshift/diffa/kernel/matching/LocalEventMatcher.scala
  142. 91  kernel/src/main/scala/net/lshift/diffa/kernel/matching/LocalEventMatchingManager.scala
  143. 45  kernel/src/main/scala/net/lshift/diffa/kernel/matching/MatchingManager.scala
  144. 41  kernel/src/main/scala/net/lshift/diffa/kernel/matching/MatchingStatusListener.scala
  145. 61  kernel/src/main/scala/net/lshift/diffa/kernel/notifications/EventNotifier.scala
  146. 36  kernel/src/main/scala/net/lshift/diffa/kernel/notifications/NotificationEvent.scala
  147. 30  kernel/src/main/scala/net/lshift/diffa/kernel/notifications/NotificationProvider.scala
  148. 30  kernel/src/main/scala/net/lshift/diffa/kernel/participants/ActionResult.scala
  149. 33  kernel/src/main/scala/net/lshift/diffa/kernel/participants/DownstreamMemoryParticipant.scala
  150. 68  kernel/src/main/scala/net/lshift/diffa/kernel/participants/MemoryParticipantBase.scala
  151. 53  kernel/src/main/scala/net/lshift/diffa/kernel/participants/Participant.scala
  152. 45  kernel/src/main/scala/net/lshift/diffa/kernel/participants/ParticipantFactory.scala
  153. 41  kernel/src/main/scala/net/lshift/diffa/kernel/participants/ParticipantProtocolFactory.scala
  154. 25  kernel/src/main/scala/net/lshift/diffa/kernel/participants/ProcessingResponse.scala
  155. 27  kernel/src/main/scala/net/lshift/diffa/kernel/participants/RangeGranularity.scala
  156. 31  kernel/src/main/scala/net/lshift/diffa/kernel/participants/UpstreamMemoryParticipant.scala
  157. 28  kernel/src/main/scala/net/lshift/diffa/kernel/participants/VersionDigest.scala
  158. 43  kernel/src/main/scala/net/lshift/diffa/kernel/protocol/ProtocolHandler.scala
  159. 55  kernel/src/main/scala/net/lshift/diffa/kernel/protocol/ProtocolMapper.scala
  160. 24  kernel/src/main/scala/net/lshift/diffa/kernel/protocol/TransportRequest.scala
  161. 31  kernel/src/main/scala/net/lshift/diffa/kernel/protocol/TransportResponse.scala
  162. 34  kernel/src/main/scala/net/lshift/diffa/kernel/util/DateUtils.scala
  163. 46  kernel/src/main/scala/net/lshift/diffa/kernel/util/DocExamplesFactory.scala
  164. 66  kernel/src/main/scala/net/lshift/diffa/kernel/util/HibernateQueryUtils.scala
  165. 23  kernel/src/main/scala/net/lshift/diffa/kernel/util/MissingObjectException.scala
  166. 27  kernel/src/main/scala/net/lshift/diffa/kernel/util/Placeholders.scala
  167. 44  kernel/src/main/scala/net/lshift/diffa/kernel/util/SessionHelper.scala
  168. 34  kernel/src/test/java/net/lshift/diffa/kernel/util/Concurrent.java
  169. 87  kernel/src/test/java/net/lshift/diffa/kernel/util/ConcurrentJunitRunner.java
  170. 21  kernel/src/test/resources/log4j.properties
  171. 41  kernel/src/test/resources/logback-test.xml
  172. 321  kernel/src/test/scala/net/lshift/diffa/kernel/config/HibernateConfigStoreTest.scala
  173. 281  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/AbstractPolicyTest.scala
  174. 156  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/CorrelatedVersionPolicyTest.scala
  175. 185  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/DefaultSessionManagerTest.scala
  176. 97  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/DigestBuilderTest.scala
  177. 161  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/DigestDifferencingUtilsTest.scala
  178. 301  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/HibernateVersionCorrelationStoreTest.scala
  179. 74  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/LocalSessionCacheProviderTest.scala
  180. 149  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/LocalSessionCacheTest.scala
  181. 29  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/NullDifferencingListener.scala
  182. 92  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/SameVersionPolicyTest.scala
  183. 44  kernel/src/test/scala/net/lshift/diffa/kernel/differencing/VersionPolicyManagerTest.scala
  184. 36  kernel/src/test/scala/net/lshift/diffa/kernel/frontend/ConfigurationTest.scala
  185. 341  kernel/src/test/scala/net/lshift/diffa/kernel/matching/AbstractMatcherTest.scala
  186. 37  kernel/src/test/scala/net/lshift/diffa/kernel/matching/LocalEventMatcherTest.scala
  187. 92  kernel/src/test/scala/net/lshift/diffa/kernel/matching/LocalEventMatchingManagerTest.scala
  188. 69  kernel/src/test/scala/net/lshift/diffa/kernel/notifications/EventNotifierTest.scala
  189. 112  kernel/src/test/scala/net/lshift/diffa/kernel/participants/ParticipantFactoryTest.scala
  190. 85  kernel/src/test/scala/net/lshift/diffa/kernel/protocol/ProtocolMapperTest.scala
  191. 72  kernel/src/test/scala/net/lshift/diffa/kernel/util/Dates.scala
  192. 58  kernel/src/test/scala/net/lshift/diffa/kernel/util/EasyMockScalaUtils.scala
  193. 185  participants-web/pom.xml
  194. 24  participants-web/src/main/resources/demo.properties
  195. 61  participants-web/src/main/resources/mvcContext.xml
  196. 42  participants-web/src/main/scala/net/lshift/diffa/participants/DownstreamWebParticipant.scala
  197. 45  participants-web/src/main/scala/net/lshift/diffa/participants/UpstreamWebParticipant.scala
  198. 35  participants-web/src/main/scala/net/lshift/diffa/participants/WebParticipant.scala
  199. 27  participants-web/src/main/scala/net/lshift/diffa/participants/domain/ParticipantEntity.scala
  200. 39  participants-web/src/main/scala/net/lshift/diffa/participants/web/ParticipantRequestHandler.scala
  201. 75  participants-web/src/main/scala/net/lshift/diffa/participants/web/ParticipantUIController.scala
  202. 39  participants-web/src/main/scala/net/lshift/diffa/util/DefaultWrapperServlet.scala
  203. 36  participants-web/src/main/scala/net/lshift/diffa/util/ResultOnlyMappingJacksonJsonView.scala
  204. 116  participants-web/src/main/webapp/WEB-INF/applicationContext.xml
  205. 184  participants-web/src/main/webapp/WEB-INF/views/home/index.jsp
  206. 20  participants-web/src/main/webapp/WEB-INF/views/json/empty.jsp
  207. 90  participants-web/src/main/webapp/WEB-INF/web.xml
  208. 104  participants-web/src/main/webapp/javascript/date.js
  209. 154  participants-web/src/main/webapp/javascript/jquery-1.4.2.min.js
  210. 9  participants-web/src/main/webapp/javascript/md5-min.js
  211. 40  participants-web/src/main/webapp/javascript/scenarios.js
  212. 21  participants-web/src/test/conf/jetty-env.xml
  213. 60  participants-web/src/test/conf/jetty.xml
  214. 19  participants/bin/file-pair.sh
  215. 54  participants/pom.xml
  216. 43  participants/src/main/scala/net/lshift/diffa/participants/DirWalker.scala
  217. 57  participants/src/main/scala/net/lshift/diffa/participants/DirWatcher.scala
  218. 37  participants/src/main/scala/net/lshift/diffa/participants/DownstreamFileParticipant.scala
  219. 47  participants/src/main/scala/net/lshift/diffa/participants/FilePair.scala
  220. 69  participants/src/main/scala/net/lshift/diffa/participants/FileParticipant.scala
  221. 47  participants/src/main/scala/net/lshift/diffa/participants/ParticipantRpcServer.scala
  222. 40  participants/src/main/scala/net/lshift/diffa/participants/UpstreamFileParticipant.scala
  223. 323  pom.xml
  224. 12  setup/Makefile
  225. 19  tools/bin/declare.sh
  226. 19  tools/bin/difftail.sh
  227. 53  tools/pom.xml
  228. 19  tools/samples/declare-same.sh
  229. 19  tools/samples/diff-same.sh
  230. 19  tools/samples/match-same.sh
  231. 92  tools/src/main/scala/net/lshift/diffa/tools/Declare.scala
  232. 52  tools/src/main/scala/net/lshift/diffa/tools/DiffTail.scala
  233. 62  tools/src/main/scala/net/lshift/diffa/tools/DiffaTool.scala
30  .gitignore
... ...
@@ -0,0 +1,30 @@
  1
+/*.hgignore
  2
+*.suo
  3
+/*.5.0.ReSharper.user
  4
+/_ReSharper*/
  5
+*.xss
  6
+*.xsc
  7
+bin/*
  8
+
  9
+*/obj/
  10
+/Mockup.bmml
  11
+/DifferenceEngine.png
  12
+/*.lnk.bmml
  13
+/.idea
  14
+diffa*.iml
  15
+*.iml
  16
+/setup/*.tar.gz
  17
+/setup/protobuf-*
  18
+target/
  19
+derby.log
  20
+glob:**/bin/
  21
+agent/target/*
  22
+kernel/target/*
  23
+participants/target/*
  24
+protocol/target/*
  25
+target/*
  26
+tools/target/*
  27
+/*.iws
  28
+/*.ipr
  29
+/*.7z
  30
+/*.tmproj
3  .gitmodules
... ...
@@ -0,0 +1,3 @@
  1
+[submodule "javamail-file-transport"]
  2
+	path = javamail-file-transport
  3
+	url = git://github.com/lshift/javamail-file-transport
202  LICENSE
... ...
@@ -0,0 +1,202 @@
  1
+
  2
+                                 Apache License
  3
+                           Version 2.0, January 2004
  4
+                        http://www.apache.org/licenses/
  5
+
  6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  7
+
  8
+   1. Definitions.
  9
+
  10
+      "License" shall mean the terms and conditions for use, reproduction,
  11
+      and distribution as defined by Sections 1 through 9 of this document.
  12
+
  13
+      "Licensor" shall mean the copyright owner or entity authorized by
  14
+      the copyright owner that is granting the License.
  15
+
  16
+      "Legal Entity" shall mean the union of the acting entity and all
  17
+      other entities that control, are controlled by, or are under common
  18
+      control with that entity. For the purposes of this definition,
  19
+      "control" means (i) the power, direct or indirect, to cause the
  20
+      direction or management of such entity, whether by contract or
  21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
  22
+      outstanding shares, or (iii) beneficial ownership of such entity.
  23
+
  24
+      "You" (or "Your") shall mean an individual or Legal Entity
  25
+      exercising permissions granted by this License.
  26
+
  27
+      "Source" form shall mean the preferred form for making modifications,
  28
+      including but not limited to software source code, documentation
  29
+      source, and configuration files.
  30
+
  31
+      "Object" form shall mean any form resulting from mechanical
  32
+      transformation or translation of a Source form, including but
  33
+      not limited to compiled object code, generated documentation,
  34
+      and conversions to other media types.
  35
+
  36
+      "Work" shall mean the work of authorship, whether in Source or
  37
+      Object form, made available under the License, as indicated by a
  38
+      copyright notice that is included in or attached to the work
  39
+      (an example is provided in the Appendix below).
  40
+
  41
+      "Derivative Works" shall mean any work, whether in Source or Object
  42
+      form, that is based on (or derived from) the Work and for which the
  43
+      editorial revisions, annotations, elaborations, or other modifications
  44
+      represent, as a whole, an original work of authorship. For the purposes
  45
+      of this License, Derivative Works shall not include works that remain
  46
+      separable from, or merely link (or bind by name) to the interfaces of,
  47
+      the Work and Derivative Works thereof.
  48
+
  49
+      "Contribution" shall mean any work of authorship, including
  50
+      the original version of the Work and any modifications or additions
  51
+      to that Work or Derivative Works thereof, that is intentionally
  52
+      submitted to Licensor for inclusion in the Work by the copyright owner
  53
+      or by an individual or Legal Entity authorized to submit on behalf of
  54
+      the copyright owner. For the purposes of this definition, "submitted"
  55
+      means any form of electronic, verbal, or written communication sent
  56
+      to the Licensor or its representatives, including but not limited to
  57
+      communication on electronic mailing lists, source code control systems,
  58
+      and issue tracking systems that are managed by, or on behalf of, the
  59
+      Licensor for the purpose of discussing and improving the Work, but
  60
+      excluding communication that is conspicuously marked or otherwise
  61
+      designated in writing by the copyright owner as "Not a Contribution."
  62
+
  63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
  64
+      on behalf of whom a Contribution has been received by Licensor and
  65
+      subsequently incorporated within the Work.
  66
+
  67
+   2. Grant of Copyright License. Subject to the terms and conditions of
  68
+      this License, each Contributor hereby grants to You a perpetual,
  69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  70
+      copyright license to reproduce, prepare Derivative Works of,
  71
+      publicly display, publicly perform, sublicense, and distribute the
  72
+      Work and such Derivative Works in Source or Object form.
  73
+
  74
+   3. Grant of Patent License. Subject to the terms and conditions of
  75
+      this License, each Contributor hereby grants to You a perpetual,
  76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  77
+      (except as stated in this section) patent license to make, have made,
  78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
  79
+      where such license applies only to those patent claims licensable
  80
+      by such Contributor that are necessarily infringed by their
  81
+      Contribution(s) alone or by combination of their Contribution(s)
  82
+      with the Work to which such Contribution(s) was submitted. If You
  83
+      institute patent litigation against any entity (including a
  84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
  85
+      or a Contribution incorporated within the Work constitutes direct
  86
+      or contributory patent infringement, then any patent licenses
  87
+      granted to You under this License for that Work shall terminate
  88
+      as of the date such litigation is filed.
  89
+
  90
+   4. Redistribution. You may reproduce and distribute copies of the
  91
+      Work or Derivative Works thereof in any medium, with or without
  92
+      modifications, and in Source or Object form, provided that You
  93
+      meet the following conditions:
  94
+
  95
+      (a) You must give any other recipients of the Work or
  96
+          Derivative Works a copy of this License; and
  97
+
  98
+      (b) You must cause any modified files to carry prominent notices
  99
+          stating that You changed the files; and
  100
+
  101
+      (c) You must retain, in the Source form of any Derivative Works
  102
+          that You distribute, all copyright, patent, trademark, and
  103
+          attribution notices from the Source form of the Work,
  104
+          excluding those notices that do not pertain to any part of
  105
+          the Derivative Works; and
  106
+
  107
+      (d) If the Work includes a "NOTICE" text file as part of its
  108
+          distribution, then any Derivative Works that You distribute must
  109
+          include a readable copy of the attribution notices contained
  110
+          within such NOTICE file, excluding those notices that do not
  111
+          pertain to any part of the Derivative Works, in at least one
  112
+          of the following places: within a NOTICE text file distributed
  113
+          as part of the Derivative Works; within the Source form or
  114
+          documentation, if provided along with the Derivative Works; or,
  115
+          within a display generated by the Derivative Works, if and
  116
+          wherever such third-party notices normally appear. The contents
  117
+          of the NOTICE file are for informational purposes only and
  118
+          do not modify the License. You may add Your own attribution
  119
+          notices within Derivative Works that You distribute, alongside
  120
+          or as an addendum to the NOTICE text from the Work, provided
  121
+          that such additional attribution notices cannot be construed
  122
+          as modifying the License.
  123
+
  124
+      You may add Your own copyright statement to Your modifications and
  125
+      may provide additional or different license terms and conditions
  126
+      for use, reproduction, or distribution of Your modifications, or
  127
+      for any such Derivative Works as a whole, provided Your use,
  128
+      reproduction, and distribution of the Work otherwise complies with
  129
+      the conditions stated in this License.
  130
+
  131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
  132
+      any Contribution intentionally submitted for inclusion in the Work
  133
+      by You to the Licensor shall be under the terms and conditions of
  134
+      this License, without any additional terms or conditions.
  135
+      Notwithstanding the above, nothing herein shall supersede or modify
  136
+      the terms of any separate license agreement you may have executed
  137
+      with Licensor regarding such Contributions.
  138
+
  139
+   6. Trademarks. This License does not grant permission to use the trade
  140
+      names, trademarks, service marks, or product names of the Licensor,
  141
+      except as required for reasonable and customary use in describing the
  142
+      origin of the Work and reproducing the content of the NOTICE file.
  143
+
  144
+   7. Disclaimer of Warranty. Unless required by applicable law or
  145
+      agreed to in writing, Licensor provides the Work (and each
  146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
  147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  148
+      implied, including, without limitation, any warranties or conditions
  149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
  151
+      appropriateness of using or redistributing the Work and assume any
  152
+      risks associated with Your exercise of permissions under this License.
  153
+
  154
+   8. Limitation of Liability. In no event and under no legal theory,
  155
+      whether in tort (including negligence), contract, or otherwise,
  156
+      unless required by applicable law (such as deliberate and grossly
  157
+      negligent acts) or agreed to in writing, shall any Contributor be
  158
+      liable to You for damages, including any direct, indirect, special,
  159
+      incidental, or consequential damages of any character arising as a
  160
+      result of this License or out of the use or inability to use the
  161
+      Work (including but not limited to damages for loss of goodwill,
  162
+      work stoppage, computer failure or malfunction, or any and all
  163
+      other commercial damages or losses), even if such Contributor
  164
+      has been advised of the possibility of such damages.
  165
+
  166
+   9. Accepting Warranty or Additional Liability. While redistributing
  167
+      the Work or Derivative Works thereof, You may choose to offer,
  168
+      and charge a fee for, acceptance of support, warranty, indemnity,
  169
+      or other liability obligations and/or rights consistent with this
  170
+      License. However, in accepting such obligations, You may act only
  171
+      on Your own behalf and on Your sole responsibility, not on behalf
  172
+      of any other Contributor, and only if You agree to indemnify,
  173
+      defend, and hold each Contributor harmless for any liability
  174
+      incurred by, or claims asserted against, such Contributor by reason
  175
+      of your accepting any such warranty or additional liability.
  176
+
  177
+   END OF TERMS AND CONDITIONS
  178
+
  179
+   APPENDIX: How to apply the Apache License to your work.
  180
+
  181
+      To apply the Apache License to your work, attach the following
  182
+      boilerplate notice, with the fields enclosed by brackets "[]"
  183
+      replaced with your own identifying information. (Don't include
  184
+      the brackets!)  The text should be enclosed in the appropriate
  185
+      comment syntax for the file format. We also recommend that a
  186
+      file or class name and description of purpose be included on the
  187
+      same "printed page" as the copyright notice for easier
  188
+      identification within third-party archives.
  189
+
  190
+   Copyright [yyyy] [name of copyright owner]
  191
+
  192
+   Licensed under the Apache License, Version 2.0 (the "License");
  193
+   you may not use this file except in compliance with the License.
  194
+   You may obtain a copy of the License at
  195
+
  196
+       http://www.apache.org/licenses/LICENSE-2.0
  197
+
  198
+   Unless required by applicable law or agreed to in writing, software
  199
+   distributed under the License is distributed on an "AS IS" BASIS,
  200
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  201
+   See the License for the specific language governing permissions and
  202
+   limitations under the License.
5  NOTICE
... ...
@@ -0,0 +1,5 @@
  1
+LShift diffa
  2
+Copyright [2010] LShift Ltd.
  3
+
  4
+This product includes software developed at
  5
+LShift Ltd. (http://www.lshift.net/).
13  README
... ...
@@ -0,0 +1,13 @@
  1
+License Checking
  2
+----------------
  3
+
  4
+Diffa uses the maven license plugin (http://code.google.com/p/maven-license-plugin/) to check that the license files are up to date.
  5
+
  6
+To run the license check:
  7
+
  8
+mvn -e license:format -Dyear=2010
  9
+
  10
+To reformat each file according to the header file:
  11
+
  12
+mvn -e license:format -Dyear=2010
  13
+
21  README.maven_opts.txt
... ...
@@ -0,0 +1,21 @@
  1
+====
  2
+    Copyright (C) 2010 LShift Ltd.
  3
+
  4
+    Licensed under the Apache License, Version 2.0 (the "License");
  5
+    you may not use this file except in compliance with the License.
  6
+    You may obtain a copy of the License at
  7
+
  8
+            http://www.apache.org/licenses/LICENSE-2.0
  9
+
  10
+    Unless required by applicable law or agreed to in writing, software
  11
+    distributed under the License is distributed on an "AS IS" BASIS,
  12
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+    See the License for the specific language governing permissions and
  14
+    limitations under the License.
  15
+====
  16
+
  17
+Due to the way that we're booting the webapps into the Maven JVM, the Permgen
  18
+space is tending to blow out when we run the integration test suite. If
  19
+you set the following environment variable, things should come good again:
  20
+
  21
+MAVEN_OPTS=-XX:MaxPermSize=512m 
15  agent/README.docgen
... ...
@@ -0,0 +1,15 @@
  1
+The REST API documentation in markdown is auto-generated from annotations in the code. This is linked to the 'process-classes' phase.
  2
+
  3
+The result should normally go to the 'doc/rest' subdirectory of a 'gh-pages' branch checkout.
  4
+
  5
+You can specify the target directory by overriding the docs.targetDir property. Thus a full example would look as follows:
  6
+
  7
+    cd DIFFA-MASTER-CHECKOUT/agent
  8
+    mvn install -Ddocs.targetDir=../../DIFFA-GH-PAGES-CHECKOUT/doc/rest
  9
+
  10
+...assuming you have your checkouts of 'gh-pages' and 'master' in a common directory.
  11
+
  12
+After checking the generated content you need to commit both the docgen logic/templates on the master branch and the generated files on the gh-pages branch separately.
  13
+
  14
+Also see README in the root of the 'gh-pages' branch.
  15
+
330  agent/pom.xml
... ...
@@ -0,0 +1,330 @@
  1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3
+
  4
+  <modelVersion>4.0.0</modelVersion>
  5
+
  6
+  <parent>
  7
+    <groupId>net.lshift.diffa</groupId>
  8
+    <artifactId>diffa-parent</artifactId>
  9
+    <version>0.8-SNAPSHOT</version>
  10
+  </parent>
  11
+
  12
+  <artifactId>diffa-agent</artifactId>
  13
+  <name>LShift Diffa Agent</name>
  14
+
  15
+  <packaging>war</packaging>
  16
+
  17
+  <dependencies>
  18
+    <dependency>
  19
+      <groupId>net.lshift.diffa</groupId>
  20
+      <artifactId>diffa-json-messaging</artifactId>
  21
+      <version>${project.version}</version>
  22
+    </dependency>
  23
+    <dependency>
  24
+      <groupId>org.scala-lang</groupId>
  25
+      <artifactId>scala-library</artifactId>
  26
+    </dependency>
  27
+    <dependency>
  28
+      <groupId>org.scala-lang</groupId>
  29
+      <artifactId>scala-compiler</artifactId>
  30
+      <scope>provided</scope>
  31
+    </dependency>
  32
+    <dependency>
  33
+      <groupId>org.springframework</groupId>
  34
+      <artifactId>spring-web</artifactId>
  35
+    </dependency>
  36
+    <dependency>
  37
+      <groupId>org.springframework</groupId>
  38
+      <artifactId>spring-orm</artifactId>
  39
+    </dependency>
  40
+    <dependency>
  41
+      <groupId>javassist</groupId>
  42
+      <artifactId>javassist</artifactId>
  43
+    </dependency>
  44
+      <!-- Hibernate imports 1.5.2 of slf4j, which is incompatible with the version
  45
+           of logback that we're using. Force an upgrade.
  46
+      -->
  47
+    <dependency>
  48
+      <groupId>com.sun.jersey</groupId>
  49
+      <artifactId>jersey-server</artifactId>
  50
+    </dependency>
  51
+    <dependency>
  52
+      <groupId>com.sun.jersey.contribs</groupId>
  53
+      <artifactId>jersey-spring</artifactId>
  54
+    </dependency>
  55
+    <dependency>
  56
+      <groupId>org.antlr</groupId>
  57
+      <artifactId>stringtemplate</artifactId>
  58
+    </dependency>
  59
+    <dependency>
  60
+      <groupId>org.codehaus.jackson</groupId>
  61
+      <artifactId>jackson-jaxrs</artifactId>      
  62
+    </dependency>
  63
+    <dependency>
  64
+      <groupId>org.codehaus.jackson</groupId>
  65
+      <artifactId>jackson-xc</artifactId>
  66
+    </dependency>
  67
+    <dependency>
  68
+      <groupId>org.slf4j</groupId>
  69
+      <artifactId>slf4j-api</artifactId>
  70
+    </dependency>    
  71
+    <dependency>
  72
+      <groupId>javax.mail</groupId>
  73
+      <artifactId>mail</artifactId>
  74
+    </dependency>
  75
+    <dependency>
  76
+        <groupId>org.codehaus.jettison</groupId>
  77
+        <artifactId>jettison</artifactId>
  78
+    </dependency>
  79
+    <dependency>
  80
+      <groupId>ch.qos.logback</groupId>
  81
+      <artifactId>logback-classic</artifactId>
  82
+    </dependency>
  83
+    <dependency>
  84
+      <groupId>javax.servlet</groupId>
  85
+      <artifactId>servlet-api</artifactId>
  86
+      <scope>provided</scope>
  87
+    </dependency>
  88
+    <dependency>
  89
+      <groupId>org.eclipse.jetty</groupId>
  90
+      <artifactId>jetty-continuation</artifactId>
  91
+      <scope>provided</scope>
  92
+    </dependency>    
  93
+    <dependency>
  94
+      <groupId>junit</groupId>
  95
+      <artifactId>junit</artifactId>
  96
+      <scope>test</scope>
  97
+    </dependency>
  98
+    <dependency>
  99
+      <groupId>org.easymock</groupId>
  100
+      <artifactId>easymock</artifactId>
  101
+      <scope>test</scope>
  102
+    </dependency>
  103
+    <dependency>
  104
+      <groupId>org.easymock</groupId>
  105
+      <artifactId>easymockclassextension</artifactId>
  106
+      <scope>test</scope>
  107
+    </dependency>
  108
+    <dependency>
  109
+      <groupId>org.easymock</groupId>
  110
+      <artifactId>easymockclassextension</artifactId>
  111
+      <scope>test</scope>
  112
+    </dependency>
  113
+    <dependency>
  114
+      <groupId>org.apache.derby</groupId>
  115
+      <artifactId>derby</artifactId>
  116
+      <scope>test</scope>
  117
+    </dependency>
  118
+    <dependency>
  119
+      <groupId>net.lshift.diffa</groupId>
  120
+      <artifactId>diffa-participants</artifactId>
  121
+      <version>${project.version}</version>
  122
+      <scope>test</scope>
  123
+    </dependency>
  124
+    <dependency>
  125
+      <groupId>net.lshift.diffa</groupId>
  126
+      <artifactId>diffa-docgen-maven-plugin</artifactId>
  127
+      <version>${project.version}</version>
  128
+    </dependency>
  129
+  </dependencies>
  130
+
  131
+  <build>
  132
+    <finalName>${project.artifactId}-${buildVersion}</finalName>
  133
+    <sourceDirectory>src/main/scala</sourceDirectory>
  134
+    <testSourceDirectory>src/test/scala</testSourceDirectory>
  135
+    <plugins>
  136
+      <plugin>
  137
+        <groupId>org.apache.maven.plugins</groupId>
  138
+        <artifactId>maven-compiler-plugin</artifactId>
  139
+        <configuration>
  140
+          <source>1.6</source>
  141
+          <target>1.6</target>
  142
+        </configuration>
  143
+      </plugin>
  144
+      <plugin>
  145
+        <groupId>org.scala-tools</groupId>
  146
+        <artifactId>maven-scala-plugin</artifactId>
  147
+      </plugin>
  148
+      <plugin>
  149
+        <groupId>org.apache.maven.plugins</groupId>
  150
+        <artifactId>maven-compiler-plugin</artifactId>
  151
+        <configuration>
  152
+          <source>1.6</source>
  153
+          <target>1.6</target>
  154
+        </configuration>
  155
+      </plugin>
  156
+      <plugin>
  157
+        <groupId>org.mortbay.jetty</groupId>
  158
+        <artifactId>jetty-maven-plugin</artifactId>
  159
+        <dependencies>          
  160
+          <dependency>
  161
+            <groupId>org.apache.derby</groupId>
  162
+            <artifactId>derby</artifactId>
  163
+            <version>${derby.version}</version>
  164
+          </dependency>
  165
+          <dependency>
  166
+            <groupId>commons-dbcp</groupId>
  167
+            <artifactId>commons-dbcp</artifactId>
  168
+            <version>${dbcp.version}</version>
  169
+          </dependency>
  170
+          <dependency>
  171
+            <groupId>net.lshift.javamail</groupId>
  172
+            <artifactId>javamail-file-transport</artifactId>
  173
+            <version>0.8-SNAPSHOT</version>
  174
+          </dependency>
  175
+        </dependencies>
  176
+
  177
+        <configuration>
  178
+          <useTestClasspath>true</useTestClasspath>
  179
+          <systemProperties>
  180
+            <systemProperty>
  181
+              <name>JETTY_NO_SHUTDOWN_HOOK</name>
  182
+              <value>true</value>
  183
+            </systemProperty>
  184
+            <systemProperty>
  185
+              <name>basedir</name>
  186
+              <value>${basedir}</value>
  187
+            </systemProperty>
  188
+            <systemProperty>
  189
+              <name>diffa.maildir</name>
  190
+              <value>${basedir}/target/messages</value>
  191
+            </systemProperty>
  192
+          </systemProperties>
  193
+          <connectors>
  194
+            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
  195
+              <port>19093</port>
  196
+              <maxIdleTime>60000</maxIdleTime>
  197
+            </connector>
  198
+          </connectors>
  199
+          <scanIntervalSeconds>600</scanIntervalSeconds>
  200
+          <stopKey>foo</stopKey>
  201
+          <stopPort>19094</stopPort>
  202
+          <jettyConfig>${basedir}/src/test/conf/jetty.xml</jettyConfig>
  203
+          <webAppXml>${basedir}/src/test/conf/jetty-env.xml</webAppXml>
  204
+          <webAppConfig>
  205
+            <contextPath>/diffa-agent</contextPath>
  206
+          </webAppConfig>
  207
+        </configuration>
  208
+        <executions>
  209
+          <execution>
  210
+            <id>start-jetty</id>
  211
+            <phase>pre-integration-test</phase>
  212
+            <goals>
  213
+              <goal>run</goal>
  214
+            </goals>
  215
+            <configuration>
  216
+              <scanIntervalSeconds>0</scanIntervalSeconds>
  217
+              <daemon>true</daemon>
  218
+            </configuration>
  219
+          </execution>
  220
+          <execution>
  221
+            <id>stop-jetty</id>
  222
+            <phase>post-integration-test</phase>
  223
+            <goals>
  224
+              <goal>stop</goal>
  225
+            </goals>
  226
+          </execution>
  227
+        </executions>
  228
+      </plugin>
  229
+      <plugin>
  230
+        <artifactId>maven-surefire-plugin</artifactId>
  231
+        <configuration>
  232
+          <!--<forkMode>never</forkMode>-->
  233
+          <excludes>
  234
+            <exclude>**/itest/**</exclude>
  235
+          </excludes>
  236
+        </configuration>
  237
+        <executions>
  238
+          <execution>
  239
+            <id>surefire-itest</id>
  240
+            <phase>integration-test</phase>
  241
+            <goals>
  242
+              <goal>test</goal>
  243
+            </goals>
  244
+            <configuration>
  245
+              <excludes>
  246
+                <exclude>none</exclude>
  247
+              </excludes>
  248
+              <includes>
  249
+                <include>**/itest/**/*Test.class</include>
  250
+              </includes>
  251
+              <systemPropertyVariables>
  252
+                <diffa.maildir>${basedir}/target/messages</diffa.maildir>
  253
+              </systemPropertyVariables>
  254
+            </configuration>
  255
+          </execution>
  256
+        </executions>
  257
+      </plugin>
  258
+      <plugin>
  259
+        <groupId>org.moyrax.qunit</groupId>
  260
+        <artifactId>qunit-maven-plugin</artifactId>
  261
+        <version>1.2.4.2</version>
  262
+
  263
+        <executions>
  264
+          <execution>
  265
+            <phase>integration-test</phase>
  266
+            <goals>
  267
+              <goal>test</goal>
  268
+            </goals>
  269
+          </execution>
  270
+        </executions>
  271
+
  272
+        <configuration>
  273
+          <contextPath>
  274
+            <entry>
  275
+              <files>
  276
+                <directory>${basedir}/src/test/js-client</directory>
  277
+              </files>
  278
+            </entry>
  279
+          </contextPath>
  280
+
  281
+          <remoteTestResources>
  282
+            <baseUrl>http://localhost:19093/js-tests/</baseUrl>
  283
+            <urlFiles>
  284
+              <urlFile>crud-test.html</urlFile>
  285
+            </urlFiles>
  286
+          </remoteTestResources>
  287
+        </configuration>
  288
+      </plugin>
  289
+      <plugin>
  290
+        <groupId>net.lshift.diffa</groupId>
  291
+        <artifactId>diffa-docgen-maven-plugin</artifactId>
  292
+        <configuration>
  293
+          <templateDir>${basedir}/src/main/resources/docgen/md</templateDir>
  294
+          <examplesFactoryClass>net.lshift.diffa.kernel.util.DocExamplesFactory</examplesFactoryClass>
  295
+          <resources>
  296
+            <resource>net.lshift.diffa.agent.rest.ConfigurationResource</resource>
  297
+            <resource>net.lshift.diffa.agent.rest.DifferencesResource</resource>
  298
+            <resource>net.lshift.diffa.agent.rest.ActionsResource</resource>
  299
+            <resource>net.lshift.diffa.agent.rest.UsersResource</resource>
  300
+          </resources>
  301
+          <targetDir>${docs.targetDir}</targetDir>
  302
+          <consoleOutput>false</consoleOutput>
  303
+        </configuration>
  304
+        <executions>
  305
+          <execution>
  306
+            <phase>process-classes</phase>
  307
+            <goals>
  308
+              <goal>generate-docs</goal>
  309
+            </goals>
  310
+          </execution>
  311
+        </executions>
  312
+      </plugin>
  313
+    </plugins>
  314
+  </build>
  315
+  <reporting>
  316
+    <plugins>
  317
+      <plugin>
  318
+        <groupId>org.scala-tools</groupId>
  319
+        <artifactId>maven-scala-plugin</artifactId>
  320
+        <configuration>
  321
+          <scalaVersion>${scala.version}</scalaVersion>
  322
+        </configuration>
  323
+      </plugin>
  324
+    </plugins>
  325
+  </reporting>
  326
+  <properties>
  327
+    <docs.targetDir>${project.build.directory}/rest-docs</docs.targetDir>
  328
+  </properties>
  329
+</project>
  330
+
20  agent/src/main/resources/diffa.properties
... ...
@@ -0,0 +1,20 @@
  1
+#
  2
+# Copyright (C) 2010 LShift Ltd.
  3
+#
  4
+# Licensed under the Apache License, Version 2.0 (the "License");
  5
+# you may not use this file except in compliance with the License.
  6
+# You may obtain a copy of the License at
  7
+#
  8
+#         http://www.apache.org/licenses/LICENSE-2.0
  9
+#
  10
+# Unless required by applicable law or agreed to in writing, software
  11
+# distributed under the License is distributed on an "AS IS" BASIS,
  12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+# See the License for the specific language governing permissions and
  14
+# limitations under the License.
  15
+#
  16
+
  17
+diffa.host=localhost
  18
+diffa.port=19093
  19
+
  20
+event.notifier.quiet.time=30
18  agent/src/main/resources/docgen/md/rest_collections.st
... ...
@@ -0,0 +1,18 @@
  1
+---
  2
+title: REST API Documentation
  3
+layout: default
  4
+---
  5
+
  6
+REST API Documentation
  7
+======================
  8
+
  9
+<div id="collections" markdown="1">
  10
+$collections: { coll |
  11
+$coll.className$
  12
+-----------
  13
+
  14
+$coll.resources: { res |
  15
+* [$res.method$ $res.nicePath$]($res.docPath$)
  16
+}$
  17
+}$
  18
+</div>
13  agent/src/main/resources/docgen/md/rest_menu.st
... ...
@@ -0,0 +1,13 @@
  1
+Contents
  2
+--------
  3
+
  4
+$collections: { coll |
  5
+### $coll.className$$\n$
  6
+$coll.resources: { res |
  7
+$if(res.active)$
  8
+* $res.method$ $res.nicePath$$\n$$! currently selected !$
  9
+$else$
  10
+* [$res.method$ $res.nicePath$]($basePath$/$res.docPath$)$\n$
  11
+$endif$
  12
+}$
  13
+}$
61  agent/src/main/resources/docgen/md/rest_resource.st
... ...
@@ -0,0 +1,61 @@
  1
+---
  2
+title: $resource.method$ $resource.nicePath$ | REST API Documentation
  3
+layout: default
  4
+---
  5
+
  6
+<div id="menu" markdown="1">
  7
+$rest_menu()$
  8
+</div>
  9
+
  10
+<div id="resources" markdown="1">
  11
+$resource.method$ $resource.nicePath$
  12
+=======================================================
  13
+
  14
+<em>$resource.description$</em>
  15
+
  16
+Entity Type
  17
+-----------
  18
+$resource.entityName$
  19
+
  20
+URL
  21
+---
  22
+http://server:port/diffa-agent/rest/$resource.nicePath$
  23
+
  24
+$if(resource.mandatoryParameters)$ 
  25
+Mandatory Parameters
  26
+--------------------
  27
+$resource.mandatoryParameters: { p |
  28
+
  29
+### $p.name$
  30
+
  31
+*$p.datatype$*
  32
+
  33
+$p.description$
  34
+}$
  35
+$endif$
  36
+
  37
+$if(resource.optionalParameters)$ 
  38
+Optional Parameters
  39
+-------------------
  40
+$resource.optionalParameters: { p |
  41
+
  42
+### $p.name$
  43
+
  44
+*$p.datatype$*
  45
+
  46
+$p.description$
  47
+}$
  48
+$endif$
  49
+
  50
+Requires Authentication
  51
+-----------------------
  52
+no $! TODO Make dynamic !$
  53
+
  54
+Example
  55
+-------
  56
+``$resource.example$ ``
  57
+
  58
+JSON Schema
  59
+-----------
  60
+``$resource.schema$ ``
  61
+</div>
34  agent/src/main/resources/logback.xml
... ...
@@ -0,0 +1,34 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<!--
  3
+
  4
+    Copyright (C) 2010 LShift Ltd.
  5
+
  6
+    Licensed under the Apache License, Version 2.0 (the "License");
  7
+    you may not use this file except in compliance with the License.
  8
+    You may obtain a copy of the License at
  9
+
  10
+            http://www.apache.org/licenses/LICENSE-2.0
  11
+
  12
+    Unless required by applicable law or agreed to in writing, software
  13
+    distributed under the License is distributed on an "AS IS" BASIS,
  14
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15
+    See the License for the specific language governing permissions and
  16
+    limitations under the License.
  17
+
  18
+-->
  19
+
  20
+<configuration>
  21
+
  22
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  23
+    <layout class="ch.qos.logback.classic.PatternLayout">
  24
+      <Pattern>%d{HH:mm:ss.SSS} [%thread] %file:%line - %msg%n</Pattern>
  25
+    </layout>
  26
+  </appender>
  27
+
  28
+  <logger name="org.hibernate" level="WARN" />
  29
+
  30
+  <root level="debug">
  31
+    <appender-ref ref="STDOUT" />
  32
+  </root>
  33
+  
  34
+</configuration>
9  agent/src/main/resources/notifications/mail_body.st
... ...
@@ -0,0 +1,9 @@
  1
+You are receiving this mail because a conflict has occurred:
  2
+
  3
+Pairing:        $pairKey$
  4
+Id:             $entityId$
  5
+Detected At:    $timestamp$
  6
+Upstream:       $upstream$
  7
+Downstream:     $downstream$
  8
+
  9
+Click <a href="$url$">here</a> to see the error in the UI
1  agent/src/main/resources/notifications/mail_subject.st
... ...
@@ -0,0 +1 @@
  1
+Conflict detected for pairing $pairKey$
84  agent/src/main/scala/net/lshift/diffa/agent/http/FrontendRequestHandler.scala
... ...
@@ -0,0 +1,84 @@
  1
+/**
  2
+ * Copyright (C) 2010 LShift Ltd.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *         http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package net.lshift.diffa.agent.http
  18
+
  19
+import org.springframework.web.HttpRequestHandler
  20
+import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
  21
+import org.springframework.http.HttpStatus
  22
+import net.lshift.diffa.kernel.protocol.{TransportResponse, TransportRequest, ProtocolHandler, ProtocolMapper}
  23
+import org.eclipse.jetty.continuation.{ContinuationSupport, Continuation}
  24
+import java.io.OutputStream
  25
+
  26
+/**
  27
+ * Handler for adapting HTTP requests to frontends via protocol handlers.
  28
+ */
  29
+class FrontendRequestHandler(mapper:ProtocolMapper, endpointGroup:String) extends HttpRequestHandler {
  30
+  def handleRequest(request:HttpServletRequest, response:HttpServletResponse) = {
  31
+    val tRequest = new TransportRequest(request.getPathInfo.substring(1), request.getInputStream)
  32
+    val tResponse = new HttpTransportResponse(request, response)
  33
+
  34
+    mapper.lookupHandler(endpointGroup, request.getContentType) match {
  35
+      case Some(handler:ProtocolHandler) =>
  36
+        if (!handler.handleRequest(tRequest, tResponse)) {
  37
+          // Request hasn't finished. Make it asynchronous
  38
+          tResponse.makeAsync
  39
+        }
  40
+      case None =>
  41
+        response.setStatus(HttpStatus.BAD_REQUEST.value)
  42
+        response.getWriter.println("No protocol handlers available for content type")
  43
+    }
  44
+  }
  45
+
  46
+  class HttpTransportResponse(val servletRequest:HttpServletRequest, val servletResponse:HttpServletResponse)
  47
+      extends TransportResponse {
  48
+    var async = false
  49
+
  50
+    val os = servletResponse.getOutputStream
  51
+    def continuation = ContinuationSupport.getContinuation(servletRequest)
  52
+    
  53
+    def setStatusCode(code: Int) = servletResponse.setStatus(code)
  54
+    def withOutputStream(f: (OutputStream) => Unit) = {
  55
+      // If the response is marked as async, then we'll need to resume and suspend a continuation
  56
+      // around it.
  57
+      if (async) {
  58
+        // TODO: Standard Jetty model would have continuation.resume called, which would re-trigger the request
  59
+        //        handling thread with an empty-ish request. This currently breaks the request handler, since
  60
+        //        the post data is null, and therefore the protocol parser crashes out. Turns out that the output
  61
+        //        stream is still valid though, so you can actually write to it from other threads even if you don't
  62
+        //        resume the connection.
  63
+//        continuation.resume
  64
+      }
  65
+      f(os)
  66
+
  67
+      if (async) {
  68
+        os.flush
  69
+
  70
+        // TODO: Unused due to the above comment.
  71
+//        continuation.suspend
  72
+      }
  73
+    }
  74
+
  75
+    def makeAsync {
  76
+      val cont = continuation
  77
+      os.flush
  78
+
  79
+      cont.setTimeout(0)
  80
+      cont.suspend
  81
+      async = true
  82
+    }
  83
+  }
  84
+}
95  agent/src/main/scala/net/lshift/diffa/agent/notifications/SmtpNotifier.scala
... ...
@@ -0,0 +1,95 @@
  1
+/**
  2
+ * Copyright (C) 2010 LShift Ltd.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *         http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package net.lshift.diffa.agent.notifications
  18
+
  19
+import net.lshift.diffa.kernel.config.User
  20
+import net.lshift.diffa.kernel.notifications.{NotificationEvent, NotificationProvider}
  21
+import org.slf4j.{Logger, LoggerFactory}
  22
+import javax.mail.internet.{MimeMessage, InternetAddress}
  23
+import javax.mail.{MessagingException, Message, Session}
  24
+import org.antlr.stringtemplate.StringTemplateGroup
  25
+import java.net.{URISyntaxException, URI}
  26
+
  27
+class SmtpNotifier(val session:Session,
  28
+                   val ctx:String,
  29
+                   val host:String) extends NotificationProvider {
  30
+
  31
+  val log:Logger = LoggerFactory.getLogger(getClass)
  32
+
  33
+  val templateGroup = new StringTemplateGroup("mail")
  34
+  val bodyMaster = templateGroup.getInstanceOf("notifications/mail_body")
  35
+  val subjectMaster = templateGroup.getInstanceOf("notifications/mail_subject")
  36
+
  37
+  var url:String = null
  38
+
  39
+  try {
  40
+    url = new URI("http://" + host + "/" + ctx).toString    
  41
+  }
  42
+  catch {
  43
+    case e:URISyntaxException => log.error("Could not setup link, host = " + host + "; ctx = " + ctx)
  44
+  }
  45
+
  46
+  log.info("Setting the notification URL to: " + url)
  47
+
  48
+
  49
+  def notify(event:NotificationEvent, user:User) = {
  50
+    log.debug("Sending notification about " + event + " to " + user)
  51
+    try {
  52
+
  53
+      val subject = subjectMaster.getInstanceOf
  54
+      subject.setAttribute("pairKey", event.id.pairKey)
  55
+
  56
+      val body = bodyMaster.getInstanceOf
  57
+      body.setAttribute("pairKey", event.id.pairKey)
  58
+      body.setAttribute("entityId", event.id.id)
  59
+      body.setAttribute("timestamp", event.lastUpdated.toString())
  60
+      body.setAttribute("upstream", event.upstreamVsn)
  61
+      body.setAttribute("downstream", event.downstreamVsn)
  62
+      body.setAttribute("url", url)
  63
+
  64
+      var to = new InternetAddress(user.email)
  65
+
  66
+      val message = new MimeMessage(session)
  67
+      message.addRecipient(Message.RecipientType.TO, to)
  68
+      message.setSubject(subject.toString)
  69
+      message.setText(body.toString)
  70
+
  71
+      session.getTransport.sendMessage(message, message.getAllRecipients)
  72
+    }
  73
+    catch {
  74
+      case m:MessagingException => {
  75
+        log.error("SMTP error: " + m.getMessage)
  76
+      }
  77
+      case n:NoSuchFieldException => {
  78
+        log.error("ST error: " + n.getMessage)
  79
+        val clazz = classOf[NotificationEvent]
  80
+        try {
  81
+          val field = clazz.getField("id")
  82
+        }
  83
+        catch {
  84
+          case e:Exception => {
  85
+            log.error("What is going on here?", e)        
  86
+          }
  87
+        }
  88
+      }
  89
+      case e:Exception => {
  90
+        log.error("Unknown error", e)        
  91
+      }
  92
+    }
  93
+  }
  94
+
  95
+}
80  agent/src/main/scala/net/lshift/diffa/agent/rest/AbstractRestResource.scala
... ...
@@ -0,0 +1,80 @@
  1
+/**
  2
+ * Copyright (C) 2010 LShift Ltd.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *         http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package net.lshift.diffa.agent.rest
  18
+
  19
+import javax.ws.rs.WebApplicationException
  20
+import javax.ws.rs.core.{Context, UriInfo, Response}
  21
+import org.slf4j.{Logger, LoggerFactory}
  22
+import net.lshift.diffa.kernel.util.MissingObjectException
  23
+
  24
+abstract class AbstractRestResource {
  25
+
  26
+  private val log:Logger = LoggerFactory.getLogger(getClass)
  27
+
  28
+  @Context var uriInfo:UriInfo = null
  29
+
  30
+  def maybe[T](f: String => T, key:String) = {
  31
+    try {
  32
+      f(key)
  33
+    }
  34
+    catch {
  35
+      case e:MissingObjectException => {
  36
+        log.debug("Attempt to perform an operation with a non-existent key:" + key)
  37
+        throw new WebApplicationException(404)
  38
+      }
  39
+    }
  40
+  }
  41
+
  42
+  def maybe[T](f: Seq[String] => T, keys:Seq[String]) = {
  43
+    try {
  44
+      f(keys)
  45
+    }