Package org.apache.lucene.gdata.storage

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


    /**
     * @see org.apache.lucene.gdata.storage.Storage#getAccount(java.lang.String)
     */
    public GDataAccount getAccount(String accountName) throws StorageException {
        if (accountName == null)
            throw new StorageException("account name must not be null");
        ReferenceCounter<StorageQuery> query = null;
        try {
            query = this.controller.getStorageQuery();
            return query.get().getUser(accountName);
        } catch (Exception e) {
            throw new StorageException("Can not access storage", e);
        } finally {
            if (query != null)
                query.decrementRef();
        }
    }
View Full Code Here


     * @see org.apache.lucene.gdata.storage.Storage#getAccountNameForFeedId(java.lang.String)
     */
    public String getAccountNameForFeedId(String feedId)
            throws StorageException {
        if (feedId == null)
            throw new StorageException("feed-id must not be null");
        ReferenceCounter<StorageQuery> query = null;
        try {
            query = this.controller.getStorageQuery();
            String accountName = query.get().getAccountNameForFeedId(feedId);
            if (accountName == null)
                throw new StorageException("no feed for feedId " + feedId
                        + " found");
            return accountName;
        } catch (IOException e) {
            throw new StorageException("Can not access storage - "
                    + e.getMessage(), e);
        } finally {
            if (query != null)
                query.decrementRef();
        }
View Full Code Here

        ReferenceCounter<StorageQuery> query = null;
        try {
            query = this.controller.getStorageQuery();
            return new Long(query.get().getEntryLastModified(entryId,feedId));
        } catch (IOException e) {
            throw new StorageException("Can not access storage - "
                    + e.getMessage(), e);
        } finally {
            if (query != null)
                query.decrementRef();
        }
View Full Code Here

        ReferenceCounter<StorageQuery> query = null;
        try {
            query = this.controller.getStorageQuery();
            return new Long(query.get().getFeedLastModified(feedId));
        } catch (IOException e) {
            throw new StorageException("Can not access storage - "
                    + e.getMessage(), e);
        } finally {
            if (query != null)
                query.decrementRef();
        }
View Full Code Here

        synchronized (StorageCoreController.class) {
        
            try {
                this.idGenerator = new IDGenerator(10);
            } catch (Exception e) {
                throw new StorageException("Can't create ID Generator", e);
            }

            boolean createNewStorage = false;
         
            if (this.storageDir == null) {

               
                File storeDir = new File(this.storageDirectory);
                File storageLog = new File(storeDir.getAbsolutePath()
                        + System.getProperty("file.separator") + STORAGELOG);
                try {
                    if (storeDir.isDirectory() && !storageLog.exists()) {

                        if (createLuceneStorageLog(storeDir)) {
                            this.storageDir = FSDirectory.getDirectory(
                                    storeDir, true);
                            createNewStorage = true;
                        } else
                            throw new StorageException(
                                    "could not create storage lock file in "
                                            + this.storageDirectory);

                    } else
                        this.storageDir = FSDirectory.getDirectory(storeDir,
                                false);
                } catch (IOException e) {
                    storageLog.delete();
                    throw new StorageException(e);
                }
               
                this.storageBufferSize = this.storageBufferSize < DEFAULT_STORAGE_BUFFER_SIZE ? DEFAULT_STORAGE_BUFFER_SIZE
                        : this.storageBufferSize;
                this.storagePersistFactor = this.storagePersistFactor < DEFAULT_STORAGE_PERSIST_FACTOR ? DEFAULT_STORAGE_PERSIST_FACTOR
                        : this.storagePersistFactor;

            }else
                createNewStorage = true;
              

            this.currentBuffer = new StorageBuffer(this.storageBufferSize);
            try{
            this.modifier = createStorageModifier(createNewStorage);
            this.searcher = new IndexSearcher(this.storageDir);
            }catch (Exception e) {
               throw new StorageException("Can not create Searcher/Modifier -- "+e.getMessage(),e);
            }
          
           
            if(createNewStorage)
                createAdminAccount();
            if(!this.recover)
                return;
            try{
            tryRecover();
            }catch (Exception e) {
                LOG.fatal("Recovering failed",e);
                throw new StorageException("Recovering failed -- "+e.getMessage(),e);
            }
           
            this.recoverController = createRecoverController(false,false);
            try{
            this.recoverController.initialize();
            }catch (Exception e) {
                LOG.fatal("Can not initialize recover controller",e);
                throw new StorageException("Can not initialize recover controller -- "+e.getMessage(),e);
            }

        }
    }
View Full Code Here

    private boolean createLuceneStorageLog(File directory)
            throws IOException {
        if (directory.isDirectory() && !directory.exists()) {
            if(!directory.createNewFile())
                throw new StorageException("Can not create directory -- "+directory);
        }
        File file = new File(directory.getAbsolutePath()
                + System.getProperty("file.separator") + STORAGELOG);
        return file.createNewFile();
View Full Code Here

     */
    public synchronized String releaseId() {
        try {
            return this.idGenerator.getUID();
        } catch (InterruptedException e) {
            throw new StorageException("Can't release new ID", e);
        }

    }
View Full Code Here

     */
    public Storage getStorage() throws StorageException {
        try {
            return new StorageImplementation();
        } catch (StorageException e) {
            StorageException ex = new StorageException(
                    "Can't create Storage instance -- " + e.getMessage(), e);
            ex.setStackTrace(e.getStackTrace());
            throw ex;

        }
    }
View Full Code Here

     */
    public String releaseId(){
        try{
        return this.idGenerator.getUID();
        }catch (InterruptedException e) {
            throw new StorageException("ID producer has been interrupted",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.