From: Yehuda Sadeh Date: Thu, 9 Jan 2014 18:37:25 +0000 (-0800) Subject: rgw: fix temp url restful apis and support multiple keys X-Git-Tag: v0.78~333^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9395e0d778807bb4531a1e4e68068726c8940160;p=ceph.git rgw: fix temp url restful apis and support multiple keys the set temp url api didn't do anything, fix that. Also add support for multiple temp url keys. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 76a428f8bf4..98ca5801fda 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1716,6 +1716,29 @@ int RGWSetTempUrl::verify_permission() void RGWSetTempUrl::execute() { + ret = get_params(); + if (ret < 0) + return; + + RGWUserAdminOpState user_op; + user_op.set_user_id(s->user.user_id); + map::iterator iter; + for (iter = temp_url_keys.begin(); iter != temp_url_keys.end(); ++iter) { + user_op.set_temp_url_key(iter->second, iter->first); + } + + RGWUser user; + ret = user.init(store, user_op); + if (ret < 0) { + ldout(store->ctx(), 0) << "ERROR: could not init user ret=" << ret << dendl; + return; + } + string err_msg; + ret = user.modify(user_op, &err_msg); + if (ret < 0) { + ldout(store->ctx(), 10) << "user.modify() returned " << ret << ": " << err_msg << dendl; + return; + } } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 3fa3497ebb7..2ff8875eb74 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -415,7 +415,7 @@ public: class RGWSetTempUrl : public RGWOp { protected: int ret; - string temp_url_key; + map temp_url_keys; public: RGWSetTempUrl() : ret(0) {} diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 68626b8a6f5..6524db8b403 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -427,11 +427,18 @@ void RGWPutMetadata_ObjStore_SWIFT::send_response() int RGWSetTempUrl_ObjStore_SWIFT::get_params() { - const char *temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL"); - if (temp_url) - return -EINVAL; + const char *temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL_KEY"); + if (temp_url) { + temp_url_keys[0] = temp_url; + } + + temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL_KEY_2"); + if (temp_url) { + temp_url_keys[1] = temp_url; + } - temp_url_key = temp_url; + if (temp_url_keys.size() == 0) + return -EINVAL; return 0; } @@ -625,7 +632,11 @@ RGWOp *RGWHandler_ObjStore_Service_SWIFT::op_head() RGWOp *RGWHandler_ObjStore_Service_SWIFT::op_post() { - const char *temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL"); + const char *temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL_KEY"); + if (temp_url) { + return new RGWSetTempUrl_ObjStore_SWIFT; + } + temp_url = s->info.env->get("HTTP_X_ACCOUNT_META_TEMP_URL_KEY_2"); if (temp_url) { return new RGWSetTempUrl_ObjStore_SWIFT; }