Sakai:如何通过REST或WS界面获取网站(课程)列表?

时间:2014-03-14 18:38:18

标签: rest sakai

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

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

3 个答案:

答案 0 :(得分:3)

如果您想获得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添加新的自定义方法({{3} })像这样:

@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

答案 1 :(得分:2)

也许您可以尝试使用JWS获取一些信息。

sakai(ROOT_OF_TOMCAT \ webapps \ sakai-axis)中有一些默认服务,您可以通过以下方式访问:http://xxx.xxx/sakai-axis/xxx.jws?wsdl)。

服务" SakaiLogin.jws" 帮助您登录sakai:

public String login(String id,String pw) throws AxisFault

服务" SakaiScript.jws" 提供了一个名为的函数:

public String getAllSitesForUser(String sessionid) throws AxisFault

可以返回与此用户关联的所有网站的列表。

也许我没有正确回答你的问题(因为我使用的是SOAP)。我希望这对你有所帮助。

我也在编写一个程序来检索sakai的数据。但我不太了解如何通过REST或Entity Broker公开数据。

干杯。


<强>更新

您可以尝试使用Apache Axis2带来的wsdl2java.bat。它将从WSDL服务生成Java类。然后,您可以直接使用它来使用Sakai提供的这些服务。像:

wsdl2java.bat -p org.sakai.wsdl -uri http://localhost:8080/sakai-axis/Assignments.jws?wsdl

我已经在使用它,感觉非常方便。

答案 2 :(得分:0)

可以使用Sakai的getAllSitesCollectionSize中的contenthostingservice方法列出所有Sakai网站。它应该称为getAllSites。别问我为什么这样命名!

例如,参见https://qa11-mysql.nightly.sakaiproject.org/sakai-ws

相关问题