Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProvider#parseBatchRequest()
The following examples show how to use
org.apache.olingo.odata2.api.ep.EntityProvider#parseBatchRequest() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataJPADefaultProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public ODataResponse executeBatch(final BatchHandler handler, final String contentType, final InputStream content) throws ODataException { try { oDataJPAContext.setODataContext(getContext()); ODataResponse batchResponse; List<BatchResponsePart> batchResponseParts = new ArrayList<BatchResponsePart>(); PathInfo pathInfo = getContext().getPathInfo(); EntityProviderBatchProperties batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); List<BatchRequestPart> batchParts = EntityProvider.parseBatchRequest(contentType, content, batchProperties); for (BatchRequestPart batchPart : batchParts) { batchResponseParts.add(handler.handleBatchPart(batchPart)); } batchResponse = EntityProvider.writeBatchResponse(batchResponseParts); return batchResponse; } finally { close(true); } }
Example 2
Source File: BatchHandlerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void contentIdReferencing() throws Exception { SERVICE_ROOT = SERVICE_BASE; PathInfoImpl pathInfo = new PathInfoImpl(); pathInfo.setServiceRoot(new URI(SERVICE_ROOT)); pathInfo.setODataPathSegment(Collections.<PathSegment> singletonList( new ODataPathSegmentImpl("$batch", null))); EntityProviderBatchProperties properties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); InputStream content = readFile("/batchContentIdReferencing.batch"); List<BatchRequestPart> parsedRequest = EntityProvider.parseBatchRequest(CONTENT_TYPE, content, properties); PathInfo firstPathInfo = parsedRequest.get(0).getRequests().get(0).getPathInfo(); assertFirst(firstPathInfo); handler.handleBatchPart(parsedRequest.get(0)); }
Example 3
Source File: BatchHandlerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void contentIdReferencingForGet() throws Exception { SERVICE_ROOT = SERVICE_BASE; PathInfoImpl pathInfo = new PathInfoImpl(); pathInfo.setServiceRoot(new URI(SERVICE_ROOT)); pathInfo.setODataPathSegment(Collections.<PathSegment> singletonList( new ODataPathSegmentImpl("$batch", null))); EntityProviderBatchProperties properties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); InputStream content = readFile("/batchContentIdReferencingForGet.batch"); List<BatchRequestPart> parsedRequest = EntityProvider.parseBatchRequest(CONTENT_TYPE, content, properties); PathInfo firstPathInfo = parsedRequest.get(0).getRequests().get(0).getPathInfo(); assertFirst(firstPathInfo); handler.handleBatchPart(parsedRequest.get(0)); handler.handleBatchPart(parsedRequest.get(1)); }
Example 4
Source File: BatchHandlerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void contentIdReferencingWithAdditionalSegments() throws Exception { SERVICE_ROOT = SERVICE_BASE + "seg1/seg2/"; PathInfoImpl pathInfo = new PathInfoImpl(); pathInfo.setPrecedingPathSegment(Arrays.asList( (PathSegment) new ODataPathSegmentImpl("seg1", null), (PathSegment) new ODataPathSegmentImpl("seg2", null))); pathInfo.setServiceRoot(new URI(SERVICE_ROOT)); pathInfo.setODataPathSegment(Collections.<PathSegment> singletonList( new ODataPathSegmentImpl("$batch", null))); EntityProviderBatchProperties properties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); InputStream content = readFile("/batchContentIdReferencing.batch"); List<BatchRequestPart> parsedRequest = EntityProvider.parseBatchRequest(CONTENT_TYPE, content, properties); PathInfo firstPathInfo = parsedRequest.get(0).getRequests().get(0).getPathInfo(); assertFirst(firstPathInfo); handler.handleBatchPart(parsedRequest.get(0)); }
Example 5
Source File: BatchHandlerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void contentIdReferencingWithAdditionalSegmentsAndMatrixParameter() throws Exception { SERVICE_ROOT = SERVICE_BASE + "seg1;v=1/seg2;v=2/"; PathInfoImpl pathInfo = new PathInfoImpl(); pathInfo.setPrecedingPathSegment(Arrays.asList( (PathSegment) new ODataPathSegmentImpl("seg1", Collections.singletonMap("v", Collections.singletonList("1"))), (PathSegment) new ODataPathSegmentImpl("seg2", Collections.singletonMap("v", Collections.singletonList("2"))))); pathInfo.setServiceRoot(new URI(SERVICE_ROOT)); pathInfo.setODataPathSegment(Collections.<PathSegment> singletonList( new ODataPathSegmentImpl("$batch", null))); EntityProviderBatchProperties properties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); InputStream content = readFile("/batchContentIdReferencing.batch"); List<BatchRequestPart> parsedRequest = EntityProvider.parseBatchRequest(CONTENT_TYPE, content, properties); PathInfo firstPathInfo = parsedRequest.get(0).getRequests().get(0).getPathInfo(); assertFirst(firstPathInfo); handler.handleBatchPart(parsedRequest.get(0)); }
Example 6
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse executeBatch(final BatchHandler handler, final String contentType, final InputStream content) throws ODataException { ODataResponse batchResponse; List<BatchResponsePart> batchResponseParts = new ArrayList<BatchResponsePart>(); PathInfo pathInfo = getContext().getPathInfo(); EntityProviderBatchProperties batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); List<BatchRequestPart> batchParts = EntityProvider.parseBatchRequest(contentType, content, batchProperties); for (BatchRequestPart batchPart : batchParts) { batchResponseParts.add(handler.handleBatchPart(batchPart)); } batchResponse = EntityProvider.writeBatchResponse(batchResponseParts); return batchResponse; }
Example 7
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse executeBatch(final BatchHandler handler, final String contentType, final InputStream content) throws ODataException { ODataResponse batchResponse; List<BatchResponsePart> batchResponseParts = new ArrayList<BatchResponsePart>(); PathInfo pathInfo = getContext().getPathInfo(); EntityProviderBatchProperties batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build(); List<BatchRequestPart> batchParts = EntityProvider.parseBatchRequest(contentType, content, batchProperties); for (BatchRequestPart batchPart : batchParts) { batchResponseParts.add(handler.handleBatchPart(batchPart)); } batchResponse = EntityProvider.writeBatchResponse(batchResponseParts); return batchResponse; }