Modified: stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/transformation/OWLAPIToClerezzaConverterTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/transformation/OWLAPIToClerezzaConverterTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/transformation/OWLAPIToClerezzaConverterTest.java (original) +++ stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/transformation/OWLAPIToClerezzaConverterTest.java Tue May 17 22:20:49 2016 @@ -20,18 +20,17 @@ import java.util.Collection; import java.util.Iterator; import java.util.Set; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.stanbol.commons.owl.transformation.OWLAPIToClerezzaConverter; import org.junit.BeforeClass; import org.junit.Test; import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLAxiom; import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLDataFactory; @@ -56,7 +55,7 @@ import com.hp.hpl.jena.vocabulary.RDF; public class OWLAPIToClerezzaConverterTest { private static OWLOntology ontology; - private static MGraph mGraph; + private static Graph mGraph; private static String ns = "http://incubator.apache.org/stanbol/owl#"; private static String foaf = "http://xmlns.com/foaf/0.1/"; @@ -73,17 +72,17 @@ public class OWLAPIToClerezzaConverterTe OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); try { - ontology = manager.createOntology(IRI.create(ns + "testOntology")); + ontology = manager.createOntology(org.semanticweb.owlapi.model.IRI.create(ns + "testOntology")); } catch (OWLOntologyCreationException e) { log.error(e.getMessage()); } if (ontology != null) { - OWLClass personClass = factory.getOWLClass(IRI.create(foaf + "Person")); - OWLNamedIndividual andreaNuzzoleseOWL = factory.getOWLNamedIndividual(IRI + OWLClass personClass = factory.getOWLClass(org.semanticweb.owlapi.model.IRI.create(foaf + "Person")); + OWLNamedIndividual andreaNuzzoleseOWL = factory.getOWLNamedIndividual(org.semanticweb.owlapi.model.IRI .create(ns + "AndreaNuzzolese")); - OWLNamedIndividual enricoDagaOWL = factory.getOWLNamedIndividual(IRI.create(ns + "EnricoDaga")); - OWLObjectProperty knowsOWL = factory.getOWLObjectProperty(IRI.create(foaf + "knows")); + OWLNamedIndividual enricoDagaOWL = factory.getOWLNamedIndividual(org.semanticweb.owlapi.model.IRI.create(ns + "EnricoDaga")); + OWLObjectProperty knowsOWL = factory.getOWLObjectProperty(org.semanticweb.owlapi.model.IRI.create(foaf + "knows")); OWLAxiom axiom = factory.getOWLClassAssertionAxiom(personClass, andreaNuzzoleseOWL); manager.addAxiom(ontology, axiom); @@ -99,14 +98,14 @@ public class OWLAPIToClerezzaConverterTe * Set-up the Clerezza model for the test. As before simply add the triples: AndreaNuzzolese isA * Person EnricoDaga isA Person AndreaNuzzolese knows EnricoDaga */ - mGraph = new SimpleMGraph(); + mGraph = new SimpleGraph(); - UriRef knowsInClerezza = new UriRef(ns + "knows"); - UriRef rdfType = new UriRef(RDF.getURI() + "type"); - UriRef foafPersonInClerezza = new UriRef(foaf + "Person"); + IRI knowsInClerezza = new IRI(ns + "knows"); + IRI rdfType = new IRI(RDF.getURI() + "type"); + IRI foafPersonInClerezza = new IRI(foaf + "Person"); - NonLiteral andreaNuzzoleseInClerezza = new UriRef(ns + "AndreaNuzzolese"); - NonLiteral enricoDagaInClerezza = new UriRef(ns + "EnricoDaga"); + BlankNodeOrIRI andreaNuzzoleseInClerezza = new IRI(ns + "AndreaNuzzolese"); + BlankNodeOrIRI enricoDagaInClerezza = new IRI(ns + "EnricoDaga"); Triple triple = new TripleImpl(andreaNuzzoleseInClerezza, rdfType, foafPersonInClerezza); mGraph.add(triple); @@ -117,9 +116,9 @@ public class OWLAPIToClerezzaConverterTe } @Test - public void testMGraphToOWLOntology() { + public void testGraphToOWLOntology() { /* - * Transform the Clerezza MGraph to an OWLOntology. + * Transform the Clerezza Graph to an OWLOntology. */ OWLOntology ontology = OWLAPIToClerezzaConverter.clerezzaGraphToOWLOntology(mGraph); @@ -139,15 +138,15 @@ public class OWLAPIToClerezzaConverterTe } @Test - public void testOWLOntologyToMGraph() { + public void testOWLOntologyToGraph() { /* - * Transform the OWLOntology into a Clerezza MGraph. + * Transform the OWLOntology into a Clerezza Graph. */ - TripleCollection mGraph = OWLAPIToClerezzaConverter.owlOntologyToClerezzaMGraph(ontology); + Graph mGraph = OWLAPIToClerezzaConverter.owlOntologyToClerezzaGraph(ontology); /* - * Print all the triples contained in the Clerezza MGraph. + * Print all the triples contained in the Clerezza Graph. */ Iterator<Triple> tripleIt = mGraph.iterator(); while (tripleIt.hasNext()) {
Modified: stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java (original) +++ stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java Tue May 17 22:20:49 2016 @@ -26,8 +26,8 @@ import static org.junit.Assert.assertTru import java.io.InputStream; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.access.TcManager; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.jena.parser.JenaParserProvider; @@ -35,7 +35,6 @@ import org.apache.clerezza.rdf.simple.st import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; -import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.OWLOntologyID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,9 +61,9 @@ public class TestOWLUtils { private Logger log = LoggerFactory.getLogger(getClass()); - private IRI ontologyIri = IRI.create("http://stanbol.apache.org/ontologies/test"); + private org.semanticweb.owlapi.model.IRI ontologyIri = org.semanticweb.owlapi.model.IRI.create("http://stanbol.apache.org/ontologies/test"); - private UriRef uri = new UriRef("ontonet:http://stanbol.apache.org/prova"); + private IRI uri = new IRI("ontonet:http://stanbol.apache.org/prova"); /* * Guessing the ID of a named ontology whose IRI is near the end of the graph. @@ -111,7 +110,7 @@ public class TestOWLUtils { // Minimum offset required is 2 because of an owl:versionInfo triple in-between. String location = "/owl/versioned.owl"; log.info("Testing lookahead for location {}", location); - IRI incubatedVersion = IRI + org.semanticweb.owlapi.model.IRI incubatedVersion = org.semanticweb.owlapi.model.IRI .create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned.owl"); OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion); @@ -151,7 +150,7 @@ public class TestOWLUtils { // Actual distance is 102 String location = "/owl/versioned_distance-100.owl"; log.info("Testing lookahead for location {}", location); - IRI incubatedVersion = IRI + org.semanticweb.owlapi.model.IRI incubatedVersion = org.semanticweb.owlapi.model.IRI .create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned_distance-100.owl"); OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion); @@ -176,7 +175,7 @@ public class TestOWLUtils { // Actual distance is 102 String location = "/owl/versioned_distance-100-reversed.owl"; log.info("Testing lookahead for location {}", location); - IRI incubatedVersion = IRI + org.semanticweb.owlapi.model.IRI incubatedVersion = org.semanticweb.owlapi.model.IRI .create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned_distance-100-reversed.owl"); OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion); @@ -200,7 +199,7 @@ public class TestOWLUtils { public void lookaheadVersionedImmediate() throws Exception { String location = "/owl/versioned_immediate.owl"; log.info("Testing lookahead for location {}", location); - IRI incubatedVersion = IRI + org.semanticweb.owlapi.model.IRI incubatedVersion = org.semanticweb.owlapi.model.IRI .create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned_immediate.owl"); OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion); @@ -215,27 +214,27 @@ public class TestOWLUtils { * Extracting the OWL ontology identifier on a *whole* ontology. */ @Test - public void namedUriRef() throws Exception { + public void namedIRI() throws Exception { InputStream inputStream = getClass().getResourceAsStream("/owl/maincharacters.owl"); - MGraph mg = TcManager.getInstance().createMGraph(uri); + Graph mg = TcManager.getInstance().createGraph(uri); parser.parse(mg, inputStream, "application/rdf+xml", uri); - assertNotNull(OWLUtils.extractOntologyID(mg.getGraph())); + assertNotNull(OWLUtils.extractOntologyID(mg.getImmutableGraph())); } /* * Extracting the OWL ontology identifier on a *whole* nameless ontology must return a null value. */ @Test - public void namelessUriRef() throws Exception { + public void namelessIRI() throws Exception { InputStream inputStream = getClass().getResourceAsStream("/owl/nameless.owl"); - MGraph mg = TcManager.getInstance().createMGraph(uri); + Graph mg = TcManager.getInstance().createGraph(uri); parser.parse(mg, inputStream, "application/rdf+xml", uri); - assertNull(OWLUtils.extractOntologyID(mg.getGraph())); + assertNull(OWLUtils.extractOntologyID(mg.getImmutableGraph())); } @After public void reset() throws Exception { - if (TcManager.getInstance().listTripleCollections().contains(uri)) TcManager.getInstance() - .deleteTripleCollection(uri); + if (TcManager.getInstance().listGraphs().contains(uri)) TcManager.getInstance() + .deleteGraph(uri); } } Modified: stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/PermissionDefinitions.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/PermissionDefinitions.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/PermissionDefinitions.java (original) +++ stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/PermissionDefinitions.java Tue May 17 22:20:49 2016 @@ -22,11 +22,11 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.osgi.service.permissionadmin.PermissionInfo; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.ontologies.OSGI; import org.apache.clerezza.rdf.ontologies.PERMISSION; import org.apache.clerezza.rdf.ontologies.SIOC; @@ -38,9 +38,9 @@ import org.apache.clerezza.rdf.ontologie */ class PermissionDefinitions { - private MGraph systemGraph; + private Graph systemGraph; - PermissionDefinitions(MGraph systeGraph) { + PermissionDefinitions(Graph systeGraph) { this.systemGraph = systeGraph; } @@ -55,10 +55,10 @@ class PermissionDefinitions { List<PermissionInfo> permInfoList = new ArrayList<PermissionInfo>(); Iterator<Triple> ownerTriples = - systemGraph.filter(new UriRef(location), OSGI.owner, null); + systemGraph.filter(new IRI(location), OSGI.owner, null); if (ownerTriples.hasNext()) { - NonLiteral user = (NonLiteral) ownerTriples.next().getObject(); + BlankNodeOrIRI user = (BlankNodeOrIRI) ownerTriples.next().getObject(); lookForPermissions(user, permInfoList); } @@ -73,16 +73,16 @@ class PermissionDefinitions { * And if the role has another role, then execute this function recursively, * until all permissions are found. * - * @param role a <code>NonLiteral</code> which is either a user or a role + * @param role a <code>BlankNodeOrIRI</code> which is either a user or a role * @param permInfoList a list with all the added permissions of this bundle */ - private void lookForPermissions(NonLiteral role, List<PermissionInfo> permInfoList) { + private void lookForPermissions(BlankNodeOrIRI role, List<PermissionInfo> permInfoList) { Iterator<Triple> permissionTriples = systemGraph.filter(role, PERMISSION.hasPermission, null); while (permissionTriples.hasNext()) { - NonLiteral permission = (NonLiteral) permissionTriples.next().getObject(); + BlankNodeOrIRI permission = (BlankNodeOrIRI) permissionTriples.next().getObject(); Iterator<Triple> javaPermissionTriples = systemGraph.filter(permission, PERMISSION.javaPermissionEntry, null); @@ -100,7 +100,7 @@ class PermissionDefinitions { systemGraph.filter(role, SIOC.has_function, null); while (roleTriples.hasNext()) { - NonLiteral anotherRole = (NonLiteral) roleTriples.next().getObject(); + BlankNodeOrIRI anotherRole = (BlankNodeOrIRI) roleTriples.next().getObject(); this.lookForPermissions(anotherRole, permInfoList); } } Modified: stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/UserAwarePolicy.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/UserAwarePolicy.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/UserAwarePolicy.java (original) +++ stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/UserAwarePolicy.java Tue May 17 22:20:49 2016 @@ -41,12 +41,13 @@ import org.apache.clerezza.platform.conf import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.clerezza.rdf.core.BNode; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.BlankNode; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.clerezza.rdf.ontologies.PERMISSION; import org.apache.clerezza.rdf.ontologies.PLATFORM; import org.apache.clerezza.rdf.ontologies.RDF; @@ -73,7 +74,7 @@ public class UserAwarePolicy extends Pol final Logger logger = LoggerFactory.getLogger(UserAwarePolicy.class); @Reference(target=SystemConfig.SYSTEM_GRAPH_FILTER) - private MGraph systemGraph; + private Graph systemGraph; /** * Stores the mapping between a String describing the permission and the @@ -175,25 +176,25 @@ public class UserAwarePolicy extends Pol private List<String> getAllPermissionsOfAUserByName(String userName) throws UserUnregisteredException { - NonLiteral user = getUserByName(userName); + BlankNodeOrIRI user = getUserByName(userName); List<String> result = getPermissionEntriesOfAUser(user, userName); Iterator<Triple> roleTriples = systemGraph.filter(user, SIOC.has_function, null); while (roleTriples.hasNext()) { - NonLiteral anotherRole = (NonLiteral) roleTriples.next() + BlankNodeOrIRI anotherRole = (BlankNodeOrIRI) roleTriples.next() .getObject(); result.addAll(getPermissionEntriesOfARole(anotherRole, userName, user)); } - Iterator<NonLiteral> baseRoles = getResourcesOfType(PERMISSION.BaseRole); + Iterator<BlankNodeOrIRI> baseRoles = getResourcesOfType(PERMISSION.BaseRole); while(baseRoles.hasNext()) { result.addAll(getPermissionEntriesOfARole(baseRoles.next(), userName, user)); } return result; } - private NonLiteral getUserByName(String userName) + private BlankNodeOrIRI getUserByName(String userName) throws UserUnregisteredException { Iterator<Triple> triples = systemGraph.filter(null, PLATFORM.userName, new PlainLiteralImpl(userName)); @@ -204,29 +205,29 @@ public class UserAwarePolicy extends Pol throw new UserUnregisteredException(userName); } - private List<String> getPermissionEntriesOfAUser(NonLiteral user, String userName) { + private List<String> getPermissionEntriesOfAUser(BlankNodeOrIRI user, String userName) { List<String> result = getPermissionEntriesOfARole(user, userName, user); - if (user instanceof UriRef) { + if (user instanceof IRI) { synchronized(permissionProviders) { for (WebIdBasedPermissionProvider p : permissionProviders) { - result.addAll(p.getPermissions((UriRef)user)); + result.addAll(p.getPermissions((IRI)user)); } } } return result; } //note that users are roles too - private List<String> getPermissionEntriesOfARole(NonLiteral role, String userName, NonLiteral user) { + private List<String> getPermissionEntriesOfARole(BlankNodeOrIRI role, String userName, BlankNodeOrIRI user) { List<String> result = new ArrayList<String>(); Iterator<Triple> permsForRole = systemGraph.filter(role, PERMISSION.hasPermission, null); while (permsForRole.hasNext()) { Iterator<Triple> javaPermForRole = systemGraph.filter( - (BNode) permsForRole.next().getObject(), + (BlankNode) permsForRole.next().getObject(), PERMISSION.javaPermissionEntry, null); if (javaPermForRole.hasNext()) { - PlainLiteralImpl permissionEntry = (PlainLiteralImpl) javaPermForRole + Literal permissionEntry = (Literal) javaPermForRole .next().getObject(); String permission = permissionEntry.getLexicalForm(); if(permission.contains("{username}")) { @@ -238,10 +239,10 @@ public class UserAwarePolicy extends Pol return result; } - private Iterator<NonLiteral> getResourcesOfType(UriRef type) { + private Iterator<BlankNodeOrIRI> getResourcesOfType(IRI type) { final Iterator<Triple> triples = systemGraph.filter(null, RDF.type, type); - return new Iterator<NonLiteral>() { + return new Iterator<BlankNodeOrIRI>() { @Override public boolean hasNext() { @@ -249,7 +250,7 @@ public class UserAwarePolicy extends Pol } @Override - public NonLiteral next() { + public BlankNodeOrIRI next() { return triples.next().getSubject(); } Modified: stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/WebIdBasedPermissionProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/WebIdBasedPermissionProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/WebIdBasedPermissionProvider.java (original) +++ stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/WebIdBasedPermissionProvider.java Tue May 17 22:20:49 2016 @@ -18,7 +18,7 @@ package org.apache.stanbol.commons.security; import java.util.Collection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; /** * Services implementing this interface provide additional permissions @@ -37,5 +37,5 @@ public interface WebIdBasedPermissionPro * @param webId the uri identifying the user (aka Web-Id) * @return the string descriptions of the permissions */ - Collection<String> getPermissions(UriRef webId); + Collection<String> getPermissions(IRI webId); } Modified: stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/auth/AuthenticationCheckerImpl.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/auth/AuthenticationCheckerImpl.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/auth/AuthenticationCheckerImpl.java (original) +++ stanbol/trunk/commons/security/core/src/main/java/org/apache/stanbol/commons/security/auth/AuthenticationCheckerImpl.java Tue May 17 22:20:49 2016 @@ -25,16 +25,16 @@ import org.apache.felix.scr.annotations. import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Service; import org.apache.stanbol.commons.security.PasswordUtil; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.clerezza.rdf.ontologies.PERMISSION; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.clerezza.platform.config.SystemConfig; -import org.apache.clerezza.rdf.core.access.LockableMGraph; import org.apache.clerezza.rdf.ontologies.PLATFORM; /** @@ -50,7 +50,7 @@ public class AuthenticationCheckerImpl i private final static Logger logger = LoggerFactory.getLogger(AuthenticationCheckerImpl.class); @Reference(target=SystemConfig.SYSTEM_GRAPH_FILTER) - private LockableMGraph systemGraph; + private Graph systemGraph; /** * Checks if the provided username and password matches a username and @@ -68,7 +68,7 @@ public class AuthenticationCheckerImpl i if (security != null) { AccessController.checkPermission(new CheckAuthenticationPermission()); } - NonLiteral agent = getAgentFromGraph(userName); + BlankNodeOrIRI agent = getAgentFromGraph(userName); String storedPassword = getPasswordOfAgent(agent); if (storedPassword.equals(PasswordUtil.convertPassword(password))) { logger.debug("user {} successfully authenticated", userName); @@ -79,8 +79,8 @@ public class AuthenticationCheckerImpl i } } - private NonLiteral getAgentFromGraph(String userName) throws NoSuchAgent { - NonLiteral agent; + private BlankNodeOrIRI getAgentFromGraph(String userName) throws NoSuchAgent { + BlankNodeOrIRI agent; Lock l = systemGraph.getLock().readLock(); l.lock(); try { @@ -97,7 +97,7 @@ public class AuthenticationCheckerImpl i return agent; } - private String getPasswordOfAgent(NonLiteral agent) { + private String getPasswordOfAgent(BlankNodeOrIRI agent) { String storedPassword = ""; Lock l = systemGraph.getLock().readLock(); l.lock(); Modified: stanbol/trunk/commons/security/core/src/test/java/org/apache/stanbol/commons/security/PermissionDefinitionsTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/core/src/test/java/org/apache/stanbol/commons/security/PermissionDefinitionsTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/core/src/test/java/org/apache/stanbol/commons/security/PermissionDefinitionsTest.java (original) +++ stanbol/trunk/commons/security/core/src/test/java/org/apache/stanbol/commons/security/PermissionDefinitionsTest.java Tue May 17 22:20:49 2016 @@ -23,8 +23,8 @@ import java.util.List; import org.junit.*; import org.osgi.service.permissionadmin.PermissionInfo; -import org.apache.clerezza.rdf.core.Graph; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.clerezza.commons.rdf.ImmutableGraph; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.stanbol.commons.security.PermissionDefinitions; @@ -52,11 +52,11 @@ public class PermissionDefinitionsTest { @Before public void setUp() { - final Graph graph = Parser.getInstance() + final ImmutableGraph graph = Parser.getInstance() .parse(getClass().getResourceAsStream("systemgraph.nt"), "text/rdf+n3"); this.permissionDefinitions = new PermissionDefinitions( - new SimpleMGraph(graph.iterator())); + new SimpleGraph(graph.iterator())); this.allPermissions = new PermissionInfo[] { new PermissionInfo( Modified: stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/Ontology.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/Ontology.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/Ontology.java (original) +++ stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/Ontology.java Tue May 17 22:20:49 2016 @@ -16,7 +16,7 @@ */ package org.apache.stanbol.commons.usermanagement; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; public final class Ontology { @@ -28,19 +28,19 @@ public final class Ontology { public final static String userManagementBase = "http://stanbol.apache.org/ontologies/usermanagement#"; - public final static UriRef EditableUser = - new UriRef("EditableUser"); + public final static IRI EditableUser = + new IRI("EditableUser"); - public final static UriRef Change = - new UriRef(userManagementBase + "Change"); + public final static IRI Change = + new IRI(userManagementBase + "Change"); - public final static UriRef predicate = - new UriRef(userManagementBase + "predicate"); + public final static IRI predicate = + new IRI(userManagementBase + "predicate"); - public final static UriRef oldValue = - new UriRef(userManagementBase + "oldValue"); + public final static IRI oldValue = + new IRI(userManagementBase + "oldValue"); - public final static UriRef newValue = - new UriRef(userManagementBase + "newValue"); + public final static IRI newValue = + new IRI(userManagementBase + "newValue"); } Modified: stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java (original) +++ stanbol/trunk/commons/security/usermanagement/src/main/java/org/apache/stanbol/commons/usermanagement/resource/UserResource.java Tue May 17 22:20:49 2016 @@ -16,10 +16,7 @@ */ package org.apache.stanbol.commons.usermanagement.resource; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.security.Policy; @@ -31,7 +28,6 @@ import java.util.Set; import java.util.concurrent.locks.Lock; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -40,7 +36,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.CacheControl; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; @@ -48,21 +43,17 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import org.apache.clerezza.platform.config.SystemConfig; -import org.apache.clerezza.rdf.core.BNode; -import org.apache.clerezza.rdf.core.Graph; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.NonLiteral; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.access.LockableMGraph; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.SimpleGraph; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.clerezza.commons.rdf.BlankNode; +import org.apache.clerezza.commons.rdf.ImmutableGraph; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.BlankNodeOrIRI; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.core.serializedform.Serializer; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; @@ -74,8 +65,6 @@ import org.apache.clerezza.rdf.ontologie import org.apache.clerezza.rdf.ontologies.RDFS; import org.apache.clerezza.rdf.ontologies.SIOC; import org.apache.clerezza.rdf.utils.GraphNode; -import org.apache.clerezza.rdf.utils.MGraphUtils; -import org.apache.clerezza.rdf.utils.MGraphUtils.NoSuchSubGraphException; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Reference; @@ -98,7 +87,7 @@ public class UserResource { private static Logger log = LoggerFactory.getLogger(UserResource.class); @Reference(target = SystemConfig.SYSTEM_GRAPH_FILTER) - private LockableMGraph systemGraph; + private Graph systemGraph; @Reference private Serializer serializer; @Reference @@ -106,7 +95,7 @@ public class UserResource { private static GraphNode dummyNode; static { - dummyNode = new GraphNode(new BNode(), new SimpleMGraph()); + dummyNode = new GraphNode(new BlankNode(), new SimpleGraph()); dummyNode.addProperty(RDF.type, FOAF.Agent); } // ********************************** @@ -128,11 +117,11 @@ public class UserResource { */ @GET @Path("users/{username}") - public TripleCollection getUserContext(@PathParam("username") String userName) + public Graph getUserContext(@PathParam("username") String userName) throws UnsupportedEncodingException { GraphNode userNode = getUser(userName); if (userNode == null) { // a kludge - return new SimpleMGraph(); + return new SimpleGraph(); } return userNode.getNodeContext(); } @@ -180,9 +169,9 @@ public class UserResource { @GET @Path("roles/{username}") @Produces(SupportedFormat.TURTLE) - public TripleCollection getUserRoles(@PathParam("username") String userName) + public Graph getUserRoles(@PathParam("username") String userName) throws UnsupportedEncodingException { - MGraph rolesGraph = getUserRolesGraph(userName); + Graph rolesGraph = getUserRolesGraph(userName); // case of no roles not handled - what best to return : empty graph or // 404? @@ -238,7 +227,7 @@ public class UserResource { @POST @Consumes(SupportedFormat.TURTLE) @Path("change-user") - public Response changeUser(Graph inputGraph) { + public Response changeUser(ImmutableGraph inputGraph) { Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); @@ -252,7 +241,7 @@ public class UserResource { if (changes.hasNext()) { Triple changeTriple = changes.next(); - NonLiteral changeNode = changeTriple.getSubject(); + BlankNodeOrIRI changeNode = changeTriple.getSubject(); Literal userName = (Literal) inputGraph .filter(changeNode, PLATFORM.userName, null).next() @@ -262,10 +251,10 @@ public class UserResource { .filter(null, PLATFORM.userName, userName); // if (userTriples.hasNext()) { - NonLiteral userNode = userTriples.next() + BlankNodeOrIRI userNode = userTriples.next() .getSubject(); - UriRef predicateUriRef = (UriRef) inputGraph + IRI predicateIRI = (IRI) inputGraph .filter(changeNode, Ontology.predicate, null).next() .getObject(); @@ -273,25 +262,25 @@ public class UserResource { Iterator<Triple> iterator = inputGraph.filter(changeNode, Ontology.oldValue, null); - Resource oldValue = null; + RDFTerm oldValue = null; if (iterator.hasNext()) { oldValue = iterator.next().getObject(); - // Triple oldTriple = systemGraph.filter(null, predicateUriRef, + // Triple oldTriple = systemGraph.filter(null, predicateIRI, // oldValue).next(); Iterator<Triple> oldTriples = systemGraph.filter(userNode, - predicateUriRef, oldValue); + predicateIRI, oldValue); if (oldTriples.hasNext()) { oldTriple = oldTriples.next(); } } - Resource newValue = inputGraph + RDFTerm newValue = inputGraph .filter(changeNode, Ontology.newValue, null).next() .getObject(); - newTriple = new TripleImpl(userNode, predicateUriRef, + newTriple = new TripleImpl(userNode, predicateIRI, newValue); // } } @@ -346,7 +335,7 @@ public class UserResource { readLock.unlock(); } - MGraph rolesGraph = getUserRolesGraph(userName); + Graph rolesGraph = getUserRolesGraph(userName); ArrayList<String> userRoleNames = new ArrayList<String>(); @@ -400,7 +389,7 @@ public class UserResource { @PUT @Path("users/{username}") @Consumes(SupportedFormat.TURTLE) - public Response createUser(@Context UriInfo uriInfo, @PathParam("username") String userName, Graph inputGraph) { + public Response createUser(@Context UriInfo uriInfo, @PathParam("username") String userName, ImmutableGraph inputGraph) { Lock writeLock = systemGraph.getLock().writeLock(); writeLock.lock(); systemGraph.addAll(inputGraph); @@ -439,11 +428,11 @@ public class UserResource { @POST @Consumes(SupportedFormat.TURTLE) @Path("add-user") - public Response addUser(@Context UriInfo uriInfo, Graph inputGraph) { + public Response addUser(@Context UriInfo uriInfo, ImmutableGraph inputGraph) { Iterator<Triple> agents = inputGraph.filter(null, null, FOAF.Agent); - NonLiteral userNode = agents.next().getSubject(); + BlankNodeOrIRI userNode = agents.next().getSubject(); Iterator<Triple> userTriples = inputGraph.filter(userNode, null, null); @@ -492,8 +481,8 @@ public class UserResource { * @param userName */ private void remove(String userName) { - Resource userResource = getNamedUser(userName).getNode(); - Iterator<Triple> userTriples = systemGraph.filter((NonLiteral) userResource, null, null); + RDFTerm userResource = getNamedUser(userName).getNode(); + Iterator<Triple> userTriples = systemGraph.filter((BlankNodeOrIRI) userResource, null, null); ArrayList<Triple> buffer = new ArrayList<Triple>(); @@ -508,7 +497,7 @@ public class UserResource { readLock.unlock(); } - // Graph context = getNamedUser(userName).getNodeContext(); + // ImmutableGraph context = getNamedUser(userName).getNodeContext(); Lock writeLock = systemGraph.getLock().writeLock(); writeLock.lock(); try { @@ -544,7 +533,7 @@ public class UserResource { @POST @Consumes(SupportedFormat.TURTLE) @Path("delete-user") - public Response deleteUser(Graph inputGraph) { + public Response deleteUser(ImmutableGraph inputGraph) { Iterator<Triple> userNameTriples = inputGraph.filter(null, PLATFORM.userName, null); @@ -662,7 +651,7 @@ public class UserResource { try { while (roleIterator.hasNext()) { - NonLiteral role = roleIterator.next().getSubject(); + BlankNodeOrIRI role = roleIterator.next().getSubject(); Iterator<Triple> roleNameTriples = systemGraph.filter(role, DC.title, null); while (roleNameTriples.hasNext()) { @@ -706,8 +695,8 @@ public class UserResource { * @param userName */ private void deleteRole(String roleName) { - Resource roleResource = getNamedRole(roleName).getNode(); - Iterator<Triple> roleTriples = systemGraph.filter((NonLiteral) roleResource, null, null); + RDFTerm roleResource = getNamedRole(roleName).getNode(); + Iterator<Triple> roleTriples = systemGraph.filter((BlankNodeOrIRI) roleResource, null, null); ArrayList<Triple> buffer = new ArrayList<Triple>(); @@ -766,7 +755,7 @@ public class UserResource { * @return user node in system graph */ private GraphNode createRole(String newRoleName, String comment) { - BNode subject = new BNode(); + BlankNode subject = new BlankNode(); GraphNode roleNode = new GraphNode(subject, systemGraph); roleNode.addProperty(RDF.type, PERMISSION.Role); roleNode.addProperty(DC.title, new PlainLiteralImpl(newRoleName)); @@ -779,7 +768,7 @@ public class UserResource { String comment, List<String> permissions) { - NonLiteral roleResource = (NonLiteral) roleNode.getNode(); + BlankNodeOrIRI roleResource = (BlankNodeOrIRI) roleNode.getNode(); if (permissions != null) { clearPermissions(roleResource); @@ -899,10 +888,10 @@ public class UserResource { changeLiteral(userNode, PERMISSION.passwordSha1, passwordSha1); } if (email != null && !email.equals("")) { - changeResource(userNode, FOAF.mbox, new UriRef("mailto:" + email)); + changeResource(userNode, FOAF.mbox, new IRI("mailto:" + email)); } - NonLiteral userResource = (NonLiteral) userNode.getNode(); + BlankNodeOrIRI userResource = (BlankNodeOrIRI) userNode.getNode(); if (roles != null) { clearRoles(userResource); @@ -964,7 +953,7 @@ public class UserResource { try { while (permissionTriples.hasNext()) { Triple triple = permissionTriples.next(); - Resource permissionResource = triple.getObject(); + RDFTerm permissionResource = triple.getObject(); buffer.add(new GraphNode(permissionResource, systemGraph)); } } finally { @@ -988,13 +977,13 @@ public class UserResource { * @param userName * @return roles graph */ - private MGraph getUserRolesGraph(String userName) { + private Graph getUserRolesGraph(String userName) { GraphNode userNode = getUser(userName); - Iterator<Resource> functionIterator = userNode + Iterator<RDFTerm> functionIterator = userNode .getObjects(SIOC.has_function); - SimpleMGraph rolesGraph = new SimpleMGraph(); + SimpleGraph rolesGraph = new SimpleGraph(); while (functionIterator.hasNext()) { @@ -1002,14 +991,14 @@ public class UserResource { systemGraph); Iterator<Triple> roleIterator = systemGraph.filter( - (NonLiteral) functionNode.getNode(), RDF.type, + (BlankNodeOrIRI) functionNode.getNode(), RDF.type, PERMISSION.Role); // needs lock? while (roleIterator.hasNext()) { Triple roleTriple = roleIterator.next(); // rolesGraph.add(roleTriple); - NonLiteral roleNode = roleTriple.getSubject(); + BlankNodeOrIRI roleNode = roleTriple.getSubject(); SimpleGraph detailsGraph = new SimpleGraph(systemGraph.filter( roleNode, null, null)); rolesGraph.addAll(detailsGraph); @@ -1025,7 +1014,7 @@ public class UserResource { * @return user node in system graph */ private GraphNode createUser(String newUserName) { - BNode subject = new BNode(); + BlankNode subject = new BlankNode(); GraphNode userNode = new GraphNode(subject, systemGraph); userNode.addProperty(RDF.type, FOAF.Agent); @@ -1036,7 +1025,7 @@ public class UserResource { // move later? public final static String rolesBase = "urn:x-localhost/role/"; - private void clearRoles(NonLiteral userResource) { + private void clearRoles(BlankNodeOrIRI userResource) { systemGraph.removeAll(filterToArray(userResource, SIOC.has_function, null)); } @@ -1048,7 +1037,7 @@ public class UserResource { * @param object * @return */ - private List<Triple> filterToArray(NonLiteral subject, UriRef predicate, Resource object) { + private List<Triple> filterToArray(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) { Iterator<Triple> triples = systemGraph.filter(subject, predicate, object); ArrayList<Triple> buffer = new ArrayList<Triple>(); Lock readLock = systemGraph.getLock().readLock(); @@ -1077,12 +1066,12 @@ public class UserResource { // otherwise make a new one as a named node if (roleNode == null) { - UriRef roleUriRef = new UriRef(rolesBase + roleName); + IRI roleIRI = new IRI(rolesBase + roleName); - roleNode = new GraphNode(roleUriRef, systemGraph); + roleNode = new GraphNode(roleIRI, systemGraph); roleNode.addProperty(RDF.type, PERMISSION.Role); roleNode.addProperty(DC.title, new PlainLiteralImpl(roleName)); - userNode.addProperty(SIOC.has_function, roleUriRef); + userNode.addProperty(SIOC.has_function, roleIRI); } else { userNode.addProperty(SIOC.has_function, roleNode.getNode()); } @@ -1095,7 +1084,7 @@ public class UserResource { if (hasPermission(subjectNode, permissionString)) { return subjectNode; } - GraphNode permissionNode = new GraphNode(new BNode(), systemGraph); + GraphNode permissionNode = new GraphNode(new BlankNode(), systemGraph); permissionNode.addProperty(RDF.type, PERMISSION.Permission); // permissionNode.addProperty(DC.title, new PlainLiteralImpl(permissionName)); subjectNode.addProperty(PERMISSION.hasPermission, permissionNode.getNode()); @@ -1105,12 +1094,12 @@ public class UserResource { private boolean hasPermission(GraphNode userNode, String permissionString) { boolean has = false; - Iterator<Triple> existingPermissions = systemGraph.filter((NonLiteral) userNode.getNode(), PERMISSION.hasPermission, null); + Iterator<Triple> existingPermissions = systemGraph.filter((BlankNodeOrIRI) userNode.getNode(), PERMISSION.hasPermission, null); Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { // check to see if the user already has this permission while (existingPermissions.hasNext()) { - NonLiteral permissionNode = (NonLiteral) existingPermissions.next().getObject(); + BlankNodeOrIRI permissionNode = (BlankNodeOrIRI) existingPermissions.next().getObject(); Iterator<Triple> permissionTriples = systemGraph.filter(permissionNode, PERMISSION.javaPermissionEntry, null); while (permissionTriples.hasNext()) { Literal permission = (Literal) permissionTriples.next().getObject(); @@ -1132,7 +1121,7 @@ public class UserResource { // <http://clerezza.org/2008/10/permission#javaPermissionEntry> // "(java.security.AllPermission \"\" \"\")" // ] ; - private void clearPermissions(NonLiteral subject) { + private void clearPermissions(BlankNodeOrIRI subject) { ArrayList<Triple> buffer = new ArrayList<Triple>(); Lock readLock = systemGraph.getLock().readLock(); @@ -1142,7 +1131,7 @@ public class UserResource { while (permissions.hasNext()) { Triple permissionTriple = permissions.next(); buffer.add(permissionTriple); - NonLiteral permissionNode = (NonLiteral) permissionTriple.getObject(); + BlankNodeOrIRI permissionNode = (BlankNodeOrIRI) permissionTriple.getObject(); Iterator<Triple> permissionTriples = systemGraph.filter(permissionNode, null, null); while (permissionTriples.hasNext()) { buffer.add(permissionTriples.next()); @@ -1160,7 +1149,7 @@ public class UserResource { private GraphNode getTitleNode(String title) { Iterator<Triple> triples = systemGraph.filter(null, DC.title, new PlainLiteralImpl(title)); if (triples.hasNext()) { - Resource resource = triples.next().getSubject(); + RDFTerm resource = triples.next().getSubject(); return new GraphNode(resource, systemGraph); } return null; @@ -1176,15 +1165,15 @@ public class UserResource { * @param predicate property of the triple to change * @param newValue new value for given predicate */ - private void changeLiteral(GraphNode userNode, UriRef predicate, + private void changeLiteral(GraphNode userNode, IRI predicate, String newValue) { Iterator<Triple> oldTriples = systemGraph.filter( - (NonLiteral) userNode.getNode(), predicate, null); + (BlankNodeOrIRI) userNode.getNode(), predicate, null); ArrayList<Triple> oldBuffer = new ArrayList<Triple>(); - Resource oldObject = null; + RDFTerm oldObject = null; Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); @@ -1201,7 +1190,7 @@ public class UserResource { // filter appears to see plain literals and xsd:strings as differerent // so not // userNode.addPropertyValue(predicate, newValue); - PlainLiteral newObject = new PlainLiteralImpl(newValue); + Literal newObject = new PlainLiteralImpl(newValue); userNode.addProperty(predicate, newObject); if (newObject.equals(oldObject)) { @@ -1218,11 +1207,11 @@ public class UserResource { * @param predicate property of the triple to change * @param newValue new value for given predicate */ - private void changeResource(GraphNode userNode, UriRef predicate, - UriRef newValue) { + private void changeResource(GraphNode userNode, IRI predicate, + IRI newValue) { Iterator<Triple> oldTriples = systemGraph.filter( - (NonLiteral) userNode.getNode(), predicate, null); + (BlankNodeOrIRI) userNode.getNode(), predicate, null); ArrayList<Triple> oldBuffer = new ArrayList<Triple>(); @@ -1232,7 +1221,7 @@ public class UserResource { while (oldTriples.hasNext()) { Triple triple = oldTriples.next(); - Resource oldValue = triple.getObject(); + RDFTerm oldValue = triple.getObject(); if (newValue.equals(oldValue)) { return; } @@ -1272,7 +1261,7 @@ public class UserResource { return getResourcesOfType(FOAF.Agent); } - private Set<GraphNode> getResourcesOfType(UriRef type) { + private Set<GraphNode> getResourcesOfType(IRI type) { Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { Modified: stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/StanbolResourceLoader.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/StanbolResourceLoader.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/StanbolResourceLoader.java (original) +++ stanbol/trunk/commons/solr/core/src/main/java/org/apache/stanbol/commons/solr/utils/StanbolResourceLoader.java Tue May 17 22:20:49 2016 @@ -98,7 +98,7 @@ public class StanbolResourceLoader imple in = classloader.getResourceAsStream(resource); } if(in == null){ - throw new IOException("Unable to load Resource '"+resource+"' from " + throw new IOException("Unable to load RDFTerm '"+resource+"' from " + (parent != null ? ("parent (message: "+parentMessage+") and from") : "") + "classpath!"); } Modified: stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java (original) +++ stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java Tue May 17 22:20:49 2016 @@ -262,7 +262,7 @@ public class SolrIndexInstaller implemen String extension = FilenameUtils.getExtension(filePath); String archiveFormat = SUPPORTED_SOLR_ARCHIVE_FORMAT.get(extension); if (archiveFormat == null) { - log.error("Unable to process Solr Index Archive from Resource " + registeredResource.getURL() + log.error("Unable to process Solr Index Archive from RDFTerm " + registeredResource.getURL() + "because of unsupported archive format \"" + extension + "\" (supported are " + SUPPORTED_SOLR_ARCHIVE_FORMAT.keySet() + ")"); return null; Modified: stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedSolrServerImpl.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedSolrServerImpl.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedSolrServerImpl.java (original) +++ stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/impl/ManagedSolrServerImpl.java Tue May 17 22:20:49 2016 @@ -985,7 +985,7 @@ public class ManagedSolrServerImpl imple //not available ais = null; } catch (ArchiveException e) { - log.error("Unable to open ArchiveInputStream for Resource '"+ + log.error("Unable to open ArchiveInputStream for RDFTerm '"+ archive+"'!",e); ais = null; } @@ -1027,7 +1027,7 @@ public class ManagedSolrServerImpl imple try { ais = ManagementUtils.getArchiveInputStream(resourceName, is); } catch (ArchiveException e) { - log.error("Unable to open ArchiveInputStream for Resource '"+ + log.error("Unable to open ArchiveInputStream for RDFTerm '"+ resourceName+"'!",e); ais = null; } Modified: stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/ClassPathDataFileProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/ClassPathDataFileProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/ClassPathDataFileProvider.java (original) +++ stanbol/trunk/commons/solr/managed/src/main/java/org/apache/stanbol/commons/solr/managed/standalone/ClassPathDataFileProvider.java Tue May 17 22:20:49 2016 @@ -109,7 +109,7 @@ public class ClassPathDataFileProvider i // load default OpenNLP models from classpath (embedded in the defaultdata bundle) final String resourcePath = path + filename; final URL dataFile = getClass().getClassLoader().getResource(resourcePath); - //log.debug("Resource {} found: {}", (in == null ? "NOT" : ""), resourcePath); + //log.debug("RDFTerm {} found: {}", (in == null ? "NOT" : ""), resourcePath); return dataFile; } Modified: stanbol/trunk/commons/stanboltools/bundledatafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/bundle/impl/BundleDataFileProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/stanboltools/bundledatafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/bundle/impl/BundleDataFileProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/stanboltools/bundledatafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/bundle/impl/BundleDataFileProvider.java (original) +++ stanbol/trunk/commons/stanboltools/bundledatafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/bundle/impl/BundleDataFileProvider.java Tue May 17 22:20:49 2016 @@ -98,7 +98,7 @@ public class BundleDataFileProvider impl public InputStream getInputStream(String bundleSymbolicName, String filename, Map<String, String> comments) throws IOException { URL resource = getDataFile(bundleSymbolicName, filename); - log.debug("Resource {} found: {}", (resource == null ? "NOT" : ""), filename); + log.debug("RDFTerm {} found: {}", (resource == null ? "NOT" : ""), filename); return resource != null ? resource.openStream() : null; } Modified: stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java (original) +++ stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/DataFileProvider.java Tue May 17 22:20:49 2016 @@ -62,7 +62,7 @@ public interface DataFileProvider { * @param filename name of the file to open * @param comments Optional - how to get a more complete version * of the data file, licensing information, etc. - * @return <code>true</code> if the requested Resource is available. + * @return <code>true</code> if the requested RDFTerm is available. * Otherwise <code>false</code> */ boolean isAvailable(String bundleSymbolicName, Modified: stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileTrackerImpl.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileTrackerImpl.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileTrackerImpl.java (original) +++ stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/DataFileTrackerImpl.java Tue May 17 22:20:49 2016 @@ -224,7 +224,7 @@ public final class DataFileTrackerImpl i trackedResources.put(r, trackingState); } trackingState.addListener(resourceListener); - if(!trackedResources.isEmpty()){ //maybe this was the first added Resource + if(!trackedResources.isEmpty()){ //maybe this was the first added RDFTerm startTracking(); //so me might want to start tracking } } Modified: stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/TrackingState.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/TrackingState.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/TrackingState.java (original) +++ stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/tracking/TrackingState.java Tue May 17 22:20:49 2016 @@ -32,12 +32,12 @@ import org.apache.stanbol.commons.stanbo * Internally used to manage {@link DataFileListener} and the state of * tracked DataFiles.<p> * Note that different {@link DataFileListener}s may have different {@link STATE} - * for the same Resource (e.g. if a new {@link DataFileListener} is registered + * for the same RDFTerm (e.g. if a new {@link DataFileListener} is registered * for a resource it will start with {@link STATE#UNKNOWN} while all the other * Listeners will be in the state of the resource (either {@link STATE#AVAILABLE} * or {@link STATE#UNAVAILABLE}). Only after the next tracking the newly added * {@link DataFileListener} will get fired and be updated to the current state - * of the Resource.<p> + * of the RDFTerm.<p> * This model will also allow to introduce an ERROR state that could be used * to manage that some {@link DataFileListener} where not able to consume a * current version of a data file. Modified: stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/GraphWriter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/GraphWriter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/GraphWriter.java (original) +++ stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/GraphWriter.java Tue May 17 22:20:49 2016 @@ -43,7 +43,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import org.apache.clerezza.rdf.core.TripleCollection; +import org.apache.clerezza.commons.rdf.Graph; import org.apache.clerezza.rdf.core.serializedform.Serializer; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Property; @@ -58,7 +58,7 @@ import org.slf4j.LoggerFactory; @Property(name="javax.ws.rs", boolValue=true) @Provider // @Produces({TEXT_PLAIN, N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE, RDF_JSON, APPLICATION_JSON}) -public class GraphWriter implements MessageBodyWriter<TripleCollection> { +public class GraphWriter implements MessageBodyWriter<Graph> { /** * The media type for JSON-LD (<code>application/ld+json</code>) @@ -91,10 +91,10 @@ public class GraphWriter implements Mess public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { String mediaTypeString = mediaType.getType() + '/' + mediaType.getSubtype(); - return TripleCollection.class.isAssignableFrom(type) && supportedMediaTypes.contains(mediaTypeString); + return Graph.class.isAssignableFrom(type) && supportedMediaTypes.contains(mediaTypeString); } - public long getSize(TripleCollection t, + public long getSize(Graph t, Class<?> type, Type genericType, Annotation[] annotations, @@ -102,7 +102,7 @@ public class GraphWriter implements Mess return -1; } - public void writeTo(TripleCollection t, + public void writeTo(Graph t, Class<?> type, Type genericType, Annotation[] annotations, Modified: stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java (original) +++ stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java Tue May 17 22:20:49 2016 @@ -21,12 +21,11 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.clerezza.rdf.core.BNode; -import org.apache.clerezza.rdf.core.Language; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.BlankNode; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.sparql.ResultSet; import org.apache.clerezza.rdf.core.sparql.SolutionMapping; import org.apache.clerezza.rdf.core.sparql.query.Variable; @@ -84,23 +83,19 @@ class ResultSetToXml { } } - private Element createValueElement(Resource resource, Document doc) { + private Element createValueElement(RDFTerm resource, Document doc) { Element value; - if (resource instanceof UriRef) { + if (resource instanceof IRI) { value = doc.createElement("uri"); - value.appendChild(doc.createTextNode(((UriRef) resource) + value.appendChild(doc.createTextNode(((IRI) resource) .getUnicodeString())); - } else if (resource instanceof TypedLiteral) { + } else if (resource instanceof Literal) { value = doc.createElement("literal"); - value.appendChild(doc.createTextNode(((TypedLiteral) resource) + value.appendChild(doc.createTextNode(((Literal)resource) .getLexicalForm())); - value.setAttribute("datatype", (((TypedLiteral) resource) + value.setAttribute("datatype", (((Literal) resource) .getDataType().getUnicodeString())); - } else if (resource instanceof PlainLiteral) { - value = doc.createElement("literal"); - value.appendChild(doc.createTextNode(((PlainLiteral) resource) - .getLexicalForm())); - Language lang = ((PlainLiteral) resource).getLanguage(); + Language lang = ((Literal) resource).getLanguage(); if (lang != null) { value.setAttribute("xml:lang", (lang.toString())); } Modified: stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RECIPES.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RECIPES.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RECIPES.java (original) +++ stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RECIPES.java Tue May 17 22:20:49 2016 @@ -15,7 +15,7 @@ */ package org.apache.stanbol.commons.web.rdfviewable.writer; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; /** * Used ontologicaal terms from recipes ontology @@ -29,13 +29,13 @@ public final class RECIPES { */ private RECIPES() {} - public static final UriRef Recipe = new UriRef("http://vocab.netlabs.org/recipe#Recipe"); + public static final IRI Recipe = new IRI("http://vocab.netlabs.org/recipe#Recipe"); - public static final UriRef recipeDomain = new UriRef("http://vocab.netlabs.org/recipe#recipeDomain"); + public static final IRI recipeDomain = new IRI("http://vocab.netlabs.org/recipe#recipeDomain"); - public static final UriRef ingredient = new UriRef("http://vocab.netlabs.org/recipe#ingredient"); + public static final IRI ingredient = new IRI("http://vocab.netlabs.org/recipe#ingredient"); - public static final UriRef ingredientProperty = new UriRef("http://vocab.netlabs.org/recipe#ingredientProperty"); + public static final IRI ingredientProperty = new IRI("http://vocab.netlabs.org/recipe#ingredientProperty"); - public static final UriRef ingredientInverseProperty = new UriRef("http://vocab.netlabs.org/recipe#ingredientInverseProperty"); + public static final IRI ingredientInverseProperty = new IRI("http://vocab.netlabs.org/recipe#ingredientInverseProperty"); } Modified: stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RecipesGraphProvider.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RecipesGraphProvider.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RecipesGraphProvider.java (original) +++ stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/RecipesGraphProvider.java Tue May 17 22:20:49 2016 @@ -18,8 +18,8 @@ package org.apache.stanbol.commons.web.r import java.io.IOException; import java.net.URL; import java.util.Enumeration; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.TripleCollection; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Graph; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; import org.apache.felix.scr.annotations.Activate; @@ -27,7 +27,7 @@ import org.apache.felix.scr.annotations. import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Service; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; @@ -47,15 +47,15 @@ public class RecipesGraphProvider implem private static Logger log = LoggerFactory.getLogger(RecipesGraphProvider.class); - private MGraph recipesGraph = null; + private Graph recipesGraph = null; - public TripleCollection getRecipesGraph() { + public Graph getRecipesGraph() { return recipesGraph; } @Activate protected void activate(BundleContext context) { - recipesGraph = new IndexedMGraph(); + recipesGraph = new IndexedGraph(); context.addBundleListener(this); for (Bundle b : context.getBundles()) { if (b.getState() == Bundle.ACTIVE) { Modified: stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java (original) +++ stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/rdfviewable/writer/impl/RdfSerializingWriter.java Tue May 17 22:20:49 2016 @@ -34,13 +34,12 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.Triple; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; import org.apache.clerezza.rdf.core.serializedform.Serializer; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; import org.apache.clerezza.rdf.utils.GraphNode; @@ -113,17 +112,17 @@ public class RdfSerializingWriter implem this.uriInfo = uriInfo; } - private TripleCollection getExpandedContext(GraphNode node, GraphNode recipe) { - final TripleCollection result = new SimpleMGraph(node.getNodeContext()); - final Set<Resource> expandedResources = new HashSet<Resource>(); + private Graph getExpandedContext(GraphNode node, GraphNode recipe) { + final Graph result = new SimpleGraph(node.getNodeContext()); + final Set<RDFTerm> expandedResources = new HashSet<RDFTerm>(); expandedResources.add(node.getNode()); while (true) { - Set<Resource> additionalExpansionRes = getAdditionalExpansionResources(result, recipe); + Set<RDFTerm> additionalExpansionRes = getAdditionalExpansionResources(result, recipe); additionalExpansionRes.removeAll(expandedResources); if (additionalExpansionRes.size() == 0) { return result; } - for (Resource resource : additionalExpansionRes) { + for (RDFTerm resource : additionalExpansionRes) { final GraphNode additionalNode = new GraphNode(resource, node.getGraph()); result.addAll(additionalNode.getNodeContext()); expandedResources.add(resource); @@ -131,14 +130,14 @@ public class RdfSerializingWriter implem } } - private Set<Resource> getAdditionalExpansionResources(TripleCollection tc, GraphNode recipe) { - final Set<UriRef> subjectExpansionProperties = getSubjectExpansionProperties(recipe); - final Set<UriRef> objectExpansionProperties = getObjectExpansionProperties(recipe); - final Set<Resource> result = new HashSet<Resource>(); + private Set<RDFTerm> getAdditionalExpansionResources(Graph tc, GraphNode recipe) { + final Set<IRI> subjectExpansionProperties = getSubjectExpansionProperties(recipe); + final Set<IRI> objectExpansionProperties = getObjectExpansionProperties(recipe); + final Set<RDFTerm> result = new HashSet<RDFTerm>(); if ((subjectExpansionProperties.size() > 0) || (objectExpansionProperties.size() > 0)) { for (Triple triple : tc) { - final UriRef predicate = triple.getPredicate(); + final IRI predicate = triple.getPredicate(); if (subjectExpansionProperties.contains(predicate)) { result.add(triple.getSubject()); } @@ -150,44 +149,44 @@ public class RdfSerializingWriter implem return result; } - private Set<UriRef> getSubjectExpansionProperties(GraphNode recipe) { + private Set<IRI> getSubjectExpansionProperties(GraphNode recipe) { final MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(true); final List<String> paramValues = queryParams.get(SUBJ_EXP_PARAM); - final Set<UriRef> result = new HashSet<UriRef>(); + final Set<IRI> result = new HashSet<IRI>(); if (paramValues != null) { for (String uriString : paramValues) { - result.add(new UriRef(uriString)); + result.add(new IRI(uriString)); } } if (recipe != null) { Iterator<GraphNode> ingredients = recipe.getObjectNodes(RECIPES.ingredient); while (ingredients.hasNext()) { - Iterator<Resource> properties = + Iterator<RDFTerm> properties = ingredients.next().getObjects(RECIPES.ingredientInverseProperty); while (properties.hasNext()) { - result.add((UriRef)properties.next()); + result.add((IRI)properties.next()); } } } return result; } - private Set<UriRef> getObjectExpansionProperties(GraphNode recipe) { + private Set<IRI> getObjectExpansionProperties(GraphNode recipe) { final MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(true); final List<String> paramValues = queryParams.get(OBJ_EXP_PARAM); - final Set<UriRef> result = new HashSet<UriRef>(); + final Set<IRI> result = new HashSet<IRI>(); if (paramValues != null) { for (String uriString : paramValues) { - result.add(new UriRef(uriString)); + result.add(new IRI(uriString)); } } if (recipe != null) { Iterator<GraphNode> ingredients = recipe.getObjectNodes(RECIPES.ingredient); while (ingredients.hasNext()) { - Iterator<Resource> properties = + Iterator<RDFTerm> properties = ingredients.next().getObjects(RECIPES.ingredientProperty); while (properties.hasNext()) { - result.add((UriRef)properties.next()); + result.add((IRI)properties.next()); } } } @@ -196,7 +195,7 @@ public class RdfSerializingWriter implem } private GraphNode getRecipe(String templatePath) { - TripleCollection rg = recipesGraphProvider.getRecipesGraph(); + Graph rg = recipesGraphProvider.getRecipesGraph(); GraphNode literalNode = new GraphNode(new PlainLiteralImpl(templatePath), rg); Iterator<GraphNode> recipes = literalNode.getSubjectNodes(RECIPES.recipeDomain); if (recipes.hasNext()) { Modified: stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java (original) +++ stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java Tue May 17 22:20:49 2016 @@ -34,8 +34,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.Status; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.access.TcManager; import org.apache.clerezza.rdf.core.sparql.ParseException; import org.apache.felix.scr.annotations.Activate; @@ -53,7 +53,7 @@ import org.osgi.framework.ServiceReferen /** * This is the SPARQL endpoint which is used throughout the Stanbol. It uses {@link BundleContext} to retrive - * {@link TripleCollection} s registered to OSGi environment. To be able to execute SPARQL queries on triple + * {@link Graph} s registered to OSGi environment. To be able to execute SPARQL queries on triple * collections, they should be registered to the OSGi environment with the following parameters: * * <p> @@ -97,7 +97,7 @@ public class SparqlEndpointResource exte }*/ /** - * HTTP GET service to execute SPARQL queries on {@link TripleCollection}s registered to OSGi environment. + * HTTP GET service to execute SPARQL queries on {@link Graph}s registered to OSGi environment. * If a <code>null</code>, it is assumed that the request is coming from the HTML interface of SPARQL * endpoint. Otherwise the query is executed on the triple collection specified by <code>graphUri</code>. * But, if no graph uri is passed, then the triple collection having highest service.ranking value is @@ -120,19 +120,19 @@ public class SparqlEndpointResource exte @QueryParam(value = "query") String sparqlQuery, @Context HttpHeaders headers) throws InvalidSyntaxException { if (sparqlQuery == null) { - populateTripleCollectionList(getServices(null)); + populateGraphList(getServices(null)); return Response.ok(new Viewable("index", this), TEXT_HTML).build(); } String mediaType = "application/sparql-results+xml"; - TripleCollection tripleCollection = getTripleCollection(graphUri); + Graph tripleCollection = getGraph(graphUri); ResponseBuilder rb; if (tripleCollection != null) { Object result; try { result = tcManager.executeSparqlQuery(sparqlQuery, tripleCollection); - if (result instanceof TripleCollection) { + if (result instanceof Graph) { mediaType = "application/rdf+xml"; } rb = Response.ok(result, mediaType); @@ -148,7 +148,7 @@ public class SparqlEndpointResource exte } /** - * HTTP GET service to execute SPARQL queries on {@link TripleCollection}s registered to OSGi environment. + * HTTP GET service to execute SPARQL queries on {@link Graph}s registered to OSGi environment. * For details, see {@link #sparql(String, String, HttpHeaders)} */ @POST @@ -160,42 +160,42 @@ public class SparqlEndpointResource exte return sparql(graphUri, sparqlQuery, headers); } - private TripleCollection getTripleCollection(String graphUri) throws InvalidSyntaxException { - Map<ServiceReference,TripleCollection> services = getServices(graphUri); + private Graph getGraph(String graphUri) throws InvalidSyntaxException { + Map<ServiceReference,Graph> services = getServices(graphUri); if (services != null && services.size() > 0) { return services.get(services.keySet().iterator().next()); } return null; } - private void populateTripleCollectionList(Map<ServiceReference,TripleCollection> services) { + private void populateGraphList(Map<ServiceReference,Graph> services) { if (services != null) { for (ServiceReference service : services.keySet()) { Object graphUri = service.getProperty(GRAPH_URI); - if (service.getProperty(GRAPH_URI) instanceof UriRef) { - graphUri = ((UriRef) graphUri).getUnicodeString(); + if (service.getProperty(GRAPH_URI) instanceof IRI) { + graphUri = ((IRI) graphUri).getUnicodeString(); } Object graphName = service.getProperty("graph.name"); Object graphDescription = service.getProperty("graph.description"); if (graphUri instanceof String && graphName instanceof String && graphDescription instanceof String) { - tripleCollections.add(new TripleCollectionInfo((String) graphUri, (String) graphName, + tripleCollections.add(new GraphInfo((String) graphUri, (String) graphName, (String) graphDescription)); } } } } - private Map<ServiceReference,TripleCollection> getServices(String graphUri) throws InvalidSyntaxException { - Map<ServiceReference,TripleCollection> registeredGraphs = new LinkedHashMap<ServiceReference,TripleCollection>(); - ServiceReference[] refs = bundleContext.getServiceReferences(TripleCollection.class.getName(), + private Map<ServiceReference,Graph> getServices(String graphUri) throws InvalidSyntaxException { + Map<ServiceReference,Graph> registeredGraphs = new LinkedHashMap<ServiceReference,Graph>(); + ServiceReference[] refs = bundleContext.getServiceReferences(Graph.class.getName(), getFilter(graphUri)); if (refs != null) { if (refs.length > 1) { Arrays.sort(refs); } for (ServiceReference ref : refs) { - registeredGraphs.put(ref, (TripleCollection) bundleContext.getService(ref)); + registeredGraphs.put(ref, (Graph) bundleContext.getService(ref)); } } return registeredGraphs; @@ -211,7 +211,7 @@ public class SparqlEndpointResource exte filterString = new StringBuilder(); } filterString - .append(String.format(constraint, Constants.OBJECTCLASS, TripleCollection.class.getName())); + .append(String.format(constraint, Constants.OBJECTCLASS, Graph.class.getName())); if (graphUri != null) { filterString.append(')'); } @@ -222,18 +222,18 @@ public class SparqlEndpointResource exte * HTML View */ - private List<TripleCollectionInfo> tripleCollections = new ArrayList<SparqlEndpointResource.TripleCollectionInfo>(); + private List<GraphInfo> tripleCollections = new ArrayList<SparqlEndpointResource.GraphInfo>(); - public List<TripleCollectionInfo> getTripleCollectionList() { + public List<GraphInfo> getGraphList() { return this.tripleCollections; } - public class TripleCollectionInfo { + public class GraphInfo { private String graphUri; private String graphName; private String graphDescription; - public TripleCollectionInfo(String graphUri, String graphName, String graphDescription) { + public GraphInfo(String graphUri, String graphName, String graphDescription) { this.graphUri = graphUri; this.graphName = graphName != null ? graphName : ""; this.graphDescription = graphDescription != null ? graphDescription : "";
