teiid SVN: r2620 - branches/7.1.x/connectors/translator-jdbc/src/test/resources.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-09-30 14:43:06 -0400 (Thu, 30 Sep 2010)
New Revision: 2620
Modified:
branches/7.1.x/connectors/translator-jdbc/src/test/resources/ModeShape.vdb
Log:
Updated the ModeShape.vdb that contains the functions model
Modified: branches/7.1.x/connectors/translator-jdbc/src/test/resources/ModeShape.vdb
===================================================================
(Binary files differ)
14 years, 3 months
teiid SVN: r2619 - branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-09-30 14:32:44 -0400 (Thu, 30 Sep 2010)
New Revision: 2619
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
Log:
TEIID-1168 fixing the blob, clob resultset comparison
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-28 21:37:16 UTC (rev 2618)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-30 18:32:44 UTC (rev 2619)
@@ -171,14 +171,14 @@
this.testResultsSummary.addTestResult(query.geQuerySetID(), rs);
+//
+// try {
+// System.out.println("HANDLE RESULT " + this.internalResultSet.isClosed());
+// } catch (SQLException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
- try {
- System.out.println("HANDLE RESULT " + this.internalResultSet.isClosed());
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount, resultFromQuery, sql);
}
14 years, 3 months
teiid SVN: r2618 - in branches/7.1.x/test-integration/db/src/main/java/org/teiid/test: client/ctc and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-09-28 17:37:16 -0400 (Tue, 28 Sep 2010)
New Revision: 2618
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
TEIID-1168 changs to stream out the blob/clob to a string before comparing to expected results, can no longer call object.toString()
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -166,11 +166,21 @@
testStatus, beginTS, endTS, resultException, null);
- this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount, resultFromQuery, sql);
-
+ System.out.println("ADD THE TEST RESULT");
+
this.testResultsSummary.addTestResult(query.geQuerySetID(), rs);
+
+ try {
+ System.out.println("HANDLE RESULT " + this.internalResultSet.isClosed());
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount, resultFromQuery, sql);
+
}
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -80,6 +80,14 @@
}
public synchronized void addTestResult(String querySetID, TestResult result) {
+
+ if (result == null) {
+ System.err
+ .println("Error - trying to add a null result set for querysetID: " + querySetID); //$NON-NLS-1$
+ throw new RuntimeException(
+ "Error - trying to add a null result set for querysetID: " + querySetID); //$NON-NLS-1$
+
+ }
Collection<TestResult> results = null;
if (this.testResults.containsKey(querySetID)) {
results = this.testResults.get(querySetID);
@@ -92,7 +100,7 @@
}
public Collection<TestResult> getTestResults(String querySetID) {
- return this.testResults.get(querySetID);
+ return this.testResults.get(querySetID);
}
private static PrintStream getSummaryStream(String outputDir,
@@ -397,7 +405,10 @@
String outputDir = scenario.getResultsGenerator().getOutputDir();
// CombinedTestClient.log("Calculating and printing result statistics"); //$NON-NLS-1$
- if (testResults.size() > 0) {
+ if (testResults == null) {
+ // do nothing
+
+ } else if (testResults.size() > 0) {
// Create output file
String outputFileName = generateFileName(querySetID, System
.currentTimeMillis(), runNumber);
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -61,12 +61,6 @@
}
validateResultsMode(this.getProperties());
-
-// try {
-// setupVDBs(this.getProperties());
-// } catch (IOException e) {
-// throw new TransactionRuntimeException(e.getMessage());
-// }
}
@@ -85,45 +79,43 @@
public void handleTestResult(TestResult tr, ResultSet resultSet, int updatecnt, boolean resultFromQuery, String sql) {
Throwable resultException = tr.getException();
- if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.COMPARE)) {
+ if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE)) {
if (tr.getStatus() != TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
- sql,
- resultSet,
- resultException,
- tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
-
- } catch (QueryTestFailedException qtf) {
- resultException = (resultException != null ? resultException
- : qtf);
- tr.setException(resultException);
- tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
-
- }
+ try {
+ this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ sql,
+ resultSet,
+ resultException,
+ tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
+
+ } catch (QueryTestFailedException qtf) {
+ resultException = (resultException != null ? resultException
+ : qtf);
+ tr.setException(resultException);
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+
+ }
}
if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
-
- this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException,
- this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
-
-
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
+ try {
+
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
}
- } else if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+ } else if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
try {
- this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
+ this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
} catch (QueryTestFailedException qtfe) {
throw new TransactionRuntimeException(qtfe.getMessage());
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -41,6 +41,7 @@
import java.util.Properties;
import org.jdom.JDOMException;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
@@ -493,26 +494,63 @@
// Compare actual elements with expected elements column by column in this row
for (int col = 0; col < actualColumnCount; col++) {
// Get actual value
- final Object actualValue = actualRecord.get(col);
+ Object actualValue = actualRecord.get(col);
// Get expected value
- final Object expectedValue = expectedRecord.get(col);
+ Object expectedValue = expectedRecord.get(col);
// DEBUG:
// debugOut.println(" Col: " +(col +1) + ": expectedValue:[" + expectedValue + "] actualValue:[" + actualValue +
// "]");
// Compare these values
- if (expectedValue == null) {
+ if ( ( expectedValue == null && actualValue != null) ||
+ (actualValue == null && expectedValue != null) ){
// Compare nulls
- if (actualValue != null) {
throw new QueryTestFailedException(eMsg + "Value mismatch at row " + (row + 1) //$NON-NLS-1$
+ " and column " + (col + 1) //$NON-NLS-1$
+ ": expected = [" //$NON-NLS-1$
- + expectedValue + "], actual = [" //$NON-NLS-1$
- + actualValue + "]"); //$NON-NLS-1$
+ + (expectedValue!=null?expectedValue:"null") + "], actual = [" //$NON-NLS-1$
+ + (actualValue!=null?actualValue:"null") + "]"); //$NON-NLS-1$
- }
- } else {
+ }
+
+ if (actualValue instanceof Blob || actualValue instanceof Clob || actualValue instanceof SQLXML) {
+
+ if (actualValue instanceof Clob){
+ Clob c = (Clob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof Blob){
+ Blob b = (Blob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof SQLXML){
+ SQLXML s = (SQLXML)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ }
+
+
+ if (!(expectedValue instanceof String)) {
+ expectedValue = expectedValue.toString();
+ }
+ }
+
// Compare values with equals
if (!expectedValue.equals(actualValue)) {
// DEBUG:
@@ -521,18 +559,21 @@
if (expectedValue instanceof String) {
final String expectedString = (String)expectedValue;
- if (actualValue instanceof Blob || actualValue instanceof Clob || actualValue instanceof SQLXML) {
- // LOB types are special case - metadata says they're Object types so
- // expected results are of type String. Actual object type is MMBlob, MMClob.
- // Must compare w/ String verion of actual!
- if (!expectedValue.equals(actualValue.toString())) {
- throw new QueryTestFailedException(eMsg + "LOB Value mismatch at row " + (row + 1) //$NON-NLS-1$
- + " and column " + (col + 1) //$NON-NLS-1$
- + ": expected = [" //$NON-NLS-1$
- + expectedValue + "], actual = [" //$NON-NLS-1$
- + actualValue + "]"); //$NON-NLS-1$
- }
- } else if (!(actualValue instanceof String)) {
+// if (actualValue instanceof Blob || actualValue instanceof Clob || actualValue instanceof SQLXML) {
+//
+// Clob c = (Clob)actualValue;
+// // LOB types are special case - metadata says they're Object types so
+// // expected results are of type String. Actual object type is MMBlob, MMClob.
+// // Must compare w/ String verion of actual!
+// if (!expectedValue.equals(actualValue.toString())) {
+// throw new QueryTestFailedException(eMsg + "LOB Value mismatch at row " + (row + 1) //$NON-NLS-1$
+// + " and column " + (col + 1) //$NON-NLS-1$
+// + ": expected = [" //$NON-NLS-1$
+// + expectedValue + "], actual = [" //$NON-NLS-1$
+// + actualValue + "]"); //$NON-NLS-1$
+// }
+// } else
+ if (!(actualValue instanceof String)) {
throw new QueryTestFailedException(eMsg + "Value mismatch at row " + (row + 1) //$NON-NLS-1$
+ " and column " + (col + 1) //$NON-NLS-1$
+ ": expected = [" //$NON-NLS-1$
@@ -552,7 +593,7 @@
}
}
- }
+
} // end loop through columns
} // end loop through rows
}
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -123,6 +123,12 @@
String query, ResultSet result, Throwable ex, int testStatus)
throws QueryTestFailedException {
+ try {
+ System.out.println("GENERATE QRF: " + result.isClosed());
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
File resultsFile = createNewResultsFile(queryID, querySetID,
getGenerateDir());
OutputStream outputStream;
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -26,9 +26,12 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -43,6 +46,7 @@
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.internal.core.xml.SAXBuilderHelper;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -50,6 +54,7 @@
import org.teiid.test.client.QueryTest;
import org.teiid.test.client.ctc.QueryResults.ColumnInfo;
import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
@@ -944,6 +949,12 @@
private Element produceResults(ResultSet object, int beginRow, int endRow)
throws JDOMException, SQLException {
+ if (object.isClosed()) {
+ throw new SQLException(
+ "ResultSet is closed at this point, unable to product results"); //$NON-NLS-1$
+
+ }
+
if ( beginRow < START_ROW ) {
throw new IllegalArgumentException(
"The starting row cannot be less than 1."); //$NON-NLS-1$
@@ -1118,7 +1129,7 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing XML.
*/
- public Element produceMsg(Object object, Element parent) throws JDOMException {
+ public Element produceMsg(Object object, Element parent) throws JDOMException, SQLException {
if ( object == null ) {
throw new IllegalArgumentException("Null object reference."); //$NON-NLS-1$
}
@@ -1229,16 +1240,52 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing the message.
*/
- private Element produceObject(Object object, Element parent) throws JDOMException {
+ private Element produceObject(Object object, Element parent) throws JDOMException, SQLException {
+ System.out.println("PRODUCT OBJECT");
// ----------------------
// Create the Object element ...
// ----------------------
Element objectElement = new Element(TagNames.Elements.OBJECT);
+ String result = null;
+ if (object instanceof Blob || object instanceof Clob || object instanceof SQLXML) {
+
+ if (object instanceof Clob){
+ Clob c = (Clob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof Blob){
+ Blob b = (Blob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof SQLXML){
+ SQLXML s = (SQLXML)object;
+ try {
+ result = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ }
+ } else {
+ result = object.toString();
+ }
+
// System.out.println("ProductObject (before encoding): " + object.toString() );
// try {
- objectElement.setText(object.toString());
+ objectElement.setText(result);
// URLEncoder.encode(object.toString(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// UTF-8 is supported natively by all jvms
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -50,8 +50,7 @@
*/
@Override
public void handleTestResult(TestResult tr, ResultSet resultSet, int updateCnt, boolean resultFromQuery, String sql) {
-
- Throwable resultException = tr.getException();
+ Throwable resultException = tr.getException();
if (getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
Modified: branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-09-28 14:30:31 UTC (rev 2617)
+++ branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-09-28 21:37:16 UTC (rev 2618)
@@ -172,7 +172,7 @@
modelToDatasourceMap.clear();
}
- dsfactory.cleanup();
+ if (dsfactory != null) dsfactory.cleanup();
DataSourceMgr.reset();
14 years, 3 months
teiid SVN: r2617 - branches/7.1.x/jboss-integration.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-09-28 10:30:31 -0400 (Tue, 28 Sep 2010)
New Revision: 2617
Modified:
branches/7.1.x/jboss-integration/pom.xml
Log:
TEIID-1265: Adding dependency on jboss security module
Modified: branches/7.1.x/jboss-integration/pom.xml
===================================================================
--- branches/7.1.x/jboss-integration/pom.xml 2010-09-27 20:39:44 UTC (rev 2616)
+++ branches/7.1.x/jboss-integration/pom.xml 2010-09-28 14:30:31 UTC (rev 2617)
@@ -68,8 +68,13 @@
<artifactId>jboss-aop-mc-int</artifactId>
<version>2.0.6.GA</version>
<scope>provided</scope>
- </dependency>
-
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx</artifactId>
+ <version>2.0.3.SP1</version>
+ <scope>provided</scope>
+ </dependency>
<!-- these for just running profile service remotely -->
<dependency>
<groupId>org.jboss.teiid</groupId>
14 years, 3 months
teiid SVN: r2616 - in branches/7.1.x/engine/src: main/java/org/teiid/query/metadata and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-27 16:39:44 -0400 (Mon, 27 Sep 2010)
New Revision: 2616
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java
branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
Log:
TEIID-1279 clarifying errors when loading udfs
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-09-27 20:39:44 UTC (rev 2616)
@@ -72,46 +72,27 @@
* Function lookup and invocation use: Function name (uppercase) to Map (recursive tree)
*/
private Map treeRoot = new HashMap();
+ private boolean validateClass;
/**
* Construct a new tree with the given source of function metadata.
* @param source The metadata source
*/
public FunctionTree(FunctionMetadataSource source) {
- // Load data structures
- addSource(source);
+ this(source, false);
}
-
+
/**
- * Construct a new tree with the given collection of sources.
- * @param sources The collection of function metadata sources ({@link org.teiid.query.function.FunctionMetadataSource})
+ * Construct a new tree with the given source of function metadata.
+ * @param source The metadata source
*/
- FunctionTree(Collection sources) {
+ public FunctionTree(FunctionMetadataSource source, boolean validateClass) {
// Load data structures
- addSources(sources);
+ this.validateClass = validateClass;
+ addSource(source);
}
/**
- * Add a collection of functions to the data structures.
- * @param sources The function metadata sources ({@link org.teiid.query.function.FunctionMetadataSource})
- */
- private void addSources(Collection sources) {
- if(sources == null) {
- return;
- }
-
- Iterator sourceIter = sources.iterator();
- while(sourceIter.hasNext()) {
- Object sourceObj = sourceIter.next();
- if(sourceObj instanceof FunctionMetadataSource) {
- addSource((FunctionMetadataSource) sourceObj);
- } else {
- Assertion.failed(QueryPlugin.Util.getString("ERR.015.001.0044", sourceObj.getClass().getName())); //$NON-NLS-1$
- }
- }
- }
-
- /**
* Add all functions from a metadata source to the data structures.
* @param source The source of the functions
*/
@@ -294,7 +275,7 @@
// Defect 20007 - Ignore the invocation method if pushdown is not required.
if (method.getPushdown() == FunctionMethod.CAN_PUSHDOWN || method.getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
try {
- Class methodClass = source.getInvocationClass(method.getInvocationClass());
+ Class<?> methodClass = source.getInvocationClass(method.getInvocationClass());
ReflectionHelper helper = new ReflectionHelper(methodClass);
try {
invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
@@ -304,15 +285,31 @@
requiresContext = true;
}
} catch (ClassNotFoundException e) {
- // Failed to load class, so can't load method - this will fail at invocation time.
- // We don't fail here because this situation can occur in the modeler, which does
- // not have the function jar files. The modeler never invokes, so this isn't a
- // problem.
+ if (validateClass) {
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.no_class", method.getName(), method.getInvocationClass())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (NoSuchMethodException e) {
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.no_method", method, method.getInvocationClass(), method.getInvocationMethod())); //$NON-NLS-1$ //$NON-NLS-2$
} catch (Exception e) {
- throw new TeiidRuntimeException(e, "ERR.015.001.0047", QueryPlugin.Util.getString("ERR.015.001.0047", new Object[]{method.getInvocationClass(), invocationMethod, inputTypes})); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new TeiidRuntimeException(e, "ERR.015.001.0047", QueryPlugin.Util.getString("ERR.015.001.0047", method, method.getInvocationClass(), method.getInvocationMethod())); //$NON-NLS-1$ //$NON-NLS-2$
}
- if(invocationMethod != null && !FunctionTree.isValidMethod(invocationMethod)) {
- throw new TeiidRuntimeException("ERR.015.001.0047", QueryPlugin.Util.getString("ERR.015.001.0047", new Object[]{method.getInvocationClass(), invocationMethod, inputTypes})); //$NON-NLS-1$ //$NON-NLS-2$
+ if (invocationMethod != null) {
+ // Check return type is non void
+ Class<?> methodReturn = invocationMethod.getReturnType();
+ if(methodReturn.equals(Void.TYPE)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.not_void", method.getName(), invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Check that method is public
+ int modifiers = invocationMethod.getModifiers();
+ if(! Modifier.isPublic(modifiers)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.not_public", method.getName(), invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Check that method is static
+ if(! Modifier.isStatic(modifiers)) {
+ throw new TeiidRuntimeException("ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.not_static", method.getName(), invocationMethod)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
} else {
inputTypes.add(0, CommandContext.class);
@@ -342,33 +339,6 @@
node.put(DESCRIPTOR_KEY, descriptor);
}
- /**
- * Validate a method looked up by reflection. The method should have a non-void return type
- * and be a public static method.
- * @param method Method to validate
- * @return True if valid
- */
- static boolean isValidMethod(Method method) {
- // Check return type is non void
- Class methodReturn = method.getReturnType();
- if(methodReturn.equals(Void.TYPE)) {
- return false;
- }
-
- // Check that method is public
- int modifiers = method.getModifiers();
- if(! Modifier.isPublic(modifiers)) {
- return false;
- }
-
- // Check that method is static
- if(! Modifier.isStatic(modifiers)) {
- return false;
- }
-
- return true;
- }
-
/**
* Look up a function descriptor by signature in the tree. If none is
* found, null is returned.
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-09-27 20:39:44 UTC (rev 2616)
@@ -46,7 +46,7 @@
System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005", report)); //$NON-NLS-1$
}
- systemFunctionTree = new FunctionTree(systemSource);
+ systemFunctionTree = new FunctionTree(systemSource, true);
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-09-27 20:39:44 UTC (rev 2616)
@@ -157,7 +157,7 @@
if (udfMethods == null) {
udfMethods = Collections.emptyList();
}
- this.functionLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(udfMethods)));
+ this.functionLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(udfMethods), true));
}
//==================================================================================
Modified: branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-09-27 20:39:44 UTC (rev 2616)
@@ -41,7 +41,12 @@
ERR.015.001.0044 = Function metadata source is of invalid type: {0}
ERR.015.001.0045 = Function method is of invalid type: {0}
ERR.015.001.0046 = The function "{0}" will not be added because a function with the same name and signature already exists.
-ERR.015.001.0047 = Unexpected exception while loading {0}.{1} with args= {2}
+ERR.015.001.0047 = Unexpected exception while loading "{1}.{2}" for UDF "{0}"
+FunctionTree.not_void = UDF "{0}" method "{1}" must not return void.
+FunctionTree.not_public = UDF "{0}" method "{1}" must be public.
+FunctionTree.not_static = UDF "{0}" method "{1}" must be static.
+FunctionTree.no_class = Could not load UDF "{0}", since its invocation class "{1}" could not be found.
+FunctionTree.no_method = UDF "{0}" could not loaded, since no method on class "{1}" with name "{2}" has a matching type signature.
ERR.015.001.0048 = Unable to represent average value from {0} / {1}
ERR.015.001.0050 = Unable to compute aggregate function {0} on data of type {1}
ERR.015.001.0052 = {0} must be non-null.
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java 2010-09-27 20:39:44 UTC (rev 2616)
@@ -24,15 +24,13 @@
import java.lang.reflect.Method;
+import junit.framework.TestCase;
+
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.metadata.FunctionMethod;
-import junit.framework.TestCase;
-
public class TestFunctionDescriptorImpl extends TestCase {
/**
@@ -72,10 +70,6 @@
return null;
}
- // Validate method
- if(! FunctionTree.isValidMethod(method)) {
- return null;
- }
return method;
}
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-09-27 20:03:53 UTC (rev 2615)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-09-27 20:39:44 UTC (rev 2616)
@@ -22,96 +22,117 @@
package org.teiid.query.function;
-import java.util.ArrayList;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.logging.LogManager;
-import org.teiid.query.function.FunctionForm;
-import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.FunctionMetadataSource;
-import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
-import org.teiid.query.function.UDFSource;
import org.teiid.query.function.metadata.FunctionCategoryConstants;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
import org.teiid.query.function.source.SystemSource;
+@SuppressWarnings("nls")
+public class TestFunctionTree {
-public class TestFunctionTree extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestFunctionTree(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- // ################################## ACTUAL TESTS ################################
-
/**
* Walk through all functions by metadata and verify that we can look
* each one up by signature
*/
- public void testWalkTree() {
+ @Test public void testWalkTree() {
SystemSource source = new SystemSource();
FunctionTree ft = new FunctionTree(source);
- Collection categories = ft.getCategories();
- Iterator catIter = categories.iterator();
- while(catIter.hasNext()) {
- String category = (String) catIter.next();
- LogManager.logInfo("test", "Category: " + category); //$NON-NLS-1$ //$NON-NLS-2$
-
- Collection functions = ft.getFunctionForms(category);
- Iterator functionIter = functions.iterator();
- while(functionIter.hasNext()) {
- FunctionForm form = (FunctionForm) functionIter.next();
- LogManager.logInfo("test", "\tFunction: " + form.getDisplayString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ Collection<String> categories = ft.getCategories();
+ for (String category : categories) {
+ Collection<FunctionForm> functions = ft.getFunctionForms(category);
+ assertTrue(functions.size() > 0);
}
}
- /**
- * Test what happens when a function is loaded that does not have a class in the
- * classpath. This *should* be ok as long as the function is not invoked.
- */
- public void testUnloadableFunction() {
- // Create dummy source
- FunctionMetadataSource dummySource = new FunctionMetadataSource() {
- public Collection getFunctionMethods() {
- // Build dummy method
- FunctionMethod method = new FunctionMethod(
- "dummy", null, "no category", "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new FunctionParameter[0],
- new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) ); //$NON-NLS-1$
+ public String z() {
+ return null;
+ }
+
+ protected static String x() {
+ return null;
+ }
+
+ public static String y() {
+ return null;
+ }
+
+ @Test public void testLoadErrors() {
+ FunctionMethod method = new FunctionMethod(
+ "dummy", null, null, FunctionMethod.CAN_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionParameter[0],
+ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING)); //$NON-NLS-1$
+
+ //allowed, since we're not validating the class
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method))));
+
+ //should fail, no class
+ try {
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationClass(TestFunctionTree.class.getName());
+
+ //should fail, no method
+ try {
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("testLoadErrors");
+
+ //should fail, not void
+ try {
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("x");
+
+ //should fail, not public
+ try {
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
+
+ method.setInvocationMethod("z");
+
+ //should fail, not static
+ try {
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ fail();
+ } catch (TeiidRuntimeException e) {
+
+ }
- // Wrap method in a list
- List methods = new ArrayList();
- methods.add(method);
- return methods;
- }
-
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- throw new ClassNotFoundException("Could not find class " + className); //$NON-NLS-1$
- }
- };
+ method.setInvocationMethod("y");
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(dummySource.getFunctionMethods())));
+ //valid!
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Arrays.asList(method)), true));
}
- public void testNullCategory() {
+ @Test public void testNullCategory() {
FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
Mockito.stub(fms.getFunctionMethods()).toReturn(Arrays.asList(new FunctionMethod(
- "dummy", null, null, FunctionMethod.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "dummy", null, null, FunctionMethod.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[0],
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) //$NON-NLS-1$
)));
14 years, 3 months
teiid SVN: r2615 - in branches/7.1.x: jboss-integration/src/main/java/org/teiid/jboss and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-09-27 16:03:53 -0400 (Mon, 27 Sep 2010)
New Revision: 2615
Added:
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java
Modified:
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
Log:
TEIID-1265: Adding a login modue that uses role based credential map to Teiid. Also adding documentation on how to use credential maps and trusted tokens with Teiid/JBoss AS in admin guide.
Modified: branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-09-27 19:08:58 UTC (rev 2614)
+++ branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-09-27 20:03:53 UTC (rev 2615)
@@ -79,13 +79,13 @@
Details of the failed attempt including invalid users, which
domains were consulted, etc. will be in the server log with appropriate
levels of severity.</para>
- <note>
- <para>The security-domain defined for the JDBC connection and Admin connections are separate.
- The default name of JDBC connection's security-domain is "teiid-security". The default name for Admin connection
- is "jmx-console". For the Admin connection's security domain, the user is allowed
- to change which LoginModule that "jmx-console" pointing to, however should not change the name of the domain, as this name is
- shared between the "admin-console" application.</para>
- </note>
+ <note>
+ <para>The security-domain defined for the JDBC connection and Admin connections are separate.
+ The default name of JDBC connection's security-domain is "teiid-security". The default name for Admin connection
+ is "jmx-console". For the Admin connection's security domain, the user is allowed
+ to change which LoginModule that "jmx-console" pointing to, however should not change the name of the domain, as this name is
+ shared between the "admin-console" application.</para>
+ </note>
<section>
<title>Built-in LoginModules</title>
@@ -93,14 +93,139 @@
<para>The UsersRolesLoginModule, which utilizes simple text files
to authenticate users and to define
their groups. The teiid-jboss-beans.xml configuration file contains an example of how to use UsersRolesLoginModule.
- Note that this is typically not for production use.
+ Note that this is typically not for production use and is strongly recommended that you replace this login module. Please
+ also note that, you can install multiple login modules as part of single security domain configuration and configure them
+ to part of login process. For example, for "teiid-security" domain, you can configure a file based and also LDAP based login modules,
+ and have your user authenticated with either both or single login module.
</para>
<para>See <ulink url="http://community.jboss.org/docs/DOC-11253">LDAP LoginModule configuration</ulink> for utilizing LDAP based authentication.
- If you want use a your own Custom Login module, check out the Developer's Guide for instructions.
+ If you want write your own Custom Login module, check out the Developer's Guide for instructions.
</para>
</section>
- </section>
+ <section>
+ <title>Security at Data Source level</title>
+ <para>In some use cases, user might need to pass-in different credentials to their data sources based on the logged in user
+ than using the shared credentials for all the logged users. To support this feature, JBoss AS and Teiid provide multiple different
+ login modules to be used in conjunction with Teiid's main security domain. See this
+ <ulink url="http://community.jboss.org/docs/DOC-9350">document</ulink> for details on configuration. Note that the below
+ directions need to be used in conjunction with this document.</para>
+
+ <section>
+ <title>CallerIdentity and Trusted Payload</title>
+ <para>If client wants to pass in simple text password or a certificate or a custom serialized object
+ as token credential to the data source, user can configure "CallerIdentity" login module.
+ Using this login module, user can pass-in same credential that user logged into Teiid security domain to the
+ data source. Here is a sample configuration, this needs to be configured in "teiid-jboss-beans.xml" file.
+ </para>
+
+ <programlisting><![CDATA[
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="teiid-security">
+ <authentication>
+
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ <module-option name = "password-stacking">useFirstPass</module-option>
+ <module-option name="usersProperties">props/teiid-security-users.properties</module-option>
+ <module-option name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ </login-module>
+
+ <login-module code="org.jboss.resource.security.CallerIdentityLoginModule" flag="required">
+ <module-option name = "password-stacking">useFirstPass</module-option>
+ <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ </login-module>
+
+ </authentication>
+ </application-policy>
+ ]]></programlisting>
+
+ <para>In the -ds.xml file that is defined as the "managedConnectionFactoryName" in the above configuration,
+ you need to add the following element</para>
+
+ <programlisting><![CDATA[
+ <security-domain>teiid-security</security-domain>
+ ]]></programlisting>
+
+ <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is setup to hold the
+ passwords in the file, and when user logs in with password, the same password will be also set on the logged in Subject after
+ authentication. This credentials can be extracted by the data source by asking for Subject's private credentials.</para>
+
+ <para>To use a certificate or serialized object instead of plain password as the token, simply replace the simple text password
+ with Base64 encoded contents of the serialized object. Please note that, encoding and decoding of this object
+ is strictly up to the user as JBoss AS and Teiid will only act like carrier of the information from
+ login module to connection factory. Using this CallerIdentity module, the connection pool for data source is segmented
+ by Subject.</para>
+ </section>
+ <section>
+ <title>Role Based Credential Map</title>
+ <para>In some use cases, the users are divided by their functionality and they have varied level of security access to
+ data sources. These types of users are identified by their roles as to what they have access to. In the above "CallerIdentity"
+ login scenario, that may be too fine-grained security at data sources, that can lead resource exhaustion as every user has
+ their own separate connection.
+ Using Role based security gives a balance, where the users with same role are treated equally
+ for authentication purposes at the data source. Teiid provides a login module called "RoleBasedCredentialMap"
+ for this purposes, where administrator can define a role based authentication module, where given the role of the user
+ from the primary login module, this module will hold credentail to that role. So, it is container of credentials that
+ map to different roles. If a user has multiple roles, the first role that has the credential will be chosen.
+ Below find the sample configuration.</para>
+
+ <programlisting><![CDATA[
+ <application-policy xmlns="urn:jboss:security-beans:1.0" name="teiid-security">
+ <authentication>
+
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ <module-option name = "password-stacking">useFirstPass</module-option>
+ <module-option name="usersProperties">props/teiid-security-users.properties</module-option>
+ <module-option name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ </login-module>
+
+ <login-module code="org.teiid.jboss.RoleBasedCredentialMapIdentityLoginModule" flag="required">
+ <module-option name = "password-stacking">useFirstPass</module-option>
+ <module-option name="credentialMap">props/teiid-credentialmap.properties</module-option>
+ <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ </login-module>
+
+ </authentication>
+ </application-policy>
+ ]]></programlisting>
+ <para>In the -ds.xml file that is defined as the "managedConnectionFactoryName" in the above configuration,
+ you need to add the following element</para>
+
+ <programlisting><![CDATA[
+ <security-domain>teiid-security</security-domain>
+ ]]></programlisting>
+
+ <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is setup for logging in
+ the primary user and assign some roles. The "RoleBasedCredentialMap" login module is configured to hold
+ role to password information in the file defined by "credentialMap" property. When user logs in, the role information
+ from the primary login module is taken, and extracts the role's passsword and attaches as
+ a private credential to the Subject. If you want use this for role based trusted token, you can configure the Base64 based
+ endcoding/decoded object as defined above.</para>
+
+ <para>You can also encrypt the password instead of plain text password using this module. Just include the encrypted
+ password in the file defined by the "credentialMap" property, and define following properties in
+ the "RoleBasedCredentialMap" login module.</para>
+
+ <programlisting><![CDATA[
+ <login-module code="org.teiid.jboss.RoleBasedCredentialMapIdentityLoginModule" flag="required">
+ <module-option name = "password-stacking">useFirstPass</module-option>
+ <module-option name="credentialMap">props/teiid-credentialmap.properties</module-option>
+ <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+
+ <!-- below properties are only required when passwords are encrypted -->
+ <module-option name = "pbealgo">PBEWithMD5AndDES</module-option>
+ <module-option name = "pbepass">testPBEIdentityLoginModule</module-option>
+ <module-option name = "salt">abcdefgh</module-option>
+ <module-option name = "iterationCount">19</module-option>
+ </login-module>
+ ]]></programlisting>
+
+ <para>For full details about encryption of the password, please follow this
+ <ulink url="http://community.jboss.org/docs/DOC-9703">document</ulink>'s
+ "A KeyStore based login module for encrypting a datasource password" section. Be sure to give the same configuration elements
+ in the above configuration, as they are used to encrypt the password.</para>
+ </section>
+ </section>
+ </section>
<section id="ssl_config">
<title>Configuring SSL</title>
@@ -134,7 +259,7 @@
enabled = traffic will be secured using the other configuration properties.</para></listitem>
<listitem><para>sslProtocol- Type of SSL protocol to be used. Default is TLSv1</para></listitem>
<listitem><para>keystoreType - Keystore type created by the keytool. Default "JKS" is used.</para></listitem>
- <listitem><para>authenticationMode - anonymous|1-way|2-way, Type of <link linkend="ssl_aut">SSL Authentication Mode</link>.</para></listitem>
+ <listitem><para>authenticationMode - anonymous|1-way|2-way, Type of <link linkend="ssl_auth">SSL Authentication Mode</link>.</para></listitem>
<listitem><para>keymanagementAlgorithm - Type of key algorithm used. Default
is based upon the VM, e.g. "SunX509"</para></listitem>
<listitem><para>keystoreFilename - The file name of the keystore, which contains the
Added: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java (rev 0)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java 2010-09-27 20:03:53 UTC (rev 2615)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Sep 26, 2007
+ * @version $Revision$
+ */
+class ResourceActions
+{
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ static URL findResource(final URLClassLoader cl, final String name)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>()
+ {
+ public URL run()
+ {
+ return cl.findResource(name);
+ }
+ });
+ }
+
+ static InputStream openStream(final URL url) throws PrivilegedActionException
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
+ {
+ public InputStream run() throws IOException
+ {
+ return url.openStream();
+ }
+ });
+ }
+}
\ No newline at end of file
Property changes on: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/ResourceActions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java (rev 0)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java 2010-09-27 20:03:53 UTC (rev 2615)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+
+import java.io.IOException;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.logging.Logger;
+import org.jboss.resource.security.AbstractPasswordCredentialLoginModule;
+import org.jboss.security.Base64Utils;
+import org.jboss.security.SimplePrincipal;
+
+/**
+ * A credential mapping login module that associates currently logged in
+ * principle's role name to password mapping from a simple properties file. It
+ * is similar to name=password, only here this uses role=password. If user has
+ * more than single role that has passwords, then first role with non null
+ * password is chosen. This login module must be defined with Managed Connection
+ * Factory.
+ *
+ * Please note, you can not use this as the primary login module, this should be strictly used
+ * to get a role based password, that can be used as credential mapping at data source level. If you
+ * are working with a object as trusted token, then do not use the encryption, and provide base64 encoded
+ * string of the object as the password and decrypt it in your custom connection factory.
+ *
+ *<pre>{@code
+ * <application-policy name = "teiid-security">
+ * <authentication>
+ * <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ * <module-option name="usersProperties">props/teiid-security-users.properties</module-option>
+ * <module-option name="rolesProperties">props/teiid-security-roles.properties</module-option>
+ * <module-option name="password-stacking">useFirstPass</module-option>
+ * </login-module>
+ * <login-module code = "org.teiid.jboss.MapIdentityLoginModule" flag = "required">
+ * <module-option name="password-stacking">useFirstPass</module-option>
+ * <module-option name = "credentialMap">config/props/rolepasswords.properties</module-option>
+ * <module-option name = "encryptedPasswords">true</module-option>
+ *
+ * <!-- below properties are only required when passwords are encrypted -->
+ * <module-option name = "pbealgo">PBEWithMD5AndDES</module-option>
+ * <module-option name = "pbepass">testPBEIdentityLoginModule</module-option>
+ * <module-option name = "salt">abcdefgh</module-option>
+ * <module-option name = "iterationCount">19</module-option>
+ * <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ * </login-module>
+ * </authentication>
+ * </application-policy>
+ * }</pre>
+ *
+ * @see org.jboss.security.SimpleGroup
+ * @see org.jboss.security.SimplePrincipal
+ *
+ */
+public class RoleBasedCredentialMapIdentityLoginModule extends AbstractPasswordCredentialLoginModule {
+ private Properties credentialMap;
+ private String mappedRole = "mappedRole"; //$NON-NLS-1$
+ private static final Logger log = Logger.getLogger(RoleBasedCredentialMapIdentityLoginModule.class);
+
+ /** The Blowfish key material */
+ private char[] pbepass = "jaas is the way".toCharArray(); //$NON-NLS-1$
+ private String pbealgo = "PBEwithMD5andDES"; //$NON-NLS-1$
+ private byte[] salt = {1, 7, 2, 9, 3, 11, 4, 13};
+ private int iterationCount = 37;
+ private boolean encryptionInUse = false;
+
+ public RoleBasedCredentialMapIdentityLoginModule(){
+ }
+
+ public void initialize(Subject subject, CallbackHandler handler, Map sharedState, Map options) {
+ super.initialize(subject, handler, sharedState, options);
+
+ String file = (String) options.get("credentialMap"); //$NON-NLS-1$
+ if (file == null) {
+ throw new IllegalArgumentException("Must supply credentialMap file name!"); //$NON-NLS-1$
+ }
+
+ try {
+ credentialMap = Util.loadProperties(file, log);
+ } catch (IOException e) {
+ log.error("failed to load credentail map"); //$NON-NLS-1$
+ }
+
+ String tmp = (String) options.get("encryptedPasswords"); //$NON-NLS-1$
+ if (tmp != null && tmp.equalsIgnoreCase("true")) { //$NON-NLS-1$
+ this.encryptionInUse = true;
+
+ // Look for the cipher password and algo parameters
+ tmp = (String) options.get("pbepass"); //$NON-NLS-1$
+ if (tmp != null) {
+ try {
+ this.pbepass = org.jboss.security.Util.loadPassword(tmp);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ tmp = (String) options.get("pbealgo"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.pbealgo = tmp;
+ }
+ tmp = (String) options.get("salt"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.salt = tmp.substring(0, 8).getBytes();
+ }
+ tmp = (String) options.get("iterationCount"); //$NON-NLS-1$
+ if (tmp != null) {
+ this.iterationCount = Integer.parseInt(tmp);
+ }
+ }
+ }
+
+ public boolean login() throws LoginException {
+
+ if (credentialMap == null) {
+ throw new LoginException( "Credential Map properties file failed to load"); //$NON-NLS-1$
+ }
+
+ return super.login();
+ }
+
+ public boolean commit() throws LoginException {
+
+ String userRole = null;
+ String rolePassword = null;
+
+ Set<String> roles = getRoles();
+ for (String role:roles) {
+ String password = this.credentialMap.getProperty(role);
+ if (password != null) {
+ userRole = role;
+ rolePassword = password;
+ }
+ }
+
+ try {
+ if (userRole != null && rolePassword != null) {
+ this.mappedRole = userRole;
+ PasswordCredential cred = new PasswordCredential(userRole, decode(rolePassword));
+ cred.setManagedConnectionFactory(getMcf());
+ SecurityActions.addCredentials(this.subject, cred);
+ }
+ return super.commit();
+ } catch (Exception e) {
+ throw new LoginException("Failed to decode password: "+e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ protected Principal getIdentity() {
+ Principal principal = new SimplePrincipal(this.mappedRole);
+ return principal;
+ }
+
+ /**
+ * This method simply returns an empty array of Groups which means that
+ * no role based permissions are assigned.
+ */
+ protected Group[] getRoleSets() throws LoginException {
+ return new Group[] {};
+ }
+
+ private Set<String> getRoles() {
+ Set<String> roles = new HashSet<String>();
+
+ Set<Principal> principals = this.subject.getPrincipals();
+ for(Principal p: principals) {
+ if ((p instanceof Group) && p.getName().equals("Roles")){ //$NON-NLS-1$
+ Group g = (Group)p;
+ Enumeration<? extends Principal> rolesPrinciples = g.members();
+ while(rolesPrinciples.hasMoreElements()) {
+ roles.add(rolesPrinciples.nextElement().getName());
+ }
+ }
+ }
+ return roles;
+ }
+
+ private char[] decode(String secret) throws Exception {
+ if (!this.encryptionInUse) {
+ return secret.toCharArray();
+ }
+ // Create the PBE secret key
+ PBEParameterSpec cipherSpec = new PBEParameterSpec(this.salt, this.iterationCount);
+ PBEKeySpec keySpec = new PBEKeySpec(this.pbepass);
+ SecretKeyFactory factory = SecretKeyFactory.getInstance(this.pbealgo);
+ SecretKey cipherKey = factory.generateSecret(keySpec);
+ // Decode the secret
+ byte[] encoding = Base64Utils.fromb64(secret);
+ Cipher cipher = Cipher.getInstance(this.pbealgo);
+ cipher.init(Cipher.DECRYPT_MODE, cipherKey, cipherSpec);
+ byte[] decode = cipher.doFinal(encoding);
+ return new String(decode).toCharArray();
+ }
+}
Property changes on: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/RoleBasedCredentialMapIdentityLoginModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-09-27 19:08:58 UTC (rev 2614)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-09-27 20:03:53 UTC (rev 2615)
@@ -25,6 +25,7 @@
import java.security.Principal;
import java.security.PrivilegedAction;
+import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import org.jboss.security.SecurityContext;
@@ -82,4 +83,26 @@
}
});
}
+
+ static class AddCredentialsAction implements PrivilegedAction
+ {
+ Subject subject;
+ PasswordCredential cred;
+ AddCredentialsAction(Subject subject, PasswordCredential cred)
+ {
+ this.subject = subject;
+ this.cred = cred;
+ }
+ public Object run()
+ {
+ subject.getPrivateCredentials().add(cred);
+ return null;
+ }
+ }
+
+ static void addCredentials(Subject subject, PasswordCredential cred)
+ {
+ AddCredentialsAction action = new AddCredentialsAction(subject, cred);
+ AccessController.doPrivileged(action);
+ }
}
Added: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java (rev 0)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java 2010-09-27 20:03:53 UTC (rev 2615)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.PrivilegedActionException;
+import java.util.Properties;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Common login module utility methods
+ *
+ * @author Scott.Stark(a)jboss.org
+ * @version $Revision: 68749 $
+ */
+public class Util {
+ /**
+ * Utility method which loads the given properties file and returns a
+ * Properties object containing the key,value pairs in that file. The
+ * properties files should be in the class path as this method looks to the
+ * thread context class loader (TCL) to locate the resource. If the TCL is a
+ * URLClassLoader the findResource(String) method is first tried. If this
+ * fails or the TCL is not a URLClassLoader getResource(String) is tried. If
+ * not, an absolute path is tried.
+ *
+ * @param propertiesName
+ * - the name of the properties file resource
+ * @param log
+ * - the logger used for trace level messages
+ * @return the loaded properties file if found
+ * @exception java.io.IOException
+ * thrown if the properties file cannot be found or loaded
+ */
+ static Properties loadProperties(String propertiesName, Logger log) throws IOException {
+ ClassLoader loader = ResourceActions.getContextClassLoader();
+ URL url = null;
+ // First check for local visibility via a URLClassLoader.findResource
+ if (loader instanceof URLClassLoader) {
+ URLClassLoader ucl = (URLClassLoader) loader;
+ url = ResourceActions.findResource(ucl, propertiesName);
+ log.trace("findResource: " + url); //$NON-NLS-1$
+ }
+ if (url == null)
+ url = loader.getResource(propertiesName);
+ if (url == null) {
+ url = new URL(propertiesName);
+ }
+
+ log.trace("Properties file=" + url); //$NON-NLS-1$
+
+ Properties bundle = new Properties();
+ InputStream is = null;
+ try {
+ is = ResourceActions.openStream(url);
+ } catch (PrivilegedActionException e) {
+ throw new IOException(e.getLocalizedMessage());
+ }
+ if (is != null) {
+ bundle.load(is);
+ is.close();
+ } else {
+ throw new IOException("Properties file " + propertiesName + " not available");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ log.debug("Loaded properties, users=" + bundle.keySet());//$NON-NLS-1$
+ return bundle;
+ }
+}
Property changes on: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/Util.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 3 months
teiid SVN: r2614 - branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-09-27 15:08:58 -0400 (Mon, 27 Sep 2010)
New Revision: 2614
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Cast.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsChildNode.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsSameNode.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Name.java
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Path.java
Log:
TEIID-1106 updates to UDFs to make the methods status
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Cast.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Cast.java 2010-09-27 17:46:50 UTC (rev 2613)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Cast.java 2010-09-27 19:08:58 UTC (rev 2614)
@@ -35,7 +35,7 @@
*/
public class Cast {
- public Object cast(String literal, String asType) {
+ public static Object cast(String literal, String asType) {
return "";
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsChildNode.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsChildNode.java 2010-09-27 17:46:50 UTC (rev 2613)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsChildNode.java 2010-09-27 19:08:58 UTC (rev 2614)
@@ -36,7 +36,7 @@
*/
public class IsChildNode {
- public boolean isChildNode(String childSelectorName, String parentSelectorName) {
+ public static boolean isChildNode(String childSelectorName, String parentSelectorName) {
return false;
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsSameNode.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsSameNode.java 2010-09-27 17:46:50 UTC (rev 2613)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/IsSameNode.java 2010-09-27 19:08:58 UTC (rev 2614)
@@ -36,11 +36,11 @@
*/
public class IsSameNode {
- public boolean isSameNode(String selectorName, String joinSelectorName) {
+ public static boolean isSameNode(String selectorName, String joinSelectorName) {
return false;
}
- public boolean isSameNode(String selectorName, String joinSelectorName, String selectorPathName) {
+ public static boolean isSameNode(String selectorName, String joinSelectorName, String selectorPathName) {
return false;
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Name.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Name.java 2010-09-27 17:46:50 UTC (rev 2613)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Name.java 2010-09-27 19:08:58 UTC (rev 2614)
@@ -35,7 +35,7 @@
*/
public class Name {
- public String name(String name) {
+ public static String name(String name) {
return "";
}
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Path.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Path.java 2010-09-27 17:46:50 UTC (rev 2613)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/functions/Path.java 2010-09-27 19:08:58 UTC (rev 2614)
@@ -37,11 +37,11 @@
public class Path {
- public String path() {
+ public static String path() {
return "";
}
- public String path(String name) {
+ public static String path(String name) {
return "";
}
14 years, 3 months
teiid SVN: r2613 - in branches/7.1.x/client/src: main/java/org/teiid/adminapi/impl and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-27 13:46:50 -0400 (Mon, 27 Sep 2010)
New Revision: 2613
Modified:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/Translator.java
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/7.1.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/7.1.x/client/src/main/resources/vdb-deployer.xsd
branches/7.1.x/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
Log:
TEIID-1278 fixing translator description output for vdb metadata and reducing the level of some exceptions
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/Translator.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/Translator.java 2010-09-27 15:41:57 UTC (rev 2612)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/Translator.java 2010-09-27 17:46:50 UTC (rev 2613)
@@ -31,4 +31,10 @@
* @return
*/
public String getType();
+
+ /**
+ * Get the Translator description
+ * @return
+ */
+ public String getDescription();
}
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-09-27 15:41:57 UTC (rev 2612)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-09-27 17:46:50 UTC (rev 2613)
@@ -41,7 +41,7 @@
public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = -3454161477587996138L;
private String type;
- private Class executionClass;
+ private Class<?> executionClass;
private String description;
@Override
@@ -83,7 +83,7 @@
return this.executionClass;
}
- public void setExecutionFactoryClass(Class clazz) {
+ public void setExecutionFactoryClass(Class<?> clazz) {
this.executionClass = clazz;
addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
}
@@ -93,7 +93,7 @@
return this.description;
}
- @XmlAttribute(name = "description", required = true)
+ @XmlAttribute(name = "description")
public void setDescription(String desc) {
this.description = desc;
}
Modified: branches/7.1.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-09-27 15:41:57 UTC (rev 2612)
+++ branches/7.1.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-09-27 17:46:50 UTC (rev 2613)
@@ -478,8 +478,8 @@
try {
resultsMsg = sendRequestMessageAndWait(reqMessage);
} catch ( Throwable ex ) {
- String msg = JDBCPlugin.Util.getString("MMStatement.Error_executing_stmt", reqMessage.getCommandString()); //$NON-NLS-1$
- logger.log(Level.SEVERE, msg, ex);
+ String msg = JDBCPlugin.Util.getString("MMStatement.Error_executing_stmt", reqMessage.getCommandString()); //$NON-NLS-1$
+ logger.log(ex instanceof SQLException?Level.WARNING:Level.SEVERE, msg, ex);
throw TeiidSQLException.create(ex, msg);
}
@@ -881,7 +881,7 @@
* Send out request message with necessary states.
*/
protected ResultsMessage sendRequestMessageAndWait(RequestMessage reqMsg)
- throws SQLException, InterruptedException, TimeoutException {
+ throws SQLException, InterruptedException {
this.currentRequestID = this.driverConnection.nextRequestID();
// Create a request message
reqMsg.setExecutionPayload(this.payload);
@@ -925,7 +925,7 @@
}
if (commandStatus == TIMED_OUT) {
- throw new TimeoutException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete")); //$NON-NLS-1$
+ throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete")); //$NON-NLS-1$
}
return result;
}
Modified: branches/7.1.x/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- branches/7.1.x/client/src/main/resources/vdb-deployer.xsd 2010-09-27 15:41:57 UTC (rev 2612)
+++ branches/7.1.x/client/src/main/resources/vdb-deployer.xsd 2010-09-27 17:46:50 UTC (rev 2613)
@@ -71,6 +71,7 @@
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
+ <xs:attribute name="description" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="data-role" minOccurs="0" maxOccurs="unbounded">
Modified: branches/7.1.x/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-09-27 15:41:57 UTC (rev 2612)
+++ branches/7.1.x/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-09-27 17:46:50 UTC (rev 2613)
@@ -85,6 +85,7 @@
TranslatorMetaData t1 = new TranslatorMetaData();
t1.setName("oracleOverride");
t1.setType("oracle");
+ t1.setDescription("hello world");
t1.addProperty("my-property", "my-value");
List<Translator> list = new ArrayList<Translator>();
list.add(t1);
@@ -160,7 +161,7 @@
assertEquals("oracleOverride", translator.getName());
assertEquals("oracle", translator.getType());
assertEquals("my-value", translator.getPropertyValue("my-property"));
-
+ assertEquals("hello world", translator.getDescription());
List<DataPolicy> roles = vdb.getDataPolicies();
assertTrue(roles.size() == 1);
14 years, 3 months