1

我正在尝试从社区活动中的一个部分获取所有活动。

首先,我遍历所有活动:

ActivityList allActivities = service.getAllActivities();
for(Activity activity : allActivities) {
    if("community_activity".equals(activity.getEntryType())) {
    ...

对于每个社区活动,我都会遍历 ActivityNodes:

ActivityNodeList activityNodesFromActivity = service.getActivityNodes(activity.getActivityId());            
    for (ActivityNode activityNode : activityNodesFromActivity) {
    ...

到目前为止,一切都很好。但是因为一些活动可以是部分,我想再次循环它们以获得他们的“孩子”活动。

ActivityNodeList activityNodesFromSection = service.getActivityNodes(activityNode.getActivityId());

现在我收到这些请求的 403 错误:

<error xmlns="http://www.ibm.com/xmlns/prod/sn">
    <code/>
    <message>
        Identifier: LCFED1E22083D5412BB4A4E5ABB1D26B10 Request denied
    </message>
    <displaymessage/>
    <errortype/>
    <trace>
        java.lang.Exception: Identifier: LCFED1E22083D5412BB4A4E5ABB1D26B10 Request denied
    </trace>
</error>

因此,SBT 丢失了 OAuth 令牌,我必须在 SmartCloud 上再次登录并获得访问权限。

是否有另一种/更好的方法可以从社区活动的某个部分获取活动?

顺便说一句:我正在使用 SBT 的倒数第二个版本:1.0.0.20140125-1133

4

1 回答 1

1

try this approach...

You can extend the base "extends ActivityService"

/**
* Method to get Activity nodes from Section
* 
* @param includeSelf 
* @param nodeUuid
* @param sectionId
* @return ActivityNodeList
* @throws ActivityServiceException
*/
public ActivityNodeList getActivityNodesInSection(String nodeUuid, String sectionId boolean includeSelf) throws ActivityServiceException {

private String sectionUri = "/activities/service/atom2/descendants";

if (null == activityId ){
throw new ActivityServiceException(null, "Null activityId");
}

/**
 * Includes section node, if it's true
 */
String include = "no";
if(includeSelf){
   include = "yes";
}

try {
Map<String, String> params = new HashMap<String, String>();
params.put("nodeUuid", activityId);
params.put("includeSelf", include);
params.put("section", sectionId);


         return (ActivityNodeList) getEntities(sectionUri, params, new ActivityNodeFeedHandler(this));
} catch (Exception e) {
throw new ActivityServiceException(e);
}
}

then the function you call - in your case, nodeUuid and sectionid should be the same.

于 2014-05-13T11:40:55.493 回答