getName()); if (!is_null($existingCommand) && $command_id != $existingCommand->getId()) { self::badInput("Command name already exists"); } if (is_null($command->getName()) || strlen($command->getName()) == 0) { self::badInput("Missing command name"); } HostsBusiness::getById($command->getHostId()); CommandTypesBusiness::getById($command->getCommandTypeId()); if (is_null($command->getDescription())) { $command->setDescription(""); } if (is_null($command->getData()) || strlen($command->getData()) == 0) { $command->setData("{}"); } $json = json_decode($command->getData()); if (is_null($json)) { self::badInput("Command data could not be converted to json"); } } public static function add(CommandsDbo $command) { self::checkCommand($command); return CommandsDataAccess::addId($command); } public static function edit(CommandsDbo $command, $command_id) { self::getById($command_id); self::checkCommand($command, $command_id); $command->setId($command_id); return CommandsDataAccess::editById($command_id, $command); } public static function exec($command_id) { self::getById($command_id); return true; } }