MCPcopy Create free account
hub / github.com/Icinga/icinga2 / RemoveComment

Method RemoveComment

lib/icinga/comment.cpp:191–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void Comment::RemoveComment(const String& id, bool removedManually, const String& removedBy)
192{
193 Comment::Ptr comment = Comment::GetByName(id);
194
195 if (!comment || comment->GetPackage() != "_api")
196 return;
197
198 Log(LogNotice, "Comment")
199 << "Removed comment '" << comment->GetName() << "' from object '" << comment->GetCheckable()->GetName() << "'.";
200
201 if (removedManually) {
202 comment->SetRemovalInfo(removedBy, Utility::GetTime());
203 }
204
205 Array::Ptr errors = new Array();
206
207 if (!ConfigObjectUtility::DeleteObject(comment, false, errors, nullptr)) {
208 ObjectLock olock(errors);
209 for (String error : errors) {
210 Log(LogCritical, "Comment", error);
211 }
212
213 BOOST_THROW_EXCEPTION(std::runtime_error("Could not remove comment."));
214 }
215}
216
217void Comment::SetRemovalInfo(const String& removedBy, double removeTime, const MessageOrigin::Ptr& origin) {
218 {

Callers

nothing calls this directly

Calls 5

LogClass · 0.85
GetPackageMethod · 0.45
GetNameMethod · 0.45
GetCheckableMethod · 0.45
SetRemovalInfoMethod · 0.45

Tested by

no test coverage detected