Show TOC

Background documentationDetermining the Personal Workspace Template Locate this document in the navigation structure

 

By default, all personal workspaces are based on a default template. However, the Workspace API enables you control programmatically which template to apply when creating a personal workspace for a specific user.

To do this, you need to implement the IPersonalTemplate interface, which is contained in the com.sap.workspaces.workspace package.

The following example shows how to determine the personal workspace template depending on the user's role.

Example Example

  1. public class PersonalTemplateImpl implements IPersonalTemplate, com.sapportals.portal.prt.service.IService {
    
    	public String getTemplateID(Object user) {
    		// Default behavior - apply the default template
    		IConfigurationService configurationService = (IConfigurationService) RuntimeFactory.getWorkspacesRuntime().getService(IConfigurationService.class);
    		String templateID = configurationService.getValue("personal.default.template");
    		if (user instanceof IUser) {
    			IUser currentUser = (IUser) user;
    			// Determine which template to apply depending on user's role or group
    			// Template IDs appear in the Workspace Templates UI under Properties
    			if (currentUser.isMemberOfRole("some_role_id", true)) {
    				templateID = "Department";
    			} else if (currentUser.isMemberOfGroup("some_group_id", true)) {
    				templateID = "Managers_and_SVP";
    			}
    		}
    		return templateID;
    	}
    }
    
End of the source code.

Deploy and configure your service, setting the property Determine Personal Workspace Template to prt_service:<your_service_key>.

For more information, see Configuring Workspace Services.