Package com.google.gdata.data

Examples of com.google.gdata.data.BaseFeed


        feed.setServiceConfig(request.getConfigurator());
        try {
            /*
             * the strategy executes either a search or a direct access.
             */
            BaseFeed retVal = this.storage.getFeed(feed);
            dynamicElementFeedStragey(retVal, request);

            return retVal;
            /*
             * Resource not found will be detected in Gdata request.
View Full Code Here


     *             if the feed could not be parsed
     */
    public static BaseFeed buildFeed(final Reader reader,
            final ProvidedService config) throws ParseException, IOException {

        BaseFeed retVal = null;
        retVal = createEntityInstance(config);
        retVal.parseAtom(config.getExtensionProfile(), reader);
     
        return retVal;
    }
View Full Code Here

    private static BaseFeed createEntityInstance(
            final ProvidedService config) {
        if(config.getFeedType() == null)
            throw new IllegalArgumentException("feedtype is null in ProvidedService");
       
        BaseFeed retVal = null;
        try {
            retVal = (BaseFeed) config.getFeedType().newInstance();
        } catch (Exception e) {
            throw new EntityBuilderException("Can't instanciate Feed for feedType "+config.getFeedType().getName(),e);
        }
View Full Code Here

                LOG.info("Requested output formate: "
                        + this.feedRequest.getRequestedResponseFormat());
            this.feedResponse.setOutputFormat(this.feedRequest
                    .getRequestedResponseFormat());
            if (this.feedRequest.isFeedRequested()) {
                BaseFeed feed = this.service.getFeed(this.feedRequest,
                        this.feedResponse);

                this.feedResponse.sendResponse(feed, this.feedRequest
                        .getConfigurator());
            } else {
View Full Code Here

            final ProvidedService config) throws IOException, ParseException {
        DateTime updated = null;
        Hits feedHits = storageFeedQuery(feedId);
        if (feedHits.length() == 0)
            return null;
        BaseFeed retVal = buildFeedFromLuceneDocument(feedHits.doc(0), config);

        List<BaseEntry> returnList = new ArrayList<BaseEntry>(resultCount);
        List<StorageEntryWrapper> bufferedWrapperList = this.buffer
                .getSortedEntries(feedId);
        int alreadyAdded = 0;
        int offset = startIndex - 1;

        if (bufferedWrapperList != null
                && bufferedWrapperList.size() >= startIndex) {
            updated = bufferedWrapperList.get(0).getEntry().getUpdated();
            for (; alreadyAdded < resultCount; alreadyAdded++) {
                if ((bufferedWrapperList.size() - offset) > 0) {
                    StorageEntryWrapper wrappedEntry = bufferedWrapperList
                            .get(offset++);
                    returnList.add(wrappedEntry.getEntry());
                } else
                    break;
            }
            // reset offset
            offset = startIndex - 1;
            if (alreadyAdded == resultCount) {
                retVal.getEntries().addAll(returnList);
                retVal.setUpdated(updated);
                return retVal;
            }
        } else {
            /*
             * if the buffer size is less than the start index the buffer size must
             * be considered. Sublists would not be a repeatable read part of
             * the whole list
             */
            if (bufferedWrapperList != null)
                offset = startIndex - 1 - bufferedWrapperList.size();
        }

        Hits hits = storageFeedQuery(feedId, this.timeStampSort);
        if (hits.length() > 0) {

            for (; (offset < hits.length()) && (alreadyAdded < resultCount); offset++, alreadyAdded++) {
                Document doc = hits.doc(offset);
                BaseEntry entry = buildEntryFromLuceneDocument(doc, config);
                returnList.add(entry);
            }
            if (updated == null) {
                try {
                    long updatedTimeStamp = Long.parseLong(hits.doc(0).get(
                            StorageEntryWrapper.FIELD_TIMESTAMP));
                    updated = new DateTime(updatedTimeStamp);
                } catch (Exception e) {
                    LOG.warn("could not create DateTime -- " + e.getMessage(),
                            e);
                    updated = buildEntryFromLuceneDocument(hits.doc(0), config)
                            .getUpdated();
                }
            }
        }
        retVal.setUpdated(updated);
        retVal.getEntries().addAll(returnList);
        return retVal;
    }
View Full Code Here

    /**
     * Test method for 'org.apache.lucene.gdata.data.GDataEntityBuilder.buildFeed(String, Reader)'
     */
    public void testBuildFeedStringReader() throws  ParseException, IOException {
        this.reader = new FileReader(incomingFeed);
        BaseFeed feed = GDataEntityBuilder.buildFeed(this.reader,this.config);
        assertNotNull(feed);
        assertEquals("feed title",feed.getTitle().getPlainText(), feedTitleFromXML);
       
      
        
    }
View Full Code Here

                    + feed.getStartIndex() + " resultCount: "
                    + feed.getItemsPerPage());
        ReferenceCounter<StorageQuery> query = null;
        try {
            query = this.controller.getStorageQuery();
            BaseFeed retVal = query.get().getLatestFeedQuery(feed.getId(),
                    feed.getItemsPerPage(), feed.getStartIndex(),
                    feed.getServiceConfig());
            return retVal;
        } catch (Exception e) {
            LOG.error("Can't get latest feed for feedID: " + feed.getId()
View Full Code Here

        ServerBaseFeed requestFeed = new ServerBaseFeed();
        requestFeed.setServiceConfig(service);
        requestFeed.setStartIndex(0);
        requestFeed.setItemsPerPage(0);
        requestFeed.setId(request.getFeedId());
        BaseFeed feed = null;
        try{
         feed = this.storage.getFeed(requestFeed);
        }catch (StorageException e) {
            throw new ServiceException("Search Failed -- can not get feed, feed not stored ",e,GDataResponse.NOT_FOUND);
        }
        for (String entryId : result) {
            ServerBaseEntry requestEntry = new ServerBaseEntry();
            requestEntry.setId(entryId);
            requestEntry.setServiceConfig(service);
            try{
            BaseEntry entry = this.storage.getEntry(requestEntry);
            feed.getEntries().add(entry);
            }catch (StorageException e) {
               
                LOG.error("StorageException caught while fetching query results -- skip entry -- "+e.getMessage(),e);
            }
        }
View Full Code Here

        assertNotSame(queryAssureWritten,this.query);
        feedQueryHelper(queryAssureWritten);
        queryAssureWritten.decrementRef();
    }
    private void feedQueryHelper(ReferenceCounter<StorageQuery> currentQuery) throws IOException,  ParseException{
       BaseFeed feed = currentQuery.get().getLatestFeedQuery(feedId,25,1,this.configurator);
       List<BaseEntry> entryList = feed.getEntries();
        assertTrue("listSize: "+entryList.size(),entryList.size() == 25);
       
        BaseEntry tempEntry = null;
        for (BaseEntry entry : entryList) {
         
            assertNotNull("entry",entry);
            if(tempEntry != null){
                assertTrue(tempEntry.getUpdated().compareTo(entry.getUpdated())>=0) ;
                tempEntry = entry;
            }else
                tempEntry = entry;
           
        }
        // test sub retrieve sublist
        int offset = 15;
        int resultCount = 5;
        feed = currentQuery.get().getLatestFeedQuery(feedId,resultCount,offset,this.configurator);
        List<BaseEntry> entrySubList = feed.getEntries();
       
        assertTrue("listSize: "+entrySubList.size(),entrySubList.size() == resultCount);
        offset--;
        for (BaseEntry entry : entrySubList) {
           
View Full Code Here

        }catch (StorageException e) {
            //
        }
       
        feed.setId(FEEDID);
        BaseFeed result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(0, result.getEntries().size());
        List<String> idlist = new ArrayList<String>(30);
        ServerBaseEntry e1 = null;
        for (int i = 0; i < 30; i++) {
            e1 = createServerBaseEntry();
            storage.storeEntry(e1);
            idlist.add(0, e1.getId());
        }
        String firstId = e1.getId();

        storage = this.controller.getStorage();
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(25, result.getEntries().size());
        for (int i = 0; i < 25; i++) {
            assertEquals(idlist.get(i),
                    ((BaseEntry) result.getEntries().get(i)).getId());
        }

        storage = this.controller.getStorage();
        feed.setItemsPerPage(5);
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(5, result.getEntries().size());
        for (int i = 0; i < 5; i++) {
            assertEquals(idlist.get(i),
                    ((BaseEntry) result.getEntries().get(i)).getId());
        }

        storage = this.controller.getStorage();
        feed.setItemsPerPage(1);
        feed.setStartIndex(1);
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(1, result.getEntries().size());

        assertEquals(idlist.get(0), ((BaseEntry) result.getEntries().get(0))
                .getId());

        storage = this.controller.getStorage();
        feed.setItemsPerPage(50);
        feed.setStartIndex(28);
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(3, result.getEntries().size());

        assertEquals(idlist.get(27), ((BaseEntry) result.getEntries().get(0))
                .getId());
        assertEquals(idlist.get(28), ((BaseEntry) result.getEntries().get(1))
                .getId());
        assertEquals(idlist.get(29), ((BaseEntry) result.getEntries().get(2))
                .getId());

        storage = this.controller.getStorage();
        feed.setItemsPerPage(50);
        feed.setStartIndex(30);
        result = storage.getFeed(feed);
        assertNotNull(result);
        assertEquals(1, result.getEntries().size());

        assertEquals(idlist.get(29), ((BaseEntry) result.getEntries().get(0))
                .getId());

        // assertNotSame(firstId,((BaseEntry)result.getEntries().get(0)).getId());
    }
View Full Code Here

TOP

Related Classes of com.google.gdata.data.BaseFeed

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.