[Mulgara-svn] r390 - branches/nw-interface/src/jar/connection/java/org/mulgara/connection

pag at mulgara.org pag at mulgara.org
Thu Aug 30 21:05:15 UTC 2007


Author: pag
Date: 2007-08-30 16:05:14 -0500 (Thu, 30 Aug 2007)
New Revision: 390

Removed:
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionException.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionFactory.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnection.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnectionUnitTest.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/InvalidQuerySyntaxException.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlConnection.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilder.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilderUnitTest.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MockBadSession.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnection.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionException.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactory.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactoryUnitTest.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/QueryBuilder.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/param/
Log:
This was a partial implementation that will not be completed, so it was removed

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,176 +0,0 @@
-/*
- * 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.connection;
-
-import java.net.URI;
-
-import org.apache.log4j.Logger;
-import org.mulgara.query.QueryException;
-import org.mulgara.server.NonRemoteSessionException;
-import org.mulgara.server.Session;
-import org.mulgara.server.SessionFactory;
-import org.mulgara.server.driver.SessionFactoryFinder;
-import org.mulgara.server.driver.SessionFactoryFinderException;
-
-/**
- * A connection for sending commands to a server.
- *
- * @created 2007-08-21
- * @author Paul Gearon
- * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public class Connection {
-
-  /** Logger. */
-  private static final Logger logger = Logger.getLogger(Connection.class.getName());
-  
-  /** The URI for the server to establish a session on. */
-  private URI serverUri;
-  
-  /** The security domain URI. */
-  private URI securityDomainUri;
-  
-  /** The session to use for this connection. */
-  private Session session;
-  
-  /**
-   * Creates a new connection, given a URI to a server.
-   * @param serverUri The URI to connect to.
-   * @throws ConnectionException There was a problem establishing the details needed for a connection.
-   */
-  public Connection(URI serverUri) throws ConnectionException {
-    setServerUri(serverUri);
-  }
-
-
-  /**
-   * Creates a new connection, given a preassigned session.
-   * @param session The session to connect with.
-   * @throws ConnectionException There was a problem establishing the details needed for a connection.
-   */
-  public Connection(Session session) {
-    this(session, null);
-  }
-  
-  
-  /**
-   * Creates a new connection, given a preassigned session.
-   * @param session The session to connect with.
-   * @throws ConnectionException There was a problem establishing the details needed for a connection.
-   */
-  public Connection(Session session, URI securityDomainUri) {
-    if (session == null) throw new IllegalArgumentException("Cannot create a connection without a server.");
-    setSession(session, securityDomainUri);
-  }
-  
-  
-  /**
-   * Give login credentials and security domain to the current session.  This should only be needed
-   * once since the session does not change.
-   * @param securityDomainUri The security domain for the login.
-   * @param user The username.
-   * @param password The password for the given username.
-   */
-  public void setCredentials(URI securityDomainUri, String user, char[] password) {
-    if (securityDomainUri == null) throw new IllegalArgumentException("Must have a security domain to yuse credentials");
-    this.securityDomainUri = securityDomainUri;
-    setCredentials(user, password);
-  }
-
-
-  /**
-   * Give login credentials for the current security domain to the current session.
-   * This should only be needed
-   * once since the session does not change.
-   * @param user The username.
-   * @param password The password for the given username.
-   */
-  public void setCredentials(String user, char[] password) {
-    if (securityDomainUri == null) throw new IllegalArgumentException("Must have a security domain to yuse credentials");
-    session.login(securityDomainUri, user, password);
-  }
-
-
-  /**
-   * @return the session
-   */
-  public Session getSession() {
-    return session;
-  }
-
-
-  // Private methods //
-
-  /**
-   * @return the serverUri
-   */
-  URI getServerUri() {
-    return serverUri;
-  }
-
-
-  /**
-   * @return the securityDomainUri
-   */
-  URI getSecurityDomainUri() {
-    return securityDomainUri;
-  }
-
-
-  /**
-   * Sets the session information for this connection
-   * @param session The session to set to.
-   * @param securityDomainURI The security domain to use for the session.
-   */
-  private void setSession(Session session, URI securityDomainUri) {
-    this.session = session;
-    this.securityDomainUri = securityDomainUri;
-  }
-
-
-  /**
-   * Establishes a session for this connection.
-   * @param uri The URI to set for the server.
-   * @throws ConnectionException There was a problem establishing a session.
-   */
-  private void setServerUri(URI uri) throws ConnectionException {
-    
-    try {
-      if (uri == null) {
-        // no model given, and the factory didn't cache a connection, so make one up.
-        serverUri = SessionFactoryFinder.findServerURI();
-      } else {
-        serverUri = uri;
-      }
-      if (logger.isDebugEnabled()) logger.debug("Set server URI to: " + serverUri);
-
-      if (logger.isDebugEnabled()) logger.debug("Finding session factory for " + uri);
-      SessionFactory sessionFactory = SessionFactoryFinder.newSessionFactory(serverUri, true);
-      if (logger.isDebugEnabled()) logger.debug("Found " + sessionFactory.getClass() +
-          " session factory, obtaining session with " + uri);
-
-      // create a new session and set this connection to it
-      if (securityDomainUri == null) securityDomainUri = sessionFactory.getSecurityDomain();
-      setSession(sessionFactory.newSession(), sessionFactory.getSecurityDomain());
-
-    } catch (SessionFactoryFinderException e) {
-      throw new ConnectionException("Unable to connect to a server", e);
-    } catch (NonRemoteSessionException e) {
-      throw new ConnectionException("Error connecting to the local server", e);
-    } catch (QueryException e) {
-      throw new ConnectionException("Data error in connection attempt", e);
-    }
-    assert session != null;
-  }
-  
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionException.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionException.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionException.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,46 +0,0 @@
-/*
- * 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.connection;
-
-/**
- * An exception indicating a connection problem.
- *
- * @created 2007-08-22
- * @author Paul Gearon
- * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public class ConnectionException extends Exception {
-
-  /** Regenerate this ID if non-private methods are added or removed. */
-  private static final long serialVersionUID = 3768510944925963668L;
-
-
-  /**
-   * Create an exception with a message.
-   * @param message The message to use.
-   */
-  public ConnectionException(String message) {
-    super(message);
-  }
-
-
-  /**
-   * Create an exception caused by another exception, and with a message.
-   * @param message The message to use.
-   * @param cause The original throwable causing this exception.
-   */
-  public ConnectionException(String message, Throwable cause) {
-    super(message, cause);
-  }
-  
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionFactory.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionFactory.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ConnectionFactory.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,70 +0,0 @@
-/*
- * 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.connection;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mulgara.server.Session;
-
-
-/**
- * Creates new connections or reloads from a cache when possible connections.
- * This must NOT be shared between users, as it is designed to cache security credentials!
- *
- * @created 2007-08-21
- * @author Paul Gearon
- * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public class ConnectionFactory {
-
-  /** Cache of Connections, based on their server URI. */
-  static private Map<URI,Connection> cacheOnUri = new HashMap<URI,Connection>();
-  /** Cache of Connections, based on their session data. */
-  static private Map<Session,Connection> cacheOnSession = new HashMap<Session,Connection>();
-
-  /**
-   * Retrieve a connection based on a server URI.
-   * @param serverUri The URI to get the connection to.
-   * @return The new Connection.
-   * @throws ConnectionException There was an error getting a connection.
-   */
-  static Connection newConnection(URI serverUri) throws ConnectionException {
-    Connection c = cacheOnUri.get(serverUri);
-    if (c == null) {
-      c = new Connection(serverUri);
-      cacheOnUri.put(serverUri, c);
-      cacheOnSession.put(c.getSession(), c);
-    }
-    return c;
-  }
-
-
-  /**
-   * Retrieve a connection for a given session.
-   * @param session The Session the Connection will use..
-   * @return The new Connection.
-   * @throws ConnectionException There was an error getting a connection.
-   */
-  static Connection newConnection(Session session) throws ConnectionException {
-    Connection c = cacheOnSession.get(session);
-    if (c == null) {
-      c = new Connection(session);
-      cacheOnSession.put(session, c);
-      cacheOnUri.put(c.getServerUri(), c);
-    }
-    return c;
-  }
-
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnection.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnection.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnection.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,94 +0,0 @@
-package org.mulgara.connection;
-
-import java.net.URI;
-
-import org.mulgara.query.Answer;
-import org.mulgara.query.Query;
-import org.mulgara.query.QueryException;
-import org.mulgara.server.Session;
-
-/**
- * Default implementation of an iTQL connection to a Mulgara store.
- *
- * @author Tom Adams
- * @version $Revision: 1.4 $
- * @created 2005-04-01
- * @modified $Date: 2005/04/04 11:30:10 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class DefaultItqlConnection implements ItqlConnection {
-
-  // FIXME: Make connections threadsafe.
-
-  private Session session;
-  private URI securityDomain;
-
-  /**
-   * Creates a new iTQL connection to a Mulgara server.
-   *
-   * @param session The session to use to communicate to the Mulgara server.
-   * @param securityDomain The security domain of the Mulgara server.
-   */
-  public DefaultItqlConnection(Session session, URI securityDomain) {
-    this.session = session;
-    this.securityDomain = securityDomain;
-  }
-
-  /**
-   * Executes a command that affects a change on the database and returns no results.
-   *
-   * @param command The command to execute.
-   * @throws InvalidQuerySyntaxException If the syntax of the query is incorrect.
-   * @throws MulgaraConnectionException If an error occurs while executing the command.
-   */
-  public void executeUpdate(String command) throws InvalidQuerySyntaxException, MulgaraConnectionException {
-    checkStringParam("command", command);
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  /**
-   * Executes a query that returns results.
-   *
-   * @param query The query to execute.
-   * @return The answer to the query, will never be <code>null</code>.
-   * @throws InvalidQuerySyntaxException If the syntax of the query is incorrect.
-   * @throws MulgaraConnectionException If an error occurs while executing the query.
-   */
-  public Answer executeQuery(String query) throws InvalidQuerySyntaxException, MulgaraConnectionException {
-    checkStringParam("query", query);
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  /**
-   * Closes the connection to the Mulgara store.
-   * <p>
-   * Calling this method will close the underlying {@link Session}, making it unusable for future use.
-   * </p>
-   *
-   * @throws MulgaraConnectionException If an error occurs while closing the connection.
-   */
-  public void close() throws MulgaraConnectionException {
-    try {
-      session.close();
-    } catch (QueryException e) {
-      throw new MulgaraConnectionException("Unable to close underlying session", e);
-    }
-  }
-
-  // FIXME: Delete this.
-  private static void checkStringParam(String name, String param) {
-    checkParamForNull(name, param);
-    checkParamForEmptyString(name, param);
-  }
-
-  // FIXME: Delete this.
-  private static void checkParamForNull(String name, Object param) {
-    if (param == null) throw new IllegalArgumentException(name+" parameter cannot be null");
-  }
-
-  // FIXME: Delete this.
-  private static void checkParamForEmptyString(String name, String param) {
-    if (param.trim().length() == 0) throw new IllegalArgumentException(name+" parameter cannot be empty");
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnectionUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnectionUnitTest.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/DefaultItqlConnectionUnitTest.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,55 +0,0 @@
-package org.mulgara.connection;
-
-import java.net.URI;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-import org.mulgara.connection.param.ParameterTestUtil;
-
-/**
- * Unit test for {@link DefaultItqlConnection}.
- *
- * @author Tom Adams
- * @version $Revision: 1.4 $
- * @created Apr 1, 2005
- * @modified $Date: 2005/04/04 11:30:10 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class DefaultItqlConnectionUnitTest extends TestCase {
-
-  private static final MockBadSession BAD_SESSION = new MockBadSession();
-  private static final URI NULL_SECURITY_DOMAIN = MulgaraConnectionFactory.NULL_SECURITY_DOMAIN;
-  private static final String EXECUTE_UPDATE_METHOD = "executeUpdate";
-  private static final String EXECUTE_QUERY_METHOD = "executeQuery";
-  private static final String NULL = ParameterTestUtil.NULL;
-  private static final String EMPTY_STRING = ParameterTestUtil.EMPTY_STRING;
-  private static final String SINGLE_SPACE = ParameterTestUtil.SINGLE_SPACE;
-
-  public void testClose() {
-    try {
-      new DefaultItqlConnection(BAD_SESSION, NULL_SECURITY_DOMAIN).close();
-      fail("Bad connection should throw MulgaraConnectionException");
-    } catch (MulgaraConnectionException expected) { }
-  }
-
-  public void testExecuteSimpleBadQuery() throws Exception {
-    DefaultItqlConnection connection = new DefaultItqlConnection(BAD_SESSION, NULL_SECURITY_DOMAIN);
-    checkBadParam(connection, EXECUTE_UPDATE_METHOD, NULL);
-    checkBadParam(connection, EXECUTE_UPDATE_METHOD, EMPTY_STRING);
-    checkBadParam(connection, EXECUTE_UPDATE_METHOD, SINGLE_SPACE);
-  }
-
-  public void testExecuteSimpleBadUpdate() throws Exception {
-    DefaultItqlConnection connection = new DefaultItqlConnection(BAD_SESSION, NULL_SECURITY_DOMAIN);
-    checkBadParam(connection, EXECUTE_QUERY_METHOD, NULL);
-    checkBadParam(connection, EXECUTE_QUERY_METHOD, EMPTY_STRING);
-    checkBadParam(connection, EXECUTE_QUERY_METHOD, SINGLE_SPACE);
-  }
-
-  private void checkBadParam(DefaultItqlConnection connection, String method, String param) throws Exception {
-    ParameterTestUtil.checkBadParam(connection, method, param);
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/InvalidQuerySyntaxException.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/InvalidQuerySyntaxException.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/InvalidQuerySyntaxException.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,22 +0,0 @@
-package org.mulgara.connection;
-
-/**
- * Indicates that the format of a query does not match the required syntax for its language.
- *
- * @author Tom Adams
- * @version $Revision: 1.1 $
- * @created 2005-04-03
- * @modified $Date: 2005/04/03 05:02:06 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class InvalidQuerySyntaxException extends Exception {
-
-  public InvalidQuerySyntaxException(String message) {
-    super(message);
-  }
-
-  public InvalidQuerySyntaxException(String message, Throwable cause) {
-    super(message, cause);
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlConnection.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlConnection.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlConnection.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,14 +0,0 @@
-package org.mulgara.connection;
-
-/**
- * A connection to a Mulgara server through which to send iTQL queries.
- *
- * @author Tom Adams
- * @version $Revision: 1.1 $
- * @created 2005-04-01
- * @modified $Date: 2005/04/03 02:26:09 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface ItqlConnection extends MulgaraConnection {
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilder.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilder.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilder.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,36 +0,0 @@
-package org.mulgara.connection;
-
-import java.util.HashMap;
-
-import org.mulgara.connection.param.MethodParameterUtil;
-import org.mulgara.itql.ItqlInterpreter;
-import org.mulgara.query.Query;
-
-/**
- * Builds iTQL queries in {@link String} form into {@link Query} objects.
- *
- * @author Tom Adams
- * @version $Revision: 1.1 $
- * @created 2005-04-03
- * @modified $Date: 2005/04/04 11:30:10 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ItqlQueryBuilder implements QueryBuilder {
-
-  /**
-   * Builds an iTQL query in {@link String} form into a {@link org.mulgara.query.Query}.
-   *
-   * @param query The query in {@link String} form of the query.
-   * @return The <code>query</code> in {@link org.mulgara.query.Query} form.
-   * @throws InvalidQuerySyntaxException If the syntax of the <code>query</code> is incorrect.
-   */
-  public Query buildQuery(String query) throws InvalidQuerySyntaxException {
-    MethodParameterUtil.checkNotEmptyString("query", query);
-    try {
-      return new ItqlInterpreter(new HashMap()).parseQuery(query);
-    } catch (Exception e) {
-      throw new InvalidQuerySyntaxException("Unable to build query from string: "+query, e);
-    }
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilderUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilderUnitTest.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/ItqlQueryBuilderUnitTest.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,40 +0,0 @@
-package org.mulgara.connection;
-
-import junit.framework.TestCase;
-
-import org.mulgara.connection.param.ParameterTestUtil;
-
-/**
- * Unit test for {@link ItqlQueryBuilder}.
- *
- * @author Tom Adams
- * @version $Revision: 1.1 $
- * @created 2005-04-03
- * @modified $Date: 2005/04/04 11:30:10 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class ItqlQueryBuilderUnitTest extends TestCase {
-
-  private static final String BUILD_QUERY_METHOD = "buildQuery";
-  private static final String NULL = ParameterTestUtil.NULL;
-  private static final String EMPTY_STRING = ParameterTestUtil.EMPTY_STRING;
-  private static final String SINGLE_SPACE = ParameterTestUtil.SINGLE_SPACE;
-
-  public void testBadParams() throws Exception {
-    ItqlQueryBuilder builder = new ItqlQueryBuilder();
-    checkBadParam(builder, NULL);
-    checkBadParam(builder, EMPTY_STRING);
-    checkBadParam(builder, SINGLE_SPACE);
-  }
-
-  public void tesBuildQuery() throws InvalidQuerySyntaxException {
-    // FIXME: Is there any more testing we can do on the form of the query?
-    String query = "select $s $p $o from <rmi://localhost/server1#> where $s $p $o ;";
-    assertNotNull(new ItqlQueryBuilder().buildQuery(query));
-  }
-
-  private void checkBadParam(ItqlQueryBuilder builder, String param) throws Exception {
-    ParameterTestUtil.checkBadParam(builder, BUILD_QUERY_METHOD, param);
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MockBadSession.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MockBadSession.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MockBadSession.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,119 +0,0 @@
-package org.mulgara.connection;
-
-import java.net.URI;
-import java.util.Set;
-import java.util.List;
-import java.io.OutputStream;
-import java.io.InputStream;
-
-import org.mulgara.query.Answer;
-import org.mulgara.query.ModelExpression;
-import org.mulgara.query.Query;
-import org.mulgara.query.QueryException;
-import org.mulgara.rules.RulesRef;
-import org.mulgara.server.Session;
-
-/**
- * Mock {@link Session} for unit testing.
- *
- * @author Tom Adams
- * @version $Revision: 1.2 $
- * @created Apr 1, 2005
- * @modified $Date: 2005/06/26 12:47:55 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class MockBadSession implements Session {
-
-  public void insert(URI modelURI, Set statements) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void insert(URI modelURI, Query query) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void delete(URI modelURI, Set statements) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void delete(URI modelURI, Query query) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void backup(URI sourceURI, URI destinationURI) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void backup(URI sourceURI, OutputStream outputStream) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void restore(URI serverURI, URI sourceURI) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void restore(InputStream inputStream, URI serverURI, URI sourceURI) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public Answer query(Query query) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public List query(List queries) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void createModel(URI modelURI, URI modelTypeURI) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void removeModel(URI uri) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public boolean modelExists(URI uri) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public long setModel(URI uri, ModelExpression modelExpression) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public long setModel(InputStream inputStream, URI uri, ModelExpression modelExpression) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void setAutoCommit(boolean autoCommit) throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void commit() throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void rollback() throws QueryException {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void close() throws QueryException {
-    throw new QueryException("Implement me...");
-  }
-
-  public boolean isLocal() {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-
-  public void login(URI securityDomain, String username, char[] password) {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-  
-  public RulesRef buildRules(URI uri, URI uri2, URI uri3) {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-  
-  public void applyRules(RulesRef rulesRef) {
-    throw new UnsupportedOperationException("Implement me...");
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnection.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnection.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnection.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,45 +0,0 @@
-package org.mulgara.connection;
-
-import org.mulgara.query.Answer;
-
-/**
- * A connection to a Mulgara store through which to send textual commands.
- * <p>
- * {@link MulgaraConnection} is the (Java) interface that query-oriented interfaces should use to connect to a Mulgara store.
- * </p>
- *
- * @created 2005-03-31
- * @author Tom Adams
- * @version $Revision: 1.3 $
- * @modified $Date: 2005/04/03 10:22:46 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface MulgaraConnection {
-
-  /**
-   * Executes a command that affects a change on the database and returns no results.
-   *
-   * @param command The command to execute.
-   * @throws InvalidQuerySyntaxException If the syntax of the <code>command</code> is incorrect.
-   * @throws MulgaraConnectionException If an error occurs while executing the command.
-   */
-  void executeUpdate(String command) throws InvalidQuerySyntaxException, MulgaraConnectionException;
-
-  /**
-   * Executes a query that returns results.
-   *
-   * @param query The query to execute.
-   * @return The answer to the query, will never be <code>null</code>.
-   * @throws InvalidQuerySyntaxException If the syntax of the <code>query</code> is incorrect.
-   * @throws MulgaraConnectionException If an error occurs while executing the query.
-   */
-  Answer executeQuery(String query) throws InvalidQuerySyntaxException, MulgaraConnectionException;
-
-  /**
-   * Closes the connection to the Mulgara store.
-   *
-   * @throws MulgaraConnectionException If an error occurs while closing the connection.
-   */
-  void close() throws MulgaraConnectionException;
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionException.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionException.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionException.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,22 +0,0 @@
-package org.mulgara.connection;
-
-/**
- * Indicates that a connection error occured while connected/ing to a Mulgara server.
- *
- * @author Tom Adams
- * @version $Revision: 1.2 $
- * @created 2005-03-31
- * @modified $Date: 2005/04/03 05:02:06 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class MulgaraConnectionException extends Exception {
-
-  public MulgaraConnectionException(String message) {
-    super(message);
-  }
-
-  public MulgaraConnectionException(String message, Throwable cause) {
-    super(message, cause);
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactory.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactory.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactory.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,43 +0,0 @@
-package org.mulgara.connection;
-
-import java.net.URI;
-
-import org.mulgara.query.rdf.Mulgara;
-import org.mulgara.server.Session;
-import org.mulgara.server.SessionFactory;
-
-/**
- * Returns query oriented connections to a Mulgara server.
- *
- * @author Tom Adams
- * @version $Revision: 1.2 $
- * @created Apr 1, 2005
- * @modified $Date: 2005/04/03 05:02:06 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public final class MulgaraConnectionFactory {
-
-  /**
-   * Indicates that no security is enabled for this Mulgara server.
-   */
-  // FIXME: Move this constant somewhere better so it can be used instead of null on the server also.
-  // FIXME: Replace the use of this constant in all code that currently passes null as a flag for no security.
-  public static final URI NULL_SECURITY_DOMAIN = URI.create(Mulgara.NAMESPACE+"NO_SECURITY");
-
-  /**
-   * Returns a connection to the Mulgara store through which to send iTQL queries.
-   * <p>
-   * Note. A new connection is returned for each call, they not pooled and are not thread safe. Clients should ensure
-   * that they call close on the connection once it is no longer required.
-   * </p>
-   *
-   * @param session The session to use to communicate to the Mulgara server.
-   * @param securityDomain The security domain of the Mulgara server.
-   * @return A connection to the Mulgara store through which to issue iTQL queries.
-   */
-  public ItqlConnection getItqlConnection(Session session, URI securityDomain) {
-    // FIXME: Use IoC to set this and mock it out in the unit test.
-    return new DefaultItqlConnection(session, securityDomain);
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactoryUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactoryUnitTest.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/MulgaraConnectionFactoryUnitTest.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,39 +0,0 @@
-package org.mulgara.connection;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-import org.mulgara.query.rdf.Mulgara;
-import org.mulgara.server.Session;
-
-/**
- * Unit test for {@link MulgaraConnectionFactory}.
- *
- * @author Tom Adams
- * @version $Revision: 1.2 $
- * @created Apr 1, 2005
- * @modified $Date: 2005/04/03 05:02:06 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public class MulgaraConnectionFactoryUnitTest extends TestCase {
-
-  private static final MockBadSession BAD_SESSION = new MockBadSession();
-  private static final URI NULL_SECURITY_DOMAIN = MulgaraConnectionFactory.NULL_SECURITY_DOMAIN;
-
-  public void testNoSecurityConstant() {
-    assertEquals(URI.create("http://mulgara.org/mulgara#NO_SECURITY"), MulgaraConnectionFactory.NULL_SECURITY_DOMAIN);
-  }
-
-  public void testGetItqlConnection() {
-    MulgaraConnectionFactory factory = new MulgaraConnectionFactory();
-    assertNotNull(factory.getItqlConnection(BAD_SESSION, NULL_SECURITY_DOMAIN));
-  }
-
-  public void testBadSessionPassthrough() {
-    try {
-      new MulgaraConnectionFactory().getItqlConnection(BAD_SESSION, NULL_SECURITY_DOMAIN).close();
-      fail("Closing connection with bad session should have thrown exception");
-    } catch (MulgaraConnectionException expected) { }
-  }
-}

Deleted: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/QueryBuilder.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/QueryBuilder.java	2007-08-29 01:21:25 UTC (rev 389)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/QueryBuilder.java	2007-08-30 21:05:14 UTC (rev 390)
@@ -1,26 +0,0 @@
-package org.mulgara.connection;
-
-import org.mulgara.query.Query;
-
-/**
- * Builds queries in {@link String} form into {@link Query} objects.
- *
- * @author Tom Adams
- * @version $Revision: 1.1 $
- * @created 2005-04-03
- * @modified $Date: 2005/04/03 10:22:46 $
- * @copyright &copy; 2005 <a href="http://www.mulgara.org/">Mulgara Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface QueryBuilder {
-
-  /**
-   * Builds a query in {@link String} form into a {@link Query}, suitable for passing to a
-   * {@link org.mulgara.server.Session}.
-   *
-   * @param query The query in {@link String} form of the query.
-   * @return The <code>query</code> in {@link Query} form.
-   * @throws InvalidQuerySyntaxException If the syntax of the <code>query</code> is incorrect.
-   */
-  Query buildQuery(String query) throws InvalidQuerySyntaxException;
-}




More information about the Mulgara-svn mailing list