Methods Summary |
---|
public void | close()
//
|
public void | deleteAccount(java.lang.String Accountname)
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();
}
|
public void | deleteEntry(org.apache.lucene.gdata.data.ServerBaseEntry entry)
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);
}
|
public void | deleteFeed(java.lang.String feedId)
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();
}
|
public org.apache.lucene.gdata.data.GDataAccount | getAccount(java.lang.String accountName)
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();
}
|
public java.lang.String | getAccountNameForFeedId(java.lang.String feedId)
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();
}
|
public com.google.gdata.data.BaseEntry | getEntry(org.apache.lucene.gdata.data.ServerBaseEntry entry)
if (entry == null)
throw new StorageException("No entry specified -- is null");
if (LOG.isInfoEnabled())
LOG.info("get entry " + entry.getId() + " -- feed: "
+ entry.getFeedId());
ReferenceCounter<StorageQuery> query = null;
try {
query = this.controller.getStorageQuery();
BaseEntry retVal = query.get().singleEntryQuery(entry.getId(),
entry.getFeedId(), entry.getServiceConfig());
if(retVal == null)
throw new ResourceNotFoundException("can not get entry for entry ID "+entry.getId());
return retVal;
} catch (Exception e) {
LOG.error("Can't get entry for feedID: " + entry.getFeedId()
+ "; entryId: " + entry.getId() + " -- " + e.getMessage(),
e);
StorageException ex = new StorageException("Can't create Entry -- "
+ e.getMessage(), e);
ex.setStackTrace(e.getStackTrace());
throw ex;
} finally {
if (query != null)
query.decrementRef();
}
|
public java.lang.Long | getEntryLastModified(java.lang.String entryId, java.lang.String feedId)
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();
}
|
public com.google.gdata.data.BaseFeed | getFeed(org.apache.lucene.gdata.data.ServerBaseFeed feed)
if (feed == null)
throw new StorageException("feed is null");
if (LOG.isInfoEnabled())
LOG.info("get feed: " + feed.getId() + " start-index: "
+ feed.getStartIndex() + " resultCount: "
+ feed.getItemsPerPage());
ReferenceCounter<StorageQuery> query = null;
try {
query = this.controller.getStorageQuery();
BaseFeed retVal = query.get().getLatestFeedQuery(feed.getId(),
feed.getItemsPerPage(), feed.getStartIndex(),
feed.getServiceConfig());
return retVal;
} catch (Exception e) {
LOG.error("Can't get latest feed for feedID: " + feed.getId()
+ " -- " + e.getMessage(), e);
StorageException ex = new StorageException("Can't create Entry -- "
+ e.getMessage(), e);
ex.setStackTrace(e.getStackTrace());
throw ex;
} finally {
if (query != null)
query.decrementRef();
}
|
public java.lang.Long | getFeedLastModified(java.lang.String feedId)
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();
}
|
public java.lang.String | getServiceForFeed(java.lang.String feedId)
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();
}
|
private void | releaseLock(java.lang.String key)
if(!this.controller.getLock().releaseLock(key))
throw new StorageException("Can not release lock for key: "+key);
|
private void | setLock(java.lang.String key)
if(!this.controller.getLock().setLock(key))
throw new ModificationConflictException("Can not set lock for entry -- "+key);
|
public void | storeAccount(org.apache.lucene.gdata.data.GDataAccount Account)
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();
}
|
public com.google.gdata.data.BaseEntry | storeEntry(org.apache.lucene.gdata.data.ServerBaseEntry entry)
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();
|
public void | storeFeed(org.apache.lucene.gdata.data.ServerBaseFeed feed, java.lang.String accountName)
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();
}
|
public void | updateAccount(org.apache.lucene.gdata.data.GDataAccount Account)
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();
}
|
public com.google.gdata.data.BaseEntry | updateEntry(org.apache.lucene.gdata.data.ServerBaseEntry entry)
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{
if(query != null)
query.decrementRef();
// release lock for concurrency
releaseLock(key);
}
return entry.getEntry();
|
public void | updateFeed(org.apache.lucene.gdata.data.ServerBaseFeed feed, java.lang.String accountName)
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();
}
|