std::string JsonToString(const Json::Value& val) {
Json::StreamWriterBuilder builder;
+ builder["indentation"] = "";
const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
return Json::writeString(builder, val);
}
std::string name = root["name"].asString();
std::string json_str = JsonToString(root);
- return ActionSchema(pkgid, name, "dd");
+ LOG(DEBUG) << "Parased action for pkgid[ " << pkgid << " ] : " << name;
+ LOG(DEBUG) << json_str;
+
+ return ActionSchema(pkgid, name, json_str);
}
} // namespace parser
.Bind(schema.GetJsonStr()));
auto r = conn_.Exec(q);
if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to insert action schema: " << schema.GetName();
+ LOG(ERROR) << "Failed to insert action schema: " << schema.GetName()
+ << ", error: " << static_cast<const char*>(r);
return false;
}
auto r = conn_.Exec(q);
if (!static_cast<bool>(r)) {
LOG(ERROR) << "Failed to delete action schema from DB: "
- << schema.GetName();
+ << schema.GetName() << ", error: " << static_cast<const char*>(r);
return false;
}
r = conn_.Exec(q);
if (!static_cast<bool>(r)) {
LOG(ERROR) << "Failed to update action schema into DB: "
- << schema.GetName();
+ << schema.GetName() << ", error: " << static_cast<const char*>(r);
return false;
}
.Bind(schema.GetPkgId()));
auto r = conn_.Exec(q);
if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to delete action schema: " << schema.GetName();
+ LOG(ERROR) << "Failed to delete action schema: " << schema.GetName()
+ << ", error: " << static_cast<const char*>(r);
return false;
}
extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(
const char* pkgid, const char* appid, GList* metadata) {
+ LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_INSTALL";
+
std::string root_path = GetActionSchemaFilePath(pkgid);
if (root_path.empty())
return -1;
if (strcmp(md->key, kActionKey) != 0)
continue;
json_file = root_path + md->value;
+ LOG(DEBUG) << "Try parsing json file: " << json_file;
parser::ActionParser parser;
parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
parser.Commit(parser::ActionParser::Operation::Install, schema);
}
+ LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_INSTALL";
return 0;
}
extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(
const char* pkgid, const char* appid, GList* metadata) {
+ LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UPGRADE";
+
std::string root_path = GetActionSchemaFilePath(pkgid);
if (root_path.empty())
return -1;
if (strcmp(md->key, kActionKey) != 0)
continue;
json_file = root_path + md->value;
+ LOG(DEBUG) << "Try parsing json file: " << json_file;
parser::ActionParser parser;
// TODO: remove and install?
parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
parser.Commit(parser::ActionParser::Operation::Update, schema);
}
+
+ LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UPGRADE";
return 0;
}
extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(
const char* pkgid, const char* appid, GList* metadata) {
+ LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
+
std::string root_path = GetActionSchemaFilePath(pkgid);
if (root_path.empty())
return -1;
std::string json_file;
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kActionKey)) {
+ json_file = root_path + md->value;
+ LOG(DEBUG) << "Try parsing json file: " << json_file;
parser::ActionParser parser;
parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
// TODO: uninstall without parsing
break;
}
}
+
+ LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
return 0;
}
extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(
const char* pkgid, const char* appid, GList* metadata) {
// TODO
+ LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_CLEAN";
+ LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_CLEAN";
return 0;
}
extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(
const char* pkgid, const char* appid, GList* metadata) {
// plugin cannot decide that what type undo of current process is
+ LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UNDO";
+ LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UNDO";
return 0;
}