Show TOC

Changing Workspace PropertiesLocate this document in the navigation structure

Use

You can change the workspace properties, such as its name, description, status or permission policy. The following samples illustrate how to change workspace properties and handle the relevant runtime exceptions.

The relevant APIs are contained in the com.sap.workspaces.workspace package.

public void getWorkspaceProperties(IPortalComponentRequest request, IIdentifier identifier)
	{
		IWorkspaceFactory workspacesFactory = (IWorkspaceFactory) RuntimeFactory.getWorkspacesRuntime().getService(IWorkspaceFactory.class);
		IWorkspace workspace = workspacesFactory.getWorkspace(request.getUser(), identifier);

		String workspaceName = workspace.getName();
		String workspaceDescription = workspace.getDescription();
		PermissionPolicy permissionPolicy = workspace.getPermissionPolicy();
		WorkspaceCategory[] workspaceCategories = workspace.getCategories();
		Status workspaceStatus = workspace.getStatus();
	}


	public void changeWorkspaceProperties(IPortalComponentRequest request, IIdentifier identifier)
	{
		String workspaceName = null, workspaceDescription= null; 
		WorkspaceCategory[] workspaceCategories = null;

		// Retrieve the workspace object
		IWorkspaceFactory workspacesFactory = (IWorkspaceFactory) RuntimeFactory.getWorkspacesRuntime().getService(IWorkspaceFactory.class);
		IWorkspace workspace = workspacesFactory.getWorkspace(request.getUser(), identifier);

		try
		{
			// Change permission policy     	
			WorkspaceProperties workspaceProperties = new WorkspaceProperties();
			workspaceProperties.setPermissionPolicy(PermissionPolicy.PUBLIC);

			// Change workspace name, description and master locale
			workspaceProperties.setName(workspaceName);
			workspaceProperties.setDescription(workspaceDescription);
			workspaceProperties.setLocale(Locale.GERMAN);
			workspaceProperties.setCategories(workspaceCategories);

			//Commit changes to workspace
			workspace.update(workspaceProperties, request.getUser());     

		} catch (WorkspaceSettingException e) 
		{
			//Analyze the error
			String errCode = e.getErrorCode();
			if (errCode == null)
			{/*  */}
			else if(errCode.equals(WorkspaceSettingException.NO_UPDATE_PERMISSIONS))
			{ /*  */ }
			else if(errCode.equals(WorkspaceSettingException.DESCRIPTION_TOO_LONG))
			{ /*  */ }
			else if(errCode.equals(WorkspaceSettingException.MANDATORY_CATEGORY_MISSING))
			{ /*  */ }
		} catch (Exception e){	
		}
	}	    	


	public void changeWorkspaceStatus(IPortalComponentRequest request, IIdentifier identifier)
	{
		// Retrieve the workspace object
		IWorkspaceFactory workspacesFactory = 
			(IWorkspaceFactory) RuntimeFactory.getWorkspacesRuntime().getService(IWorkspaceFactory.class);
		IWorkspace workspace = workspacesFactory.getWorkspace(request.getUser(), identifier);

		try
		{
			// Change status
			workspace.setStatus(request.getUser(), Status.CLOSED, "The workspace owner has left the company");

		} catch (WorkspaceSettingException e) 
		{
			String errCode = e.getErrorCode();
			if (errCode == null)
			{/*  */}
			else if(WorkspaceSettingException.NO_STATUS_CHANGE_PERMISSIONS.equals(e.getErrorCode()))
			{/* */}
		} catch (Exception e){
		}