MojErr MojDbMultiExtractor::fromObject(const MojObject& obj, const MojChar* locale) { LOG_TRACE("Entering function %s", __FUNCTION__); MojErr err = MojDbExtractor::fromObject(obj, locale); MojErrCheck(err); // load the default config MojDbPropExtractor defaultExtractor; err = defaultExtractor.fromObject(obj, locale); MojErrCheck(err); MojObject include; err = obj.getRequired(IncludeKey, include); MojErrCheck(err); for (MojObject::ConstArrayIterator i = include.arrayBegin(); i != include.arrayEnd(); ++i) { MojString includeName; err = i->stringValue(includeName); MojErrCheck(err); MojRefCountedPtr<MojDbPropExtractor> propExtractor(new MojDbPropExtractor); MojAllocCheck(propExtractor.get()); err = propExtractor->fromObjectImpl(*i, defaultExtractor, locale); MojErrCheck(err); err = m_extractors.push(propExtractor); MojErrCheck(err); } return MojErrNone; }
MojErr MojDbKind::configure(const MojObject& obj, const KindMap& map, const MojString& locale, MojDbReq& req) { MojLogTrace(s_log); // get owner before checking permissions MojString owner; MojErr err = obj.getRequired(OwnerKey, owner); MojErrCheck(err); // only admin can change owner if (!m_owner.empty() && m_owner != owner && !req.admin()) { err = deny(req); MojErrCheck(err); } m_owner = owner; err = checkPermission(OpKindUpdate, req); MojErrCheck(err); // schema MojObject schema; if (obj.get(SchemaKey,schema)) { err = m_schema.fromObject(schema); MojErrCheck(err); } // supers StringVec superIds; MojObject supers; if (obj.get(ExtendsKey, supers)) { MojObject::ConstArrayIterator end = supers.arrayEnd(); for (MojObject::ConstArrayIterator i = supers.arrayBegin(); i != end; ++i) { MojString str; err = i->stringValue(str); MojErrCheck(err); err = superIds.push(str); MojErrCheck(err); } } // backup bool backup = false; if (obj.get(SyncKey, backup)) m_backup = backup; bool updating = !m_obj.undefined(); // load state m_state.reset(new MojDbKindState(m_id, m_kindEngine)); MojAllocCheck(m_state.get()); err = m_state->init(m_schema.strings(), req); MojErrCheck(err); // indexes err = configureIndexes(obj, locale, req); MojErrCheck(err); // supers err = updateSupers(map, superIds, updating, req); MojErrCheck(err); // revision sets err = configureRevSets(obj); MojErrCheck(err); // keep a copy of obj m_obj = obj; return MojErrNone; }