Package org.apache.lucene.gdata.storage

Examples of org.apache.lucene.gdata.storage.StorageException


     *             if the entry can not be stored
     */
    public void updateEntry(StorageEntryWrapper wrapper)
            throws StorageException {
        if(wrapper.getOperation() != StorageOperation.UPDATE)
            throw new StorageException("Illegal method call -- updateEntry does not accept other storageOperations than update");
        this.lock.lock();
        try {
           
            Term tempTerm = new Term(StorageEntryWrapper.FIELD_ENTRY_ID,
                    wrapper.getEntryId());
View Full Code Here


     *             if the entry can not be stored
     */
    public void insertEntry(StorageEntryWrapper wrapper)
            throws StorageException {
        if(wrapper.getOperation() != StorageOperation.INSERT)
            throw new StorageException("Illegal method call -- insertEntry does not accept other storage operations than insert");
        this.lock.lock();
        try {
            this.documentMap.put(wrapper.getEntryId(), wrapper
                    .getLuceneDocument());
            storageModified();
View Full Code Here

     *
     */
    public void deleteEntry(final StorageEntryWrapper wrapper)
            throws StorageException {
        if(wrapper.getOperation() != StorageOperation.DELETE)
            throw new StorageException("Illegal method call -- insertEntry does not accept other storage operations than delete");
        this.lock.lock();
        try {
           
            Term tempTerm = new Term(StorageEntryWrapper.FIELD_ENTRY_ID,
                    wrapper.getEntryId());
View Full Code Here

            this.modifiedCounter = 0;
        } catch (IOException e) {

            LOG.error("Writing persistent index failed - Recovering", e);
            throw new StorageException("could not write to storage index -- "+e.getMessage(),e);
        }
      
    }
View Full Code Here

    public StorageCoreControllerStub() throws IOException, StorageException {
        try{
            this.idGenerator = new IDGenerator(5);
        }catch (NoSuchAlgorithmException e) {
            throw new StorageException(e);
        }
      
    }
View Full Code Here

       
        try {
            return this.idGenerator.getUID();
        } catch (InterruptedException e) {
           
          throw new StorageException(e);
        }
    }
View Full Code Here

            } catch (Exception e) {
                LOG.warn("Can not parse timestamp from entry -- "
                        + h.doc(0).get(StorageEntryWrapper.FIELD_TIMESTAMP));
            }
        else
            throw new StorageException("Entry not found");
        return 0;

    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#storeEntry(org.apache.lucene.gdata.data.ServerBaseEntry)
     */
    public BaseEntry storeEntry(ServerBaseEntry entry) throws StorageException {
        if (entry == null)
            throw new StorageException("Can not store entry -- is null");

        if (entry.getFeedId() == null)
            throw new StorageException("can not store entry -- feed id is null");
        if (LOG.isDebugEnabled())
            LOG.debug("Storing entry for feed: " + entry.getFeedId());
        BaseFeed<BaseFeed, BaseEntry> feed = getFeedOnly(entry.getFeedId(),entry.getServiceType());
       refreshPersistentObject(feed);
        try {
            StringBuilder idBuilder = new StringBuilder(entry.getFeedId());
            idBuilder.append(this.controller.releaseId());
            entry.setId(idBuilder.toString());
        } catch (StorageException e) {
            LOG.error("Can not create uid for entry -- " + e.getMessage(), e);
            throw new StorageException("Can not create uid for entry -- "
                    + e.getMessage(), e);

        }
        setUpdated(entry, feed);
        DB4oEntry intEntry = new DB4oEntry();
        intEntry.setEntry(entry.getEntry());
        intEntry.setUpdateTime(entry.getUpdated().getValue());
        intEntry.setFeedId(feed.getId());
        intEntry.setVersion(entry.getVersion());

      
        try {
            this.container.set(feed);
            this.container.set(intEntry);
            this.container.commit();
        } catch (Exception e) {
            LOG
                    .error("Error occured on persisting changes -- rollback changes");
            this.container.rollback();
            throw new StorageException("Can not persist changes -- "
                    + e.getMessage(), e);
        }
        if (LOG.isInfoEnabled())
            LOG.info("Stored Entry for entryID: " + entry.getId()
                    + " -- feedID: " + entry.getFeedId());
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#deleteEntry(org.apache.lucene.gdata.data.ServerBaseEntry)
     */
    public void deleteEntry(ServerBaseEntry entry) throws StorageException {
        if (entry == null)
            throw new StorageException("Can not delete entry -- is null");
        if (entry.getFeedId() == null)
            throw new StorageException(
                    "can not delete entry -- feed id is null");
        if (entry.getId() == null)
            throw new StorageException("Can not delete entry -- id is null");
        if (LOG.isDebugEnabled())
            LOG.debug("delete entry for feed: " + entry.getFeedId()
                    + " entry ID: " + entry.getId());
        DB4oEntry persistentEntry = getInternalEntry(entry.getId());
        // lock the entry to prevent concurrent access
        createSemaphore(entry.getId());
        refreshPersistentObject(persistentEntry);
        if(persistentEntry.getVersion() != entry.getVersion())
            throw new ModificationConflictException(
                    "Current version does not match given version  -- currentVersion: "+persistentEntry.getVersion()+"; given Version: "+entry.getVersion() );
        BaseFeed<BaseFeed, BaseEntry> feed = getFeedOnly(entry.getFeedId(),entry.getServiceType());
        refreshPersistentObject(feed);
        DateTime time = DateTime.now();
        if (persistentEntry.getEntry().getUpdated() != null)
            time.setTzShift(persistentEntry.getEntry().getUpdated().getTzShift());
        feed.setUpdated(time);
        try {
            //delete the entry
            this.container.delete(persistentEntry.getEntry());
            this.container.delete(persistentEntry);
            this.container.set(feed);
            this.container.commit();
           
        } catch (Exception e) {
            LOG
                    .error("Error occured on persisting changes -- rollback changes");
            this.container.rollback();
            throw new StorageException("Can not persist changes -- "
                    + e.getMessage(), e);
        } finally {
            releaseSemaphore(entry.getId());
        }
    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#updateEntry(org.apache.lucene.gdata.data.ServerBaseEntry)
     */
    public BaseEntry updateEntry(ServerBaseEntry entry) throws StorageException {
        if (entry == null)
            throw new StorageException("Can not update entry -- is null");
        if (entry.getFeedId() == null)
            throw new StorageException(
                    "can not delete entry -- feed id is null");
        if (entry.getId() == null)
            throw new StorageException("Can not delete entry -- id is null");

        DB4oEntry persistentEntry = getInternalEntry(entry.getId());
        // lock the entry to prevent concurrent access
        createSemaphore(entry.getId());
        refreshPersistentObject(persistentEntry);
        if(persistentEntry.getVersion() != entry.getVersion())
            throw new ModificationConflictException(
                    "Current version does not match given version  -- currentVersion: "+persistentEntry.getVersion()+"; given Version: "+entry.getVersion() );
       
        setUpdated(entry, persistentEntry);
        BaseFeed<BaseFeed, BaseEntry> feed = getFeedOnly(entry.getFeedId(),entry.getServiceType());
        refreshPersistentObject(feed);
        BaseEntry retVal = entry.getEntry();
        DB4oEntry newEntry = new DB4oEntry();
        newEntry.setEntry(retVal);
        newEntry.setUpdateTime(entry.getUpdated().getValue());
        newEntry.setFeedId(feed.getId());
        // increment Version
        newEntry.setVersion((entry.getVersion())+1);

        setUpdated(entry, feed);
        try {
            this.container.set(feed);
            this.container.set(newEntry);
            this.container.delete(persistentEntry.getEntry());
            this.container.delete(persistentEntry);
            this.container.commit();
        } catch (Exception e) {
            LOG
                    .error("Error occured on persisting changes -- rollback changes");
            this.container.rollback();
            throw new StorageException("Can not persist changes -- "
                    + e.getMessage(), e);
        } finally {
            releaseSemaphore(entry.getId());
        }
        return retVal;
View Full Code Here

TOP

Related Classes of org.apache.lucene.gdata.storage.StorageException

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.