-
Notifications
You must be signed in to change notification settings - Fork 9
[#1177] Add ProtectedAtomDB #1221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcocapozzoli
wants to merge
15
commits into
master
Choose a base branch
from
masc/1177-atomdb-auth-b
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0394707
WIP
marcocapozzoli 5957630
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli 92e65cc
implement wrap_is_protected()
marcocapozzoli a3be60c
Add tests
marcocapozzoli c9a62f3
add get_backend()
marcocapozzoli 10fa4a1
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli 604ed25
Remove get_backend()
marcocapozzoli 3b0f08e
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli 6a4a105
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli f205cad
move ProtectedAtomDB
marcocapozzoli 5faaf4c
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli 1d069b1
fix BUILD
marcocapozzoli b4c2a49
Add RemoteAtomDB::is_protected()
marcocapozzoli d193e6d
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli ae514ef
Merge branch 'masc/1177-atomdb-auth-a' into masc/1177-atomdb-auth-b
marcocapozzoli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,296 @@ | ||
| #include "ProtectedAtomDB.h" | ||
|
|
||
| #include "Logger.h" | ||
| #include "Utils.h" | ||
|
|
||
| using namespace atomdb; | ||
| using namespace commons; | ||
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Constructors and destructors | ||
|
|
||
| ProtectedAtomDB::ProtectedAtomDB(shared_ptr<AtomDB> backend) : backend(std::move(backend)) { | ||
| if (this->backend == nullptr) { | ||
| RAISE_ERROR("ProtectedAtomDB requires a non-null backend AtomDB"); | ||
| } | ||
| LOG_INFO("ProtectedAtomDB initialized!"); | ||
| } | ||
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Public methods | ||
|
|
||
| shared_ptr<Atom> ProtectedAtomDB::get_atom(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::get_atom(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| shared_ptr<Node> ProtectedAtomDB::get_node(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::get_node(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| shared_ptr<Link> ProtectedAtomDB::get_link(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::get_link(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| vector<shared_ptr<Atom>> ProtectedAtomDB::get_matching_atoms(bool is_toplevel, | ||
| Atom& key, | ||
| const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::get_matching_atoms(..., public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleSet> ProtectedAtomDB::query_for_pattern(const LinkSchema& link_schema, | ||
| const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::query_for_pattern(link_schema, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleList> ProtectedAtomDB::query_for_targets(const string& handle, | ||
| const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::query_for_targets(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleSet> ProtectedAtomDB::query_for_incoming_set( | ||
| const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::query_for_incoming_set(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::atom_exists(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::atom_exists(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::node_exists(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::node_exists(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::link_exists(const string& handle, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::link_exists(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| set<string> ProtectedAtomDB::atoms_exist(const vector<string>& handles, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::atoms_exist(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| set<string> ProtectedAtomDB::nodes_exist(const vector<string>& handles, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::nodes_exist(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| set<string> ProtectedAtomDB::links_exist(const vector<string>& handles, const string& public_key) { | ||
| RAISE_ERROR("ProtectedAtomDB::links_exist(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_atom(const atoms::Atom* atom, | ||
| const string& public_key, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_atom(atom, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_node(const atoms::Node* node, | ||
| const string& public_key, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_node(node, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_link(const atoms::Link* link, | ||
| const string& public_key, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_link(link, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_atoms(const vector<atoms::Atom*>& atom_list, | ||
| const string& public_key, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_atoms(atom_list, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_nodes(const vector<atoms::Node*>& nodes, | ||
| const string& public_key, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_nodes(nodes, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_links(const vector<atoms::Link*>& links, | ||
| const string& public_key, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| RAISE_ERROR("ProtectedAtomDB::add_links(links, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_atom(const string& handle, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_atom(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_node(const string& handle, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_node(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_link(const string& handle, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_link(handle, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_atoms(const vector<string>& handles, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_atoms(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_nodes(const vector<string>& handles, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_nodes(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_links(const vector<string>& handles, | ||
| const string& public_key, | ||
| bool delete_link_targets) { | ||
| RAISE_ERROR("ProtectedAtomDB::delete_links(handles, public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| void ProtectedAtomDB::re_index_patterns(const string& public_key, bool flush_patterns) { | ||
| RAISE_ERROR("ProtectedAtomDB::re_index_patterns(public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| size_t ProtectedAtomDB::node_count(const string& public_key) const { | ||
| RAISE_ERROR("ProtectedAtomDB::node_count(public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| size_t ProtectedAtomDB::link_count(const string& public_key) const { | ||
| RAISE_ERROR("ProtectedAtomDB::link_count(public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| size_t ProtectedAtomDB::atom_count(const string& public_key) const { | ||
| RAISE_ERROR("ProtectedAtomDB::atom_count(public_key) is not implemented yet"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::allow_nested_indexing() { return this->backend->allow_nested_indexing(); } | ||
|
|
||
| bool ProtectedAtomDB::composite_type_enabled() const { return this->backend->composite_type_enabled(); } | ||
|
|
||
| bool ProtectedAtomDB::is_protected() const { return true; } | ||
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Public methods (without public_key - reject the call) | ||
|
|
||
| shared_ptr<Atom> ProtectedAtomDB::get_atom(const string& handle) { | ||
| raise_public_key_required("get_atom"); | ||
| } | ||
|
|
||
| shared_ptr<Node> ProtectedAtomDB::get_node(const string& handle) { | ||
| raise_public_key_required("get_node"); | ||
| } | ||
|
|
||
| shared_ptr<Link> ProtectedAtomDB::get_link(const string& handle) { | ||
| raise_public_key_required("get_link"); | ||
| } | ||
|
|
||
| vector<shared_ptr<Atom>> ProtectedAtomDB::get_matching_atoms(bool is_toplevel, Atom& key) { | ||
| raise_public_key_required("get_matching_atoms"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleSet> ProtectedAtomDB::query_for_pattern( | ||
| const LinkSchema& link_schema) { | ||
| raise_public_key_required("query_for_pattern"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleList> ProtectedAtomDB::query_for_targets(const string& handle) { | ||
| raise_public_key_required("query_for_targets"); | ||
| } | ||
|
|
||
| shared_ptr<atomdb_api_types::HandleSet> ProtectedAtomDB::query_for_incoming_set(const string& handle) { | ||
| raise_public_key_required("query_for_incoming_set"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::atom_exists(const string& handle) { raise_public_key_required("atom_exists"); } | ||
|
|
||
| bool ProtectedAtomDB::node_exists(const string& handle) { raise_public_key_required("node_exists"); } | ||
|
|
||
| bool ProtectedAtomDB::link_exists(const string& handle) { raise_public_key_required("link_exists"); } | ||
|
|
||
| set<string> ProtectedAtomDB::atoms_exist(const vector<string>& handles) { | ||
| raise_public_key_required("atoms_exist"); | ||
| } | ||
|
|
||
| set<string> ProtectedAtomDB::nodes_exist(const vector<string>& handles) { | ||
| raise_public_key_required("nodes_exist"); | ||
| } | ||
|
|
||
| set<string> ProtectedAtomDB::links_exist(const vector<string>& handles) { | ||
| raise_public_key_required("links_exist"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_atom(const atoms::Atom* atom, const atoms::Merger* merger) { | ||
| raise_public_key_required("add_atom"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_node(const atoms::Node* node, const atoms::Merger* merger) { | ||
| raise_public_key_required("add_node"); | ||
| } | ||
|
|
||
| string ProtectedAtomDB::add_link(const atoms::Link* link, const atoms::Merger* merger) { | ||
| raise_public_key_required("add_link"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_atoms(const vector<atoms::Atom*>& atom_list, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| raise_public_key_required("add_atoms"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_nodes(const vector<atoms::Node*>& nodes, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| raise_public_key_required("add_nodes"); | ||
| } | ||
|
|
||
| vector<string> ProtectedAtomDB::add_links(const vector<atoms::Link*>& links, | ||
| bool is_transactional, | ||
| const atoms::Merger* merger) { | ||
| raise_public_key_required("add_links"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_atom(const string& handle, bool delete_link_targets) { | ||
| raise_public_key_required("delete_atom"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_node(const string& handle, bool delete_link_targets) { | ||
| raise_public_key_required("delete_node"); | ||
| } | ||
|
|
||
| bool ProtectedAtomDB::delete_link(const string& handle, bool delete_link_targets) { | ||
| raise_public_key_required("delete_link"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_atoms(const vector<string>& handles, bool delete_link_targets) { | ||
| raise_public_key_required("delete_atoms"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_nodes(const vector<string>& handles, bool delete_link_targets) { | ||
| raise_public_key_required("delete_nodes"); | ||
| } | ||
|
|
||
| uint ProtectedAtomDB::delete_links(const vector<string>& handles, bool delete_link_targets) { | ||
| raise_public_key_required("delete_links"); | ||
| } | ||
|
|
||
| void ProtectedAtomDB::re_index_patterns(bool flush_patterns) { | ||
| raise_public_key_required("re_index_patterns"); | ||
| } | ||
|
|
||
| size_t ProtectedAtomDB::node_count() const { raise_public_key_required("node_count"); } | ||
|
|
||
| size_t ProtectedAtomDB::link_count() const { raise_public_key_required("link_count"); } | ||
|
|
||
| size_t ProtectedAtomDB::atom_count() const { raise_public_key_required("atom_count"); } | ||
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Private methods | ||
|
|
||
| void ProtectedAtomDB::raise_public_key_required(const string& method_name) { | ||
| RAISE_ERROR("ProtectedAtomDB::" + method_name + | ||
| "() is unavailable without a public_key; use the overload that accepts a public_key"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.