@Override
public Integer update(String id, Integer version, T content) throws IResourceStore.ResourceStoreException, IResourceStore.ResourceModifiedException, IResourceStore.ResourceNotFoundException {
RuntimeUtilities.checkNotNull(id, "id");
RuntimeUtilities.checkNotNull(version, "version");
RuntimeUtilities.checkNotNull(content, "content");
IResourceStorage.IResource resource = resourceStorage.read(id, version);
checkIfFoundAndLatest(id, version, resource);
IResourceStorage.IHistoryResource history = resourceStorage.newHistoryResourceFor(resource, false);
resourceStorage.store(history);
try {
Integer newVersion = resource.getVersion() + 1;
IResourceStorage.IResource newResource = resourceStorage.newResource(resource.getId(), newVersion, content);
resourceStorage.store(newResource);
return newVersion;
} catch (IOException e) {
throw new IResourceStore.ResourceStoreException(e.getLocalizedMessage(), e);
}
}