PageRenderTime 543ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/dumbhippo/branches/cluster/server/src/com/dumbhippo/server/HttpMethods.java

https://gitlab.com/manoj-makkuboy/magnetism
Java | 390 lines | 260 code | 79 blank | 51 comment | 0 complexity | a7c4772eb2b96d0e800991836ef192ee MD5 | raw file
  1. package com.dumbhippo.server;
  2. import java.io.IOException;
  3. import java.io.OutputStream;
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import javax.ejb.Local;
  7. import org.xml.sax.SAXException;
  8. import com.dumbhippo.XmlBuilder;
  9. import com.dumbhippo.identity20.Guid;
  10. import com.dumbhippo.identity20.Guid.ParseException;
  11. import com.dumbhippo.persistence.UserBlockData;
  12. /**
  13. * - Methods must be named getFoo or doFoo
  14. * - the args to a method are: OutputStream,HttpResponseData pair; User
  15. * logged in user; http params
  16. * - the OutputStream,HttpResponseData can be omitted if you only return
  17. * content type NONE
  18. * - if you have the User arg then you require login for the method to work
  19. *
  20. */
  21. @Local
  22. public interface HttpMethods {
  23. @HttpContentTypes(HttpResponseData.XML)
  24. @HttpParams( { "groupId" })
  25. public void getAddableContacts(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String groupId)
  26. throws IOException;
  27. @HttpContentTypes(HttpResponseData.XML)
  28. @HttpParams( { })
  29. public void getContactsAndGroups(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint)
  30. throws IOException;
  31. @HttpContentTypes(HttpResponseData.XML)
  32. @HttpParams( { "email" })
  33. public void doCreateOrGetContact(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String email)
  34. throws IOException;
  35. @HttpContentTypes(HttpResponseData.XML)
  36. @HttpParams( { "name", "members", "secret", "description" })
  37. @HttpOptions( optionalParams = { "members", "description" } )
  38. public void doCreateGroup(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String name, String memberIds, boolean secret, String description)
  39. throws IOException, ParseException, NotFoundException;
  40. @HttpContentTypes(HttpResponseData.XML)
  41. @HttpParams( { "groupId", "members" })
  42. public void doAddMembers(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String groupId, String memberIds)
  43. throws IOException, ParseException, NotFoundException;
  44. @HttpContentTypes(HttpResponseData.XML)
  45. @HttpParams( { "title", "url", "recipients", "description", "isPublic", "postInfoXml" })
  46. @HttpOptions( optionalParams = { "postInfoXml" } )
  47. public void doShareLink(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String title, String url, String recipientIds, String description, boolean isPublic, String postInfoXml) throws ParseException,
  48. NotFoundException, SAXException, MalformedURLException, IOException;
  49. @HttpContentTypes(HttpResponseData.NONE)
  50. @HttpParams( { "groupId", "recipients", "description" })
  51. public void doShareGroup(UserViewpoint viewpoint, String groupId, String recipientIds, String description) throws ParseException,
  52. NotFoundException;
  53. @HttpContentTypes(HttpResponseData.NONE)
  54. @HttpParams( { "name" })
  55. @HttpOptions(invalidatesSession = true)
  56. public void doRenamePerson(UserViewpoint viewpoint, String name);
  57. @HttpContentTypes(HttpResponseData.NONE)
  58. @HttpParams( { "contactId" })
  59. public void doAddContactPerson(UserViewpoint viewpoint, String contactId);
  60. @HttpContentTypes(HttpResponseData.NONE)
  61. @HttpParams( { "contactId" })
  62. public void doRemoveContactPerson(UserViewpoint viewpoint, String contactId);
  63. @HttpContentTypes(HttpResponseData.NONE)
  64. @HttpParams( { "groupId" })
  65. public void doJoinGroup(UserViewpoint viewpoint, String groupId);
  66. @HttpContentTypes(HttpResponseData.NONE)
  67. @HttpParams( { "groupId" })
  68. public void doLeaveGroup(UserViewpoint viewpoint, String groupId);
  69. @HttpContentTypes(HttpResponseData.NONE)
  70. @HttpParams( { "groupId", "name" })
  71. public void doRenameGroup(UserViewpoint viewpoint, String groupId, String name);
  72. @HttpContentTypes(HttpResponseData.NONE)
  73. @HttpParams( { "groupId", "description" })
  74. public void doSetGroupDescription(UserViewpoint viewpoint, String groupId, String name);
  75. @HttpContentTypes(HttpResponseData.NONE)
  76. @HttpParams( { "groupId", "photo" })
  77. public void doSetGroupStockPhoto(UserViewpoint viewpoint, String groupId, String photo);
  78. @HttpContentTypes(HttpResponseData.XML)
  79. @HttpParams( { "email" })
  80. public void doAddContact(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String email) throws IOException;
  81. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  82. @HttpParams( { "address" })
  83. public void doSendLoginLinkEmail(XmlBuilder xml, String address) throws IOException, HumanVisibleException;
  84. @HttpContentTypes(HttpResponseData.NONE)
  85. @HttpParams( { "address" })
  86. public void doSendClaimLinkEmail(UserViewpoint viewpoint, String address) throws IOException, HumanVisibleException;
  87. @HttpContentTypes(HttpResponseData.NONE)
  88. @HttpParams( { "address" })
  89. public void doSendClaimLinkAim(UserViewpoint viewpoint, String address) throws IOException, HumanVisibleException;
  90. @HttpContentTypes(HttpResponseData.NONE)
  91. @HttpParams( { "address" })
  92. public void doRemoveClaimEmail(UserViewpoint viewpoint, String address) throws IOException, HumanVisibleException;
  93. @HttpContentTypes(HttpResponseData.NONE)
  94. @HttpParams( { "address" })
  95. public void doRemoveClaimAim(UserViewpoint viewpoint, String address) throws IOException, HumanVisibleException;
  96. @HttpContentTypes(HttpResponseData.NONE)
  97. @HttpParams( { "disabled" })
  98. @HttpOptions( allowDisabledAccount = true )
  99. public void doSetAccountDisabled(UserViewpoint viewpoint, boolean disabled) throws IOException, HumanVisibleException;
  100. @HttpContentTypes(HttpResponseData.NONE)
  101. @HttpParams( { "password" })
  102. public void doSetPassword(UserViewpoint viewpoint, String password) throws IOException, HumanVisibleException;
  103. @HttpContentTypes(HttpResponseData.NONE)
  104. @HttpParams( { "enabled" })
  105. public void doSetMusicSharingEnabled(UserViewpoint viewpoint, boolean enabled) throws IOException;
  106. @HttpContentTypes(HttpResponseData.NONE)
  107. @HttpParams( { "notify" })
  108. public void doSetNotifyPublicShares(UserViewpoint viewpoint, boolean notify) throws IOException;
  109. @HttpContentTypes(HttpResponseData.XML)
  110. @HttpParams( { "who", "theme" })
  111. @HttpOptions( optionalParams = { "theme" } )
  112. public void getNowPlaying(OutputStream out, HttpResponseData contentType, String who, String theme)
  113. throws IOException;
  114. @HttpContentTypes(HttpResponseData.TEXT)
  115. @HttpParams( { "basedOn" })
  116. @HttpOptions( optionalParams = { "basedOn" } )
  117. public void doCreateNewNowPlayingTheme(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String basedOn)
  118. throws IOException;
  119. @HttpContentTypes(HttpResponseData.NONE)
  120. @HttpParams( { "theme" })
  121. public void doSetNowPlayingTheme(UserViewpoint viewpoint, String themeId) throws IOException;
  122. @HttpContentTypes(HttpResponseData.NONE)
  123. @HttpParams( { "theme", "key", "value" })
  124. public void doModifyNowPlayingTheme(UserViewpoint viewpoint, String themeId, String key, String value) throws IOException;
  125. @HttpContentTypes(HttpResponseData.XML)
  126. @HttpParams( { "address", "promotion" })
  127. public void doInviteSelf(OutputStream out, HttpResponseData contentType, String address, String promotion) throws IOException;
  128. @HttpContentTypes(HttpResponseData.XML)
  129. @HttpParams( { "address", "subject", "message", "suggestedGroupIds" })
  130. public void doSendEmailInvitation(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String address, String subject, String message, String suggestedGroupIds) throws IOException;
  131. @HttpContentTypes(HttpResponseData.NONE)
  132. @HttpParams( { "countToInvite", "subject", "message", "suggestedGroupIds" })
  133. @HttpOptions( adminOnly = true )
  134. public void doInviteWantsIn(String countToInvite, String subject, String message, String suggestedGroupIds) throws IOException;
  135. @HttpContentTypes(HttpResponseData.XML)
  136. @HttpParams( { "groupId", "inviteeId", "inviteeAddress", "subject", "message" })
  137. @HttpOptions( optionalParams = { "inviteeId", "inviteeAddress" } )
  138. public void doSendGroupInvitation(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String groupId, String inviteeId, String inviteeAddress, String subject, String message) throws IOException;
  139. @HttpContentTypes(HttpResponseData.NONE)
  140. @HttpParams( { "address", "suggestedGroupIds", "desuggestedGroupIds" })
  141. public void doSuggestGroups(UserViewpoint viewpoint, String address, String suggestedGroupIds, String desuggestedGroupIds);
  142. @HttpContentTypes(HttpResponseData.NONE)
  143. @HttpParams( { "userId" })
  144. public void doSendRepairEmail(UserViewpoint viewpoint, String userId);
  145. @HttpContentTypes(HttpResponseData.NONE)
  146. @HttpParams( {} )
  147. public void doReindexAll(UserViewpoint viewpoint);
  148. @HttpContentTypes(HttpResponseData.NONE)
  149. @HttpParams( { "postId", "favorite" })
  150. public void doSetFavoritePost(UserViewpoint viewpoint, String postId, boolean favorite);
  151. @HttpContentTypes(HttpResponseData.TEXT)
  152. @HttpParams( { })
  153. public void getRandomBio(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint)
  154. throws IOException;
  155. @HttpContentTypes(HttpResponseData.TEXT)
  156. @HttpParams( { })
  157. public void getRandomMusicBio(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint)
  158. throws IOException;
  159. @HttpContentTypes(HttpResponseData.NONE)
  160. @HttpParams( { "bio" })
  161. public void doSetBio(UserViewpoint viewpoint, String bio);
  162. @HttpContentTypes(HttpResponseData.NONE)
  163. @HttpParams( { "musicbio" })
  164. public void doSetMusicBio(UserViewpoint viewpoint, String bio);
  165. @HttpContentTypes(HttpResponseData.NONE)
  166. @HttpParams( { "photo" })
  167. public void doSetStockPhoto(UserViewpoint viewpoint, String photo);
  168. @HttpContentTypes(HttpResponseData.TEXT)
  169. @HttpParams( { "userId", "size" })
  170. public void getUserPhoto(OutputStream out, HttpResponseData contentType, String userId, String size)
  171. throws IOException;
  172. @HttpContentTypes(HttpResponseData.TEXT)
  173. @HttpParams( { "groupId", "size" })
  174. public void getGroupPhoto(OutputStream out, HttpResponseData contentType, String groupId, String size)
  175. throws IOException;
  176. @HttpContentTypes(HttpResponseData.NONE)
  177. @HttpParams( {} )
  178. @HttpOptions( allowDisabledAccount = true )
  179. public void doAcceptTerms(UserViewpoint viewpoint);
  180. @HttpContentTypes(HttpResponseData.NONE)
  181. @HttpParams( { "userId", "disabled" } )
  182. @HttpOptions( adminOnly = true )
  183. public void doSetAdminDisabled(UserViewpoint viewpoint, String userId, boolean disabled);
  184. @HttpContentTypes(HttpResponseData.NONE)
  185. @HttpParams( { "newFeaturesFlag" } )
  186. @HttpOptions( adminOnly = true )
  187. public void doSetNewFeatures(UserViewpoint viewpoint, boolean newFeaturesFlag);
  188. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  189. @HttpParams( { "parseOnly", "command" } )
  190. @HttpOptions( adminOnly = true )
  191. public void doAdminShellExec(XmlBuilder xml, UserViewpoint viewpoint, boolean parseOnly, String command) throws IOException, HumanVisibleException;
  192. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  193. @HttpParams( { "url" })
  194. public void doFeedPreview(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException;
  195. @HttpContentTypes(HttpResponseData.TEXT)
  196. @HttpParams( { "url" })
  197. public void getFeedDump(OutputStream out, HttpResponseData contentType, UserViewpoint viewpoint, String url) throws HumanVisibleException, IOException;
  198. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  199. @HttpParams( { "groupId", "url" })
  200. public void doAddGroupFeed(XmlBuilder xml, UserViewpoint viewpoint, String groupId, String url) throws XmlMethodException;
  201. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  202. @HttpParams( { "groupId", "url" })
  203. public void doRemoveGroupFeed(XmlBuilder xml, UserViewpoint viewpoint, String groupId, String url) throws XmlMethodException;
  204. /**
  205. * Mark an external account as "hated" and give an optional quip about why.
  206. * If the quip is missing or empty it's taken as "delete any quip"
  207. *
  208. * @param xml
  209. * @param viewpoint
  210. * @param type
  211. * @param quip
  212. * @throws XmlMethodException
  213. */
  214. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  215. @HttpParams( { "type", "quip" })
  216. @HttpOptions( optionalParams = { "quip" } )
  217. public void doHateExternalAccount(XmlBuilder xml, UserViewpoint viewpoint, String type, String quip) throws XmlMethodException;
  218. /**
  219. * Mark an external account as "indifferent" which effectively hides both any hate-quip or
  220. * account information from your profile. i.e. this is the same as "removing" an external account.
  221. * We don't really remove it though, i.e. the quip/account-info are remembered in case you
  222. * switch back to those states.
  223. *
  224. * @param xml
  225. * @param viewpoint
  226. * @param type
  227. * @throws XmlMethodException
  228. */
  229. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  230. @HttpParams( { "type" })
  231. public void doRemoveExternalAccount(XmlBuilder xml, UserViewpoint viewpoint, String type) throws XmlMethodException;
  232. /**
  233. * Given an email address, try to lookup the associated flickr account information.
  234. *
  235. * @param xml
  236. * @param viewpoint
  237. * @param email the flickr email address
  238. * @throws XmlMethodException
  239. */
  240. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  241. @HttpParams( { "email" })
  242. public void doFindFlickrAccount(XmlBuilder xml, UserViewpoint viewpoint, String email) throws XmlMethodException;
  243. /**
  244. * Adds a flickr account with the given nsid and Flickr email address. Automatically marks
  245. * Flickr as "loved" instead of "hated"
  246. *
  247. * To get the NSID, you would ask someone for their Flickr email address, then use it to call
  248. * FindFlickrAccount, then you have both email and nsid.
  249. *
  250. * @param xml
  251. * @param viewpoint
  252. * @param nsid
  253. * @param email
  254. * @throws XmlMethodException
  255. */
  256. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  257. @HttpParams( { "nsid", "email" })
  258. public void doSetFlickrAccount(XmlBuilder xml, UserViewpoint viewpoint, String nsid, String email) throws XmlMethodException;
  259. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  260. @HttpParams( { "name" })
  261. public void doSetMySpaceName(XmlBuilder xml, UserViewpoint viewpoint, String name) throws XmlMethodException;
  262. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  263. @HttpParams( { "urlOrName" })
  264. public void doSetLinkedInProfile(XmlBuilder xml, UserViewpoint viewpoint, String urlOrName) throws XmlMethodException;
  265. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  266. @HttpParams( { "urlOrName" })
  267. public void doSetYouTubeName(XmlBuilder xml, UserViewpoint viewpoint, String urlOrName) throws XmlMethodException;
  268. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  269. @HttpParams( { "url" })
  270. public void doSetWebsite(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException;
  271. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  272. @HttpParams( { "url" })
  273. public void doSetRhapsodyHistoryFeed(XmlBuilder xml, UserViewpoint viewpoint, String url) throws XmlMethodException;
  274. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  275. @HttpParams( { "url" })
  276. public void doSetBlog(XmlBuilder xml, UserViewpoint viewpoint, URL url) throws XmlMethodException;
  277. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  278. @HttpParams( { "filename" })
  279. @HttpOptions( optionalParams = { "filename" } )
  280. public void getStatisticsSets(XmlBuilder xml, UserViewpoint viewpoint, String filename) throws IOException, XmlMethodException;
  281. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  282. @HttpParams( { "filename", "columns", "start", "end", "timescale" })
  283. @HttpOptions( optionalParams = { "filename", "start", "end", "timescale" } )
  284. public void getStatistics(XmlBuilder xml, UserViewpoint viewpoint, String filename, String columns, String start, String end, String timescale) throws IOException, XmlMethodException;
  285. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  286. @HttpParams( { "userId", "lastTimestamp", "start", "count" })
  287. @HttpOptions( optionalParams = { "userId" } )
  288. public void getBlocks(XmlBuilder xml, UserViewpoint viewpoint, String userId, String lastTimestamp, String start, String count) throws XmlMethodException;
  289. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  290. @HttpParams( { "blockId" })
  291. public void getBlock(XmlBuilder xml, UserViewpoint viewpoint, UserBlockData block) throws XmlMethodException;
  292. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  293. @HttpParams( { "userId" })
  294. public void getMusicPersonSummary(XmlBuilder xml, UserViewpoint viewpoint, String userId) throws XmlMethodException;
  295. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  296. @HttpParams( { "userId", "accountType" })
  297. public void getExternalAccountSummary(XmlBuilder xml, UserViewpoint viewpoint, String userId, String accountType) throws XmlMethodException, NotFoundException;
  298. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  299. @HttpParams( { "groupId" })
  300. public void getGroupChatSummary(XmlBuilder xml, UserViewpoint viewpoint, String groupId) throws XmlMethodException;
  301. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  302. @HttpParams( { "postId" })
  303. public void getPostSummary(XmlBuilder xml, UserViewpoint viewpoint, String postId) throws XmlMethodException;
  304. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  305. @HttpParams( { "blockId", "hushed" })
  306. public void doSetBlockHushed(XmlBuilder xml, UserViewpoint viewpoint, UserBlockData userBlockData, boolean hushed) throws XmlMethodException;
  307. @HttpContentTypes(HttpResponseData.XMLMETHOD)
  308. @HttpParams( { "fileId" })
  309. @HttpOptions(transaction=false)
  310. public void doDeleteFile(XmlBuilder xml, UserViewpoint viewpoint, Guid fileId) throws XmlMethodException;
  311. }