@Test(expected = ODataException.class) public void errorEdmProvider() throws Exception { EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImplProv(null); serviceMetadata.getMetadata(); }
@Override public InputStream getMetadata() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } OutputStreamWriter writer = null; CircleStreamBuffer csb = new CircleStreamBuffer(); EntityProviderException cachedException = null; DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion()); try { writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null); return csb.getInputStream(); } catch (XMLStreamException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } catch (UnsupportedEncodingException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.COMMON, e); } } } } }
EdmServiceMetadataImplProv implements EdmServiceMetadata { @Override public InputStream getMetadata() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } OutputStreamWriter writer = null; CircleStreamBuffer csb = new CircleStreamBuffer(); EntityProviderException cachedException = null; DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion()); try { writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null); return csb.getInputStream(); } catch (XMLStreamException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } catch (UnsupportedEncodingException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.COMMON, e); } } } } } }
EdmServiceMetadataImplProv implements EdmServiceMetadata { @Override public InputStream getMetadata() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } OutputStreamWriter writer = null; CircleStreamBuffer csb = new CircleStreamBuffer(); EntityProviderException cachedException = null; DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion()); try { writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null); return csb.getInputStream(); } catch (XMLStreamException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } catch (UnsupportedEncodingException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.COMMON, e); } } } } } EdmServiceMetadataImplProv(final EdmProvider edmProvider); }
EdmServiceMetadataImplProv implements EdmServiceMetadata { @Override public InputStream getMetadata() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } OutputStreamWriter writer = null; CircleStreamBuffer csb = new CircleStreamBuffer(); EntityProviderException cachedException = null; DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion()); try { writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null); return csb.getInputStream(); } catch (XMLStreamException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } catch (UnsupportedEncodingException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.COMMON, e); } } } } } EdmServiceMetadataImplProv(final EdmProvider edmProvider); @Override InputStream getMetadata(); @Override String getDataServiceVersion(); @Override List<EdmEntitySetInfo> getEntitySetInfos(); }
EdmServiceMetadataImplProv implements EdmServiceMetadata { @Override public InputStream getMetadata() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } OutputStreamWriter writer = null; CircleStreamBuffer csb = new CircleStreamBuffer(); EntityProviderException cachedException = null; DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(getDataServiceVersion()); try { writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = XmlHelper.getXMLOutputFactory().createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, null); return csb.getInputStream(); } catch (XMLStreamException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } catch (UnsupportedEncodingException e) { cachedException = new EntityProviderException(EntityProviderException.COMMON, e); throw cachedException; } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { if (cachedException != null) { throw cachedException; } else { throw new EntityProviderException(EntityProviderException.COMMON, e); } } } } } EdmServiceMetadataImplProv(final EdmProvider edmProvider); @Override InputStream getMetadata(); @Override String getDataServiceVersion(); @Override List<EdmEntitySetInfo> getEntitySetInfos();  }