Package org.apache.lucene.gdata.storage

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


     * @see org.apache.lucene.gdata.storage.Storage#getFeed(org.apache.lucene.gdata.data.ServerBaseFeed)
     */
    @SuppressWarnings("unchecked")
    public BaseFeed getFeed(ServerBaseFeed feed) throws StorageException {
        if (feed.getId() == null)
            throw new StorageException("can not get feed -- feed id is null");
        if (feed.getStartIndex() < 1)
            feed.setStartIndex(1);
        if (feed.getItemsPerPage() < 0)
            feed.setItemsPerPage(25);

View Full Code Here


    @SuppressWarnings("unchecked")
    private BaseFeed<BaseFeed, BaseEntry> getFeedOnly(final String feedId, final String serviceId)
            throws StorageException {
        if(!checkService(feedId,serviceId))
            throw new StorageException();
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
     
        query.constrain(BaseFeed.class);

        query.descend("id").constrain(feedId).equal();

        ObjectSet set = query.execute();
        if (set.size() > 1)
            throw new StorageException("Query for feed id " + feedId
                    + " returns more than one result");
        if (set.hasNext())
        return (BaseFeed<BaseFeed, BaseEntry>) set.next();
        throw new ResourceNotFoundException("can not find feed for given feed id -- "
                + feedId);
View Full Code Here

     * @see org.apache.lucene.gdata.storage.Storage#getEntry(org.apache.lucene.gdata.data.ServerBaseEntry)
     */

    public BaseEntry getEntry(ServerBaseEntry entry) throws StorageException {
        if (entry == null)
            throw new StorageException("can not retrieve entry -- is null");
        if (entry.getId() == null)
            throw new StorageException("can not retrieve entry -- id is null");
        if (LOG.isInfoEnabled())
            LOG.info("Retrieving entry for entryID: " + entry.getId());
        DB4oEntry retval = getInternalEntry(entry.getId());
        this.container.activate(retval.getEntry(),RENDER_ACTIVATION_DEPTH);
        return clearDynamicElements(retval.getEntry());
View Full Code Here

        Query query = this.container.query();
        query.constrain(DB4oEntry.class);
        query.descend("entry").descend("id").constrain(id).equal();
        ObjectSet<DB4oEntry> resultSet = query.execute();
        if (resultSet.size() > 1)
            throw new StorageException(
                    "Entry query returned not a unique result");
        if (resultSet.hasNext())
            return resultSet.next();
        throw new ResourceNotFoundException("no entry with entryID: " + id
                + " stored -- query returned no result");
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#storeAccount(org.apache.lucene.gdata.data.GDataAccount)
     */
    public void storeAccount(GDataAccount account) throws StorageException {
        if (account == null)
            throw new StorageException("can not store account -- is null");
        if (account.getName() == null)
            throw new StorageException("can not store account -- name is null");
        if (account.getPassword() == null)
            throw new StorageException(
                    "can not store account -- password is null");
        try {
            getAccount(account.getName());
            throw new IllegalStateException("account with accountname: "
                    + account.getName() + " already exists");
        } catch (IllegalStateException e) {
            throw new StorageException("Account already exists");
        } catch (StorageException e) {
            if (LOG.isDebugEnabled())
                LOG
                        .debug("checked account for existence -- does not exist -- store account");
        }
        try {
            this.container.set(account);
            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 account: " + account);
    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#updateAccount(org.apache.lucene.gdata.data.GDataAccount)
     */
    public void updateAccount(GDataAccount account) throws StorageException {
        if (account == null)
            throw new StorageException("can not update account -- is null");
        if (account.getName() == null)
            throw new StorageException("can not update account -- name is null");
        if (account.getPassword() == null)
            throw new StorageException(
                    "can not update account -- password is null");
        GDataAccount persitentAccount = getAccount(account.getName());
        refreshPersistentObject(persitentAccount);
        try {
            this.container.set(account);
            this.container.delete(persitentAccount);
            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);
        }
    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#deleteAccount(java.lang.String)
     */
    public void deleteAccount(String accountname) throws StorageException {
        if (accountname == null)
            throw new StorageException(
                    "can not delete account -- account name is null");
        GDataAccount account = this.getAccount(accountname);
        refreshPersistentObject(account);
        if (LOG.isInfoEnabled())
            LOG.info("delete account -- account name: " + accountname);
        try {
            this.container.delete(account);
            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);
        }
    }
View Full Code Here

     *      java.lang.String)
     */
    public void storeFeed(ServerBaseFeed feed, String accountname)
            throws StorageException {
        if (feed == null)
            throw new StorageException("Can not store feed -- is null");
        if (feed.getId() == null)
            throw new StorageException("Can not store feed -- id is null");
        if(feed.getServiceType() == null)
            throw new StorageException("Can not store feed -- service type is null");
        if(accountname == null)
            throw new StorageException("Account name is null");
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feed.getId()).equal();
        ObjectSet set = query.execute();
        if (set.hasNext())
            throw new StorageException("feed with feedID " + feed.getId()
                    + " is already stored");
        GDataAccount account = getAccount(accountname);
        refreshPersistentObject(account);
        feed.setAccount(account);
        /*
         * service config not required in db4o storage.
         * Entries/Feeds don't have to be build from xml
         */
        feed.setServiceConfig(null);
        try {
            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);
        }
    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#deleteFeed(java.lang.String)
     */
    public void deleteFeed(String feedId) throws StorageException {
        if (feedId == null)
            throw new StorageException("can not delete feed -- feed id is null");
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feedId).equal();
        ObjectSet set = query.execute();
        if (set.size() > 1)
            throw new StorageException(
                    "Feed query returned not a unique result");
        if (set.size() == 0)
            throw new StorageException("no feed with feedID: " + feedId
                    + " stored -- query returned no result");

        ServerBaseFeed feed = (ServerBaseFeed) set.next();
        refreshPersistentObject(feed);
        ObjectSet entrySet = getEnriesForFeedID(feed.getId());
        try {
            this.container.delete(feed);
            this.container.delete(feed.getFeed());
            for (Object object : entrySet) {
                refreshPersistentObject(object);
                this.container.delete(object);
            }
           
            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);
        }

    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public void updateFeed(ServerBaseFeed feed, String accountname)
            throws StorageException {
        if (feed == null)
            throw new StorageException("Can not update feed -- is null");
        if (feed.getId() == null)
            throw new StorageException("Can not update feed -- id is null");
        if(feed.getServiceType() == null)
            throw new StorageException("Can not update feed -- service type is null");
        if(accountname == null)
            throw new StorageException("Account name is null");
        GDataAccount account = getAccount(accountname);
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feed.getId());
        ObjectSet<ServerBaseFeed> set=  query.execute();
        if (set.size() > 1)
            throw new StorageException("Query for feed id " + feed.getId()
                    + " returns more than one result");
        if (set.size() < 1)
            throw new StorageException("can not find feed for given feed id -- "
                + feed.getId());
        ServerBaseFeed result = set.next();
        refreshPersistentObject(result);
        BaseFeed oldFeed = result.getFeed();
        result.setAccount(account);
        result.setFeed(feed.getFeed());
        try {
            this.container.delete(oldFeed);
            this.container.set(result);
            this.container.commit();
        } catch (Exception e) {
            LOG
                    .error("Error occurred on persisting changes -- rollback changes");
            this.container.rollback();
            throw new StorageException("Can not persist changes -- "
                    + e.getMessage(), e);
        }
       
    }
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.