Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Connections wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 1.0
  • 1.0.x
  • 2.0
  • 2.0.1
  • 2.0.1.1
  • 2.0_media
  • 2.5
  • 2.5_deployment
  • 2.5_media
  • 2.5_performance
  • 3
  • 3.0
  • 3.0.1
  • 3.0.1_media
  • 3.0_media
  • 3_deployment
  • 8.1.1
  • 8.2
  • activities
  • administrators
  • api
  • best_practices
  • blogs
  • bookmarks
  • business_card
  • cluster
  • communities
  • community
  • community_manager
  • connections
  • connections_3
  • connections_301
  • customization
  • customize
  • customizing
  • demos
  • deploying
  • deployment
  • deployments
  • developers
  • dogear
  • Domino
  • Edge server
  • education
  • error messages
  • files
  • forums
  • getting_started
  • Help
  • home
  • home_page
  • homepage
  • how-to
  • HTTP server
  • ibm
  • index
  • installation
  • integration
  • iOS
  • ipad
  • iWidget
  • J2EE
  • javadoc
  • lc3.0
  • learning
  • lotus-connections
  • mml
  • mobile
  • Notes
  • performance
  • person_card
  • Portal
  • portlet
  • portlet_factory
  • profiles
  • proxy server
  • quickr
  • Redbooks
  • rest
  • reverse proxy server
  • Sametime
  • scenarios
  • search
  • security
  • self-paced
  • SSO
  • tags
  • test_infrastructure
  • troubleshooting
  • tuning
  • video
  • VideoFest
  • videos
  • WAI
  • WAS
  • web_seminar
  • WebAppIntegrator
  • WebSphere
  • widgets
  • wikis
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > IBM Redbooks: Customizing IBM Connections 3.0.1 > 9.3 Retrieving a person's profile: A sample application
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

9.3 Retrieving a person's profile: A sample application 

expanded Abstract
collapsed Abstract
No abstract provided.
Previous | Next

One of the most commonly used services that IBM Connections API provides is retrieving a person's profile. This topic describes a sample application that retrieves a person's profile using the Profiles API.

The REST-style API that IBM Connections provides receives an HTTP request and returns an Atom document. Therefore, to retrieve a person's information, the correct HTTP request URL must be constructed. For example, the following URL returns an Atom document that contains the profile information of person with the e-mail address of PBrown@demoibm.com:
http://connections.demoibm.com/profiles/atom/profile.do?email=PBrown@demoibm.com

For more details about how to assemble the Atom API request URL, refer to IBM Connections Product Documentation. Sending the Profiles API request through a web browser or other client that can send HTTP requests, a resulting Atom document is returned.

The following example shows a Profiles Atom document:
 
 <?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:app="http://www.w3.org/2007/app" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:fh="http://purl.org/syndication/history/1.0" xmlns:snx="http://www.ibm.com/xmlns/prod/sn" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom">
    <id>tag:profiles.ibm.com,2006:feed</id>
    <generator version="3.0.1.0" uri="http://www.ibm.com/xmlns/prod/sn">IBM Connections - Profiles</generator>
    <title type="text">profile with email frank.adams@demoibm.com</title>
    <author>
        <name>IBM Connections - Profiles</name>
    </author>
    <updated>2011-08-15T20:16:59.743Z</updated>
    <fh:complete/>
    <link href="http://server/profiles/atom/profileTags.do?targetKey=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/tag-cloud" type="application/atomcat+xml"/>
    <link href="http://server/profiles/atom/mv/theboard/entries.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/mv/theboard" type="application/atom+xml"/>
    <link href="http://server/profiles/atom/mv/theboard/entry/status.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="http://www.ibm.com/xmlns/prod/sn/status" type="application/atom+xml"/>
    <link href="http://server/profiles/atom/connections.do?connectionType=colleague&amp;key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/connections/colleague" type="application/atom+xml"/>
    <link href="http://server/profiles/atom/reportingChain.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="http://www.ibm.com/xmlns/prod/sn/reporting-chain" type="application/atom+xml"/>
    <link href="http://server/profiles/atom/peopleManaged.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="http://www.ibm.com/xmlns/prod/sn/people-managed" type="application/atom+xml"/>
    <link href="http://server/profiles/atom/profileExtension.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;extensionId=profileLinks&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/ext-attr" type="text/xml" snx:extensionId="profileLinks" xmlns:snx="http://www.ibm.com/xmlns/prod/sn"/>
    <link href="http://server/profiles/atom/profile.do?email=bochs%40thinksis.com" rel="self" type="application/atom+xml"/>
    <entry>
        <id>tag:profiles.ibm.com,2006:entryd988f052-3f18-46a8-90f9-1a3b4c7a1d94</id>
        <title type="text">Frank Adams</title>
        <updated>2011-08-08T13:28:42.978Z</updated>
        <category term="profile" scheme="http://www.ibm.com/xmlns/prod/sn/type"/>
        <contributor>
            <name>Frank Adams</name>
            <snx:userid>E514AA26290C91108525688600530CAC</snx:userid>
            <email>frank.adams@demoibm.com</email>
            <snx:userState>active</snx:userState>
        </contributor>
        <link href="http://server/profiles/atom/profileEntry.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="self" type="application/atom+xml"/>
        <link href="http://server/profiles/html/profileView.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="related" type="text/html"/>
        <link href="http://server/profiles/photo.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/image" type="image"/>
        <link href="http://server/profiles/audio.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" rel="http://www.ibm.com/xmlns/prod/sn/pronunciation" type="audio"/>
        <link href="http://server/profiles/vcard/profile.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94" rel="alternate" type="text/directory"/>
        <summary type="text">Profile information for Frank Adams</summary>
        <content type="xhtml">
            <sp_0:div xmlns="http://www.w3.org/1999/xhtml" xmlns:sp_0="http://www.w3.org/1999/xhtml">
                <span class="vcard">
                    <div>
                        <img src="http://server/profiles/photo.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94&amp;lastMod=1312810122978" class="photo"/>
                    </div>
                    <div>
                        <a class="fn url" href="http://server/profiles/atom/profile.do?key=d988f052-3f18-46a8-90f9-1a3b4c7a1d94">Frank Adams</a>
                    </div>
                    <div>
                        <a class="email" href="mailto:frank.adams@demoibm.com">frank.adams@demoibm.com</a>
                    </div>
                    <div class="org">
                        <span class="organization-unit"/>
                    </div>
                    <div class="role"/>
                    <div class="title">Manager</div>
                    <div class="adr work postal">
                        <div class="street-address">100 Main Street</div>
                        <span class="locality">New York</span>
                        <span class="region">NY</span>
                        <span class="postal-code">10001</span>
                        <div class="country-name"/>
                        <div class="x-country-code" style="display:none">USA</div>
                        <div class="x-worklocation-code" style="display:none">New York</div>
                    </div>
                    <div class="x-office">
                        <span class="x-building"/>
                        <span class="x-floor"/>
                        <span class="x-office-number">New York</span>
                    </div>
                    <div class="tel">
                        <abbr class="type" title="work">Work:</abbr>
                        <span class="value">555-123-456</span>
                    </div>
                    <div class="x-is-manager" style="display:none">Y</div>
                    <div class="x-profile-key">d988f052-3f18-46a8-90f9-1a3b4c7a1d94</div>
                    <div class="uid">E514AA26290C91108525688600530CAC</div>
                    <div class="x-profile-uid">frank.adams</div>
                    <div class="x-lconn-userid">E514AA26290C91108525688600530CAC</div>
                    <div class="rev" style="display:none">2011-08-08T13:28:42.978Z</div>
                    <div class="x-profile-type" style="display:none">default</div>
                </span>
            </sp_0:div>
        </content>
    </entry>
</feed>


Using this Atom document, profile information can be extracted and processed. So, the next step is to parse the Atom document to get the profiles attributes. Since the profile Atom document is an XML document, there are many ways to parse the document.

Note:
In the remaining sections of this topic, the Apache Abdera library is used in the sample code. Apache Abdera is an open source implementation of the Atom Syndication Format and Atom Publishing Protocol. It provides a Java development toolkit that is used to help develop Atom clients. For more details about the Apache Abdera project, refer to the Apache Abdera project site

The following code example shows how to retrieve a person's profile and extract attributes using traditional XML DOM processing:
 Abdera abdera = new Abdera();
Parser parser = abdera.getParser();

URL api_url = new URL("http://connections.demoibm.com/profiles/atom/profile.do?email=PBrown@demoibm.com");
Document<Element> document = parser.parse(api_url.openStream());
Feed feed = (Feed)document.getRoot();

// Navigating the content element to get the profile of the person
List<Entry> entries = feed.getEntries();
Entry entry = entries.get(0);
        
// Name
System.out.println("Name: " + entry.getTitle()); 
        
Element content = entry.getContentElement();
List<Element> divElements = content.getFirstChild().getFirstChild().getElements();
for (Element divElement : divElements) {
        if ("org".equalsIgnoreCase(divElement.getAttributeValue("class"))) {       
                List<Element> spanElements = divElement.getElements();
                for (Element spanElement : spanElements) {
                    
                    // Organization
                    if ("organization-unit".equalsIgnoreCase(spanElement.getAttributeValue("class"))) {
                        System.out.println("Organization: " + spanElement.getText());
                    }
                }
        }

        // Title
        if ("title".equalsIgnoreCase(divElement.getAttributeValue("class"))) {
                System.out.println("Title: " + divElement.getText());
        }

        if ("tel".equalsIgnoreCase(divElement.getAttributeValue("class"))) {
                List<Element> spanElements = divElement.getElements();
                for (Element spanElement : spanElements) {
                    
                    // Telephone number
                    if ("value".equalsIgnoreCase(spanElement.getAttributeValue("class"))) {
                        System.out.println("Telephone: " + spanElement.getText());
                    }
                }
            }
 }  


The following code example shows how to retrieve a person's profile and extract attributes using XPath:
 Abdera abdera = new Abdera();
Parser parser = abdera.getParser();

URL api_url = new URL("http://connections.demoibm.com/profiles/atom/profile.do?email=PBrown@demoibm.com");
Document<Element> document = parser.parse(api_url.openStream());
Feed feed = (Feed)document.getRoot();
        
List<Entry> entries = feed.getEntries();
Entry entry = entries.get(0);
        
Element content = entry.getContentElement();
        
// Using XPath functions to get the profile of the person
XPath xpath = abdera.getXPath();
System.out.println("Name: " + xpath.valueOf("a:entry/a:title", feed));
System.out.println("Organization: " + xpath.valueOf("//xhtml:div[@class='org']/xhtml:span[@class='organization-unit']", feed));
System.out.println("Title: " + xpath.valueOf("//xhtml:div[@class='title']", feed));
System.out.println("Telephone: " + xpath.valueOf("//xhtml:div[@class='tel']/xhtml:span[@class='value']", content)); 


Parent topic: 9.0 Using the API
 

expanded Article information
collapsed Article information
Category:
IBM Redbooks: Customizing IBM Connections 3.0.1
Tags:
Redbooks

This Version: Version 2 November 22, 2011 12:03:01 PM by Amanda J Bauman  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (2)
collapsed Versions (2)
Version Comparison     
Version Date Changed by               Summary of changes
This version (2) Nov 22, 2011 12:03:01 PM Amanda J Bauman  
1 Nov 21, 2011 1:07:58 PM Amanda J Bauman  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use