Selecting OSLC Configurations

For OSLC applications supporting configuration management, projects may have resources that are configuration controlled. In such case, as a developer, you need to specify the configuration you are interested in when querying a resource or modifying content.

An OSLC application supporting configuration management will provide access to its available configurations, referred in this section as local configurations. Such OSLC application can also contribute its configurations to the Jazz Global Configuration application. In such case, querying an OSLC resource can be done either in the context of a local configuration or a global configuration.

MDAccess for OSLC provides requests for retrieving delegated user interfaces to select configurations. Those user interfaces are provided by the targeted OSLC application and are delivered as HTML components that can be displayed in a web browser.

Here are the requests to retrieved OSLC configuration selection dialogs:

Here is a snippet demonstrating the display of OSLC configuration selection dialogs in a Java user interface:

	Dialog globalDialog = new GetGlobalConfigurationSelectionDialog(client, rootServicesLocation).call();
	Dialog localDialog = new GetLocalConfigurationSelectionDialog(client, rootServicesLocation, serviceProviderLocation).call();
	        
	ResourceSelectionDialog selectionDialog = ResourceSelectionDialog.forConfiguration(myShell, globalDialog, localDialog);
	selectionDialog.create();
	selectionDialog.getShell().setText("Configuration Context Selection");
	selectionDialog.setTitle("Select the Configuration Context");
	selectionDialog.setMessage("Choose the stream which determines the state of artifacts to use.");
	
	// configures the browser within the selection dialog to use specific credentials, avoiding the user to manually enter them.
	Browsers.setJazzCredentials(selectionDialog.getBrowser(), new UsernamePasswordCredentials("myUser", "myPassword"));
	
	// show the dialog
	if (selectionDialog.open() == Window.OK) {
	
	    // prints out the selected configuration
	    Link selectedConfiguration = selectionDialog.getResult().get(0);
	    System.out.println("Selected configuration: ");
	    System.out.println("  - Title: " + selectedConfiguration.getLabel());
	    System.out.println("  - URI:   " + selectedConfiguration.getValue());
	}

Related tasks
Using OSLC Configurations

Related reference
API Reference