Show TOC

Background documentationCreating Workspaces Locate this document in the navigation structure

 

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 Example

  1. 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());
        }
    
End of the source code.

The following example illustrates how to create a shared workspace and set its properties and ownership.

Example Example

  1. 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);
        }
    
End of the source code.