[teiid-commits] teiid SVN: r1547 - in trunk: client/src/main/java/com/metamatrix/platform and 14 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Nov 10 14:46:58 EST 2009


Author: shawkins
Date: 2009-11-10 14:46:56 -0500 (Tue, 10 Nov 2009)
New Revision: 1547

Removed:
   trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/SessionException.java
   trunk/client/src/main/java/com/metamatrix/platform/util/
   trunk/common-internal/src/main/java/com/metamatrix/common/xml/XPathUtil.java
   trunk/common-internal/src/main/java/com/metamatrix/common/xml/xmi/
Modified:
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
   trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/InvalidSessionException.java
   trunk/client/src/main/java/org/teiid/adminapi/VDB.java
   trunk/common-core/src/main/java/com/metamatrix/core/vdb/VDBStatus.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
   trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
   trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
   trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
   trunk/test-integration/common/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
Log:
minor cleanups and ensuring that the active default status logic is in teiid.

Modified: trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/InvalidSessionException.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/InvalidSessionException.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/InvalidSessionException.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -22,7 +22,7 @@
 
 package com.metamatrix.admin.api.exception.security;
 
-public class InvalidSessionException extends SessionException {
+public class InvalidSessionException extends MetaMatrixSecurityException {
 
 
     /**

Deleted: trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/SessionException.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/SessionException.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/exception/security/SessionException.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.admin.api.exception.security;
-
-public class SessionException extends MetaMatrixSecurityException {
-
-    /**
-     * No-Arg Constructor
-     */
-    public SessionException(  ) {
-        super( );
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message. A detail
-     * message is a String that describes this particular exception.
-     * @param the detail message
-     */
-    public SessionException(String message) {
-    	super(message);
-    }
-    /**
-     * Constructs an instance of the exception with no detail message but with a
-     * single exception.
-     * @param e the exception that is encapsulated by this exception
-     */
-    public SessionException(Throwable e) {
-        super(e);
-    }
-    /**
-     * Constructs an instance of the exception with the specified detail message
-     * and a single exception. A detail message is a String that describes this
-     * particular exception.
-     * @param message the detail message
-     * @param e the exception that is encapsulated by this exception
-     */
-    public SessionException( Throwable e, String message ) {
-        super(e, message);
-    }
-    /**
-     * Construct an instance with an error code and message specified.
-     *
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public SessionException( String code, String message ) {
-        super( code, message );
-    }
-    /**
-     * Construct an instance with a linked exception, and an error code and
-     * message, specified.
-     *
-     * @param e       An exception to chain to this exception
-     * @param message The error message
-     * @param code    The error code 
-     */
-    public SessionException( Throwable e, String code, String message ) {
-        super( e, code, message );
-    }
-}
-

Modified: trunk/client/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/VDB.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client/src/main/java/org/teiid/adminapi/VDB.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -24,6 +24,8 @@
 
 import java.util.Collection;
 import java.util.Date;
+
+import com.metamatrix.core.vdb.VDBStatus;
 
 /**
  * Represents a Virtual Database in the MetaMatrix system.
@@ -54,25 +56,31 @@
      * 
      * @since 4.3
      */
-    public static final int INCOMPLETE = 1;
+    public static final int INCOMPLETE = VDBStatus.INCOMPLETE;
     /**
      * Inactive VDB (can edit connector binding)
      * 
      * @since 4.3
      */
-    public static final int INACTIVE = 2;
+    public static final int INACTIVE = VDBStatus.INACTIVE;
     /**
      * Active VDB
      * 
      * @since 4.3
      */
-    public static final int ACTIVE = 3;
+    public static final int ACTIVE = VDBStatus.ACTIVE;
     /**
      * Mark VDB for Deletion
      * 
      * @since 4.3
      */
-    public static final int DELETED = 4;
+    public static final int DELETED = VDBStatus.DELETED;
+    /**
+     * Active Default
+     * 
+     * @since 5.5.3
+     */
+    public static final int ACTIVE_DEFAULT = VDBStatus.ACTIVE_DEFAULT;
 
     /**
      * @return date the VDB was versioned

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -68,7 +68,6 @@
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.dqp.client.ClientSideDQP;
 import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.util.ProductInfoConstants;
 
 /**
  * <p>The Connection object represents driver's connection to the MetaMatrix embedded server.
@@ -495,7 +494,12 @@
         checkConnection();
         //get the virtual database name to which we are connected.
 
-        return this.serverConn.getLogonResult().getProductInfo(ProductInfoConstants.VIRTUAL_DB);
+        return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_NAME);
+    }
+    
+    public String getVDBVersion() throws SQLException {
+    	checkConnection();
+        return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_VERSION);
     }
 
     /**

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -40,5 +40,7 @@
      * @throws SQLException
      */
     Admin getAdminAPI() throws SQLException;
+    
+    String getVDBVersion() throws SQLException;
 
 }

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -22,21 +22,19 @@
 
 package com.metamatrix.jdbc;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.*;
 
 import java.sql.SQLException;
 import java.util.Properties;
 
 import junit.framework.TestCase;
 
+import com.metamatrix.common.api.MMURL;
 import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
 import com.metamatrix.dqp.client.ClientSideDQP;
 import com.metamatrix.platform.security.api.LogonResult;
 import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.util.ProductInfoConstants;
 
 public class TestMMConnection extends TestCase {
 
@@ -57,8 +55,8 @@
     	props.setProperty(BaseDataSource.VDB_VERSION, STD_DATABASE_VERSION);
     	props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin"); //$NON-NLS-1$
     	Properties productInfo = new Properties();
-    	productInfo.setProperty(ProductInfoConstants.VIRTUAL_DB, STD_DATABASE_NAME);
-    	productInfo.setProperty(ProductInfoConstants.VDB_VERSION, STD_DATABASE_VERSION);
+    	productInfo.setProperty(MMURL.JDBC.VDB_NAME, STD_DATABASE_NAME);
+    	productInfo.setProperty(MMURL.JDBC.VDB_VERSION, STD_DATABASE_VERSION);
     	stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake")); //$NON-NLS-1$
     	return new MMConnection(mock, props, serverUrl);
     }

Modified: trunk/common-core/src/main/java/com/metamatrix/core/vdb/VDBStatus.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/vdb/VDBStatus.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/common-core/src/main/java/com/metamatrix/core/vdb/VDBStatus.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -28,7 +28,7 @@
     public static final short INACTIVE = 2;
     public static final short ACTIVE = 3;
     public static final short DELETED = 4;
-    public static final short ACTIVE_DEFAULT = 3;
+    public static final short ACTIVE_DEFAULT = 5;
     
     final static String[] VDB_STATUS_NAMES = {
     	"Incomplete", //$NON-NLS-1$

Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xml/XPathUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xml/XPathUtil.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xml/XPathUtil.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.xml;
-
-import java.util.*;
-import org.jdom.*;
-import com.metamatrix.core.util.Assertion;
-
-public class XPathUtil {
-
-    /** Delimiter for XPath */
-    public static final String STEP_DELIMITER = "/"; //$NON-NLS-1$
-    public static final char STEP_DELIMITER_CHAR = STEP_DELIMITER.charAt(0);
-
-    private static final String DOCUMENT_ROOT = "/doc/"; //$NON-NLS-1$
-//    private static final char ALL = '*';
-
-    public static class Literal {
-        public static final char APOSTROPHE            = '\'';
-        public static final char QUOTE                 = '"';
-    }
-
-    public static class ExpressionToken {
-        public static final char ATTRIBUTE_PREFIX      = '@';
-        public static final char INDEX_OPEN            = '[';
-        public static final char INDEX_CLOSE           = ']';
-        public static final char PARAMETERS_OPEN       = '(';
-        public static final char PARAMETERS_CLOSE      = ')';
-        public static final char SELF                  = '.';
-        public static final String PARENT              = ".."; //$NON-NLS-1$
-        public static final String AXIS_SUFFIX         = "::"; //$NON-NLS-1$
-    }
-
-    public static class Operator {
-        public static final char OR                    = '|';
-        public static final char ADD                   = '+';
-        public static final char MINUS                 = '-';
-        public static final char EQUAL                 = '=';
-        public static final char LESS_THAN             = '<';
-        public static final char MULTIPLY              = '*';
-        public static final char GREATER_THAN          = '>';
-        public static final String NOT_EQUAL           = "!="; //$NON-NLS-1$
-        public static final String LESS_THAN_EQUAL     = "<="; //$NON-NLS-1$
-        public static final String GREATER_THAN_EQUAL  = ">="; //$NON-NLS-1$
-        public static final String AND_NAME            = "and"; //$NON-NLS-1$
-        public static final String OR_NAME             = "or"; //$NON-NLS-1$
-        public static final String MODULUS_NAME        = "mod"; //$NON-NLS-1$
-        public static final String DIVIDE_NAME         = "div"; //$NON-NLS-1$
-        public static final String DECENDENT_OR_SELF   = "//"; //$NON-NLS-1$
-    }
-
-    /**
-     * Get the absolute path using the abbreviated format of XPath 1.0
-     * for the specified element.  For example, the following XPath:
-     * <p><code>/doc/chapter[5]/section[2]</code></p>
-     * specifies the second section of the fifth chapter of the document.
-     * @return the XPath of the specified element.
-     * @see <a href="http://www.w3c.org/TR/xpath#path-abbrev">XPath</a>
-     */
-    public static String getAbsolutePath( Element tag ) {
-        Assertion.isNotNull(tag,"The JDOM Element reference may not be null"); //$NON-NLS-1$
-        return addToXPath( tag, new StringBuffer(DOCUMENT_ROOT) ).toString();
-    }
-
-    /**
-     * Get the absolute path using the abbreviated format of XPath 1.0
-     * for the specified attribute.  For example, the following XPath:
-     * <p><code>/doc/chapter[5]/section[2]/@title</code></p>
-     * specifies the title attribute of the second section of the fifth chapter of the document.
-     * @return the XPath of the specified element.
-     * @see <a href="http://www.w3c.org/TR/xpath#path-abbrev">XPath</a>
-     */
-    public static String getAbsolutePath( Attribute attribute ) {
-        Assertion.isNotNull(attribute,"The JDOM Attribute reference may not be null"); //$NON-NLS-1$
-        Element tag = attribute.getParent();
-        StringBuffer sb = new StringBuffer(DOCUMENT_ROOT);
-        addToXPath( tag, sb );
-        sb.append(STEP_DELIMITER_CHAR);
-        sb.append(ExpressionToken.ATTRIBUTE_PREFIX);
-        sb.append(attribute.getName());
-        sb.append(Operator.EQUAL);
-        sb.append(Literal.QUOTE);
-        sb.append(attribute.getValue());
-        sb.append(Literal.QUOTE);
-        return sb.toString();
-    }
-
-    protected static StringBuffer addToXPath(Element tag, StringBuffer sb) {
-        StringBuffer result = sb;
-        // Add the parent's name first ...
-        // The parent could be an Element or Document
-        Parent parent = tag.getParent();
-        int index = 1;
-        if ( parent != null && parent instanceof Element ) {
-            List parentsChildren = ((Element)parent).getChildren();
-            index = parentsChildren.indexOf(tag) + 1;
-            result = addToXPath((Element)parent,result);
-            result.append(STEP_DELIMITER_CHAR);
-        }
-        result.append(tag.getName());
-        result.append(ExpressionToken.INDEX_OPEN);
-        result.append(index);
-        result.append(ExpressionToken.INDEX_CLOSE);
-        return result;
-    }
-
-}

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/VDBService.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -28,7 +28,6 @@
 import com.metamatrix.common.application.ApplicationService;
 import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
 
 /**
  * This interface defines methods which are specific to dealing with VDBs
@@ -101,7 +100,12 @@
     // to be removed later..
     public String getConnectorName(String connectorBindingID) throws MetaMatrixComponentException;    
     
-    public String getActiveVDBVersion(String vdbName, String vdbVersion) throws MetaMatrixComponentException, VirtualDatabaseException;
-    
+    /**
+     * 
+     * @param vdbName
+     * @param vdbVersion may be null to indicate latest/default
+     * @return
+     * @throws MetaMatrixComponentException
+     */
     public VDBArchive getVDB(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
 }

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeVDBService.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -268,11 +268,6 @@
     }
     
     @Override
-    public String getActiveVDBVersion(String vdbName, String vdbVersion) {
-    	throw new UnsupportedOperationException();
-    }
-    
-    @Override
     public VDBArchive getVDB(String vdbName, String vdbVersion)
     		throws MetaMatrixComponentException {
     	throw new UnsupportedOperationException();

Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -52,6 +52,7 @@
 import com.metamatrix.admin.objects.MMVDB;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.common.api.MMURL;
 import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.config.api.ComponentType;
 import com.metamatrix.common.config.api.ComponentTypeDefn;
@@ -74,7 +75,6 @@
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
 import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
 import com.metamatrix.server.serverapi.RequestInfo;
 
 
@@ -282,8 +282,8 @@
     
     private Session convertConnection(MetaMatrixSessionInfo src) {
         MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
-        session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
-        session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION)); 
+        session.setVDBName(src.getProductInfo(MMURL.JDBC.VDB_NAME));
+        session.setVDBVersion(src.getProductInfo(MMURL.JDBC.VDB_VERSION)); 
         session.setApplicationName(src.getApplicationName());
         session.setIPAddress(src.getClientIp());
         session.setHostName(src.getClientHostname());

Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -40,6 +40,7 @@
 import com.google.inject.name.Named;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.common.api.MMURL;
 import com.metamatrix.common.application.AbstractClassLoaderManager;
 import com.metamatrix.common.application.ApplicationEnvironment;
 import com.metamatrix.common.application.exception.ApplicationInitializationException;
@@ -75,7 +76,6 @@
 import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
 import com.metamatrix.platform.security.api.service.SessionListener;
 import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
 import com.metamatrix.query.function.FunctionLibraryManager;
 import com.metamatrix.query.function.UDFSource;
 import com.metamatrix.vdb.runtime.BasicModelInfo;
@@ -1214,8 +1214,8 @@
              * A Client Connection to DQP has been removed  
              */
             public void sessionClosed(MetaMatrixSessionInfo session) {
-            	String vdbName = session.getProductInfo(ProductInfoConstants.VIRTUAL_DB);
-            	String vdbVersion = session.getProductInfo(ProductInfoConstants.VDB_VERSION);
+            	String vdbName = session.getProductInfo(MMURL.JDBC.VDB_NAME);
+            	String vdbVersion = session.getProductInfo(MMURL.JDBC.VDB_VERSION);
             	if (vdbName != null && vdbVersion != null) {
 	            	if (canDeleteVDB(vdbName, vdbVersion)) {
 	            		runVDBCleanUp(vdbName, vdbVersion);

Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -47,7 +47,6 @@
 import com.metamatrix.dqp.service.VDBLifeCycleListener;
 import com.metamatrix.dqp.service.VDBService;
 import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
 import com.metamatrix.vdb.runtime.BasicModelInfo;
 import com.metamatrix.vdb.runtime.BasicVDBDefn;
 
@@ -57,7 +56,6 @@
  * @since 4.3
  */
 public class EmbeddedVDBService extends EmbeddedBaseDQPService implements VDBService, VDBLifeCycleListener {   
-    static final String[] VDB_STATUS = {"INCOMPLETE", "INACTIVE", "ACTIVE", "DELETED"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     
     @Inject
     private DQPContextCache contextCache;
@@ -67,15 +65,37 @@
      * @param name
      * @param version
      * @return vdb if one found; execption otherwise
+     * @throws VirtualDatabaseDoesNotExistException 
      * @since 4.3
      */
     public VDBArchive getVDB(String vdbName, String vdbVersion) 
         throws MetaMatrixComponentException {        
-        VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
+        if (vdbVersion == null) {
+        	List<VDBArchive> vdbs = getAvailableVDBs();
+
+            // We are looking for the latest version find that now 
+        	int latestVersion = 0;
+            for (VDBArchive vdb:vdbs) {
+                if(vdb.getName().equalsIgnoreCase(vdbName)) {
+                    if (vdb.getStatus() == VDBStatus.ACTIVE_DEFAULT) {
+                    	latestVersion = Integer.parseInt(vdb.getVersion());
+                    	break;
+                    }
+                    latestVersion = Math.max(latestVersion, Integer.parseInt(vdb.getVersion()));
+                }
+            }
+            if(latestVersion == 0) {
+                throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, "latest")); //$NON-NLS-1$ //$NON-NLS-2$ 
+            }
+            vdbVersion = String.valueOf(latestVersion);
+        }
+    	
+    	VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
         // Make sure VDB is not null
         if (vdb == null) {
             throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", new Object[] {vdbName, vdbVersion})); //$NON-NLS-1$    
-        }        
+        }       
+        
         return vdb;
     }
         
@@ -223,23 +243,30 @@
         
         if (status != currentStatus) {            
             // Change the VDB's status
-        	VDBArchive sameVdb = vdb;
             if (currentStatus != VDBStatus.ACTIVE
                     && (status == VDBStatus.ACTIVE || status == VDBStatus.ACTIVE_DEFAULT) ) {
-                if (!isValidVDB(sameVdb) || !getConfigurationService().isFullyConfiguredVDB(sameVdb)) {
+                if (!isValidVDB(vdb) || !getConfigurationService().isFullyConfiguredVDB(vdb)) {
                     throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.vdb_missing_bindings", new Object[] {vdb.getName(), vdb.getVersion()})); //$NON-NLS-1$
                 }
             }
-            sameVdb.setStatus((short)status);
+            if (status == VDBStatus.ACTIVE_DEFAULT) {
+            	//only 1 can be set as active default
+            	VDBArchive latestActive = getVDB(vdbName, null);
+            	if (latestActive.getStatus() == VDBStatus.ACTIVE_DEFAULT) {
+            		latestActive.setStatus(VDBStatus.ACTIVE);
+                    getConfigurationService().saveVDB(latestActive, latestActive.getVersion());
+            	}
+            }
+            vdb.setStatus((short)status);
 
             // make sure we got what we asked for
-            if (status != sameVdb.getStatus()) {
-                throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.vdb_change_status_failed", new Object[] {vdbName, vdbVersion, VDB_STATUS[currentStatus-1], VDB_STATUS[status-1]})); //$NON-NLS-1$                
+            if (status != vdb.getStatus()) {
+                throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.vdb_change_status_failed", new Object[] {vdbName, vdbVersion, VDBStatus.VDB_STATUS_NAMES[currentStatus-1], VDBStatus.VDB_STATUS_NAMES[status-1]})); //$NON-NLS-1$                
             }
             
             // now save the change in the configuration. 
             getConfigurationService().saveVDB(vdb, vdb.getVersion());
-            DQPEmbeddedPlugin.logInfo("VDBService.vdb_change_status", new Object[] {vdbName, vdbVersion, VDB_STATUS[currentStatus-1], VDB_STATUS[status-1]}); //$NON-NLS-1$
+            DQPEmbeddedPlugin.logInfo("VDBService.vdb_change_status", new Object[] {vdbName, vdbVersion, VDBStatus.VDB_STATUS_NAMES[currentStatus-1], VDBStatus.VDB_STATUS_NAMES[status-1]}); //$NON-NLS-1$
         }
     }
     
@@ -282,32 +309,4 @@
 		this.contextCache.removeVDBScopedCache(vdbName, vdbVersion);
 	} 
 	
-    @Override
-    public String getActiveVDBVersion(String vdbName, String vdbVersion) throws MetaMatrixComponentException, VirtualDatabaseException {
-    	List<VDBArchive> vdbs = getAvailableVDBs();
-
-        // We are looking for the latest version find that now 
-        if (vdbVersion == null) {
-        	int latestVersion = 0;
-            for (VDBArchive vdb:vdbs) {
-                if(vdb.getName().equalsIgnoreCase(vdbName)) {
-                    // Make sure the VDB Name and version number are the only parts of this vdb key
-                    latestVersion = Math.max(latestVersion, Integer.parseInt(vdb.getVersion()));
-                }
-            }
-            if(latestVersion == 0) {
-                throw new VirtualDatabaseDoesNotExistException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, "latest")); //$NON-NLS-1$ //$NON-NLS-2$ 
-            }
-            vdbVersion = String.valueOf(latestVersion);
-        }
-        
-        // This below call will load the VDB from configuration into VDB service 
-        // if not already done so.
-        int status = getVDB(vdbName, vdbVersion).getStatus();
-        if (status != VDBStatus.ACTIVE) {
-            throw new VirtualDatabaseException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, vdbVersion)); //$NON-NLS-1$
-        }
-        return vdbVersion;
-    }
-
 }

Modified: trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -48,11 +48,11 @@
 import com.metamatrix.common.comm.api.ServerConnection;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.common.vdb.api.VDBArchive;
 import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.vdb.VDBStatus;
 import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
 import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.metadata.runtime.api.VirtualDatabaseDoesNotExistException;
-import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
 import com.metamatrix.platform.security.api.Credentials;
 import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
 import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
@@ -62,7 +62,6 @@
 import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
 import com.metamatrix.platform.security.api.service.SessionListener;
 import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
 
 /**
  * This class serves as the primary implementation of the Session Service.
@@ -115,7 +114,7 @@
 		if (info == null) {
 			throw new InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
 		}
-		if (info.getProductInfo(ProductInfoConstants.VIRTUAL_DB) != null) {
+		if (info.getProductInfo(MMURL.JDBC.VDB_NAME) != null) {
             try {
     			dqpCore.terminateConnection(info.getSessionToken().getSessionIDValue());
             } catch (Exception e) {
@@ -148,24 +147,22 @@
         //
         // Validate VDB and version if logging on to server product...
         //
-        String vdbName = properties.getProperty(ProductInfoConstants.VIRTUAL_DB);
+        String vdbName = properties.getProperty(MMURL.JDBC.VDB_NAME);
         if (vdbName != null) {
-            String vdbVersion = properties.getProperty(ProductInfoConstants.VDB_VERSION);
+            String vdbVersion = properties.getProperty(MMURL.JDBC.VDB_VERSION);
             try {
-            	vdbVersion = vdbService.getActiveVDBVersion(vdbName, vdbVersion);
-            } catch (VirtualDatabaseDoesNotExistException e) {
-                throw new SessionServiceException(e);
-            } catch (VirtualDatabaseException e) {
-                if (vdbVersion == null) {
-                    throw new SessionServiceException(e,DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.Unexpected_error_finding_latest_version_of_Virtual_Database", new Object[] {vdbName})); //$NON-NLS-1$
+            	VDBArchive vdb = vdbService.getVDB(vdbName, vdbVersion);
+                if (vdb.getStatus() != VDBStatus.ACTIVE && vdb.getStatus() != VDBStatus.ACTIVE_DEFAULT) {
+                    throw new SessionServiceException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, vdbVersion==null?"latest":vdbVersion)); //$NON-NLS-1$ //$NON-NLS-2$
                 }
-                throw new SessionServiceException(e,DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.Unexpected_error_finding_latest_version_of_Virtual_Database_{0}_of_version_{1}", new Object[] {vdbName, vdbVersion})); //$NON-NLS-1$
+                vdbName = vdb.getName();
+                vdbVersion = vdb.getVersion();
             } catch (MetaMatrixComponentException e) {
-				throw new SessionServiceException(e);
+                throw new SessionServiceException(e); 
 			}
             // Reset product info with validated constants
-            productInfo.put(ProductInfoConstants.VIRTUAL_DB, vdbName);
-            productInfo.put(ProductInfoConstants.VDB_VERSION, vdbVersion);
+            productInfo.put(MMURL.JDBC.VDB_NAME, vdbName);
+            productInfo.put(MMURL.JDBC.VDB_VERSION, vdbVersion);
         }
 
         if (sessionMaxLimit > 0 && getActiveSessionsCount() >= sessionMaxLimit) {
@@ -252,7 +249,7 @@
 		}
 		ArrayList<MetaMatrixSessionInfo> results = new ArrayList<MetaMatrixSessionInfo>();
 		for (MetaMatrixSessionInfo info : this.sessionCache.values()) {
-			if (VDBName.equalsIgnoreCase(info.getProductInfo(ProductInfoConstants.VIRTUAL_DB)) && VDBVersion.equalsIgnoreCase(info.getProductInfo(ProductInfoConstants.VDB_VERSION))) {
+			if (VDBName.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_NAME)) && VDBVersion.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_VERSION))) {
 				results.add(info);
 			}
 		}

Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -51,7 +51,6 @@
 import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
 
 public class LogonImpl implements ILogon {
 	
@@ -139,8 +138,8 @@
 		workContext.setSessionToken(sessionInfo.getSessionToken());
 		workContext.setAppName(sessionInfo.getApplicationName());
 		workContext.setTrustedPayload(sessionInfo.getTrustedToken());
-		workContext.setVdbName(sessionInfo.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
-		workContext.setVdbVersion(sessionInfo.getProductInfo(ProductInfoConstants.VDB_VERSION));
+		workContext.setVdbName(sessionInfo.getProductInfo(MMURL.JDBC.VDB_NAME));
+		workContext.setVdbVersion(sessionInfo.getProductInfo(MMURL.JDBC.VDB_VERSION));
 		return sessionID;
 	}
 		

Modified: trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties	2009-11-10 19:46:56 UTC (rev 1547)
@@ -44,7 +44,7 @@
 VDBConfigFileReader.Already_contains_connector_type=Configuration has two definitions for connector type \"{0}\".
 VDBConfigFileReader.No_connector_binding_in_config = A model \"{0}\" specifies a connector binding "{1}" for which there is no definition found in the configuration or VDB definition files.
 
-VDBService.VDB_does_not_exist._2=VDB \"{0}\" version \"{1}\" does not exist or not in valid state.
+VDBService.VDB_does_not_exist._2=VDB \"{0}\" version \"{1}\" is not active.
 VDBService.VDB_does_not_exist._3=In VDB \"{0}\" version \"{1}\" the Model \"{2}\" does not exist.
 VDBService.Model_does_not_exist._4=Model "{0}" does not exist.
 VDBService.0=Error trying to read visibility information from the vdb \"{0}\".

Modified: trunk/test-integration/common/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java	2009-11-09 16:41:36 UTC (rev 1546)
+++ trunk/test-integration/common/src/test/java/org/teiid/runtime/adminapi/TestEmbeddedAdmin.java	2009-11-10 19:46:56 UTC (rev 1547)
@@ -190,7 +190,7 @@
             admin.changeVDBStatus("DoesNotExist", "1", VDB.DELETED); //$NON-NLS-1$ //$NON-NLS-2$
             fail("Must have failed to delete a non existing VDB"); //$NON-NLS-1$
         } catch (AdminException err) {
-            assertEquals("VDB \"DoesNotExist\" version \"1\" does not exist or not in valid state.", err.getMessage()); //$NON-NLS-1$
+            assertEquals("VDB \"DoesNotExist\" version \"1\" is not active.", err.getMessage()); //$NON-NLS-1$
         } 
     }
 
@@ -211,7 +211,7 @@
             getConnection("DoesNotExist", configFile); //$NON-NLS-1$
             fail("found a Connection to a non avtive VDB"); //$NON-NLS-1$
         } catch (SQLException err) {
-            assertEquals("VDB \"DoesNotExist\" version \"latest\" does not exist or not in valid state.", err.getMessage()); //$NON-NLS-1$
+            assertEquals("VDB \"DoesNotExist\" version \"latest\" is not active.", err.getMessage()); //$NON-NLS-1$
         } 
     }
     
@@ -226,12 +226,31 @@
             conn = getConnection(VDB_NAME, configFile);
             fail("found a Connection to a non avtive VDB");                 //$NON-NLS-1$
         } catch (SQLException err) {
-            assertEquals("Unexpected error finding latest version of Virtual Database TestEmpty", err.getMessage()); //$NON-NLS-1$
+            assertEquals("VDB \"TestEmpty\" version \"latest\" is not active.", err.getMessage()); //$NON-NLS-1$
         } finally {
             cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
         }
     }
+    
+    @Test public void testGetConnectionToActiveDefault() throws Exception {
+        admin = getAdmin();
+        cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+        try {
+            admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
 
+            admin.changeVDBStatus(VDB_NAME, "1", VDB.ACTIVE_DEFAULT); //$NON-NLS-1$ 
+            
+            admin.addVDB(VDB_NAME, Util.getBinaryFile(VDB_FILE), new AdminOptions(AdminOptions.OnConflict.IGNORE));
+            
+            admin.changeVDBStatus(VDB_NAME, "2", VDB.ACTIVE); //$NON-NLS-1$
+            
+            conn = getConnection(VDB_NAME, configFile);
+            assertEquals("1", conn.getVDBVersion()); //$NON-NLS-1$
+        } finally {
+            cleanupVDB(admin, VDB_NAME, "1"); //$NON-NLS-1$
+            cleanupVDB(admin, VDB_NAME, "2"); //$NON-NLS-1$
+        }
+    }
     
     @Test public void testSelectNonPrepared() throws Exception {
         admin = getAdmin();



More information about the teiid-commits mailing list