Parameters parameters)
throws Exception {
// general setup
OutputModule output = null;
ServiceSelector outputSelector = null;
// I don't like this. Have a better idea to return two values.
Object[] obj = this.readParameters(parameters);
String outputName = (String) obj[0];
boolean storeEmpty = ((Boolean) obj[1]).booleanValue();
Configuration outputConf = null;
if (outputName == null) {
outputName = this.outputName;
outputConf = this.outputConf;
}
Map actionMap = new HashMap();
try {
outputSelector =
(ServiceSelector) this.manager.lookup(OUTPUT_MODULE_SELECTOR);
if (outputName != null
&& outputSelector != null
&& outputSelector.isSelectable(outputName)) {
output = (OutputModule) outputSelector.select(outputName);
String[] names = parameters.getNames();
// parameters
for (int i = 0; i < names.length; i++) {
String sessionParamName = names[i];
String value = parameters.getParameter(sessionParamName);
if (storeEmpty || (value != null && !value.equals(""))) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(
"Propagating value "
+ value
+ " to output module"
+ sessionParamName);
}
output.setAttribute(
outputConf,
objectModel,
sessionParamName,
value);
actionMap.put(sessionParamName, value);
}
}
// defaults, that are not overridden
for (Iterator i = defaults.iterator(); i.hasNext();) {
Entry entry = (Entry) i.next();
if (!actionMap.containsKey(entry.key)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(
"Propagating default value "
+ entry.value
+ " to session attribute "
+ entry.key);
}
output.setAttribute(
outputConf,
objectModel,
entry.key,
entry.value);
actionMap.put(entry.key, entry.value);
}
}
output.commit(outputConf, objectModel);
}
} catch (Exception e) {
if (output != null) {
output.rollback(outputConf, objectModel, e);
}
throw e;
} finally {
if (outputSelector != null) {
if (output != null)
outputSelector.release(output);
this.manager.release(outputSelector);
}
}
return Collections.unmodifiableMap(actionMap);
}