| 1420 | } |
| 1421 | |
| 1422 | void CatalogServer::CatalogObjectsUrlCallback(const Webserver::WebRequest& req, |
| 1423 | Document* document) { |
| 1424 | const auto& args = req.parsed_args; |
| 1425 | Webserver::ArgumentMap::const_iterator object_type_arg = args.find("object_type"); |
| 1426 | Webserver::ArgumentMap::const_iterator object_name_arg = args.find("object_name"); |
| 1427 | Webserver::ArgumentMap::const_iterator json_arg = args.find("json"); |
| 1428 | if (object_type_arg != args.end() && object_name_arg != args.end()) { |
| 1429 | TCatalogObjectType::type object_type = |
| 1430 | TCatalogObjectTypeFromName(object_type_arg->second); |
| 1431 | |
| 1432 | // Get the object type and name from the topic entry key |
| 1433 | TCatalogObject request; |
| 1434 | Status status = |
| 1435 | TCatalogObjectFromObjectName(object_type, object_name_arg->second, &request); |
| 1436 | |
| 1437 | if (json_arg != args.end()) { |
| 1438 | // Get the JSON string from FE since Thrift doesn't have a cpp implementation for |
| 1439 | // SimpleJsonProtocol (THRIFT-2476), so we use it's java implementation. |
| 1440 | // TODO: switch to use cpp implementation of SimpleJsonProtocol after THRIFT-2476 |
| 1441 | // is resolved. |
| 1442 | string json_str; |
| 1443 | if (status.ok()) status = catalog_->GetJsonCatalogObject(request, &json_str); |
| 1444 | if (status.ok()) { |
| 1445 | Value debug_string(json_str, document->GetAllocator()); |
| 1446 | document->AddMember("json_string", debug_string, document->GetAllocator()); |
| 1447 | } |
| 1448 | } else { |
| 1449 | // Get the object and dump its contents. |
| 1450 | TCatalogObject result; |
| 1451 | if (status.ok()) status = catalog_->GetCatalogObject(request, &result); |
| 1452 | if(status.ok()) { |
| 1453 | Value debug_string( |
| 1454 | ThriftDebugStringNoThrow(result), document->GetAllocator()); |
| 1455 | document->AddMember("thrift_string", debug_string, document->GetAllocator()); |
| 1456 | } |
| 1457 | } |
| 1458 | if (!status.ok()) { |
| 1459 | Value error(status.GetDetail(), document->GetAllocator()); |
| 1460 | document->AddMember("error", error, document->GetAllocator()); |
| 1461 | } |
| 1462 | } else { |
| 1463 | Value error("Please specify values for the object_type and object_name parameters.", |
| 1464 | document->GetAllocator()); |
| 1465 | document->AddMember("error", error, document->GetAllocator()); |
| 1466 | } |
| 1467 | } |
| 1468 | |
| 1469 | void CatalogServer::OperationUsageUrlCallback( |
| 1470 | const Webserver::WebRequest& req, Document* document) { |
no test coverage detected