Package org.apache.lucene.gdata.storage

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


     * @see org.apache.lucene.gdata.storage.Storage#getServiceForFeed(java.lang.String)
     */
    @SuppressWarnings("unchecked")
    public String getServiceForFeed(final String feedId) throws StorageException {
        if(feedId == null)
            throw new StorageException("can not get Service for feed -- feed id is null");
        if(LOG.isInfoEnabled())
            LOG.info("Retrieving Service for feed -- feed id: "+feedId);
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feedId);
        ObjectSet<ServerBaseFeed> feed =  query.execute();
        if (feed.size() > 1)
            throw new StorageException("Query for feed id " + feedId
                    + " returns more than one result");
        if (feed.size() < 1)
            throw new StorageException("can not find feed for given feed id -- "
                + feedId);
       
        ServerBaseFeed result = feed.next();
        if(LOG.isInfoEnabled())
            LOG.info("Retrieved Service for feed -- serviceType: "+result.getServiceType());
View Full Code Here


    /**
     * @see org.apache.lucene.gdata.storage.Storage#getAccount(java.lang.String)
     */
    public GDataAccount getAccount(String accountName) throws StorageException {
        if (accountName == null)
            throw new StorageException(
                    "Can not get account -- account name is null");
        if (LOG.isInfoEnabled())
            LOG.info("Retrieving account for account name: " + accountName);
        Query query = this.container.query();
        query.constrain(GDataAccount.class);
        query.descend("name").constrain(accountName).equal();
        ObjectSet set = query.execute();
        if (set.size() > 1)
            throw new StorageException(
                    "Account query returned not a unique result -- account name: "
                            + accountName);
        if (!set.hasNext())
            throw new ResourceNotFoundException(
                    "No such account stored -- query returned not result for account name: "
View Full Code Here

     */
   
    public String getAccountNameForFeedId(String feedId)
            throws StorageException {
        if(feedId == null)
            throw new StorageException("feed id is null");
        GDataAccount account = getServerBaseFeed(feedId).getAccount();
        if(account == null)
            throw new IllegalStateException("No account stored with feed -- feedID: "+feedId);
       
        return account.getName();
View Full Code Here

     * @see org.apache.lucene.gdata.storage.Storage#getEntryLastModified(java.lang.String, java.lang.String)
     */
    public Long getEntryLastModified(String entryId, final String feedId)
            throws StorageException {
        if(entryId == null)
            throw new StorageException("Entry ID is null");
        return new Long(getInternalEntry(entryId).getUpdateTime());
    }
View Full Code Here

        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feedId);
        ObjectSet<ServerBaseFeed> feed =  query.execute();
        if (feed.size() > 1)
            throw new StorageException("Query for feed id " + feedId
                    + " returns more than one result");
        if (feed.size() < 1)
            throw new StorageException("can not find feed for given feed id -- "
                + feedId);
        return feed.next();
    }
View Full Code Here

    /**
     * @see org.apache.lucene.gdata.storage.Storage#getFeedLastModified(java.lang.String)
     */
    public Long getFeedLastModified(String feedId) throws StorageException {
        if(feedId == null)
            throw new StorageException("can not get last modified -- id is null");
        ServerBaseFeed feed = getServerBaseFeed(feedId);
        return new Long(feed.getUpdated().getValue());
    
    }
View Full Code Here

    public StorageImplementation() throws StorageException {
        this.controller = (StorageCoreController) GDataServerRegistry
                .getRegistry().lookup(StorageController.class,
                        ComponentType.STORAGECONTROLLER);
        if (this.controller == null)
            throw new StorageException("Can't get registered StorageController");
    }
View Full Code Here

     * @see org.apache.lucene.gdata.storage.Storage#storeEntry(org.apache.lucene.gdata.data.ServerBaseEntry)
     */
    public BaseEntry storeEntry(final ServerBaseEntry entry)
            throws StorageException {
        if (entry == null)
            throw new StorageException("entry is null");
        if(entry.getFeedId() == null)
            throw new StorageException("feed-id is null");
        if(entry.getVersion() != 1)
            throw new StorageException("entry version must be 1");
        if(entry.getServiceConfig() == null)
            throw new StorageException("ProvidedService must not be null");
        StorageModifier modifier = this.controller.getStorageModifier();
        String id = this.controller.releaseId();
        entry.setId(entry.getFeedId() + id);
        if (LOG.isInfoEnabled())
            LOG.info("Store entry " + id + " -- feed: " + entry.getFeedId());

        try {
            StorageEntryWrapper wrapper = new StorageEntryWrapper(entry,
                    StorageOperation.INSERT);
            modifier.insertEntry(wrapper);
        } catch (IOException e) {
            StorageException ex = new StorageException("Can't create Entry -- "
                    + e.getMessage(), e);
            ex.setStackTrace(e.getStackTrace());
            throw ex;

        }

        return entry.getEntry();
View Full Code Here

     */
    public void deleteEntry(final ServerBaseEntry entry)
            throws StorageException {

        if (entry == null)
            throw new StorageException("Entry is null");
        if(entry.getId() == null)
            throw new StorageException("Entry id is null");
        if(entry.getFeedId() == null)
            throw new StorageException("feed id is null");
        if (LOG.isInfoEnabled())
            LOG.info("delete entry " + entry.getId() + " -- feed: "
                    + entry.getFeedId());
        StorageModifier modifier = this.controller.getStorageModifier();
        ReferenceCounter<StorageQuery> query = this.controller.getStorageQuery();
        // try to set concurrency Lock
        String key = entry.getId();
        setLock(key);
        try{
        if(query.get().isEntryStored(entry.getId(),entry.getFeedId())){
            if(query.get().checkEntryVersion(entry.getId(),entry.getFeedId(),entry.getVersion())){
                modifier.deleteEntry(new StorageEntryWrapper(entry,StorageOperation.DELETE));
            }else
                throw new ModificationConflictException("The entry version does not match -- entry "+entry.getId()+" feed:"+entry.getFeedId()+" version: "+entry.getVersion());
        }
        else
            throw new ResourceNotFoundException("Entry for entry id: "+entry.getId()+" is not stored");
        }catch (IOException e) {
            throw new StorageException("Can not access storage");
        }finally{
            if(query != null)
                query.decrementRef();
            // release lock for concurrency
            releaseLock(key);
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("entry is null");
        if(entry.getId() == null)
            throw new StorageException("entry id is null");
        if(entry.getServiceConfig() == null)
            throw new StorageException("service config is not set -- null");
        if(entry.getFeedId() == null)
            throw new StorageException("feed id is null");
        if (LOG.isInfoEnabled())
            LOG.info("update entry " + entry.getId() + " -- feed: "
                    + entry.getFeedId());
        StorageModifier modifier = this.controller.getStorageModifier();
        ReferenceCounter<StorageQuery> query = this.controller.getStorageQuery();
        // try to set concurrency Lock
        String key = entry.getId();
        setLock(key);
        try {
           
           
            if(query.get().isEntryStored(entry.getId(),entry.getFeedId())){
               
                if(query.get().checkEntryVersion(entry.getId(),entry.getFeedId(),entry.getVersion())){
                    entry.setVersion(entry.getVersion()+1);
                    StorageEntryWrapper wrapper = new StorageEntryWrapper(entry,
                            StorageOperation.UPDATE)
                    modifier.updateEntry(wrapper);
                }else
                    throw new ModificationConflictException("The entry version does not match -- entry "+entry.getId()+" feed:"+entry.getFeedId()+" version: "+entry.getVersion());
             
            }else
                throw new ResourceNotFoundException("Entry for entry id: "+entry.getId()+" is not stored");
           
        } catch (IOException e) {
            LOG.error("Can't update entry for feedID: " + entry.getFeedId()
                    + "; entryId: " + entry.getId() + " -- " + e.getMessage(),
                    e);
            StorageException ex = new StorageException("Can't update Entry -- "
                    + e.getMessage(), e);
            ex.setStackTrace(e.getStackTrace());
            throw ex;

        }

        finally{
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.