summaryrefslogtreecommitdiff
path: root/chef-server-api/app
diff options
context:
space:
mode:
authorNuo Yan <nuoyan@nuo-yans-macbook-pro.local>2009-11-02 12:03:23 -0800
committerNuo Yan <nuoyan@nuo-yans-macbook-pro.local>2009-11-02 12:03:23 -0800
commitc7382be341eb0d1d30d8ec8b924d44f8c7fd936d (patch)
treeef3ac944368eb25b076523f0fdbc956beb2cb4ee /chef-server-api/app
parentbe8c347dd179446e69fe1789967bc99aa6af78b0 (diff)
downloadchef-c7382be341eb0d1d30d8ec8b924d44f8c7fd936d.tar.gz
webui work
Diffstat (limited to 'chef-server-api/app')
-rw-r--r--chef-server-api/app/controllers/data_item.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/chef-server-api/app/controllers/data_item.rb b/chef-server-api/app/controllers/data_item.rb
index 8a8f14a64b..fbbeb104ae 100644
--- a/chef-server-api/app/controllers/data_item.rb
+++ b/chef-server-api/app/controllers/data_item.rb
@@ -1,6 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Christopher Brown (<cb@opscode.com>)
+# Author:: Nuo Yan (<nuo@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
@@ -61,11 +62,39 @@ class ChefServerApi::DataItem < ChefServerApi::Application
rescue Chef::Exceptions::CouchDBNotFound
@data_bag_item = Chef::DataBagItem.new
@data_bag_item.data_bag(@data_bag.name)
+ else
+ raise Forbidden, "Databag Item #{params[:id]} already exists" if @data_bag_item
end
@data_bag_item.raw_data = raw_data
@data_bag_item.cdb_save
display @data_bag_item.raw_data
end
+
+ def update
+ raw_data = nil
+ if params.has_key?("inflated_object")
+ raw_data = params["inflated_object"].raw_data
+ STDERR.puts "in inflated"
+ else
+ raw_data = params
+ raw_data.delete(:action)
+ raw_data.delete(:controller)
+ raw_data.delete(:data_bag_id)
+ STDERR.puts "in else"
+ end
+
+ begin
+ @data_bag_item = Chef::DataBagItem.cdb_load(@data_bag.name, params[:id])
+ rescue Chef::Exceptions::CouchDBNotFound => e
+ raise NotFound, "Cannot load Databag Item #{params[:id]}"
+ end
+
+ @data_bag_item.raw_data = raw_data
+ @data_bag_item.cdb_save
+ display @data_bag_item.raw_data
+
+ end
+
def destroy
begin