People use Web 2.0 style collaboration tools to work more effectively. A common challenge is how to better manage the content used by these tools. It can be difficult to keep track of all the content that's distributed across many systems. The goal of this article is to provide an example of how several collaboration tools can be linked together to allow them to share content.
In this example, IBM Lotus Connections and IBM Lotus Quickr share content using simple published services. The implementation uses a simple Eclipse plug-in that uses Lotus Connections and Lotus Quickr services to access content in the two systems. In the spirit of the Web 2.0 style, the services rely on the basic HTTP methods GET, POST, PUT, and DELETE to create and modify the resources, which are identified as URIs.
A good understanding of IBM Lotus Connections and IBM Lotus Quickr REST services is required as well as some knowledge of the Eclipse framework, Eclipse plug-in development, Java, and Apache Abdera. See the developerWorks article, "Introducing IBM Lotus Quickr REST services," for more information about Lotus Quickr REST services.
About Lotus Quickr Document Linker
Let's consider a scenario in which your organization is using activity-centric computing to organize work and to provide support for the collaborative work environment. Your organization has deployed Lotus Connections software to organize work around employees' day-to-day activities. In Lotus Connections, an activity is a unit of work that involves one or more people in the organization working toward a common goal. For example, it might be preparing for a meeting, acquiring knowledge about a business process, or organizing a sales engagement. In the end, when the activity is completed, it usually contains documents as an end result; the documents can be presentations, spreadsheets, text documents, or other kinds of documents.
Suppose your company has also decided to deploy Lotus Quickr as a way of organizing and sharing content around the concept of shared team places. In Lotus Quickr, a place is a shared work area in which employees can work together using simple collaboration tools, such as a document manager and a wiki. To take better advantage of Lotus Quickr's document management capabilities such as versioning, check in/check out, and archiving, your company wants to easily publish documents from an activity to a place.
Your job as a developer is to implement this capability of publishing documents from an activity to a place. You decide to write a connector that retrieves the files in a Lotus Connections activity and lets you post those files to a Lotus Quickr place with just one click. In this example, the connector is an Eclipse plug-in called the Lotus Quickr Document Linker, which works with both the J2EE and the IBM Lotus Domino versions of Lotus Quickr. The Lotus Quickr Document Linker lets you publish the activity contents to a Lotus Quickr place and updates the activity with links to the documents in Lotus Quickr. The Lotus Quickr Document Linker has a tree view of activities and files within each activity. You can configure the application with the URL of the specific Activity server and the Lotus Quickr server for your organization.
This application does the following:
- Retrieves activities
- Publishes documents from an activity to a Lotus Quickr place
- Refreshes activities
In this example, we use the Lotus Connections REST services to get documents from a Lotus Connections activity, and then use the Lotus Quickr REST services to publish documents to a Lotus Quickr place. Because both Lotus Quickr and Lotus Connections use Atom as a standard protocol, we also use the open-source Apache Abdera client to parse the Atom feeds and to create HTTP requests.
Set up the environment to configure and execute the plug-in
The following steps explain how to set up the Eclipse development environment and how to execute Lotus Quickr Document Linker.
Create the Lotus Quickr Document Linker project
Download the Lotus Quickr Document Linker provided with this article. Import the sample to create a project in Eclipse.
Provide the Lotus Quickr library path
A property file (libraryConfig.properties) has been defined to configure the Lotus Quickr library to which the activity documents are published. The path shown in figure 1 is the Lotus Quickr library path. Replace this path with the path for your Lotus Quickr library. The plug-in dynamically picks this path from the property file when a document has to be published.
Figure 1. Eclipse view showing the Lotus Quickr library path
Execute the Lotus Quickr Document Linker
To execute the plug-in, run it as an Eclipse application. This opens another instance of Eclipse. Refer to figure 2.
Figure 2. Launching QuickrDocumentLinker
To view the plug-in, choose Window - ShowView - Other in the new Eclipse instance. This opens a window of available plug-ins. Choose QuickrDocumentLinker - Activities. Refer to figure 3.
Figure 3. Open QuickrDocumentLinker view in Eclipse
The Activity Plug-in view opens. Click the icon on the right side where the tool tip is seen to configure the server. This opens a Configure window for configuring the Activity and Lotus Quickr servers. Refer to figure 4.
Figure 4. QuickrDocumentLinker launched in Eclipse
To access the contents in the activity and to post them to Lotus Quickr, you need the server URL and credential details. A ConfigDialog control is written in Eclipse with the URL and login information as parameters defined in the ConfigDialog control. Create a Dialog area that gets and sets the values, which can be accessed by HTTP methods. ConfigDialog looks like figure 5 when the plug-in is launched.
Figure 5. Server Settings dialog box for the Lotus Quickr Document Linker
Refer to configDialog.java in the sample provided for more details on the implementation.
The Lotus Quickr Document Linker contains an Eclipse tree view of activities as first-level nodes and files within each activity as second-level nodes. To build this tree view, first access the Activity server to get a list of all activities.
The HTTP GET operation is done on the following URL to retrieve a list of all activities:
https://activities.abc-corp.com/activities/service/atom/activities
Listing 1 gets the list of activities and builds the first-level nodes.
Listing 1. Code snippet to get all activities and process the response
private void getActivities() {
if (serverConfig != null && serverConfig.getUrl() != null) {
try {
httpClient.addCredentials(serverConfig.getUrl(), null, null,
new UsernamePasswordCredentials(serverConfig.getUserId(), serverConfig.getPassword()));
httpClient.usePreemptiveAuthentication(true);
ClientResponse response = httpClient.get(
serverConfig.getUrl()+ "/activities/service/atom/activities");
if (response.getStatus() == 200) {
Document activityRes = response.getDocument();
Feed feed = (Feed) activityRes.getRoot();
if (feed != null) {
Iterator entries = feed.getEntries().iterator();
while (entries.hasNext()) {
TreeParent entry = new TreeParent((Entry) entries.next(), true);
invisibleRoot.addChild(entry);
}
feed = feed.getNextSibling();
}
} else {
showMessage("Could not connect to Activity server.
Please check server configuration");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
The result of the GET request is an Atom feed containing activities as each entry as shown in listing 2. Iterate through the entries of the feed to construct first-level activity nodes.
Listing 2. Feed returned for GET operation on the Activity server
<feed>
<entry>
<id>urn:lsid:abc-corp.com:oa:6A3G091E0E4B373A9D79D2CED14BD2003410</id>
<title type="text">First activity</title>
<updated>2007-10-17T15:26:53Z</updated>
<published>2007-10-17T13:52:03Z</published>
<author>
<name>Mark case</name>
<email>mcase@us.abc-corp.com</email>
<snx:ldapid>21EG091E0E4B9E7E3C2F5CD9D61E9300B79C</snx:ldapid>
</author>
<contributor>
<name>Mark case</name>
<email>mcase@us.abc-corp.com</email>
<snx:ldapid>21EG091E0E4B9E7E3C2F5CD9D61E9300B79C</snx:ldapid>
</contributor>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="activity"
label="Activity"/>
<category scheme="http://www.ibm.com/xmlns/prod/sn/priority" term="1"
label="Normal"/>
<link rel="http://www.ibm.com/xmlns/prod/sn/member-list" type="application/atom+xml"
href="https://activities.abc-corp.com/activities/service/atom/
acl?activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410" />
<link rel="http://www.ibm.com/xmlns/prod/sn/history" type="application/atom+xml"
href="https://activities.abc-corp.com/activities/service/atom/activity/
history?activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410" />
<app:collection href="https://activities.abc-corp.com/activities/service/atom/
activity?activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410">
<title type="text">First activity</title>
<app:categories href="https://activities.abc-corp.com/activities/service/
atom/activity/
categories?activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410"/>
</app:collection>
<snx:activity>6A3G091E0E4B373A9D79D2CED14BD2003410</snx:activity>
<link rel="edit" type="application/atom+xml"
href="https://activities.abc-corp.com/activities/service/atom/activitynode?
activityNodeUuid=6A3G091E0E4B373A9D79D2CED14BD2003410" />
<link rel="self" type="application/atom+xml"
href="https://activities.abc-corp.com/activities/service/atom/activity?
activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410"/>
<link rel="alternate" type="text/html"
href="https://activities. abc-corp.com/activities/service/html/activity/recent?
activityUuid=6A3G091E0E4B373A9D79D2CED14BD2003410"/>
<snx:permissions>none, create_activity, view_activity, edit_activity,
delete_activity, activity_owner, edit_activity_tags, design_activity,
edit_statements, delete_statements, add_members, delete_members,
create_entries, edit_personal_entries, edit_all_entries, delete_personal_entries,
delete_all_entries, edit_personal_entry_tags, edit_all_entry_tags,
view_members</snx:permissions>
<snx:icon>
https://activities.abc-corp.com/activities/images/activityIcon16.gif
</snx:icon>
<content type="text">Learning</content>
</entry>
<entry>
……
…………
</entry>
</feed>
|
For each activity, have the media in that activity build second-level nodes. For retrieving the files in each activity, use another method in the TreeParent object to get the URL of the activity (first-level node) and do a GET request on the activity URL as shown in listing 3. This action returns a list of contents for that activity. The returned feed contains entries for each piece of content including a bookmark, text, and files. In this example, select only media contents of type File to build the second-level nodes. You choose contents of type File because these are the pieces of content (such as images, presentations, word/text documents, and PDF files) that result from an activity and because they are the content you want to use in a Lotus Quickr place.
Listing 3. Getting file contents for each activity (second-level nodes)
public TreeObject[] getChildren() {
if (!getChildren) {
getChildren = true;
if (activityURL != null) {
ClientResponse response = httpClient.get(activityURL);
if (response.getStatus() == 200) {
Document activityDoc = response.getDocument();
Feed feedRoot = (Feed) activityDoc.getRoot();
Iterator entriesIterator =
(Iterator) feedRoot.getEntries().iterator();
while (entriesIterator.hasNext()) {
Entry entry = (Entry) entriesIterator.next();
if (((Category) entry.getCategories().get(0).getLabel().equals("File")) {
TreeObject activity = new TreeObject(entry);
addChild(activity);
}
}
}
}
}
return (TreeObject[]) children.toArray(new TreeObject[children.size()]);
}
|
The HTTP GET request on a specific activity returns a feed containing entries of the activity contents. Figure 6 shows a tree view of an activity and its media files in the plug-in.
Figure 6. Tree view of activity contents
With the first- and second-level nodes built in the tree view of the Lotus Quickr Document Linker, you are now ready to publish the contents to the Lotus Quickr server.
Publish contents to Lotus Quickr
Right-click an activity, and choose the "Publish to Lotus Quickr" option. After you select this option, a confirmation dialog box appears that shows the status of the action.
Figure 7. Menu option to publish the activity contents to Lotus Quickr
A section of the code for posting the activity contents to the Lotus Quickr file is shown in listing 4.
Listing 4. Section of the code for posting activity contents to Lotus Quickr
ClientResponse res = null;
Library lib = new Library();
try {
String libpath = lib.getLibProps().getProperty("quickr.lib");
if ((enclosureLink != null) && (name != null)) {
String QuickrLibURI = Activator.getDefault()
.getPluginPreferences().getString("quickrserver.url");
QuickrLibURI = QuickrLibURI + libpath
+ "feed?replace=true&lock=true";
String QuserName = Activator.getDefault().getPluginPreferences()
.getString("quickr.user");
String QPassword = Activator.getDefault().getPluginPreferences().
getString("quickr.pwd");
ClientResponse response = httpClient.get(enclosureLink);
if (response.getStatus() == 200) {
InputStream is = response.getInputStream();
CommonsClient httpQuickrClient = new CommonsClient();
httpQuickrClient.addCredentials(QuickrLibURI, null, null,
new UsernamePasswordCredentials(QuserName,QPassword));
httpQuickrClient.usePreemptiveAuthentication(true);
RequestOptions options = new RequestOptions();
options.setSlug(name);
options.setContentType(contentType);
res = httpQuickrClient.post(QuickrLibURI, is, options);
}
}
}
|
To complete publishing to Lotus Quickr, follow these steps:
- Get the URL of the activity file selected.
- Do a GET request on the Activity server to read the contents of the activity file.
- Do a POST request on Lotus Quickr to publish the file. In this step, you need the Lotus Quickr library; it is fetched from the property file and is configurable.
- Read the content location on the Lotus Quickr server, which is an entry returned from the HTTP POST request. You need this information to update the activity with a bookmark.
Figure 8 shows that the document is published to Lotus Quickr from the activities.
Figure 8. Document posted to Lotus Quickr
Update an activity with a Lotus Quickr bookmark
As you have seen, the response of the POST is an entry returned from Lotus Quickr that describes the location and details of the document you just posted. Get the media link from the entry, and then update the activity to create a bookmark on the activity for this document. This task requires an HTTP POST request to the Activity server. Listing 5 shows the code that updates the activity with a bookmark directing to the content location in Lotus Quickr.
Listing 5. Updating activity contents with a bookmark
public int updateActivities(Entry entry, TreeObject target) {
ClientResponse postResponse = null;
try {
RequestOptions ro = new RequestOptions();
ro.setContentType("application/atom+xml");
Entry updateEntry = Abdera.getNewFactory().newEntry();
updateEntry.setId(target.getId());
updateEntry.setTitle(target.getName());
updateEntry.addLink(target.getActivityURL(), "edit");
updateEntry.addLink(target.getActivityURL(), "self");
updateEntry.addCategory("http://www.ibm.com/xmlns/prod/sn/type",
"bookmark", "Bookmark");
updateEntry .addLink(entry.getEditMediaLinkResolvedHref().toString());
ClientResponse deleteResponse = httpClient.delete(target
.getActivityURL());
postResponse = httpClient.post(target.getParent().getActivityURL(), updateEntry, ro);
} catch (Exception e) {
e.printStackTrace();
}
return postResponse.getStatus();
}
|
Notice in figure 9 that the activity content you posted from the Eclipse plug-in to Lotus Quickr is updated with a bookmark that points to the document URL in Lotus Quickr.
Figure 9. Activities updated with a bookmark pointing to the Lotus Quickr document location
After the activity contents are published to Lotus Quickr, the file no longer exists in the activity. It has been replaced with a bookmark to the Lotus Quickr location. When you refresh that activity from the menu that appears when you right-click the activity, you can see that the files are not present as second-level nodes. (Recall that you are working with media contents of activity only for second-level nodes.)
In this example, we have shown how two collaboration tools can be used together to publish documents from Lotus Connection activities to Lotus Quickr places in a simple and easy way. This pattern can be applied to address your specific requirements to build software that can connect two or more systems.
| Name | Size | Download method |
|---|---|---|
| LotusQuickrDocumentLinker.zip | 2121KB | HTTP |
Information about download methods
Learn
-
Read the developerWorks Lotus article, "Introducing IBM Lotus Quickr REST services."
-
Read the developerWorks Lotus article, "IBM Lotus Quickr: Enhance team productivity with social computing."
-
Read the developerWorks article, "Getting to know the Atom Publishing Protocol, Part 3: Introducing the Apache Abdera project."
-
Refer to the Lotus Quickr Developer's Guide.
-
Refer to the developerWorks Lotus Quickr documentation page.
-
Refer to the developerWorks Lotus Connections documentation page.
-
Learn more about the Lotus Connections Activities API.
-
Learn more about Eclipse plug-in development.
-
Consult the Apache Abdera documentation.
Discuss
- Participate in the discussion forum.
-
Participate in the developerWorks Lotus team blog.
Soumya Sreeram is a Staff Software Engineer at IBM working with the IBM Lotus Quickr team in Research Triangle Park, NC. You can reach Soumya at soumya.sreeram@us.ibm.com.
Comments (Undergoing maintenance)





