in core/src/main/java/flex/messaging/endpoints/amf/LegacyFilter.java [71:155]
public void invoke(final ActionContext context) throws IOException {
MessageBody requestBody = context.getRequestMessageBody();
context.setLegacy(true);
// Parameters are usually sent as an AMF Array
Object data = requestBody.getData();
List newParams = null;
// Check whether we're a new Flex 2.0 Messaging request
if (data != null) {
if (data.getClass().isArray()) {
int paramLength = Array.getLength(data);
if (paramLength == 1) {
Object obj = Array.get(data, 0);
if (obj != null && obj instanceof Message) {
context.setLegacy(false);
newParams = new ArrayList();
newParams.add(obj);
}
}
// It was not a Flex 2.0 Message, but we have an array, use its contents as our params
if (newParams == null) {
newParams = new ArrayList();
for (int i = 0; i < paramLength; i++) {
try {
newParams.add(Array.get(data, i));
} catch (Throwable t) {
}
}
}
} else if (data instanceof List) {
List paramList = (List) data;
if (paramList.size() == 1) {
Object obj = paramList.get(0);
if (obj != null && obj instanceof Message) {
context.setLegacy(false);
newParams = new ArrayList();
newParams.add(obj);
}
}
// It was not a Flex 2.0 Message, but we have a list, so use it as our params
if (newParams == null) {
newParams = (List) data;
}
}
}
// We still haven't found any lists of params, so create one with
// whatever data we have.
if (newParams == null) {
newParams = new ArrayList();
newParams.add(data);
}
if (context.isLegacy()) {
newParams = legacyRequest(context, newParams);
}
requestBody.setData(newParams);
next.invoke(context);
if (context.isLegacy()) {
MessageBody responseBody = context.getResponseMessageBody();
Object response = responseBody.getData();
if (response instanceof ErrorMessage) {
ErrorMessage error = (ErrorMessage) response;
ASObject aso = new ASObject();
aso.put("message", error.faultString);
aso.put("code", error.faultCode);
aso.put("details", error.faultDetail);
aso.put("rootCause", error.rootCause);
response = aso;
} else if (response instanceof Message) {
response = ((Message) response).getBody();
}
responseBody.setData(response);
}
}