We authenticated in
Part I, and created Workspaces in
Part II, and we are about to add our first tools here in Part III. But first I'd like to revisit SharePoint and Groove workspace creation, for I did them a disservice by not talking about custom templates. These are templates created by you, that describe either the components of a workspace, or describe a component itself.
In Part II I stated that Groove's workspace creation is designed to be much more generic than SharePoint's Document Workspace. This is not entirely true. As a few people pointed out, and as Microsoft's
Working with Templates page attests, you can in fact create, load and instantiate custom templates with SharePoint. SharePoint calls these Site Templates and List Templates. In Groove nomenclature, these are called Groove Space Archives (.gsa file extension) and Groove Tool Archives (.gta file extension) and while they're not techinically templates, you can use them as such.
Where SharePoint and Groove differ with regard to populating custom spaces is how they differ with populating custom tools themselves. You cannot register a custom template with SharePoint strictly using WSS. With Groove GWS, however, you can, sort of. SharePoint site templates and Groove space archives are really immaterial to the problem of created templated workspaces. The root of the problem lies with the tool templates. By this I mean both SharePoint and Groove allow you to create empty workspaces and to add new tools based on a template-- so your tool layout could exist purely in your smart client code if you wished.
For SharePoint, you must be use their HTML based administration UI to add a custom template to the system, which then allows WSS to add that custom template to a workspace. SharePoint then acts as its own distribution mechanism for the template, but cannot propogate the template to other SharePoint servers.
Groove, on the other hand, because of its peer-to-peer nature, can. In fact, Groove used to allow you to add a general template as long as you identified a server on the internet to fetch it from (this is how our
first PM tool works). You can't do that anymore, but you can add a Groove Form with a custom schema, design and view, and
not need to identify a server to fetch it from. Why? Because a Groove Form is self-contained. And once its registered on an endpoint, it is propogated to other endpoints by Groove itself. And this process of adding a custom Groove Form can be done by GWS.
But that's yet another part.
Hugh Pyle has been extremely helpful in showing me how this works, but I have to work through it myself first before I can write about it. In the meantime, on to the this weeks installment: Adding tools to SharePoint and Groove.
What is a workspace without any tools? Not much. So both SharePoint and Groove provide a set of default tools a developer can add via web services. SharePoint and Groove also provide a way to create default workspaces that contain a default set of tools. As we saw in Part II, a SharePoint Document workspace comes packaged with tools like Announcements, Share Documents, Task List and such, while Groove's default workspace contained only Files, Discussion and Members. (By the way, this is an disparity we hope to correct soon!).
But what if our SharePoint space needs a second Document Library tool, and our Groove workspace needs a Groove Form? We add them with the code outlined below.
For SharePoint, I need to identify the tool template I would like to use. Assuming I have the workspace in mind, maybe even a workspace I just created, I would use the Webs service method
GetListTemplates(); This will return an XML string you can parse for specific template names and identifiers. It's generally human readable, which is good, since you do have to know what you're looking for. But once you've identified the template id for a Document Library ("101"), you could code something like:
public void AddDocumentLibrary() {
// We've gotten the templates via Webs, now we use the Lists service
// to add a tool based on a template
SharePointProxies.Lists l = new SharePointProxies.Lists();
// We're caching our credentials
l.Credentials = this.Credentials;
// and using the workspace we created in Part II
l.Url = "http://myserver/myroot/uniquename" + "/_vti_bin/lists.asmx";
// The result xml from the AddList method XmlNode resultNode = null;
// the display name of the tool we will add
string toolName = "My Display Name";
// its template id
int toolID = 101;
try {
// if successful, the result will be XML we can parse for
resultNode = l.AddList( toolName, "My Description", toolID );
// the result id, which looks a alot like a GUID
// I like to check for both name and id
resultID = parseForID( toolName, toolID.ToString() );
}
catch ( System.Exception ex ) {
reportError( aReporter, ex.Message );
}
finally {
if ( l != null ) {
l.Dispose();
l = null;
}
}
}
// a simple routine to find the ID from the AddList result XML
private string parseForID( System.Xml.XmlNode xmlNode, string name, string templateID ) {
System.Xml.XmlAttributeCollection attrs = xmlNode.Attributes;
XmlNode idNode = attrs.GetNamedItem( "ID" );
XmlNode titleNode = attrs.GetNamedItem( "Title" );
XmlNode serverTemplateNode = attrs.GetNamedItem( "ServerTemplate" );
string id = ( idNode == null ) ? "" : idNode.Value;
string title = ( titleNode == null ) ? "" : titleNode.Value;
string serverTemplate = ( serverTemplateNode == null ) ? "" : serverTemplateNode.Value;
if ( title == name && templateID == serverTemplate )
return id;
else
return null;
}
The end result of the above code is the addition of a new Document Library to the SharePoint workspace. An interesting thing about this particular tool is it also supports Web Distributed Authoring and Versioning, or
WevDAV. This is a nice tool in two respects: 1) You have a choice of using SharePoint WSS or WebDAV to work with it and 2) It supports versioning-- which is very hard to do in a purely peer-to-peer environment.
The pattern for adding a Groove Form to a new Groove workspace is very similar. First we call the Groove version GetListTemplates, which is part of the Tools service and is called:
ReadAvailableTools();Also similar to SharePoint is you have to know what you are looking for. This call returns an array of templates you can iterate through. Each template contains a human readable Name and a not so human readable ComponentResourceURL (your remember those?). The ComponentResourceURL is like the SharePoint template identifier. The code for adding a Groove tool via GWS follows:
// Here is an OSD URL that identifies a Groove Form and its version
private static string s_grooveFormComponentResourceURL = "http://components.groove.net/Groove/Components/Root.osd?Package=net.groove.Groove.Tools.Business.GrooveForms.Groo veForms_TPL&Version=5&Factory=Open";
public string AddGrooveForm() {
// Tools is the container we add a Tool to
GrooveProxies.Tools tools = new GrooveProxies.Tools();
// refer to Part I or Part II for more detail
buildRequestHeader( tools );
// refer to Part I or Part II for more detail
tools.Url = m_grooveHost + m_grooveTelespaceTools;
// instantiae a tool to fill out
GrooveProxies.Tool tool = new GrooveProxies.Tool();
// with name
tool.Name = "My Display Name";
// and all-important identifier
tool.ComponentResourceURL = s_grooveFormComponentResourceURL;
// the result is the tool identifier you can append to
// m_grooveHost
string toolID = tools.Create( tool );
if ( toolID == null || toolID.Length == 0 )
return null;
else
return toolID;
}
private bool acquireTelespaceTools() {
// We go through Spaces container to find the Space tool
// to find the Tools container.
GrooveProxies.Spaces spaces = new GrooveProxies.Spaces();
// refer to Part I or Part II if you
// want to see headers built
buildRequestHeader( spaces );
// again, refer to Part I or Part II for more detail
spaces.Url = m_grooveHost + m_grooveTelespace;
// retrieve data about the space
GrooveProxies.Space space = spaces.ReadSpace();
if ( space == null )
return false;
// retrieve the Tools container for the space
m_grooveTelespaceTools = space.Tools;
return true;
}
The Groove Forms tool also has lots of nifty features, but we'll get to them in another installment, I promise. In the meantime, what you have seen is how to add not just SharePoint Document Libraries or Groove Forms, but any tool given the proper template id. For each system, you could iterate through the templates returned by either GetListTemplates or ReadAvailableTools and add them to a workspace, thus creating a workspace containing every possible web part or Groove tool.
In this case, SharePoint and Groove are nearly identical in how you discover and add tools. The real differences lie in the tools themselves. Each tool tends to, understandably, acquiesce to the strengths and weaknesses of their architecture. The SharePoint Document Library supports versioning as well as robust internet protocols, while the Groove Form supports peer-to-peer distribution of schema, design and content.
We will take a more detailed look at both in Part IV.