use of org.apache.olingo.odata2.api.client.batch.BatchPart in project camel by apache.
the class Olingo2AppImpl method addChangeSetParts.
private void addChangeSetParts(ArrayList<BatchPart> parts, ArrayList<BatchChangeSetPart> changeSetParts) {
final BatchChangeSet changeSet = BatchChangeSet.newBuilder().build();
for (BatchChangeSetPart changeSetPart : changeSetParts) {
changeSet.add(changeSetPart);
}
parts.add(changeSet);
}
use of org.apache.olingo.odata2.api.client.batch.BatchPart in project camel by apache.
the class Olingo2AppImpl method parseBatchRequest.
private ODataResponse parseBatchRequest(final Edm edm, final List<Olingo2BatchRequest> batchParts) throws IOException, EntityProviderException, ODataApplicationException, EdmException, URISyntaxException {
// create Batch request from parts
final ArrayList<BatchPart> parts = new ArrayList<BatchPart>();
final ArrayList<BatchChangeSetPart> changeSetParts = new ArrayList<BatchChangeSetPart>();
final Map<String, String> contentIdMap = new HashMap<String, String>();
for (Olingo2BatchRequest batchPart : batchParts) {
if (batchPart instanceof Olingo2BatchQueryRequest) {
// need to add change set parts collected so far??
if (!changeSetParts.isEmpty()) {
addChangeSetParts(parts, changeSetParts);
changeSetParts.clear();
contentIdMap.clear();
}
// add to request parts
final UriInfoWithType uriInfo = parseUri(edm, batchPart.getResourcePath(), null);
parts.add(createBatchQueryPart(uriInfo, (Olingo2BatchQueryRequest) batchPart));
} else {
// add to change set parts
final BatchChangeSetPart changeSetPart = createBatchChangeSetPart(edm, contentIdMap, (Olingo2BatchChangeRequest) batchPart);
changeSetParts.add(changeSetPart);
}
}
// add any remaining change set parts
if (!changeSetParts.isEmpty()) {
addChangeSetParts(parts, changeSetParts);
}
final String boundary = BOUNDARY_PREFIX + UUID.randomUUID();
InputStream batchRequest = EntityProvider.writeBatchRequest(parts, boundary);
// two blank lines are already added. No need to add extra blank lines
final String contentHeader = BATCH_CONTENT_TYPE + BOUNDARY_PARAMETER + boundary;
return ODataResponse.entity(batchRequest).contentHeader(contentHeader).build();
}
Aggregations