Examples of CircleStreamBuffer


Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    entityTypes.add(entityType);
    schema.setEntityTypes(entityTypes);

    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);

    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");

    NamespaceContext ctx = new SimpleNamespaceContext(prefixMap);
    XMLUnit.setXpathNamespaceContext(ctx);

    String metadata = StringHelper.inputStreamToString(csb.getInputStream());
    assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    schema.setNamespace("http://namespace.com");
    schemas.add(schema);

    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
    String metadata = StringHelper.inputStreamToString(csb.getInputStream());

    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
    prefixMap.put("atom", "http://www.w3.org/2005/Atom");
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    schema.setNamespace("http://namespace.com");
    schemas.add(schema);

    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
    String metadata = StringHelper.inputStreamToString(csb.getInputStream());

    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
    prefixMap.put("atom", "http://www.w3.org/2005/Atom");
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    schema.setNamespace("http://namespace.com");
    schemas.add(schema);

    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
    String metadata = StringHelper.inputStreamToString(csb.getInputStream());

    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
    prefixMap.put("atom", "http://www.w3.org/2005/Atom");
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    schema.setNamespace("http://namespace.com");
    schemas.add(schema);

    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    // Execute
    Map<String, String> predefinedNamespaces = new HashMap<String, String>();
    predefinedNamespaces.put("foo", "http://www.foo.bar/Protocols/Data");
    DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8");
    XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer);
    XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, predefinedNamespaces);
    String metadata = StringHelper.inputStreamToString(csb.getInputStream());

    // Verify
    Map<String, String> prefixMap = new HashMap<String, String>();
    prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
    prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm");
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    if (schemas != null) {
      dataServiceVersion = calculateDataServiceVersion(schemas);
    }
    DataServices metadata = new DataServices().setSchemas(schemas).setDataServiceVersion(dataServiceVersion);
    OutputStreamWriter writer = null;
    CircleStreamBuffer csb = new CircleStreamBuffer();
    try {
      writer = new OutputStreamWriter(csb.getOutputStream(), DEFAULT_CHARSET);
      XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
      XmlMetadataProducer.writeMetadata(metadata, xmlStreamWriter, predefinedNamespaces);
    } catch (UnsupportedEncodingException e) {
      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
          .getSimpleName()), e);
    } catch (XMLStreamException e) {
      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
          .getSimpleName()), e);
    } catch (FactoryConfigurationError e) {
      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
          .getSimpleName()), e);
    }
    builder.entity(csb.getInputStream());
    builder.header(ODataHttpHeaders.DATASERVICEVERSION, dataServiceVersion);
    return builder.build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    @Override
    public ODataResponse readEntitySimpleProperty(final GetSimplePropertyUriInfo uriInfo, final String contentType)
        throws ODataException {
      assertTrue(getContext().isInBatchMode());

      CircleStreamBuffer buffer = new CircleStreamBuffer();
      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(buffer.getOutputStream()));
      JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
      try {
        jsonStreamWriter.beginObject()
            .name(FormatJson.D)
            .beginObject()
            .namedStringValue("EmployeeName", "Walter Winter")
            .endObject()
            .endObject();
        writer.flush();
        buffer.closeWrite();
      } catch (IOException e) {
        buffer.close();
        throw new RuntimeException(e);
      }

      ODataResponse oDataResponse =
          ODataResponse.entity(buffer.getInputStream()).status(HttpStatusCodes.OK).contentHeader("application/json")
              .build();
      return oDataResponse;
    }
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

    super(type);
  }

  @Before
  public void initialize() throws Exception {
    csb = new CircleStreamBuffer();
    OutputStream outStream = csb.getOutputStream();
    writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET);
    defaultProperties = EntityProviderWriteProperties.serviceRoot(BASE_URI).build();
    defaultEia =
        EntityInfoAggregator.create(MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"),
View Full Code Here

Examples of org.apache.olingo.odata2.core.ep.util.CircleStreamBuffer

   * @return an {@link ODataResponse} containing the serialized error message
   */
  @Override
  public ODataResponse writeErrorDocument(final HttpStatusCodes status, final String errorCode, final String message,
      final Locale locale, final String innerError) {
    CircleStreamBuffer csb = new CircleStreamBuffer();

    try {
      OutputStream outStream = csb.getOutputStream();
      XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outStream, DEFAULT_CHARSET);

      XmlErrorDocumentProducer producer = new XmlErrorDocumentProducer();
      producer.writeErrorDocument(writer, errorCode, message, locale, innerError);

      writer.flush();
      csb.closeWrite();

      ODataResponseBuilder response = ODataResponse.entity(csb.getInputStream())
          .header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10)
          .status(status);
      return response.build();
    } catch (Exception e) {
      csb.close();
      throw new ODataRuntimeException(e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.