#include <dpl/wrt-dao-ro/plugin_dao_read_only.h>
#include <sstream>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
#include <dpl/foreach.h>
#include <dpl/wrt-dao-ro/webruntime_database.h>
#include <dpl/db/orm.h>
PluginRow getPluginRow(DbPluginHandle pluginHandle)
{
- LogDebug("Getting plugin row. Handle: " << pluginHandle);
+ WrtLogD("Getting plugin row. Handle: %i", pluginHandle);
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
m_pluginHandle(pluginHandle)
{
if (!isPluginInstalled(m_pluginHandle)) {
- LogError("Plugin " << m_pluginHandle << " not installed.");
+ WrtLogE("Plugin %i not installed.", m_pluginHandle);
Throw(PluginDAOReadOnly::Exception::PluginNotExist);
}
-
- checkInstallationCompleted();
}
PluginDAOReadOnly::PluginDAOReadOnly(const std::string &libraryName)
{
- LogDebug("PluginDAOReadOnly ( " << libraryName << " )");
+ WrtLogD("PluginDAOReadOnly ( %s )", libraryName.c_str());
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
ThrowMsg(PluginDAOReadOnly::Exception::PluginNotExist,
"Cannot find plugin: [" + libraryName + "]");
}
- LogDebug(" >> Handle for this plugin: " << m_pluginHandle);
-
- checkInstallationCompleted();
+ WrtLogD(" >> Handle for this plugin: %i", m_pluginHandle);
}
Catch(DPL::DB::SqlConnection::Exception::Base) {
ReThrowMsg(PluginDAOReadOnly::Exception::DatabaseError,
}
}
-void PluginDAOReadOnly::checkInstallationCompleted()
-{
- if (getInstallationStateForHandle(m_pluginHandle)
- != PluginDAOReadOnly::INSTALLATION_COMPLETED)
- {
- LogError("Plugin " << m_pluginHandle << " installation not completed");
- Throw(PluginDAOReadOnly::Exception::PluginInstallationNotCompleted);
- }
-}
-
bool PluginDAOReadOnly::isPluginInstalled(const std::string &libraryName)
{
- LogDebug("Check if Library is installed. LibraryName: " << libraryName);
+ WrtLogD("Check if Library is installed. LibraryName: %s",
+ libraryName.c_str());
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
PluginProperties::Select::RowList rows = select->GetRowList();
bool flag = !rows.empty();
- LogDebug(" >> Plugin " << libraryName <<
+ WrtLogD(" >> Plugin %s %s", libraryName.c_str(),
(flag ? " found." : " not found."));
return flag;
PluginHandleList PluginDAOReadOnly::getPluginHandleList()
{
- LogDebug("Getting plugin handle list.");
+ WrtLogD("Getting plugin handle list.");
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
std::ostringstream handles;
FOREACH(it, ret)
handles << *it << " ";
- LogDebug(" >> PluginHandle list retrieved: (" << handles << ")");
+ WrtLogD(" >> PluginHandle list retrieved: (%s)", handles.str().c_str());
return ret;
}
PluginHandleList PluginDAOReadOnly::getRootPluginHandleList()
{
- LogDebug("Getting root plugin handle list.");
+ WrtLogD("Getting root plugin handle list.");
Try {
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::wrt;
//"value" cannot be null, as in registerPlugin it is always set
#define RETURN_STD_STRING(in, what) \
std::string ret = ""; \
- if (!in.IsNull()) { \
+ if (!!in) { \
ret = DPL::ToUTF8String(*in); } \
- LogDebug(" >> Plugin " << what << ": " << ret); \
+ WrtLogD(" >> Plugin %s: %s", what, ret.c_str()); \
return ret;
std::string PluginDAOReadOnly::getLibraryPath() const
{
- LogDebug("Getting plugin library path. Handle: " << m_pluginHandle);
+ WrtLogD("Getting plugin library path. Handle: %i", m_pluginHandle);
PluginRow row = getPluginRow(m_pluginHandle);
RETURN_STD_STRING(row.Get_PluginLibraryPath(), "library path")
}
std::string PluginDAOReadOnly::getLibraryName() const
{
- LogDebug("Getting plugin library name. Handle: " << m_pluginHandle);
+ WrtLogD("Getting plugin library name. Handle: %i", m_pluginHandle);
PluginRow row = getPluginRow(m_pluginHandle);
std::string ret = DPL::ToUTF8String(row.Get_PluginLibraryName());
- LogDebug(" >> Plugin library name: " << ret);
+ WrtLogD(" >> Plugin library name: %s", ret.c_str());
return ret;
}
}
}
+PluginHandleSetPtr PluginDAOReadOnly::getLibraryDependentPlugins() const
+{
+ Try
+ {
+ using namespace DPL::DB::ORM;
+ using namespace DPL::DB::ORM::wrt;
+ PluginHandleSetPtr dependencies(new PluginHandleSet);
+
+ WRT_DB_SELECT(select, PluginDependencies, &WrtDatabase::interface())
+ select->Where(
+ Equals<PluginDependencies::RequiredPluginPropertiesId>(m_pluginHandle));
+
+ PluginDependencies::Select::RowList rows = select->GetRowList();
+
+ if (!rows.empty()) {
+ FOREACH(it, rows)
+ {
+ dependencies->insert(it->Get_PluginPropertiesId());
+ }
+ }
+
+ return dependencies;
+ }
+ Catch(DPL::DB::SqlConnection::Exception::Base) {
+ ReThrowMsg(PluginDAOReadOnly::Exception::DatabaseError,
+ "Failed in GetLibraryDependencies");
+ }
+}
+
DbPluginHandle PluginDAOReadOnly::getPluginHandleForImplementedObject(
const std::string& objectName)
{
- LogDebug("GetPluginHandle for object: " << objectName);
+ WrtLogD("GetPluginHandle for object: %s", objectName.c_str());
Try
{
if (!rows.empty()) {
pluginHandle = rows.front().Get_PluginPropertiesId();
} else {
- LogWarning("PluginHandle for object not found");
+ WrtLogW("PluginHandle for object not found");
}
return pluginHandle;
}
ImplementedObjectsList PluginDAOReadOnly::getImplementedObjects()
{
- LogDebug("getImplementedObjects");
+ WrtLogD("getImplementedObjects");
Try
{
objectList.push_back(DPL::ToUTF8String(*it));
}
} else {
- LogWarning("PluginHandle for object not found");
+ WrtLogW("PluginHandle for object not found");
}
return objectList;
}
ImplementedObjectsList PluginDAOReadOnly::getImplementedObjectsForPluginHandle(
DbPluginHandle handle)
{
- LogDebug("getImplementedObjects for pluginHandle: " << handle);
+ WrtLogD("getImplementedObjects for pluginHandle: %i", handle);
Try
{
objectList.push_back(DPL::ToUTF8String(it->Get_PluginObject()));
}
} else {
- LogWarning("PluginHandle for object not found");
+ WrtLogW("PluginHandle for object not found");
}
return objectList;
}
if (!rows.empty()) {
return ToState(rows.front().Get_InstallationState());
}
- LogError("Data in DB are invalid. Missing field");
+ WrtLogE("Data in DB are invalid. Missing field");
return UNKNOWN_ERROR;
}
Catch(DPL::DB::SqlConnection::Exception::Base) {
}
}
+std::time_t PluginDAOReadOnly::getLibraryTimestamp() const
+{
+ WrtLogD("Getting plugin library timestamp. Handle: %i", m_pluginHandle);
+ PluginRow row = getPluginRow(m_pluginHandle);
+ std::time_t ret = row.Get_LibraryTimestamp();
+ WrtLogD(" >> Plugin library timestamp: %li", ret);
+ return ret;
+}
+
bool PluginDAOReadOnly::isPluginInstalled(DbPluginHandle pluginHandle)
{
Try {