teiid SVN: r4027 - in branches/8.0.x/client/src: test/java/org/teiid/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-23 14:13:47 -0400 (Mon, 23 Apr 2012)
New Revision: 4027
Removed:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java
Modified:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java
Log:
TEIID-2006 adding support for a set payload statement and optional encryption of requests and refactoring to simplify xaresourceimpl
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/BaseDataSource.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -350,11 +350,7 @@
* @see javax.sql.XADataSource#getXAConnection(java.lang.String, java.lang.String)
*/
public XAConnection getXAConnection(final String userName, final String password) throws java.sql.SQLException {
- return XAConnectionImpl.newInstance(new XAConnectionImpl.ConnectionSource() {
-
- public ConnectionImpl createConnection() throws SQLException {
- return (ConnectionImpl)getConnection(userName, password);
- }});
+ return new XAConnectionImpl((ConnectionImpl) getConnection(userName, password));
}
public PooledConnection getPooledConnection() throws SQLException {
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -100,7 +100,8 @@
private String debugLog;
// the last query annotations
private Collection<Annotation> annotations;
- private Properties connectionProps;
+ private Properties connectionProps;
+ private Properties payload;
public ConnectionImpl(ServerConnection serverConn, Properties info, String url) {
this.connectionProps = info;
@@ -829,6 +830,7 @@
}
public void recycleConnection() {
+ this.payload = null;
try {
//close all open statements
this.closeStatements();
@@ -1034,6 +1036,14 @@
public void setSchema(String schema) throws SQLException {
- }
-
+ }
+
+ public Properties getPayload() {
+ return payload;
+ }
+
+ public void setPayload(Properties payload) {
+ this.payload = payload;
+ }
+
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -156,8 +156,8 @@
protected Map<String, Integer> outParamByName = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
private static Pattern TRANSACTION_STATEMENT = Pattern.compile("\\s*(commit|rollback|(start\\s+transaction))\\s*;?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
- private static Pattern SET_STATEMENT = Pattern.compile("\\s*set\\s+((?:session authorization)|(?:\\w+))\\s+(?:([a-zA-Z](?:\\w|_)*)|((?:'[^']*')+));?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
- private static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s+(\\w*);?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private static Pattern SET_STATEMENT = Pattern.compile("\\s*set(?:\\s+(payload))?\\s+((?:session authorization)|(?:[a-zA-Z]\\w*))\\s+(?:([a-zA-Z]\\w*)|((?:'[^']*')+));?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private static Pattern SHOW_STATEMENT = Pattern.compile("\\s*show\\s+([a-zA-Z]\\w*);?", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
/**
* Factory Constructor
* @param driverConnection
@@ -430,14 +430,22 @@
if (resultsMode == ResultsMode.RESULTSET) {
throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.set_result_set")); //$NON-NLS-1$
}
- String key = match.group(1);
- String value = match.group(2);
+ String key = match.group(2);
+ String value = match.group(3);
if (value == null) {
- value = match.group(3);
+ value = match.group(4);
value = StringUtil.replaceAll(value, "''", "'"); //$NON-NLS-1$ //$NON-NLS-2$
value = value.substring(1, value.length() - 1);
}
- if ("SESSION AUTHORIZATION".equalsIgnoreCase(key)) { //$NON-NLS-1$
+ if (match.group(1) != null) {
+ //payload case
+ Properties p = this.getMMConnection().getPayload();
+ if (p == null) {
+ p = new Properties();
+ this.getMMConnection().setPayload(p);
+ }
+ p.setProperty(key, value);
+ } else if ("SESSION AUTHORIZATION".equalsIgnoreCase(key)) { //$NON-NLS-1$
this.getMMConnection().changeUser(value, this.getMMConnection().getPassword());
} else if (key.equalsIgnoreCase(TeiidURL.CONNECTION.PASSWORD)) {
this.getMMConnection().setPassword(value);
@@ -589,7 +597,11 @@
this.getConnection().beginLocalTxnIfNeeded();
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
- reqMsg.setExecutionPayload(this.payload);
+ if (this.payload != null) {
+ reqMsg.setExecutionPayload(this.payload);
+ } else {
+ reqMsg.setExecutionPayload(this.getMMConnection().getPayload());
+ }
reqMsg.setCursorType(this.resultSetType);
reqMsg.setFetchSize(this.fetchSize);
reqMsg.setRowLimit(this.maxRows);
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -32,15 +32,21 @@
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
import javax.sql.StatementEventListener;
import javax.sql.XAConnection;
+import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.util.ExceptionUtil;
+import org.teiid.client.xa.XATransactionException;
+import org.teiid.client.xa.XidImpl;
import org.teiid.net.CommunicationException;
import org.teiid.net.ServerConnection;
import org.teiid.net.socket.SingleInstanceCommunicationException;
@@ -48,14 +54,8 @@
/**
* Implementation of XAConnection.
*/
-public class XAConnectionImpl implements XAConnection{
+public class XAConnectionImpl implements XAConnection, XAResource {
- interface ConnectionSource {
-
- ConnectionImpl createConnection() throws SQLException;
-
- }
-
private final class CloseInterceptor implements
InvocationHandler {
@@ -69,8 +69,7 @@
Method method,
Object[] args) throws Throwable {
if ("close".equals(method.getName())) { //$NON-NLS-1$
- this.proxiedConnection.recycleConnection();
- XAConnectionImpl.this.notifyListener(null);
+ close();
return null;
}
@@ -99,28 +98,32 @@
throw e.getTargetException();
}
}
+
+ void close() {
+ this.proxiedConnection.recycleConnection();
+ XAConnectionImpl.this.notifyListener(null);
+ }
}
+ private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+
+ private int timeOut;
private Set<ConnectionEventListener> listeners;
- private XAResource resource;
private ConnectionImpl connection;
- private ConnectionSource cs;
-
+ private CloseInterceptor handler;
private boolean isClosed;
- public static XAConnectionImpl newInstance (ConnectionSource cs){
- return new XAConnectionImpl(cs);
- }
-
- public XAConnectionImpl(ConnectionSource cs){
- this.cs = cs;
+ public XAConnectionImpl(ConnectionImpl conn){
+ this.connection = conn;
}
public Connection getConnection() throws SQLException{
ConnectionImpl conn = getConnectionImpl();
-
- Connection result = (Connection)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {Connection.class}, new CloseInterceptor(conn));
-
+ if (handler != null) {
+ handler.close();
+ }
+ handler = new CloseInterceptor(conn);
+ Connection result = (Connection)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {Connection.class}, handler);
return result;
}
@@ -129,15 +132,6 @@
throw new SQLException(JDBCPlugin.Util.getString("MMXAConnection.connection_is_closed")); //$NON-NLS-1$
}
- if(connection == null){
- try{
- connection = cs.createConnection();
- }catch(SQLException e){
- notifyListener(e);
- throw e;
- }
- }
-
return connection;
}
@@ -156,10 +150,7 @@
}
public XAResource getXAResource() throws SQLException{
- if(resource == null){
- resource = XAResourceImpl.newInstance(this);
- }
- return resource;
+ return this;
}
public void close()throws SQLException{
@@ -195,4 +186,138 @@
public void removeStatementEventListener(StatementEventListener arg0) {
}
+
+ public void commit(Xid xid, boolean onePhase) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().commitTransaction(mmXid, onePhase);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedCommitTXN", xid, onePhase ? "true":"false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ private XAException handleError(Exception e,String logMsg) {
+ logger.log(Level.SEVERE, logMsg, e);
+
+ if(e instanceof TeiidSQLException){
+ Throwable ex = ((TeiidSQLException)e).getCause();
+ if(ex instanceof XAException){
+ return (XAException)ex;
+ }
+ if (ex instanceof XATransactionException) {
+ return ((XATransactionException)ex).getXAException();
+ }
+ }
+ return new XAException(XAException.XAER_RMERR);
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
+ */
+ public void end(Xid xid, int flag) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().endTransaction(mmXid, flag);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedEndTXN", xid, new Integer(flag)); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
+ */
+ public void forget(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().forgetTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedForgetTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return timeOut;
+ }
+
+ public boolean isSameRM(XAResource arg0) throws XAException {
+ if (arg0 == this) {
+ return true;
+ }
+ if (!(arg0 instanceof XAConnectionImpl)) {
+ return false;
+ }
+ XAConnectionImpl other = (XAConnectionImpl)arg0;
+ try {
+ return this.getMMConnection().isSameProcess(other.getMMConnection());
+ } catch (CommunicationException e) {
+ throw handleError(e, JDBCPlugin.Util.getString("MMXAResource.FailedISSameRM")); //$NON-NLS-1$
+ }
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ return getMMConnection().prepareTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedPrepareTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ /**
+ * @see javax.transaction.xa.XAResource#recover(int)
+ */
+ public Xid[] recover(int flag) throws XAException {
+ try{
+ return getMMConnection().recoverTransaction(flag);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRecoverTXN", flag); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().rollbackTransaction(mmXid);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRollbackTXN", xid); //$NON-NLS-1$
+ throw handleError(e, logMsg);
+ }
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ timeOut = seconds;
+ return true;
+ }
+
+ public void start(Xid xid, int flag) throws XAException {
+ XidImpl mmXid = getMMXid(xid);
+ try{
+ getMMConnection().startTransaction(mmXid, flag, timeOut);
+ }catch(SQLException e){
+ String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedStartTXN", xid, new Integer(flag)); //$NON-NLS-1$
+ handleError(e, logMsg);
+ }
+ }
+
+ private ConnectionImpl getMMConnection() throws XAException{
+ try{
+ return this.getConnectionImpl();
+ }catch(SQLException e){
+ throw new XAException(XAException.XAER_RMFAIL);
+ }
+ }
+
+ /**
+ * @param xid
+ * @return
+ * @throws XAException
+ */
+ private XidImpl getMMXid(Xid originalXid) {
+ return new XidImpl(originalXid);
+ }
}
Deleted: branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/XAResourceImpl.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -1,209 +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 org.teiid.jdbc;
-
-import java.sql.SQLException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.teiid.client.xa.XATransactionException;
-import org.teiid.client.xa.XidImpl;
-import org.teiid.net.CommunicationException;
-
-
-/**
- * Implementation of XAResource.
- */
-public class XAResourceImpl implements XAResource{
- private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
-
- private XAConnectionImpl mmConnection;
- private int timeOut;
-
- public static XAResourceImpl newInstance (XAConnectionImpl mmConnection){
- return new XAResourceImpl(mmConnection);
- }
-
- public XAResourceImpl(XAConnectionImpl mmConnection){
- this.mmConnection = mmConnection;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#commit(javax.transaction.xa.Xid, boolean)
- */
- public void commit(Xid xid, boolean onePhase) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().commitTransaction(mmXid, onePhase);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedCommitTXN", xid, onePhase ? "true":"false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- throw handleError(e, logMsg);
- }
- }
-
- private XAException handleError(Exception e,String logMsg) {
- logger.log(Level.SEVERE, logMsg, e);
-
- if(e instanceof TeiidSQLException){
- Throwable ex = ((TeiidSQLException)e).getCause();
- if(ex instanceof XAException){
- return (XAException)ex;
- }
- if (ex instanceof XATransactionException) {
- return ((XATransactionException)ex).getXAException();
- }
- }
- return new XAException(XAException.XAER_RMERR);
- }
-
- /**
- * @see javax.transaction.xa.XAResource#end(javax.transaction.xa.Xid, int)
- */
- public void end(Xid xid, int flag) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().endTransaction(mmXid, flag);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedEndTXN", xid, new Integer(flag)); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#forget(javax.transaction.xa.Xid)
- */
- public void forget(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().forgetTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedForgetTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#getTransactionTimeout()
- */
- public int getTransactionTimeout() throws XAException {
- return timeOut;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#isSameRM(javax.transaction.xa.XAResource)
- */
- public boolean isSameRM(XAResource arg0) throws XAException {
- if (arg0 == this) {
- return true;
- }
- if (!(arg0 instanceof XAResourceImpl)) {
- return false;
- }
- XAResourceImpl other = (XAResourceImpl)arg0;
- try {
- return this.getMMConnection().isSameProcess(other.getMMConnection());
- } catch (CommunicationException e) {
- throw handleError(e, JDBCPlugin.Util.getString("MMXAResource.FailedISSameRM")); //$NON-NLS-1$
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#prepare(javax.transaction.xa.Xid)
- */
- public int prepare(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- return getMMConnection().prepareTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedPrepareTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#recover(int)
- */
- public Xid[] recover(int flag) throws XAException {
- try{
- return getMMConnection().recoverTransaction(flag);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRecoverTXN", flag); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#rollback(javax.transaction.xa.Xid)
- */
- public void rollback(Xid xid) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().rollbackTransaction(mmXid);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedRollbackTXN", xid); //$NON-NLS-1$
- throw handleError(e, logMsg);
- }
- }
-
- /**
- * @see javax.transaction.xa.XAResource#setTransactionTimeout(int)
- */
- public boolean setTransactionTimeout(int seconds) throws XAException {
- timeOut = seconds;
- return true;
- }
-
- /**
- * @see javax.transaction.xa.XAResource#start(javax.transaction.xa.Xid, int)
- */
- public void start(Xid xid, int flag) throws XAException {
- XidImpl mmXid = getMMXid(xid);
- try{
- getMMConnection().startTransaction(mmXid, flag, timeOut);
- }catch(SQLException e){
- String logMsg = JDBCPlugin.Util.getString("MMXAResource.FailedStartTXN", xid, new Integer(flag)); //$NON-NLS-1$
- handleError(e, logMsg);
- }
- }
-
- private ConnectionImpl getMMConnection() throws XAException{
- try{
- return this.mmConnection.getConnectionImpl();
- }catch(SQLException e){
- throw new XAException(XAException.XAER_RMFAIL);
- }
- }
-
- /**
- * @param xid
- * @return
- * @throws XAException
- */
- private XidImpl getMMXid(Xid originalXid) {
- return new XidImpl(originalXid);
- }
-}
Modified: branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java
===================================================================
--- branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java 2012-04-23 17:02:11 UTC (rev 4026)
+++ branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestXAConnection.java 2012-04-23 18:13:47 UTC (rev 4027)
@@ -42,12 +42,7 @@
final ConnectionImpl mmConn = TestConnection.getMMConnection();
- XAConnectionImpl xaConn = new XAConnectionImpl(new XAConnectionImpl.ConnectionSource() {
- @Override
- public ConnectionImpl createConnection() throws SQLException {
- return mmConn;
- }
- });
+ XAConnectionImpl xaConn = new XAConnectionImpl(mmConn);
Connection conn = xaConn.getConnection();
StatementImpl stmt = (StatementImpl)conn.createStatement();
@@ -68,14 +63,9 @@
}
@Test public void testNotification() throws Exception {
- XAConnectionImpl xaConn = new XAConnectionImpl(new XAConnectionImpl.ConnectionSource() {
- @Override
- public ConnectionImpl createConnection() throws SQLException {
- ConnectionImpl c = Mockito.mock(ConnectionImpl.class);
- Mockito.doThrow(new SQLException(new InvalidSessionException())).when(c).commit();
- return c;
- }
- });
+ ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
+ Mockito.doThrow(new SQLException(new InvalidSessionException())).when(conn).commit();
+ XAConnectionImpl xaConn = new XAConnectionImpl(conn);
ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class);
xaConn.addConnectionEventListener(cel);
Connection c = xaConn.getConnection();
12 years, 8 months
teiid SVN: r4026 - in branches/8.0.x/client/src: main/java/org/teiid/client/security and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-23 13:02:11 -0400 (Mon, 23 Apr 2012)
New Revision: 4026
Added:
branches/8.0.x/client/src/main/java/org/teiid/client/security/Secure.java
Modified:
branches/8.0.x/client/src/main/java/org/teiid/client/DQP.java
branches/8.0.x/client/src/main/java/org/teiid/client/security/ILogon.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
branches/8.0.x/client/src/main/java/org/teiid/net/TeiidURL.java
branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestStatement.java
branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
Log:
TEIID-2006 adding support for a set payload statement and optional encryption of requests
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/DQP.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/DQP.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/DQP.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -26,6 +26,7 @@
import org.teiid.client.lob.LobChunk;
import org.teiid.client.metadata.MetadataResult;
+import org.teiid.client.security.Secure;
import org.teiid.client.util.ResultsFuture;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
@@ -35,6 +36,7 @@
public interface DQP {
+ @Secure(optional=true)
ResultsFuture<ResultsMessage> executeRequest(long reqID, RequestMessage message) throws TeiidProcessingException, TeiidComponentException;
ResultsFuture<ResultsMessage> processCursorRequest(long reqID, int batchFirst, int fetchSize) throws TeiidProcessingException;
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/security/ILogon.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/security/ILogon.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/security/ILogon.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -37,9 +37,11 @@
static final String KRB5TOKEN = "KRB5TOKEN"; //$NON-NLS-1$
static final String KRB5_ESTABLISHED = "KRB5_CONTEXT_ESTABLISHED"; //$NON-NLS-1$
+ @Secure
LogonResult logon(Properties connectionProperties)
throws LogonException, TeiidComponentException, CommunicationException;
+ @Secure
LogonResult neogitiateGssLogin(Properties connectionProperties, byte[] serviceToken, boolean createSession) throws LogonException;
/**
@@ -60,5 +62,6 @@
*/
ResultsFuture<?> logoff() throws InvalidSessionException, TeiidComponentException;
+ @Secure
void assertIdentity(SessionToken sessionId) throws InvalidSessionException, TeiidComponentException, CommunicationException;
}
Added: branches/8.0.x/client/src/main/java/org/teiid/client/security/Secure.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/security/Secure.java (rev 0)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/security/Secure.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -0,0 +1,40 @@
+/*
+ * 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 org.teiid.client.security;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+(a)Target({ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface Secure {
+
+ boolean optional() default false;
+
+}
Property changes on: branches/8.0.x/client/src/main/java/org/teiid/client/security/Secure.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -75,7 +75,8 @@
TeiidURL.CONNECTION.DISCOVERY_STRATEGY,
TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
TeiidURL.CONNECTION.JAAS_NAME,
- TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME));
+ TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME,
+ TeiidURL.CONNECTION.ENCRYPT_REQUESTS));
props.addAll(EXECUTION_PROPERTIES);
return Collections.unmodifiableSet(props);
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -109,6 +109,10 @@
* Name of Kerberos KDC service principle name
*/
private String kerberosServicePrincipleName;
+ /**
+ * If not using ssl determines whether requests with the associated command payload should be encrypted
+ */
+ private boolean encryptRequests;
public TeiidDataSource() {
}
@@ -523,5 +527,17 @@
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return TeiidDriver.logger;
}
+
+ public void setEncryptRequests(boolean encryptRequests) {
+ this.encryptRequests = encryptRequests;
+ }
+
+ public boolean isEncryptRequests() {
+ return encryptRequests;
+ }
+
+ public boolean getEncryptRequests() {
+ return encryptRequests;
+ }
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/net/TeiidURL.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/net/TeiidURL.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -84,6 +84,8 @@
public static final String JAAS_NAME = "jaasName"; //$NON-NLS-1$
public static final String KERBEROS_SERVICE_PRINCIPLE_NAME = "kerberosServicePrincipleName"; //$NON-NLS-1$;
+
+ public static final String ENCRYPT_REQUESTS = "encryptRequests"; //$NON-NLS-1$;
}
public static final String DOT_DELIMITER = "."; //$NON-NLS-1$
Modified: branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -49,6 +49,7 @@
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.gss.MakeGSS;
import org.teiid.jdbc.JDBCPlugin;
import org.teiid.net.CommunicationException;
@@ -210,7 +211,7 @@
}
public <T> T getService(Class<T> iface) {
- return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface) {
+ return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) {
@Override
protected SocketServerInstance getInstance() throws CommunicationException {
if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) {
Modified: branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -31,6 +31,7 @@
import java.lang.reflect.Proxy;
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -43,7 +44,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.teiid.client.security.ILogon;
+import org.teiid.client.security.Secure;
import org.teiid.client.util.ExceptionHolder;
import org.teiid.client.util.ExceptionUtil;
import org.teiid.client.util.ResultsFuture;
@@ -77,6 +78,7 @@
private Cryptor cryptor;
private String serverVersion;
private AuthenticationType authType = AuthenticationType.CLEARTEXT;
+ private HashMap<Class<?>, Object> serviceMap = new HashMap<Class<?>, Object>();
private boolean hasReader;
@@ -275,15 +277,19 @@
}
}
- @SuppressWarnings("unchecked")
@Override
- public <T> T getService(Class<T> iface) {
- return (T)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface) {
- @Override
- protected SocketServerInstanceImpl getInstance() {
- return SocketServerInstanceImpl.this;
- }
- });
+ public synchronized <T> T getService(Class<T> iface) {
+ Object service = this.serviceMap.get(iface);
+ if (service == null) {
+ service = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface, false) {
+ @Override
+ protected SocketServerInstanceImpl getInstance() {
+ return SocketServerInstanceImpl.this;
+ }
+ });
+ this.serviceMap.put(iface, service);
+ }
+ return iface.cast(service);
}
public long getSynchTimeout() {
@@ -292,12 +298,12 @@
public static abstract class RemoteInvocationHandler implements InvocationHandler {
- private boolean secure;
private Class<?> targetClass;
+ private boolean secureOptional;
- public RemoteInvocationHandler(Class<?> targetClass) {
+ public RemoteInvocationHandler(Class<?> targetClass, boolean secureOptional) {
this.targetClass = targetClass;
- this.secure = ILogon.class.isAssignableFrom(targetClass);
+ this.secureOptional = secureOptional;
}
@Override
@@ -309,7 +315,8 @@
Message message = new Message();
message.setContents(new ServiceInvocationStruct(args, method.getName(),
targetClass));
- if (secure) {
+ Secure secure = method.getAnnotation(Secure.class);
+ if (secure != null && (!secure.optional() || secureOptional)) {
message.setContents(instance.getCryptor().sealObject(message.getContents()));
}
ResultsFuture<Object> results = new ResultsFuture<Object>() {
Modified: branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestStatement.java
===================================================================
--- branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestStatement.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestStatement.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -71,6 +71,14 @@
assertEquals("b'ar", p.get("foo")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @Test public void testSetPayloadStatement() throws Exception {
+ ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
+ Properties p = new Properties();
+ Mockito.stub(conn.getExecutionProperties()).toReturn(p);
+ StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ assertFalse(statement.execute("set payload foo bar")); //$NON-NLS-1$
+ }
+
@Test public void testSetAuthorizationStatement() throws Exception {
ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
Properties p = new Properties();
Modified: branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-04-20 16:35:02 UTC (rev 4025)
+++ branches/8.0.x/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2012-04-23 17:02:11 UTC (rev 4026)
@@ -138,7 +138,7 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
- assertEquals(23, info.length);
+ assertEquals(24, info.length);
assertEquals(false, info[0].required);
assertEquals("ApplicationName", info[0].name); //$NON-NLS-1$
assertEquals("x", info[0].value); //$NON-NLS-1$
12 years, 8 months
teiid SVN: r4025 - in branches/8.0.x: build/kits/jboss-as7/docs/teiid and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-20 12:35:02 -0400 (Fri, 20 Apr 2012)
New Revision: 4025
Modified:
branches/8.0.x/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
branches/8.0.x/connectors/translator-hive/src/main/java/org/teiid/translator/hive/HiveExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
branches/8.0.x/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
Log:
TEIID-2010 removing unused methods
Modified: branches/8.0.x/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -192,18 +192,10 @@
return delegate.supportsBatchedUpdates();
}
@Override
- public boolean supportsBetweenCriteria() {
- return delegate.supportsBetweenCriteria();
- }
- @Override
public boolean supportsBulkUpdate() {
return delegate.supportsBulkUpdate();
}
@Override
- public boolean supportsCaseExpressions() {
- return delegate.supportsCaseExpressions();
- }
- @Override
public boolean supportsCommonTableExpressions() {
return delegate.supportsCommonTableExpressions();
}
Modified: branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -377,15 +377,6 @@
}
/**
- * Support indicates connector accepts criteria of form (element BETWEEN constant AND constant)
- * <br>NOT CURRENTLY USED - between is rewritten as compound compare criteria
- * @since 4.0
- */
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
- /**
* Support indicates connector accepts criteria of form (element = constant)
* @since 3.1 SP2
*/
@@ -633,16 +624,6 @@
}
/**
- * Support indicates connector can accept queries with non-searched
- * CASE <expression> WHEN <expression> ... END
- * <br>NOT CURRENTLY USED - case is pushed down as searched case
- * @since 4.0
- */
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- /**
* Support indicates connector can accept queries with searched CASE WHEN <criteria> ... END
* @since 4.0
*/
Modified: branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-04-20 16:35:02 UTC (rev 4025)
@@ -74,7 +74,8 @@
<li>The translator API facilities for iterator/bulk updates were combined and updated. Multi-valued literals were replaced by the Parameter class with an associated value iterator
available on the BatchedCommand. The IteratorValueSource class was also removed.
<li>VARBINARY, OPTIONS, and OUT were added as reserved words.
- <li>AbstractMetadataRecord and its sub-classes use a case-insensitive map for properties rather than a LinkedHashMap. Thus, property key lookups are now case-insensitive.
+ <li>AbstractMetadataRecord and its sub-classes use a case-insensitive map for properties rather than a LinkedHashMap. Thus, property key lookups are now case-insensitive.
+ <li>Removed the unused ExecutionFactory methods supportsBetweenCriteria and supportsCaseExpression.
</ul>
<h4>from 7.7</h4>
Modified: branches/8.0.x/connectors/translator-hive/src/main/java/org/teiid/translator/hive/HiveExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-hive/src/main/java/org/teiid/translator/hive/HiveExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-hive/src/main/java/org/teiid/translator/hive/HiveExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -128,17 +128,6 @@
}
@Override
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
- @Override
- public boolean supportsCaseExpressions() {
- //https://issues.apache.org/jira/browse/HIVE-164
- return true;
- }
-
- @Override
public boolean supportsCorrelatedSubqueries() {
//https://issues.apache.org/jira/browse/HIVE-784
return false;
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -325,16 +325,6 @@
}
@Override
- public boolean supportsBetweenCriteria() {
- return true;
- }
-
- @Override
- public boolean supportsCaseExpressions() {
- return true;
- }
-
- @Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -85,12 +85,6 @@
}
@Override
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
-
- @Override
public boolean supportsLikeCriteriaEscapeCharacter() {
return false;
}
@@ -161,11 +155,6 @@
}
@Override
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- @Override
public boolean supportsSearchedCaseExpressions() {
return false;
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -171,16 +171,7 @@
return supportedFunctions;
}
- /**
- * Derby supports only SearchedCaseExpression, not CaseExpression.
- * @since 5.0
- */
@Override
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- @Override
public boolean supportsRowLimit() {
return this.getDatabaseVersion().compareTo(TEN_5) >= 0;
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -194,11 +194,6 @@
}
@Override
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- @Override
public boolean supportsCorrelatedSubqueries() {
return false;
}
Modified: branches/8.0.x/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -27,11 +27,11 @@
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.Translator;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
import org.teiid.translator.TranslatorProperty;
/**
@@ -111,8 +111,8 @@
}
@Override
- public List getSupportedFunctions() {
- List functions = Arrays.asList(new String[] {
+ public List<String> getSupportedFunctions() {
+ List<String> functions = Arrays.asList(new String[] {
"+", "-", "*", "/", "abs", "acos", "asin", "atan", "atan2", "ceiling", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
"bitand", "bitnot", "bitor", "bitxor", "cos", "cot", "degrees", "cos", "cot", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
"degrees", "exp", "floor", "log", "log10", "mod", "pi", "power", "radians", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
@@ -174,16 +174,6 @@
}
@Override
- public boolean supportsBetweenCriteria() {
- return true;
- }
-
- @Override
- public boolean supportsCaseExpressions() {
- return true;
- }
-
- @Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2012-04-20 16:29:16 UTC (rev 4024)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2012-04-20 16:35:02 UTC (rev 4025)
@@ -81,7 +81,6 @@
tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
- tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
12 years, 8 months
teiid SVN: r4024 - in branches/8.0.x/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-20 12:29:16 -0400 (Fri, 20 Apr 2012)
New Revision: 4024
Modified:
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
Log:
TEIID-2009 allowing for a custom AuthorizationValidator to modify the command
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -33,8 +33,34 @@
*/
public interface AuthorizationValidator {
- void validate(Command command, QueryMetadataInterface metadata, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException;
+ enum CommandType {
+ USER,
+ PREPARED,
+ CACHED
+ }
+ /**
+ * Validates the given command. If the command is not a {@link CommandType#USER} command, the command object should not be modified.
+ * Any modification must be fully resolved using the associated {@link QueryMetadataInterface}. Returning true for a
+ * {@link CommandType#PREPARED} or {@link CommandType#CACHED} commands means that the matching prepared plan or cache entry
+ * will not be used.
+ * @param originalSql array of commands will typically contain only a single string, but may have multiple for batched updates.
+ * @param command the parsed and resolved command.
+ * @param metadata
+ * @param commandContext
+ * @param commandType
+ * @return true if the USER command was modified, or if the non-USER command should be modified.
+ * @throws QueryValidatorException
+ * @throws TeiidComponentException
+ */
+ boolean validate(String[] originalSql, Command command, QueryMetadataInterface metadata, CommandContext commandContext, CommandType commandType) throws QueryValidatorException, TeiidComponentException;
+
+ /**
+ *
+ * @param roleName
+ * @param commandContext
+ * @return true if the current user has the given role
+ */
boolean hasRole(String roleName, CommandContext commandContext);
boolean isEnabled();
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/DefaultAuthorizationValidator.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -41,11 +41,15 @@
}
@Override
- public void validate(Command command, QueryMetadataInterface metadata, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException {
+ public boolean validate(String[] originalSql, Command command,
+ QueryMetadataInterface metadata, CommandContext commandContext,
+ CommandType commandType) throws QueryValidatorException,
+ TeiidComponentException {
if (enabled && policyDecider.validateCommand(commandContext)) {
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.policyDecider, commandContext);
Request.validateWithVisitor(visitor, metadata, command);
}
+ return false;
}
@Override
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -35,6 +35,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.process.AuthorizationValidator.CommandType;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -131,6 +132,21 @@
String sqlQuery = requestMsg.getCommands()[0];
CacheID id = new CacheID(this.workContext, Request.createParseInfo(this.requestMsg), sqlQuery);
prepPlan = prepPlanCache.get(id);
+
+ if (prepPlan != null) {
+ ProcessorPlan cachedPlan = prepPlan.getPlan();
+ this.userCommand = prepPlan.getCommand();
+ if (validateAccess(requestMsg.getCommands(), userCommand, CommandType.PREPARED)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, requestId, "AuthorizationValidator indicates that the prepared plan for command will not be used"); //$NON-NLS-1$
+ prepPlan = null;
+ } else {
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
+ processPlan = cachedPlan.clone();
+ //already in cache. obtain the values from cache
+ analysisRecord = prepPlan.getAnalysisRecord();
+ }
+ }
+
if (prepPlan == null) {
//if prepared plan does not exist, create one
prepPlan = new PreparedPlan();
@@ -149,15 +165,7 @@
}
this.prepPlanCache.put(id, determinismLevel, prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
- }
- } else {
- ProcessorPlan cachedPlan = prepPlan.getPlan();
- this.userCommand = prepPlan.getCommand();
- validateAccess(userCommand);
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
- processPlan = cachedPlan.clone();
- //already in cache. obtain the values from cache
- analysisRecord = prepPlan.getAnalysisRecord();
+ }
}
if (requestMsg.isBatchedUpdate()) {
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -46,6 +46,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.AuthorizationValidator.CommandType;
import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
@@ -283,8 +284,6 @@
//ensure that the user command is distinct from the processing command
//rewrite and planning may alter options, symbols, etc.
QueryResolver.resolveCommand(command, metadata);
-
- this.userCommand = (Command)command.clone();
}
private void validateQuery(Command command)
@@ -386,8 +385,10 @@
resolveCommand(command);
- validateAccess(userCommand);
+ validateAccess(requestMsg.getCommands(), command, CommandType.USER);
+ this.userCommand = (Command) command.clone();
+
Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, true);
for (GroupSymbol groupSymbol : groups) {
if (groupSymbol.isTempTable()) {
@@ -465,11 +466,14 @@
this.context.setValidateXML(requestMsg.getValidationMode());
}
- protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
- createCommandContext(command);
+ protected boolean validateAccess(String[] commandStr, Command command, CommandType type) throws QueryValidatorException, TeiidComponentException {
+ if (context == null) {
+ createCommandContext(command);
+ }
if (this.authorizationValidator != null) {
- this.authorizationValidator.validate(command, metadata, context);
+ return this.authorizationValidator.validate(commandStr, command, metadata, context, type);
}
+ return false;
}
public void setExecutor(Executor executor) {
Modified: branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -45,12 +45,12 @@
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
-import org.teiid.core.BundleUtil;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.internal.process.AuthorizationValidator.CommandType;
import org.teiid.dqp.internal.process.DQPCore.CompletionListener;
import org.teiid.dqp.internal.process.DQPCore.FutureWork;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
@@ -520,9 +520,11 @@
this.resultsBuffer = cr.getResults();
request.initMetadata();
this.originalCommand = cr.getCommand(requestMsg.getCommandString(), request.metadata, pi);
- request.validateAccess(this.originalCommand);
- this.doneProducingBatches();
- return;
+ if (!request.validateAccess(requestMsg.getCommands(), this.originalCommand, CommandType.CACHED)) {
+ this.doneProducingBatches();
+ return;
+ }
+ LogManager.logDetail(LogConstants.CTX_DQP, requestID, "Cached result command to be modified, will not use the cached results", cacheId); //$NON-NLS-1$
}
} else {
LogManager.logDetail(LogConstants.CTX_DQP, requestID, "Parameters are not serializable - cache cannot be used for", cacheId); //$NON-NLS-1$
Modified: branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2012-04-20 14:50:45 UTC (rev 4023)
+++ branches/8.0.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2012-04-20 16:29:16 UTC (rev 4024)
@@ -35,6 +35,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.FakeTransactionService;
+import org.teiid.dqp.internal.process.AuthorizationValidator.CommandType;
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.parser.QueryParser;
@@ -88,10 +89,9 @@
drpd.setAllowFunctionCallsByDefault(true);
drav.setPolicyDecider(drpd);
request.setAuthorizationValidator(drav);
- request.validateAccess(command);
+ request.validateAccess(new String[] {QUERY}, command, CommandType.USER);
}
-
/**
* Test Request.processRequest().
* Test processing the same query twice, and make sure that doesn't cause problems.
@@ -165,7 +165,7 @@
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
message.setStatementType(StatementType.PREPARED);
- message.setParameterValues(new ArrayList());
+ message.setParameterValues(new ArrayList<Object>());
helpProcessMessage(message, cache, workContext);
@@ -173,7 +173,7 @@
//If this doesn't throw an exception, assume it was successful.
message = new RequestMessage(QUERY);
message.setStatementType(StatementType.PREPARED);
- message.setParameterValues(new ArrayList());
+ message.setParameterValues(new ArrayList<Object>());
helpProcessMessage(message, cache, workContext);
}
12 years, 8 months
teiid SVN: r4023 - branches/8.0.x/client/src/main/java/org/teiid/netty/handler/codec/serialization.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-20 10:50:45 -0400 (Fri, 20 Apr 2012)
New Revision: 4023
Modified:
branches/8.0.x/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
Log:
TEIID-2008 allowing the maxObejctSize to be settable
Modified: branches/8.0.x/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2012-04-19 18:05:03 UTC (rev 4022)
+++ branches/8.0.x/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2012-04-20 14:50:45 UTC (rev 4023)
@@ -22,24 +22,13 @@
*/
package org.teiid.netty.handler.codec.serialization;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.OutputStream;
-import java.io.StreamCorruptedException;
+import java.io.*;
import java.util.List;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.types.InputStreamFactory.StreamFactoryReference;
import org.teiid.core.util.ExternalizeUtil;
+import org.teiid.jdbc.JDBCPlugin;
/**
@@ -83,8 +72,7 @@
throw new StreamCorruptedException("invalid data length: " + dataLen); //$NON-NLS-1$
}
if (dataLen > maxObjectSize) {
- throw new StreamCorruptedException(
- "data length too big: " + dataLen + " (max: " + maxObjectSize + ')'); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new StreamCorruptedException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20028, dataLen, maxObjectSize));
}
}
fillBuffer();
12 years, 8 months
teiid SVN: r4022 - in branches/8.0.x/client/src/main: java/org/teiid/net/socket and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-19 14:05:03 -0400 (Thu, 19 Apr 2012)
New Revision: 4022
Modified:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCPlugin.java
branches/8.0.x/client/src/main/java/org/teiid/net/socket/OioOjbectChannelFactory.java
branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
branches/8.0.x/client/src/main/resources/teiid-client-settings.orig.properties
Log:
TEIID-2008 allowing the maxObejctSize to be settable
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCPlugin.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCPlugin.java 2012-04-19 17:44:05 UTC (rev 4021)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/JDBCPlugin.java 2012-04-19 18:05:03 UTC (rev 4022)
@@ -66,5 +66,6 @@
TEIID20025,
TEIID20026,
TEIID20027,
+ TEIID20028
}
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/net/socket/OioOjbectChannelFactory.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/net/socket/OioOjbectChannelFactory.java 2012-04-19 17:44:05 UTC (rev 4021)
+++ branches/8.0.x/client/src/main/java/org/teiid/net/socket/OioOjbectChannelFactory.java 2012-04-19 18:05:03 UTC (rev 4022)
@@ -49,7 +49,7 @@
public final class OioOjbectChannelFactory implements ObjectChannelFactory {
private final static int STREAM_BUFFER_SIZE = 1<<15;
- private final static int MAX_OBJECT_SIZE = 1 << 25;
+ private final static int DEFAULT_MAX_OBJECT_SIZE = 1 << 25;
private static Logger log = Logger.getLogger("org.teiid.client.sockets"); //$NON-NLS-1$
@@ -59,7 +59,7 @@
private ObjectInputStream inputStream;
private Object readLock = new Object();
- private OioObjectChannel(Socket socket) throws IOException {
+ private OioObjectChannel(Socket socket, int maxObjectSize) throws IOException {
log.fine("creating new OioObjectChannel"); //$NON-NLS-1$
this.socket = socket;
BufferedOutputStream bos = new BufferedOutputStream( socket.getOutputStream(), STREAM_BUFFER_SIZE);
@@ -69,7 +69,7 @@
outputStream.flush();
final ClassLoader cl = this.getClass().getClassLoader();
BufferedInputStream bis = new BufferedInputStream(socket.getInputStream(), STREAM_BUFFER_SIZE);
- inputStream = new ObjectDecoderInputStream(new DataInputStream(bis), cl, MAX_OBJECT_SIZE);
+ inputStream = new ObjectDecoderInputStream(new DataInputStream(bis), cl, maxObjectSize);
}
@Override
@@ -145,6 +145,7 @@
private boolean conserveBandwidth;
private int soTimeout = 3000;
private volatile SSLSocketFactory sslSocketFactory;
+ private int maxObjectSize = DEFAULT_MAX_OBJECT_SIZE;
public OioOjbectChannelFactory(Properties props) {
this.props = props;
@@ -176,7 +177,7 @@
socket.setTcpNoDelay(!conserveBandwidth); // enable Nagle's algorithm to conserve bandwidth
socket.connect(address);
socket.setSoTimeout(soTimeout);
- return new OioObjectChannel(socket);
+ return new OioObjectChannel(socket, maxObjectSize);
}
public int getSendBufferSize() {
@@ -206,6 +207,10 @@
public void setSoTimeout(int soTimeout) {
this.soTimeout = soTimeout;
}
+
+ public void setMaxObjectSize(int maxObjectSize) {
+ this.maxObjectSize = maxObjectSize;
+ }
public int getSoTimeout() {
return soTimeout;
Modified: branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-19 17:44:05 UTC (rev 4021)
+++ branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-19 18:05:03 UTC (rev 4022)
@@ -171,4 +171,5 @@
</drivers>
TEIID20008=Failed to load "org.jboss.teiid" module.
TEIID20023=connection closed
-TEIID20007=Duplicate Class
\ No newline at end of file
+TEIID20007=Duplicate Class
+TEIID20028=data length too big: {0} > max of {1}. You may need to adjust the maxObjectSize client setting.
\ No newline at end of file
Modified: branches/8.0.x/client/src/main/resources/teiid-client-settings.orig.properties
===================================================================
--- branches/8.0.x/client/src/main/resources/teiid-client-settings.orig.properties 2012-04-19 17:44:05 UTC (rev 4021)
+++ branches/8.0.x/client/src/main/resources/teiid-client-settings.orig.properties 2012-04-19 18:05:03 UTC (rev 4022)
@@ -127,3 +127,10 @@
#
org.teiid.sockets.conserveBandwidth=false
+
+#
+# Maximum number of bytes per server message.
+# May need to be increased when using custom types and/or large batch sizes.
+#
+
+org.teiid.sockets.maxObjectSize=33554432
12 years, 8 months
teiid SVN: r4021 - in branches/8.0.x: client/src/main/java/org/teiid/client/util and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-19 13:44:05 -0400 (Thu, 19 Apr 2012)
New Revision: 4021
Modified:
branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
branches/8.0.x/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidSQLWarning.java
branches/8.0.x/client/src/test/java/org/teiid/client/util/TestExceptionHolder.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
Log:
TEIID-2007 updating the ExceptionHolder to handle SQLException chains and correcting the JDBC handling of warnings
Modified: branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-04-18 18:03:49 UTC (rev 4020)
+++ branches/8.0.x/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-04-19 17:44:05 UTC (rev 4021)
@@ -80,6 +80,8 @@
<h4>from 7.7</h4>
<ul>
<li>parse/formatdate and parse/formattime are no longer pushdown functions. They are converted into parse/formattimestamp.
+ <li>SQLWarning exception chains attached to the ExecutionContext will be returned as a single TeiidSQLWarning rather than as individual TeiidSQLWarnings. See the TeiidSQLWarning javadocs
+for how to access the underlying SQLWarning chains.
</ul>
<h4>from 7.5</h4>
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2012-04-18 18:03:49 UTC (rev 4020)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2012-04-19 17:44:05 UTC (rev 4021)
@@ -22,14 +22,8 @@
package org.teiid.client.util;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
+import java.io.*;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -72,23 +66,27 @@
if (this.exception == null) {
Throwable t = buildException(classNames, message, stackTrace, code);
- if (t == null) {
- if (causeHolder != null) {
- this.exception = causeHolder.exception;
- }
+ if (causeHolder != null) {
+ t.initCause(causeHolder.exception);
}
- else {
- if (causeHolder != null) {
- t.initCause(causeHolder.exception);
+ this.exception = t;
+
+ if (this.exception instanceof SQLException) {
+ try {
+ int count = in.readInt();
+ for (int i = 0; i < count; i++) {
+ ExceptionHolder next = (ExceptionHolder)in.readObject();
+ if (next.exception instanceof SQLException) {
+ ((SQLException)this.exception).setNextException((SQLException) next.exception);
+ }
+ }
+ } catch (EOFException e) {
+
+ } catch (OptionalDataException e) {
+
}
- this.exception = t;
}
}
-
- if (this.exception == null) {
- this.exception = new TeiidRuntimeException(message);
- this.exception.setStackTrace(stackTrace);
- }
}
@Override
@@ -126,6 +124,22 @@
else {
out.writeObject(null);
}
+ // handle SQLException chains
+ if (exception instanceof SQLException) {
+ SQLException se = (SQLException)exception;
+ SQLException next = se.getNextException();
+ int count = 0;
+ while (next != null) {
+ count++;
+ next = next.getNextException();
+ }
+ out.writeInt(count);
+ next = se.getNextException();
+ while (next != null) {
+ out.writeObject(new ExceptionHolder(next, true));
+ next = next.getNextException();
+ }
+ }
}
public Throwable getException() {
@@ -133,30 +147,32 @@
}
private Throwable buildException(List<String> classNames, String message, StackTraceElement[] stackTrace, String code) {
- if (classNames.isEmpty()) {
- return null;
+ String originalClass = Exception.class.getName();
+
+ if (!classNames.isEmpty()) {
+ originalClass = classNames.get(0);
}
- String originalClass = classNames.get(0);
-
List<String> args = Arrays.asList(CorePlugin.Util.getString("ExceptionHolder.converted_exception", message, originalClass)); //$NON-NLS-1$
Throwable result = null;
for (String className : classNames) {
try {
result = (Throwable)ReflectionHelper.create(className, args, ExceptionHolder.class.getClassLoader());
- result.setStackTrace(stackTrace);
break;
} catch (TeiidException e1) {
//
}
}
- if (result instanceof TeiidException) {
+ if (result == null) {
+ result = new TeiidRuntimeException(args.get(0));
+ } else if (result instanceof TeiidException) {
((TeiidException)result).setCode(code);
((TeiidException)result).setOriginalType(classNames.get(0));
}
+ result.setStackTrace(stackTrace);
return result;
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidSQLWarning.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidSQLWarning.java 2012-04-18 18:03:49 UTC (rev 4020)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidSQLWarning.java 2012-04-19 17:44:05 UTC (rev 4021)
@@ -26,11 +26,33 @@
/**
- * Teiid specific SQLWarning
+ * Teiid specific SQLWarning<br>
+ * If the cause was a source SQLWarning, then you may need to consult
+ * the warning chain to get all warnings, see the example below.
+ *
+<code><pre>
+//warning will be an instanceof TeiidSQLWarning to convey model/source information
+SQLWarning warning = stmt.getWarnings();
+
+while (warning != null) {
+ Exception e = warning.getCause();
+ if (cause instanceof SQLWarning) {
+ //childWarning should now be the head of the source warning chain
+ SQLWarning childWarning = (SQLWarning)cause;
+ while (childWarning != null) {
+ //do something with childWarning
+ childWarning = childWarning.getNextWarning();
+ }
+ }
+ warning = warning.getNextWarning();
+}
+</pre></code>
+ *
*/
-
public class TeiidSQLWarning extends SQLWarning {
+ private static final long serialVersionUID = -7080782561220818997L;
+
private String modelName = "UNKNOWN"; // variable stores the name of the model for the atomic query //$NON-NLS-1$
private String sourceName = "UNKNOWN"; // variable stores name of the connector binding //$NON-NLS-1$
Modified: branches/8.0.x/client/src/test/java/org/teiid/client/util/TestExceptionHolder.java
===================================================================
--- branches/8.0.x/client/src/test/java/org/teiid/client/util/TestExceptionHolder.java 2012-04-18 18:03:49 UTC (rev 4020)
+++ branches/8.0.x/client/src/test/java/org/teiid/client/util/TestExceptionHolder.java 2012-04-19 17:44:05 UTC (rev 4021)
@@ -1,3 +1,25 @@
+/*
+ * 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 org.teiid.client.util;
import static org.junit.Assert.*;
@@ -18,7 +40,7 @@
import org.teiid.core.util.ReflectionHelper;
import org.teiid.core.util.UnitTestUtil;
-
+@SuppressWarnings("nls")
public class TestExceptionHolder {
@SuppressWarnings("all")
@@ -72,12 +94,43 @@
assertTrue(e instanceof BadException2);
assertEquals("Remote org.teiid.client.util.TestExceptionHolder$BadException2: I have foreign exception embedded in me", e.getMessage()); //$NON-NLS-1$
- // now unknown exception is not found, so promote known SQL exception up
e = e.getCause();
+ assertTrue(e instanceof TeiidRuntimeException);
+
+ e = e.getCause();
assertTrue(e instanceof SQLException);
+
assertEquals("Remote java.sql.SQLException: something bad happended", e.getMessage()); //$NON-NLS-1$
- }
+ }
+ @Test public void testSQLExceptionChain() throws Exception {
+ ClassLoader cl = new URLClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
+ Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", null, cl); //$NON-NLS-1$
+ SQLException se = new SQLException("something bad happended");
+ se.initCause(obj); //$NON-NLS-1$
+ SQLException se1 = new SQLException("something else bad happended");
+ se1.initCause(obj); //$NON-NLS-1$
+ se.setNextException(se1);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(new ExceptionHolder(se, false)); //$NON-NLS-1$
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ ExceptionHolder holder = (ExceptionHolder)ois.readObject();
+ Throwable e = holder.getException();
+ assertTrue(e instanceof SQLException);
+ assertEquals("Remote java.sql.SQLException: something bad happended", e.getMessage()); //$NON-NLS-1$
+
+ assertTrue(e.getCause() instanceof TeiidRuntimeException);
+
+ e = ((SQLException)e).getNextException();
+ assertTrue(e instanceof SQLException);
+
+ assertEquals("Remote java.sql.SQLException: something else bad happended", e.getMessage()); //$NON-NLS-1$
+ }
+
@Test public void testDeserializationUnknownChildException2() throws Exception {
ClassLoader cl = new URLClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
ArrayList<String> args = new ArrayList<String>();
@@ -93,7 +146,7 @@
ExceptionHolder holder = (ExceptionHolder)ois.readObject();
Throwable e = holder.getException();
assertTrue(e instanceof TeiidRuntimeException);
- assertEquals("Unknown Exception", e.getMessage()); //$NON-NLS-1$
+ assertEquals("Remote test.UnknownException: Unknown Exception", e.getMessage()); //$NON-NLS-1$
}
private static class NotSerializable {
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2012-04-18 18:03:49 UTC (rev 4020)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2012-04-19 17:44:05 UTC (rev 4021)
@@ -193,15 +193,15 @@
public void addStatementWarnings() throws SQLException {
SQLWarning warning = this.statement.getWarnings();
- while (warning != null) {
- SQLWarning toAdd = warning;
- warning = toAdd.getNextWarning();
- toAdd.setNextException(null);
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId() + " Warning: ", warning); //$NON-NLS-1$
- }
- context.addWarning(toAdd);
- }
+ if (warning != null) {
+ context.addWarning(warning);
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
+ while (warning != null) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId() + " Warning: ", warning); //$NON-NLS-1$
+ warning = warning.getNextWarning();
+ }
+ }
+ }
this.statement.clearWarnings();
}
}
12 years, 8 months
teiid SVN: r4020 - in branches/8.0.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-18 14:03:49 -0400 (Wed, 18 Apr 2012)
New Revision: 4020
Modified:
branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
Log:
TEIID-2005 fixing oracle sequence issue and updating javadocs
Modified: branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18 18:03:19 UTC (rev 4019)
+++ branches/8.0.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18 18:03:49 UTC (rev 4020)
@@ -685,7 +685,10 @@
/**
* Get list of all supported function names. Arithmetic functions have names like
* "+".
- * @see SourceSystemFunctions
+ * @see SourceSystemFunctions for a listing of system pushdown functions. Note that
+ * not all system functions are listed as some functions will use a common name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
* @since 3.1 SP3
*/
public List<String> getSupportedFunctions() {
Modified: branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18 18:03:19 UTC (rev 4019)
+++ branches/8.0.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18 18:03:49 UTC (rev 4020)
@@ -27,6 +27,10 @@
* The names and function forms follow the Open Group CLI functions, with a few exceptions
* (such as lpad, rpad, bitand, bitor, etc. which are most notably supported by Oracle).
*
+ * Note that not all system functions are listed as some functions will use a common name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
+ *
*/
public class SourceSystemFunctions {
Modified: branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18 18:03:19 UTC (rev 4019)
+++ branches/8.0.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18 18:03:49 UTC (rev 4020)
@@ -41,6 +41,7 @@
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -493,6 +494,34 @@
super.visit(obj);
}
+ public void visit(NamedTable table) {
+ stripDualAlias(table);
+ super.visit(table);
+ }
+
+ private void stripDualAlias(NamedTable table) {
+ if (table.getCorrelationName() != null) {
+ String groupName = null;
+ AbstractMetadataRecord groupID = table.getMetadataObject();
+ if(groupID != null) {
+ groupName = getName(groupID);
+ } else {
+ groupName = table.getName();
+ }
+ if (DUAL.equalsIgnoreCase(groupName)) {
+ table.setCorrelationName(null);
+ }
+ }
+ }
+
+ @Override
+ public void visit(ColumnReference obj) {
+ if (obj.getTable() != null) {
+ stripDualAlias(obj.getTable());
+ }
+ super.visit(obj);
+ }
+
};
}
Modified: branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18 18:03:19 UTC (rev 4019)
+++ branches/8.0.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18 18:03:49 UTC (rev 4020)
@@ -655,8 +655,8 @@
* @since 4.3
*/
@Test public void testDUAL() throws Exception {
- String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
- String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
+ String input = "SELECT something FROM DUAL as g0"; //$NON-NLS-1$
+ String output = "SELECT seq.nextval FROM DUAL"; //$NON-NLS-1$
helpTestVisitor(getOracleSpecificMetadata(),
input,
@@ -776,14 +776,15 @@
cols.get(1).setNameInSource("ID:SEQUENCE=MYSEQUENCE.nextVal"); //$NON-NLS-1$
cols.get(2).setNativeType("date"); //$NON-NLS-1$
cols.get(3).setNativeType("CHAR");
- RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ List<Column> dualCols = RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ dualCols.get(0).setNameInSource("seq.nextval");
ProcedureParameter in1 = RealMetadataFactory.createParameter("in1", SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
ColumnSet<Procedure> rs3 = RealMetadataFactory.createResultSet("proc.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
Procedure p = RealMetadataFactory.createStoredProcedure("proc", foo, Arrays.asList(in1));
p.setResultSet(rs3);
p.setProperty(SQLConversionVisitor.TEIID_NATIVE_QUERY, "select x from y where z = $1");
-
+
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
return new TransformationMetadata(null, store, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
12 years, 8 months
teiid SVN: r4019 - in branches/7.7.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-18 14:03:19 -0400 (Wed, 18 Apr 2012)
New Revision: 4019
Modified:
branches/7.7.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/7.7.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-2005 fixing oracle sequence and expanding javadocs
Modified: branches/7.7.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18 15:28:57 UTC (rev 4018)
+++ branches/7.7.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-04-18 18:03:19 UTC (rev 4019)
@@ -683,7 +683,11 @@
/**
* Get list of all supported function names. Arithmetic functions have names like
- * "+".
+ * "+".
+ * @see SourceSystemFunctions for a listing of system pushdown functions. Note that
+ * not all system functions are listed as some functions will use a common name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
* @since 3.1 SP3
*/
public List<String> getSupportedFunctions() {
Modified: branches/7.7.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18 15:28:57 UTC (rev 4018)
+++ branches/7.7.x/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-04-18 18:03:19 UTC (rev 4019)
@@ -27,6 +27,10 @@
* The names and function forms follow the Open Group CLI functions, with a few exceptions
* (such as lpad, rpad, bitand, bitor, etc. which are most notably supported by Oracle).
*
+ * Note that not all system functions are listed as some functions will use a common name
+ * such as CONCAT vs. the || operator, and other functions will be rewritten and
+ * not pushed down, such as SPACE.
+ *
*/
public class SourceSystemFunctions {
Modified: branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18 15:28:57 UTC (rev 4018)
+++ branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-04-18 18:03:19 UTC (rev 4019)
@@ -41,6 +41,7 @@
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -493,6 +494,34 @@
super.visit(obj);
}
+ public void visit(NamedTable table) {
+ stripDualAlias(table);
+ super.visit(table);
+ }
+
+ private void stripDualAlias(NamedTable table) {
+ if (table.getCorrelationName() != null) {
+ String groupName = null;
+ AbstractMetadataRecord groupID = table.getMetadataObject();
+ if(groupID != null) {
+ groupName = getName(groupID);
+ } else {
+ groupName = table.getName();
+ }
+ if (DUAL.equalsIgnoreCase(groupName)) {
+ table.setCorrelationName(null);
+ }
+ }
+ }
+
+ @Override
+ public void visit(ColumnReference obj) {
+ if (obj.getTable() != null) {
+ stripDualAlias(obj.getTable());
+ }
+ super.visit(obj);
+ }
+
};
}
Modified: branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18 15:28:57 UTC (rev 4018)
+++ branches/7.7.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-04-18 18:03:19 UTC (rev 4019)
@@ -655,8 +655,8 @@
* @since 4.3
*/
@Test public void testDUAL() throws Exception {
- String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
- String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
+ String input = "SELECT something FROM DUAL as g0"; //$NON-NLS-1$
+ String output = "SELECT seq.nextval FROM DUAL"; //$NON-NLS-1$
helpTestVisitor(getOracleSpecificMetadata(),
input,
@@ -776,14 +776,15 @@
cols.get(1).setNameInSource("ID:SEQUENCE=MYSEQUENCE.nextVal"); //$NON-NLS-1$
cols.get(2).setNativeType("date"); //$NON-NLS-1$
cols.get(3).setNativeType("CHAR");
- RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ List<Column> dualCols = RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+ dualCols.get(0).setNameInSource("seq.nextval");
ProcedureParameter in1 = RealMetadataFactory.createParameter("in1", SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
ColumnSet<Procedure> rs3 = RealMetadataFactory.createResultSet("proc.rs1", new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
Procedure p = RealMetadataFactory.createStoredProcedure("proc", foo, Arrays.asList(in1));
p.setResultSet(rs3);
p.setProperty(SQLConversionVisitor.TEIID_NATIVE_QUERY, "select x from y where z = $1");
-
+
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
return new TransformationMetadata(null, store, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
Modified: branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2012-04-18 15:28:57 UTC (rev 4018)
+++ branches/7.7.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2012-04-18 18:03:19 UTC (rev 4019)
@@ -353,7 +353,7 @@
<emphasis>oracle</emphasis> - for use with Oracle 9i or later.
Sequences may be used with the Oracle translator. A sequence may be
modeled as a table with a name in source of DUAL and columns with the
- name in source set to <code><sequencesequence name>.[nextval|currentval].</code>
+ name in source set to <code><sequence name>.[nextval|currentval].</code>
You can use a sequence as the default value for insert columns by
setting the column to autoincrement and the name in source to
<code><element name>:SEQUENCE=<sequence name>.<sequence value></code>.
12 years, 8 months
teiid SVN: r4018 - in branches/8.0.x: common-core/src/main/java/org/teiid/core/util and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-04-18 11:28:57 -0400 (Wed, 18 Apr 2012)
New Revision: 4018
Modified:
branches/8.0.x/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
branches/8.0.x/common-core/src/main/java/org/teiid/core/util/SqlUtil.java
branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
Log:
TEIID-2004 updating for 1.7 builds
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -681,4 +681,13 @@
setObject((Object)parameterName, val);
}
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
}
\ No newline at end of file
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -32,6 +32,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -1005,6 +1006,34 @@
setPassword(oldPassword);
}
}
+ }
+
+ public void abort(Executor executor) throws SQLException {
+ if (closed) {
+ return;
+ }
+ //TODO: ensure that threads are released. In theory they will be since close effectively cancels current executions
+ close();
+ }
+
+ public int getNetworkTimeout() throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
+ public String getSchema() throws SQLException {
+ return null;
+ }
+
+ /**
+ * @see query timeouts and the synchronousTtl setting if using socket connections
+ */
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
+ public void setSchema(String schema) throws SQLException {
+
}
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -446,14 +446,13 @@
/**
* <p>Gets a description of the access rights for a column of the given name.
- * Catalog, schema and table names are not used to narrow down the search,
- * but the schema name should match the virtualdatabasename used to obtain
+ * Catalog name should match the virtualdatabasename used to obtain
* this driver connection.</p>
* @param name of the catalog to which columns belong.
* @param name of the schema to which columns belong.
* @param name of the table to which columns belong.
* @param name pattern to be matched by column names.
- * @return ResultSet containing column privilage information.
+ * @return ResultSet containing column privilege information.
* @throws SQLException if there is an error obtaining server results
*/
public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnName) throws SQLException {
@@ -487,9 +486,8 @@
/**
* <p>Get's the metadata information about the columns whose names match the given
- * columnNamePattern. Catalog, schema and tableNamePattern are not used to
- * narrow down the search, but Catalog and schema names should match the
- * virtualdatabasename and version used to obtain this driver connection.</p>
+ * columnNamePattern. Catalog names should match the
+ * virtualdatabasename used to obtain this driver connection.</p>
* <p> The ResultSet returned by this method contains the following additional
* columns that are not specified in the JDBC specification.</p>
* <OL>
@@ -594,9 +592,8 @@
/**
* <p>Gets the description of the foreign key columns in the table foreignTable.
* These foreign key columns reference primary key columns of primaryTable.
- * Catalog and schema information is not used to narrow down the search, but
- * Catalog and schema names(primary and foreign) should match the
- * virtualdatabasename and version used to obtain this driver connection.
+ * Catalog names(primary and foreign) should match the
+ * virtualdatabasename used to obtain this driver connection.
* @param name of the catalog containing primary keys.
* @param name of the schema containing primary keys.
* @param name of the table containing primary keys.
@@ -1985,7 +1982,7 @@
}
public boolean supportsGroupByUnrelated() throws SQLException {
- return false;
+ return true;
}
public boolean supportsIntegrityEnhancementFacility() throws SQLException {
@@ -2004,22 +2001,10 @@
return true;
}
- /**
- * <p>Checks whether mixed-case unquoted SQL identifiers used in SQL statements are
- * case sensitive</p>
- * @return if so return true, else false.
- * @throws SQLException, should never occur.
- */
public boolean supportsMixedCaseIdentifiers() throws SQLException {
return false;
}
- /**
- * <p>Checks whether mixed-case quoted SQL identifiers used in SQL statements are
- * case sensitive</p>
- * @return if so return true, else false.
- * @throws SQLException, should never occur.
- */
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
return false;
}
@@ -2028,36 +2013,20 @@
return false;
}
- /**
- * <p>Are multiple ResultSets from a single execute supported?</p>
- * @return <code>true</code> if so; <code>false</code> otherwise
- * @throws SQLException, should never occur
- */
public boolean supportsMultipleResultSets() throws SQLException {
return false;
}
- /**
- * Retrieves whether it is possible to have multiple ResultSet objects
- * returned from a CallableStatement object simultaneously.
- * @return <code>true</code> if so; <code>false</code> otherwise
- * @throws SQLException, should never occur
- */
public boolean supportsMultipleOpenResults() throws SQLException {
return false;
}
- /**
- * <p>Checks whether multiple transactions open at once on different connectons</p>
- * @return if so return true, else false.
- * @throws SQLException, should never occur.
- */
public boolean supportsMultipleTransactions() throws SQLException {
return true;
}
public boolean supportsNamedParameters() throws SQLException {
- return false;
+ return true;
}
public boolean supportsNonNullableColumns() throws SQLException {
@@ -2076,11 +2045,6 @@
return true;
}
- /**
- * <p>Checks whether an ORDER BY clause can use columns that are not in the SELECT clause.</p>
- * @return if so return true, else false.
- * @throws SQLException, should never occur.
- */
public boolean supportsOrderByUnrelated() throws SQLException {
return true;
}
@@ -2115,7 +2079,6 @@
* @param intValue holdability
* @return boolean true if so; false otherwise
* @throws SQLException, should never occur
-
*/
public boolean supportsResultSetHoldability(int holdability) throws SQLException {
return false;
@@ -2354,4 +2317,14 @@
}
}
}
+
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ return false;
+ }
+
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern,
+ String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -1666,4 +1666,13 @@
throws SQLException {
throw SqlUtil.createFeatureNotSupportedException();
}
+
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -1108,4 +1108,12 @@
return metadataMap;
}
+
+ public void closeOnCompletion() throws SQLException {
+ throw SqlUtil.createFeatureNotSupportedException();
+ }
+
+ public boolean isCloseOnCompletion() throws SQLException {
+ return false;
+ }
}
\ No newline at end of file
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -24,7 +24,9 @@
import java.net.MalformedURLException;
import java.sql.Connection;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
+import java.util.logging.Logger;
import org.teiid.net.TeiidURL;
@@ -517,5 +519,9 @@
public void setKerberosServicePrincipleName(String kerberosServerName) {
this.kerberosServicePrincipleName = kerberosServerName;
}
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ return TeiidDriver.logger;
+ }
}
Modified: branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/client/src/main/java/org/teiid/jdbc/TeiidDriver.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -27,6 +27,7 @@
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
@@ -55,7 +56,7 @@
public class TeiidDriver implements Driver {
- private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
+ static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
static final String DRIVER_NAME = "Teiid JDBC Driver"; //$NON-NLS-1$
private static TeiidDriver INSTANCE = new TeiidDriver();
@@ -235,6 +236,10 @@
public boolean jdbcCompliant() {
return false;
}
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ return logger;
+ }
}
Modified: branches/8.0.x/common-core/src/main/java/org/teiid/core/util/SqlUtil.java
===================================================================
--- branches/8.0.x/common-core/src/main/java/org/teiid/core/util/SqlUtil.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/common-core/src/main/java/org/teiid/core/util/SqlUtil.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -87,6 +87,6 @@
public static SQLException createFeatureNotSupportedException() {
StackTraceElement ste = new Exception().getStackTrace()[1];
String methodName = ste.getMethodName();
- return new SQLFeatureNotSupportedException(methodName + " is not supported");
+ return new SQLFeatureNotSupportedException(methodName + " is not supported"); //$NON-NLS-1$
}
}
Modified: branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
===================================================================
--- branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -28,7 +28,15 @@
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
import java.util.concurrent.Semaphore;
import org.jboss.vfs.VirtualFile;
@@ -375,19 +383,6 @@
List<Table> records = recs;
- //load non-materialized first, so that the uuid->table cache is populated
- Collections.sort(records, new Comparator<Table>() {
- @Override
- public int compare(Table o1, Table o2) {
- if (!o1.isMaterialized()) {
- return -1;
- }
- if (!o2.isMaterialized()) {
- return 1;
- }
- return 0;
- }
- });
for (Table tableRecord : records) {
List<Column> columns = new ArrayList<Column>(getByParent(tableRecord.getUUID(), MetadataConstants.RECORD_TYPE.COLUMN, Column.class, false));
for (Column columnRecordImpl : columns) {
Modified: branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
--- branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2012-04-18 15:24:25 UTC (rev 4017)
+++ branches/8.0.x/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2012-04-18 15:28:57 UTC (rev 4018)
@@ -825,7 +825,7 @@
expected.put("supportsGetGeneratedKeys", Boolean.FALSE); //$NON-NLS-1$
expected.put("supportsGroupBy", Boolean.TRUE); //$NON-NLS-1$
expected.put("supportsGroupByBeyondSelect", Boolean.TRUE); //$NON-NLS-1$
- expected.put("supportsGroupByUnrelated", Boolean.FALSE); //$NON-NLS-1$
+ expected.put("supportsGroupByUnrelated", Boolean.TRUE); //$NON-NLS-1$
expected.put("supportsIntegrityEnhancementFacility", Boolean.FALSE); //$NON-NLS-1$
expected.put("supportsLikeEscapeClause", Boolean.TRUE); //$NON-NLS-1$
expected.put("supportsLimitedOuterJoins", Boolean.TRUE); //$NON-NLS-1$
@@ -836,7 +836,7 @@
expected.put("supportsMultipleResultSets", Boolean.FALSE); //$NON-NLS-1$
expected.put("supportsMultipleOpenResults", Boolean.FALSE); //$NON-NLS-1$
expected.put("supportsMultipleTransactions", Boolean.TRUE); //$NON-NLS-1$
- expected.put("supportsNamedParameters", Boolean.FALSE); //$NON-NLS-1$
+ expected.put("supportsNamedParameters", Boolean.TRUE); //$NON-NLS-1$
expected.put("supportsNonNullableColumns", Boolean.TRUE); //$NON-NLS-1$
expected.put("supportsOpenCursorsAcrossRollback", Boolean.FALSE); //$NON-NLS-1$
expected.put("supportsOpenStatementsAcrossCommit", Boolean.TRUE); //$NON-NLS-1$
12 years, 8 months