}
} else {
throw new ProcessException(new ErrorMessage("unpresentableValue"));
}
}
Store resultStore = stepStore;
if ( store == Store.OUTPUT ) {
// check if result is defined
boolean resultDefined = false;
for ( int i = 0; i < resultEntryDescriptors.length; i++ ) {
if ( resultEntryDescriptors[i].getName().equals(key) ) {
// check if result matches description
if ( ContentType.matches(resultEntryDescriptors[i].getContentType(), value.getContentType()) ) {
result.addResultEntry(key, value);
resultDefined = true;
break;
} else {
throw new ProcessException(new ErrorMessage("contentTypeMismatch", new String[] { key, value.getContentType(), resultEntryDescriptors[i].getContentType()}));
}
}
}
if ( !resultDefined ) {
throw new ProcessException(new ErrorMessage("undefinedResultKey", new String[] { key }));
}
} else {
if ( store != Store.NONE ) {
resultStore = context.getStore(store);
}
if ( resultStore == null ) {
throw new ProcessException(new ErrorMessage("storeNotAvailable", new String[] { key, Store.stores[store] }));
} else {
try {
String evaluatedKey = Process.evaluateKey(key, context);
if ( evaluatedKey != null ) {
if ( domain != null ) {
Map map;
MapValue mapResource = (MapValue)resultStore.get(domain);
if ( mapResource == null ) {
map = new HashMap();
mapResource = new MapValue(map);
} else {
map = mapResource.getMap();
}
map.put(evaluatedKey, value);
evaluatedKey = domain;
value = mapResource;
}
if ( timeout != -1 ) {
resultStore.put(evaluatedKey, value, timeout);
} else {
resultStore.put(evaluatedKey, value);
}
}
} catch ( IOException e ) {
throw new ProcessException(new ErrorMessage("storingResultFailed"), e);
}