You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/04/14 15:13:33 UTC
[58/87] [abbrv] clerezza git commit: CLEREZZA-989: All bundle and
components in linked data launchers satisfied, some runtime problems
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
index 3477bd2..5029eea 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
@@ -38,20 +38,19 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
+import org.apache.clerezza.rdf.core.LiteralFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.commons.rdf.Graph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-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.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
@@ -88,12 +87,12 @@ public class BackupMessageBodyWriter implements MessageBodyWriter<Backup> {
}
private void archive(ZipOutputStream compressedTcs,
- TripleCollection tripleCollection,
+ Graph tripleCollection,
String fileName) throws IOException, UnsupportedFormatException {
Lock readLock = null;
compressedTcs.putNextEntry(new ZipEntry(fileName));
- if (tripleCollection instanceof LockableMGraph) {
- readLock = ((LockableMGraph) tripleCollection).getLock().readLock();
+ if (tripleCollection instanceof Graph) {
+ readLock = ((Graph) tripleCollection).getLock().readLock();
readLock.lock();
}
try {
@@ -106,7 +105,7 @@ public class BackupMessageBodyWriter implements MessageBodyWriter<Backup> {
}
}
- private String getTcFileName(UriRef tcUri, String extension,
+ private String getTcFileName(Iri tcUri, String extension,
Map<String, Integer> fileNameCount) {
String fileName = tcUri.getUnicodeString();
fileName = fileName.substring(fileName.lastIndexOf("/")+1);
@@ -123,23 +122,23 @@ public class BackupMessageBodyWriter implements MessageBodyWriter<Backup> {
private void writeBackup(OutputStream result) {
Map<String, Integer> fileNameCount = new HashMap<String, Integer>();
- MGraph backupContents = new SimpleMGraph();
+ Graph backupContents = new SimpleGraph();
try {
ZipOutputStream compressedTcs = new ZipOutputStream(result);
compressedTcs.putNextEntry(new ZipEntry(folder));
- Set<UriRef> tripleCollections = tcManager.listTripleCollections();
- Iterator<UriRef> tcUriRefs = tripleCollections.iterator();
- while (tcUriRefs.hasNext()) {
- UriRef tcUri = tcUriRefs.next();
+ Set<Iri> tripleCollections = tcManager.listGraphs();
+ Iterator<Iri> tcIris = tripleCollections.iterator();
+ while (tcIris.hasNext()) {
+ Iri tcUri = tcIris.next();
String fileName = folder + getTcFileName(tcUri, ".nt",
fileNameCount);
- TripleCollection tripleCollection = tcManager.getTriples(tcUri);
+ Graph tripleCollection = tcManager.getGraph(tcUri);
archive(compressedTcs, tripleCollection, fileName);
- if (tripleCollection instanceof MGraph) {
+ if (tripleCollection instanceof Graph) {
backupContents.add(new TripleImpl(tcUri, RDF.type,
- BACKUP.MGraph));
+ BACKUP.Graph));
} else {
backupContents.add(new TripleImpl(tcUri, RDF.type,
BACKUP.Graph));
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
index 1cd7491..caf5d18 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
@@ -33,7 +33,7 @@ public class BackupPermission extends Permission {
public BackupPermission() {
- super("Graph Management permission");
+ super("ImmutableGraph Management permission");
}
/**
*
@@ -41,7 +41,7 @@ public class BackupPermission extends Permission {
* @param action ignored
*/
public BackupPermission(String target, String actions) {
- super("Graph Management permission");
+ super("ImmutableGraph Management permission");
}
@Override
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
index f08e5ce..c00bf1b 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
@@ -26,17 +26,17 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.clerezza.jaxrs.utils.RedirectUtil;
import org.apache.clerezza.platform.typerendering.RenderletManager;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Graph;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
import org.apache.clerezza.rdf.ontologies.FOAF;
import org.apache.clerezza.rdf.ontologies.OWL;
import org.apache.clerezza.rdf.ontologies.PLATFORM;
@@ -45,7 +45,7 @@ import org.apache.clerezza.rdf.utils.Smusher;
import org.osgi.service.component.ComponentContext;
/**
- * Provides a method to remove duplicate noded from (aka smush) a Graph
+ * Provides a method to remove duplicate noded from (aka smush) a ImmutableGraph
*
* @author reto
*/
@@ -60,8 +60,8 @@ public class Delete {
@POST
- public Response delete(@Context UriInfo uriInfo, @FormParam("graphName") UriRef graphName) {
- tcManager.deleteTripleCollection(graphName);
+ public Response delete(@Context UriInfo uriInfo, @FormParam("graphName") Iri graphName) {
+ tcManager.deleteGraph(graphName);
return RedirectUtil.createSeeOtherResponse("./", uriInfo);
}
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
index 118c6f1..886d1e7 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
@@ -33,18 +33,18 @@ import org.apache.clerezza.platform.globalmenu.GlobalMenuItem;
import org.apache.clerezza.platform.globalmenu.GlobalMenuItemsProvider;
import org.apache.clerezza.platform.typerendering.RenderletManager;
import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.ImmutableGraph;
import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.commons.rdf.Graph;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
import org.apache.clerezza.rdf.ontologies.PLATFORM;
import org.apache.clerezza.rdf.ontologies.RDF;
import org.apache.clerezza.rdf.ontologies.TCPROVIDER;
@@ -74,7 +74,7 @@ public class GraphManagement implements GlobalMenuItemsProvider {
protected void activate(ComponentContext componentContext) {
URL templateURL = getClass().getResource("graph-management.ssp");
renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
- new UriRef(templateURL.toString()), GRAPHMANAGEMENT.GraphManagementPage,
+ new Iri(templateURL.toString()), GRAPHMANAGEMENT.GraphManagementPage,
"naked", MediaType.APPLICATION_XHTML_XML_TYPE, true);
}
@@ -82,19 +82,19 @@ public class GraphManagement implements GlobalMenuItemsProvider {
public GraphNode mainPage(@Context UriInfo uriInfo) {
AccessController.checkPermission(new GraphManagementAppPermission());
TrailingSlash.enforcePresent(uriInfo);
- final SimpleMGraph resultGraph = new SimpleMGraph();
- GraphNode graphNode = new GraphNode(new BNode(), resultGraph);
- Set<UriRef> tripleCollections = tcManager.listTripleCollections();
- for (UriRef uriRef : tripleCollections) {
+ final SimpleGraph resultGraph = new SimpleGraph();
+ GraphNode graphNode = new GraphNode(new BlankNode(), resultGraph);
+ Set<Iri> tripleCollections = tcManager.listGraphs();
+ for (Iri uriRef : tripleCollections) {
graphNode.addProperty(GRAPHMANAGEMENT.tripleCollection, uriRef);
- final TripleCollection tripleCollection = tcManager.getTriples(uriRef);
+ final Graph tripleCollection = tcManager.getGraph(uriRef);
resultGraph.add(new TripleImpl(uriRef,GRAPHMANAGEMENT.size,
LiteralFactory.getInstance().createTypedLiteral(
tripleCollection.size())));
- if (tripleCollection instanceof Graph) {
+ if (tripleCollection instanceof ImmutableGraph) {
resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.Graph));
} else {
- resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.MGraph));
+ resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.Graph));
}
}
graphNode.addProperty(RDF.type, GRAPHMANAGEMENT.GraphManagementPage);
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
index 838879e..09ec04d 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
@@ -22,18 +22,18 @@ import java.security.Permission;
import org.apache.clerezza.permissiondescriptions.PermissionInfo;
/**
- * Permission to use the Graph-Management page. Nothe that the user
- * additioonally needs permssion on the TripleCollections they manipulate.
+ * Permission to use the ImmutableGraph-Management page. Nothe that the user
+ * additioonally needs permssion on the Graphs they manipulate.
*
* @author reto
*/
-@PermissionInfo(value="Graph Management Access Permission", description="Grants access " +
- "to the Graph Management page")
+@PermissionInfo(value="ImmutableGraph Management Access Permission", description="Grants access " +
+ "to the ImmutableGraph Management page")
public class GraphManagementAppPermission extends Permission {
public GraphManagementAppPermission() {
- super("Graph Management permission");
+ super("ImmutableGraph Management permission");
}
/**
*
@@ -41,7 +41,7 @@ public class GraphManagementAppPermission extends Permission {
* @param action ignored
*/
public GraphManagementAppPermission(String target, String actions) {
- super("Graph Management permission");
+ super("ImmutableGraph Management permission");
}
@Override
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
index 1096524..d0ceed7 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
@@ -32,13 +32,13 @@ import java.util.Iterator;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Literal;
import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcProvider;
import org.apache.clerezza.rdf.core.serializedform.Parser;
@@ -75,10 +75,10 @@ public class Restorer {
public void restore(InputStream backupData, TcProvider target) throws IOException {
ZipInputStream compressedTcs = new ZipInputStream(backupData);
- Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
+ Map<String, Graph> extractedTc = new HashMap<String, Graph>();
String folder = "";
ZipEntry entry;
- Graph metaGraph = null;
+ ImmutableGraph metaGraph = null;
while ((entry = compressedTcs.getNextEntry()) != null) {
String entryName = entry.getName();
if (entry.isDirectory()) {
@@ -109,7 +109,7 @@ public class Restorer {
metaGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
} else {
- Graph deserializedGraph = parser.parse(serializedGraph,
+ ImmutableGraph deserializedGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
extractedTc.put(entryName, deserializedGraph);
}
@@ -121,16 +121,16 @@ public class Restorer {
}
compressedTcs.close();
{
- final Iterator<Triple> mGraphIterator = metaGraph.filter(null, RDF.type, BACKUP.MGraph);
+ final Iterator<Triple> mGraphIterator = metaGraph.filter(null, RDF.type, BACKUP.Graph);
while (mGraphIterator.hasNext()) {
GraphNode graphGN = new GraphNode(mGraphIterator.next().getSubject(), metaGraph);
String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
- TripleCollection extracted = extractedTc.get(fileName);
+ Graph extracted = extractedTc.get(fileName);
- MGraph mGraph;
+ Graph mGraph;
boolean created = false;
try {
- mGraph = target.getMGraph((UriRef)graphGN.getNode());
+ mGraph = target.getGraph((Iri)graphGN.getNode());
try {
mGraph.clear();
} catch (UnsupportedOperationException ex) {
@@ -139,7 +139,7 @@ public class Restorer {
continue;
}
} catch (NoSuchEntityException ex) {
- mGraph = target.createMGraph((UriRef)graphGN.getNode());
+ mGraph = target.createGraph((Iri)graphGN.getNode());
created = true;
}
try {
@@ -156,9 +156,9 @@ public class Restorer {
while (graphIterator.hasNext()) {
GraphNode graphGN = new GraphNode(graphIterator.next().getSubject(), metaGraph);
String fileName = graphGN.getLiterals(BACKUP.file).next().getLexicalForm();
- TripleCollection extracted = extractedTc.get(fileName);
+ Graph extracted = extractedTc.get(fileName);
try {
- target.deleteTripleCollection((UriRef)graphGN.getNode());
+ target.deleteGraph((Iri)graphGN.getNode());
} catch (UnsupportedOperationException ex) {
log.warn("could not restore "+graphGN.getNode()+" as the exsting triple "
+ "collection could not be deleted");
@@ -166,10 +166,10 @@ public class Restorer {
} catch (NoSuchEntityException ex) {
log.debug("could not remove "+graphGN.getNode()+", no such entity");
}
- target.createGraph((UriRef)graphGN.getNode(), extracted);
+ target.createImmutableGraph((Iri)graphGN.getNode(), extracted);
}
}
- for (Map.Entry<String, TripleCollection> pathTcPair : extractedTc.entrySet()) {
+ for (Map.Entry<String, Graph> pathTcPair : extractedTc.entrySet()) {
Literal fileNameLit = LiteralFactory.getInstance().createTypedLiteral(
pathTcPair.getKey());
Iterator<Triple> graphResIterator = metaGraph.filter(null, BACKUP.file, fileNameLit);
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
index 9db6c04..f3678a7 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
@@ -45,16 +45,15 @@ import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-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.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.TcManager;
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;
+import org.apache.commons.rdf.Literal;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -154,33 +153,29 @@ public class ResultSetMessageBodyWriter implements MessageBodyWriter<ResultSet>
/**
- * Helper: creates value element from {@link Resource} depending on its
+ * Helper: creates value element from {@link RdfTerm} depending on its
* class
*
*/
- private Element createValueElement(Resource resource, Document doc) {
+ private Element createValueElement(RdfTerm resource, Document doc) {
Element value = null;
- 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()));
}
} else {
value = doc.createElement("bnode");
- value.appendChild(doc.createTextNode(((BNode) resource).toString()));
+ value.appendChild(doc.createTextNode(((BlankNode) resource).toString()));
}
return value;
}
@@ -197,7 +192,7 @@ public class ResultSetMessageBodyWriter implements MessageBodyWriter<ResultSet>
Element bindingElement = doc.createElement("binding");
bindingElement.setAttribute("name", key.getName());
bindingElement.appendChild(createValueElement(
- (Resource) solutionMap.get(key), doc));
+ (RdfTerm) solutionMap.get(key), doc));
result.appendChild(bindingElement);
}
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
index 98e125a..fa29fde 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
@@ -26,17 +26,16 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.clerezza.jaxrs.utils.RedirectUtil;
import org.apache.clerezza.platform.typerendering.RenderletManager;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.commons.rdf.Graph;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
import org.apache.clerezza.rdf.ontologies.FOAF;
import org.apache.clerezza.rdf.ontologies.OWL;
import org.apache.clerezza.rdf.ontologies.PLATFORM;
@@ -45,7 +44,7 @@ import org.apache.clerezza.rdf.utils.Smusher;
import org.osgi.service.component.ComponentContext;
/**
- * Provides a method to remove duplicate noded from (aka smush) a Graph
+ * Provides a method to remove duplicate noded from (aka smush) a ImmutableGraph
*
* @author reto
*/
@@ -54,7 +53,7 @@ import org.osgi.service.component.ComponentContext;
@Property(name="javax.ws.rs", boolValue=true)
@Path("/admin/graphs/smush")
public class Smush {
- private final UriRef tBoxName = new UriRef("urn:x-localinstance:/tbox.graph");
+ private final Iri tBoxName = new Iri("urn:x-localinstance:/tbox.graph");
@Reference
private TcManager tcManager;
@@ -62,27 +61,27 @@ public class Smush {
@Reference
private RenderletManager renderletManager;
- private TripleCollection tBox;
+ private Graph tBox;
protected void activate(ComponentContext componentContext) {
try {
//getting the tBox here means no read right on Tbox is necessary
//when smushing
- tBox = tcManager.getTriples(tBoxName);
+ tBox = tcManager.getGraph(tBoxName);
} catch (NoSuchEntityException e) {
- tBox = new SimpleMGraph();
+ tBox = new SimpleGraph();
tBox.add(new TripleImpl(FOAF.mbox, RDF.type, OWL.InverseFunctionalProperty));
tBox.add(new TripleImpl(FOAF.mbox_sha1sum, RDF.type, OWL.InverseFunctionalProperty));
tBox.add(new TripleImpl(PLATFORM.userName, RDF.type, OWL.InverseFunctionalProperty));
- tBox = tcManager.createGraph(tBoxName, tBox);
+ tBox = tcManager.createImmutableGraph(tBoxName, tBox);
}
}
@POST
- public Response smush(@Context UriInfo uriInfo, @FormParam("graphName") UriRef graphName) {
- MGraph mGraph = tcManager.getMGraph(graphName);
+ public Response smush(@Context UriInfo uriInfo, @FormParam("graphName") Iri graphName) {
+ Graph mGraph = tcManager.getGraph(graphName);
Smusher.smush(mGraph, tBox);
return RedirectUtil.createSeeOtherResponse("./", uriInfo);
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
index 59f6e46..69f318f 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
@@ -61,18 +61,16 @@ import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPa
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Language;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
import org.apache.clerezza.rdf.core.sparql.ParseException;
import org.apache.clerezza.rdf.core.sparql.QueryParser;
import org.apache.clerezza.rdf.core.sparql.ResultSet;
@@ -83,6 +81,7 @@ import org.apache.clerezza.rdf.core.sparql.query.Variable;
import org.apache.clerezza.rdf.ontologies.RDF;
import org.apache.clerezza.rdf.utils.GraphNode;
import org.apache.clerezza.rdf.web.ontologies.SPARQLENDPOINT;
+import org.apache.commons.rdf.Literal;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.ProcessingInstruction;
@@ -115,18 +114,18 @@ public class SparqlEndpoint {
protected void activate(ComponentContext componentContext) {
URL templateURL = getClass().getResource("sparql-endpoint.ssp");
renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
- new UriRef(templateURL.toString()), SPARQLENDPOINT.SparqlEndpoint,
+ new Iri(templateURL.toString()), SPARQLENDPOINT.SparqlEndpoint,
null, MediaType.APPLICATION_XHTML_XML_TYPE, true);
}
@GET
@Path("form")
- public GraphNode getAvailableTripleCollectionUris(@Context UriInfo uriInfo) {
+ public GraphNode getAvailableGraphUris(@Context UriInfo uriInfo) {
AccessController.checkPermission(new SparqlEndpointAccessPermission());
TrailingSlash.enforceNotPresent(uriInfo);
- GraphNode graphNode = new GraphNode(new BNode(), new SimpleMGraph());
- Set<UriRef> tripleCollections = tcManager.listTripleCollections();
- for (UriRef uriRef : tripleCollections) {
+ GraphNode graphNode = new GraphNode(new BlankNode(), new SimpleGraph());
+ Set<Iri> tripleCollections = tcManager.listGraphs();
+ for (Iri uriRef : tripleCollections) {
graphNode.addProperty(SPARQLENDPOINT.tripleCollection, uriRef);
}
graphNode.addProperty(RDF.type, SPARQLENDPOINT.SparqlEndpoint);
@@ -134,7 +133,7 @@ public class SparqlEndpoint {
}
/**
- * Returns either a {@link Graph} or a {@link DOMSource}. A {@link Graph} is
+ * Returns either a {@link ImmutableGraph} or a {@link DOMSource}. A {@link ImmutableGraph} is
* returned if a CONSTRUCT or a DESCRIBE sparql query was submitted and
* successfully carried out. A {@link DOMSource} is returned if an ASK or a
* SELECT sparql query was submitted and successfully carried out. The query
@@ -144,15 +143,15 @@ public class SparqlEndpoint {
* @param queryString
* URL encoded sparql query
* @param defaultGraphUri
- * URI of the default graph, an {@link UriRef} is expected
+ * URI of the default graph, an {@link Iri} is expected
* @param applyStyleSheet
* @param serverSide
* @param styleSheetUri
- * @return either a {@link Graph} or a {@link DOMSource}
+ * @return either a {@link ImmutableGraph} or a {@link DOMSource}
*/
@POST
public Object runFormQuery(@FormParam("query") String queryString,
- @FormParam("default-graph-uri") UriRef defaultGraphUri,
+ @FormParam("default-graph-uri") Iri defaultGraphUri,
@FormParam("apply-style-sheet") String applyStyleSheet,
@FormParam("server-side") String serverSide,
@FormParam("style-sheet-uri") String styleSheetUri) {
@@ -170,12 +169,12 @@ public class SparqlEndpoint {
} else {
applyServerSide = false;
}
- //TripleCollection defaultGraph = null;
+ //Graph defaultGraph = null;
Object result = null;
try {
if (defaultGraphUri == null
|| defaultGraphUri.getUnicodeString().equals("")) {
- defaultGraphUri = new UriRef(Constants.CONTENT_GRAPH_URI_STRING);
+ defaultGraphUri = new Iri(Constants.CONTENT_GRAPH_URI_STRING);
//defaultGraph = contentGraph;
} else {
//defaultGraph = tcManager.getTriples(defaultGraphUri);
@@ -184,8 +183,8 @@ public class SparqlEndpoint {
//TODO use ResultSet.getResultVars instead
Query query = QueryParser.getInstance().parse(queryString);
result = tcManager.executeSparqlQuery(queryString, defaultGraphUri);
- if (result instanceof Graph) {
- return (Graph) result;
+ if (result instanceof ImmutableGraph) {
+ return (ImmutableGraph) result;
} else if ((result instanceof ResultSet)
|| (result instanceof Boolean)) {
Source source = toXmlSource(result, query, applyStyle,
@@ -199,7 +198,7 @@ public class SparqlEndpoint {
} else {
throw new WebApplicationException(
Response.status(Status.BAD_REQUEST).entity("Only " +
- "queries yielding to a Graph, a ResultSet or " +
+ "queries yielding to a ImmutableGraph, a ResultSet or " +
"Boolean are supported").build());
}
} catch (ParseException e) {
@@ -210,7 +209,7 @@ public class SparqlEndpoint {
}
/**
- * Returns either a {@link Graph} or a {@link DOMSource}. A {@link Graph} is
+ * Returns either a {@link ImmutableGraph} or a {@link DOMSource}. A {@link ImmutableGraph} is
* returned if a CONSTRUCT or a DESCRIBE sparql query was submitted and
* successfully carried out. A {@link DOMSource} is returned if an ASK or a
* SELECT sparql query was submitted and successfully carried out. The query
@@ -225,7 +224,7 @@ public class SparqlEndpoint {
*/
@GET
public Object runGetQuery(@QueryParam("query") String queryString,
- @QueryParam("default-graph-uri") UriRef defaultGraphUri,
+ @QueryParam("default-graph-uri") Iri defaultGraphUri,
@QueryParam("style-sheet-uri") String styleSheetUri,
@QueryParam("server-side") String serverSide) {
AccessController.checkPermission(new SparqlEndpointAccessPermission());
@@ -375,7 +374,7 @@ public class SparqlEndpoint {
Element bindingElement = doc.createElement("binding");
bindingElement.setAttribute("name", key.getName());
bindingElement.appendChild(createValueElement(
- (Resource) solutionMap.get(key), doc));
+ (RdfTerm) solutionMap.get(key), doc));
result.appendChild(bindingElement);
}
}
@@ -383,33 +382,29 @@ public class SparqlEndpoint {
}
/**
- * Helper: creates value element from {@link Resource} depending on its
+ * Helper: creates value element from {@link RdfTerm} depending on its
* class
*
*/
- private Element createValueElement(Resource resource, Document doc) {
+ private Element createValueElement(RdfTerm resource, Document doc) {
Element value = null;
- 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()));
}
} else {
value = doc.createElement("bnode");
- value.appendChild(doc.createTextNode(((BNode) resource).toString()));
+ value.appendChild(doc.createTextNode(((BlankNode) resource).toString()));
}
return value;
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
index 8a95484..6a71c01 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
@@ -43,14 +43,13 @@ import org.apache.felix.scr.annotations.Service;
import org.apache.clerezza.jaxrs.utils.RedirectUtil;
import org.apache.clerezza.jaxrs.utils.form.FormFile;
import org.apache.clerezza.jaxrs.utils.form.MultiPartBody;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-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.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.clerezza.rdf.core.serializedform.Parser;
@@ -77,13 +76,13 @@ public class WebAccess {
final Logger logger = LoggerFactory.getLogger(WebAccess.class);
/**
- * Gets the TripleCollection with specified name
+ * Gets the Graph with specified name
*
* @param name
* @return
*/
@GET
- public TripleCollection getTriples(@QueryParam("name") UriRef name) {
+ public Graph getTriples(@QueryParam("name") Iri name) {
AccessController.checkPermission(new WebAccessPermission());
if (name == null) {
Response r = Response.status(Response.Status.BAD_REQUEST)
@@ -91,7 +90,7 @@ public class WebAccess {
.type(MediaType.TEXT_PLAIN_TYPE).build();
throw new WebApplicationException(r);
}
- TripleCollection result = tcManager.getTriples(name);
+ Graph result = tcManager.getGraph(name);
logger.debug("Got graph of size {} ", result.size());
int i = 1;
if (logger.isDebugEnabled()) {
@@ -104,8 +103,8 @@ public class WebAccess {
}
/**
- * Puts the triples replacing the triples of the existing MGraph with the
- * specified name. If the graph doesn't exist creates a new <code>MGraph</code>
+ * Puts the triples replacing the triples of the existing Graph with the
+ * specified name. If the graph doesn't exist creates a new <code>Graph</code>
* with the specified name and puts the triples
*
*
@@ -113,13 +112,13 @@ public class WebAccess {
* @param triples
*/
@PUT
- public void putTriples(@QueryParam("name") UriRef name, TripleCollection triples) {
+ public void putTriples(@QueryParam("name") Iri name, Graph triples) {
AccessController.checkPermission(new WebAccessPermission());
- LockableMGraph mGraph;
+ Graph mGraph;
try {
- mGraph = tcManager.getMGraph(name);
+ mGraph = tcManager.getGraph(name);
} catch (NoSuchEntityException e) {
- mGraph = tcManager.createMGraph(name);
+ mGraph = tcManager.createGraph(name);
}
Lock writeLock = mGraph.getLock().writeLock();
writeLock.lock();
@@ -132,18 +131,18 @@ public class WebAccess {
}
/**
- * Posts triples to be placed into an {@link MGraph} of the specified name.
- * If an {@link MGraph} with this name doesn't already exist, a new one
+ * Posts triples to be placed into an {@link Graph} of the specified name.
+ * If an {@link Graph} with this name doesn't already exist, a new one
* is created and filled with the triples posted.
* @param form
* a multipart/form-data consisting of:
* - a {@link FormFile} labeled "graph" containing the triples and
* the mime-type.
- * - a text field labeled "name" specifying the name of the MGraph.
+ * - a text field labeled "name" specifying the name of the Graph.
* - an optional text field labeled "mode" specifying the mode.
- * If the mode is "replace", existing triples of the MGraph will be
+ * If the mode is "replace", existing triples of the Graph will be
* deleted before new triples are added. If the mode is not
- * specified or is "append", posted triples are added to the MGraph.
+ * specified or is "append", posted triples are added to the Graph.
* - an optional text field labeled "redirection" specifying an URI
* which the client should be redirected to in case of success.
* @return
@@ -152,9 +151,9 @@ public class WebAccess {
* satisfied, one of the following responses is returned:
* - SEE OTHER (303), if redirection is specified.
* - CREATED (201), if redirection is not specified and a new
- * {@link MGraph} is created.
+ * {@link Graph} is created.
* - NO CONTENT (204), if redirection is not specified and no new
- * {@link MGraph} is created.
+ * {@link Graph} is created.
*/
@POST
@Consumes("multipart/form-data")
@@ -193,14 +192,14 @@ public class WebAccess {
mode = "append";
}
InputStream is = new ByteArrayInputStream(graph);
- Graph parsedGraph = parser.parse(is, mediaType.toString());
- UriRef graphUri = new UriRef(graphName);
- LockableMGraph mGraph;
+ ImmutableGraph parsedGraph = parser.parse(is, mediaType.toString());
+ Iri graphUri = new Iri(graphName);
+ Graph mGraph;
boolean newGraph = false;
try {
- mGraph = tcManager.getMGraph(graphUri);
+ mGraph = tcManager.getGraph(graphUri);
} catch (NoSuchEntityException e) {
- mGraph = tcManager.createMGraph(graphUri);
+ mGraph = tcManager.createGraph(graphUri);
newGraph = true;
}
Lock writeLock = mGraph.getLock().writeLock();
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
index d922d78..8964eda 100644
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
+++ b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
@@ -23,17 +23,17 @@ import java.security.Permission;
import org.apache.clerezza.permissiondescriptions.PermissionInfo;
/**
- * Permission to use the Graph via Web. Note that the user
+ * Permission to use the ImmutableGraph via Web. Note that the user
* additionally needs permission to read a graph.
*
* @author mir
*/
-@PermissionInfo(value="Graph via Web Access Permission", description="Grants access " +
- "to the Graph via Web")
+@PermissionInfo(value="ImmutableGraph via Web Access Permission", description="Grants access " +
+ "to the ImmutableGraph via Web")
public class WebAccessPermission extends Permission{
public WebAccessPermission() {
- super("Graph via Web access permission");
+ super("ImmutableGraph via Web access permission");
}
/**
*
@@ -41,7 +41,7 @@ public class WebAccessPermission extends Permission{
* @param action ignored
*/
public WebAccessPermission(String target, String actions) {
- super("Graph via Web access permission");
+ super("ImmutableGraph via Web access permission");
}
@Override
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java b/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
index 6419460..a43a6a2 100644
--- a/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
+++ b/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
@@ -29,17 +29,16 @@ import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
import org.apache.clerezza.rdf.core.serializedform.Parser;
import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
import org.apache.clerezza.rdf.core.serializedform.Serializer;
@@ -48,6 +47,7 @@ import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
import org.apache.clerezza.rdf.jena.serializer.JenaSerializerProvider;
import org.apache.clerezza.rdf.ontologies.RDF;
import org.apache.clerezza.rdf.web.ontologies.BACKUP;
+import org.apache.commons.rdf.Literal;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Before;
@@ -62,25 +62,25 @@ public class BackupAndRestoreTest {
private static String testGraphFileName = "test.graph";
- private static MGraph testMGraph0 = new SimpleMGraph();
- private static UriRef testMGraphUri0 = // the URI of testMGraph0
- new UriRef("http://localhost/test0/"+testGraphFileName);
- // a resource in testMGraph0
- private static UriRef uri0 = new UriRef("http://localhost/test0/testuri");
+ private static Graph testGraph0 = new SimpleGraph();
+ private static Iri testGraphUri0 = // the URI of testGraph0
+ new Iri("http://localhost/test0/"+testGraphFileName);
+ // a resource in testGraph0
+ private static Iri uri0 = new Iri("http://localhost/test0/testuri");
- private static MGraph testMGraph1 = new SimpleMGraph();
- private static UriRef testMGraphUri1 = // the URI of testMGraph1
- new UriRef("http://localhost/test1/"+testGraphFileName);
+ private static Graph testGraph1 = new SimpleGraph();
+ private static Iri testGraphUri1 = // the URI of testGraph1
+ new Iri("http://localhost/test1/"+testGraphFileName);
- // a resource in testMGraph1
- private static UriRef uri1 = new UriRef("http://localhost/test1/testuri");
+ // a resource in testGraph1
+ private static Iri uri1 = new Iri("http://localhost/test1/testuri");
- private static Graph testGraphA;
- private static UriRef testGraphUriA = // the URI of testGraphA
- new UriRef("http://localhost/testA/"+testGraphFileName);
+ private static ImmutableGraph testGraphA;
+ private static Iri testGraphUriA = // the URI of testGraphA
+ new Iri("http://localhost/testA/"+testGraphFileName);
// a resource in testGraphA
- private static UriRef uriA = new UriRef("http://localhost/testA/testuri");
+ private static Iri uriA = new Iri("http://localhost/testA/testuri");
private static String backupContentFileName = "triplecollections.nt";
@@ -94,24 +94,24 @@ public class BackupAndRestoreTest {
backup.serializer = Serializer.getInstance();
backup.serializer.bindSerializingProvider(
new JenaSerializerProvider());
- testMGraph0.add(new TripleImpl(uri0, uri0, uri0));
- testMGraph1.add(new TripleImpl(uri1, uri1, uri1));
- MGraph graphBuilder = new SimpleMGraph();
+ testGraph0.add(new TripleImpl(uri0, uri0, uri0));
+ testGraph1.add(new TripleImpl(uri1, uri1, uri1));
+ Graph graphBuilder = new SimpleGraph();
graphBuilder.add(new TripleImpl(uriA, uriA, uriA));
- testGraphA = graphBuilder.getGraph();
+ testGraphA = graphBuilder.getImmutableGraph();
}
@Test
public void testBackup() throws IOException {
- //Graph downloadedTestGraphX = null;
- //Graph downloadedTestGraphY = null;
- Graph downloadedBackupContentsGraph = null;
+ //ImmutableGraph downloadedTestGraphX = null;
+ //ImmutableGraph downloadedTestGraphY = null;
+ ImmutableGraph downloadedBackupContentsGraph = null;
byte[] download = backup.createBackup();
ByteArrayInputStream bais = new ByteArrayInputStream(download);
ZipInputStream compressedTcs = new ZipInputStream(bais);
- Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
+ Map<String, Graph> extractedTc = new HashMap<String, Graph>();
String folder = "";
ZipEntry entry;
while ((entry = compressedTcs.getNextEntry()) != null) {
@@ -140,7 +140,7 @@ public class BackupAndRestoreTest {
downloadedBackupContentsGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
} else {
- Graph deserializedGraph = parser.parse(serializedGraph,
+ ImmutableGraph deserializedGraph = parser.parse(serializedGraph,
SupportedFormat.N_TRIPLE, null);
extractedTc.put(entryName, deserializedGraph);
}
@@ -157,13 +157,13 @@ public class BackupAndRestoreTest {
public void restoreFromBackup() throws IOException {
byte[] backupData = backup.createBackup();
TcProvider tcProvider = EasyMock.createMock(TcProvider.class);
- EasyMock.expect(tcProvider.getMGraph(testMGraphUri0)).andReturn(
- EasyMock.createNiceMock(MGraph.class));
- EasyMock.expect(tcProvider.getMGraph(testMGraphUri1)).andReturn(
- EasyMock.createNiceMock(MGraph.class));
- tcProvider.deleteTripleCollection(testGraphUriA);
- EasyMock.expect(tcProvider.createGraph(EasyMock.eq(testGraphUriA),
- EasyMock.notNull(TripleCollection.class))).andReturn(new SimpleMGraph().getGraph());
+ EasyMock.expect(tcProvider.getGraph(testGraphUri0)).andReturn(
+ EasyMock.createNiceMock(Graph.class));
+ EasyMock.expect(tcProvider.getGraph(testGraphUri1)).andReturn(
+ EasyMock.createNiceMock(Graph.class));
+ tcProvider.deleteGraph(testGraphUriA);
+ EasyMock.expect(tcProvider.createImmutableGraph(EasyMock.eq(testGraphUriA),
+ EasyMock.notNull(Graph.class))).andReturn(new SimpleGraph().getImmutableGraph());
EasyMock.replay(tcProvider);
Restorer restore = new Restorer();
restore.parser = Parser.getInstance();
@@ -171,36 +171,36 @@ public class BackupAndRestoreTest {
EasyMock.verify(tcProvider);
}
- private void checkDownloadedGraphs(Map<String, TripleCollection> extractedTc,
- Graph downloadedBackupContentsGraph, String folder) {
+ private void checkDownloadedGraphs(Map<String, Graph> extractedTc,
+ ImmutableGraph downloadedBackupContentsGraph, String folder) {
Assert.assertFalse(extractedTc.isEmpty());
Assert.assertNotNull(downloadedBackupContentsGraph);
Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
- testMGraphUri0, RDF.type, BACKUP.MGraph)));
+ testGraphUri0, RDF.type, BACKUP.Graph)));
Iterator<Triple> triples = downloadedBackupContentsGraph.filter(
- testMGraphUri0, BACKUP.file, null);
+ testGraphUri0, BACKUP.file, null);
Assert.assertTrue(triples.hasNext());
- String fileName0 = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
+ String fileName0 = ((Literal) triples.next().getObject()).getLexicalForm();
Assert.assertTrue(fileName0.startsWith(folder+testGraphFileName));
- TripleCollection extracted0 = extractedTc.get(fileName0);
+ Graph extracted0 = extractedTc.get(fileName0);
Assert.assertNotNull(extracted0);
Assert.assertTrue(extracted0.filter(uri0, uri0, uri0).hasNext());
Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
- testMGraphUri1, RDF.type, BACKUP.MGraph)));
+ testGraphUri1, RDF.type, BACKUP.Graph)));
triples = downloadedBackupContentsGraph.filter(
- testMGraphUri1, BACKUP.file, null);
+ testGraphUri1, BACKUP.file, null);
Assert.assertTrue(triples.hasNext());
- String fileName1 = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
+ String fileName1 = ((Literal) triples.next().getObject()).getLexicalForm();
Assert.assertTrue(fileName1.startsWith(folder+testGraphFileName));
- TripleCollection extracted1 = extractedTc.get(fileName1);
+ Graph extracted1 = extractedTc.get(fileName1);
Assert.assertNotNull(extracted1);
Assert.assertTrue(extracted1.filter(uri1, uri1, uri1).hasNext());
@@ -214,9 +214,9 @@ public class BackupAndRestoreTest {
testGraphUriA, BACKUP.file, null);
Assert.assertTrue(triples.hasNext());
- String fileNameA = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
+ String fileNameA = ((Literal) triples.next().getObject()).getLexicalForm();
Assert.assertTrue(fileNameA.startsWith(folder+testGraphFileName));
- TripleCollection extractedA = extractedTc.get(fileNameA);
+ Graph extractedA = extractedTc.get(fileNameA);
Assert.assertNotNull(extractedA);
Assert.assertTrue(extractedA.filter(uriA, uriA, uriA).hasNext());
@@ -225,13 +225,13 @@ public class BackupAndRestoreTest {
private class TestTcManager extends TcManager {
- // Associates testGraphUri0 with testMGraph0 and testGraphUri1 with testGraph1
+ // Associates testGraphUri0 with testGraph0 and testGraphUri1 with testGraph1
@Override
- public TripleCollection getTriples(UriRef name) throws NoSuchEntityException {
- if (name.equals(testMGraphUri0)) {
- return testMGraph0;
- } else if (name.equals(testMGraphUri1)) {
- return testMGraph1;
+ public Graph getGraph(Iri name) throws NoSuchEntityException {
+ if (name.equals(testGraphUri0)) {
+ return testGraph0;
+ } else if (name.equals(testGraphUri1)) {
+ return testGraph1;
} else if (name.equals(testGraphUriA)) {
return testGraphA;
}
@@ -239,10 +239,10 @@ public class BackupAndRestoreTest {
}
@Override
- public Set<UriRef> listTripleCollections() {
- Set<UriRef> result = new HashSet<UriRef>();
- result.add(testMGraphUri0);
- result.add(testMGraphUri1);
+ public Set<Iri> listGraphs() {
+ Set<Iri> result = new HashSet<Iri>();
+ result.add(testGraphUri0);
+ result.add(testGraphUri1);
result.add(testGraphUriA);
return result;
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf.web/rdf.web.ontologies/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.ontologies/pom.xml b/rdf.web/rdf.web.ontologies/pom.xml
index 4585475..1713a43 100644
--- a/rdf.web/rdf.web.ontologies/pom.xml
+++ b/rdf.web/rdf.web.ontologies/pom.xml
@@ -23,8 +23,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.web</artifactId>
- <version>0.10</version>
+ <artifactId>clerezza</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath />
</parent>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.web.ontologies</artifactId>
@@ -36,7 +37,7 @@
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.core</artifactId>
- <version>0.14</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
@@ -58,7 +59,7 @@
</goals>
</execution>
</executions>
- <version>0.3-incubating</version>
+ <version>1.0.0-SNAPSHOT</version>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf/jena/parser/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/parser/pom.xml b/rdf/jena/parser/pom.xml
index 90572ad..d682f94 100644
--- a/rdf/jena/parser/pom.xml
+++ b/rdf/jena/parser/pom.xml
@@ -70,7 +70,11 @@
</dependency>
</dependencies>
<build>
- <plugins>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf/jena/serializer/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/serializer/pom.xml b/rdf/jena/serializer/pom.xml
index 9555624..1de87ce 100644
--- a/rdf/jena/serializer/pom.xml
+++ b/rdf/jena/serializer/pom.xml
@@ -33,6 +33,14 @@
<version>1.0.0-SNAPSHOT</version>
<name>Clerezza - RDF - Jena - Serializer</name>
<description>A SerializingProvider based on jena</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencyManagement>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf/jena/tdb.storage/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/jena/tdb.storage/pom.xml b/rdf/jena/tdb.storage/pom.xml
index 11d054d..5fc86ef 100644
--- a/rdf/jena/tdb.storage/pom.xml
+++ b/rdf/jena/tdb.storage/pom.xml
@@ -31,6 +31,14 @@
<version>1.0.0-SNAPSHOT</version>
<name>Clerezza - RDF - Jena - TDB Storage Provider</name>
<description>A Jena TDB based storage provider</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencyManagement>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/c8c34941/rdf/jena/tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/TdbTcProvider.java
----------------------------------------------------------------------
diff --git a/rdf/jena/tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/TdbTcProvider.java b/rdf/jena/tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/TdbTcProvider.java
index d50ef64..c9733ff 100644
--- a/rdf/jena/tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/TdbTcProvider.java
+++ b/rdf/jena/tdb.storage/src/main/java/org/apache/clerezza/rdf/jena/tdb/storage/TdbTcProvider.java
@@ -324,8 +324,8 @@ public class TdbTcProvider implements WeightedTcProvider {
@Override
public Set<Iri> listGraphs() {
Set<Iri> result = new HashSet<Iri>();
- result.addAll(listGraphs());
- result.addAll(listGraphs());
+ result.addAll(listMGraphs());
+ result.addAll(listImmutableGraphs());
return result;
}