| 284 | } |
| 285 | |
| 286 | String ConfigPackageUtility::GetActiveStage(const String& packageName) |
| 287 | { |
| 288 | String activeStage; |
| 289 | |
| 290 | ApiListener::Ptr listener = ApiListener::GetInstance(); |
| 291 | |
| 292 | /* If we don't have an API feature, just use the file storage without caching this. |
| 293 | * This happens when ScheduledDowntime objects generate Downtime objects. |
| 294 | * TODO: Make the API a first class citizen. |
| 295 | */ |
| 296 | if (!listener) |
| 297 | return GetActiveStageFromFile(packageName); |
| 298 | |
| 299 | /* First use runtime state. */ |
| 300 | try { |
| 301 | activeStage = listener->GetActivePackageStage(packageName); |
| 302 | } catch (const std::exception& ex) { |
| 303 | /* Fallback to reading the file, happens on restarts. */ |
| 304 | activeStage = GetActiveStageFromFile(packageName); |
| 305 | |
| 306 | /* When we've read something, correct memory. */ |
| 307 | if (!activeStage.IsEmpty()) |
| 308 | listener->SetActivePackageStage(packageName, activeStage); |
| 309 | } |
| 310 | |
| 311 | return activeStage; |
| 312 | } |
| 313 | |
| 314 | void ConfigPackageUtility::SetActiveStage(const String& packageName, const String& stageName) |
| 315 | { |
nothing calls this directly
no test coverage detected