⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storageimplementation.java

📁 lucene2.2.0版本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public void close() {        //    }    /**     * @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 save null Account");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (query.get().getUser(Account.getName()) != null)                throw new StorageException("Account already exists");            StorageModifier modifier = this.controller.getStorageModifier();            StorageAccountWrapper wrapper = new StorageAccountWrapper(Account);            modifier.createAccount(wrapper);        } catch (Exception e) {            LOG.error("Can't save Account -- " + e.getMessage(), e);            StorageException ex = new StorageException("Can't save Account -- "                    + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @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 null Account");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (query.get().getUser(Account.getName()) == null)                throw new StorageException("Account does not exist");            StorageModifier modifier = this.controller.getStorageModifier();            StorageAccountWrapper wrapper = new StorageAccountWrapper(Account);            modifier.updateAccount(wrapper);        } catch (Exception e) {            LOG.error("Can't update Account -- " + e.getMessage(), e);            StorageException ex = new StorageException(                    "Can't update Account -- " + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @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 null Account");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (query.get().getUser(Accountname) == null)                throw new StorageException("Account does not exist");            StorageModifier modifier = this.controller.getStorageModifier();            modifier.deleteAccount(Accountname);        } catch (Exception e) {            LOG.error("Can't update Account -- " + e.getMessage(), e);            StorageException ex = new StorageException(                    "Can't update Account -- " + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @see org.apache.lucene.gdata.storage.Storage#storeFeed(org.apache.lucene.gdata.data.ServerBaseFeed,     *      java.lang.String)     */    public void storeFeed(ServerBaseFeed feed, String accountName)            throws StorageException {        if (feed == null)            throw new StorageException("can not insert null feed");        if (accountName == null)            throw new StorageException("accountName must not be null");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (query.get().isFeedStored(feed.getId()))                throw new StorageException("feed with feedID " + feed.getId()                        + " is already stored");            StorageModifier modifier = this.controller.getStorageModifier();            StorageFeedWrapper wrapper = new StorageFeedWrapper(feed,                    accountName);            modifier.createFeed(wrapper);        } catch (Exception e) {            LOG.error("Can't create feed -- " + e.getMessage(), e);            StorageException ex = new StorageException("Can't create feed -- "                    + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @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 id is null ");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (!query.get().isFeedStored(feedId))                throw new StorageException("Account does not exist");            StorageModifier modifier = this.controller.getStorageModifier();            modifier.deleteFeed(feedId);        } catch (Exception e) {            LOG.error("Can't delete feed -- " + e.getMessage(), e);            StorageException ex = new StorageException("Can't create feed -- "                    + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @see org.apache.lucene.gdata.storage.Storage#updateFeed(org.apache.lucene.gdata.data.ServerBaseFeed,     *      java.lang.String)     */    public void updateFeed(ServerBaseFeed feed, String accountName)            throws StorageException {        if (feed == null)            throw new StorageException("can not update null feed");        if (accountName == null)            throw new StorageException("accountName must not be null");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            if (!query.get().isFeedStored(feed.getId()))                throw new StorageException("Account does not exist");            StorageModifier modifier = this.controller.getStorageModifier();            StorageFeedWrapper wrapper = new StorageFeedWrapper(feed,                    accountName);            modifier.updateFeed(wrapper);        } catch (Exception e) {            LOG.error("Can't create feed -- " + e.getMessage(), e);            StorageException ex = new StorageException("Can't create feed -- "                    + e.getMessage(), e);            ex.setStackTrace(e.getStackTrace());            throw ex;        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @see org.apache.lucene.gdata.storage.Storage#getServiceForFeed(java.lang.String)     */    public String getServiceForFeed(String feedId) throws StorageException {        if (feedId == null)            throw new StorageException("no feed for the feedID == null");        ReferenceCounter<StorageQuery> query = null;        try {            query = this.controller.getStorageQuery();            String type = query.get().getService(feedId);            if (type == null)                throw new StorageException("no feed for the feedID == "                        + feedId + " found");            return type;        } catch (Exception e) {            throw new StorageException("Can not access storage", e);        } finally {            if (query != null)                query.decrementRef();        }    }    /**     * @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();        }    }    /**     * @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();        }    }    /**     * @see org.apache.lucene.gdata.storage.Storage#getEntryLastModified(java.lang.String, java.lang.String)     */    public Long getEntryLastModified(String entryId,String feedId) throws StorageException {        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();        }            }    /**     * @see org.apache.lucene.gdata.storage.Storage#getFeedLastModified(java.lang.String)     */    public Long getFeedLastModified(String feedId) throws StorageException {        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();        }            }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -