+HTTPResponse* Server::cmd_plant_get(const Command& command) {
+ if (!command.get_args().size()) {
+ return new HTTPResponse(HTTPMessage::CONFLICT,
+ "Faltan argumentos.");
+ }
+ Glib::Mutex::Lock lock(plants_mutex);
+ string plant = command.get_args()[0];
+ if (plants.find(plant) == plants.end()) {
+ return new HTTPResponse(HTTPMessage::NOT_FOUND,
+ string("No existe la planta ") + plant);
+ }
+ string xml = plants[plant]->get_xml();
+ if (xml.length()) {
+ return new HTTPResponse(HTTPMessage::OK, xml);
+ } else {
+ return new HTTPResponse(HTTPMessage::INTERNAL_SERVER_ERROR,
+ ("No se pudo obtener el XML de la planta ") + plant);
+ }
+}
+
+HTTPResponse* Server::cmd_plant_set(const Command& command) {
+ const Command::Arguments& args = command.get_args();
+ if (args.size() < 4) {
+ return new HTTPResponse(HTTPMessage::CONFLICT,
+ "Faltan argumentos.");
+ }
+ string plant = args[0];
+ string element = args[1];
+ string key = args[2];
+ string value = args[3];
+ Glib::Mutex::Lock lock(plants_mutex);
+ PlantList::iterator p = plants.find(plant);
+ if (p == plants.end()) {
+ return new HTTPResponse(HTTPMessage::NOT_FOUND,
+ string("No existe la planta '") + plant + "'.");
+ }
+/* if (!plants[plant]->set_element(host, port)) {
+ return new HTTPResponse(HTTPMessage::INTERNAL_SERVER_ERROR,
+ string("Error al crear la transmisión a de la planta '")
+ + plant + "' a " + host + ":" + args[2] + ".");
+ }*/
+ return new HTTPResponse(HTTPMessage::OK);
+}
+