Repository: marmotta Updated Branches: refs/heads/develop 60f7c1758 -> 2306e05a3
MARMOTTA-650: added delete context to the js client Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2306e05a Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2306e05a Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2306e05a Branch: refs/heads/develop Commit: 2306e05a3305cfe2aea2305c2a0b32bbb24a7299 Parents: 60f7c17 Author: Sergio Fernández <[email protected]> Authored: Thu Jun 30 10:49:52 2016 +0200 Committer: Sergio Fernández <[email protected]> Committed: Thu Jun 30 10:49:52 2016 +0200 ---------------------------------------------------------------------- .../marmotta-client-js/src/main/js/marmotta.js | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/2306e05a/client/marmotta-client-js/src/main/js/marmotta.js ---------------------------------------------------------------------- diff --git a/client/marmotta-client-js/src/main/js/marmotta.js b/client/marmotta-client-js/src/main/js/marmotta.js index 984b4f3..1508ca6 100644 --- a/client/marmotta-client-js/src/main/js/marmotta.js +++ b/client/marmotta-client-js/src/main/js/marmotta.js @@ -43,6 +43,9 @@ function MarmottaClient(url,opts) { resource : { path : "/resource" }, + context : { + path : "/context" + }, 'import' : { path : "/import" }, @@ -199,6 +202,22 @@ function MarmottaClient(url,opts) { } }; + var contextClient = new ContextClient(options.context); + /** + * This client manages the operations on contexts (graphs) + */ + this.contextClient = { + /** + * Delete context + * @param name/uri of the context ("default" is missing) + * @param onsuccess Function is executed on success. (OPTIONAL) + * @param onfailure Function is executed on failure. It takes a ServerError object.(OPTIONAL) + */ + deleteContext : function(name,onsuccess,onfailure) { + contextClient.deleteContext((typeof name === 'undefined') ? 'default' : name,onsuccess,onfailure); + } + }; + var importClient = new ImportClient(options['import']); /** * TODO: TEST @@ -434,6 +453,21 @@ function MarmottaClient(url,opts) { } /** + * Internal Context Client implementation + * @param options + */ + function ContextClient(options) { + this.deleteContext = function(name,onsuccess,onfailure) { + HTTP.delete(options.path+"/"+name,null,null,{ + 200:function(){if(onsuccess)onsuccess();console.debug("context "+name+" deleted")}, + 400:function(){if(onfailure)onfailure(new ServerError("context "+name+" invalid, cannot delete",400));else throw new Error("context "+name+" invalid, cannot delete")}, + 404:function(){if(onfailure)onfailure(new ServerError("context "+name+" does not exist, cannot delete",404));else throw new Error("context "+name+" does not exist, cannot delete")}, + "default":function(){if(onfailure)onfailure(new ServerError("unknown error"));else throw new Error("unknown error")} + }); + }; + } + + /** * Internal Configuration Client implementation * @param options */
