mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Exists Event for internal operations
This commit is contained in:
parent
7fa2fccd15
commit
a9f2bb4c11
|
@ -9,6 +9,8 @@ use error::OperationError;
|
||||||
// FIXME: Remove seralising here - each type should
|
// FIXME: Remove seralising here - each type should
|
||||||
// have it's own result type!
|
// have it's own result type!
|
||||||
|
|
||||||
|
// TODO: Every event should have a uuid for logging analysis
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct OpResult {}
|
pub struct OpResult {}
|
||||||
|
|
||||||
|
@ -107,3 +109,22 @@ impl CreateEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ExistsEvent {
|
||||||
|
pub filter: Filter,
|
||||||
|
pub internal: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Message for ExistsEvent {
|
||||||
|
type Result = Result<OpResult, OperationError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExistsEvent {
|
||||||
|
pub fn new_internal(filter: Filter) -> Self {
|
||||||
|
ExistsEvent {
|
||||||
|
filter: filter,
|
||||||
|
internal: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use be::{
|
||||||
|
|
||||||
use entry::Entry;
|
use entry::Entry;
|
||||||
use error::OperationError;
|
use error::OperationError;
|
||||||
use event::{CreateEvent, OpResult, SearchEvent, SearchResult};
|
use event::{CreateEvent, OpResult, SearchEvent, SearchResult, ExistsEvent};
|
||||||
use filter::Filter;
|
use filter::Filter;
|
||||||
use log::EventLog;
|
use log::EventLog;
|
||||||
use plugins::Plugins;
|
use plugins::Plugins;
|
||||||
|
@ -191,12 +191,30 @@ pub trait QueryServerReadTransaction {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialisation of search for exists or not
|
fn exists(&self, au: &mut AuditScope, ee: &ExistsEvent) -> Result<bool, OperationError> {
|
||||||
fn internal_exists(&self, filter: Filter) -> Result<bool, ()> {
|
let mut audit_be = AuditScope::new("backend_exists");
|
||||||
unimplemented!()
|
let res = self
|
||||||
|
.get_be_txn()
|
||||||
|
.exists(&mut audit_be, &ee.filter)
|
||||||
|
.map(|r| r)
|
||||||
|
.map_err(|_| OperationError::Backend);
|
||||||
|
au.append_scope(audit_be);
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_search(&self, filter: Filter) -> Result<(), ()> {
|
// From internal, generate an exists event and dispatch
|
||||||
|
fn internal_exists(&self, au: &mut AuditScope, filter: Filter) -> Result<bool, OperationError> {
|
||||||
|
let mut audit_int = AuditScope::new("internal_exists");
|
||||||
|
// Build an exists event
|
||||||
|
let ee = ExistsEvent::new_internal(filter);
|
||||||
|
// Submit it
|
||||||
|
let res = self.exists(&mut audit_int, &ee);
|
||||||
|
au.append_scope(audit_int);
|
||||||
|
// return result
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
|
fn internal_search(&self, au: &mut AuditScope, filter: Filter) -> Result<(), ()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue