static void hippo_block_group_revision_dispose(GObject *object) { HippoBlockGroupRevision *block_group_revision = HIPPO_BLOCK_GROUP_REVISION(object); set_group(block_group_revision, NULL); set_edit_link(block_group_revision, NULL); G_OBJECT_CLASS(hippo_block_group_revision_parent_class)->dispose(object); }
static void update_edit_link(HippoBlockGroupRevision *block_group_revision) { HippoBlock *block = HIPPO_BLOCK(block_group_revision); const char *edit_link = NULL; /* Only active members can edit */ if (block_group_revision->group != NULL && hippo_group_get_status(block_group_revision->group) >= HIPPO_MEMBERSHIP_STATUS_ACTIVE) { ddm_data_resource_get(block->resource, "editLink", DDM_DATA_URL, &edit_link, NULL); } set_edit_link(block_group_revision, edit_link); }
// Handler to process HTTP::GET requests. // Replies to the request with data. void odata_test_service::handle_get(http_request message) { try { bool is_async = false; auto prefer_header = message.headers().find(U("Prefer")); if (prefer_header != message.headers().end()) { if (prefer_header->second.find(U("respond-async")) != ::odata::utility::string_t::npos) { is_async = true; } } auto parsed_uri = m_uri_parser->parse_uri(message.relative_uri()); odata_message_writer writer(m_model, m_service_root); odata_context_url_builder context_url_builder(m_model, m_service_root); odata_metadata_builder metadata_builder(m_model, m_service_root); ::odata::utility::string_t content; if (parsed_uri->is_service_document()) { // Write service document content = writer.write_service_document(m_service_document); } else if (parsed_uri->is_metadata_document()) { // Write metadata document content = writer.write_metadata_document(); } else { if (parsed_uri->path()->size() >= 1) { if (parsed_uri->path()->segment_at(0)->segment_type() == odata_path_segment_type::EntitySet) { auto entity_set_segment = parsed_uri->path()->segment_at(0)->as<odata_entity_set_segment>(); if (entity_set_segment->entity_set()->get_name() == U("People")) { if (parsed_uri->path()->size() == 1) { auto people = get_people(); auto context_url = context_url_builder.get_context_uri_for_collection_of_entities(entity_set_segment->entity_set()); people->set_context_url(context_url); if (is_async) { std::unordered_map<string_t, string_t> headers; headers[U("OData-Version")] = U("4.0"); headers[U("Content-Type")] = U("application/json;odata.metadata=full"); content = writer.write_asynchronous_odata_value(people, 200, U("OK"), headers); } else { content = writer.write_odata_value(people); } } else if (parsed_uri->path()->segment_at(1)->segment_type() == odata_path_segment_type::Key) { auto key_segment = parsed_uri->path()->segment_at(1)->as<odata_key_segment>(); auto key = key_segment->keys()[0].second->as<::odata::utility::string_t>(); auto single_person = get_single_people(key); single_person->set_is_top_level(true); auto context_url = context_url_builder.get_context_uri_for_entity(entity_set_segment->entity_set()); single_person->set_context_url(context_url); auto id = metadata_builder.get_entity_id(single_person, entity_set_segment->entity_set()); single_person->set_id(id); auto read_link = metadata_builder.get_read_link(single_person, entity_set_segment->entity_set()); single_person->set_read_link(read_link); auto edit_link = metadata_builder.get_edit_link(single_person, entity_set_segment->entity_set()); single_person->set_edit_link(edit_link); content = writer.write_odata_value(single_person); } } } } } message.reply(status_codes::OK, content).then(std::bind(&handle_error, std::placeholders::_1)); } catch (::odata::core::odata_exception &e) { message.reply(status_codes::BadRequest, U("Exception: ") + e.what()).then(std::bind(&handle_error, std::placeholders::_1)); } ////Get odata objects from resorce and odata_path // }