2022

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
 public List<HelloParameter> readHello(HelloFilter filter){

	logger.info("Received Read operation with filter:" + filter.key + ":with session" + sessionKey);

	System.out.println("Received Read operation with filter:" + filter.key + ":with session" + sessionKey);

	List<HelloParameter> returnList = new ArrayList<HelloWorldSvc.HelloParameter>();

	for(HelloParameter initParam : initParams) {

		if(filter.key.equalsIgnoreCase(initParam.name)) {

			//Now set the value to "Hello":name:sessionId
			initParam.value = "Hello:"+initParam.name+":"+sessionKey;

			System.out.println("Matched Key:" + initParam.name + ":value:" + initParam.value );

			logger.info("Matched Key:" + initParam.name + ":value:" + initParam.value );

			returnList.add(initParam);
		}
	}

	return returnList;
}

e. WriteHello 

In the write method we take the input list and print the value based on the logic explained above after iterating through the list and returns back an array of SaveResults with the newid which contains the sessionKey appended
You can view the code below 

Code Block

 public SaveResult[] writeHello(List<HelloParameter> inputParams){

	List<SaveResult> saveResults = new ArrayList<SaveResult>();

	logger.info("Received write operation with session" + sessionKey);

	System.out.println("Received write operation with session" + sessionKey);

	for(HelloParameter inputParam : inputParams) {

		System.out.println("Received input parameter:id:" + inputParam.id + ":name:" + inputParam.name);
		logger.info("Received input parameter:id:" + inputParam.id + ":name:" + inputParam.name);

		inputParam.value = "Hello:"+inputParam.name+":"+sessionKey;
		System.out.println("Writing value:" + inputParam.value );
		logger.info("Writing value:" + inputParam.value);

		SaveResult result = new SaveResult();
		result.id = inputParam.id;
		result.newid = inputParam.id+":"+sessionKey;
		result.success = true;

		saveResults.add(result);

	}

	return saveResults.toArray(new SaveResult[] {});
}