* @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{