You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by ci...@apache.org on 2011/03/30 15:44:01 UTC

svn commit: r1086954 [7/16] - in /incubator/stanbol/trunk/kres/ontologymanager/store: ./ api/ api/src/ api/src/main/ api/src/main/java/ api/src/main/java/org/ api/src/main/java/org/apache/ api/src/main/java/org/apache/stanbol/ api/src/main/java/org/apa...

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClient.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClient.java?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClient.java (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClient.java Wed Mar 30 13:43:53 2011
@@ -0,0 +1,576 @@
+package org.apache.stanbol.ontologymanager.store.rest.client;
+
+import java.util.List;
+
+import org.apache.stanbol.ontologymanager.store.model.AdministeredOntologies;
+import org.apache.stanbol.ontologymanager.store.model.ClassContext;
+import org.apache.stanbol.ontologymanager.store.model.ClassMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.ClassesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.IndividualContext;
+import org.apache.stanbol.ontologymanager.store.model.IndividualMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.IndividualsForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.PropertyMetaInformation;
+
+public interface RestClient {
+
+    /**
+     * @param PsURL
+     *            URL of the external Persistence Store.
+     */
+    public void setPsURL(String PsURL);
+
+    /**
+     * Interface method for registering an ontology to the persistence store
+     * 
+     * @param ontologyContent
+     *            the ontology itself, encoded as text
+     * @param ontologyURI
+     *            the base URI to be used for the ontology
+     * @param encoding
+     *            the encoding of ontologyContent (e.g. UTF-8), important: not to be mixed up with the output
+     *            style of an ontology (i.e. RDF/XML, OWL, etc.)
+     * @return OntologyMetaInformation: the XSD element contains the "URI" and the "description" of the
+     *         ontology
+     * @throws Exception
+     */
+    public OntologyMetaInformation saveOntology(String ontologyContent, String ontologyURI, String encoding) throws RestClientException;
+
+    /**
+     * Interface method to retrieve a particular ontology
+     * 
+     * @param ontologyPath
+     *            the path of the ontology to be retrieved
+     * @param language
+     *            the language (i.e RDF/XML, OWL, etc.) see particular persistence store implementation (i.e.
+     *            JenaPersistenceStore) for the set of supported languages
+     * @param withInferredAxioms
+     *            connects to the reasoner if true
+     * @return the ontology encoded in the given language
+     * @throws RestClientException
+     */
+    public String retrieveOntology(String ontologyPath, String language, boolean withInferredAxioms) throws RestClientException;
+
+    /**
+     * Interface method to return a list of all registered ontologies
+     * 
+     * @return AdministeredOntologies: List of all registered ontologies (i.e. list of
+     *         OntologyMetaInformation)
+     * @throws RestClientException
+     */
+    public AdministeredOntologies retrieveAdministeredOntologies() throws RestClientException;
+
+    /**
+     * Interface method to return the OntologyMetaInformation element associated with a particular ontology
+     * 
+     * @param ontologyPath
+     *            the path of the ontology
+     * @return OntologyMetaInformation: the XSD element contains the "URI" and the "description" of the
+     *         ontology
+     * @throws RestClientException
+     */
+    public OntologyMetaInformation retrieveOntologyMetaInformation(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to list all of the classes that the ontology contains
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology
+     * @return ClassesForOntology: contains the OntologyMetaInformation of the ontology as well as a list of
+     *         ClassMetaInformation elements. Each ClassMetaInformation element contains the "URI",
+     *         "description", "namespace", "localname" and "href". "href" is the *URL* that the Persistence
+     *         Layer Service assigns to each registered class (e.g. ontologies
+     *         /784360a5-2194-4f4a-8fd6-14f4dbd34262/classes/3f5fa9ff-4 cdc-42c8-8629-f2d7ecdbf16b)
+     * @throws RestClientException
+     */
+    public ClassesForOntology retrieveClassesOfOntology(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to list all of the data type properties that the ontology contains
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology
+     * @return DatatypePropertiesForOntology: contains the OntologyMetaInformation of the ontology as well as
+     *         a list of PropertyMetaInformation elements. Each PropertyMetaInformation element contains the
+     *         "URI", "description", "namespace", "localname" and "href". "href" is the *URL* that the
+     *         Persistence Layer Service assigns to each registered data type property. (e.g.
+     *         ontologies/45514659-c5e8-423e-80a9-e86256eb7b99/
+     *         datatypeProperties/36c453b5-f619-4828-82cb-2414c9749e87)
+     * @throws RestClientException
+     */
+    public DatatypePropertiesForOntology retrieveDatatypePropertiesOfOntology(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to list all of the object properties that the ontology contains
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology
+     * @return ObjectPropertiesForOntology: contains the OntologyMetaInformation of the ontology as well as a
+     *         list of PropertyMetaInformation elements. Each PropertyMetaInformation element contains the
+     *         "URI", "description", "namespace", "localname" and "href". "href" is the *URL* that the
+     *         Persistence Layer Service assigns to each registered object property. (e.g.
+     *         ontologies/45514659-c5e8-423e-80 a9-e86256eb7b99/objectProperties/a2bf8f9a
+     *         -dbb3-4d4d-a7d9-187733ba238c)
+     * @throws RestClientException
+     */
+    public ObjectPropertiesForOntology retrieveObjectPropertiesOfOntology(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to list all of the individuals that the ontology contains
+     * 
+     * @param ontologyPath
+     *            the path of the ontology
+     * @return IndividualsForOntology: contains the OntologyMetaInformation of the ontology as well as a list
+     *         of PropertyMetaInformation elements. Each PropertyMetaInformation element contains the "URI",
+     *         "description", "namespace", "localname" and "href". "href" is the *URL* that the Persistence
+     *         Layer Service assigns to each registered individual. (e.g.
+     *         ontologies/0d541ddc-7afd-4901-a2ff-41d
+     *         cad687efb/individuals/1aefd64c-8700-4f24-b705-9ced6caa6951)
+     * @throws RestClientException
+     */
+    public IndividualsForOntology retrieveIndividualsOfOntology(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to get a Protege-like view of the particular ontology class
+     * 
+     * @param classPath
+     *            the path of the class
+     * @param withInferredAxioms
+     *            connects to the reasoner if true
+     * @return ClassContext: Each ClassContext contains a ClassMetaInformation, the equivalent, super and
+     *         disjoint classes of the class in question and an unbounded array of the constraints on the
+     *         class.
+     * @throws RestClientException
+     */
+    public ClassContext generateClassContext(String classPath, boolean withInferredAxioms) throws RestClientException;
+
+    /**
+     * Interface method to get a Protege-like view of the particular data type property
+     * 
+     * @param datatypePropertyPath
+     *            the Path of the data type property
+     * @param withInferredAxioms
+     *            connects to the reasoner if true
+     * @return DatatypePropertyContext: Each DatatypePropertyContext contains a PropertyMetaInformation, the
+     *         domain and range of the data type property as well as the equivalent and super properties.
+     *         Finally, some attributes of the data type property (i.e. isFunctional) are also conveyed.
+     * @throws RestClientException
+     */
+    public DatatypePropertyContext generateDatatypePropertyContext(String datatypePropertyPath,
+                                                                   boolean withInferredAxioms) throws RestClientException;
+
+    /**
+     * Interface method to get a Protege-like view of the particular object property
+     * 
+     * @param objectPropertyPath
+     *            the Path of the object property
+     * @param withInferredAxioms
+     *            connects to the reasoner if true
+     * @return ObjectPropertyContext: Each ObjectPropertyContext contains a PropertyMetaInformation, the
+     *         domain and range of the object property as well as the equivalent and super properties.
+     *         Finally, some attributes of the object property (i.e. isFunctional, isInverseFunctional,
+     *         isTransitive, isSymmetric) are also conveyed.
+     * @throws RestClientException
+     */
+    public ObjectPropertyContext generateObjectPropertyContext(String objectPropertyPath,
+                                                               boolean withInferredAxioms) throws RestClientException;
+
+    /**
+     * Interface method to get a Protege-like view of the particular individual
+     * 
+     * @param individualPath
+     *            the Path of the individual
+     * @param withInferredAxioms
+     *            connects to the reasoner if true
+     * @return IndividualContext: Each IndividualContext contains an IndividualMetaInformation, the list of
+     *         classes to which this individual belongs (ContainerClasses) and finally, the names and values
+     *         of any properties associated with this individual.
+     * @throws RestClientException
+     */
+    public IndividualContext generateIndividualContext(String individualPath, boolean withInferredAxioms) throws RestClientException;
+
+    /**
+     * Interface method to create a new class for a particular ontology
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology in which the new class will be generated
+     * @param classURI
+     *            the URI to assign to the new class
+     * @return ClassMetaInformation: contains the "URI", "description", "namespace", "localname" and "href".
+     *         "href" is the *URL* that the Persistence Layer Service assigns to the newly registered class
+     *         (e.g. ontologies/784360a5-2194-4f4a-8fd6-14f4dbd34262/classes/3f5f
+     *         a9ff-4cdc-42c8-8629-f2d7ecdbf16b).
+     * @throws RestClientException
+     */
+    public ClassMetaInformation generateClassForOntology(String ontologyPath, String classURI) throws RestClientException;
+
+    /**
+     * Interface method to create a new data type property for a particular ontology
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology in which the new data type property will be generated
+     * @param datatypePropertyURI
+     *            the URI to assign to the new data type property
+     * @return PropertyMetaInformation: contains the "URI", "description", "namespace", "localname" and
+     *         "href". "href" is the *URL* that the Persistence Layer Service assigns to the newly registered
+     *         data type property (e.g. ontologies/45514659-c5e8-423e-80a9-e86256eb7b99
+     *         /datatypeProperties/36c453b5-f619-4828-82cb-2414c9749e87).
+     * @throws RestClientException
+     */
+    public PropertyMetaInformation generateDatatypePropertyForOntology(String ontologyPath,
+                                                                       String datatypePropertyURI) throws RestClientException;
+
+    /**
+     * Interface method to create a new object property for a particular ontology
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology in which the new object property will be generated
+     * @param objectPropertyURI
+     *            the URI to assign to the new object property
+     * @return PropertyMetaInformation: contains the "URI", "description", "namespace", "localname" and
+     *         "href". "href" is the *URL* that the Persistence Layer Service assigns to the newly registered
+     *         object property (e.g. ontologies/45514659-c5e8-423e-80a9-e86256eb7b99/ objectProperties
+     *         /a2bf8f9a-dbb3-4d4d-a7d9-187733ba238c)
+     * @throws RestClientException
+     */
+    public PropertyMetaInformation generateObjectPropertyForOntology(String ontologyPath,
+                                                                     String objectPropertyURI) throws RestClientException;
+
+    /**
+     * Interface method to create a new individual for a particular ontology
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology in which the new individual will be generated
+     * @param classURI
+     *            the URI of the class to which the new individual belongs
+     * @param individualURI
+     *            the URI to assign to the new individual
+     * @return IndividualMetaInformation: contains the "URI", "description", "namespace", "localname" and
+     *         "href". "href" is the *URL* that the Persistence Layer Service assigns to the newly registered
+     *         individual (e.g. ontologies/0d541ddc-7afd-4901-a2ff-41dcad687efb/individuals
+     *         /1aefd64c-8700-4f24-b705-9ced6caa6951)
+     * @throws RestClientException
+     */
+    public IndividualMetaInformation generateIndividualForOntology(String ontologyPath,
+                                                                   String classURI,
+                                                                   String individualURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* a new super-sub class association
+     * 
+     * @param subClassPath
+     *            the Path of the subclass
+     * @param superClassURI
+     *            the URI of the superclass
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void makeSubClassOf(String subClassPath, String superClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a superclass association
+     * 
+     * @param subClassPath
+     *            the Path of the subclass
+     * @param superClassURI
+     *            the URI of the superclass
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteSuperClass(String subClassPath, String superClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* a new equivalent class association
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param equivalentClassURI
+     *            the URI of the class which will be equivalent to the class in context
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addEquivalentClass(String classPath, String equivalentClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a new equivalent class association
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param equivalentClassURI
+     *            the URI of the class which will be deleted from equivalent classes
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteEquivalentClass(String classPath, String equivalentClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* a new disjoint class association
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param equivalentClassURI
+     *            the URI of the class which will be disjoint to the class in context
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addDisjointClass(String classPath, String disjointClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* an existing disjoint class association
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param disjointClassURI
+     *            the URI of the class which will be deleted from disjoint classes
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteDisjointClass(String classPath, String disjointClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* a particular class to union set of another class
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param unionClassURIs
+     *            the URI of the classes to be added to union set
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addUnionClass(String classPath, String unionClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a particular class from the union set of another class
+     * 
+     * @param classPath
+     *            the Path of the class in context
+     * @param unionClassURIs
+     *            the URI of the class to be deleted from union set
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteUnionClass(String classPath, String unionClassURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* a new super-sub property association
+     * 
+     * @param subPropertyPath
+     *            the Path of the subproperty
+     * @param superPropertyURI
+     *            the URI of the superproperty
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void makeSubPropertyOf(String subPropertyPath, String superPropertyURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a super property association
+     * 
+     * @param subPropertyPath
+     *            the Path of the subproperty
+     * @param superPropertyURI
+     *            the URI of the superproperty
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteSuperPropertyAssertion(String subPropertyPath, String superPropertyURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* multiple domains to domain set of a property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param domainURIs
+     *            the URI list of the domain classes
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addDomains(String propertyPath, List<String> domainURIs) throws RestClientException;
+
+    /**
+     * Interface method to *add* a domain to the domain set of an object and data type property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addDomain(String propertyPath, String domainURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a domain from the domain set of an object or data type property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param domainURI
+     *            the URI of the domain class
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteDomain(String propertyPath, String domainURI) throws RestClientException;
+
+    /**
+     * Interface method to *add* multiple ranges to range set of a property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param rangeURIs
+     *            the URI list of the range classes or one of OWL-built in types for data type properties
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addRanges(String propertyPath, List<String> rangeURIs) throws RestClientException;
+
+    /**
+     * Interface method to *add* a range to range set of an object or data type property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param rangeURI
+     *            the URI of the range class or one of OWL-built in types for data type properties
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addRange(String propertyPath, String rangeURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a range from range set of an object or data type property
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param rangeURI
+     *            the URI of the range class or one of OWL-built in types for data type properties
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deleteRange(String propertyPath, String rangeURI) throws RestClientException;
+
+    /**
+     * Interface method to *set* the various property attributes (e.g. isFunctional, isTransitive, etc.)
+     * Please note that some apply to object properties only while some apply to both
+     * 
+     * @param propertyPath
+     *            the Path of the property in context
+     * @param isFunctional
+     *            true/false/null
+     * @param isTransitive
+     *            true/false/null
+     * @param isSymmetric
+     *            true/false/null
+     * @param isInverseFunctional
+     *            true/false/null
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void setPropertyAttributes(String propertyPath,
+                                      Boolean isFunctional,
+                                      Boolean isTransitive,
+                                      Boolean isSymmetric,
+                                      Boolean isInverseFunctional) throws RestClientException;
+
+    /**
+     * Interface method to *set* the property value of a particular individual
+     * 
+     * @param individualPath
+     *            the Path of the individual in context
+     * @param propertyURI
+     *            the URI of the property whose value will be set
+     * @param individualAsValueURI
+     *            a choice between {individualAsValueURI} and {literalAsValue} has to be made: if it is an
+     *            object property {individualAsValueURI} cannot be null
+     * @param literalAsValue
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void assertPropertyValue(String individualPath,
+                                    String propertyURI,
+                                    String individualAsValueURI,
+                                    String literalAsValue) throws RestClientException;
+
+    /**
+     * Interface method to *delete* the property assertion of a particular individual
+     * 
+     * @param individualPath
+     *            the Path of the individual in context
+     * @param propertyURI
+     *            the URI of the property whose assertion will be deleted
+     * @param individualAsValueURI
+     *            a choice between {individualAsValueURI} and {literalAsValue} has to be made: if it is an
+     *            object property {individualAsValueURI} cannot be null
+     * @param literalAsValue
+     *            if it is an datatype property {literalAsValue} cannot be null
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void deletePropertyAssertion(String individualPath,
+                                        String propertyURI,
+                                        String individualAsValueURI,
+                                        String literalAsValue) throws RestClientException;
+
+    /**
+     * Interface method to *add* a class for an individual
+     * 
+     * @param individualPath
+     *            the Path of the individual in context
+     * @param classURI
+     *            the URI of the class in context
+     * @return true if successful (e.g. all required resources exit)
+     * @throws RestClientException
+     */
+    public void addContainerClassForIndividual(String individualPath, String classURI) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a class for an individual
+     * 
+     * @param individualPath
+     *            the Path of the individual in context
+     * @param classURI
+     *            the URI of the class in context
+     * @return true if successful
+     * @throws RestClientException
+     */
+    public void deleteContainerClassForIndividual(String individualPath, String classURI) throws RestClientException;
+
+    /**
+     * Delete any resource on persistence store
+     * 
+     * @param resourcePath
+     *            REST path of the resource
+     * @throws RestClientException
+     */
+    public void deleteResource(String resourcePath) throws RestClientException;
+
+    /**
+     * Interface method to *delete* a particular ontology
+     * 
+     * @param ontologyPath
+     *            the Path of the ontology to delete
+     * @return true if successful (e.g. all required resources exit)
+     */
+    public void deleteOntology(String ontologyPath) throws RestClientException;
+
+    /**
+     * Interface method to *delete* all registered ontologies together with their resources
+     * 
+     * @return true if successful
+     * @throws RestClientException
+     */
+    public void clearPersistenceStore() throws RestClientException;
+
+    /**
+     * Interface method to *merge* resources
+     * 
+     * @param ontologyPath
+     *            the path of the ontology onto which target ontology will be merged
+     * @param targetOntology
+     *            ontology content to be merged
+     * @param targetOntologyBaseURI
+     *            base URI of the target ontology
+     * @throws RestClientException
+     */
+    public String mergeOntology(String ontologyPath, String targetOntology, String targetOntologyBaseURI) throws RestClientException;
+}
\ No newline at end of file

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClientException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClientException.java?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClientException.java (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/RestClientException.java Wed Mar 30 13:43:53 2011
@@ -0,0 +1,19 @@
+package org.apache.stanbol.ontologymanager.store.rest.client;
+
+/**
+ * Class to represent any exception in execution of methods of RestClient
+ * 
+ * @author Cihan
+ */
+public class RestClientException extends Exception {
+
+    /**
+	 * 
+	 */
+    private static final long serialVersionUID = -5713995314670538506L;
+
+    public RestClientException(String message, Throwable throwable) {
+        super(message, throwable);
+    }
+
+}

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/imp/RestClientImp.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/imp/RestClientImp.java?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/imp/RestClientImp.java (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest-client/src/main/java/org/apache/stanbol/ontologymanager/store/rest/client/imp/RestClientImp.java Wed Mar 30 13:43:53 2011
@@ -0,0 +1,709 @@
+package org.apache.stanbol.ontologymanager.store.rest.client.imp;
+
+import java.io.StringReader;
+import java.util.List;
+import java.util.Locale;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.ontologymanager.store.model.AdministeredOntologies;
+import org.apache.stanbol.ontologymanager.store.model.ClassContext;
+import org.apache.stanbol.ontologymanager.store.model.ClassMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.ClassesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.IndividualContext;
+import org.apache.stanbol.ontologymanager.store.model.IndividualMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.IndividualsForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectFactory;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.PropertyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.ResourceMetaInformationType;
+import org.apache.stanbol.ontologymanager.store.rest.client.RestClient;
+import org.apache.stanbol.ontologymanager.store.rest.client.RestClientException;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+
+@Component(immediate = true)
+@Service
+public class RestClientImp implements RestClient {
+    private static final String ONTOLOGIES = "/ontologies/";
+
+    private static final String CLASSES = "/classes/";
+
+    private static final String INDIVIDUALS = "/individuals/";
+
+    private static final String DATATYPE_PROPERTIES = "/datatypeProperties/";
+
+    private static final String OBJECT_PROPERTIES = "/objectProperties/";
+
+    private static final String SUPER_CLASSES = "/superClasses/";
+
+    private static final String EQUIVALENT_CLASSES = "/equivalentClasses/";
+
+    private static final String DISJOINT_CLASSES = "/disjointClasses/";
+
+    private static final String UNION_CLASSES = "/unionClasses/";
+
+    private static final String DOMAINS = "/domains/";
+
+    private static final String RANGES = "/ranges/";
+
+    private static final String SUPER_PROPERTIES = "/superProperties/";
+
+    private static final String TYPES = "/types/";
+
+    private static final String PROPERTY_ASSERTIONS = "/propertyAssertions/";
+
+    private static final String LITERALS = "/literals/";
+
+    private static final String OBJECTS = "/objects/";
+
+    private static final String JAXB_CONTEXT = "org.apache.stanbol.ontologymanager.store.model";
+
+    private static final String APPLICATION_RDF_XML = "application/rdf+xml";
+
+    private static final String WITH_INFERRED_AXIOMS = "withInferredAxioms";
+
+    private static final String DELIMITER = "/";
+
+    private Client client;
+
+    /**
+     * Base URL for Persistence Store RESTful interface.
+     */
+    private String PSAddress;
+
+    public RestClientImp() {
+        this.client = Client.create();
+    }
+
+    private static final String normalizeURI(String uri) {
+        return uri.replaceAll("#", "/");
+    }
+
+    private static Object unmarshall(String content) throws RestClientException {
+        Locale oldLocale = Locale.getDefault();
+        Locale.setDefault(new Locale("en"));
+        try {
+            ClassLoader cl = ObjectFactory.class.getClassLoader();
+            JAXBContext jc = JAXBContext.newInstance(JAXB_CONTEXT, cl);
+            Unmarshaller unmarshaller = jc.createUnmarshaller();
+            Object obj = unmarshaller.unmarshal(new StringReader(content));
+            Locale.setDefault(oldLocale);
+            return obj;
+        } catch (JAXBException ex) {
+            throw new RestClientException("Exception in marshalling", ex);
+        } finally {
+            Locale.setDefault(oldLocale);
+        }
+    }
+
+    @Override
+    public void setPsURL(String PsURL) {
+        PSAddress = PsURL;
+    }
+
+    public RestClientImp getRestClient() {
+        return this;
+    }
+
+    @Override
+    public AdministeredOntologies retrieveAdministeredOntologies() throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + ONTOLOGIES);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            AdministeredOntologies onts = (AdministeredOntologies) unmarshall(content);
+            return onts;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public ClassesForOntology retrieveClassesOfOntology(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI + CLASSES);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            ClassesForOntology classes = (ClassesForOntology) unmarshall(content);
+            return classes;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public DatatypePropertiesForOntology retrieveDatatypePropertiesOfOntology(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI
+                                                      + DATATYPE_PROPERTIES);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            DatatypePropertiesForOntology datatypeProps = (DatatypePropertiesForOntology) unmarshall(content);
+            return datatypeProps;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public IndividualsForOntology retrieveIndividualsOfOntology(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI + INDIVIDUALS);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            IndividualsForOntology onts = (IndividualsForOntology) unmarshall(content);
+            return onts;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public ObjectPropertiesForOntology retrieveObjectPropertiesOfOntology(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client
+                    .resource(PSAddress + DELIMITER + ontologyURI + OBJECT_PROPERTIES);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            ObjectPropertiesForOntology objectProps = (ObjectPropertiesForOntology) unmarshall(content);
+            return objectProps;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public String retrieveOntology(String ontologyURI, String language, boolean withInferredAxioms) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI);
+            String content = webResource.accept(APPLICATION_RDF_XML).get(String.class);
+            return content;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public OntologyMetaInformation retrieveOntologyMetaInformation(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            OntologyMetaInformation ont = (OntologyMetaInformation) unmarshall(content);
+            return ont;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    public ResourceMetaInformationType retrieveResourceWithURI(String resourceURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + resourceURI);
+            String content = webResource.accept(MediaType.APPLICATION_XML).get(String.class);
+            ResourceMetaInformationType resourceInfo = (ResourceMetaInformationType) unmarshall(content);
+            return resourceInfo;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public OntologyMetaInformation saveOntology(String ontologyContent, String ontologyURI, String encoding) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + ONTOLOGIES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("ontologyURI", ontologyURI);
+            formData.add("ontologyContent", ontologyContent);
+            String content = webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                    .accept(MediaType.APPLICATION_XML_TYPE).post(String.class, formData);
+            OntologyMetaInformation resourceInfo = (OntologyMetaInformation) unmarshall(content);
+            return resourceInfo;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void addContainerClassForIndividual(String individualURI, String classURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + individualURI + TYPES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("containerClassURIs", classURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void addDisjointClass(String classURI, String disjointClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + DISJOINT_CLASSES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("disjointClassURIs", disjointClassURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void addDomain(String propertyURI, String domainURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + DOMAINS);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("domainURIs", domainURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void addEquivalentClass(String classURI, String equivalentClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + EQUIVALENT_CLASSES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("equivalentClassURIs", equivalentClassURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void addRange(String propertyURI, String rangeURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + RANGES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("rangeURIs", rangeURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void addUnionClass(String classURI, String unionClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + UNION_CLASSES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("unionClassURIs", unionClassURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void assertPropertyValue(String individualURI,
+                                    String propertyURI,
+                                    String individualAsValueURI,
+                                    String literalAsValue) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + individualURI
+                                                      + PROPERTY_ASSERTIONS + normalizeURI(propertyURI));
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("literalValues", literalAsValue);
+            formData.add("objectValues", individualAsValueURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void clearPersistenceStore() throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + ONTOLOGIES);
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteContainerClassForIndividual(String individualURI, String classURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + individualURI + TYPES
+                                                      + normalizeURI(classURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteDisjointClass(String classURI, String disjointClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + DISJOINT_CLASSES
+                                                      + normalizeURI(disjointClassURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void deleteDomain(String propertyURI, String domainURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + DOMAINS
+                                                      + normalizeURI(domainURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteEquivalentClass(String classURI, String equivalentClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + EQUIVALENT_CLASSES
+                                                      + normalizeURI(equivalentClassURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteOntology(String ontologyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI);
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deletePropertyAssertion(String individualURI,
+                                        String propertyURI,
+                                        String individualAsValueURI,
+                                        String literalAsValue) throws RestClientException {
+        try {
+            WebResource webResource;
+            if (literalAsValue != null) {
+                MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+                formData.add("value", literalAsValue);
+                webResource = client.resource(PSAddress + DELIMITER + individualURI + PROPERTY_ASSERTIONS
+                                              + normalizeURI(propertyURI) + LITERALS);
+                webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                        .header("X-HTTP-Method-Override", "DELETE").post(String.class, formData);
+            } else if (individualAsValueURI != null) {
+                webResource = client.resource(PSAddress + DELIMITER + individualURI + PROPERTY_ASSERTIONS
+                                              + normalizeURI(propertyURI) + OBJECTS
+                                              + normalizeURI(individualAsValueURI));
+                webResource.delete();
+            } else {
+                throw new IllegalArgumentException(
+                        "Either individualAsValueURI or literalAsValue must not be null");
+            }
+
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void deleteRange(String propertyURI, String rangeURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + RANGES
+                                                      + normalizeURI(rangeURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteResource(String resourceURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + resourceURI);
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void deleteSuperClass(String subClassURI, String superClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + subClassURI + SUPER_CLASSES
+                                                      + normalizeURI(superClassURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void deleteSuperPropertyAssertion(String subPropertyURI, String superPropertyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + subPropertyURI
+                                                      + SUPER_PROPERTIES + normalizeURI(superPropertyURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void deleteUnionClass(String classURI, String unionClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI + UNION_CLASSES
+                                                      + normalizeURI(unionClassURI));
+            webResource.delete();
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public ClassContext generateClassContext(String classURI, boolean withInferredAxioms) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + classURI);
+            String content = webResource
+                    .queryParam(WITH_INFERRED_AXIOMS, Boolean.toString(withInferredAxioms))
+                    .accept(MediaType.APPLICATION_XML).get(String.class);
+            ClassContext classContext = (ClassContext) unmarshall(content);
+            return classContext;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public ClassMetaInformation generateClassForOntology(String ontologyURI, String classURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI + CLASSES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("classURI", classURI);
+            String content = webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                    .accept(MediaType.APPLICATION_XML_TYPE).post(String.class, formData);
+            ClassMetaInformation classMetaInformation = (ClassMetaInformation) unmarshall(content);
+            return classMetaInformation;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public DatatypePropertyContext generateDatatypePropertyContext(String datatypePropertyURI,
+                                                                   boolean withInferredAxioms) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + datatypePropertyURI);
+            String content = webResource
+                    .queryParam(WITH_INFERRED_AXIOMS, Boolean.toString(withInferredAxioms))
+                    .accept(MediaType.APPLICATION_XML).get(String.class);
+            DatatypePropertyContext datatypePropertyContext = (DatatypePropertyContext) unmarshall(content);
+            return datatypePropertyContext;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public PropertyMetaInformation generateDatatypePropertyForOntology(String ontologyURI,
+                                                                       String datatypePropertyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI
+                                                      + DATATYPE_PROPERTIES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("datatypePropertyURI", datatypePropertyURI);
+            String content = webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                    .accept(MediaType.APPLICATION_XML_TYPE).post(String.class, formData);
+            PropertyMetaInformation propertyMetaInformation = (PropertyMetaInformation) unmarshall(content);
+            return propertyMetaInformation;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public IndividualContext generateIndividualContext(String individualURI, boolean withInferredAxioms) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + individualURI);
+            String content = webResource
+                    .queryParam(WITH_INFERRED_AXIOMS, Boolean.toString(withInferredAxioms))
+                    .accept(MediaType.APPLICATION_XML).get(String.class);
+            IndividualContext individualContext = (IndividualContext) unmarshall(content);
+            return individualContext;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public IndividualMetaInformation generateIndividualForOntology(String ontologyURI,
+                                                                   String classURI,
+                                                                   String individualURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyURI + INDIVIDUALS);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("classURI", classURI);
+            formData.add("individualURI", individualURI);
+            String content = webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                    .accept(MediaType.APPLICATION_XML_TYPE).post(String.class, formData);
+            IndividualMetaInformation individualMetaInformation = (IndividualMetaInformation) unmarshall(content);
+            return individualMetaInformation;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public ObjectPropertyContext generateObjectPropertyContext(String objectPropertyURI,
+                                                               boolean withInferredAxioms) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + objectPropertyURI);
+            String content = webResource
+                    .queryParam(WITH_INFERRED_AXIOMS, Boolean.toString(withInferredAxioms))
+                    .accept(MediaType.APPLICATION_XML).get(String.class);
+            ObjectPropertyContext objectPropertyContext = (ObjectPropertyContext) unmarshall(content);
+            return objectPropertyContext;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public PropertyMetaInformation generateObjectPropertyForOntology(String ontologyURI,
+                                                                     String objectPropertyURI) throws RestClientException {
+        try {
+            WebResource webResource = client
+                    .resource(PSAddress + DELIMITER + ontologyURI + OBJECT_PROPERTIES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("objectPropertyURI", objectPropertyURI);
+            String content = webResource.type(MediaType.APPLICATION_FORM_URLENCODED)
+                    .accept(MediaType.APPLICATION_XML_TYPE).post(String.class, formData);
+            PropertyMetaInformation propertyMetaInformation = (PropertyMetaInformation) unmarshall(content);
+            return propertyMetaInformation;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void makeSubClassOf(String subClassURI, String superClassURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + subClassURI + SUPER_CLASSES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("superClassURIs", superClassURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void makeSubPropertyOf(String subPropertyURI, String superPropertyURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + subPropertyURI
+                                                      + SUPER_PROPERTIES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("superPropertyURIs", superPropertyURI);
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void addDomains(String propertyURI, List<String> domainURIs) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + DOMAINS);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            for (String domainURI : domainURIs) {
+                formData.add("domainURIs", domainURI);
+            }
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public void setPropertyAttributes(String propertyURI,
+                                      Boolean isFunctional,
+                                      Boolean isTransitive,
+                                      Boolean isSymmetric,
+                                      Boolean isInverseFunctional) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            if (isFunctional != null) {
+                formData.add("isFunctional", Boolean.toString(isFunctional));
+            }
+            if (isTransitive != null) {
+                formData.add("isTransitive", Boolean.toString(isTransitive));
+            }
+            if (isSymmetric != null) {
+                formData.add("isSymmetric", Boolean.toString(isSymmetric));
+            }
+            if (isInverseFunctional != null) {
+                formData.add("isInverseFunctional", Boolean.toString(isInverseFunctional));
+            }
+
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+
+    }
+
+    @Override
+    public void addRanges(String propertyURI, List<String> rangeURIs) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + propertyURI + RANGES);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            for (String rangeURI : rangeURIs) {
+                formData.add("rangeURIs", rangeURI);
+            }
+            webResource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(String.class, formData);
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+
+    @Override
+    public String mergeOntology(String ontologyPath, String targetOntology, String targetOntologyBaseURI) throws RestClientException {
+        try {
+            WebResource webResource = client.resource(PSAddress + DELIMITER + ontologyPath);
+            MultivaluedMap<String,String> formData = new MultivaluedMapImpl();
+            formData.add("targetOntology", targetOntology);
+            formData.add("targetOntologyBaseURI", targetOntologyBaseURI);
+            String content = webResource.accept(APPLICATION_RDF_XML).post(String.class, formData);
+            return content;
+        } catch (UniformInterfaceException e) {
+            throw new RestClientException("REST service exception", e);
+        }
+    }
+}

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest/README.txt
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest/README.txt?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest/README.txt (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest/README.txt Wed Mar 30 13:43:53 2011
@@ -0,0 +1,36 @@
+IKS FISE Persistence Store
+==========================
+This bundle defines a persistence store interface through org.apache.stanbol.ontologymanager.store.PersistenceStore.   
+
+Run
+===
+Sling launcher can be used to create the FISE launcher with persistence store deployed on it. 
+Other instructions can be found at /launchers/fise/README.txt 
+
+
+Restful Services
+================
+Following paths can be used to explore persistence store with prefix http://localhost:8080/ontologymanager/store/
+If here is no JAX-RS handler in system to bind rest resources, then the component eu.iksproject.fise.stores.persistencestore.rest.ServletRegisterer can be activated to register a servlet which contains the rest resources.
+The servlet alias is /persistencestore and can be configured through the property eu.iksproject.fise.stores.persistencestore.rest.alias.name.
+
+ontologies
+ontologies/{ontologypath}
+ontologies/{ontologypath}/classes
+ontologies/{ontologyPath}/classes/{classPath}
+ontologies/{ontologypath}/individuals
+ontologies/{ontologypath}/datatypeProperties
+ontologies/{ontologyPath}/datatypeProperties/{datatypePropertyPath}
+ontologies/{ontologypath}/individuals
+ontologies/{ontologyPath}/individuals/{individualPath}
+ontologies/{ontologypath}/objectProperties
+ontologies/{ontologyPath}/objectProperties/{objectPropertyPath}
+
+To access some of these services you may need to give following permissions from http://localhost:8080/admin/user-manager/manage-role-permissions?roleTitle=BasePermissionsRole
+
+( java.net.SocketPermission "localhost:3306" "resolve, connect")
+( java.util.PropertyPermission "user.language" "write" )
+( java.io.FilePermission "*" "read" )
+( java.lang.RuntimePermission "accessDeclaredMembers")
+( java.lang.reflect.ReflectPermission "suppressAccessChecks" )
+

Propchange: incubator/stanbol/trunk/kres/ontologymanager/store/rest/README.txt
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest/pom.xml?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest/pom.xml (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest/pom.xml Wed Mar 30 13:43:53 2011
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.stanbol</groupId>
+		<artifactId>org.apache.stanbol.ontologymanager.store.parent</artifactId>
+		<version>0.9-SNAPSHOT</version>
+		<relativePath>../parent</relativePath>
+	</parent>
+
+	<artifactId>org.apache.stanbol.ontologymanager.store.web</artifactId>
+	<packaging>bundle</packaging>
+
+	<name>Apache Stanbol Ontology Manager Store - JAX-RS Frontend</name>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Embed-Dependency>freemarker</Embed-Dependency>
+						<Embed-Transitive>true</Embed-Transitive>
+						<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
+						<Import-Package>
+							!org.apache.tools.ant.taskdefs,
+							!org.apache.xpath.objects,
+							!org.apache.xml.*,
+							!org.apache.xpath.*,
+							!org.apache.tools.ant.*,
+							!org.apache.log.*,
+							!org.dom4j.*,
+							!org.mozilla.*,
+							!org.jaxen.*,
+							!org.python.*,
+							!org.jaxen.jdom,
+							!org.jdom.*,
+							!javax.servlet.jsp.*,
+							<!--  apache derby -->
+							org.apache.derby.jdbc,
+							*
+						</Import-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-scr-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.ontologymanager.store.api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr.annotations</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>javax.ws.rs</groupId>
+			<artifactId>jsr311-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-server</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-json</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.freemarker</groupId>
+			<artifactId>freemarker</artifactId>
+		</dependency>		
+		<dependency>
+			<groupId>com.hp.hpl.jena</groupId>
+			<artifactId>jena</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mortbay.jetty</groupId>
+			<artifactId>jetty</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+	
+</project>

Propchange: incubator/stanbol/trunk/kres/ontologymanager/store/rest/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/stanbol/trunk/kres/ontologymanager/store/rest/src/main/java/org/apache/stanbol/ontologymanager/store/rest/FreemarkerViewProcessor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/ontologymanager/store/rest/src/main/java/org/apache/stanbol/ontologymanager/store/rest/FreemarkerViewProcessor.java?rev=1086954&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/ontologymanager/store/rest/src/main/java/org/apache/stanbol/ontologymanager/store/rest/FreemarkerViewProcessor.java (added)
+++ incubator/stanbol/trunk/kres/ontologymanager/store/rest/src/main/java/org/apache/stanbol/ontologymanager/store/rest/FreemarkerViewProcessor.java Wed Mar 30 13:43:53 2011
@@ -0,0 +1,213 @@
+package org.apache.stanbol.ontologymanager.store.rest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.api.view.Viewable;
+import com.sun.jersey.spi.resource.Singleton;
+import com.sun.jersey.spi.template.ViewProcessor;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+
+/**
+ * Match a Viewable-named view with a Freemarker template.
+ * 
+ * This class is based on the following original implementation: http://github.com/cwinters/jersey-freemarker/
+ * 
+ * <p>
+ * You can configure the location of your templates with the context param 'freemarker.template.path'. If not
+ * assigned we'll use a default of <tt>WEB-INF/templates</tt>. Note that this uses Freemarker's
+ * {@link freemarker.cache.WebappTemplateLoader} to load/cache the templates, so check its docs (or crank up
+ * the logging under the 'freemarker.cache' package) if your templates aren't getting loaded.
+ * </p>
+ * 
+ * <p>
+ * This will put your Viewable's model object in the template variable "it", unless the model is a Map. If so,
+ * the values will be assigned to the template assuming the map is of type <tt>Map&lt;String,Object></tt>.
+ * </p>
+ * 
+ * <p>
+ * There are a number of methods you can override to change the behavior, such as handling processing
+ * exceptions, changing the default template extension, or adding variables to be assigned to every template
+ * context.
+ * </p>
+ * 
+ * @author Chris Winters <ch...@cwinters.com> // original code
+ * @author Olivier Grisel <og...@nuxeo.com> // ViewProcessor refactoring
+ */
+@Singleton
+@Provider
+public class FreemarkerViewProcessor implements ViewProcessor<Template> {
+
+    public static final String FREEMARKER_TEMPLATE_PATH_INIT_PARAM = "freemarker.template.path";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    protected Configuration freemarkerConfig;
+
+    protected String rootPath;
+
+    @Context
+    protected ServletContext context;
+
+    public FreemarkerViewProcessor() {}
+
+    /**
+     * @return extension for templates, ".ftl" by default; if we don't see this at the end of your view we'll
+     *         append it so we can find the template resource
+     */
+    protected String getDefaultExtension() {
+        return ".ftl";
+    }
+
+    /**
+     * Define additional variables to make available to the template.
+     * 
+     * @param viewableVariables
+     *            variables provided by whomever generated the viewable object; these are provided for
+     *            reference only, there will be no effect if you modify this map
+     * @return new variables for the template context, which will override any defaults provided
+     */
+    protected Map<String,Object> getVariablesForTemplate(final Map<String,Object> viewableVariables) {
+        return Collections.emptyMap();
+    }
+
+    /**
+     * Catch any exception generated during template processing.
+     * 
+     * @param t
+     *            throwable caught
+     * @param templatePath
+     *            path of template we're executing
+     * @param templateContext
+     *            context use when evaluating this template
+     * @param out
+     *            output stream from servlet container
+     * @throws IOException
+     *             on any write errors, or if you want to rethrow
+     */
+    protected void onProcessException(final Throwable t,
+                                      final Template template,
+                                      final Map<String,Object> templateContext,
+                                      final OutputStream out) throws IOException {
+        log.error("Error processing freemarker template @ " + template.getName() + ": " + t.getMessage(), t);
+        out.write("<pre>".getBytes());
+        t.printStackTrace(new PrintStream(out));
+        out.write("</pre>".getBytes());
+    }
+
+    /**
+     * Modify freemarker configuration after we've created it and applied any settings from
+     * 'freemarker.properties' on the classpath.
+     * 
+     * @param config
+     *            configuration we've created so far
+     * @param context
+     *            servlet context used to create the configuration
+     */
+    protected void assignFreemarkerConfig(final Configuration config, final ServletContext context) {
+        // TODO read those parameters from context instead of hardcoding them
+
+        // don't always put a ',' in numbers (e.g., id=2000 vs id=2,000)
+        config.setNumberFormat("0");
+
+        // don't look for list.en.ftl when list.ftl requested
+        config.setLocalizedLookup(false);
+
+        // don't cache for more that 2s
+        config.setTemplateUpdateDelay(2);
+        log.info("Assigned default freemarker configuration");
+    }
+
+    protected Configuration getConfig() {
+        if (freemarkerConfig == null) {
+            // deferred initialization of the freemarker config to ensure that
+            // the injected ServletContext is fully functional and for some
+            // reason the #getInitParam access does not work hence using the
+            // #getAttribute access after servlet init.
+            Configuration config = new Configuration();
+            if (context != null) {
+                rootPath = (String) context.getAttribute(FREEMARKER_TEMPLATE_PATH_INIT_PARAM);
+            }
+            if (rootPath == null || rootPath.trim().length() == 0) {
+                log.info("No 'freemarker.template.path' context-param, "
+                         + "defaulting to '/WEB-INF/templates'");
+                rootPath = "/WEB-INF/templates";
+            }
+            rootPath = rootPath.replaceAll("/$", "");
+            config.setTemplateLoader(new ClassTemplateLoader(getClass(), rootPath));
+
+            // TODO: make the usage of a freemaker properties file an explicit
+            // parameter declared in the servlet context instead of magic
+            // classloading auto-detect. That way the application could
+            // explicitly override the defaults
+            final InputStream fmProps = context.getResourceAsStream("freemarker.properties");
+            boolean loadDefaults = true;
+            if (fmProps != null) {
+                try {
+                    config.setSettings(fmProps);
+                    log.info("Assigned freemarker configuration from 'freemarker.properties'");
+                    loadDefaults = false;
+                } catch (Throwable t) {
+                    log.warn("Failed to load/assign freemarker.properties, will"
+                             + " use default settings instead: " + t.getMessage(), t);
+                }
+            }
+            if (loadDefaults) {
+                assignFreemarkerConfig(config, context);
+            }
+            freemarkerConfig = config;
+        }
+        return freemarkerConfig;
+    }
+
+    public Template resolve(final String path) {
+        // accept both '/path/to/template' and '/path/to/template.ftl'
+        final String defaultExtension = getDefaultExtension();
+        final String filePath = path.endsWith(defaultExtension) ? path : path + defaultExtension;
+        try {
+            return getConfig().getTemplate(filePath);
+        } catch (IOException e) {
+            log.error("Failed to load freemaker template: " + rootPath + filePath);
+            return null;
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void writeTo(Template template, Viewable viewable, OutputStream out) throws IOException {
+        out.flush(); // send status + headers
+
+        Object model = viewable.getModel();
+        final Map<String,Object> vars = new HashMap<String,Object>();
+        if (model instanceof Map<?,?>) {
+            vars.putAll((Map<String,Object>) model);
+        } else {
+            vars.put("it", model);
+        }
+        // override custom variables if any
+        vars.putAll(getVariablesForTemplate(vars));
+
+        final OutputStreamWriter writer = new OutputStreamWriter(out);
+        try {
+            template.process(vars, writer);
+        } catch (Throwable t) {
+            onProcessException(t, template, vars, out);
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/stanbol/trunk/kres/ontologymanager/store/rest/src/main/java/org/apache/stanbol/ontologymanager/store/rest/FreemarkerViewProcessor.java
------------------------------------------------------------------------------
    svn:executable = *