MojErr MojDbPermissionTest::testObjectPermissions(MojDb& db) { MojErr err = putPermissions(db); MojTestErrCheck(err); err = checkPermissions(db); MojTestErrCheck(err); err = db.close(); MojTestErrCheck(err); err = db.open(MojDbTestDir); MojTestErrCheck(err); err = checkPermissions(db); MojTestErrCheck(err); return MojErrNone; }
MojErr MojDb::loadImpl(MojObject& obj, MojUInt32 flags, MojDbReq& req) { bool found = false; MojString kindName; MojErr err = obj.get(MojDb::KindKey, kindName, found); MojErrCheck(err); if (!found) MojErrThrow(MojErrDbKindNotSpecified); bool deleted = false; obj.get(MojDb::DelKey, deleted); // when loading objects, if the object is deleted, call delKind/del // otherwise, call putKind, putPermissions or put depending on the kind if (deleted) { MojObject id; if (obj.get(MojDbServiceDefs::IdKey, id)) { if (kindName.startsWith(MojDbKindEngine::KindKindIdPrefix)) { err = delKind(id, found, flags, req); MojErrCheck(err); } else { err = del(id, found, flags, req); MojErrCheck(err); } } } else { if (kindName.startsWith(MojDbKindEngine::KindKindIdPrefix)) { err = putKind(obj, flags, req); MojErrCheck(err); } else if (kindName.startsWith(MojDbKindEngine::PermissionIdPrefix)) { err = putPermissions(&obj, &obj + 1, req); MojErrCatch(err, MojErrDbKindNotRegistered); // kind may not have been backed up MojErrCheck(err); } else { err = putImpl(obj, flags, req, false /*checkSchema*/); MojErrCatch(err, MojErrDbKindNotRegistered); // kind may not have been backed up MojErrCheck(err); } } return MojErrNone; }