1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
--
-- $Id$
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2012 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
--use DB;
create procedure
DB.DBA.SIMILE_INIT ()
{
if (exists (select 1 from "DB"."DBA"."SYS_USERS" where U_NAME = 'SIMILE'))
return;
DB.DBA.USER_CREATE ('SIMILE', uuid(), vector ('DISABLED', 1, 'LOGIN_QUALIFIER', 'SIMILE'));
}
;
--!AFTER
DB.DBA.SIMILE_INIT ()
;
DB.DBA.VHOST_REMOVE (lpath=>'/bank')
;
DB.DBA.VHOST_DEFINE (lpath=>'/bank', ppath=>'/SOAP/Http/simile', soap_user=>'SIMILE')
;
use SIMILE
;
create procedure simile_iri (in s varchar)
{
return concat ('http://simile.org/piggybank/', s);
}
;
create procedure SIMILE.SIMILE.simile () __SOAP_HTTP 'text/html'
{
declare lines, ppath, path, pars, command, _rdf, _user, graph_iri, iri any;
lines := http_request_header ();
pars := http_param ();
ppath := http_physical_path ();
path := split_and_decode (ppath, 0, '\0\0/');
_user := path[4];
command := trim (ucase (get_keyword ('command', pars, '')));
_rdf := get_keyword ('content', pars, '');
-- dbg_obj_print ('lines ', lines);
-- dbg_obj_print ('ppath ', ppath);
-- dbg_obj_print ('path ', path);
-- dbg_obj_print ('pars ', pars);
-- dbg_obj_print ('command ', command);
-- dbg_obj_print ('_rdf ', _rdf);
if (command = 'UPLOAD')
upload (_rdf, _user);
else if (command = 'CREATE')
create_u (_user, lines);
else if (command = 'REMOVE')
remove_u (_user);
else if (command = 'SAVE')
upload (_rdf, _user);
else if (command = 'PUBLISH')
upload (_rdf, _user);
else if (command = 'PERSIST')
persist (_user);
else
http_request_status ('HTTP/1.1 405 Method Not Allowed');
-- return ret;
}
;
create procedure SIMILE.SIMILE.upload (in _rdf any, in _user varchar)
{
set_user_id ('dba');
DB.DBA.RDF_LOAD_RDFXML (_rdf, simile_iri ('simile'), simile_iri (_user));
}
;
create procedure SIMILE.SIMILE."create_u" (in _user varchar, in lines any)
{
declare _pass any;
_pass := WS.WS.FINDPARAM (lines, 'x-sembank-password-hash:');
if (exists (select 1 from WS.WS.SYS_DAV_USER where U_NAME = _user and pwd_magic_calc (U_NAME, U_PWD, 1) = _pass
and U_ACCOUNT_DISABLED = 0))
http_request_status ('HTTP/1.1 201 Created');
else
http_request_status ('HTTP/1.1 403 Forbidden');
}
;
create procedure SIMILE.SIMILE."remove_u" (in _item varchar)
{
return;
}
;
create procedure SIMILE.SIMILE."persist" (in _obj_uri varchar)
{
return;
}
;
grant execute on simile to public
;
|