Accessing Tools in a Workspace

The GrooveTools service provides accesses the tools in a workspace. It only provides information about tools that can be accessed through Groove Web Services. The GrooveToolsRead operation provides information about each tool in the Tool class, which includes information such as:

  • Name.

  • Type of the tool.

  • URI for the GrooveTools service for the tool.

  • URI for the Web Service provided by the tool, in the Data element.

The following table lists these types for the Groove tools accessible via Groove Web Services. The tool Type is a URN.

Tool Type URN Tool Web Service

urn:groove.net:platform.tools.Forms2

Groove Forms tool version 5.0

GrooveForms2

urn:groove.net:platform.tools.InfoPathForms

InfoPath Forms tool version 1.0

GrooveForms2

urn:groove.net:platform.tools.Files

Files tool

GrooveFilesBase64

urn:groove.net:platform.tools.WSSFiles

SharePoint Files tool

GrooveFilesBase64

urn:groove.net:platform.tools.Calendar

Calendar tool

GrooveCalendar

Note that the Tool structure includes two URIs for the tool: one in the URI element and one in the Data element. The URI element contains a URI that allows you to call the GrooveTools service for this tool. You can use the GrooveTools service to remove the tool from the space, change the tool name, or update the unread state of the tool. The Data element contains a URI for the service provided by the tool. For example, if the tool is a Files tool, the Data element contains the URI for the GrooveFilesBase64 service.

Reading Tools in a Workspace

The following sample reads the tools in a workspace and tests the type of each tool.

GrooveTools.GrooveTools toolsSvc = new GrooveTools.GrooveTools();
toolsSvc.GrooveRequestHeaderValue = new GrooveTools.GrooveRequestHeader();
   
// Get the Identity2 from GrooveAccounts.Read2
GrooveAccounts.Identity2 ident = ...; 
   
toolsSvc.GrooveRequestHeaderValue.GrooveIdentityURL = ident.URI;
string requestKey = ...; // Read the request key from the registry
toolsSvc.GrooveRequestHeaderValue.GrooveRequestKey = requestKey;

// Get the HTTP address from app configuration information
// and the port number from the registry 
string HTTPAddressAndPort = ...;

// Get the space from GrooveSpaces.Read
GrooveSpaces.Space space = ...; 
   
// Get Post URL from GrooveSpaces.Space
toolsSvc.Url = HTTPAddressAndPort + space.Tools; 
   
GrooveTools.Tool[] tools = toolsSvc.Read();

foreach (GrooveTools.Tool tool in tools)
{
  switch (tool.Type)
  {
    case "urn:groove.net:platform.tools.Forms2":
    case "urn:groove.net:platform.tools.InfoPathForms":
    {
      // Groove Forms or InfoPath Forms tool
      // can call GrooveForms2 using tool.Data
      break;
    }

    case "urn:groove.net:platform.tools.Files":
    case "urn:groove.net:platform.tools.WSSFiles":
    {
      // Groove Files or Sharepoint Files tool
      // can call GrooveFilesBase64 using tool.Data
      break;
    }

    case "urn:groove.net:platform.tools.Calendar":
    {
      // Groove Calendar tool
      // can call GrooveCalendar using tool.Data
      break;
    }

    default:
    {
      // unknown tool
      break;
    }
  }
}

Adding Tools to a Workspace

When you add a new tool to a workspace using the GrooveToolsCreate operation, you specify the tool by its template's ComponentResourceURL. The GrooveToolsReadAvailableTools operation returns the tool templates that are available to the identity. The template object contains the tool ID and ComponentResourceURL. Your application can use the ID to select the template that describes a tool and then use the template's ComponentResourceURL to add the tool to a workspace.

The following sample creates a new workspace, reads all the available tools, and adds a Files tool and a Discussion tool to a workspace. Note that after you create the workspace, you must read the workspace to get the Post URL for the GrooveTools service.

string spacePostURL = spacesSvc.Create(createSpace, "");

// Use the returned Post URL to read the workspace
// to get the Space.Tools Post URL for GrooveTools
spacesSvc.Url = HTTPAddressAndPort + spacePostURL;
GrooveSpaces.Space newSpace = spacesSvc.ReadSpace();

GrooveTools.GrooveTools toolsSvc = new GrooveTools.GrooveTools();
// Create and set the header and set HTTPAddressAndPort string variable

// Get Post URL from GrooveSpaces.Space returned by ReadSpace
toolsSvc.Url = HTTPAddressAndPort + newSpace.Tools; 

GrooveTools.Template[] templates = toolsSvc.ReadAvailableTools();
for (int i = 0; i < templates.Length; i++)
{
    GrooveTools.Template template = templates[i];
    if (template.ID == "Discussion" || template.ID == "Files")
    {
        GrooveTools.Tool newTool = new GrooveTools.Tool();
        newTool.ComponentResourceURL = template.ComponentResourceURL;
        newTool.Name = template.Name;

        // Get Post URL from GrooveSpaces.Space
        toolsSvc.Url = HTTPAddressAndPort + newSpace.Tools;

        // Now create the tool in the workspace
        string toolURI = toolsSvc.Create(newTool);
        
        // Get the Post URL returned by Create for ReadTool
        toolsSvc.Url = HTTPAddressAndPort + toolURI;

        // Now read the newly created tool
        GrooveTools.Tool tool = toolsSvc.ReadTool();
    }
}

Note that the ReadAvailableTools operation returns the templates for all tools that are available for workspaces compatible with Groove 2007. You cannot add tools to workspaces compatible with older versions of Groove. You can check the workspace template version returned by GrooveSpacesRead before adding a tool to a workspace.

The GrooveToolsUpdate operation allows you to change a tool's display name and the UpdateUnreadMark operation allows you to mark all entries in the tool as either read or unread. The Delete operation removes the specified tool from a workspace. These operations specify the tool they are acting on in the service-specific data of the HTTP Post URL. The Read and ReadTool operation return a URI with this service-specific data in the Tool URI element.

See Also

Reference

GrooveTools Web Service

Concepts

Creating Workspaces
Accessing the Groove Web Services Hierarchy