gpt4 book ai didi

rest - Sakai:如何获得带有 REST 或 WS 接口(interface)的站点(类(class))列表?

转载 作者:行者123 更新时间:2023-12-02 08:35:15 25 4
gpt4 key购买 nike

我正在尝试从外部应用程序与 Sakai 交互,以获取只读类(class)信息(标识符、类(class)名称、描述、讲师等)。它看起来(/direct/site/describe)就像“站点”REST 服务只公开需要您已经拥有类(class) ID 的内容。我在浏览 Sakai 源代码时注意到有一个 SiteService,它有一个名为 getSites() 的方法,它看起来很像我需要的,但是(免责声明)我对 Sakai 几乎一无所知。我只需要这些数据。

我的问题是:这似乎是应该存在的东西,我错过了什么吗?此外,最好的方法是通过自定义服务公开 SiteService getSites 吗?

最佳答案

如果您只想获得 Sakai 安装中每个站点的列表,那么您将不得不构建一些自定义的东西,因为所有站点的完整列表不是典型的用例。通常,应用程序对获取特定用户有权访问的站点列表更感兴趣。例如:

http://nightly2.sakaiproject.org:8081/direct/site.json

将返回当前登录用户的完整列表(可能带有分页)。

{"entityPrefix": "site", "site_collection": [
{
"createdDate": 1401938965607,
"createdTime": {
"display": "Jun 4, 2014 11:29 pm",
"time": 1401938965607
},
"description": null,
"htmlDescription": "",
"htmlShortDescription": "",
"iconUrl": null,
"iconUrlFull": null,
"id": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"infoUrl": null,
"infoUrlFull": null,
"joinerRole": null,
"lastModified": 1401938965993,
"maintainRole": "maintain",
"modifiedDate": 1401938965993,
"modifiedTime": {
"display": "Jun 4, 2014 11:29 pm",
"time": 1401938965993
},
"owner": "admin",
"props": {
"contact-name": "Sakai Administrator"
},
"providerGroupId": null,
"reference": "\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"shortDescription": null,
"siteGroups": null,
"siteOwner": {
"userDisplayName": "Sakai Administrator",
"userEntityURL": "\/direct\/user\/admin",
"userId": "admin"
},
"sitePages": [
{
"id": "e051601e-2162-47c1-9e04-63a033f56cdf",
"layout": 0,
"layoutTitle": "Single Column Layout",
"position": 0,
"props": {
"is_home_page": "true"
},
"reference": "\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/e051601e-2162-47c1-9e04-63a033f56cdf",
"siteId": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"skin": "neo-default",
"title": "Home",
"titleCustom": false,
"url": "http:\/\/nightly2.sakaiproject.org:8081\/portal\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/e051601e-2162-47c1-9e04-63a033f56cdf",
"activeEdit": false,
"popUp": false
},
{
"id": "2e7c2004-0dc2-47bc-8e55-ca1df8e58c33",
"layout": 0,
"layoutTitle": "Single Column Layout",
"position": 1,
"props": null,
"reference": "\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/2e7c2004-0dc2-47bc-8e55-ca1df8e58c33",
"siteId": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"skin": "neo-default",
"title": "Assignments",
"titleCustom": false,
"url": "http:\/\/nightly2.sakaiproject.org:8081\/portal\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/2e7c2004-0dc2-47bc-8e55-ca1df8e58c33",
"activeEdit": false,
"popUp": false
},
{
"id": "332c52a8-89fe-45bb-9b1a-bf6bace3e88a",
"layout": 0,
"layoutTitle": "Single Column Layout",
"position": 2,
"props": null,
"reference": "\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/332c52a8-89fe-45bb-9b1a-bf6bace3e88a",
"siteId": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"skin": "neo-default",
"title": "Site Info",
"titleCustom": false,
"url": "http:\/\/nightly2.sakaiproject.org:8081\/portal\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9\/page\/332c52a8-89fe-45bb-9b1a-bf6bace3e88a",
"activeEdit": false,
"popUp": false
}
],
"skin": null,
"softlyDeletedDate": null,
"title": "AZ",
"type": "project",
"userRoles": [
"maintain",
"access"
],
"activeEdit": false,
"customPageOrdered": false,
"empty": false,
"joinable": false,
"pubView": true,
"published": true,
"softlyDeleted": false,
"entityReference": "\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"entityURL": "http:\/\/nightly2.sakaiproject.org:8081\/direct\/site\/61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"entityId": "61a1ebbd-e507-4ca3-8f88-65abca0803d9",
"entityTitle": "AZ"
},{
...

由于您有一个非常具体的用例,我建议您使用 SiteService(或者甚至可能是 SQL)来检索您正在寻找的非常有限的数据,然后将新的自定义方法添加到 SiteEntityProvider ( https://source.sakaiproject.org/svn/entitybroker/trunk/core-providers/src/java/org/sakaiproject/entitybroker/providers/SiteEntityProvider.java )像这样:

@EntityCustomAction(action = "my_custom_method", viewKey = EntityView.VIEW_SHOW)
public boolean myCustomMethod(EntityView view) {
HashMap yourMap = new HashMap();
// put code here to get all the sites data you need from the SiteService or the DB and then put the parts you want to return into a Map and then return that map
return yourMap;
}

然后您可以像这样调用该方法:

http://nightly2.sakaiproject.org:8081/direct/site/my_custom_method.json

关于rest - Sakai:如何获得带有 REST 或 WS 接口(interface)的站点(类(class))列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22413156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com