Creating Workspaces 
The Workspace API enables you to create workspaces and set their properties.
The following example illustrates how to create a personal workspace for a specific user.
Example
public void createPersonalWorkspace(IPortalComponentRequest request, IUser workspaceOwnerUser)
{
// Retrieve the workspace factory
IWorkspaceFactory workspacesFactory = (IWorkspaceFactory) RuntimeFactory.getWorkspacesRuntime().getService(IWorkspaceFactory.class);
//Create personal workspace for the specified user
workspacesFactory.createPersonal(workspaceOwnerUser, request.getLocale());
}
The following example illustrates how to create a shared workspace and set its properties and ownership.
Example
public void createSharedWorkspace(IPortalComponentRequest request, IUser workspaceOwnerUser)
{
// Retrieve the workspace factory
IWorkspaceFactory workspacesFactory = (IWorkspaceFactory) RuntimeFactory.getWorkspacesRuntime().getService(IWorkspaceFactory.class);
WorkspaceProperties workspaceProperties = new WorkspaceProperties();
workspaceProperties.setName("Workspace Name");
workspaceProperties.setDescription("Workspace Description");
workspaceProperties.setPermissionPolicy(PermissionPolicy.RESTRICTED);
//create shared workspace with the specified user as owner
workspacesFactory.createShared(workspaceOwnerUser, workspaceProperties);
}