コード例 #1
0
static gboolean
meta1_dispatch_v2_PROPDEL(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	gchar **keys = NULL;
	gsize length = 0;
	void *body = metautils_message_get_BODY(reply->request, &length);
	GError *err = STRV_decode_buffer(body, length, &keys);

	if (NULL != err)
		reply->send_error(CODE_BAD_REQUEST, err);
	else {
		err = meta1_backend_del_container_properties(m1, url, keys);
		if (err)
			reply->send_error(0, err);
		else
			reply->send_reply(CODE_FINAL_OK, "OK");
		g_strfreev (keys);
	}

	oio_url_clean (url);
	return TRUE;
}
コード例 #2
0
static gboolean
meta1_dispatch_v2_SRVRELINK(struct gridd_reply_ctx_s *reply,
	struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err = NULL;
	gchar *replaced = NULL, *kept = NULL, **newset = NULL;
	struct oio_url_s *url = NULL;
	(void) ignored;

	url = metautils_message_extract_url (reply->request);
	kept = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_OLD);
	replaced = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_NOTIN);
	gboolean dryrun = metautils_message_extract_flag (reply->request, NAME_MSGKEY_DRYRUN, FALSE);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	if (!url) {
		reply->send_error (0, NEWERROR(CODE_BAD_REQUEST, "Missing field (%s)", "url"));
	} else {
		err = meta1_backend_services_relink (m1, url, kept, replaced, dryrun, &newset);
		if (NULL != err) {
			reply->send_error (0, err);
		} else {
			reply->add_body(marshall_stringv_and_clean(&newset));
			reply->send_reply (CODE_FINAL_OK, "OK");
		}
	}

	oio_url_pclean (&url);
	g_free0 (kept);
	g_free0 (replaced);
	if (newset) g_strfreev (newset);
	return TRUE;
}
コード例 #3
0
static gboolean
meta1_dispatch_v2_SRV_UNLINK(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	gchar **urlv = NULL;
	GError *err;
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype);
	(void) ignored;

	if (!srvtype)
		reply->send_error(CODE_BAD_REQUEST, NEWERROR(CODE_BAD_REQUEST, "Missing srvtype"));
	else if (NULL != (err = metautils_message_extract_body_strv(reply->request, &urlv)))
		reply->send_error(CODE_BAD_REQUEST, err);
	else if (NULL != (err = meta1_backend_services_unlink(m1, url, srvtype, urlv)))
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "OK");

	if (urlv) g_strfreev (urlv);
	oio_url_clean (url);
	g_free0 (srvtype);
	return TRUE;
}
コード例 #4
0
static gboolean
meta1_dispatch_v2_SRV_FORCE(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gboolean ac = metautils_message_extract_flag (reply->request, NAME_MSGKEY_AUTOCREATE, FALSE);
	gboolean force = metautils_message_extract_flag (reply->request, NAME_MSGKEY_FORCE, FALSE);
	reply->subject("%s|%s|?", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	gchar *m1url = NULL;
	GError *err = metautils_message_extract_body_string(reply->request, &m1url);
	if (NULL != err)
		reply->send_error(CODE_BAD_REQUEST, err);
	else {
		reply->subject("%s|%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), m1url);
		err = meta1_backend_services_set(m1, url, m1url, ac, force);
		g_free0 (m1url);
		if (NULL != err)
			reply->send_error(0, err);
		else
			reply->send_reply(200, "OK");
	}

	oio_url_clean (url);
	return TRUE;
}
コード例 #5
0
static gboolean
meta1_dispatch_v2_USERCREATE(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	gsize length = 0;
	void *body = metautils_message_get_BODY(reply->request, &length);
	gchar **properties = NULL;
	GError *err = KV_decode_buffer(body, length, &properties);
	if (NULL != err) {
		reply->send_error(0, err);
		return TRUE;
	}

	err = meta1_backend_user_create(m1, url, properties);
	g_strfreev(properties);

	if (NULL != err)
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "Created");

	oio_url_clean (url);
	return TRUE;
}
コード例 #6
0
static gboolean
meta1_dispatch_v2_SRV_UNLINK(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype);

	if (!srvtype)
		reply->send_error(CODE_BAD_REQUEST, NEWERROR(CODE_BAD_REQUEST, "Missing srvtype"));
	else {
		gsize length = 0;
		void *body = metautils_message_get_BODY(reply->request, &length);
		gchar **urlv = NULL;
		GError *err = STRV_decode_buffer(body, length, &urlv);
		if (NULL != err)
			reply->send_error(CODE_BAD_REQUEST, err);
		else {
			err = meta1_backend_services_unlink(m1, url, srvtype, urlv);
			if (NULL != err)
				reply->send_error(0, err);
			else
				reply->send_reply(CODE_FINAL_OK, "OK");
			g_strfreev (urlv);
		}
	}

	oio_url_clean (url);
	g_free0 (srvtype);
	return TRUE;
}
コード例 #7
0
static gboolean
meta1_dispatch_v2_PROPGET(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar **strv = NULL, **result = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	(void) ignored;

	if (NULL != (err = metautils_message_extract_body_strv(reply->request, &strv)))
		reply->send_error(CODE_BAD_REQUEST, err);
	else if (NULL != (err = meta1_backend_get_container_properties(m1, url, strv, &result)))
		reply->send_error(0, err);
	else {
		reply->add_body(marshall_stringv_and_clean(&result));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	if (strv) g_strfreev (strv);
	if (result) g_strfreev (result);
	oio_url_clean (url);
	return TRUE;
}
コード例 #8
0
static gboolean
meta1_dispatch_v2_SRV_RENEW(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gboolean ac = metautils_message_extract_flag(reply->request, NAME_MSGKEY_AUTOCREATE, FALSE);
	gboolean dryrun = metautils_message_extract_flag(reply->request, NAME_MSGKEY_DRYRUN, FALSE);
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	reply->subject("%s|%s|%s|%d", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype, dryrun);
	(void) ignored;

	gchar **result = NULL;
	GError *err = meta1_backend_services_poll(m1, url, srvtype, ac, dryrun, &result);
	if (NULL != err)
		reply->send_error(0, err);
	else {
		reply->add_body(marshall_stringv_and_clean(&result));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	if (result) g_strfreev (result);
	oio_url_clean(url);
	g_free0 (srvtype);
	return TRUE;
}
コード例 #9
0
int
meta2_filter_extract_header_url(struct gridd_filter_ctx_s *ctx,
		struct gridd_reply_ctx_s *reply)
{
	TRACE_FILTER();
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	meta2_filter_ctx_set_url(ctx, url);
	return FILTER_OK;
}
コード例 #10
0
static gboolean
meta1_dispatch_v2_USERCREATE(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	(void) ignored;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	GError *err = meta1_backend_user_create(m1, url);
	if (NULL != err)
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "Created");

	oio_url_clean (url);
	return TRUE;
}
コード例 #11
0
static gboolean
meta1_dispatch_v2_USERDESTROY(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gboolean force = metautils_message_extract_flag(reply->request, NAME_MSGKEY_FORCE, FALSE);
	reply->subject("%s|%s|%d", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), force);

	GError *err = meta1_backend_user_destroy(m1, url, force);
	if (NULL != err)
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "OK");

	oio_url_clean (url);
	return TRUE;
}
コード例 #12
0
static gboolean
meta1_dispatch_v2_USERINFO(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));

	gchar **info = NULL;
	GError *err = meta1_backend_user_info(m1, url, &info);
	if (NULL != err)
		reply->send_error(0, err);
	else {
		reply->add_body(encode_and_clean(STRV_encode_gba, info));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	oio_url_clean (url);
	return TRUE;
}
コード例 #13
0
static gboolean
meta1_dispatch_v2_SRV_ALLONM1(struct gridd_reply_ctx_s *reply,
        struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
    reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));
    reply->send_reply(CODE_TEMPORARY, "Received");

	gchar **result = NULL;
	GError *err = meta1_backend_services_all(m1, url, &result);
	if (NULL != err)
        reply->send_error(0, err);
    else {
        reply->add_body(encode_and_clean(STRV_encode_gba, result));
        reply->send_reply(CODE_FINAL_OK, "OK");
    }

	oio_url_clean (url);
    return TRUE;
}
コード例 #14
0
static gboolean
meta1_dispatch_v2_SRV_CONFIG(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar *m1url = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));
	(void) ignored;

	if (NULL != (err = metautils_message_extract_body_string(reply->request, &m1url)))
		reply->send_error(CODE_BAD_REQUEST, err);
	else if (NULL != (err = meta1_backend_services_config(m1, url, m1url)))
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "OK");

	g_free0 (m1url);
	oio_url_clean (url);
	return TRUE;
}
コード例 #15
0
static gboolean
meta1_dispatch_v2_SRV_LIST(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	reply->subject("%s|%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype);
	STRING_STACKIFY(srvtype);

	gchar **result = NULL;
	GError *err = meta1_backend_services_list(m1, url, srvtype, &result);
	if (NULL != err)
		reply->send_error(0, err);
	else {
		reply->add_body(encode_and_clean(STRV_encode_gba, result));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	oio_url_clean (url);
	return TRUE;
}
コード例 #16
0
static gboolean
meta1_dispatch_v2_USERINFO(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar **info = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));
	(void) ignored;

	if (NULL != (err = meta1_backend_user_info(m1, url, &info)))
		reply->send_error(0, err);
	else {
		reply->add_body(marshall_stringv_and_clean(&info));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	if (info) g_strfreev (info);
	oio_url_clean (url);
	return TRUE;
}
コード例 #17
0
static gboolean
meta1_dispatch_v2_SRV_ALLONM1(struct gridd_reply_ctx_s *reply,
        struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar **result = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
    reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));
    reply->send_reply(CODE_TEMPORARY, "Received");
    (void) ignored;

	if (NULL != (err = meta1_backend_services_all(m1, url, &result)))
        reply->send_error(0, err);
    else {
        reply->add_body(marshall_stringv_and_clean(&result));
        reply->send_reply(CODE_FINAL_OK, "OK");
    }

	if (result) g_strfreev (result);
	oio_url_clean (url);
    return TRUE;
}
コード例 #18
0
static gboolean
meta1_dispatch_v2_SRV_LINK(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored UNUSED)
{
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	gboolean dryrun = metautils_message_extract_flag(reply->request, NAME_MSGKEY_DRYRUN, FALSE);
	gboolean autocreate = metautils_message_extract_flag(reply->request, NAME_MSGKEY_AUTOCREATE, FALSE);
	reply->subject("%s|%s|%s|%d", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype, dryrun);

	gchar **result = NULL;
	GError *err = meta1_backend_services_link (m1, url, srvtype, dryrun, autocreate, &result);
	if (NULL != err)
		reply->send_error(0, err);
	else {
		reply->add_body(encode_and_clean(STRV_encode_gba, result));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	oio_url_clean(url);
	g_free0 (srvtype);
	return TRUE;
}
コード例 #19
0
static gboolean
meta1_dispatch_v2_SRV_LIST(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar **result = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gchar *srvtype = metautils_message_extract_string_copy (reply->request, NAME_MSGKEY_TYPENAME);
	reply->subject("%s|%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID), srvtype);
	(void) ignored;

	if (NULL != (err = meta1_backend_services_list(m1, url, srvtype, &result)))
		reply->send_error(0, err);
	else {
		reply->add_body(marshall_stringv_and_clean(&result));
		reply->send_reply(CODE_FINAL_OK, "OK");
	}

	if (result) g_strfreev (result);
	oio_url_clean (url);
	g_free0 (srvtype);
	return TRUE;
}
コード例 #20
0
static gboolean
meta1_dispatch_v2_PROPSET(struct gridd_reply_ctx_s *reply,
		struct meta1_backend_s *m1, gpointer ignored)
{
	GError *err;
	gchar **strv = NULL;
	struct oio_url_s *url = metautils_message_extract_url (reply->request);
	gboolean flush = metautils_message_extract_flag(reply->request,
			NAME_MSGKEY_FLUSH, FALSE);
	reply->subject("%s|%s", oio_url_get(url, OIOURL_WHOLE), oio_url_get(url, OIOURL_HEXID));
	(void) ignored;

	if (NULL != (err = metautils_message_extract_body_strv(reply->request, &strv)))
		reply->send_error(CODE_BAD_REQUEST, err);
	else if (NULL != (err = meta1_backend_set_container_properties(m1, url, strv, flush)))
		reply->send_error(0, err);
	else
		reply->send_reply(CODE_FINAL_OK, "OK");

	if (strv) g_strfreev (strv);
	oio_url_clean (url);
	return TRUE;
}