DerivableHTTPMessageEntity entity,
HTTPMessageEntities requestEntities,
HTTPMessageEntityMerger merger)
throws HTTPException {
HTTPMessageEntity values [] = null;
String from = entity.getFrom();
if (from == null || requestEntities == null) {
if (entity.getName() == null && (from == null)) {
throw new HTTPException(
"Entity " + entity + " has neither a name " +
"nor a from property. This is not valid");
}
if (requestEntities == null && from != null) {
logger.warn("request-entities-null-ignoring-from-property",
entity.getName());
}
values = (HTTPMessageEntity[])
Array.newInstance(entity.getClass(), 1);
values[0] = entity;
} else {
// Find the alternative or source entitites in the request that
// are specified by the "from" property. We need to create an
// identity for this whose name is derived from "from" and whose
// other identity properties if any are derived from entity e.g.
// for cookies.
HTTPMessageEntity requestEntityArray [] =
requestEntities.retrieve(entity.getFromIdentity());
if (requestEntityArray.length == 0) {
throw new HTTPException(
"Entity " + entity.getName() + "has neither " +
"a from nor a value property. This is not valid");
}
values = (HTTPMessageEntity[]) Array.newInstance(entity.getClass(),
requestEntityArray.length);
// Now merge each requestEntity with the original entity.
for (int i = 0; i < requestEntityArray.length; i++) {
HTTPMessageEntity merged =
merger.mergeHTTPMessageEntities(entity,
requestEntityArray[i]);
values[i] = merged;
}
}