Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Creating a new adapter

Adapters are trivial to create, however you will need to modify the portlet source to do so. We made this as straightforward as possible.

Create a class that extends au.edu.anu.portal.portlets.basiclti.adapters.AbstractAdapter

You then need to provide an implementation for a single method:

public Map<String,String> processLaunchData(Map<String,String> params);

In this method, you perform any processing or parameter injection that you need. The following is an example that adds an extra parameter and lowercases another parameter:

SampleAdapter.java

public class SampleAdapter extends AbstractAdapter {
	
	@Override
	public Map<String, String> processLaunchData(Map<String, String> params) {
		
		log.debug("SampleAdapter.processLaunchData() called");
		
		//lowercase a parameter
		params.put("user_id", StringUtils.lowerCase(params.get("user_id")));
		
		//conditionally add new parameter
		if(Boolean.parseBoolean(params.get("some_boolean_param"))) {
			params.put("my_param", "My Special Parameter");
		}
		
		//add defaults
		params.putAll(super.getDefaultParameters());
		
		return params;
	}
}



You must include the following at the end of any logic you perform:

//add defaults
params.putAll(super.getDefaultParameters());
  • No labels