本文整理汇总了C++中MojDbReq::admin方法的典型用法代码示例。如果您正苦于以下问题:C++ MojDbReq::admin方法的具体用法?C++ MojDbReq::admin怎么用?C++ MojDbReq::admin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MojDbReq
的用法示例。
在下文中一共展示了MojDbReq::admin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stats
MojErr MojDbQuotaEngine::stats(MojObject& objOut, MojDbReq& req)
{
// check for admin permission
if (!req.admin()) {
MojErrThrow(MojErrDbPermissionDenied);
}
for (QuotaMap::ConstIterator i = m_quotas.begin(); i != m_quotas.end(); ++i) {
MojObject quota;
MojErr err = quota.put(MojDbServiceDefs::SizeKey, i.value()->size());
MojErrCheck(err);
err = quota.put(MojDbServiceDefs::UsedKey, i.value()->usage());
MojErrCheck(err);
err = objOut.put(i.key(), quota);
MojErrCheck(err);
}
return MojErrNone;
}
示例2: put
MojErr MojDbQuotaEngine::put(MojObject& obj, MojDbReq& req, bool putObj)
{
MojLogTrace(s_log);
MojAssertWriteLocked(m_db->schemaLock());
// check for admin permission
if (!req.admin()) {
MojErrThrow(MojErrDbPermissionDenied);
}
// pull params out of object
MojString owner;
MojErr err = obj.getRequired(MojDbServiceDefs::OwnerKey, owner);
MojErrCheck(err);
MojInt64 size = 0;
err = obj.getRequired(MojDbServiceDefs::SizeKey, size);
MojErrCheck(err);
// validate owner
err = validateWildcard(owner, MojErrDbInvalidOwner);
MojErrCheck(err);
// put object
if (putObj) {
MojString id;
err = id.format(_T("_quotas/%s"), owner.data());
MojErrCheck(err);
err = obj.put(MojDb::IdKey, id);
MojErrCheck(err);
err = obj.putString(MojDb::KindKey, MojDbKindEngine::QuotaId);
MojErrCheck(err);
MojDbAdminGuard adminGuard(req);
err = m_db->put(obj, MojDb::FlagForce, req);
MojErrCheck(err);
// defer commit of quota until txn commit
MojRefCountedPtr<MojDbQuotaCommitHandler> handler(new MojDbQuotaCommitHandler(this, owner, size, req.txn()));
MojAllocCheck(handler.get());
} else {
err = commitQuota(owner, size);
MojErrCheck(err);
}
return MojErrNone;
}
示例3: hasOwnerPermission
bool MojDbKind::hasOwnerPermission(MojDbReq& req)
{
return (req.admin() || req.domain() == m_owner);
}
示例4: configure
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;
}