Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProvider#readEntry()
The following examples show how to use
org.apache.olingo.odata2.api.ep.EntityProvider#readEntry() .
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: ODataClient.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
/** * Reads an entry (an Entity, a property, a complexType, ...). * * @param resource_path the resource path to the parent of the requested * EntitySet, as defined in {@link #getResourcePath(URI)}. * @param query_parameters Query parameters, as defined in {@link URI}. * * @return an ODataEntry for the given {@code resource_path}. * * @throws HttpException if the server emits an HTTP error code. * @throws IOException if the connection with the remote service fails. * @throws EdmException if the EDM does not contain the given entitySetName. * @throws EntityProviderException if reading of data (de-serialization) * fails. * @throws UriSyntaxException violation of the OData URI construction rules. * @throws UriNotMatchingException URI parsing exception. * @throws ODataException encapsulate the OData exceptions described above. * @throws InterruptedException if running thread has been interrupted. */ public ODataEntry readEntry(String resource_path, Map<String, String> query_parameters) throws IOException, ODataException, InterruptedException { if (resource_path == null || resource_path.isEmpty ()) throw new IllegalArgumentException ( "resource_path must not be null or empty."); ContentType contentType = ContentType.APPLICATION_ATOM_XML; String absolutUri = serviceRoot.toString () + '/' + resource_path; // Builds the query parameters string part of the URL. absolutUri = appendQueryParam (absolutUri, query_parameters); InputStream content = execute (absolutUri, contentType, "GET"); return EntityProvider.readEntry(contentType.type (), getEntitySet (resource_path), content, EntityProviderReadProperties.init ().build ()); }
Example 2
Source File: ServiceTicketODataConsumer.java From C4CODATAAPIDEVGUIDE with Apache License 2.0 | 6 votes |
public ODataEntry readEntry(String serviceUri, String contentType, String entitySetName, String keyValue, SystemQueryOptions options) throws IllegalStateException, IOException, EdmException, EntityProviderException { EdmEntityContainer entityContainer = readEdm() .getDefaultEntityContainer(); logger.info("Entity container is => " + entityContainer.getName()); String absolutUri = createUri(serviceUri, entitySetName, keyValue, options); InputStream content = executeGet(absolutUri, contentType); return EntityProvider.readEntry(contentType, entityContainer.getEntitySet(entitySetName), content, EntityProviderReadProperties.init().build()); }
Example 3
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content, final String requestContentType, final EntityProviderReadProperties properties) throws ODataBadRequestException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readEntry"); ODataEntry entryValues; try { entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, properties); } catch (final EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } context.stopRuntimeMeasurement(timingHandle); return entryValues; }
Example 4
Source File: ListsProcessor.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content, final String requestContentType, final EntityProviderReadProperties properties) throws ODataBadRequestException { ODataContext context = getContext(); final int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readEntry"); ODataEntry entryValues; try { entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, properties); } catch (final EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } context.stopRuntimeMeasurement(timingHandle); return entryValues; }
Example 5
Source File: ODataEntityParser.java From olingo-odata2 with Apache License 2.0 | 5 votes |
public final ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content, final String requestContentType, final boolean merge) throws ODataBadRequestException { ODataEntry entryValues; try { EntityProviderReadProperties entityProviderProperties = EntityProviderReadProperties.init().mergeSemantic(merge).build(); entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, entityProviderProperties); } catch (EntityProviderException e) { throw new ODataBadRequestException(ODataBadRequestException.BODY, e); } return entryValues; }
Example 6
Source File: ProducerConsumerIntegrationTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Map<String, Object> execute(final Map<String, Object> localRoomData, final EdmEntitySet roomSet, final String contentType) throws EntityProviderException { ODataResponse response = EntityProvider.writeEntry(contentType, roomSet, localRoomData, DEFAULT_WRITE_PROPERTIES); InputStream content = (InputStream) response.getEntity(); ODataEntry entry = EntityProvider.readEntry(contentType, roomSet, content, DEFAULT_READ_PROPERTIES); Map<String, Object> properties = entry.getProperties(); return properties; }
Example 7
Source File: XmlHelperTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void lolApiWithProtection() throws Exception { try { InputStream content = new ByteArrayInputStream(XML_LOL.getBytes("UTF-8")); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); EntityProvider.readEntry("application/xml", entitySet, content, EntityProviderReadProperties.init().build()); fail(); } catch (EntityProviderException e) { assertEquals(WstxParsingException.class, e.getCause().getClass()); } }
Example 8
Source File: XmlHelperTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void xxeApiWithProtection() throws Exception { try { InputStream content = new ByteArrayInputStream(XML_XXE.getBytes("UTF-8")); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); EntityProvider.readEntry("application/xml", entitySet, content, EntityProviderReadProperties.init().build()); fail(); } catch (EntityProviderException e) { assertEquals(WstxParsingException.class, e.getCause().getClass()); } }
Example 9
Source File: XmlHelperTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void xmlDoctypeApiWithProtection() throws Exception { try { InputStream content = new ByteArrayInputStream(XML_DOCTYPE.getBytes("UTF-8")); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); EntityProvider.readEntry("application/xml", entitySet, content, EntityProviderReadProperties.init().build()); fail(); } catch (EntityProviderException e) { assertEquals(WstxParsingException.class, e.getCause().getClass()); } }
Example 10
Source File: XmlHelperTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test @Ignore("not way to disable in parser") public void xmlProcessingApiWithProtection() throws Exception { try { InputStream content = new ByteArrayInputStream(XML_PROCESSING.getBytes("UTF-8")); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); EntityProvider.readEntry("application/xml", entitySet, content, EntityProviderReadProperties.init().build()); fail(); } catch (EntityProviderException e) { e.printStackTrace(); assertEquals(WstxParsingException.class, e.getCause().getClass()); } }