Creating Workspaces
Applies to: SharePoint Workspace 2010 | Visual Studio 2008
There are three ways to create workspaces using GrooveSpaces:
Create an empty workspace with the Create operation. This operation creates a Groove 2007 workspace.
Create a workspace using a Groove Workspace Template or Archive with the CreateFromGSA or CreateFromGSAByRef operation. A Groove Workspace Template is a binary file with a .GSA file type that is created when a member saves a workspace to a template or archive using the SharePoint Workspace user interface. A template typically does not contain the tool data where an archive does. The CreateFromGSA operation passes the contents of the .GSA file as a parameter, where the CreateFromGSAByRef specifies the .GSA file as a file path on the local device.
Create a Shared Folder with the CreateGrooveFileSharingSpace operation.
If you are creating a workspace with the Create operation, you specify the workspace name and description in a Space object. The following code creates a GrooveSpaces service, creates a new Space object, and assigns the workspace name and description. Note that you must set the Create operation CSTURI parameter to an empty string because all other values are reserved for future use.
GrooveSpaces.GrooveSpaces spacesSvc = new GrooveSpaces.GrooveSpaces();
...
GrooveSpaces.Space createSpace = new GrooveSpaces.Space();
createSpace.Name = "New space";
createSpace.Description = "New space";
string spacePostURL = spacesSvc.Create(createSpace, "");
The following example code demonstrates how to create a workspace from a GSA. It reads the contents of a GSA file into a stream, then calls CreateFromGSA, and finally reads the newly created space with ReadSpace. This code demonstrates how to pass the GSA in a buffer. However, if the GSA is stored in a file, you should use the CreateFromGSAByRef operation rather than the CreateFromGSA operation.
using System.IO;
...
// Create GrooveSpaces service
// Read the GSA from a file into a byte array
string gsaPath = "c:\\temp\\TestSpace.gsa";
FileStream fStream = new FileStream(gsaPath, System.IO.FileMode.Open);
int streamLen = (int) fStream.Length;
byte[] gsaBuffer = new byte[streamLen];
BinaryReader bReader = new BinaryReader(fStream);
gsaBuffer = bReader.ReadBytes(streamLen);
bReader.Close();
// Create the space
string createdURI = spacesSvc.CreateFromGSA(gsaBuffer,
"Test Space From GSA","");
// Reset the HTTP Post URL for the new space and then read it
spacesSvc.Url = HTTPAddressAndPort + createdURI;
GrooveSpaces.Space newSpace = spacesSvc.ReadSpace();
If you are creating a Shared Folder, you specify the workspace name in a separate parameter rather than in a Space object. In addition, you specify the Windows folder to use for the Shared Folder. You must ensure that the folder exists before calling the operation. If the folder does not exist, the folder is the root folder of the device, or the folder is on a removable drive, the operation fails and returns a SOAP fault.