- 浏览: 184398 次
- 性别:
- 来自: 北京
最新评论
-
angjunwen:
^[1-9]\d*|0$ 这个能处理小数吗?
ruby on rails 常用正则表达式 -
hot88zh:
Hooopo 写道为什么这么多踩的呢 呃。。还真是,你不说我都 ...
Ruby如何用Oauth与第三方网站互动 -
Hooopo:
为什么这么多踩的呢
Ruby如何用Oauth与第三方网站互动 -
robbinwork:
顶
改良程序的11技巧 -
rogerer:
请问ROR上传大文件,怎么解决内存占用问题:1. lightt ...
查询rails的API
Introduction
Now that the OpenSocial REST API and the Shindig implementation is stabilizing, we can finalize the SocialSite REST API – which is OpenSocial plus our extensions that support friending, groups, enchanced search and gadget management. This proposal presents a way to do that.
Currently, our SocialSite extensions are implemented in an adhoc fashion: a simple Servlet that parses the incoming URL and uses a large and unweildy if-else statement to decide which POJOs to create, retrieve, update or delete and to return JSON data. Only JSON is supported, unlike OpenSocial APIs which support JSON, XML and Atom. On the client-side, the SocialSite JavaScript API is different from the OpenSocial web services in many ways and does not use the Shindig infrastructure for supporting batching of calls.
Benefits
By abandoning our adhoc implementation and instead implementing our web services via Shindig ~DataRequestHandlers on the server-side and using standard OpenSocial request facilities the server-side we get these benefits:
- Support for OpenSocial style REST and JSON-RPC on the server-side
- Support for JSON-RPC batching of requests on client-side
- Comply with OpenSocial requirements for extensions
The rest of this document presents a design for our new web services in terms of URIs and HTTP actions/verbs POST, GET, PUT and DELETE as well as notes on how to implement these new web services using the framework provided by Shindig.
References
The proposal is based on these specifications and codebases:
- OpenSocial REST API - http://docs.google.com/View?docid=dcc2jvzt_37hdzwkmf8
- OpenSocial JSON-RPC API - http://docs.google.com/View?docid=dhjrqr8t_4cwzqq7gh
- Apache Shindig (incubating) - trunk rev. 694454
- http://code.google.com/p/opensocial-resources/wiki/ComplianceTests
- http://markmail.org/message/uxnpq36dgdz7lj6h - John Panzer's notes on RESTful approach to friending
The REST API handlers and URIs
On the server-side, each URI root such as '/people' or '/activities' is handled by a ~DataRequestHandler with methods for POST, GET, PUT and DELETE. These methods accept and return Java beans and Shindig specific collection classes that hold Java beans. Shindig takes care of converting POJOS to and from XML, Atom and JSON formats.
Note that, though we are talking about REST and URIs and HTTP verbs, these same handlers are used for JSON-RPC implementation and by implementing them we get support for both REST and JSON-RPC interaction -- all taken care of by Shinding.
This section lays out the SocialSite extensions to OpenSocial by explaining each of the handlers that we will implement or modify to add the URIs and actions we need.
PersonHandlerImpl
We will extend the Shindig PersonHandlerImpl, which supports the '/people' APIs discussed in the. We will add support for the new URIs and actions below.
POJO type: returns and accepts Profiles
/people/@all [?search={searchString}] GET - get all people /people/{userId}/{groupId} GET - members of a group /people/{userId}/@union/{groupId1}/{groupId2} GET - union of members in two groups
To create a friend connection, you post a Profile representation of the person you wish to friend to your friends collection:
/people/{yourUserId}/@friends
To get a list of people who have invited you to be a friend, do a get on:
/people/{yourUserId}/@requests
To accept a friendship, post a Profile representation of the requesting person to your friend collection:
/people/{yourUserId}/@friends
To ignore a friendship, do a delete on:
/people/{yourUserId}/@requests/{userId}
GroupDefinitionHandler
POJO type: returns GroupDefinition
/groupdef GET - get group definition
GroupHandler
POJO type: Returns and accepts Groups
Types of groups:
- Public: visible to all, anybody can ask to join
- Closed: not visible to all, join by invitation only
- Private: visible to only one user who can add/remove folks as needed
NOTE that we will implement only public groups for October milestone
/groups/@public [?search={searchString}] GET - get list of all public groups defined in system POST - create a new public group /groups/@public/{groupId} GET - get public group PUT - update a public group that you are the admin of DELETE - delete a public group that you are the admin of /groups/{userId} GET - get list all groups (public, private and closed) associated with a user /groups/{userId}/@friends GET - get list of groups (public, private and closed) that friends belong to
GroupMemberHandler
POJO type: returns and accepts Profiles
Do this inside the people handler!
/members/{groupId} GET - get list of members in group POST - add a new member to the group /members/{groupId}/{userId} PUT - update a member in group DELETE - delete a member in group
To ask to join a group, post a sufficient Profile representation of yourself to:
/members/{groupId}
To get a list of incoming group membership requests:
/members/@requests
To accept an incoming group request, post sufficient Group representation to:
/members/{groupId}
To reject an incoming group request, do a delete on the request:
/members/{groupId}/@requests/{userId}
MessageHandler
POJO type: Returns and accepts MessageContents
/messages/{userId}/outbox POST - create a new message, recipient(s) should be specified in content GET - get sent messages for user [added by Bobby] /messages/{userId}/inbox GET - get messages for user /messages/{userId}/inbox/{messageId} GET - get individual message PUT - update message for user (i.e. mark it as read) DELETE - delete a message
SearchHandler
POJO type: Returns SearchResults
/search/{searchString} GET - get combined search results
GadgetHandler
POJO type: Returns and accepts InstalledGadgets
/gadgets/@all [?search={searchString}] GET - all gadgets known to system, with optional search string /gadgets/@user/{userId} - [?destination={destinationId}] GET - all user's installed gadgets /gadgets/@user/{userId} POST - install a gadget for user (destination specified in content) /gadgets/@group/{groupId} - [?destination={destinationId}] GET - all group's installed gadgets /gadgets/@group/{groupId} POST - install a gadget for group (destination specified in content)
Implementing the SocialSite extensions
For each handler you implement:
On the server-side
Define a POJO to represent the data item handled
Define a simple POJO to represent that type and provide a way to serialize and de-serialize the POJO to XML and JSON. Shindig expects us to return POJO objects, which Shindig will automatically convert to either JSON or XML, depending on what was requested.
In some cases, we can use our existing POJOs for this -- but I expect that some of our POJOs expose more information than we want to return to the client. In those cases, we might have to develop simple wrapper POJOs that expose just the things we want.
Implement the DataRequestHandler interface
Implement the get(), post(), put() and delete() methods as needed. Define a URI parsing template that can be applied to incoming RequestItems, use the RequestItem to get data from the request in the form of POJOs. See our existing handler implementationsfor examples.
Add your handler to those in CustomHandlerProvider
Guice is used to inject handlers into the Shindig Servlet, so you will need to add your handlers to our CustomHandlerProvider.
On the client side
Define JavaScript object to match your POJO
Define a JavaScript object to match your Java POJO and code thatcan construct this from JSON data. See sectionprivacy.js for an example of how to do this.
Define JavaScript request methods to support your handler
Define JavaScript methods to create needed requests and process the responses. If you support full CRUD for your data type then you'll need four methods like so (see socialsite.js for examples):
- socialsite.newCreateXXXRequest()
- socialsite.newFetchXXXRequest()
- socialsite.newUpdateXXXRequest()
- socialsite.newDeleteXXXRequest()
Modify your Gadgets to use the new APIs
Modify your existing SocialSite Gadgets to use your new methods instead of the old deprecated JS APIs.
Clean up
Delete your old and no longer needed code from the SocialSiteGadgetDataServlet and socialsite.js.
Appendix A: Mapping the old REST API to the new
This section lists URI patterns from the old REST API and, in highlights, explains which parts of the new REST API to use instead.
Profiles
/profiles getOnProfilesUrl DONE /profiles/{ownerId} getOnProfilesAndOwnerUrl putOnProfileUrl DONE /allprofiles getOnAllProfilesUrl Use PersonHandlerImpl /people/@all instead /profiles/{ownerId}/friendsgroups getOnFriendsGroupsUrl - returns - Collection of Groups POJOs in JSON form Use GroupHandler /groups/@friends insead /profiles/{ownerId}/request/{friendId} putOnRequestFriendUrl use POST to /people/{userId}/@friends /profiles/{ownerId}/accept/{friendId} putOnAcceptFriendUrl use POST to /people/{userId}/@friends instead /profiles/{ownerId}/reject/{friendId} See notes above
Groups
/groups getOnGroupsUrl - returns - GroupDefinition in JSON form Use GroupDefinitionHandler /groupdef instead /groups/{groupHandle} getOnGroupsAndGroupIdUrl - returns - Group POJO in JSON form putOnGroupUrl - updates - Group POJO from JSON data Use GroupHandler and /groups/@public and /groups/@public/{groupId} instead /groups/{groupHandle}/members getOnGroupMembersGroupsUrl - returns - Group POJOs Use PersonHandlerImpl /people/{userId}/{groupId} instead /groups/{groupHandle1}/{groupHandle2} getOnCommonGroupMembersUrl - Group POJOs Use PersonHandlerImpl /people/{userId}/@union/{groupId1}/{groupId2} instead /groups/{groupHandle}/activities getOnGroupActivities - Activity POJOs Use standard OpenSocial /activities/{userId}/{groupId} instead /groups/{groupHandle}/myfriends/{ownerId} getMyFriendsInGroupUrl - returns - Profile POJOs Use standard OpenSocial /people/{userId}/{groupId} instead /groups/{groupHandle}/admin/{ownerId} getOnGroupAdminsUrl - returns - type value of MEMBER or ADMIN Instead, use a field in the group to indicate user's standing /currentgroup getOnCurrentGroupUrl - Group POJO for current group Instead, passing groupId to gadget and get group by ID /mygroups getOnMyGroupsUrl - returns - Group POJOs Use standard OpenSocial API instead /groups/{userId} /mygroups/add/{ownerId} putOnAddRemoveGroupUrl Instead, use POST to /members/{groupId} /mygroups/remove/{ownerId} putOnAddRemoveGroupUrl Instead, use DELETE on /members/{groupId}/{userId} /allgroups getOnAllGroupsUrl Use /groups/@public instead /groups/{groupHandle}/create/{ownerId} putOnCreateGroup Use POST to /groups/@public instead /groups/{groupHandle}/invite/{ownerId} putOnInviteFriendToGroupUrl Use POST to /members/{groupId} instead /groups/{groupHande}/{ownerId}/accept/{memberId} putOnAcceptGroupMemberUrl See notes above on joining groups /groups/{groupHande}/{ownerId}/reject/{memberId} putOnRejectGroupMemberUrl See notes above on joining groups
Notifications
/notifications/{ownerId} getOnNotificationsAndOwnerUrl Use GET on /messages/{userId}/inbox instead /notifications/id/{notficationId} getOnNotificationId Use GET on /message/{userId}/inbox/{messageId} instead /notifications/person/{fromId}/{toId}/{subject} putOnMessageToPersonUrl Use POST to /messages/{userId}/outbox with person recipient in data instead /notifications/group/{fromId}/{toId}/{subject} putOnMessageToGroupUrl Use POST to /messages/{userId}/outbox with group recipient in data instead /notifications/id deleteOnNotificationUrl Use GET on /message/{userId}/inbox/{messageId} instead
Search
/search/{searchString} getOnSearch Use SearchHandler instead with same URL /search/profile/{searchString} getOnProfileSearch Use PersonHandler and /people/@all [?search={searchString}] instead /search/group/{searchString} getOnGroupSearch Use GroupHandler and /groups/@public [?search={searchString}] instead /search/gadget/{searchString} getOnGadgetSearch Use GadgetHandler and /gadgets [?search={searchString}] instead
Gadgets
/installedgadgets/user/{ownerId}/{destination} putOnCreateInstalledGadgetForUser Use POST to /gadgets/@user/{userId} instead /installedgadgets/group/{groupId}/{destination} putOnCreateInstalledGadgetForGroup Use POST /gadgets/@group/{groupId} instead /installedgadgets/id deleteOnInstalledGadgetUrl Use DELETE on either /gadgets/@user/{userId}/{gadgetId} or the group equivalent
发表评论
-
linux下进入rails console提示cannot load such file -- readline
2011-12-17 20:38 2809在linux下输入rails console,之后提示错误,如 ... -
在Windows7中编译Mysql2的GEM
2011-11-08 15:47 0If you still want to force t ... -
CentOS用gem安装Mysql2提示缺少mysql.h
2011-08-30 12:17 2892环境: CentOS6 Ruby1.9.2 Rails3.0. ... -
Rake提示uninitialized constant Rake::DSL解决办法
2011-06-20 00:09 3709环境:Ruby 1.9.1/Rails 3.0.9/Rake ... -
Debian5安装Thin时候出现no such file to load -- openssl
2011-04-19 22:38 1134今天在执行thin install的时候,出现no such ... -
oauth GEM的几个小例子
2011-03-22 08:32 15981、注册并认证你的应用 #!/usr/bin/r ... -
Ruby如何用Oauth与第三方网站互动
2011-03-13 12:25 2087首先是介绍一下这个gem:oauth 项目首页是:http: ... -
升级gem提示缺少no such file to load zlib
2011-02-20 01:16 1368升级gem提示 no such file to load zl ... -
使用Ruby解析图片EXIF数据获取坐标信息
2011-01-10 08:32 1822最近在做一个项目时需要将图片EXIF信息解析出来并获取相应 ... -
Paperclip提示command is not recognized by the 'identify
2011-01-05 00:43 2312用Paperclip来裁减图片,会提示如下错误: /tmp/ ... -
在Debian上部署Ruby On Rails应用(续)
2011-01-05 00:36 1279写在前面: 其实这个续应该和前面那个部署的文章互换一下顺序… ... -
Ruby1.9.2+Rails3.0.3迁移文件中加索引出错的解决办法
2011-01-03 23:53 1555环境: Ruby1.9.2 Rails3.0.3 Gem ... -
rails3使用declarative_authorization注意事项
2010-11-17 17:32 1238Rails3中把declarative_authorizati ... -
rails3使用restful-authentication
2010-11-09 14:01 2041首先要下载支持Rails3的restful-authentic ... -
Ubuntu安装Mysql Gem
2010-11-03 14:49 1328在安装过程中出现如下错误: Building native e ... -
如何寫出有效率的 Ruby Code
2010-09-28 22:44 1026Instance Variables versus Acces ... -
Rails Migration Data Types – MySql – Postgresql – SQLite
2010-06-04 19:09 1229Rails mysql post ... -
request.env
2009-11-11 13:16 1161@client_ip = request.env[" ... -
Active Record Validations and Callbacks
2009-11-08 22:39 2051有许多种在保存数据到 ... -
Ruby on Rails 的检验方法(Validation Helpers)大全
2009-11-06 12:07 1444可以自定义validate(), 这个方法在每次保存数据时都会 ...
相关推荐
### AES Proposal: Rijndael – 关键知识点详解 #### 一、引言与背景 AES(Advanced Encryption Standard,高级加密标准)是目前最广泛使用的对称加密算法之一,它被设计用于保护敏感数据免受未经授权的访问。AES ...
开源项目-golang-go.zip,proposal: add typed enum support · Issue #19814 · golang/go
【标题】"quantumguys_proposal:拟议的量子论网站" 提示我们这是一个关于量子理论的在线平台的提议。这个项目可能旨在提供量子物理的学习资源、互动体验或者相关研究的信息分享。作为这样一个网站的核心技术,我们...
《yearn-aave-proposal:yearn的arcaip——深入理解智能合约与DeFi生态》 在区块链技术的快速发展中,去中心化金融(DeFi)已成为一个炙手可热的话题,其中yearn.finance(简称yearn)和Aave是两个极具影响力的项目...
建议书 该提议基于Martin Odersky的,并试图解决功能性编程Scala社区的一些已知缺点。 因此,该提议的理由应与原始提议相同。 基本原理 有两种主要的Scala程序结构样式:标准(面向对象)类层次结构或使用隐式参数...
数据学院数据记者的R课程 在这个项目中,我们希望为记者和数据记者...devtools::install_github("school-of-data/r-consortium-proposal", subdir="r-package") learnr::run_tutorial("en-recipe-template", packag
关于 这是一份正在进行中的 2 页研究提案,用于我独立的博士后奖学金申请。 有关我为什么要这样做的更多信息,请访问我博客上的相关帖子: 想看看 PDF 版本吗? 您可以从以下链接找到最新编译的 PDF: ...
r-hub :R社区需要的一切建设者 GáborCsárdi,基于先前版本的作者:JJ Allaire(RStudio),Ben Bolker(麦克马斯特大学)Dirk Eddelbuettel(Debian),Jay Emerson(耶鲁大学),Nicholas Lewin-Koh(基因技术)...
输出 pdf_document 默认 R的数量 ,阿图罗·阿苏科拉。 西班牙马德里卡洛斯三世大学信息通信工程系。 支持作者: 。 德国明斯特大学地理信息研究所。...数量是“现象,物体或物质的属性,其中属性的大小可以表示为...
Node.js中ES模块的适度建议指导原则该解决方案必须100%向后兼容。 将来,开发人员应该能够在不了解CommonJS模块系统的情况下编写Node程序和库。... Web浏览器使用的默认解析算法不会自动附加文件扩展名
然而,正如“nix-error-proposal”项目所指出的,Nix在处理错误时可能不够直观或用户友好,这给开发者带来了困扰。这个提案旨在改善Nix的错误处理机制,以提升用户体验。 首先,我们要理解Nix错误处理的现状。当Nix...
LaTeX DFG模板 上次更新时间:2021年3月 基本DFG(德国研究基金会,德国研究基金会)拨款提案的LaTeX模板。 注意:您需要pdflatex和biber (不是bibtex )来编译文档。 致谢 这个模板是基于模板和基于RTF的 ,在2020...
gRPC RFC 介绍 在继续之前,请阅读gRPC组织的和。 此存储库包含有关gRPC实质性功能更改的设计建议,这些更改需要预先设计。 前期设计过程的目标是: 为社区提供有关即将发生的更改以及围绕它们的设计注意事项的更...
提出变更建议介绍Go项目的开发过程是设计驱动的。 在对语言,库或工具进行重大更改之前,必须先进行讨论,有时甚至要正式记录下来,然后才能实施。 本文档介绍了对Go项目进行提议,记录和实施更改的过程。...
curl -L https://github.com/yuki-kimoto/mop-minus-proposal/archive/master.tar.gz > mop-minus-master.tar.gz cpanm mop-minus-master.tar.gz 例子 # Point.pm package Point { use mop::minus; has x = 0; ...
阅读整个proposal.pdf文件。 直接修正错别字。 在您的姓名首字母中查找WRITE HERE注释,然后实施它们。 在邮件列表上评论其他建议。 作为工作包的负责人 编辑文件WorkPackages / <WorkPackageName> .tex。 有关更...
毕业设计视频会议源码GSoC-20-提案 在 Tensorflow Graphics 中实现 Mesh RCNN 联系信息 姓名:马达夫·艾扬格大学 : 电子邮件ID ...它能够通过查看相应的无约束现实生活图像(具有多个对象、遮挡、不同的照明)来预测...
建议书 ARnft框架折射
这是在NeurIPS 2020上针对预测深度学习挑战的入门套件开发的。 先决条件: 的Python 3.6.6 Tensorflow 2.2 大熊猫pyyaml scikit学习我提出的算法的主要代码可以在baselines / proposed_complexity中查看用法: (1)...
非科班出身程序员刷题开放计算教育 使最佳实践成为普遍实践 埃文科尔 顾问:Benoît Vanderose & Bruno Dumas 2020 年 ...已经为新手程序员开发了许多很棒的资源、课程、工具和学习环境。...这可以说是最大的编程学生群体...