| 801 | } |
| 802 | |
| 803 | Value ClusterEvents::AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) |
| 804 | { |
| 805 | Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint(); |
| 806 | |
| 807 | if (!endpoint) { |
| 808 | Log(LogNotice, "ClusterEvents") |
| 809 | << "Discarding 'acknowledgement set' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed)."; |
| 810 | return Empty; |
| 811 | } |
| 812 | |
| 813 | Host::Ptr host = Host::GetByName(params->Get("host")); |
| 814 | |
| 815 | if (!host) |
| 816 | return Empty; |
| 817 | |
| 818 | Checkable::Ptr checkable; |
| 819 | |
| 820 | if (params->Contains("service")) |
| 821 | checkable = host->GetServiceByShortName(params->Get("service")); |
| 822 | else |
| 823 | checkable = host; |
| 824 | |
| 825 | if (!checkable) |
| 826 | return Empty; |
| 827 | |
| 828 | if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) { |
| 829 | Log(LogNotice, "ClusterEvents") |
| 830 | << "Discarding 'acknowledgement set' message for checkable '" << checkable->GetName() |
| 831 | << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access."; |
| 832 | return Empty; |
| 833 | } |
| 834 | |
| 835 | ObjectLock oLock (checkable); |
| 836 | |
| 837 | if (checkable->IsAcknowledged()) { |
| 838 | Log(LogWarning, "ClusterEvents") |
| 839 | << "Discarding 'acknowledgement set' message for checkable '" << checkable->GetName() |
| 840 | << "' from '" << origin->FromClient->GetIdentity() << "': Checkable is already acknowledged."; |
| 841 | return Empty; |
| 842 | } |
| 843 | |
| 844 | checkable->AcknowledgeProblem(params->Get("author"), params->Get("comment"), |
| 845 | static_cast<AcknowledgementType>(static_cast<int>(params->Get("acktype"))), |
| 846 | params->Get("notify"), params->Get("persistent"), params->Get("change_time"), params->Get("expiry"), origin); |
| 847 | |
| 848 | return Empty; |
| 849 | } |
| 850 | |
| 851 | void ClusterEvents::AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& removedBy, double changeTime, const MessageOrigin::Ptr& origin) |
| 852 | { |
nothing calls this directly
no test coverage detected