Thanks, I think understand it now. I will think of a user case for deleting cache of referenced site entities. At the moment I am playing with entityhub to see what it can de.
By the way, I tried creating all entities from the rdf file available here http://openlylocal.com/councils.rdf (I have downloaded the file into my local disk in the name "councils.rdf") Here is the curl I used: curl -X POST -H "Content-Type: application/rdf+xml" --data "@councils.rdf" http://localhost:8080/entityhub/entity I don't know if it worked (no error messages). Then I tried to retrieve the entity with id/uri http://openlylocal.com/id/councils/180 which is present in the source rdf file. The curl I used is: curl http://localhost:8080/entityhub/entity?id=http://openlylocal.com/id/councils/180 It returns the following "Not Found" error message: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 404 Not Found</title> </head> <body><h2>HTTP ERROR 404</h2> <p>Problem accessing /entityhub/entity. Reason: <pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/> <br/> I don't know what is going here. It may be that the entities have not been created. Any idea what's wrong? Regards Rohana -----Original Message----- From: Rupert Westenthaler [mailto:[email protected]] Sent: 02 August 2011 15:12 To: [email protected] Subject: Re: Delete, Update locally cached entities On Tue, Aug 2, 2011 at 3:07 PM, Rohana Rajapakse <[email protected]> wrote: > Thanks a lot Rupert. > > I am interested in deleting an entity locally cached for a referenced site > too. Aren't they (locally managed entities and referenced site entities > cached locally) stored in the same way (in a Solr/Clerrezza Yard)? Aren't > they treated the same/similar (as symbols) once you store them locally? I > thought they were, because you can work with (referenced entities) off-line > once you have locally cached/stored them. > By directly using the Java API of the Yard it would be possible but via the RESTful interface there is currently no way to delete a locally cached version. The idea behind this is that * entities of the "/entityhub/entity" are considered as locally managed. Therefore you can create/update and delete them. * entities of "/entityhub/site/{siteId}/entity" are considered as governed by this site and therefore read only. However as mentioned in my first replay deleting a locally cached version (e.g. to force the update to a current remote version) is absolutely something that should be supported. If you have a usage scenario that would require a ReferencedSite that also allows full CRUD access please let me know. I would be very interested! If you want to try to directly use the Java API I would suggest to use something like this @Reference org.apache.stanbol.entityhub.servicesapi.yard.YardManager yardManager; @Reference org.apache.stanbol.entityhub.servicesapi.site.ReferencedSiteManager siteManager; //the entity we want to remove from the local cache Siring entityToRemoveTheLocallyCacheVersion = "urn:demo" //1. get the referenced site //a) first possibility to use the ReferencedSiteManager: String siteId = "mySite"; //the site in question ReferencedSite site = siteManager.getReferencedSite(siteId); // b) Second possibility would be to directly inject the Referenced // site or use a ServiceTracker by filtering on the // "org.apache.stanbol.entityhub.site.id" property with the siteId // value //2. get the ID of the Yard used to cache local entities //first check if the site uses a local cache CacheStrategy cacheStrategy = site.getConfiguration().getCacheStrategy if(cacheStrategy == CacheStrategy.none){ throw new IllegalStateException("Site does not use a local Cache!") } //Note that the cacheID is also used as ID for the Yard String yardId = site.getConfiguration().getCacheId(); if(yardId == null) { //this should not be the case if "cacheStrategy != CacheStrategy.none" throw new IllegalStateException("Yard ID of ReferencedSite "+siteId+ " is NULL even that CacheStrategy is set to "+cacheStrategy); } //3. get the Yard with that ID // here again you can use the YardManager or optionally also a // ServiceTracker with a filter on the // "org.apache.stanbol.entityhub.yard.id" property with the value // of yardId Yard localCache = yardManager.getYard(yardId) if(localCache != null={ localCache.remove(entityToRemoveTheLocallyCacheVersion); } //else local cache is currently not available BTW: there is no direct way to get the Yard from the ReferencedSite interface. This is the reason why you need to lookup the Yard via the YardManager. best Rupert Westenthaler > Please point me to any detailed documentation on the web (if any). > > Rohana > > > -----Original Message----- > From: Rupert Westenthaler [mailto:[email protected]] > Sent: 02 August 2011 12:49 > To: [email protected] > Subject: Re: Delete, Update locally cached entities > > On Tue, Aug 2, 2011 at 1:20 PM, Rohana Rajapakse > <[email protected]> wrote: >> Hi, >> >> I was under the impression that the entityhub/entity can be used for >> managing local (cached) entities. I am confused with what this page/endpoint >> http://localhost:8080/entityhub/entity says (page to >> get/create/update/delete Entities Managed by the entity hub). Am I missing >> something here? >> > > Yeas the entityhub/entity endpoint supports full CRUD. I was thinking > you talk about updating an entity locally cached for a referenced site > ... > > Here are some examples for the "entityhub/entity" service endpoint: > > create all entities within the parsed RDF graph > > curl -X POST -H "Content-Type: application/rdf+xml" --data > "@{rdfXmlFile}" http://localhost:8080/entityhub/entity > > Note that Entities are created for all subjects used in triples of the > parsed RDF data. E.g. parsing a RDF file containing a SKOS thesaurus > should create Entities for all skos:Concept's and the > skos:ConcpetScheme. > > If one only want to create a specific Entity (and ignore all other > triples) one needs to specify the ID of the Entity to create as > additional parameter. > > curl -X POST -H "Content-Type: application/rdf+xml" --data > "@{rdfXmlFile}" http://localhost:8080/entityhub/entity?id={entity-uri} > > This will only create the Entity with the id {entity-uri} and ignore > all triples within the parsed {rdfXmlFile} that use an other URI as > subject. > > > > Retrieval works the same as for referenced sites > > curl http://localhost:8080/entityhub/entity?id={entity-uri} > > > > Update works the same way. Only use -X PUT instead of -X POST > > > To delete an Entity use > > curl -X DELETE http://localhost:8080/entityhub/entity?id={entity-id} > > > best > Rupert Westenthaler > >> >> Rohana >> >> -----Original Message----- >> From: Rupert Westenthaler [mailto:[email protected]] >> Sent: 02 August 2011 11:06 >> To: [email protected] >> Subject: Re: Delete, Update locally cached entities >> >> Hi >> >> On Tue, Aug 2, 2011 at 10:42 AM, Rohana Rajapakse >> <[email protected]> wrote: >>> How do you delete/update locally cached entities in Entityhub? Which >>> endpoint(s) can I use? Can someone pass me a sample CURL instructions >>> please. >>> >> ReferencedSites are read only. Via the RESTful interface there is no >> possibility to delete/update entities. >> Currently there is also no possibility to control the behavior of the >> local cache. >> >> The preferred way to provide this feature would be to use the HTTP >> Cache-Control headers [1] as described by [2]. >> This would allow to update the local cache by adding the >> "Cache-Control: max-age=0" to a request. >> >> To support this one would also need to extend the interface of the >> ReferencedSite to allow to parse CacheControl parameters along with >> requests. >> >> If this would solve your issue I can create an JIRA issue for this new >> feature. >> >> best >> Rupert Westenthaler >> >> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 >> [2] >> http://incubator.apache.org/stanbol/docs/trunk/entityhub/entityhubandlinkeddata.html#cache-controlhttpwwww3orgprotocolsrfc2616rfc2616-sec14htmlsec149 >> >>> >>> >>> Thanks >>> >>> >>> >>> Rohana >>> >>> >>> >>> >>> Sign-up for our monthly newsletter www.gossinteractive.com/newsletter >>> >>> Registered Office: c/o Bishop Fleming, Cobourg House, Mayflower Street, >>> Plymouth, PL1 1LG. Company Registration No: 3553908 >>> >>> This email contains proprietary information, some or all of which may be >>> legally privileged. It is for the intended recipient only. If an addressing >>> or transmission error has misdirected this email, please notify the author >>> by replying to this email. If you are not the intended recipient you may >>> not use, disclose, distribute, copy, print or rely on this email. >>> >>> Email transmission cannot be guaranteed to be secure or error free, as >>> information may be intercepted, corrupted, lost, destroyed, arrive late or >>> incomplete or contain viruses. This email and any files attached to it have >>> been checked with virus detection software before transmission. You should >>> nonetheless carry out your own virus check before opening any attachment. >>> GOSS Interactive Ltd accepts no liability for any loss or damage that may >>> be caused by software viruses. >>> >>> wn virus check before opening any attachment. GOSS Interactive Ltd accepts >>> no liability for any loss or damage that may be caused by software viruses. >>> >>> >>> >>> >> >> >> >> -- >> | Rupert Westenthaler [email protected] >> | Bodenlehenstraße 11 ++43-699-11108907 >> | A-5500 Bischofshofen >> > > > > -- > | Rupert Westenthaler [email protected] > | Bodenlehenstraße 11 ++43-699-11108907 > | A-5500 Bischofshofen > > > > > Sign-up for our free client webinar: http://www.gossinteractive.com/webinar > > Registered Office: c/o Bishop Fleming, Cobourg House, Mayflower Street, > Plymouth, PL1 1LG. Company Registration No: 3553908 > > This email contains proprietary information, some or all of which may be > legally privileged. It is for the intended recipient only. If an addressing > or transmission error has misdirected this email, please notify the author by > replying to this email. If you are not the intended recipient you may not > use, disclose, distribute, copy, print or rely on this email. > > Email transmission cannot be guaranteed to be secure or error free, as > information may be intercepted, corrupted, lost, destroyed, arrive late or > incomplete or contain viruses. This email and any files attached to it have > been checked with virus detection software before transmission. You should > nonetheless carry out your own virus check before opening any attachment. > GOSS Interactive Ltd accepts no liability for any loss or damage that may be > caused by software viruses. > > > > -- | Rupert Westenthaler [email protected] | Bodenlehenstraße 11 ++43-699-11108907 | A-5500 Bischofshofen
