Step 1:
To get the list of all the ‘public & private communities’ information service document from IBM Connections, by this URL
https://social.maargasystems.com/communities/service/atom/communities/all
<?xml version=”1.0″ encoding=”UTF-8″?>
<feed xmlns=”https://www.w3.org/2005/Atom” xmlns:app=”https://www.w3.org/2007/app”
xmlns:opensearch=”https://a9.com/-/spec/opensearch/1.1/” xmlns:snx=”https://www.ibm.com/xmlns/prod/sn”>
<id>https://social.maargasystems.com/communities/service/atom/communities/all</id>
<updated>2012-12-20T12:05:47.885Z</updated>
<title type=”text”>Public Communities</title>
<link
href=”https://social.maargasystems.com/communities/service/html/allcommunities”
rel=”alternate”></link>
<generator uri=”https://www.ibm.com/xmlns/prod/sn” version=”3.0.1.0″>IBM
Connections – Communities</generator>
<opensearch:totalResults>7</opensearch:totalResults>
<opensearch:startIndex>1</opensearch:startIndex>
<opensearch:itemsPerPage>10</opensearch:itemsPerPage>
<link
href=”https://social.maargasystems.com/communities/service/atom/communities/all”
rel=”self”></link>
<link
href=”https://social.maargasystems.com/communities/service/atom/service”
rel=”https://www.ibm.com/xmlns/prod/sn/service” type=”application/atomsvc+xml”></link>
<link
href=”https://social.maargasystems.com/communities/service/atom/communities/all?outputType=categories”
rel=”https://www.ibm.com/xmlns/prod/sn/tag-cloud” type=”application/atomcat+xml”></link>
<entry>
<id>https://communities.ibm.com:2006/service/atom/community/instance?communityUuid=f1043565-7d8f-47ec-96fa-6c31c0d511df</id>
<title type=”text”>Getting Started with IBM Connections</title>
<summary type=”text”></summary>
<content type=”html”></content>
<published>2012-10-30T12:22:29.706Z</published>
<author>
<name>Anjaneyulu Telugu</name>
<email>anjaneyulu_t@maargasystems.com</email>
<snx:userid>5E181713-4F0A-A592-6525-795700404ACD</snx:userid>
<snx:userState>active</snx:userState>
</author>
<updated>2012-12-04T13:20:49.200Z</updated>
Step 2:
Parse the service document using DOM or SAX parsing and get the list of communities information (CommunityID, CommunityName etc.,
Step 3:
Construct the cookie as shown below
Cookie[] cookies = request.getCookies();
StringBuffer buffer = new StringBuffer();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
String cookieName = cookie.getName();
String cookieValue = cookie.getValue();
if ((cookies.length – 1) == i) {
buffer.append(cookieName + “=” + cookieValue);
} else {buffer.append(cookieName + “=” + cookieValue + “; “);
}
}
}
String cookieStr = buffer.toString();
Step 4:
This variable cookieStr contains info about LTPA tokens and sessionID
Step 5:
To get updates from a specific community, we need to construct the URL with the communityID of that community as shown below.
forum = “https://social.maargasystems.com/forums/atom/topics?communityUuid=e6b913fd-0d34-4af0-8ec9-b68d0a9179ee”;
bookmarks = “https://social.maargasystems.com/communities/service/atom/community/bookmarks?communityUuid=e6b913fd-0d34-4af0-8ec9-b68d0a9179ee”;
feeds = “https://social.maargasystems.com/communities/service/atom/community/feeds?communityUuid=e6b913fd-0d34-4af0-8ec9-b68d0a9179ee”;
activities = “https://social.maargasystems.com/activities/service/atom2/activities?tunedout=yes&ps=10&public=yes&page=1&commUuid=e6b913fd-0d34-4af0-8ec9-b68d0a9179ee”;
blog = “https://social.maargasystems.com/blogs/roller-ui/rendering/feed/e6b913fd-0d34-4af0-8ec9-b68d0a9179ee/entries/atom?lang=en_us”;
Step 6:
Set the cookie on request header of each URL and get the service documents.
abdera = new Abdera();
url = new URL(forum);
conn = url.openConnection();
conn.setRequestProperty(“Cookie”, cookie);
conn.connect();
Step 7:
All the service documents are merged using Xquery. A single xml is generated by sorting in the ascending order of published date. Saxon is used as an Xquery processor. A sample is shown below
<root>
<items>{
let $merged := for $url in (collection(“../xml?select=*.xml”))
let $feeddoc := $url
return if (count($feeddoc/atom:feed/atom:entry) > 0)
then
local:parse-atom($feeddoc)
else
local:parse-rss($feeddoc)return for $item in $merged
order by $item/pubdate descending
return local:rss-row($item)}
</items>
</root>
Step 8:
The code given below runs the Shell script on the command line to get the merged xml.
ProcessBuilder
pb = new ProcessBuilder(“/opt/IBM/LotusConnections/data/shared/customization/common/web/project/scripts/Xquery.sh”);
Process p = pb.start();
p.waitFor();
Shell script code as shown below
#!/bin/bash
/opt/IBM/WebSphere/AppServer/java/bin/java -cp /opt/IBM/LotusConnections/data/shared/customization/common/web/project/scripts/saxon9.jar net.sf.saxon.Query /opt/IBM/LotusConnections/data/shared/customization/common/web/project/scripts/FileDir.xql >> /opt/IBM/LotusConnections/data/shared/customization/common/web/project/output/rss.xml
The above steps help you to get the data from IBM Connections’ Communities.
Leave A Comment