[Mulgara-svn] r1020 - in trunk/src/jar: itql/java/org/mulgara/itql itql/sablecc query/java/org/mulgara/query/operation query/java/org/mulgara/server resolver/java/org/mulgara/resolver server-beep/java/org/mulgara/server/beep server-rmi/java/org/mulgara/server/rmi
alexhall at mulgara.org
alexhall at mulgara.org
Mon Jun 23 23:17:37 UTC 2008
Author: alexhall
Date: 2008-06-23 16:17:36 -0700 (Mon, 23 Jun 2008)
New Revision: 1020
Added:
trunk/src/jar/query/java/org/mulgara/query/operation/Export.java
trunk/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java
Modified:
trunk/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
trunk/src/jar/itql/sablecc/itql.grammar
trunk/src/jar/query/java/org/mulgara/query/operation/Backup.java
trunk/src/jar/query/java/org/mulgara/query/operation/DataTx.java
trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
trunk/src/jar/query/java/org/mulgara/server/Session.java
trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
trunk/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.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:
Add new Export command and a new Session method for exporting graphs. The export operation remains unimplemented on the server side.
Modified: trunk/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- trunk/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -38,6 +38,7 @@
import org.mulgara.query.operation.Deletion;
import org.mulgara.query.operation.DropGraph;
import org.mulgara.query.operation.ExecuteScript;
+import org.mulgara.query.operation.Export;
import org.mulgara.query.operation.Help;
import org.mulgara.query.operation.Insertion;
import org.mulgara.query.operation.Load;
@@ -689,6 +690,24 @@
}
/**
+ * Exports the contents of a graph to a local or remote file.
+ *
+ * @param node the backup command
+ */
+ public void outAExportCommand(AExportCommand node) {
+
+ // log the command
+ if (logger.isDebugEnabled()) logger.debug("Processing export command " + node);
+
+ // get constituents of the export command
+ URI sourceURI = toURI(node.getSource());
+ URI destinationURI = toURI(node.getDestination());
+ boolean locality = node.getLocality() != null && (node.getLocality() instanceof ALocalLocality);
+
+ lastCommand = new Export(sourceURI, destinationURI, locality);
+ }
+
+ /**
* Restores the contents of a server from a file.
*
* @param node the restore command
Modified: trunk/src/jar/itql/sablecc/itql.grammar
===================================================================
--- trunk/src/jar/itql/sablecc/itql.grammar 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/itql/sablecc/itql.grammar 2008-06-23 23:17:36 UTC (rev 1020)
@@ -48,6 +48,7 @@
{def} echo = 'echo';
{def} execute = 'execute';
{def} exclude = 'exclude';
+ {def} export = 'export';
{def} from = 'from';
{def} help = 'help';
{def} in = 'in';
@@ -130,6 +131,7 @@
{directory} directory resource |
{drop} drop resource |
{execute} execute resource |
+ {export} export [source]:resource to [locality]:locality? [destination]:resource |
{help} help command_prefix |
{insert} insert triple_factor into resource |
{load} load [locality]:locality? [source]:resource into [destination]:resource |
@@ -180,6 +182,7 @@
{directory} directory |
{drop} drop |
{execute} execute |
+ {export} export |
{help} help |
{insert} insert |
{load} load |
Modified: trunk/src/jar/query/java/org/mulgara/query/operation/Backup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/Backup.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/Backup.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -39,8 +39,6 @@
*/
public class Backup extends DataTx {
- private static final String FILE = "file";
-
/** The logger */
static final Logger logger = Logger.getLogger(Backup.class.getName());
@@ -55,7 +53,7 @@
*/
public Backup(URI source, URI destination, boolean locality) {
super(source, destination, source, locality);
- if (!destination.getScheme().equals(FILE)) throw new IllegalArgumentException("Backups must be sent to a file");
+ if (!destination.getScheme().equals(FILE_SCHEME)) throw new IllegalArgumentException("Backups must be sent to a file");
updateServerUri(source);
}
Modified: trunk/src/jar/query/java/org/mulgara/query/operation/DataTx.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -47,6 +47,8 @@
/** String constant for the extension of zip files. */
private static final String ZIP_EXTENSION = ".zip";
+ protected static final String FILE_SCHEME = "file";
+
/** The source of data to insert. */
private final URI source;
Added: trunk/src/jar/query/java/org/mulgara/query/operation/Export.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/Export.java (rev 0)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/Export.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -0,0 +1,133 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.query.operation;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+
+import edu.emory.mathcs.util.remote.io.RemoteOutputStream;
+import edu.emory.mathcs.util.remote.io.server.impl.RemoteOutputStreamSrvImpl;
+
+/**
+ * Represents a command to export data from a graph.
+ *
+ * @created Jun 23, 2008
+ * @author Alex Hall
+ * @copyright © 2008 <a href="http://www.revelytix.com">Revelytix, Inc.</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class Export extends DataTx {
+
+ /**
+ * Creates a new Export command.
+ * @param source The graph to export.
+ * @param destination The location where to export the data.
+ * Only file URLs supported at the moment.
+ */
+ public Export(URI source, URI destination, boolean locality) {
+ super(source, destination, source, locality);
+ if (!destination.getScheme().equals(FILE_SCHEME)) throw new IllegalArgumentException("Exports must be sent to a file");
+ }
+
+ /**
+ * 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.
+ * @throws QueryException There was an error asking the server to perform the export.
+ * @throws MalformedURLException The destination is not a valid file.
+ */
+ public Object execute(Connection conn) throws Exception {
+ // test if the server can do all the work, or if data needs to be streamed
+ if (!isLocal()) {
+ // server does all the work
+ conn.getSession().export(getSource(), getDestination());
+ } else {
+ // need to stream data through to an output stream
+ FileOutputStream fileOutputStream = null;
+ String destinationFile = this.getDestination().toURL().getPath();
+ try {
+ fileOutputStream = new FileOutputStream(destinationFile);
+ } catch (FileNotFoundException ex) {
+ throw new QueryException("File " + destinationFile + " cannot be created for export. ", ex);
+ }
+
+ // send to open method for exporting to a stream
+ export(conn, getSource(), fileOutputStream);
+ }
+
+ return setResultMessage("Successfully exported " + getSource() + " to " + getDestination() + ".");
+ }
+
+ /**
+ * Public interface to perform an export into an output stream.
+ * This is callable directly, without an AST interface.
+ * @param conn The connection to a server to perform the export.
+ * @param source The URI describing the graph on the server to export.
+ * @param outputStream The output which will receive the data to be exported.
+ * @throws QueryException There was an error asking the server to perform the export.
+ */
+ public static void export(Connection conn, URI source, OutputStream outputStream) throws QueryException {
+ // open and wrap the outputstream
+ RemoteOutputStreamSrvImpl srv = new RemoteOutputStreamSrvImpl(outputStream);
+
+ // prepare it for exporting
+ try {
+ UnicastRemoteObject.exportObject(srv);
+ } catch (RemoteException rex) {
+ throw new QueryException("Unable to export "+ source + " to an output stream", rex);
+ }
+
+ OutputStream marshallingOutputStream = new RemoteOutputStream(srv);
+
+ // perform the export
+ try {
+ conn.getSession().export(source, marshallingOutputStream);
+ } finally {
+ // cleanup the output
+ if (marshallingOutputStream != null) {
+ try {
+ marshallingOutputStream.close();
+ } catch (IOException ioe ) { /* ignore */ }
+ }
+ // cleanup the RMI for the output stream
+ if (srv != null) {
+ try {
+ UnicastRemoteObject.unexportObject(srv, false);
+ } catch (NoSuchObjectException ex) {};
+ }
+ try {
+ srv.close();
+ } catch (IOException e) {}
+ }
+ }
+
+ /**
+ * Perform the transfer with the configured datastream.
+ * @return The number of statements affected, or <code>null</code> if this is not relevant.
+ */
+ @Override
+ protected Long doTx(Connection conn, InputStream inputStream) throws QueryException {
+ return null;
+ }
+
+}
Modified: trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -12,6 +12,7 @@
package org.mulgara.query.operation;
import java.net.URI;
+import java.util.Iterator;
import java.util.Set;
import org.mulgara.query.ModelResource;
@@ -48,8 +49,12 @@
*/
public URI getServerURI() {
Set<URI> gs = serverGraph.getDatabaseURIs();
- assert gs.size() == 1;
- return gs.iterator().next();
+ URI serverUri = null;
+ Iterator<URI> iter = gs.iterator();
+ if (iter.hasNext()) {
+ serverUri = iter.next();
+ }
+ return serverUri;
}
Modified: trunk/src/jar/query/java/org/mulgara/server/Session.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/server/Session.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/query/java/org/mulgara/server/Session.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -132,6 +132,28 @@
*/
public void backup(URI sourceURI, OutputStream outputStream)
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.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param destinationURI The URI of the file to export into.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) 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.
+ *
+ * @param graphURI The URI of the graph to export.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException;
/**
* Restore all the data on the specified server. If the database is not
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -28,23 +28,30 @@
package org.mulgara.resolver;
// Java 2 standard packages
-import java.io.*;
+import java.io.BufferedWriter;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.net.URI;
-import java.util.*;
+import java.util.Date;
import java.util.zip.GZIPOutputStream;
-// Third party packages
-import org.apache.log4j.Logger;
-import org.jrdf.graph.*;
-
-// Local packages
-import org.mulgara.content.rdfxml.writer.*;
-import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
-import org.mulgara.resolver.spi.*;
+import org.jrdf.graph.URIReference;
+import org.mulgara.content.rdfxml.writer.RDFXMLWriter;
+import org.mulgara.query.Constraint;
+import org.mulgara.query.ConstraintImpl;
+import org.mulgara.query.LocalNode;
+import org.mulgara.query.Variable;
+import org.mulgara.query.rdf.URIReferenceImpl;
+import org.mulgara.resolver.spi.DatabaseMetadata;
+import org.mulgara.resolver.spi.Resolution;
+import org.mulgara.resolver.spi.Resolver;
+import org.mulgara.resolver.spi.ResolverSession;
+import org.mulgara.resolver.spi.Statements;
+import org.mulgara.resolver.spi.SystemResolver;
+import org.mulgara.resolver.spi.TuplesWrapperStatements;
import org.mulgara.store.statement.StatementStore;
import org.mulgara.store.stringpool.SPObject;
-import org.mulgara.store.stringpool.StringPool;
import org.mulgara.store.tuples.Tuples;
/**
@@ -60,15 +67,9 @@
* Technology, Inc</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-class BackupOperation implements BackupConstants, Operation {
+class BackupOperation extends OutputOperation implements BackupConstants, Operation {
- /** Logger. */
- private static final Logger logger =
- Logger.getLogger(BackupOperation.class.getName());
-
- private final OutputStream outputStream;
private final URI serverURI;
- private final URI destinationURI;
//
// Constructor
@@ -87,12 +88,9 @@
* @param destinationURI URI of the file to backup into, may be
* <code>null</code> if an <var>outputStream</var> is specified
*/
- public BackupOperation(
- OutputStream outputStream, URI serverURI, URI destinationURI
- ) {
- this.outputStream = outputStream;
+ public BackupOperation(OutputStream outputStream, URI serverURI, URI destinationURI) {
+ super(outputStream, destinationURI);
this.serverURI = serverURI;
- this.destinationURI = destinationURI;
}
//
@@ -105,27 +103,8 @@
OutputStream os = outputStream;
Writer writer = null;
try {
- // Check if an output stream was supplied and open the local file if it
- // hasn't.
- if (os == null) {
- // Verify that the destination is a local file.
- String scheme = destinationURI.getScheme();
- if (scheme == null) {
- throw new IllegalArgumentException(
- "Relative URIs are not supported as backup destination");
- }
- if (!scheme.equals("file")) {
- throw new IllegalArgumentException(
- "Only file URIs are currently supported as backup destination");
- }
+ os = getOutputStream();
- // Open the local file.
- os = new FileOutputStream(destinationURI.getPath());
- }
-
- // Ensure the output is buffered for efficiency.
- os = new BufferedOutputStream(os);
-
// The existence of a fragment indicates that a model is to be backed
// up otherwise the entire database is to be backed up.
if (serverURI != null && serverURI.getFragment() != null) {
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -341,6 +341,29 @@
public void backup(URI sourceURI, OutputStream outputStream) throws QueryException {
this.backup(outputStream, sourceURI, null);
}
+
+
+ /**
+ * Export the data in the specified graph. 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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) throws QueryException {
+ this.export(null, graphURI, destinationURI);
+ }
+
+
+ /**
+ * 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.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException {
+ this.export(outputStream, graphURI, null);
+ }
/**
@@ -581,6 +604,21 @@
execute(new BackupOperation(outputStream, serverURI, destinationURI),
"Unable to backup to " + destinationURI);
}
+
+ /**
+ * Export the data on the specified graph to a URI or an output stream.
+ * The database is not changed by this method.
+ *
+ * If an outputstream is supplied then the destinationURI is ignored.
+ *
+ * @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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ private synchronized void export(OutputStream outputStream, URI graphURI, URI destinationURI)
+ throws QueryException {
+ }
//
Added: trunk/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java (rev 0)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -0,0 +1,90 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+package org.mulgara.resolver;
+
+import java.io.BufferedOutputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import org.mulgara.resolver.spi.DatabaseMetadata;
+import org.mulgara.resolver.spi.SystemResolver;
+
+/**
+ * Abstract base class for operations that need to write output to the file system.
+ * @created Jun 23, 2008
+ * @author Alex Hall
+ * @copyright © 2008 <a href="http://www.revelytix.com">Revelytix, Inc.</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public abstract class OutputOperation implements Operation {
+
+ protected final OutputStream outputStream;
+ protected final URI destinationURI;
+
+ public OutputOperation(OutputStream outputStream, URI destinationURI) {
+ if (outputStream == null && destinationURI == null) {
+ throw new IllegalArgumentException("At least one of outputStream and destinationURI must be set");
+ }
+ this.outputStream = outputStream;
+ this.destinationURI = destinationURI;
+ }
+
+ /**
+ * Gets an output stream for this operation, opening one from the destination
+ * URI if necessary.
+ * @return An output stream to receive the contents from this operation.
+ * @throws FileNotFoundException if creating from a destination URI which could not be opened.
+ */
+ protected OutputStream getOutputStream() throws FileNotFoundException {
+ OutputStream os = outputStream;
+
+ // Check if an output stream was supplied and open the local file if it
+ // hasn't.
+ if (os == null) {
+ // Verify that the destination is a local file.
+ String scheme = destinationURI.getScheme();
+ if (scheme == null) {
+ throw new IllegalArgumentException(
+ "Relative URIs are not supported as backup destination");
+ }
+ if (!scheme.equals("file")) {
+ throw new IllegalArgumentException(
+ "Only file URIs are currently supported as backup destination");
+ }
+
+ // Open the local file.
+ os = new FileOutputStream(destinationURI.getPath());
+ }
+
+ // Ensure the output is buffered for efficiency.
+ os = new BufferedOutputStream(os);
+
+ return os;
+ }
+
+ /* (non-Javadoc)
+ * @see org.mulgara.resolver.Operation#execute(org.mulgara.resolver.OperationContext, org.mulgara.resolver.spi.SystemResolver, org.mulgara.resolver.spi.DatabaseMetadata)
+ */
+ abstract public void execute(OperationContext operationContext,
+ SystemResolver systemResolver, DatabaseMetadata metadata)
+ throws Exception;
+
+ /**
+ * @return <code>false</code>
+ */
+ public boolean isWriteOperation() {
+ return false;
+ }
+
+}
Modified: trunk/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java
===================================================================
--- trunk/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java 2008-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/server-beep/java/org/mulgara/server/beep/BEEPSession.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -29,29 +29,30 @@
package org.mulgara.server.beep;
// Java 2 Standard Packages
-import java.io.*;
-import java.net.*;
-import java.rmi.RemoteException;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
import javax.transaction.xa.XAResource;
-// Third party packages
-import org.apache.log4j.Logger; // Apache Log4J
-import org.beepcore.beep.core.BEEPException; // BEEP
+import org.apache.log4j.Logger;
+import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.ByteOutputDataStream;
import org.beepcore.beep.core.Channel;
import org.beepcore.beep.core.Message;
-import org.beepcore.beep.core.StringOutputDataStream;
import org.beepcore.beep.lib.Reply;
-import org.jrdf.graph.Node; // JRDF
-import org.jrdf.graph.Triple; // JRDF
-
-// Locally written packages
+import org.jrdf.graph.Triple;
import org.mulgara.query.Answer;
import org.mulgara.query.ModelExpression;
import org.mulgara.query.Query;
import org.mulgara.query.QueryException;
-import org.mulgara.rules.RulesException;
import org.mulgara.rules.RulesRef;
import org.mulgara.server.Session;
import org.mulgara.sparql.protocol.StreamFormatException;
@@ -206,6 +207,31 @@
public void backup(URI serverURI, OutputStream outputStream) throws QueryException {
throw new QueryException("Backup not implemented");
}
+
+
+ /**
+ * Export the data in the specified graph. 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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) throws QueryException {
+ throw new QueryException("Export not implemented");
+ }
+
+
+ /**
+ * 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.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException {
+ throw new QueryException("Export not implemented");
+ }
/**
@@ -316,6 +342,7 @@
* @return a list of non-<code>null</code> answers to the <var>queries</var>
* @throws QueryException if <var>query</var> can't be answered
*/
+ @SuppressWarnings("unchecked")
public List query(List queries) throws QueryException {
throw new QueryException("Multiple queries not implemented");
}
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-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSession.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -131,6 +131,27 @@
*/
public void backup(URI sourceURI, OutputStream outputStream)
throws QueryException, RemoteException;
+
+
+ /**
+ * Export the data in the specified graph. 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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) throws QueryException, RemoteException;
+
+
+ /**
+ * 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.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException, RemoteException;
/**
* Restore the specified server.
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-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/RemoteSessionWrapperSession.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -306,6 +306,43 @@
backup(sourceURI, outputStream);
}
}
+
+
+ /**
+ * Export the data in the specified graph. 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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) throws QueryException {
+ try {
+ remoteSession.export(graphURI, destinationURI);
+ 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.
+ *
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException {
+ try {
+ remoteSession.export(graphURI, outputStream);
+ resetRetries();
+ } catch (RemoteException e) {
+ testRetry(e);
+ export(graphURI, outputStream);
+ }
+ }
/**
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-06-23 23:06:43 UTC (rev 1019)
+++ trunk/src/jar/server-rmi/java/org/mulgara/server/rmi/SessionWrapperRemoteSession.java 2008-06-23 23:17:36 UTC (rev 1020)
@@ -207,6 +207,37 @@
throw convertToQueryException(t);
}
}
+
+ /**
+ * Export the data in the specified graph. 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.
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, URI destinationURI) throws QueryException, RemoteException {
+ try {
+ session.export(graphURI, destinationURI);
+ } 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.
+ *
+ * @param graphURI The URI of the server or model to export.
+ * @param outputStream The stream to receive the contents
+ * @throws QueryException if the export cannot be completed.
+ */
+ public void export(URI graphURI, OutputStream outputStream) throws QueryException, RemoteException {
+ try {
+ session.export(graphURI, outputStream);
+ } catch (Throwable t) {
+ throw convertToQueryException(t);
+ }
+ }
/**
* Restore all the data on the specified server. If the database is not
More information about the Mulgara-svn
mailing list