org.apache.olingo.commons.api.edmx.EdmxReference Java Examples
The following examples show how to use
org.apache.olingo.commons.api.edmx.EdmxReference.
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: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor()); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #2
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #3
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #4
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(odata, edm.getEdm()); session.setAttribute(Storage.class.getName(), storage); } ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #5
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #6
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #7
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #8
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in DemoServlet", e); throw new ServletException(e); } }
Example #9
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #10
Source File: ProductsServlet.java From syndesis with Apache License 2.0 | 6 votes |
@Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { Storage storage = Storage.getInstance(); // create odata handler and configure it with CsdlEdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new ProductsEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new ProductsEntityCollectionProcessor(storage)); handler.register(new ProductEntityProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred: ", e); throw new ServletException(e); } }
Example #11
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); handler.register(new DemoActionProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #12
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); handler.register(new DemoBatchProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #13
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in DemoServlet", e); throw new ServletException(e); } }
Example #14
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(odata, edm.getEdm()); session.setAttribute(Storage.class.getName(), storage); } ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #15
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #16
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }
Example #17
Source File: CarsServlet.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { HttpSession session = req.getSession(true); DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName()); if (dataProvider == null) { dataProvider = new DataProvider(); session.setAttribute(DataProvider.class.getName(), dataProvider); LOG.info("Created new data provider."); } OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new CarsEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new CarsProcessor(dataProvider)); handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error", e); throw new ServletException(e); } }
Example #18
Source File: JaxrsODataService.java From cxf with Apache License 2.0 | 6 votes |
@GET @Path("{id:.*}") public Response service(@Context HttpServletRequest req, @Context HttpServletResponse resp) { String requestMapping = req.getContextPath() + req.getServletPath() + "/DemoService.svc"; req.setAttribute("requestMapping", requestMapping); // create odata handler and configure it with EdmProvider and Processor OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor()); // let the handler do the work handler.process(req, resp); return Response.ok().build(); }
Example #19
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void uriParserExceptionResultsInRightResponseEdmCause() throws Exception { final OData odata = OData.newInstance(); final ServiceMetadata serviceMetadata = odata.createServiceMetadata( new CsdlAbstractEdmProvider() { @Override public CsdlEntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName) throws ODataException { throw new ODataException("msg"); } }, Collections.<EdmxReference> emptyList()); ODataRequest request = new ODataRequest(); request.setMethod(HttpMethod.GET); request.setRawODataPath("EdmException"); final ODataResponse response = new ODataHandlerImpl(odata, serviceMetadata, new ServerCoreDebugger(odata)).process(request); assertNotNull(response); assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode()); }
Example #20
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void handlerExtTest() throws Exception { final OData odata = OData.newInstance(); final ServiceMetadata serviceMetadata = odata.createServiceMetadata( new CsdlAbstractEdmProvider() { @Override public CsdlEntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName) throws ODataException { throw new ODataException("msg"); } }, Collections.<EdmxReference> emptyList()); ODataRequest request = new ODataRequest(); request.setMethod(HttpMethod.GET); request.setRawODataPath("EdmException"); ODataHandlerImpl handler = new ODataHandlerImpl(odata, serviceMetadata, new ServerCoreDebugger(odata)); Processor extension = new TechnicalActionProcessor(null, serviceMetadata); handler.register(extension); assertNull(handler.getLastThrownException()); assertNull(handler.getUriInfo()); }
Example #21
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void dispatchEmptyContentWithoutContentType() { final String path = "ESAllPrim"; final EntityCollectionProcessor processor = mock(EntityCollectionProcessor.class); ODataRequest request = new ODataRequest(); request.setMethod(HttpMethod.POST); request.setRawBaseUri(BASE_URI); request.setRawRequestUri(BASE_URI); request.setRawODataPath(path); request.setBody(new ByteArrayInputStream(new byte[0])); final OData odata = OData.newInstance(); final ServiceMetadata metadata = odata.createServiceMetadata( new EdmTechProvider(), Collections.<EdmxReference> emptyList()); ODataHandlerImpl handler = new ODataHandlerImpl(odata, metadata, new ServerCoreDebugger(odata)); if (processor != null) { handler.register(processor); } final ODataResponse response = handler.process(request); assertNotNull(response); }
Example #22
Source File: EdmAssistedJsonSerializerTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void metadataMin() throws Exception { final ServiceMetadata metadata = oData.createServiceMetadata(null, Collections.<EdmxReference> emptyList(), new MetadataETagSupport("W/\"42\"")); Entity entity = new Entity(); entity.setType("Namespace.EntityType"); entity.setId(URI.create("ID")); entity.setETag("W/\"1000\""); Link link = new Link(); link.setHref("editLink"); entity.setEditLink(link); entity.setMediaContentSource(URI.create("media")); entity.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, UUID.fromString("12345678-ABCD-1234-CDEF-123456789012"))); EntityCollection entityCollection = new EntityCollection(); entityCollection.getEntities().add(entity); Assert.assertEquals("{\"@odata.context\":\"$metadata#EntitySet(Property1)\"," + "\"@odata.metadataEtag\":\"W/\\\"42\\\"\",\"value\":[{" + "\"@odata.etag\":\"W/\\\"1000\\\"\"," + "\"Property1\":\"12345678-abcd-1234-cdef-123456789012\"," + "\"@odata.editLink\":\"editLink\"," + "\"@odata.mediaReadLink\":\"editLink/$value\"}]}", serialize(serializerMin, metadata, null, entityCollection, null)); }
Example #23
Source File: MetadataDocumentJsonSerializer.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private void appendReference(JsonGenerator json) throws SerializerException, IOException { json.writeObjectFieldStart(REFERENCES); for (final EdmxReference reference : serviceMetadata.getReferences()) { json.writeObjectFieldStart(reference.getUri().toASCIIString()); List<EdmxReferenceInclude> includes = reference.getIncludes(); if (!includes.isEmpty()) { appendIncludes(json, includes); } List<EdmxReferenceIncludeAnnotation> includeAnnotations = reference.getIncludeAnnotations(); if (!includeAnnotations.isEmpty()) { appendIncludeAnnotations(json, includeAnnotations); } json.writeEndObject(); } json.writeEndObject(); }
Example #24
Source File: ServiceMetadataImpl.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public ServiceMetadataImpl(final CsdlEdmProvider edmProvider, final List<EdmxReference> references, final ServiceMetadataETagSupport serviceMetadataETagSupport) { edm = new EdmProviderImpl(edmProvider); this.references = new ArrayList<>(); this.references.addAll(references); this.serviceMetadataETagSupport = serviceMetadataETagSupport; }
Example #25
Source File: ODataServiceHandler.java From micro-integrator with Apache License 2.0 | 5 votes |
public ODataServiceHandler(ODataDataHandler dataHandler, String namespace, String configID) throws ODataServiceFault { ODataAdapter processor = new ODataAdapter(dataHandler, namespace, configID); OData odata = OData4Impl.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(processor.getEdmProvider(), new ArrayList<EdmxReference>()); this.handler = odata.createHandler(edm); this.handler.register(processor); }
Example #26
Source File: TechnicalServlet.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Override protected void service(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { OData odata = OData.newInstance(); EdmxReference reference = new EdmxReference(URI.create("../v4.0/cs02/vocabularies/Org.OData.Core.V1.xml")); reference.addInclude(new EdmxReferenceInclude("Org.OData.Core.V1", "Core")); final ServiceMetadata serviceMetadata = odata.createServiceMetadata( new EdmTechProvider(), Collections.singletonList(reference), new MetadataETagSupport(metadataETag)); HttpSession session = request.getSession(true); DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName()); if (dataProvider == null) { dataProvider = new DataProvider(odata, serviceMetadata.getEdm()); session.setAttribute(DataProvider.class.getName(), dataProvider); LOG.info("Created new data provider."); } ODataHttpHandler handler = odata.createHandler(serviceMetadata); // Register processors. handler.register(new TechnicalEntityProcessor(dataProvider, serviceMetadata)); handler.register(new TechnicalPrimitiveComplexProcessor(dataProvider, serviceMetadata)); handler.register(new TechnicalActionProcessor(dataProvider, serviceMetadata)); handler.register(new TechnicalBatchProcessor(dataProvider)); // Register helpers. handler.register(new ETagSupport()); handler.register(new DefaultDebugSupport()); // Process the request. handler.process(request, response); } catch (final RuntimeException e) { LOG.error("Server Error", e); throw new ServletException(e); } }
Example #27
Source File: ODataNettyHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Test public void testNettyReqResp_GetMethod() { MetadataProcessor processor = mock(MetadataProcessor.class); final ODataNetty odata = ODataNetty.newInstance(); final ServiceMetadata metadata = odata.createServiceMetadata( new EdmTechProvider(), Collections.<EdmxReference> emptyList()); ODataNettyHandler handler = odata.createNettyHandler(metadata); handler.register(processor); DefaultFullHttpRequest nettyRequest = mock(DefaultFullHttpRequest.class); io.netty.handler.codec.http.HttpMethod httpMethod = mock(io.netty.handler.codec.http.HttpMethod.class); when(httpMethod.name()).thenReturn("GET"); when(nettyRequest.method()).thenReturn(httpMethod); HttpVersion httpVersion = mock(HttpVersion.class); when(httpVersion.text()).thenReturn("HTTP/1.0"); when(nettyRequest.protocolVersion()).thenReturn(httpVersion); when(nettyRequest.uri()).thenReturn("/odata.svc/$metadata"); HttpHeaders headers = mock(HttpHeaders.class); headers.add("Accept", "application/atom+xml"); Set<String> set = new HashSet<String>(); set.add("Accept"); when(headers.names()).thenReturn(set); when(nettyRequest.headers()).thenReturn(headers); when(nettyRequest.content()).thenReturn(Unpooled.buffer()); DefaultFullHttpResponse nettyResponse = mock(DefaultFullHttpResponse.class); when(nettyResponse.status()).thenReturn(HttpResponseStatus.OK); when(nettyResponse.headers()).thenReturn(headers); when(nettyResponse.content()).thenReturn(Unpooled.buffer()); Map<String, String> requestParams = new HashMap<String, String>(); requestParams.put("contextPath", "/odata.svc"); handler.processNettyRequest(nettyRequest, nettyResponse, requestParams); nettyResponse.status(); assertEquals(HttpStatusCode.OK.getStatusCode(), HttpResponseStatus.OK.code()); }
Example #28
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private ODataResponse dispatch(final HttpMethod method, final String path, final String query, final String headerName, final String headerValue, final Processor processor) { ODataRequest request = new ODataRequest(); request.setMethod(method); request.setRawBaseUri(BASE_URI); if (path.isEmpty()) { request.setRawRequestUri(BASE_URI); } request.setRawODataPath(path); request.setRawQueryPath(query); if (headerName != null) { request.addHeader(headerName, Collections.singletonList(headerValue)); } if (headerName != HttpHeader.CONTENT_TYPE) { request.addHeader(HttpHeader.CONTENT_TYPE, Collections.singletonList( ContentType.JSON.toContentTypeString())); } final OData odata = OData.newInstance(); final ServiceMetadata metadata = odata.createServiceMetadata( new EdmTechProvider(), Collections.<EdmxReference> emptyList()); ODataHandlerImpl handler = new ODataHandlerImpl(odata, metadata, new ServerCoreDebugger(odata)); if (processor != null) { handler.register(processor); } final ODataResponse response = handler.process(request); assertNotNull(response); return response; }
Example #29
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private ODataResponse dispatchToValidateHeaders(final HttpMethod method, final String path, final String query, final Map<String, String> headers, final Processor processor) throws ODataHandlerException { ODataRequest request = new ODataRequest(); request.setMethod(method); request.setRawBaseUri(BASE_URI); for (Entry<String, String> header : headers.entrySet()) { request.addHeader(header.getKey(), header.getValue()); } if (path.isEmpty()) { request.setRawRequestUri(BASE_URI); } request.setRawODataPath(path); request.setRawQueryPath(query); final OData odata = OData.newInstance(); final ServiceMetadata metadata = odata.createServiceMetadata( new EdmTechProvider(), Collections.<EdmxReference> emptyList()); ODataHandlerImpl handler = new ODataHandlerImpl(odata, metadata, new ServerCoreDebugger(odata)); if (processor != null) { handler.register(processor); } final ODataResponse response = handler.process(request); return response; }
Example #30
Source File: DemoServlet.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { OData odata = OData.newInstance(); ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>()); try { HttpSession session = req.getSession(true); Storage storage = (Storage) session.getAttribute(Storage.class.getName()); if (storage == null) { storage = new Storage(odata, edm.getEdm()); session.setAttribute(Storage.class.getName(), storage); } // create odata handler and configure it with EdmProvider and Processor ODataHttpHandler handler = odata.createHandler(edm); handler.register(new DemoEntityCollectionProcessor(storage)); handler.register(new DemoEntityProcessor(storage)); handler.register(new DemoPrimitiveProcessor(storage)); handler.register(new DemoActionProcessor(storage)); handler.register(new DemoBatchProcessor(storage)); // let the handler do the work handler.process(req, resp); } catch (RuntimeException e) { LOG.error("Server Error occurred in ExampleServlet", e); throw new ServletException(e); } }