def create_data(request, rest_path, name, data, *options)
rest_path ||= request.rest_path
begin
data_store.create(rest_path, name, data, *options, :requestor => request.requestor)
rescue DataStore::DataNotFoundError
if options.include?(:data_store_exceptions)
raise
else
raise RestErrorResponse.new(404, "Parent not found: #{build_uri(request.base_uri, request.rest_path)}")
end
rescue DataStore::DataAlreadyExistsError
if options.include?(:data_store_exceptions)
raise
else
raise RestErrorResponse.new(409, "Object already exists: #{build_uri(request.base_uri, request.rest_path + [name])}")
end
end
end