summaryrefslogtreecommitdiffstats
path: root/lib/MiddleWare
diff options
context:
space:
mode:
authorZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-05-12 14:02:23 +0200
committerZdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com>2009-05-12 14:02:23 +0200
commit132e3403a62e47df970241c289f718e5ca2ece97 (patch)
tree78d130f75feac1c176ccc4201e1e2a6d92e661a9 /lib/MiddleWare
parent7d0eaab97308c65d0da2db0a0d2f5710ce36e2fe (diff)
downloadabrt-132e3403a62e47df970241c289f718e5ca2ece97.tar.gz
abrt-132e3403a62e47df970241c289f718e5ca2ece97.tar.xz
abrt-132e3403a62e47df970241c289f718e5ca2ece97.zip
support for simpler settings
Diffstat (limited to 'lib/MiddleWare')
-rw-r--r--lib/MiddleWare/Action.h2
-rw-r--r--lib/MiddleWare/MiddleWare.cpp107
-rw-r--r--lib/MiddleWare/MiddleWare.h29
3 files changed, 89 insertions, 49 deletions
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h
index 9a2c2f11..96461f3c 100644
--- a/lib/MiddleWare/Action.h
+++ b/lib/MiddleWare/Action.h
@@ -29,7 +29,7 @@ class CAction : public CPlugin
{
public:
virtual ~CAction() {}
- virtual void Run(const std::string& pDebugDumpDir,
+ virtual void Run(const std::string& pActionDir,
const std::string& pArgs) = 0;
};
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
index 03285ee7..3c8ed4aa 100644
--- a/lib/MiddleWare/MiddleWare.cpp
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -185,24 +185,58 @@ int CMiddleWare::CreateCrashReport(const std::string& pUUID,
return 1;
}
-void CMiddleWare::Report(const std::string& pDebugDumpDir)
+void CMiddleWare::RunAction(const std::string& pActionDir,
+ const std::string& pPluginName,
+ const std::string& pPluginArgs)
{
- map_crash_report_t crashReport;
+ try
+ {
+ CAction* action = m_pPluginManager->GetAction(pPluginName);
+ if (action)
+ {
+ action->Run(pActionDir, pPluginArgs);
+ }
+ else
+ {
+ throw CABRTException(EXCEP_ERROR, "Plugin '"+pPluginName+"' is not registered.");
+ }
+ }
+ catch (CABRTException& e)
+ {
+ comm_layer_inner_warning("CMiddleWare::RunAction(): " + e.what());
+ comm_layer_inner_status("Execution of '"+pPluginName+"' was not successful: " + e.what());
+ }
- DebugDumpToCrashReport(pDebugDumpDir, crashReport);
+}
- set_reporters_t::iterator it_r;
- for (it_r = m_setReporters.begin(); it_r != m_setReporters.end(); it_r++)
+void CMiddleWare::RunActionsAndReporters(const std::string& pDebugDumpDir)
+{
+ vector_actions_and_reporters_t::iterator it_ar;
+ for (it_ar = m_vectorActionsAndReporters.begin(); it_ar != m_vectorActionsAndReporters.end(); it_ar++)
{
try
{
- CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first);
- reporter->Report(crashReport, (*it_r).second);
+ CReporter* reporter = m_pPluginManager->GetReporter((*it_ar).first);
+ CAction* action = m_pPluginManager->GetAction((*it_ar).first);
+ if (reporter)
+ {
+ map_crash_report_t crashReport;
+ DebugDumpToCrashReport(pDebugDumpDir, crashReport);
+ reporter->Report(crashReport, (*it_ar).second);
+ }
+ else if (action)
+ {
+ action->Run(pDebugDumpDir, (*it_ar).second);
+ }
+ else
+ {
+ throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_ar).first+"' is not registered.");
+ }
}
catch (CABRTException& e)
{
- comm_layer_inner_warning("CMiddleWare::Report(): " + e.what());
- comm_layer_inner_status("Reporting via '"+(*it_r).first+"' was not successful: " + e.what());
+ comm_layer_inner_warning("CMiddleWare::RunActionsAndReporters(): " + e.what());
+ comm_layer_inner_status("Reporting via '"+(*it_ar).first+"' was not successful: " + e.what());
}
}
}
@@ -219,17 +253,24 @@ void CMiddleWare::Report(const map_crash_report_t& pCrashReport)
std::string UID = pCrashReport.find(CD_MWUID)->second[CD_CONTENT];
std::string UUID = pCrashReport.find(CD_MWUUID)->second[CD_CONTENT];
- if (m_mapAnalyzerReporters.find(analyzer) != m_mapAnalyzerReporters.end())
+ if (m_mapAnalyzerActionsAndReporters.find(analyzer) != m_mapAnalyzerActionsAndReporters.end())
{
- set_reporters_t::iterator it_r;
- for (it_r = m_mapAnalyzerReporters[analyzer].begin();
- it_r != m_mapAnalyzerReporters[analyzer].end();
+ vector_actions_and_reporters_t::iterator it_r;
+ for (it_r = m_mapAnalyzerActionsAndReporters[analyzer].begin();
+ it_r != m_mapAnalyzerActionsAndReporters[analyzer].end();
it_r++)
{
try
{
CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first);
- reporter->Report(pCrashReport, (*it_r).second);
+ if (reporter)
+ {
+ reporter->Report(pCrashReport, (*it_r).second);
+ }
+ else
+ {
+ throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_r).first+"' is not registered.");
+ }
}
catch (CABRTException& e)
{
@@ -338,17 +379,24 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutabl
void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir)
{
- if (m_mapAnalyzerActions.find(pAnalyzer) != m_mapAnalyzerActions.end())
+ if (m_mapAnalyzerActionsAndReporters.find(pAnalyzer) != m_mapAnalyzerActionsAndReporters.end())
{
- set_pairt_strings_t::iterator it_a;
- for (it_a = m_mapAnalyzerActions[pAnalyzer].begin();
- it_a != m_mapAnalyzerActions[pAnalyzer].end();
+ vector_actions_and_reporters_t::iterator it_a;
+ for (it_a = m_mapAnalyzerActionsAndReporters[pAnalyzer].begin();
+ it_a != m_mapAnalyzerActionsAndReporters[pAnalyzer].end();
it_a++)
{
try
{
CAction* action = m_pPluginManager->GetAction((*it_a).first);
- action->Run(pDebugDumpDir, (*it_a).second);
+ if (action)
+ {
+ action->Run(pDebugDumpDir, (*it_a).second);
+ }
+ else if (m_pPluginManager->GetReporter((*it_a).first) == NULL)
+ {
+ throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_a).first+"' is not registered.");
+ }
}
catch (CABRTException& e)
{
@@ -522,22 +570,15 @@ void CMiddleWare::AddBlackListedPackage(const std::string& pPackage)
m_setBlackList.insert(pPackage);
}
-void CMiddleWare::AddAnalyzerReporter(const std::string& pAnalyzer,
- const std::string& pReporter,
- const std::string& pArgs)
-{
- m_mapAnalyzerReporters[pAnalyzer].insert(make_pair(pReporter, pArgs));
-}
-
-void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer,
- const std::string& pAction,
- const std::string& pArgs)
+void CMiddleWare::AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
+ const std::string& pAnalyzerOrReporter,
+ const std::string& pArgs)
{
- m_mapAnalyzerActions[pAnalyzer].insert(make_pair(pAction, pArgs));
+ m_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs));
}
-void CMiddleWare::AddReporter(const std::string& pReporter,
- const std::string& pArgs)
+void CMiddleWare::AddActionOrReporter(const std::string& pActionOrReporter,
+ const std::string& pArgs)
{
- m_setReporters.insert(make_pair(pReporter, pArgs));
+ m_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs));
}
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index c3b47a4f..cad737a7 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -35,18 +35,16 @@ class CMiddleWare
typedef set_strings_t set_blacklist_t;
typedef set_strings_t set_enabled_plugins_t;
- typedef std::set<pair_string_string_t> set_pairt_strings_t;
- typedef std::map<std::string, set_pairt_strings_t> map_reporter_associations_t;
- typedef std::map<std::string, set_pairt_strings_t> map_action_associations_t;
- typedef set_pairt_strings_t set_reporters_t;
+ typedef std::vector<pair_string_string_t> vector_pairt_strings_t;
+ typedef vector_pairt_strings_t vector_actions_and_reporters_t;
+ typedef std::map<std::string, vector_actions_and_reporters_t> map_analyzer_actions_and_reporters_t;
CPluginManager* m_pPluginManager;
CRPM m_RPM;
set_blacklist_t m_setBlackList;
std::string m_sDatabase;
- map_reporter_associations_t m_mapAnalyzerReporters;
- map_action_associations_t m_mapAnalyzerActions;
- set_reporters_t m_setReporters;
+ map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters;
+ vector_actions_and_reporters_t m_vectorActionsAndReporters;
bool m_bOpenGPGCheck;
@@ -83,7 +81,11 @@ class CMiddleWare
const std::string& pUID,
map_crash_report_t& pCrashReport);
- void Report(const std::string& pDebugDumpDir);
+ void RunAction(const std::string& pActionDir,
+ const std::string& pPluginName,
+ const std::string& pPluginArgs);
+ void RunActionsAndReporters(const std::string& pDebugDumpDir);
+
void Report(const map_crash_report_t& pCrashReport);
void DeleteDebugDumpDir(const std::string& pDebugDumpDir);
void DeleteCrashInfo(const std::string& pUUID,
@@ -100,14 +102,11 @@ class CMiddleWare
void SetDatabase(const std::string& pDatabase);
void AddOpenGPGPublicKey(const std::string& pKey);
void AddBlackListedPackage(const std::string& pPackage);
- void AddAnalyzerReporter(const std::string& pAnalyzer,
- const std::string& pReporter,
+ void AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
+ const std::string& pActionOrReporter,
+ const std::string& pArgs);
+ void AddActionOrReporter(const std::string& pActionOrReporter,
const std::string& pArgs);
- void AddAnalyzerAction(const std::string& pAnalyzer,
- const std::string& pAction,
- const std::string& pArgs);
- void AddReporter(const std::string& pReporter,
- const std::string& pArgs);
};
#endif /*MIDDLEWARE_H_*/