*/
private void processRequest(AgentRequest agentRequest) {
Parameters inputParameters = descriptorStore.createParameters();
ParameterNames outputParameters = descriptorStore.createParameterNames();
final Request request = agentRequest.getRequest();
final com.volantis.map.common.param.Parameters inputParams =
request.getInputParams();
final Iterator requestInputParams = inputParams.getParameterNames();
try {
while (requestInputParams.hasNext()) {
String paramName = (String) requestInputParams.next();
inputParameters.setParameterValue(
paramName, inputParams.getParameterValue(paramName));
}
} catch (MissingParameterException e) {
// this is not expected as we iterate through the parameter names
throw new UndeclaredThrowableException(e);
}
Iterator requestOutputParams = request.getOutputParams().iterator();
while (requestOutputParams.hasNext()) {
String paramName = (String) requestOutputParams.next();
outputParameters.setName(paramName);
}
// TODO later If there's an appropriate plugin, allow it to do pre-processing of the parameters.
// plugin.preProcess(inputParameters, outputParameters, device);
ResourceDescriptor descriptor = descriptorStore.createDescriptor(
request.getResourceType(), inputParameters, outputParameters,
timeToLive);
// TODO later If there's an appropriate plugin, allow it to do post-processing of the parameters.
// plugin.postProcess(outputParameters, device);
MutableParameters callbackParameters = COMMON_FACTORY.createMutableParameters();
Iterator processedParameters = descriptor.getOutputParameters().iterator();
while (processedParameters.hasNext()) {
Parameters.Entry entry = (Parameters.Entry) processedParameters.next();
callbackParameters.setParameterValue(entry.getName(), entry.getValue());
}
String externalId = descriptor.getExternalID();
externalIds.add(externalId);
// base 64 can contain "/"
externalId = externalId.replaceAll("/", "-");
callbackParameters.setParameterValue(
OUTPUT_URL_PARAMETER_NAME, urlPrefix + externalId);
try {
agentRequest.getResponseCallback().execute(callbackParameters);
} catch (Exception e) {
LOGGER.warn("error-executing-response-callback", request.getSourceURL(),e);
}
}