1

I'm trying to get all the activities from a section in a community Activity.

First I loop over all the activities:

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

For every community activities I loop over the ActivityNodes:

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

So far so good. But because some of the activities can be Sections, I want to loop over them once more to get their 'child' activities.

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

Now I get 403 errors for these requests:

<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>

Because of that the SBT loses the OAuth token and I have to login again on SmartCloud and grand access.

Is there another/better way to get the activities from a section in a community activity?

btw: I'm using the second last version of the SBT: 1.0.0.20140125-1133

magnetronnie
  • 505
  • 3
  • 16
  • 1
    are you using the Session Store for the oAuth or are you using the Database? it shouldn't loose the session. maybe report a defect on that one? – Paul Bastide May 08 '14 at 12:09
  • 1
    I wrote my own store using Portal's CredentialVault. I'll look into it a bit more to see what goes wrong. If it's something in the SBT I'll report it on Github. – magnetronnie May 15 '14 at 09:01

1 Answers1

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.

Paul Bastide
  • 1,505
  • 4
  • 17
  • 22
  • you will then add a new function as above for activityservice – Paul Bastide May 13 '14 at 11:41
  • So if I understand it right, there's a different API URL (/activities/service/atom2/descendants) to get the nodes of a section? Is this documented somewhere? – magnetronnie May 15 '14 at 09:08
  • 1
    if you log in to the service, you'll see the section on the right, select a section, and click on the feed icon at the bottom of the section – Paul Bastide May 15 '14 at 12:13