2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-01-29 16:29:09 +01:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/service.hpp"
|
2015-08-20 17:18:48 +02:00
|
|
|
#include "remote/configobjectutility.hpp"
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configtype.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/objectlock.hpp"
|
|
|
|
#include "base/timer.hpp"
|
|
|
|
#include "base/utility.hpp"
|
2014-10-19 14:21:12 +02:00
|
|
|
#include "base/logger.hpp"
|
2013-01-29 16:29:09 +01:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
void Checkable::RemoveAllComments()
|
2013-01-29 16:29:09 +01:00
|
|
|
{
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Comment::Ptr& comment : GetComments()) {
|
2015-08-20 17:18:48 +02:00
|
|
|
Comment::RemoveComment(comment->GetName());
|
2013-08-20 11:06:04 +02:00
|
|
|
}
|
2013-01-29 16:29:09 +01:00
|
|
|
}
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
void Checkable::RemoveCommentsByType(int type)
|
2013-02-27 15:23:25 +01:00
|
|
|
{
|
2016-08-25 06:19:44 +02:00
|
|
|
for (const Comment::Ptr& comment : GetComments()) {
|
2017-01-25 21:21:22 +01:00
|
|
|
/* Do not remove persistent comments from an acknowledgement */
|
|
|
|
if (comment->GetEntryType() == CommentAcknowledgement && comment->GetPersistent())
|
|
|
|
continue;
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
if (comment->GetEntryType() == type)
|
|
|
|
Comment::RemoveComment(comment->GetName());
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
std::set<Comment::Ptr> Checkable::GetComments() const
|
2013-06-19 10:57:07 +02:00
|
|
|
{
|
2015-08-20 17:18:48 +02:00
|
|
|
boost::mutex::scoped_lock lock(m_CommentMutex);
|
|
|
|
return m_Comments;
|
2013-06-19 10:57:07 +02:00
|
|
|
}
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
void Checkable::RegisterComment(const Comment::Ptr& comment)
|
2013-01-30 14:28:13 +01:00
|
|
|
{
|
2015-08-20 17:18:48 +02:00
|
|
|
boost::mutex::scoped_lock lock(m_CommentMutex);
|
|
|
|
m_Comments.insert(comment);
|
2013-01-30 14:28:13 +01:00
|
|
|
}
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
void Checkable::UnregisterComment(const Comment::Ptr& comment)
|
2013-01-30 14:28:13 +01:00
|
|
|
{
|
2015-08-20 17:18:48 +02:00
|
|
|
boost::mutex::scoped_lock lock(m_CommentMutex);
|
|
|
|
m_Comments.erase(comment);
|
2013-01-29 16:29:09 +01:00
|
|
|
}
|