Author: shawkins
Date: 2010-08-06 00:57:28 -0400 (Fri, 06 Aug 2010)
New Revision: 2421
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
Log:
TEIID-1187 updating connection type logic
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-08-05 20:13:20
UTC (rev 2420)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-08-06 04:57:28
UTC (rev 2421)
@@ -36,8 +36,6 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Model;
-import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.core.CoreConstants;
@@ -130,20 +128,23 @@
return new VDBKey(vdb.getName(), vdb.getVersion());
}
- public VDBMetaData getActiveVDB(String vdbName) throws VirtualDatabaseException {
+ public VDBMetaData getVDB(String vdbName) throws VirtualDatabaseException {
int latestVersion = 0;
for (VDBKey key:this.vdbRepo.tailMap(new VDBKey(vdbName, 0)).keySet()) {
if(!key.getName().equalsIgnoreCase(vdbName)) {
break;
}
VDBMetaData vdb = this.vdbRepo.get(key).getVDB();
- if (vdb.getStatus() == Status.ACTIVE) {
- if (vdb.getConnectionType() == ConnectionType.ANY) {
- latestVersion = Math.max(vdb.getVersion(), latestVersion);
- } else if (latestVersion == 0 && vdb.getConnectionType() ==
ConnectionType.BY_VERSION) {
+ switch (vdb.getConnectionType()) {
+ case ANY:
+ latestVersion = Math.max(vdb.getVersion(), latestVersion);
+ break;
+ case BY_VERSION:
+ if (latestVersion == 0) {
latestVersion = vdb.getVersion();
- }
- }
+ }
+ break;
+ }
}
if(latestVersion == 0) {
throw new
VirtualDatabaseException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, "latest")); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-08-05
20:13:20 UTC (rev 2420)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-08-06
04:57:28 UTC (rev 2421)
@@ -166,18 +166,19 @@
if (vdbName != null) {
String vdbVersion = properties.getProperty(TeiidURL.JDBC.VDB_VERSION);
if (vdbVersion == null) {
+ vdbVersion = "latest"; //$NON-NLS-1$
try {
- vdb = this.vdbRepository.getActiveVDB(vdbName);
+ vdb = this.vdbRepository.getVDB(vdbName);
} catch (VirtualDatabaseException e) {
- throw new
SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, "latest")); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new
SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, vdbVersion)); //$NON-NLS-1$
}
}
else {
vdb = this.vdbRepository.getVDB(vdbName, Integer.parseInt(vdbVersion));
- if (vdb.getStatus() != VDB.Status.ACTIVE || vdb.getConnectionType() ==
ConnectionType.NONE) {
- throw new
SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, vdbVersion)); //$NON-NLS-1$
- }
}
+ if (vdb.getStatus() != VDB.Status.ACTIVE || vdb.getConnectionType() ==
ConnectionType.NONE) {
+ throw new
SessionServiceException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, vdbVersion)); //$NON-NLS-1$
+ }
}
if (sessionMaxLimit > 0 && getActiveSessionsCount() >=
sessionMaxLimit) {
Show replies by date