} catch (Exception e) {
// report any parsing errors as error response
responses.add(new Olingo2BatchResponse(
Integer.parseInt(response.getStatusCode()),
response.getStatusInfo(), response.getContentId(), response.getHeaders(),
new ODataApplicationException(
"Error parsing response for " + request + ": " + e.getMessage(),
Locale.ENGLISH, e)));
}
}
responseHandler.onResponse((T) responses);
break;
case URI4:
case URI5:
// simple property
// get the response content as Object for $value or Map<String, Object> otherwise
final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
if (uriInfo.isValue()) {
responseHandler.onResponse(
(T) EntityProvider.readPropertyValue(simpleProperty,
result.getEntity().getContent()));
} else {
responseHandler.onResponse(
(T) EntityProvider.readProperty(getContentType(), simpleProperty,
result.getEntity().getContent(),
EntityProviderReadProperties.init().build()));
}
break;
case URI3:
// complex property
// get the response content as Map<String, Object>
final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
responseHandler.onResponse((T)EntityProvider.readProperty(getContentType(),
complexProperty, result
.getEntity()
.getContent(),
EntityProviderReadProperties
.init().build()));
break;
case URI7A:
// $links with 0..1 cardinality property
// get the response content as String
final EdmEntitySet targetLinkEntitySet = uriInfo.getTargetEntitySet();
responseHandler.onResponse((T)EntityProvider.readLink(getContentType(),
targetLinkEntitySet, result
.getEntity()
.getContent()));
break;
case URI7B:
// $links with * cardinality property
// get the response content as java.util.List<String>
final EdmEntitySet targetLinksEntitySet = uriInfo.getTargetEntitySet();
responseHandler.onResponse((T)EntityProvider.readLinks(getContentType(),
targetLinksEntitySet,
result.getEntity()
.getContent()));
break;
case URI1:
case URI2:
case URI6A:
case URI6B:
// Entity
// get the response content as an ODataEntry object
responseHandler.onResponse((T) EntityProvider.readEntry(response.getContentHeader(),
uriInfo.getTargetEntitySet(),
result.getEntity().getContent(),
EntityProviderReadProperties.init().build()));
break;
default:
throw new ODataApplicationException("Unsupported resource type " + uriInfo.getTargetType(),
Locale.ENGLISH);
}
}
}