Package org.apache.olingo.odata2.core.ep.feed

Examples of org.apache.olingo.odata2.core.ep.feed.FeedMetadataImpl


   * @return
   */
  private Object extractODataEntity(final boolean isFeed, final List<ODataEntry> inlineEntries) {
    if (isFeed) {
      // TODO: fill metadata correctly with inline count and inline next link. Both are currently ignored.
      return new ODataDeltaFeedImpl(inlineEntries, new FeedMetadataImpl());
    } else if (!inlineEntries.isEmpty()) {
      return inlineEntries.get(0);
    }
    return null;
  }
View Full Code Here


          reader.beginObject();
          openedObjects++;
          nextName = reader.nextName();
        }
      }
      FeedMetadataImpl feedMetadata = new FeedMetadataImpl();
      if (FormatJson.COUNT.equals(nextName)) {
        JsonFeedConsumer.readInlineCount(reader, feedMetadata);
        nextName = reader.nextName();
      }
      if (FormatJson.RESULTS.equals(nextName)) {
View Full Code Here

   * @throws XMLStreamException if malformed xml is read in stream
   * @throws EntityProviderException if xml contains invalid data (based on odata specification and edm definition)
   */
  private ODataFeed readFeedData(final XMLStreamReader reader, final EntityInfoAggregator eia,
      final EntityProviderReadProperties entryReadProperties) throws XMLStreamException, EntityProviderException {
    FeedMetadataImpl metadata = new FeedMetadataImpl();
    XmlEntryConsumer xec = new XmlEntryConsumer();
    List<ODataEntry> results = new ArrayList<ODataEntry>();

    while (reader.hasNext() && !isFeedEndTag(reader)) {
      if (FormatXml.ATOM_ENTRY.equals(reader.getLocalName())) {
        ODataEntry entry = xec.readEntry(reader, eia, entryReadProperties);
        results.add(entry);
      } else if (FormatXml.M_COUNT.equals(reader.getLocalName())) {
        reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_M_2007_08, FormatXml.M_COUNT);

        reader.next();
        if (reader.hasText()) {
          String inlineCountString = reader.getText();
          try {
            int inlineCountNumber = Integer.valueOf(inlineCountString);
            if (inlineCountNumber >= 0) {
              metadata.setInlineCount(inlineCountNumber);
            } else {
              throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID
                  .addContent(inlineCountNumber));
            }
          } catch (NumberFormatException e) {
            throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID.addContent(""), e);
          }
        }
      } else if (FormatXml.ATOM_LINK.equals(reader.getLocalName())) {
        reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_LINK);

        final String rel = reader.getAttributeValue(null, FormatXml.ATOM_REL);
        if (FormatXml.ATOM_NEXT_LINK.equals(rel)) {
          final String uri = reader.getAttributeValue(null, FormatXml.ATOM_HREF);
          metadata.setNextLink(uri);
        } else if (FormatXml.ATOM_DELTA_LINK.equals(rel)) {
          final String uri = reader.getAttributeValue(null, FormatXml.ATOM_HREF);
          metadata.setDeltaLink(uri);
        }

        reader.next();
      } else {
        reader.next();
View Full Code Here

   * @return
   */
  private Object extractODataEntity(final boolean isFeed, final List<ODataEntry> inlineEntries) {
    if (isFeed) {
      // TODO: fill metadata correctly with inline count and inline next link. Both are currently ignored.
      return new ODataFeedImpl(inlineEntries, new FeedMetadataImpl());
    } else if (!inlineEntries.isEmpty()) {
      return inlineEntries.get(0);
    }
    return null;
  }
View Full Code Here

   * @return
   */
  private Object extractODataEntity(final boolean isFeed, final List<ODataEntry> inlineEntries) {
    if (isFeed) {
      // TODO: fill metadata correctly with inline count and inline next link. Both are currently ignored.
      return new ODataFeedImpl(inlineEntries, new FeedMetadataImpl());
    } else if (!inlineEntries.isEmpty()) {
      return inlineEntries.get(0);
    }
    return null;
  }
View Full Code Here

   * @throws XMLStreamException if malformed xml is read in stream
   * @throws EntityProviderException if xml contains invalid data (based on odata specification and edm definition)
   */
  private ODataFeed readFeedData(final XMLStreamReader reader, final EntityInfoAggregator eia,
      final EntityProviderReadProperties entryReadProperties) throws XMLStreamException, EntityProviderException {
    FeedMetadataImpl metadata = new FeedMetadataImpl();
    XmlEntryConsumer xec = new XmlEntryConsumer();
    List<ODataEntry> results = new ArrayList<ODataEntry>();

    while (reader.hasNext() && !isFeedEndTag(reader)) {
      if (FormatXml.ATOM_ENTRY.equals(reader.getLocalName())) {
        ODataEntry entry = xec.readEntry(reader, eia, entryReadProperties);
        results.add(entry);
      } else if (FormatXml.M_COUNT.equals(reader.getLocalName())) {
        reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_M_2007_08, FormatXml.M_COUNT);

        String inlineCountString = reader.getElementText();
        if (inlineCountString != null) {
          try {
            int inlineCountNumber = Integer.valueOf(inlineCountString);
            if (inlineCountNumber >= 0) {
              metadata.setInlineCount(inlineCountNumber);
            } else {
              throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID
                  .addContent(inlineCountNumber));
            }
          } catch (NumberFormatException e) {
            throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID.addContent(""), e);
          }
        }
      } else if (FormatXml.ATOM_LINK.equals(reader.getLocalName())) {
        reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_LINK);

        final String rel = reader.getAttributeValue(null, FormatXml.ATOM_REL);
        if (FormatXml.ATOM_NEXT_LINK.equals(rel)) {
          final String uri = reader.getAttributeValue(null, FormatXml.ATOM_HREF);
          metadata.setNextLink(uri);
        } else if (FormatXml.ATOM_DELTA_LINK.equals(rel)) {
          final String uri = reader.getAttributeValue(null, FormatXml.ATOM_HREF);
          metadata.setDeltaLink(uri);
        }

        reader.next();
      } else {
        reader.next();
View Full Code Here

  public void before() {
    try {
      final ODataSingleProcessor processor = mock(ODataSingleProcessor.class);
      final EdmProvider provider = mock(EdmProvider.class);

      service = new ODataSingleProcessorService(provider, processor) {};
      // FitStaticServiceFactory.setService(service);

      // science fiction (return context after setContext)
      // see http://www.planetgeek.ch/2010/07/20/mockito-answer-vs-return/
View Full Code Here

    @Override
    public <T> void read(final Edm edm, final String resourcePath, final Map<String, String> queryParams,
                         final Olingo2ResponseHandler<T> responseHandler) {

        final UriInfoImpl uriInfo = parseUri(edm, resourcePath, queryParams);

        execute(new HttpGet(createUri(resourcePath, queryParams)), getResourceContentType(uriInfo),
            new AbstractFutureCallback<T>(responseHandler) {

                @Override
View Full Code Here

        return resourceContentType;
    }

    @Override
    public <T> void create(Edm edm, String resourcePath, Object data, Olingo2ResponseHandler<T> responseHandler) {
        final UriInfoImpl uriInfo = parseUri(edm, resourcePath, null);

        writeContent(edm, new HttpPost(createUri(resourcePath, null)), uriInfo, data, responseHandler);
    }
View Full Code Here

        writeContent(edm, new HttpPost(createUri(resourcePath, null)), uriInfo, data, responseHandler);
    }

    @Override
    public <T> void update(Edm edm, String resourcePath, Object data, Olingo2ResponseHandler<T> responseHandler) {
        final UriInfoImpl uriInfo = parseUri(edm, resourcePath, null);

        writeContent(edm, new HttpPut(createUri(resourcePath, null)), uriInfo, data, responseHandler);
    }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.core.ep.feed.FeedMetadataImpl

Copyright © 2018 www.massapicom. 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.