diff options
author | Siegfried-Angel Gevatter Pujals <siegfried.gevatter@collabora.co.uk> | 2012-09-25 16:36:24 +0200 |
---|---|---|
committer | Siegfried-Angel Gevatter Pujals <siegfried.gevatter@collabora.co.uk> | 2012-09-25 16:36:24 +0200 |
commit | e8ac4b2860bdb935516972605177e847c5cb8712 (patch) | |
tree | 714202edb805e2bae2ebcfa55757e48573ff3801 /src | |
parent | d2e179479d4af080022f0fe45454b2af9feae894 (diff) | |
download | zeitgeist-e8ac4b2860bdb935516972605177e847c5cb8712.tar.gz |
Require event interp/manif/actor and subject uri
Those fields are essential event information. If they are missing, the
event is considered invalid and rejected.
This commit also adds some test cases for those cases.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.vala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/engine.vala b/src/engine.vala index e9cd4b75..026c530c 100644 --- a/src/engine.vala +++ b/src/engine.vala @@ -97,11 +97,26 @@ public class Engine : DbReader private void preprocess_event (Event event) throws EngineError { + if (is_empty_string (event.interpretation) + || is_empty_string (event.manifestation) + || is_empty_string (event.actor)) + { + throw new EngineError.INVALID_ARGUMENT ( + "Incomplete event: interpretation, manifestation and actor " + + "are required"); + } + // Iterate through subjects and check for validity - for (int i = 0; i < event.num_subjects(); ++i) + for (int i = 0; i < event.num_subjects (); ++i) { unowned Subject subject = event.subjects[i]; + if (is_empty_string (subject.uri)) + { + throw new EngineError.INVALID_ARGUMENT ( + "Incomplete event: subject without URI"); + } + // If current_uri is unset, give it the same value as URI if (is_empty_string (subject.current_uri)) subject.current_uri = subject.uri; |