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/08/01 12:01:26 UTC

CORS for rules endpoint

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 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