You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Melanie Reiplinger <me...@dfki.de> on 2012/07/09 22:51:12 UTC
rules endpoint
Hi all.
Here I go again: this time it's the /rules endpoint, and I'm having a
few questions on that (as usual).
1) (just a minor issue)
The RESTful docu is a bit confusing here, since it states as endpoints
<stanbol>/rule
<stanbol>/recipe
<stanbol>/refactor
<stanbol>/refactor/apply
In the apache docu it's
<stanbol>/rules/store
<stanbol>/rules/recipe
<stanbol>/rules/refactor
<stanbol>/rules/refactor/apply
2)
Also, in the RESTful docu all examples name "http://localhost:8080" as
<stanbol>. I guess this means that I have to set my stanbol home
somewhere in the configuration ? ( I haven't found the right place as
yet ).
3)
To find something to start with, I tried to create a recipe, which is "a
container *[...]***, which identifies a set of rules that share the same
business logic and interpret them as a whole." [1]
So, when stating
curl -i -X POST -d recipe="r1" -d description="A test recipe."
http://<stanbol>/rules/recipe
I get as response:
HTTP/1.1 405 Method Not Allowed
Allow: GET,OPTIONS,HEAD
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1395
Server: Jetty(6.1.x)
Am I doing it the wrong way, or do I need the methods POST (and DELETE)
to be allowed from server-side ?
Thank you,
melanie
[1] http://incubator.apache.org/stanbol/docs/trunk/rules.html
Re: rules endpoint refactoring
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie, sorry for the delay but I've been sick today.
On 8/22/12 12:47 PM, Melanie Reiplinger wrote:
> Thank you a lot, for me this seems to work. I get e.g.
>
> [...]
> and also for the SPARQLObject it works:
>
> {"recipe":"<http:\/\/www.dfki.de\/mere01\/recipe\/r1>","adaptedTo":"org.apache.stanbol.rules.base.api.SPARQLObject","result":"[org.apache.stanbol.rules.adapters.sparql.SPARQLQuery@1648c53]"}
>
>
> but not for the other two classes, there it logs
> ClassNotFoundExceptions, just as for you.
I checked it back. Those two classes work for me too. I know the output
for the SPARQLObject type is not very significant for the REST API, but
I guess that's because adapters are mainly used for the Java API.
I'm just guessing, but probably those two types are working because the
classes belong to packages exported by dependencies of the
org.apache.stanbol.rules.web bundle. Whereas Rules and ConstructQuery
are contributed by plugins that are not dependencies. Perhaps a solution
would be to do the Class.forName() trick from within the adapter manager.
> But anyway, thanks for letting me know, that already helped me. Now I
> just need CORS access. Do you think it makes sense for me to try that
> on my own by changing my version of the server according to the
> samples of endpoints where CORS already works? In principle, most of
> it seems to be about calling the addCORS and enableCORS methods in the
> right places, so maybe I'll try that once I'm done with the cmsadapter.
That's right. I can see the addCORSOrigin() call is there for the
adapter methods though. It's not working for you? Perhaps then there
should be OPTIONS preflight methods - with the enableCORSOrigin() call
- for /adapters and /adapters/{recipe} ... but should they? There are
only GET methods there.
If you would like to try it out and test it, please feel free to post a
patch to STANBOL-712 <https://issues.apache.org/jira/browse/STANBOL-712>
. Thanks a lot!
Alessandro
> Am 20.08.2012 11:59, schrieb Alessandro Adamou:
>> Sorry, this message slipped over.
>>
>> On 8/8/12 3:28 PM, Melanie Reiplinger wrote:
>>> is there any reference for the
>>> rules/adapters
>>> ( and rules/adapters/recipe)
>>> ?
>>
>> I'm afraid I don't know much about them because they're the newest
>> addition to the rules API as far as I know.
>>
>> But from the code I see, the RESTful API should be handled like this
>> (in GET methods)
>>
>> curl [-X GET]
>> http://[stanbol]/rules/adapters/{recipeID}?format={returnType}
>>
>> The adapted recipe should be wrapped in a JSON object with the fields
>> - "recipe" (the original recipe)
>> - "adaptedTo" (the format)
>> - "result" (the content)
>>
>> "returnType" is the canonical name of the Java class. From what I can
>> see the supported types should be:
>>
>> * com.hp.hpl.jena.reasoner.rulesys.Rule
>> * org.apache.clerezza.rdf.core.sparql.query.ConstructQuery
>> * org.apache.stanbol.rules.base.api.SPARQLObject
>> * org.semanticweb.owlapi.model.SWRLRule
>>
>> However this isn't working for me, since every time I tried these
>> classes, a java.lang.ClassNotFoundException was logged on a
>> class.forName() method call.
>>
>> Either the classes cannot be found because they are registered with
>> the classloaders of other OSGi bundles, and the rules.web bundle
>> doesn't have them in its classloader, or I am doing something wrong.
>> Hope someone behind this feature knows better.
>>
>> Sorry for not being of so much help here.
>>
>> Best
>> -- Alessandro
>>
>>
>>> Am 06.08.2012 17:33, schrieb Alessandro Adamou:
>>>> On 8/6/12 10:10 AM, Melanie Reiplinger wrote:
>>>>>> Do not use "application/turtle" for Turtle Syntax. Either use
>>>>>> "text/turtle" (normative MIME type) or "application/x-turtle"
>>>>>> (pre-registration MIME type). For the latter you should svn
>>>>>> update and reinstall rules/web now (I also added some additional
>>>>>> CORS support for that endpoint and fixed some wrong media type
>>>>>> headers).
>>>>>
>>>>> for which paths was it that you added the CORS support?
>>>>
>>>> /refactor/apply and /refactor/applyfile, but neither has PUT or
>>>> DELETE methods so perhaps it was not necessary.
>>>>
>>>> Alessandro
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint refactoring
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro.
Thank you a lot, for me this seems to work. I get e.g.
curl -i -X GET
http://[stanbol]/rules/adapters/http://www.dfki.de/mere01/recipe/r1?format=org.semanticweb.owlapi.model.SWRLRule
HTTP/1.1 200 OK
Content-Type: application/rdf+json
Transfer-Encoding: chunked
Server: Jetty(6.1.x)
{"recipe":"<http:\/\/www.dfki.de\/mere01\/recipe\/r1>",
"adaptedTo":"org.semanticweb.owlapi.model.SWRLRule",
"result":"[DLSafeRule(
Body(
ObjectPropertyAtom(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/r>
Variable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/x>)
Variable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/z>)
)
ObjectPropertyAtom(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/r>
Variable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/z>)
Variable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/y>)
)
)
Head(
ObjectPropertyAtom(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/r>
Variable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/x>)
ariable(<http:\/\/incubator.apache.org\/stanbol\/rules\/variables\/y>)
)
)
)]"}
and also for the SPARQLObject it works:
curl -i -X GET
http://lnv-89012.dfki.uni-sb.de:9001/rules/adapters/http://www.dfki.de/mere01/recipe/r1?format=org.apache.stanbol.rules.base.api.SPARQLObject
HTTP/1.1 200 OK
Content-Type: application/rdf+json
Transfer-Encoding: chunked
Server: Jetty(6.1.x)
{"recipe":"<http:\/\/www.dfki.de\/mere01\/recipe\/r1>","adaptedTo":"org.apache.stanbol.rules.base.api.SPARQLObject","result":"[org.apache.stanbol.rules.adapters.sparql.SPARQLQuery@1648c53]"}
but not for the other two classes, there it logs
ClassNotFoundExceptions, just as for you. But anyway, thanks for letting
me know, that already helped me. Now I just need CORS access. Do you
think it makes sense for me to try that on my own by changing my version
of the server according to the samples of endpoints where CORS already
works? In principle, most of it seems to be about calling the addCORS
and enableCORS methods in the right places, so maybe I'll try that once
I'm done with the cmsadapter.
Best,
Melanie
Am 20.08.2012 11:59, schrieb Alessandro Adamou:
> Sorry, this message slipped over.
>
> On 8/8/12 3:28 PM, Melanie Reiplinger wrote:
>> is there any reference for the
>> rules/adapters
>> ( and rules/adapters/recipe)
>> ?
>
> I'm afraid I don't know much about them because they're the newest
> addition to the rules API as far as I know.
>
> But from the code I see, the RESTful API should be handled like this
> (in GET methods)
>
> curl [-X GET]
> http://[stanbol]/rules/adapters/{recipeID}?format={returnType}
>
> The adapted recipe should be wrapped in a JSON object with the fields
> - "recipe" (the original recipe)
> - "adaptedTo" (the format)
> - "result" (the content)
>
> "returnType" is the canonical name of the Java class. From what I can
> see the supported types should be:
>
> * com.hp.hpl.jena.reasoner.rulesys.Rule
> * org.apache.clerezza.rdf.core.sparql.query.ConstructQuery
> * org.apache.stanbol.rules.base.api.SPARQLObject
> * org.semanticweb.owlapi.model.SWRLRule
>
> However this isn't working for me, since every time I tried these
> classes, a java.lang.ClassNotFoundException was logged on a
> class.forName() method call.
>
> Either the classes cannot be found because they are registered with
> the classloaders of other OSGi bundles, and the rules.web bundle
> doesn't have them in its classloader, or I am doing something wrong.
> Hope someone behind this feature knows better.
>
> Sorry for not being of so much help here.
>
> Best
> -- Alessandro
>
>
>> Am 06.08.2012 17:33, schrieb Alessandro Adamou:
>>> On 8/6/12 10:10 AM, Melanie Reiplinger wrote:
>>>>> Do not use "application/turtle" for Turtle Syntax. Either use
>>>>> "text/turtle" (normative MIME type) or "application/x-turtle"
>>>>> (pre-registration MIME type). For the latter you should svn update
>>>>> and reinstall rules/web now (I also added some additional CORS
>>>>> support for that endpoint and fixed some wrong media type headers).
>>>>
>>>> for which paths was it that you added the CORS support?
>>>
>>> /refactor/apply and /refactor/applyfile, but neither has PUT or
>>> DELETE methods so perhaps it was not necessary.
>>>
>>> Alessandro
>>>
>>>
>>
>>
>
>
Re: rules endpoint refactoring
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Sorry, this message slipped over.
On 8/8/12 3:28 PM, Melanie Reiplinger wrote:
> is there any reference for the
> rules/adapters
> ( and rules/adapters/recipe)
> ?
I'm afraid I don't know much about them because they're the newest
addition to the rules API as far as I know.
But from the code I see, the RESTful API should be handled like this (in
GET methods)
curl [-X GET] http://[stanbol]/rules/adapters/{recipeID}?format={returnType}
The adapted recipe should be wrapped in a JSON object with the fields
- "recipe" (the original recipe)
- "adaptedTo" (the format)
- "result" (the content)
"returnType" is the canonical name of the Java class. From what I can
see the supported types should be:
* com.hp.hpl.jena.reasoner.rulesys.Rule
* org.apache.clerezza.rdf.core.sparql.query.ConstructQuery
* org.apache.stanbol.rules.base.api.SPARQLObject
* org.semanticweb.owlapi.model.SWRLRule
However this isn't working for me, since every time I tried these
classes, a java.lang.ClassNotFoundException was logged on a
class.forName() method call.
Either the classes cannot be found because they are registered with the
classloaders of other OSGi bundles, and the rules.web bundle doesn't
have them in its classloader, or I am doing something wrong. Hope
someone behind this feature knows better.
Sorry for not being of so much help here.
Best
-- Alessandro
> Am 06.08.2012 17:33, schrieb Alessandro Adamou:
>> On 8/6/12 10:10 AM, Melanie Reiplinger wrote:
>>>> Do not use "application/turtle" for Turtle Syntax. Either use
>>>> "text/turtle" (normative MIME type) or "application/x-turtle"
>>>> (pre-registration MIME type). For the latter you should svn update
>>>> and reinstall rules/web now (I also added some additional CORS
>>>> support for that endpoint and fixed some wrong media type headers).
>>>
>>> for which paths was it that you added the CORS support?
>>
>> /refactor/apply and /refactor/applyfile, but neither has PUT or
>> DELETE methods so perhaps it was not necessary.
>>
>> Alessandro
>>
>>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint refactoring
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi again,
is there any reference for the
rules/adapters
( and rules/adapters/recipe)
?
Am 06.08.2012 17:33, schrieb Alessandro Adamou:
> On 8/6/12 10:10 AM, Melanie Reiplinger wrote:
>>> Do not use "application/turtle" for Turtle Syntax. Either use
>>> "text/turtle" (normative MIME type) or "application/x-turtle"
>>> (pre-registration MIME type). For the latter you should svn update
>>> and reinstall rules/web now (I also added some additional CORS
>>> support for that endpoint and fixed some wrong media type headers).
>>
>> for which paths was it that you added the CORS support?
>
> /refactor/apply and /refactor/applyfile, but neither has PUT or DELETE
> methods so perhaps it was not necessary.
>
> Alessandro
>
>
Re: rules endpoint refactoring
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
On 8/6/12 10:10 AM, Melanie Reiplinger wrote:
>> Do not use "application/turtle" for Turtle Syntax. Either use
>> "text/turtle" (normative MIME type) or "application/x-turtle"
>> (pre-registration MIME type). For the latter you should svn update
>> and reinstall rules/web now (I also added some additional CORS
>> support for that endpoint and fixed some wrong media type headers).
>
> for which paths was it that you added the CORS support?
/refactor/apply and /refactor/applyfile, but neither has PUT or DELETE
methods so perhaps it was not necessary.
Alessandro
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint refactoring
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro,
Am 02.08.2012 12:02, schrieb Alessandro Adamou:
> Hi Melanie,
>
> On 8/2/12 10:38 AM, Melanie Reiplinger wrote:
>> curl -X POST -H "Content-Type: multipart/form-data" -H "Accept:
>> application/turtle" -F recipe="is(http://dbpedia.org/ontology/Person,
>> ?x) -> is(http://rdf.data-vocabulary.org/Person, ?x)" -F
>> input=@personsRDF.xml
>> http://lnv-89012.dfki.uni-sb.de:9001/refactor/apply
>>
>> For this, I get HTTP ERROR 406 Problem accessing /refactor/apply.
>> Reason: Not Acceptable.
>
> Do not use "application/turtle" for Turtle Syntax. Either use
> "text/turtle" (normative MIME type) or "application/x-turtle"
> (pre-registration MIME type). For the latter you should svn update and
> reinstall rules/web now (I also added some additional CORS support for
> that endpoint and fixed some wrong media type headers).
for which paths was it that you added the CORS support?
thanks
melanie
Re: rules endpoint refactoring
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie,
On 8/2/12 10:38 AM, Melanie Reiplinger wrote:
> curl -X POST -H "Content-Type: multipart/form-data" -H "Accept:
> application/turtle" -F recipe="is(http://dbpedia.org/ontology/Person,
> ?x) -> is(http://rdf.data-vocabulary.org/Person, ?x)" -F
> input=@personsRDF.xml http://lnv-89012.dfki.uni-sb.de:9001/refactor/apply
>
> For this, I get HTTP ERROR 406 Problem accessing /refactor/apply.
> Reason: Not Acceptable.
Do not use "application/turtle" for Turtle Syntax. Either use
"text/turtle" (normative MIME type) or "application/x-turtle"
(pre-registration MIME type). For the latter you should svn update and
reinstall rules/web now (I also added some additional CORS support for
that endpoint and fixed some wrong media type headers).
Also, do not forget that 1) full IRIs must be enclosed in <>, and the
rules must be named and enclosed in square brackets, e.g.
personTypes[is(<http://dbpedia.org/ontology/Person>, ?x) ->
is(<http://rdf.data-vocabulary.org/Person>, ?x)]
> curl -X POST -H "Accept: application/rdf+xml" -F input=@personsRDF.xml
> -F
> recipe="http://<stanbol>/rules/recipe/http://www.dfki.de/mere01/recipe/TestRecipe"
> http://<stanbol>/refactor
>
> for an existing recipe with at least one rule in it gives me 'HTTP
> ERROR 404 Problem accessing /refactor/. Reason: Not Found
Perhaps the recipe was not found. You need to use the recipe ID, not the
full URL e.g. "recipe=http://www.dfki.de/mere01/recipe/TestRecipe"
(you can try if simpler recipe IDs work as well)
> Or does it have to be curl -d for /refactor ? (because in one of the
> versions on the RESTful API it is also shown with GET -G -d). But for
> this I also get the Not Found error.
No it doesn't look like there's any methods that accepts URLencoded
forms so I think there's no need for -d .
> Btw: how do I get namespace specification into my recipes? (like the
> google or dbpedia shorthands shown in the tutorial) Do I simply add
> them in the rules body?
At the beginning of the recipe, like this:
dbpont = <http://dbpedia.org/ontology/> .
datavoc = <http://rdf.data-vocabulary.org/> .
personTypes[is(dbpont:Person, ?x) -> is(datavoc:Person, ?x)]
Note that you must not enclose resources in the rule body with "<" ">"
when you use prefixes.
hth
Alessandro
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
rules endpoint refactoring
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi all.
Has someone already used the /refactor and /refactor/apply(file)
services of the rules endpoint?
I tried the curl commands from the hands-on tutorial, none would work
for me. Maybe I'm just making syntax errors here ? (although I already
tried some variants) e.g.:
curl -X POST -H "Content-Type: multipart/form-data" -H "Accept:
application/turtle" -F recipe="is(http://dbpedia.org/ontology/Person,
?x) -> is(http://rdf.data-vocabulary.org/Person, ?x)" -F
input=@personsRDF.xml http://lnv-89012.dfki.uni-sb.de:9001/refactor/apply
For this, I get HTTP ERROR 406 Problem accessing /refactor/apply.
Reason: Not Acceptable.
curl -X POST -H "Accept: application/rdf+xml" -F input=@personsRDF.xml
-F
recipe="http://<stanbol>/rules/recipe/http://www.dfki.de/mere01/recipe/TestRecipe"
http://<stanbol>/refactor
for an existing recipe with at least one rule in it gives me 'HTTP ERROR
404 Problem accessing /refactor/. Reason: Not Found
Or does it have to be curl -d for /refactor ? (because in one of the
versions on the RESTful API it is also shown with GET -G -d). But for
this I also get the Not Found error.
Btw: how do I get namespace specification into my recipes? (like the
google or dbpedia shorthands shown in the tutorial) Do I simply add them
in the rules body?
Thanks,
Melanie
Re: CORS for rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Ok, I opened a 'wish' (https://issues.apache.org/jira/browse/STANBOL-712)
let's see if someone will find the time to grant it :-)
Am 01.08.2012 12:43, schrieb Alessandro Adamou:
> I'm not sure if this is the source of the problem, but the rules
> endpoint seems to be handling CORS preflight only on the root resource
> and not in the subresources. And there are a few GET methods that
> still need to add the CORS origin.
>
> I'm afraid I don't have the time to fix and test it myself, but a
> ticket could be opened in the meantime.
>
> Alessandro
>
>
> On 8/1/12 12:01 PM, Melanie Reiplinger wrote:
>> Hi Alessandro and all,
>>
>>
>> Is CORS access to the rules endpoint granted?
>>
>> When I do e.g. a PUT to
>> http://<stanbol>/rules/recipe/http://www.dfki.de/mere01/recipe/melaniesRecipe
>>
>> in order to create a new recipe
>> "http://www.dfki.de/mere01/recipe/melaniesRecipe",
>> I'm getting a real strange response header:
>>
>> Allow:
>> OPTIONS,POST,GET,DELETE,HEAD,PUT
>>
>> This looks a bit ancient, most of the other endpoints return at least
>>
>> Access-Control-Allow-Origin
>> and
>>
>> 1.
>> Access-Control-Allow-Headers
>> 2.
>> Access-Control-Allow-Methods
>>
>>
>>
>>
>> Best,
>> melanie
>>
>> Am 15.07.2012 13:21, schrieb Melanie Reiplinger:
>>> Hi Alessandro.
>>>
>>> Sorry to bother you again, but I have a few more questions for the
>>> rules endpoint.
>>>
>>> Am 13.07.2012 16:09, schrieb Alessandro Adamou:
>>>> On 7/13/12 3:57 PM, Melanie Reiplinger wrote:
>>>>> Am 13.07.2012 15:33, schrieb Alessandro Adamou:
>>>>>> Here is what worked for me:
>>>>>>
>>>>>> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z,
>>>>>> ?y) -> has(?r, ?x, ?y)]" -F "description=Test rule"
>>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>
>>>>> great, works fine. Now, if I want to get the rule itself, to what
>>>>> URL do I send the GET? I tested
>>>>> <stanbol>/rules/rule/transitivity
>>>>> <stanbol>/rules/transitivity
>>>>> <stanbol>/rule/transitivity
>>>>> <stanbol>/rules/find/rules
>>>>
>>>> The last one with query parameters is correct. Try this:
>>>>
>>>> curl -H "Accept: application/rdf+xml"
>>>> http://[stanbol]/rules/find/rules?name=rans
>>>>
>>>> curl -H "Accept: application/rdf+xml"
>>>> http://[stanbol]/rules/find/rules?description=irst
>>>
>>> hmm, ok, so one could assume that it works analogously for the
>>> rules/find/recipes. But when doing
>>>
>>> curl -H "Accept: text/turtle"
>>> http://<stanbol>/rules/find/recipes?name=r2
>>> or
>>> curl -H "Accept: text/turtle"
>>> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>>>
>>> I get a 404 Not Found.
>>> (for a recipe named 'r2', created by
>>> curl -i -X PUT
>>> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>>> )
>>>
>>> what am I doing wrong?
>>>
>>>
>>> Also: How do we then remove rules from a recipe, if we cannot
>>> address them simply by attaching their URI or name to the endpoint's
>>> URL?
>>>
>>> And one more: For the refactoring functionality I didn't get very
>>> far. First thing I wanted to give some minimal toy RDF graph as an
>>> input and refactor via the RESTful Interface. This gives me the (not
>>> very informative) message:
>>> "The site <stanbol> says: Error".
>>> (in the form of an alert window). This error might be due to
>>> virtually anything. My toy example is
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <rdf:RDF
>>> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>>> xmlns:dbpedia="http://dbpedia.org/property/">
>>> <rdf:Description rdf:about="urn:example:person:ernie">
>>> <dbpedia:Person>Ernie</dbpedia:Person>
>>> <dbpedia:profession>Friend of Bert</dbpedia:profession>
>>> </rdf:Description>
>>> </rdf:RDF>
>>>
>>> and I was hoping for something like an application of the
>>> "peopleProfessionRule" rule or something. (I already checked on
>>> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
>>>
>>> best
>>> melanie
>>>
>>>
>>>>
>>>> You can also ask for:
>>>>
>>>> text/turtle
>>>> text/owl-manchester
>>>> text/owl-functional
>>>> application/owl+xml
>>>> application/rdf+json
>>>>
>>>> Theoretically, it should also support
>>>>
>>>> application/json (JSON-LD)
>>>> text/plain
>>>>
>>>> but I don't see a body writer registered with rule lists so it
>>>> didn't work for me.
>>>>
>>>> Best,
>>>> Alessandro
>>>>
>>>>
>>>>>> To check if it has been stored (and therefore parsed), you can do
>>>>>> a GET on
>>>>>>
>>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>>
>>>>>> requesting text/plain or some KR format such as
>>>>>>
>>>>>> text/turtle
>>>>>> application/rdf+xml
>>>>>> text/owl-manchester
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> Alessandro
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Re: CORS for rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
I'm not sure if this is the source of the problem, but the rules
endpoint seems to be handling CORS preflight only on the root resource
and not in the subresources. And there are a few GET methods that still
need to add the CORS origin.
I'm afraid I don't have the time to fix and test it myself, but a ticket
could be opened in the meantime.
Alessandro
On 8/1/12 12:01 PM, Melanie Reiplinger wrote:
> Hi Alessandro and all,
>
>
> Is CORS access to the rules endpoint granted?
>
> When I do e.g. a PUT to
> http://<stanbol>/rules/recipe/http://www.dfki.de/mere01/recipe/melaniesRecipe
>
> in order to create a new recipe
> "http://www.dfki.de/mere01/recipe/melaniesRecipe",
> I'm getting a real strange response header:
>
> Allow:
> OPTIONS,POST,GET,DELETE,HEAD,PUT
>
> This looks a bit ancient, most of the other endpoints return at least
>
> Access-Control-Allow-Origin
> and
>
> 1.
> Access-Control-Allow-Headers
> 2.
> Access-Control-Allow-Methods
>
>
>
>
> Best,
> melanie
>
> Am 15.07.2012 13:21, schrieb Melanie Reiplinger:
>> Hi Alessandro.
>>
>> Sorry to bother you again, but I have a few more questions for the
>> rules endpoint.
>>
>> Am 13.07.2012 16:09, schrieb Alessandro Adamou:
>>> On 7/13/12 3:57 PM, Melanie Reiplinger wrote:
>>>> Am 13.07.2012 15:33, schrieb Alessandro Adamou:
>>>>> Here is what worked for me:
>>>>>
>>>>> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z,
>>>>> ?y) -> has(?r, ?x, ?y)]" -F "description=Test rule"
>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>
>>>> great, works fine. Now, if I want to get the rule itself, to what
>>>> URL do I send the GET? I tested
>>>> <stanbol>/rules/rule/transitivity
>>>> <stanbol>/rules/transitivity
>>>> <stanbol>/rule/transitivity
>>>> <stanbol>/rules/find/rules
>>>
>>> The last one with query parameters is correct. Try this:
>>>
>>> curl -H "Accept: application/rdf+xml"
>>> http://[stanbol]/rules/find/rules?name=rans
>>>
>>> curl -H "Accept: application/rdf+xml"
>>> http://[stanbol]/rules/find/rules?description=irst
>>
>> hmm, ok, so one could assume that it works analogously for the
>> rules/find/recipes. But when doing
>>
>> curl -H "Accept: text/turtle"
>> http://<stanbol>/rules/find/recipes?name=r2
>> or
>> curl -H "Accept: text/turtle"
>> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>>
>> I get a 404 Not Found.
>> (for a recipe named 'r2', created by
>> curl -i -X PUT
>> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>> )
>>
>> what am I doing wrong?
>>
>>
>> Also: How do we then remove rules from a recipe, if we cannot address
>> them simply by attaching their URI or name to the endpoint's URL?
>>
>> And one more: For the refactoring functionality I didn't get very
>> far. First thing I wanted to give some minimal toy RDF graph as an
>> input and refactor via the RESTful Interface. This gives me the (not
>> very informative) message:
>> "The site <stanbol> says: Error".
>> (in the form of an alert window). This error might be due to
>> virtually anything. My toy example is
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <rdf:RDF
>> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>> xmlns:dbpedia="http://dbpedia.org/property/">
>> <rdf:Description rdf:about="urn:example:person:ernie">
>> <dbpedia:Person>Ernie</dbpedia:Person>
>> <dbpedia:profession>Friend of Bert</dbpedia:profession>
>> </rdf:Description>
>> </rdf:RDF>
>>
>> and I was hoping for something like an application of the
>> "peopleProfessionRule" rule or something. (I already checked on
>> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
>>
>> best
>> melanie
>>
>>
>>>
>>> You can also ask for:
>>>
>>> text/turtle
>>> text/owl-manchester
>>> text/owl-functional
>>> application/owl+xml
>>> application/rdf+json
>>>
>>> Theoretically, it should also support
>>>
>>> application/json (JSON-LD)
>>> text/plain
>>>
>>> but I don't see a body writer registered with rule lists so it
>>> didn't work for me.
>>>
>>> Best,
>>> Alessandro
>>>
>>>
>>>>> To check if it has been stored (and therefore parsed), you can do
>>>>> a GET on
>>>>>
>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>
>>>>> requesting text/plain or some KR format such as
>>>>>
>>>>> text/turtle
>>>>> application/rdf+xml
>>>>> text/owl-manchester
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> Alessandro
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
CORS for rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro and all,
Is CORS access to the rules endpoint granted?
When I do e.g. a PUT to
http://<stanbol>/rules/recipe/http://www.dfki.de/mere01/recipe/melaniesRecipe
in order to create a new recipe
"http://www.dfki.de/mere01/recipe/melaniesRecipe",
I'm getting a real strange response header:
Allow:
OPTIONS,POST,GET,DELETE,HEAD,PUT
This looks a bit ancient, most of the other endpoints return at least
Access-Control-Allow-Origin
and
1.
Access-Control-Allow-Headers
2.
Access-Control-Allow-Methods
Best,
melanie
Am 15.07.2012 13:21, schrieb Melanie Reiplinger:
> Hi Alessandro.
>
> Sorry to bother you again, but I have a few more questions for the
> rules endpoint.
>
> Am 13.07.2012 16:09, schrieb Alessandro Adamou:
>> On 7/13/12 3:57 PM, Melanie Reiplinger wrote:
>>> Am 13.07.2012 15:33, schrieb Alessandro Adamou:
>>>> Here is what worked for me:
>>>>
>>>> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z,
>>>> ?y) -> has(?r, ?x, ?y)]" -F "description=Test rule"
>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>
>>> great, works fine. Now, if I want to get the rule itself, to what
>>> URL do I send the GET? I tested
>>> <stanbol>/rules/rule/transitivity
>>> <stanbol>/rules/transitivity
>>> <stanbol>/rule/transitivity
>>> <stanbol>/rules/find/rules
>>
>> The last one with query parameters is correct. Try this:
>>
>> curl -H "Accept: application/rdf+xml"
>> http://[stanbol]/rules/find/rules?name=rans
>>
>> curl -H "Accept: application/rdf+xml"
>> http://[stanbol]/rules/find/rules?description=irst
>
> hmm, ok, so one could assume that it works analogously for the
> rules/find/recipes. But when doing
>
> curl -H "Accept: text/turtle" http://<stanbol>/rules/find/recipes?name=r2
> or
> curl -H "Accept: text/turtle"
> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>
> I get a 404 Not Found.
> (for a recipe named 'r2', created by
> curl -i -X PUT
> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
> )
>
> what am I doing wrong?
>
>
> Also: How do we then remove rules from a recipe, if we cannot address
> them simply by attaching their URI or name to the endpoint's URL?
>
> And one more: For the refactoring functionality I didn't get very far.
> First thing I wanted to give some minimal toy RDF graph as an input
> and refactor via the RESTful Interface. This gives me the (not very
> informative) message:
> "The site <stanbol> says: Error".
> (in the form of an alert window). This error might be due to virtually
> anything. My toy example is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <rdf:RDF
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:dbpedia="http://dbpedia.org/property/">
> <rdf:Description rdf:about="urn:example:person:ernie">
> <dbpedia:Person>Ernie</dbpedia:Person>
> <dbpedia:profession>Friend of Bert</dbpedia:profession>
> </rdf:Description>
> </rdf:RDF>
>
> and I was hoping for something like an application of the
> "peopleProfessionRule" rule or something. (I already checked on
> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
>
> best
> melanie
>
>
>>
>> You can also ask for:
>>
>> text/turtle
>> text/owl-manchester
>> text/owl-functional
>> application/owl+xml
>> application/rdf+json
>>
>> Theoretically, it should also support
>>
>> application/json (JSON-LD)
>> text/plain
>>
>> but I don't see a body writer registered with rule lists so it didn't
>> work for me.
>>
>> Best,
>> Alessandro
>>
>>
>>>> To check if it has been stored (and therefore parsed), you can do a
>>>> GET on
>>>>
>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>
>>>> requesting text/plain or some KR format such as
>>>>
>>>> text/turtle
>>>> application/rdf+xml
>>>> text/owl-manchester
>>>>
>>>> Hope this helps,
>>>>
>>>> Alessandro
>>>>
>>>
>>>
>>>
>>
>>
>
>
Re: rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie,
On 8/1/12 11:26 AM, Melanie Reiplinger wrote:
> ok so I tried this. I first created a recipe r2 and then uploaded a
> rule by
>
> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y)
> -> has(?r, ?x, ?y)]" -F "description=transitivity"
> http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>
> This works fine, by GET I can see that the rule has been integrated
> into the recipe. Now I try to delete:
>
> curl -i -X DELETE
> http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2?rule=transitivity
>
> and I get '200 OK'. But when checking with GET, the 'transitivity'
> rule is still part of the r2 recipe. Seems it was not deleted.
I haven't dug this as I'm not very rule store savvy, but it might be a
bug in the Clerezza rule store. Maybe you could open a ticket on
https://issues.apache.org/jira/browse/STANBOL ? (be sure to include
Rules in the component field).
> Also, submitting the very same rule twice to this recipe does not
> throw any error.
From what I can see, Rule does not override equals() or hashCode() so
in general if two rules have the same body, they won't be recognized as
equal unless their names are. But I guess you're right, it should at
least return a 409 Conflict if the rule names matched.
>> Did you use an HTML interface somewhere? Seems like the refactor
>> endpoint doesn't have one at the moment. Did you try it through the
>> tutorial in the /rules endpoint?
>
> It doesn't have an interface??? I was trying on the /rules/ RESTful
> interface. You can load an RDF file and then click at 'refactor'. I
> thought that would do the job while only testing the default
> transformation patterns.
Yes that's the "hands-on" form, it's intended for the live tutorial but
I'm sure a 'regular' GUI will be added too at some point. In the
meantime, I guess you can use that form for testing.
What I meant is that literally the "[stanbol]/refactor" endpoint doesn't
have a GUI yet (returns 500 on me), but that's okay because I think that
endpoint should be moved to a sub-endpoint of /rules.
> Sorry, I didn't try that since it requires that I pass a recipe ID
> there, and I don't know by which ID these default rules go. So I'll
> report on that as soon as I have my own recipe to use for transformation.
I think it doesn't have one. It is also possible to refactor by passing
the recipe in the payload without storing it with an ID. I think the
tutorial does exactly that.
HTH
--alessandro
>>>> You can also ask for:
>>>>
>>>> text/turtle
>>>> text/owl-manchester
>>>> text/owl-functional
>>>> application/owl+xml
>>>> application/rdf+json
>>>>
>>>> Theoretically, it should also support
>>>>
>>>> application/json (JSON-LD)
>>>> text/plain
>>>>
>>>> but I don't see a body writer registered with rule lists so it
>>>> didn't work for me.
>>>>
>>>> Best,
>>>> Alessandro
>>>>
>>>>
>>>>>> To check if it has been stored (and therefore parsed), you can do
>>>>>> a GET on
>>>>>>
>>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>>
>>>>>> requesting text/plain or some KR format such as
>>>>>>
>>>>>> text/turtle
>>>>>> application/rdf+xml
>>>>>> text/owl-manchester
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> Alessandro
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro.
Am 16.07.2012 12:18, schrieb Alessandro Adamou:
> On 7/15/12 1:21 PM, Melanie Reiplinger wrote:
>> hmm, ok, so one could assume that it works analogously for the
>> rules/find/recipes. But when doing
>>
>> curl -H "Accept: text/turtle"
>> http://<stanbol>/rules/find/recipes?name=r2
>> or
>> curl -H "Accept: text/turtle"
>> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>>
>> I get a 404 Not Found.
>> (for a recipe named 'r2', created by
>> curl -i -X PUT
>> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
>> )
>>
>> what am I doing wrong?
>
> Nothing, except for assuming (with good reason) that it worked exactly
> the same. The rules/find/recipes resource does not support the "name"
> parameter at present, it only supports "description".
>
> This means that if you want a recipe to be found, it must have been
> created with a comment, such as
>
> curl -i -X PUT
> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2?description=Test%20recipe
>
> (not sure what happens with the URLencoded value for "description",
> though)
>
> then
>
> curl -H "Accept: text/turtle"
> http://lnv-89012.dfki.uni-sb.de:9001/rules/find/recipes?description=est
>
> Sorry for not finding this out earlier and misleading you.
Never mind, I'm here to test these things :-)
Fine, this one works.
>
>> Also: How do we then remove rules from a recipe, if we cannot address
>> them simply by attaching their URI or name to the endpoint's URL?
>
> (again by checking the code) The recipe/rule path is currently in the
> form
>
> /rules/recipe/{recipeId}?rule={ruleId}
>
> and the DELETE works the same way, depending on "rule" having a value
> or not.
>
> It might be better to have something like
>
> /rules/recipe/{recipeId}/{ruleId}
ok so I tried this. I first created a recipe r2 and then uploaded a rule by
curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y)
-> has(?r, ?x, ?y)]" -F "description=transitivity"
http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2
This works fine, by GET I can see that the rule has been integrated into
the recipe. Now I try to delete:
curl -i -X DELETE
http://dev.iks-project.eu:8081/rules/recipe/http://www.dfki.de/mere01/recipe/r2?rule=transitivity
and I get '200 OK'. But when checking with GET, the 'transitivity' rule
is still part of the r2 recipe. Seems it was not deleted. Also,
submitting the very same rule twice to this recipe does not throw any
error.
>
> but before that we should make sure that recipeId allows simple
> non-URI identifiers and refactoring works with non-URIs (which maybe
> now does).
>
>> And one more: For the refactoring functionality I didn't get very
>> far. First thing I wanted to give some minimal toy RDF graph as an
>> input and refactor via the RESTful Interface. This gives me the (not
>> very informative) message:
>> "The site <stanbol> says: Error".
>> (in the form of an alert window). This error might be due to
>> virtually anything. My toy example is
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <rdf:RDF
>> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>> xmlns:dbpedia="http://dbpedia.org/property/">
>> <rdf:Description rdf:about="urn:example:person:ernie">
>> <dbpedia:Person>Ernie</dbpedia:Person>
>> <dbpedia:profession>Friend of Bert</dbpedia:profession>
>> </rdf:Description>
>> </rdf:RDF>
>>
>> and I was hoping for something like an application of the
>> "peopleProfessionRule" rule or something. (I already checked on
>> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
>
> Here you're entering a realm I know even less, so I'm afraid I'm going
> to need some more info.
>
> What does the rule look like? Remember with that RDF there (with
> literal triples / datatype assertions in OWL) the rules must be of the
> form values() instead of has()
ok, I will try to build my own recipe with rules that use the values()
assertion.
>
> Did you use an HTML interface somewhere? Seems like the refactor
> endpoint doesn't have one at the moment. Did you try it through the
> tutorial in the /rules endpoint?
It doesn't have an interface??? I was trying on the /rules/ RESTful
interface. You can load an RDF file and then click at 'refactor'. I
thought that would do the job while only testing the default
transformation patterns.
>
> What response did you get by issuing the equivalent request to
> /refactor via curl?
Sorry, I didn't try that since it requires that I pass a recipe ID
there, and I don't know by which ID these default rules go. So I'll
report on that as soon as I have my own recipe to use for transformation.
Best,
melanie
>
> best
> -- Alessandro
>
>
>>> You can also ask for:
>>>
>>> text/turtle
>>> text/owl-manchester
>>> text/owl-functional
>>> application/owl+xml
>>> application/rdf+json
>>>
>>> Theoretically, it should also support
>>>
>>> application/json (JSON-LD)
>>> text/plain
>>>
>>> but I don't see a body writer registered with rule lists so it
>>> didn't work for me.
>>>
>>> Best,
>>> Alessandro
>>>
>>>
>>>>> To check if it has been stored (and therefore parsed), you can do
>>>>> a GET on
>>>>>
>>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>>
>>>>> requesting text/plain or some KR format such as
>>>>>
>>>>> text/turtle
>>>>> application/rdf+xml
>>>>> text/owl-manchester
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> Alessandro
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>
Re: rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
On 7/15/12 1:21 PM, Melanie Reiplinger wrote:
> hmm, ok, so one could assume that it works analogously for the
> rules/find/recipes. But when doing
>
> curl -H "Accept: text/turtle" http://<stanbol>/rules/find/recipes?name=r2
> or
> curl -H "Accept: text/turtle"
> http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
>
> I get a 404 Not Found.
> (for a recipe named 'r2', created by
> curl -i -X PUT
> http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
> )
>
> what am I doing wrong?
Nothing, except for assuming (with good reason) that it worked exactly
the same. The rules/find/recipes resource does not support the "name"
parameter at present, it only supports "description".
This means that if you want a recipe to be found, it must have been
created with a comment, such as
curl -i -X PUT
http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2?description=Test%20recipe
(not sure what happens with the URLencoded value for "description", though)
then
curl -H "Accept: text/turtle"
http://lnv-89012.dfki.uni-sb.de:9001/rules/find/recipes?description=est
Sorry for not finding this out earlier and misleading you.
> Also: How do we then remove rules from a recipe, if we cannot address
> them simply by attaching their URI or name to the endpoint's URL?
(again by checking the code) The recipe/rule path is currently in the form
/rules/recipe/{recipeId}?rule={ruleId}
and the DELETE works the same way, depending on "rule" having a value or
not.
It might be better to have something like
/rules/recipe/{recipeId}/{ruleId}
but before that we should make sure that recipeId allows simple non-URI
identifiers and refactoring works with non-URIs (which maybe now does).
> And one more: For the refactoring functionality I didn't get very far.
> First thing I wanted to give some minimal toy RDF graph as an input
> and refactor via the RESTful Interface. This gives me the (not very
> informative) message:
> "The site <stanbol> says: Error".
> (in the form of an alert window). This error might be due to virtually
> anything. My toy example is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <rdf:RDF
> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> xmlns:dbpedia="http://dbpedia.org/property/">
> <rdf:Description rdf:about="urn:example:person:ernie">
> <dbpedia:Person>Ernie</dbpedia:Person>
> <dbpedia:profession>Friend of Bert</dbpedia:profession>
> </rdf:Description>
> </rdf:RDF>
>
> and I was hoping for something like an application of the
> "peopleProfessionRule" rule or something. (I already checked on
> http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
Here you're entering a realm I know even less, so I'm afraid I'm going
to need some more info.
What does the rule look like? Remember with that RDF there (with literal
triples / datatype assertions in OWL) the rules must be of the form
values() instead of has()
Did you use an HTML interface somewhere? Seems like the refactor
endpoint doesn't have one at the moment. Did you try it through the
tutorial in the /rules endpoint?
What response did you get by issuing the equivalent request to /refactor
via curl?
best
-- Alessandro
>> You can also ask for:
>>
>> text/turtle
>> text/owl-manchester
>> text/owl-functional
>> application/owl+xml
>> application/rdf+json
>>
>> Theoretically, it should also support
>>
>> application/json (JSON-LD)
>> text/plain
>>
>> but I don't see a body writer registered with rule lists so it didn't
>> work for me.
>>
>> Best,
>> Alessandro
>>
>>
>>>> To check if it has been stored (and therefore parsed), you can do a
>>>> GET on
>>>>
>>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>>
>>>> requesting text/plain or some KR format such as
>>>>
>>>> text/turtle
>>>> application/rdf+xml
>>>> text/owl-manchester
>>>>
>>>> Hope this helps,
>>>>
>>>> Alessandro
>>>>
>>>
>>>
>>>
>>
>>
>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro.
Sorry to bother you again, but I have a few more questions for the rules
endpoint.
Am 13.07.2012 16:09, schrieb Alessandro Adamou:
> On 7/13/12 3:57 PM, Melanie Reiplinger wrote:
>> Am 13.07.2012 15:33, schrieb Alessandro Adamou:
>>> Here is what worked for me:
>>>
>>> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z,
>>> ?y) -> has(?r, ?x, ?y)]" -F "description=Test rule"
>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>
>> great, works fine. Now, if I want to get the rule itself, to what URL
>> do I send the GET? I tested
>> <stanbol>/rules/rule/transitivity
>> <stanbol>/rules/transitivity
>> <stanbol>/rule/transitivity
>> <stanbol>/rules/find/rules
>
> The last one with query parameters is correct. Try this:
>
> curl -H "Accept: application/rdf+xml"
> http://[stanbol]/rules/find/rules?name=rans
>
> curl -H "Accept: application/rdf+xml"
> http://[stanbol]/rules/find/rules?description=irst
hmm, ok, so one could assume that it works analogously for the
rules/find/recipes. But when doing
curl -H "Accept: text/turtle" http://<stanbol>/rules/find/recipes?name=r2
or
curl -H "Accept: text/turtle"
http://<stanbol>/rules/find/recipes?name=http://www.dfki.de/mere01/recipe/r2
I get a 404 Not Found.
(for a recipe named 'r2', created by
curl -i -X PUT
http://lnv-89012.dfki.uni-sb.de:9001/rules/recipe/http://www.dfki.de/mere01/recipe/r2
)
what am I doing wrong?
Also: How do we then remove rules from a recipe, if we cannot address
them simply by attaching their URI or name to the endpoint's URL?
And one more: For the refactoring functionality I didn't get very far.
First thing I wanted to give some minimal toy RDF graph as an input and
refactor via the RESTful Interface. This gives me the (not very
informative) message:
"The site <stanbol> says: Error".
(in the form of an alert window). This error might be due to virtually
anything. My toy example is
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dbpedia="http://dbpedia.org/property/">
<rdf:Description rdf:about="urn:example:person:ernie">
<dbpedia:Person>Ernie</dbpedia:Person>
<dbpedia:profession>Friend of Bert</dbpedia:profession>
</rdf:Description>
</rdf:RDF>
and I was hoping for something like an application of the
"peopleProfessionRule" rule or something. (I already checked on
http://www.w3.org/RDF/Validator/ to make sure it is well-formed).
best
melanie
>
> You can also ask for:
>
> text/turtle
> text/owl-manchester
> text/owl-functional
> application/owl+xml
> application/rdf+json
>
> Theoretically, it should also support
>
> application/json (JSON-LD)
> text/plain
>
> but I don't see a body writer registered with rule lists so it didn't
> work for me.
>
> Best,
> Alessandro
>
>
>>> To check if it has been stored (and therefore parsed), you can do a
>>> GET on
>>>
>>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>>
>>> requesting text/plain or some KR format such as
>>>
>>> text/turtle
>>> application/rdf+xml
>>> text/owl-manchester
>>>
>>> Hope this helps,
>>>
>>> Alessandro
>>>
>>
>>
>>
>
>
Re: rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
On 7/13/12 3:57 PM, Melanie Reiplinger wrote:
> Am 13.07.2012 15:33, schrieb Alessandro Adamou:
>> Here is what worked for me:
>>
>> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y)
>> -> has(?r, ?x, ?y)]" -F "description=Test rule"
>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>
> great, works fine. Now, if I want to get the rule itself, to what URL
> do I send the GET? I tested
> <stanbol>/rules/rule/transitivity
> <stanbol>/rules/transitivity
> <stanbol>/rule/transitivity
> <stanbol>/rules/find/rules
The last one with query parameters is correct. Try this:
curl -H "Accept: application/rdf+xml"
http://[stanbol]/rules/find/rules?name=rans
curl -H "Accept: application/rdf+xml"
http://[stanbol]/rules/find/rules?description=irst
You can also ask for:
text/turtle
text/owl-manchester
text/owl-functional
application/owl+xml
application/rdf+json
Theoretically, it should also support
application/json (JSON-LD)
text/plain
but I don't see a body writer registered with rule lists so it didn't
work for me.
Best,
Alessandro
>> To check if it has been stored (and therefore parsed), you can do a
>> GET on
>>
>> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>>
>> requesting text/plain or some KR format such as
>>
>> text/turtle
>> application/rdf+xml
>> text/owl-manchester
>>
>> Hope this helps,
>>
>> Alessandro
>>
>
>
>
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro.
Am 13.07.2012 15:33, schrieb Alessandro Adamou:
> Hi Melanie,
>
> On 7/13/12 2:51 PM, Melanie Reiplinger wrote:
>> Thank you for your instructions. I was able to create a recipe
>> "http://www.dfki.de/mere01/recipe/r1" via PUT.
>> Now, when trying to upload/create a new rule, I again get the Method
>> not allowed error.
>>
>> curl -i -X POST -F "recipe=http://www.dfki.de/mere01/recipe/r1" -F
>> "description=first_rule" -F
>> "rule=http://www.dfki.de/mere01/rules/R.has_transitive" -F
>> "kres-syntax=has(, ?x, ?z) . has(, ?z, ?y) -> has(, ?x, ?y)"
>> http://<stanbol>/rules/recipe/
>> HTTP/1.1 100 Continue
>>
>> HTTP/1.1 405 Method Not Allowed
>> Allow: GET,OPTIONS,HEAD
>> Content-Type: text/html; charset=iso-8859-1
>> Cache-Control: must-revalidate,no-cache,no-store
>> Content-Length: 1396
>> Server: Jetty(6.1.x)
>>
>> (the same if I send it just to <stanbol>/rules, as it sais in the
>> docu). I guess my request is not correct?
>
> After a quick look at the resource code, it looks like the
> documentation is outdated again.
>
> The recipe ID is now a Path parameter. There's no "kres-syntax"
> parameter anymore, and "rule" is now "rules" and it accommodates the
> rule name and the syntax as well.
>
> Here is what worked for me:
>
> curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y)
> -> has(?r, ?x, ?y)]" -F "description=Test rule"
> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
great, works fine. Now, if I want to get the rule itself, to what URL do
I send the GET? I tested
<stanbol>/rules/rule/transitivity
<stanbol>/rules/transitivity
<stanbol>/rule/transitivity
<stanbol>/rules/find/rules
>
> To check if it has been stored (and therefore parsed), you can do a
> GET on
>
> http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
>
> requesting text/plain or some KR format such as
>
> text/turtle
> application/rdf+xml
> text/owl-manchester
>
> Hope this helps,
>
> Alessandro
>
Re: rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie,
On 7/13/12 2:51 PM, Melanie Reiplinger wrote:
> Thank you for your instructions. I was able to create a recipe
> "http://www.dfki.de/mere01/recipe/r1" via PUT.
> Now, when trying to upload/create a new rule, I again get the Method
> not allowed error.
>
> curl -i -X POST -F "recipe=http://www.dfki.de/mere01/recipe/r1" -F
> "description=first_rule" -F
> "rule=http://www.dfki.de/mere01/rules/R.has_transitive" -F
> "kres-syntax=has(, ?x, ?z) . has(, ?z, ?y) -> has(, ?x, ?y)"
> http://<stanbol>/rules/recipe/
> HTTP/1.1 100 Continue
>
> HTTP/1.1 405 Method Not Allowed
> Allow: GET,OPTIONS,HEAD
> Content-Type: text/html; charset=iso-8859-1
> Cache-Control: must-revalidate,no-cache,no-store
> Content-Length: 1396
> Server: Jetty(6.1.x)
>
> (the same if I send it just to <stanbol>/rules, as it sais in the
> docu). I guess my request is not correct?
After a quick look at the resource code, it looks like the documentation
is outdated again.
The recipe ID is now a Path parameter. There's no "kres-syntax"
parameter anymore, and "rule" is now "rules" and it accommodates the
rule name and the syntax as well.
Here is what worked for me:
curl -X POST -F "rules=transitivity[has(?r, ?x, ?z) . has(?r, ?z, ?y) ->
has(?r, ?x, ?y)]" -F "description=Test rule"
http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
To check if it has been stored (and therefore parsed), you can do a GET on
http://[stanbol]/rules/recipe/http://www.dfki.de/mere01/recipe/r1
requesting text/plain or some KR format such as
text/turtle
application/rdf+xml
text/owl-manchester
Hope this helps,
Alessandro
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice
Re: rules endpoint
Posted by Melanie Reiplinger <me...@dfki.de>.
Hi Alessandro.
Thank you for your instructions. I was able to create a recipe
"http://www.dfki.de/mere01/recipe/r1" via PUT.
Now, when trying to upload/create a new rule, I again get the Method not
allowed error.
curl -i -X POST -F "recipe=http://www.dfki.de/mere01/recipe/r1" -F
"description=first_rule" -F
"rule=http://www.dfki.de/mere01/rules/R.has_transitive" -F
"kres-syntax=has(, ?x, ?z) . has(, ?z, ?y) -> has(, ?x, ?y)"
http://<stanbol>/rules/recipe/
HTTP/1.1 100 Continue
HTTP/1.1 405 Method Not Allowed
Allow: GET,OPTIONS,HEAD
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1396
Server: Jetty(6.1.x)
(the same if I send it just to <stanbol>/rules, as it sais in the docu).
I guess my request is not correct?
>>
>> So, when stating
>>
>> curl -i -X POST -d recipe="r1" -d description="A test recipe."
>> http://<stanbol>/rules/recipe
>>
>> I get as response:
>>
>> HTTP/1.1 405 Method Not Allowed
>> Allow: GET,OPTIONS,HEAD
>> Content-Type: text/html; charset=iso-8859-1
>> Cache-Control: must-revalidate,no-cache,no-store
>> Content-Length: 1395
>> Server: Jetty(6.1.x)
>>
>> Am I doing it the wrong way, or do I need the methods POST (and
>> DELETE) to be allowed from server-side ?
>
> you have to PUT /rules/recipe/r1 and then POST the rules onto that
> resource.
>
> but as I said, there might be problems if you try to refactor an
> ontology afterwards. If so, maybe for the time being you're better off
> using
>
> /rules/recipe/http://www.dfki.de/melanie/recipe/r1
>
> or something like that.
>
> And don't forget that resource expects multipart formdata in the POST
>
> HTH
>
> Alessandro
>
>
Re: rules endpoint
Posted by Alessandro Adamou <ad...@cs.unibo.it>.
Hi Melanie,
I'm groping my way a bit on this endpoint because I'm not as savvy on
the rule manager as on the ontology manager, but I've seen the code
quite a few times.
> 1) (just a minor issue)
> The RESTful docu is a bit confusing here, since it states as endpoints
> <stanbol>/rule
> <stanbol>/recipe
> <stanbol>/refactor
> <stanbol>/refactor/apply
>
> In the apache docu it's
> <stanbol>/rules/store
> <stanbol>/rules/recipe
> <stanbol>/rules/refactor
> <stanbol>/rules/refactor/apply
Looks like they're both outdated, but the Apache site seems more
up-to-date. I can see these endpoints:
/rules/recipe # for storing and organizing rules
/rules/recipe/[ID] # see below
/rules/find/recipes # search by description using SPARQL string matching
/rules/find/rules
/rules/adapters/ # for exporting in other formats such as SWRL and
SPARQL Construct
/rules/adapters/recipe
/refactor # uses a stored recipe. we should move this to /rules/refactor
/refactor/apply # uses a recipe supplied in the request payload
/refactor/applyfile # this is redundant, it's like calling
/refactor/apply on @filename
Theoretically the recipe identifier [ID] can be almost any string.
However, last time I tried refactoring it only worked if ID was an IRI,
such as
[stanbol-host]/rules/recipe/http://dfki.de/rules/recipe/1
Please bear with this, I'm sure it will be fixed if it hasn't been already.
> 2)
> Also, in the RESTful docu all examples name "http://localhost:8080" as
> <stanbol>. I guess this means that I have to set my stanbol home
> somewhere in the configuration ? ( I haven't found the right place as
> yet ).
You don't have to, not this time. It's just that the REST API
documentation uses hardcoded URLs rather that dynamically with
freemarker. Feel free to use your hostname instead.
> 3)
> To find something to start with, I tried to create a recipe, which is
> "a container *[...]***, which identifies a set of rules that share the
> same business logic and interpret them as a whole." [1]
> So, when stating
>
> curl -i -X POST -d recipe="r1" -d description="A test recipe."
> http://<stanbol>/rules/recipe
>
> I get as response:
>
> HTTP/1.1 405 Method Not Allowed
> Allow: GET,OPTIONS,HEAD
> Content-Type: text/html; charset=iso-8859-1
> Cache-Control: must-revalidate,no-cache,no-store
> Content-Length: 1395
> Server: Jetty(6.1.x)
>
> Am I doing it the wrong way, or do I need the methods POST (and
> DELETE) to be allowed from server-side ?
you have to PUT /rules/recipe/r1 and then POST the rules onto that resource.
but as I said, there might be problems if you try to refactor an
ontology afterwards. If so, maybe for the time being you're better off using
/rules/recipe/http://www.dfki.de/melanie/recipe/r1
or something like that.
And don't forget that resource expects multipart formdata in the POST
HTH
Alessandro
--
M.Sc. Alessandro Adamou
Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, 40127 Bologna - Italy
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy
"I will give you everything, just don't demand anything."
(Ettore Petrolini, 1917)
Not sent from my iSnobTechDevice