[Mulgara-svn] r1254 - in trunk/src/jar: content-rdfxml/java/org/mulgara/content/rdfxml/writer query/java/org/mulgara/query/operation query/java/org/mulgara/server querylang/java/org/mulgara/itql resolver/java/org/mulgara/resolver server-rmi/java/org/mulgara/server/rmi
alexhall at mulgara.org
alexhall at mulgara.org
Mon Sep 8 18:11:25 UTC 2008
Author: alexhall
Date: 2008-09-08 11:11:24 -0700 (Mon, 08 Sep 2008)
New Revision: 1254
Modified:
trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/NamespaceMap.java
trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java
trunk/src/jar/query/java/org/mulgara/query/operation/Export.java
trunk/src/jar/query/java/org/mulgara/server/Session.java
trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
Log:
Added the capability to include a set of user-supplied namespace definitions in an exported RDF/XML file. This does not change the actual content of the exported RDF/XML, only its presentation.
It is anticipated that this feature may be useful for users working with external tools (such as Protege) that use the RDF/XML namespace definitions to create human-readable prefixed URI's for display purposes.
The ability to define namespace prefixes in the XML is exposed to the client in two ways:
1. Programatically via the new setNamespacePrefixes method in the Export command.
2. Through the TQL shell "alias" command - the TqlInterpreter adds any aliases that it knows about to the namespace definitions in the Export command.
Modified: trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/NamespaceMap.java
===================================================================
--- trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/NamespaceMap.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/NamespaceMap.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -73,6 +73,9 @@
/** A mirror of this map (where keys and values are swapped) */
private Map<String,String> mirror = null;
+
+ /** A mapping of user-supplied namespace URI to prefix string */
+ private Map<String,String> userPrefixes = null;
/** Prefix used to abbreviate RDF Namespace */
private static final String RDF_PREFIX = "rdf";
@@ -96,10 +99,12 @@
/**
* Constructor. Pre-populates the map with prefixes for a set of default namespaces
* (RDF, RDFS, OWL, DC), and adds a set of user-defined initial namespace prefixes.
- * Any initial prefix mapping which attempts to redefine a default namespace prefix, or which
+ * Any initial prefix mapping which attempts to redefine a default namespace or prefix, or which
* contains a prefix that is not a valid XML NCName, will be ignored. It then populates
* the map with generated prefixes for all unique namespaces in the statements that do not
- * match a default or initial namespace prefix mapping.
+ * match a default or initial namespace prefix mapping. User-supplied namespace prefixes
+ * that do not appear in the statements will not appear in the RDF/XML. The default namespace may
+ * be defined by including an initial mapping for the empty prefix in the namespace map.
*
* @param statements The statements which will be parsed for namespaces.
* @param session The session used to globalize statement URI's.
@@ -117,7 +122,7 @@
put("dc", "http://purl.org/dc/elements/1.1/");
if (initialPrefixes != null) {
- prePopulate(initialPrefixes);
+ userPrefixes = validateUserPrefixes(initialPrefixes);
}
//read namespaces from the statements
@@ -136,18 +141,46 @@
* already been defined will be ignored.
* @param existingMap A mapping of prefix to namespace URI.
*/
- protected void prePopulate(Map<String,URI> existingMap) {
+ private Map<String,String> validateUserPrefixes(Map<String,URI> existingMap) {
+ Map<String,String> mappings = new HashMap<String,String>();
for (Map.Entry<String,URI> entry : existingMap.entrySet()) {
String prefix = entry.getKey();
- // If the value is a valid XML namespace, it will be untouched. If it is not a namespace, the
- // namespace portion will be extracted and used.
- String namespace = toNamespaceURI(entry.getValue().toString());
-
- if (namespace != null && !containsValue(namespace) && XMLChar.isValidNCName(prefix)) {
- put(prefix, namespace);
+ if (prefix != null) {
+ // If the value is a valid XML namespace, it will be untouched. If it is not a namespace, the
+ // namespace portion will be extracted and used.
+ String namespace = toNamespaceURI(entry.getValue().toString());
+
+ if (namespace != null && !mappings.containsKey(namespace) && validatePrefix(prefix)) {
+ mappings.put(namespace, prefix);
+ }
}
}
+
+ return mappings;
}
+
+ /**
+ * Validates a user-defined prefix. A prefix is rejected if it meets any of the following conditions:
+ * <ul>
+ * <li>Is not a valid NCName according to the XML specification, or empty to represent the default namespace.</li>
+ * <li>Attempts to redefine one of the existing default prefixes (rdf, rdfs, owl, dc).</li>
+ * <li>Begins with the sequence "ns[0-9]" as this could conflict with a generated prefix.</li>
+ * </ul>
+ * @param prefix The prefix to validate.
+ * @return <code>true</code> if it is safe to include the prefix in the available namespace definitions.
+ */
+ private boolean validatePrefix(String prefix) {
+ // Only accept prefixes that can be used in XML qnames.
+ if (!(XMLChar.isValidNCName(prefix) || prefix.equals(""))) return false;
+
+ // Don't allow existing prefixes to be redefined.
+ if (containsKey(prefix)) return false;
+
+ // Prefixes starting with "ns1", "ns2", etc. may conflict with generated prefixes.
+ if (prefix.matches("^ns\\d")) return false;
+
+ return true;
+ }
/**
* Evaluates the statements and adds namespace mappings for all unique namespaces.
@@ -236,7 +269,15 @@
//only add namespace if it is new
if ((newURI != null) && !containsValue(newURI)) {
//add to namespaces
- put("ns" + size(), newURI);
+ String prefix = null;
+
+ // Look for a user-defined prefix for the new namespace.
+ if (userPrefixes != null) prefix = userPrefixes.get(newURI);
+
+ // If no user-defined prefix exists, generate a new one.
+ if (prefix == null) prefix = "ns" + size();
+
+ put(prefix, newURI);
}
}
@@ -311,9 +352,10 @@
logger.warn("Replacing URI: " + uri + " with ENTITY: " + newURI +
". Namepace replacement may be invalid XML.");
} else if (uri.startsWith(nsURI)) {
-
- //replace namespace part with key
- newURI = uri.replaceAll(nsURI, key + ":");
+ // URI's in the default namespace get shortened to local name only.
+ String prefix = key.length() > 0 ? key + ":" : key;
+ //replace namespace part with prefix
+ newURI = uri.replaceAll(nsURI, prefix);
}
assert newURI != null;
Modified: trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java
===================================================================
--- trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/RDFXMLWriter.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -33,6 +33,7 @@
import java.net.URI;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
@@ -109,7 +110,7 @@
StatementStore.VARIABLES[2],
};
}
-
+
/**
* Writes the contents of the JRDF Graph to a Writer in RDF/XML
* format with the encoding specified in the opening XML tag.
@@ -122,7 +123,23 @@
*/
synchronized public void write(Statements statements, ResolverSession session,
OutputStreamWriter writer) throws QueryException {
+ write(statements, session, writer, null);
+ }
+ /**
+ * Writes the contents of the JRDF Graph to a Writer in RDF/XML
+ * format with the encoding specified in the opening XML tag.
+ *
+ * @param statements Statements The RDF to be written.
+ * @param session ResolverSession Used to globalize nodes
+ * @param writer OutputStreamWriter Destination of the RDF/XML (supports
+ * character encoding)
+ * @param initialPrefixes A set of user-supplied namespace prefix mappings.
+ * @throws QueryException
+ */
+ synchronized public void write(Statements statements, ResolverSession session,
+ OutputStreamWriter writer, Map<String,URI> initialPrefixes) throws QueryException {
+
//validate
if (statements == null) {
@@ -148,7 +165,7 @@
statements = prepareStatements(statements);
//initialize the namespaces first
- namespaces = new NamespaceMap(statements, session);
+ namespaces = new NamespaceMap(statements, session, initialPrefixes);
RDF_PREFIX = namespaces.getRDFPrefix();
//write document
@@ -256,7 +273,7 @@
currentKey = keyIter.next();
currentValue = namespaces.get(currentKey);
- if ((currentKey != null) && (currentValue != null)) {
+ if ((currentKey != null) && (currentKey.length() > 0) && (currentValue != null)) {
//write as: <!ENTITY ns 'http://example.org/abc#'>
out.print(NEWLINE + " <!ENTITY " + currentKey + " '" + currentValue + "'>");
@@ -295,11 +312,15 @@
currentKey = keyIter.next();
currentValue = namespaces.get(currentKey);
- if ((currentKey != null)
- && (currentValue != null)) {
-
- //use entities: xmlns:ns="&ns;"
- out.print(NEWLINE + " xmlns:" + currentKey + "=\"&" + currentKey + ";\"");
+ if ((currentKey != null) && (currentValue != null)) {
+ // For default namespace, write 'xmlns="[namespace]"'
+ // For other namespaces, write 'xmlns:[prefix]="&[prefix];"' (XML entity)
+ String xmlnsPart = "xmlns";
+ if (currentKey.length() > 0) {
+ xmlnsPart += ":" + currentKey;
+ }
+ out.print(NEWLINE + " " + xmlnsPart + "=\"" +
+ ((currentKey.length() > 0) ? ("&" + currentKey + ";") : currentValue) + "\"");
}
}
}
Modified: trunk/src/jar/query/java/org/mulgara/query/operation/Export.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/Export.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/Export.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -14,6 +14,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
import org.mulgara.connection.Connection;
import org.mulgara.query.QueryException;
@@ -28,6 +30,9 @@
*/
public class Export extends DataOutputTx {
+ /** Optional user-defined namespace prefix mappings. */
+ private Map<String,URI> namespacePrefixes;
+
/**
* Creates a new Export command, exporting data from the graph URI to a file or output stream.
* @param graphURI The graph to export.
@@ -51,6 +56,15 @@
}
/**
+ * Provide a set of namespace prefix mappings which will be used to pre-populate the namespace
+ * prefix definitions in the exported RDF/XML.
+ * @param prefixes A mapping of prefix string to namespace URI.
+ */
+ public void setNamespacePrefixes(Map<String,URI> prefixes) {
+ namespacePrefixes = new HashMap<String,URI>(prefixes);
+ }
+
+ /**
* Perform an export on a graph.
* @param conn The connection to talk to the server on.
* @return The text describing the graph that was exported.
@@ -64,7 +78,7 @@
if (isLocal()) {
getMarshalledData(conn);
} else {
- conn.getSession().export(src, dest);
+ conn.getSession().export(src, dest, namespacePrefixes);
}
if (logger.isDebugEnabled()) logger.debug("Completed backing up " + src + " to " + dest);
@@ -97,7 +111,7 @@
*/
@Override
protected void doTx(Connection conn, OutputStream outputStream) throws QueryException {
- conn.getSession().export(getSource(), outputStream);
+ conn.getSession().export(getSource(), outputStream, namespacePrefixes);
}
}
Modified: trunk/src/jar/query/java/org/mulgara/server/Session.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/server/Session.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/query/java/org/mulgara/server/Session.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -146,6 +146,21 @@
public void export(URI graphURI, URI destinationURI) throws QueryException;
/**
+ * Export the data in the specified graph. The database is not changed by
+ * this method. Does not require an exclusive lock on the database and will
+ * begin with the currently committed state.
+ * If a set of namespace prefixes is supplied, it will be used to pre-populate
+ * the namespace prefix definitions in the exported RDF/XML.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @param prefixes An optional set of user-supplied namespace prefix mappings;
+ * may be <code>null</code> to use the generated namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI, Map<String,URI> prefixes) throws QueryException;
+
+ /**
* Export the data in the specified graph to an output stream.
* The database is not changed by this method. Does not require an exclusive
* lock on the database and will begin with the currently committed state.
@@ -157,6 +172,21 @@
public void export(URI graphURI, OutputStream outputStream) throws QueryException;
/**
+ * Export the data in the specified graph to an output stream.
+ * The database is not changed by this method. Does not require an exclusive
+ * lock on the database and will begin with the currently committed state.
+ * If a set of namespace prefixes is supplied, it will be used to pre-populate
+ * the namespace prefix definitions in the exported RDF/XML.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param outputStream The stream to receive the contents
+ * @param prefixes An optional set of user-supplied namespace prefix mappings;
+ * may be <code>null</code> to use the generated namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream, Map<String,URI> prefixes) throws QueryException;
+
+ /**
* Restore all the data on the server. If the database is not
* currently empty then the current contents of the database will be replaced
* with the content of the backup file when this method returns.
Modified: trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -718,7 +718,9 @@
URI destinationURI = toURI(node.getDestination());
boolean locality = node.getLocality() != null && (node.getLocality() instanceof ALocalLocality);
- lastCommand = new Export(sourceURI, destinationURI, locality);
+ Export exportCommand = new Export(sourceURI, destinationURI, locality);
+ exportCommand.setNamespacePrefixes(aliasMap);
+ lastCommand = exportCommand;
}
/**
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -382,11 +382,24 @@
* @throws QueryException if the export cannot be completed.
*/
public void export(URI graphURI, URI destinationURI) throws QueryException {
- this.export(null, graphURI, destinationURI);
+ this.export(null, graphURI, destinationURI, null);
}
/**
+ * Export the data in the specified graph using pre-defined namespace prefixes.
+ * The database is not changed by this method.
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI, Map<String,URI> prefixes) throws QueryException {
+ this.export(null, graphURI, destinationURI, prefixes);
+ }
+
+
+ /**
* Export the data in the specified graph to an output stream.
* The database is not changed by this method.
* @param graphURI The URI of the server or model to export.
@@ -394,11 +407,24 @@
* @throws QueryException if the export cannot be completed.
*/
public void export(URI graphURI, OutputStream outputStream) throws QueryException {
- this.export(outputStream, graphURI, null);
+ this.export(outputStream, graphURI, null, null);
}
/**
+ * Export the data in the specified graph to an output stream using pre-defined namespace prefixes.
+ * The database is not changed by this method.
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream, Map<String,URI> prefixes) throws QueryException {
+ this.export(outputStream, graphURI, null, prefixes);
+ }
+
+
+ /**
* Restore all the data on the server. If the database is not
* currently empty then the current contents of the database will be replaced
* with the content of the backup file when this method returns.
@@ -680,11 +706,13 @@
* @param outputStream Optional output stream to receive the contents
* @param graphURI The URI of the graph to export.
* @param destinationURI Optional URI of the file to export into.
+ * @param initialPrefixes An optional set of user-supplied namespace prefix mappings;
+ * may be <code>null</code> to use the generated namespace prefixes.
* @throws QueryException if the export cannot be completed.
*/
- private synchronized void export(OutputStream outputStream, URI graphURI, URI destinationURI)
- throws QueryException {
- execute(new ExportOperation(outputStream, graphURI, destinationURI),
+ private synchronized void export(OutputStream outputStream, URI graphURI, URI destinationURI,
+ Map<String,URI> initialPrefixes) throws QueryException {
+ execute(new ExportOperation(outputStream, graphURI, destinationURI, initialPrefixes),
"Unable to export " + graphURI);
}
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -14,6 +14,7 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URI;
+import java.util.Map;
import org.mulgara.content.rdfxml.writer.RDFXMLWriter;
import org.mulgara.query.Constraint;
@@ -42,6 +43,7 @@
class ExportOperation extends OutputOperation {
private final URI graphURI;
+ private final Map<String,URI> prefixes;
/**
* Create an {@link Operation} which exports the contents of the specified RDF graph
@@ -55,14 +57,18 @@
* @param graphURI The URI of the graph to export, never <code>null</code>.
* @param destinationURI The URI of the file to export into, may be
* <code>null</code> if an <var>outputStream</var> is specified
+ * @param initialPrefixes An optional set of user-supplied namespace prefix mappings;
+ * may be <code>null</code> to use the generated namespace prefixes.
*/
- public ExportOperation(OutputStream outputStream, URI graphURI, URI destinationURI) {
+ public ExportOperation(OutputStream outputStream, URI graphURI, URI destinationURI,
+ Map<String,URI> initialPrefixes) {
super(outputStream, destinationURI);
if (graphURI == null) {
throw new IllegalArgumentException("Graph URI may not be null.");
}
this.graphURI = graphURI;
+ this.prefixes = initialPrefixes;
}
/* (non-Javadoc)
@@ -99,7 +105,7 @@
try {
// TODO: Use the destination URI file suffix to determine the appropriate writer.
RDFXMLWriter rdfWriter = new RDFXMLWriter();
- rdfWriter.write(graphStatements, systemResolver, writer);
+ rdfWriter.write(graphStatements, systemResolver, writer, prefixes);
} finally {
// This will close the wrapped resolution as well.
graphStatements.close();
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -144,6 +144,18 @@
/**
+ * Export the data in the specified graph using predefined namespace prefix mappings.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI, Map<String,URI> prefixes) throws QueryException, RemoteException;
+
+
+ /**
* Export the data in the specified graph to an output stream.
* The database is not changed by this method.
*
@@ -154,6 +166,18 @@
public void export(URI graphURI, OutputStream outputStream) throws QueryException, RemoteException;
/**
+ * Export the data in the specified graph to an output stream using predefined namespace prefixes.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream, Map<String,URI> prefixes)
+ throws QueryException, RemoteException;
+
+ /**
* Restore the specified server.
*
* @param sourceURI The URI of the backup file to restore from.
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -328,6 +328,26 @@
/**
+ * Export the data in the specified graph using predefined namespace prefixes.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI, Map<String,URI> prefixes) throws QueryException {
+ try {
+ remoteSession.export(graphURI, destinationURI, prefixes);
+ resetRetries();
+ } catch (RemoteException e) {
+ testRetry(e);
+ export(graphURI, destinationURI);
+ }
+ }
+
+
+ /**
* Export the data in the specified graph to an output stream.
* The database is not changed by this method.
*
@@ -347,6 +367,26 @@
/**
+ * Export the data in the specified graph to an output stream using predefined namespace prefixes.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream, Map<String,URI> prefixes) throws QueryException {
+ try {
+ remoteSession.export(graphURI, outputStream, prefixes);
+ resetRetries();
+ } catch (RemoteException e) {
+ testRetry(e);
+ export(graphURI, outputStream);
+ }
+ }
+
+
+ /**
* Restore all the data on the server. If the database is not
* currently empty then the current contents of the database will be replaced
* with the content of the backup file when this method returns.
Modified: trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java
===================================================================
--- trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2008-09-08 09:19:40 UTC (rev 1253)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2008-09-08 18:11:24 UTC (rev 1254)
@@ -224,6 +224,23 @@
}
/**
+ * Export the data in the specified graph using predefined namespace prefixes.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI, Map<String,URI> prefixes) throws QueryException, RemoteException {
+ try {
+ session.export(graphURI, destinationURI, prefixes);
+ } catch (Throwable t) {
+ throw convertToQueryException(t);
+ }
+ }
+
+ /**
* Export the data in the specified graph to an output stream.
* The database is not changed by this method.
*
@@ -240,6 +257,23 @@
}
/**
+ * Export the data in the specified graph to an output stream using predefined namespace prefixes.
+ * The database is not changed by this method.
+ *
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @param prefixes An optional mapping for pre-populating the RDF/XML namespace prefixes.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream, Map<String,URI> prefixes) throws QueryException, RemoteException {
+ try {
+ session.export(graphURI, outputStream, prefixes);
+ } catch (Throwable t) {
+ throw convertToQueryException(t);
+ }
+ }
+
+ /**
* Restore all the data on the server. If the database is not
* currently empty then the current contents of the database will be replaced
* with the content of the backup file when this method returns.
More information about the Mulgara-svn
mailing list