Welcome!

.NET Authors: Liz McMillan, Peter Silva, Yakov Werde, Matthew Pollicove , Corey Roth

Related Topics: .NET

.NET: Article

Integrating Content and Search Results with SharePoint

How we built a SharePoint Connector for Confluence - Part 1

Those features are broken out as follows: (Table 1)

Content Embedding
The goal of content embedding is to show Confluence content in SharePoint and SharePoint content in Confluence. The approaches for this were:

  1. Use Confluence plug-ins to show SharePoint content such as list data and document links in Confluence.
  2. Use SharePoint Web parts to show Confluence wiki pages and Confluence wiki page hierarchy in SharePoint.
Confluence Plug-In
The Confluence plug-in lets the user enter SharePoint-specific Confluence wiki markup in a Confluence wiki page. The plug-in uses the built-in SharePoint Web Services (primarily Lists.asmx) to retrieve list content. A simple example of the markup might be:

{sp-list:test doc library|doc}

The resulting section of the wiki pageis shown in Figure 2.

One interesting aspect of the plug-in was a technique4 used to provide an external link for editing a document in a SharePoint document library. The link is shown in a Confluence wiki page, but lets the user click the link, edit the document, and save the changes back to SharePoint as seamlessly as in a SharePoint document library.

SharePoint Web Parts
Two Web parts were created to show Confluence content in SharePoint:

  • Confluence Page Web Part
  • Confluence Space Pages Web Part
Both Web parts use Confluence Web Services to get Confluence content. Following a section for each Web part, we discuss how the Web parts are administered.

Confluence Page Web Part
The Confluence Page Web part shows a Confluence wiki page in a SharePoint Web part.

The example in Figure 3 shows a Confluence wiki page that displays news via RSS. The high-level work of displaying the page content in the Web part is shown below:

RemotePage page = ConfluenceHelper.GetConfluencePage(this.PageId);
this.TitleUrl = page.url;
pageContent = ConfluenceHelper.RenderContent(this.SpaceKey, this.PageId);
pageContent = GetCleanPageContent(pageContent);
_literalPage.Text = pageContent;

This is simplifying things a bit, but the ConfluenceHelper class basically has several methods that wrap Confluence Web Service method proxy calls. In this case, the GetConfluencePage method wraps the Confluence getPage Web method and the RenderContent wraps the Confluence renderContentAsUser Web method. In addition, regular expressions are used to prefix all URLs properly in the Confluence page content with the Confluence host and remove some inline CSS styles that were conflicting with the rest of the SharePoint page. Finally, the pageContent is simply applied to the Text property of a Literal control. All of this happens in the OnPreRender override of the Web part.

The image in Figure 3 also shows an "Edit Confluence Page" verb on the Web part menu. This is done simply by overriding the get of WebPartVerbCollection in the Web part as shown in Listing 1.

Once again we use our Web Service proxy wrapper, this time to determine if the user can edit the page. Note that caching should be done on operations such as this in the get of the WebPartVerbCollection since it may be called multiple times when a single Web part is displayed.

A more interesting aspect of the Web parts is the editor part. Editor parts are used to provide a custom editor for Web part properties. Without an editor part, custom Web part properties are typically text boxes shown in the "Miscellaneous" section when you edit your Web part properties (enumeration Web part properties show as drop-downs). In this case, we want to let the user select a page for the Web part. Our editor part is shown in Figure 4.

To make this work, we override the CreateEditorParts method on the Web part as shown in Listing 2, where you can see it references a ConfluencePageEditorPart. This class inherits from the EditorPart, which is an extension of a Panel (a WebControl). In this particular editor part we override CreateChildControls and OnPreRender to display the content you see in Figure 4. We happen to use our own custom DropDownList control to encapsulate the list of Confluence spaces and a custom TreeView control to encapsulate the pages in a space. This was done because they are both used in the Confluence Space Pages Web Part we'll discuss below.

The primary difference between a UserControl and an EditorPart is that the EditorPart must be able to communicate to the Web part. This is done through two methods: SyncChanges and ApplyChanges.

A Web part is in charge of storing and retrieving the Web part property values. SyncChanges is used to take the Web part property values in the Web part and provide them to the EditorPart so it can properly display the current settings as seen in Listing 3.

Typically, the EnsureChildControls method can be called to make sure that CreateChildControls is already called and then the properties can sometimes be applied directly to controls in the editor part. However, in our case the processing was a little more complex so we stored the property values in member variables to be used later in OnPreRender.

The ApplyChanges method is the corollary to SynChanges. It lets the editor part provide Web part property values to the Web part as shown in Listing 4.


More Stories By Kirk Liemohn

Kirk Liemohn is a principal software engineer with ThreeWill. His recent project experience includes Microsoft Office SharePoint Server (MOSS) enterprise search projects as well as a Windows SharePoint Services (WSS) business analysis portal. Kirk manages a SharePoint blog at http://www.implementingsharepoint.com.

More Stories By Chris Edwards

Chris Edwards is a senior software engineer with ThreeWill. His project roles have ranged from development/technical lead to development resource. He is certified as MCSD using Microsoft .NET and as MCTS: SharePoint Services 3.0, Application Development. Chris manages resource links related to WSS at http://wssresourceguide.com.

Comments (3) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
fdaske 09/23/09 11:33:00 AM EDT

Generally SharePoint is a great platform for data integration. Sharepoint lists can be directly connected to almost any external data sources using the BDLC found here.

In this way you can use all SharePoint list features, even workflows if external data records are changed.

shirley 11/26/08 05:05:46 AM EST

We can assist here as we specialize in developing and implementing SharePoint 2007 – that’s all we do. There is more information on this at http://www.nsynergy.com/Services/Pages/default.aspx or mail to Mark.Davis@nsynergy.com .

shirley 11/04/08 12:01:21 AM EST

For more information on document management and collaboration solutions, please visit http://www.nsynergy.com or please email to Mark.Davis@nsynergy.com.