Package org.apache.lucene.gdata.data

Examples of org.apache.lucene.gdata.data.ServerBaseEntry


     */

    public BaseEntry updateEntry(GDataRequest request, GDataResponse response)
            throws ServiceException {

        ServerBaseEntry entry = buildEntry(request, response);
        entry.setFeedId(request.getFeedId());
        setVersionId(entry,request,response);
        entry.setServiceConfig(request.getConfigurator());
        if (LOG.isInfoEnabled())
            LOG.info("update Entry" + entry.getId() + " for feedId: "
                    + request.getFeedId());
        if (entry.getId() == null) {
            throw new ServiceException("Entry id is null can not update entry",GDataResponse.BAD_REQUEST);
        }
        if (!entry.getId().equals(request.getEntryId())) {
            if (LOG.isInfoEnabled())
                LOG
                        .info("Entry id in the entry xml does not match the requested resource -- XML-ID:"
                                + entry.getId()
                                + "; Requested resource: "
                                + request.getEntryId());

            throw new ServiceException(
                    "Entry id in the entry xml does not match the requested resource",GDataResponse.BAD_REQUEST);
        }
        BaseEntry tempEntry = entry.getEntry();
        tempEntry.setUpdated(getCurrentDateTime());
        removeDynamicElements(entry.getEntry());
       
        BaseEntry retVal = null;
    
        try {
            retVal = this.storage.updateEntry(entry);
View Full Code Here


        f.setName("myField");
        f.setContentType(ContentType.KEYWORD);
        f.setPath("entry/id");
        this.schema.addSchemaField(f);
        this.controller.initialize();
        ServerBaseEntry e = new ServerBaseEntry();
        e.setId("someId");
        e.setFeedId("someId");
        e.setServiceConfig(new ProvidedServiceStub());
        CommitListener l = new CommitListener();
        l.createLatch(1);
        ServiceIndex sIndex = this.controller.indexerMap.get(this.schema.getName());
        sIndex.getIndexer().registerIndexEventListener(l);
        this.controller.fireInsertEvent(e);
        l.waitOnLatch();     
      
       assertEquals(1,sIndex.getIndexer().optimized.get());
       assertEquals(1,sIndex.getIndexer().committed.get());
      
       sIndex.getIndexer().removeIndexEventListener(l);
      
      
       e = new ServerBaseEntry();
       e.setId("someId");
       e.setFeedId("someId");
       e.setServiceConfig(new ProvidedServiceStub());
       l = new CommitListener();
       l.createLatch(1);
        sIndex = this.controller.indexerMap.get(this.schema.getName());
       sIndex.getIndexer().registerIndexEventListener(l);
       this.controller.fireUpdateEvent(e);
       l.waitOnLatch();     
     
      assertEquals(2,sIndex.getIndexer().optimized.get());
      assertEquals(2,sIndex.getIndexer().committed.get());
     
      GDataSearcher<String> searcher = this.controller.getServiceSearcher(e.getServiceConfig());
      List<String> results = searcher.search(new TermQuery(new Term(IndexDocument.FIELD_ENTRY_ID,"someId")),10,0,"someId");
      assertEquals(1,results.size());
      searcher.close();
     
      
View Full Code Here

    }

    private ServerBaseEntry buildEntry(final GDataRequest request,
            final GDataResponse response) throws ServiceException {
        try {
            ServerBaseEntry entry = new ServerBaseEntry(GDataEntityBuilder
                    .buildEntry(request));
            return entry;

        } catch (ParseException e) {
            ServiceException ex = new ServiceException(
View Full Code Here

    public BaseEntry getSingleEntry(GDataRequest request, GDataResponse response)
            throws ServiceException {

        try {
            ServerBaseEntry entry = new ServerBaseEntry();
            entry.setServiceConfig(request.getConfigurator());
            entry.setFeedId(request.getFeedId());
            entry.setId(request.getEntryId());

           
            if(entry.getId() == null){
                throw new ServiceException("entry is null can't get entry", GDataResponse.BAD_REQUEST);
            }
               
            BaseEntry retVal = null;
            retVal = this.storage.getEntry(entry);
View Full Code Here

public class TestDomIndexable extends TestCase {

  
    public void testConstructor(){
        try {
            new DomIndexable(new ServerBaseEntry());
            fail("no service config");
        } catch (NotIndexableException e) {
           
           
        }
        ServerBaseEntry e = new ServerBaseEntry();
        e.setServiceConfig(new ProvidedServiceConfig());
        try {
            new DomIndexable(e);
            fail("no extension profile");
        } catch (IllegalStateException e1) {
           
           
        } catch (NotIndexableException e2) {
           
            fail("unexp. exception");  
        }
        e.setServiceConfig(new ProvidedServiceStub());
        try {
            new DomIndexable(e);
        } catch (NotIndexableException e1) {
         fail("unexp. exception");  
        
View Full Code Here

    /*
     * Test method for 'org.apache.lucene.gdata.search.analysis.DomIndexable.applyPath(String)'
     */
    public void testApplyPath() throws NotIndexableException, XPathExpressionException {
        String content = "fooo bar<br>";
        ServerBaseEntry entry = new ServerBaseEntry();
        entry.setContent(new HtmlTextConstruct(content));
        entry.setServiceConfig(new ProvidedServiceStub());
       
            Indexable ind = new DomIndexable(entry);
            Node n = ind.applyPath("/entry/content");
            assertNotNull(n);
            assertEquals(content,n.getTextContent());
View Full Code Here

    IndexDocumentBuilderTask zeroFields;
    static String ID = "someId";
    static String CONTENT_FIELD = "someId";
    static String CONTENT = "foo bar";
    protected void setUp() throws Exception {
        ServerBaseEntry entry = new ServerBaseEntry();
        entry.setVersionId("1");
        entry.setFeedId("myFeed");
        entry.setId(ID);
        entry.setContent(new PlainTextConstruct(CONTENT));
        entry.setServiceConfig(new ProvidedServiceStub());
        IndexSchema schema = new IndexSchema();
        schema.setName("mySchema");
        IndexSchemaField field = new IndexSchemaField();
        field.setName(CONTENT_FIELD);
        field.setPath("/entry/content");
View Full Code Here

        for (int i = 1; i < this.count; i++) {
            Entry e = new Entry();
            e.setId("" + i);
            String insertString = "Hello world" + i;
            e.setTitle(new PlainTextConstruct(insertString));
            ServerBaseEntry en = getServerEntry(e);
            StorageEntryWrapper wrapper = new StorageEntryWrapper(en,
                    StorageOperation.UPDATE);
            this.modifier.updateEntry(wrapper);
            ReferenceCounter<StorageQuery> innerQuery = this.controller
                    .getStorageQuery();
            BaseEntry fetchedEntry = innerQuery.get().singleEntryQuery("" + i,
                    feedId, this.configurator);
            assertEquals("updated Title:", insertString, fetchedEntry
                    .getTitle().getPlainText());
        }
        // double updates
        for (int i = 1; i < this.count; i++) {
            Entry e = new Entry();
            e.setId("" + i);
            String insertString = "Hello world" + i;
            e.setTitle(new PlainTextConstruct(insertString));
            ServerBaseEntry en = getServerEntry(e);
            StorageEntryWrapper wrapper = new StorageEntryWrapper(en,
                    StorageOperation.UPDATE);
            this.modifier.updateEntry(wrapper);

            e = new Entry();
View Full Code Here

    public void testDeleteEntry() throws IOException, InterruptedException,
            ParseException, StorageException {
        testInsertEntry();
        for (int i = 1; i < this.count; i++) {
            if (i % 2 == 0 || i < 10) {
                ServerBaseEntry entry = new ServerBaseEntry();
                entry.setId("" + i);
                entry.setFeedId(feedId);
                this.modifier.deleteEntry(new StorageEntryWrapper(entry,StorageOperation.DELETE));
            }
            ReferenceCounter<StorageQuery> query = this.controller
                    .getStorageQuery();
            if (i % 2 == 0 || i < 10) {
View Full Code Here

    public void testDeleteFeed() throws IOException, StorageException {
        testSaveFeed();
        Entry e = new Entry();
        e.setTitle(new PlainTextConstruct("hello world"));
        ServerBaseEntry entry = new ServerBaseEntry(e);
        entry.setFeedId(feedId);
        entry.setId("testme");
        entry.setServiceConfig(this.configurator);
        StorageEntryWrapper entryWrapper = new StorageEntryWrapper(entry,StorageOperation.INSERT);
        this.modifier.insertEntry(entryWrapper);
        this.modifier.forceWrite();
        this.modifier.deleteFeed(feedId);
        IndexSearcher searcher = new IndexSearcher(this.dir);
View Full Code Here

TOP

Related Classes of org.apache.lucene.gdata.data.ServerBaseEntry

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.