Author: rareddy
Date: 2009-12-15 15:07:33 -0500 (Tue, 15 Dec 2009)
New Revision: 1670
Added:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java
branches/JCA/connectors/connector-ldap/src/main/rar/
branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/
branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
Removed:
branches/JCA/connectors/connector-ldap/src/assembly/
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java
Modified:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
branches/JCA/connectors/connector-ldap/pom.xml
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java
branches/JCA/connectors/pom.xml
Log:
TEIID-861: Converted LDAP connector as JCA connector
Modified: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 19:24:54 UTC
(rev 1669)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2009-12-15 20:07:33 UTC
(rev 1670)
@@ -18,7 +18,7 @@
<include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
<include>org.jboss.teiid.connectors:connector-loopback</include>
<include>org.jboss.teiid.connectors:connector-text</include>
-
+ <include>org.jboss.teiid.connectors:connector-ldap</include>
</includes>
<binaries>
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java
===================================================================
---
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connector-api/src/main/java/org/teiid/connector/basic/BasicConnector.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -10,6 +10,7 @@
public abstract class BasicConnector implements Connector {
protected ConnectorEnvironment config;
+ protected ConnectorCapabilities capabilities;
@Override
public void initialize(ConnectorEnvironment config) throws ConnectorException {
@@ -27,19 +28,21 @@
@Override
public ConnectorCapabilities getCapabilities() throws ConnectorException {
- // create Capabilities
- String className = this.config.getCapabilitiesClass();
- try {
- ConnectorCapabilities result = null;
- if (className != null && className.length() > 0) {
- result = (ConnectorCapabilities) ReflectionHelper.create(className, null,
Thread.currentThread().getContextClassLoader());
- } else {
- result = getDefaultCapabilities().newInstance();
+ if (capabilities == null) {
+ // create Capabilities
+ String className = this.config.getCapabilitiesClass();
+ try {
+ if (className != null && className.length() > 0) {
+ capabilities = (ConnectorCapabilities) ReflectionHelper.create(className, null,
Thread.currentThread().getContextClassLoader());
+ } else {
+ capabilities = getDefaultCapabilities().newInstance();
+ }
+
+ return capabilities;
+ } catch (Exception e) {
+ throw new ConnectorException(e);
}
-
- return result;
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
+ }
+ return capabilities;
}
}
Modified: branches/JCA/connectors/connector-ldap/pom.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/connector-ldap/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -21,100 +21,27 @@
<artifactId>teiid-common-core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
- <!-- This build portion is identical for all the connectors that are deployed; so
when making changes make sure
- it applies to all the connectors. This below block computes the classpath, writes to
classpath.properties; it replaces
- classpath in the xml file, then bundles current project and its dependencies and xml
file in a zip for deployment-->
+
<build>
<plugins>
- <!-- build class path -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
- <id>build-classpath</id>
- <phase>generate-sources</phase>
+ <id>build_jar</id>
+ <phase>process-classes</phase>
<goals>
- <goal>build-classpath</goal>
+ <goal>jar</goal>
</goals>
- <configuration>
- <fileSeparator>:</fileSeparator>
- <pathSeparator>;</pathSeparator>
- <prefix>extensionjar</prefix>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
-
<outputFile>target/classpath.properties</outputFile>
- <regenerateFile>true</regenerateFile>
- <outputFilterFile>true</outputFilterFile>
- </configuration>
</execution>
</executions>
</plugin>
-
- <!-- bundles all its dependencies in a single zip file -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <excludeTransitive>false</excludeTransitive>
- <includeScope>runtime</includeScope>
- <excludeTypes>pom</excludeTypes>
-
<outputDirectory>target/dependency</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/bundle.xml</descriptor>
- </descriptors>
- <outputDirectory>target/distribution</outputDirectory>
- <workDirectory>target/assembly/work</workDirectory>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
- <!-- replaces the classpath tokens in the xml file -->
- <filters>
- <filter>target/classpath.properties</filter>
- </filters>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- </excludes>
- </resource>
- </resources>
-
- </build>
+ </build>
</project>
\ No newline at end of file
Modified:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -41,7 +41,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
-import java.util.Properties;
import javax.naming.NamingException;
import javax.naming.directory.BasicAttribute;
@@ -49,7 +48,6 @@
import javax.naming.ldap.SortKey;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.IAggregate;
import org.teiid.connector.language.ICompareCriteria;
import org.teiid.connector.language.ICompoundCriteria;
@@ -81,19 +79,17 @@
* Utility class which translates a SQL query into an LDAP search.
*/
public class IQueryToLdapSearchParser {
- private ConnectorLogger logger;
private RuntimeMetadata rm;
- private Properties props;
+ private LDAPManagedConnectionFactory config;
/**
* Constructor.
* @param logger the connector logger
* @param rm the RuntimeMetadata
*/
- public IQueryToLdapSearchParser(ConnectorLogger logger, RuntimeMetadata rm, Properties
props) {
- this.logger = logger;
+ public IQueryToLdapSearchParser(RuntimeMetadata rm, LDAPManagedConnectionFactory config)
{
this.rm = rm;
- this.props = props;
+ this.config = config;
}
/**
@@ -127,13 +123,13 @@
Iterator itr = fromList.listIterator();
if(!itr.hasNext()) {
final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.noTablesInFromError");
//$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
throw new ConnectorException(msg);
}
IFromItem fItm = (IFromItem)itr.next();
if(itr.hasNext()) {
final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.multiItemsInFromError");
//$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
throw new ConnectorException(msg);
}
String contextName = getContextNameFromFromItem(fItm);
@@ -176,7 +172,7 @@
LDAPSearchDetails sd = new LDAPSearchDetails(contextName, searchScope, filter,
attributeList, sortKeys, countLimit, elementList);
// Search Details logging
try {
- sd.printDetailsToLog(logger);
+ sd.printDetailsToLog(this.config.getLogger());
} catch (NamingException nme) {
final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.searchDetailsLoggingError");
//$NON-NLS-1$
throw new ConnectorException(msg);
@@ -206,12 +202,12 @@
IOrderByItem item = (IOrderByItem)orderItr.next();
if(item != null) {
String itemName = getExpressionString((IExpression)item.getElement());
- logger.logTrace("Adding sort key for item: " + itemName); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Adding sort key for item: " + itemName);
//$NON-NLS-1$
if(item.getDirection() == IOrderByItem.ASC) {
- logger.logTrace("with ASC ordering."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("with ASC ordering."); //$NON-NLS-1$
sortKey = new SortKey(itemName, true, null);
} else if(item.getDirection() == IOrderByItem.DESC){
- logger.logTrace("with DESC ordering."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("with DESC ordering."); //$NON-NLS-1$
sortKey = new SortKey(itemName, false, null);
}
}
@@ -252,7 +248,7 @@
// if there is no context name specified
// try the default in the connector properties
if(contextName.equals("")) { //$NON-NLS-1$
- contextName = props.getProperty(LDAPConnectorPropertyNames.LDAP_DEFAULT_BASEDN);
+ contextName = this.config.getSearchDefaultBaseDN();
}
} else {
final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.groupCountExceededError");
//$NON-NLS-1$
@@ -297,8 +293,7 @@
// see if the connector property is set to true. If
// it is, use the Name of the class for the restriction.
if(namedClass == null || namedClass.equals("")) { //$NON-NLS-1$
- String restrictToObjectClass =
props.getProperty(LDAPConnectorPropertyNames.LDAP_RESTRICT_TO_OBJECTCLASS);
- if (restrictToObjectClass == null ||
restrictToObjectClass.toUpperCase().equals("FALSE")) { //$NON-NLS-1$
+ if (!this.config.isRestrictToObjectClass()) { //$NON-NLS-1$
namedClass = ""; //$NON-NLS-1$
} else {
namedClass = mdIDGroup.getName();
@@ -332,7 +327,7 @@
// if there is no search scope specified
// try the default in the connector properties
if(searchScopeString.equals("")) { //$NON-NLS-1$
- searchScopeString =
props.getProperty(LDAPConnectorPropertyNames.LDAP_DEFAULT_SCOPE);
+ searchScopeString = this.config.getSearchDefaultScope();
// protect against getting null back from the property
if(searchScopeString == null) {
searchScopeString = ""; //$NON-NLS-1$
@@ -390,13 +385,13 @@
} else if(e instanceof ILiteral) {
try {
if(((ILiteral)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
- logger.logTrace("Found an expression that uses timestamp; converting to LDAP
string format."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Found an expression that uses timestamp;
converting to LDAP string format."); //$NON-NLS-1$
Timestamp ts = (Timestamp)((ILiteral)e).getValue();
Date dt = new Date(ts.getTime());
//TODO: Fetch format if provided.
SimpleDateFormat sdf = new
SimpleDateFormat(LDAPConnectorConstants.ldapTimestampFormat);
expressionName = sdf.format(dt);
- logger.logTrace("Timestamp to stsring is: " + expressionName);
//$NON-NLS-1$
+ this.config.getLogger().logTrace("Timestamp to stsring is: " +
expressionName); //$NON-NLS-1$
}
else {
expressionName = ((ILiteral)e).getValue().toString();
@@ -408,13 +403,13 @@
} else {
if(e instanceof IAggregate) {
- logger.logError("Received IAggregate, but it is not supported. Check
capabilities."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IAggregate, but it is not supported.
Check capabilities."); //$NON-NLS-1$
} else if(e instanceof IFunction) {
- logger.logError("Received IFunction, but it is not supported. Check
capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IFunction, but it is not supported.
Check capabilties."); //$NON-NLS-1$
} else if(e instanceof IScalarSubquery) {
- logger.logError("Received IScalarSubquery, but it is not supported. Check
capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received IScalarSubquery, but it is not
supported. Check capabilties."); //$NON-NLS-1$
} else if (e instanceof ISearchedCaseExpression) {
- logger.logError("Received ISearchedCaseExpression, but it is not supported.
Check capabilties."); //$NON-NLS-1$
+ this.config.getLogger().logError("Received ISearchedCaseExpression, but it is
not supported. Check capabilties."); //$NON-NLS-1$
}
final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.unsupportedElementError");
//$NON-NLS-1$
throw new ConnectorException(msg + e.toString());
@@ -465,7 +460,7 @@
boolean isNegated = false;
// Recursive case: compound criteria
if(criteria instanceof ICompoundCriteria) {
- logger.logTrace("Parsing compound criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing compound criteria.");
//$NON-NLS-1$
ICompoundCriteria.Operator op = ((ICompoundCriteria) criteria).getOperator();
List criteriaList = ((ICompoundCriteria) criteria).getCriteria();
String stringOp = parseCompoundCriteriaOp(op);
@@ -482,7 +477,7 @@
// Base case
} else if(criteria instanceof ICompareCriteria) {
- logger.logTrace("Parsing compare criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing compare criteria.");
//$NON-NLS-1$
ICompareCriteria.Operator op = ((ICompareCriteria) criteria).getOperator();
isNegated = op == Operator.NE || op == Operator.GT || op == Operator.LT;
@@ -500,11 +495,11 @@
addCompareCriteriaToList(filterList, op, lhsString, rhsString);
// Base case
} else if(criteria instanceof IExistsCriteria) {
- logger.logTrace("Parsing EXISTS criteria: NOT IMPLEMENTED YET");
//$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing EXISTS criteria: NOT IMPLEMENTED
YET"); //$NON-NLS-1$
// TODO Exists should be supported in a future release.
// Base case
} else if(criteria instanceof ILikeCriteria) {
- logger.logTrace("Parsing LIKE criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing LIKE criteria."); //$NON-NLS-1$
isNegated = ((ILikeCriteria) criteria).isNegated();
// Convert LIKE to Equals, where any "%" symbol is replaced with
"*".
ICompareCriteria.Operator op = Operator.EQ;
@@ -518,14 +513,14 @@
// Base case
} else if(criteria instanceof IInCriteria) {
- logger.logTrace("Parsing IN criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing IN criteria."); //$NON-NLS-1$
isNegated = ((IInCriteria) criteria).isNegated();
IExpression lhs = ((IInCriteria)criteria).getLeftExpression();
List rhsList = ((IInCriteria)criteria).getRightExpressions();
// Recursively add each IN expression to the filter list.
processInCriteriaList(filterList, rhsList, lhs);
} else if (criteria instanceof INotCriteria) {
- logger.logTrace("Parsing NOT criteria."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Parsing NOT criteria."); //$NON-NLS-1$
isNegated = true;
filterList.addAll(getSearchFilterFromWhereClause(((INotCriteria)criteria).getCriteria(),
new LinkedList()));
}
Modified:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -46,37 +46,27 @@
*/
public class LDAPConnection extends BasicConnection {
+ private LDAPManagedConnectionFactory config;
+
// Standard Connection data members
- private ConnectorLogger logger;
private InitialLdapContext initCtx;
- private Properties props;
// LDAP-specific properties
public static final String LDAP_AUTH_TYPE = "simple"; //$NON-NLS-1$
public static final String LDAP_USER_OBJECT_TYPE = "person"; //$NON-NLS-1$
public static final String LDAP_REFERRAL_MODE = "follow"; //$NON-NLS-1$
- private String ldapURL;
- private String ldapAdminUserDN;
- private String ldapAdminUserPass;
- private String ldapTxnTimeoutInMillis;
+
private String jndiLdapCtxFactory;
- /**
- * Constructor.
- * @param ctx
- * @param props
- * @param logger
- */
- public LDAPConnection(ExecutionContext ctx, Properties props, ConnectorLogger logger)
throws ConnectorException {
- this(ctx, props, logger, LDAPConnectorConstants.JNDI_LDAP_CTX_FACTORY);
+ public LDAPConnection(LDAPManagedConnectionFactory config) throws ConnectorException {
+ this(config, LDAPConnectorConstants.JNDI_LDAP_CTX_FACTORY);
}
- public LDAPConnection(ExecutionContext ctx, Properties props, ConnectorLogger logger,
String jndiLdapCtxFactory) throws ConnectorException {
- this.logger = logger;
- this.props = props;
+ public LDAPConnection(LDAPManagedConnectionFactory config, String jndiLdapCtxFactory)
throws ConnectorException {
+ this.config = config;
this.jndiLdapCtxFactory = jndiLdapCtxFactory;
- parseProperties(props);
+ checkProperties();
// Create initial LDAP connection.
try {
@@ -86,7 +76,7 @@
throw new ConnectorException(ce, msg);
}
- logger.logDetail("LDAP Connection has been newly created."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("LDAP Connection has been newly created.");
//$NON-NLS-1$
}
public void setJndiLdapCtxFactory(String jndiLdapCtxFactory) {
@@ -98,26 +88,22 @@
* a ConnectorException is thrown.
* @param props
*/
- private void parseProperties(Properties props) throws ConnectorException {
+ private void checkProperties() throws ConnectorException {
// LDAP URL
- if((ldapURL = props.getProperty(LDAPConnectorPropertyNames.LDAP_URL)) == null) {
+ if(this.config.getLdapUrl() == null) {
final String msg =
LDAPPlugin.Util.getString("LDAPConnection.urlPropNotFound"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
// LDAP Admin User DN
- if((ldapAdminUserDN = props.getProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_DN))
== null) {
+ if(this.config.getLdapAdminUserDN() == null) {
final String msg =
LDAPPlugin.Util.getString("LDAPConnection.adminUserDNPropNotFound");
//$NON-NLS-1$
throw new ConnectorException(msg);
}
// LDAP Admin User Password
- if((ldapAdminUserPass =
props.getProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_PASSWORD)) == null) {
+ if(this.config.getLdapAdminUserPassword() == null) {
final String msg =
LDAPPlugin.Util.getString("LDAPConnection.adminUserPassPropNotFound");
//$NON-NLS-1$
throw new ConnectorException(msg);
}
- // LDAP Txn Timeout in Milliseconds
- if((ldapTxnTimeoutInMillis =
props.getProperty(LDAPConnectorPropertyNames.LDAP_TXN_TIMEOUT_IN_MILLIS)) == null) {
- // If unset, leave it at null, since we will default to TCP timeout value.
- }
}
/**
@@ -132,22 +118,22 @@
Hashtable connenv = new Hashtable();
connenv.put(Context.INITIAL_CONTEXT_FACTORY, jndiLdapCtxFactory);
- connenv.put(Context.PROVIDER_URL, this.ldapURL);
+ connenv.put(Context.PROVIDER_URL, this.config.getLdapUrl());
connenv.put(Context.REFERRAL, LDAP_REFERRAL_MODE);
// If username is blank, we will perform an anonymous bind.
// Note: This is not supported when using Sun's VLVs, so remove this if VLVs are
used.
- if(!ldapAdminUserDN.equals("")) { //$NON-NLS-1$
+ if(!this.config.getLdapAdminUserDN().equals("")) { //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, LDAP_AUTH_TYPE);
- connenv.put(Context.SECURITY_PRINCIPAL, this.ldapAdminUserDN);
- connenv.put(Context.SECURITY_CREDENTIALS, this.ldapAdminUserPass);
+ connenv.put(Context.SECURITY_PRINCIPAL, this.config.getLdapAdminUserDN());
+ connenv.put(Context.SECURITY_CREDENTIALS, this.config.getLdapAdminUserPassword());
} else {
- logger.logWarning("LDAP Username DN was blank; performing anonymous bind.");
//$NON-NLS-1$
+ this.config.getLogger().logWarning("LDAP Username DN was blank; performing
anonymous bind."); //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, "none"); //$NON-NLS-1$
}
- if(ldapTxnTimeoutInMillis != null &&
!ldapTxnTimeoutInMillis.equals("")) { //$NON-NLS-1$
- connenv.put("com.sun.jndi.ldap.connect.timeout", ldapTxnTimeoutInMillis);
//$NON-NLS-1$
+ if(this.config.getLdapTxnTimeoutInMillis() != -1) { //$NON-NLS-1$
+ connenv.put("com.sun.jndi.ldap.connect.timeout",
this.config.getLdapTxnTimeoutInMillis()); //$NON-NLS-1$
}
// Enable connection pooling for the Initial context.
@@ -163,7 +149,7 @@
final String msg =
LDAPPlugin.Util.getString("LDAPConnection.directoryInitError"); //$NON-NLS-1$
throw new ConnectorException(e, msg);
}
- logger.logDetail("Successfully obtained initial LDAP context.");
//$NON-NLS-1$
+ this.config.getLogger().logDetail("Successfully obtained initial LDAP
context."); //$NON-NLS-1$
return initContext;
}
@@ -171,14 +157,14 @@
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LDAPSyncQueryExecution((IQuery)command, executionContext, metadata,
this.logger, this.initCtx, this.props);
+ return new LDAPSyncQueryExecution((IQuery)command, executionContext, metadata,
this.initCtx, this.config);
}
@Override
public UpdateExecution createUpdateExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LDAPUpdateExecution(command, executionContext, metadata, this.logger,
this.initCtx);
+ return new LDAPUpdateExecution(command, executionContext, metadata, this.initCtx,
this.config);
}
/**
@@ -192,10 +178,10 @@
try {
initCtx.close();
} catch(NamingException e) {
- logger.logDetail(LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation()));
//$NON-NLS-1$
+ this.config.getLogger().logDetail(LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation()));
//$NON-NLS-1$
}
}
- logger.logDetail("LDAP context has been closed."); //$NON-NLS-1$
+ this.config.getLogger().logDetail("LDAP context has been closed.");
//$NON-NLS-1$
}
/**
@@ -213,13 +199,8 @@
*/
@Override
public boolean isAlive() {
- logger.logTrace("LDAP Connection is alive."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("LDAP Connection is alive."); //$NON-NLS-1$
return true;
}
- @Override
- public void closeCalled() {
-
- }
-
}
Modified:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -21,14 +21,10 @@
*/
package com.metamatrix.connector.ldap;
-import java.util.Properties;
-
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
-import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicConnector;
@@ -37,48 +33,20 @@
* a connection factory, and obtaining connections to LDAP.
*/
public class LDAPConnector extends BasicConnector {
- private ConnectorEnvironment env;
- private ConnectorLogger logger;
- private Properties props;
- private LDAPConnectorCapabilities myCaps;
+ private LDAPManagedConnectionFactory config;
- @Override
- public ConnectorCapabilities getCapabilities() {
- return myCaps;
+ public Connection getConnection() throws ConnectorException {
+ config.getLogger().logDetail(LDAPPlugin.Util.getString("LDAPSourceConnectionFactory.creatingConnection"));
+ return new LDAPConnection(this.config);
}
- /*
- * @see
com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
- public Connection getConnection(ExecutionContext ctx) throws ConnectorException {
- final String msg =
LDAPPlugin.Util.getString("LDAPSourceConnectionFactory.creatingConnection");
//$NON-NLS-1$
- logger.logDetail(msg);
- return new LDAPConnection(ctx, this.props, this.logger);
- }
-
- /**
- * (non-Javadoc)
- * @see
org.teiid.connector.basic.BasicConnector#initialize(org.teiid.connector.api.ConnectorEnvironment)
- */
@Override
- public void start(ConnectorEnvironment env) throws ConnectorException {
- this.env = env;
- this.logger = this.env.getLogger();
- if(logger == null) {
- final String msg =
LDAPPlugin.Util.getString("LDAPConnector.loggerNotFound"); //$NON-NLS-1$
- final ConnectorException e = new ConnectorException(msg);
- throw e;
- }
- this.props = env.getProperties();
-
- // Create and configure capabilities class.
- myCaps = new LDAPConnectorCapabilities();
- }
-
- /**
- */
- @Override
- public void stop() {
- }
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ this.config = (LDAPManagedConnectionFactory)env;
+ }
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return LDAPConnectorCapabilities.class;
+ }
}
Deleted:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnectorPropertyNames.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.ldap;
-
-/**
- * Property names used in the LDAP connector.
- */
-public class LDAPConnectorPropertyNames {
- public static final String LDAP_URL = "LdapUrl"; //$NON-NLS-1$
- public static final String LDAP_ADMIN_USER_DN = "LdapAdminUserDN";
//$NON-NLS-1$
- public static final String LDAP_ADMIN_USER_PASSWORD =
"LdapAdminUserPassword"; //$NON-NLS-1$
- public static final String LDAP_TXN_TIMEOUT_IN_MILLIS =
"LdapTxnTimeoutInMillis"; //$NON-NLS-1$
- public static final String LDAP_DEFAULT_BASEDN = "SearchDefaultBaseDN";
//$NON-NLS-1$
- public static final String LDAP_DEFAULT_SCOPE = "SearchDefaultScope";
//$NON-NLS-1$
- public static final String LDAP_RESTRICT_TO_OBJECTCLASS =
"RestrictToObjectClass"; //$NON-NLS-1$
-}
Added:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java
(rev 0)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPManagedConnectionFactory.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.connector.ldap;
+
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+
+public class LDAPManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+ private static final long serialVersionUID = -1832915223199053471L;
+
+ private String searchDefaultBaseDN;
+ private String ldapAdminUserDN;
+ private String ldapAdminUserPassword;
+ private boolean restrictToObjectClass = false;
+ private long ldapTxnTimeoutInMillis;
+ private String ldapUrl;
+ private String searchDefaultScope = "SUBTREE_SCOPE";
+
+ public String getSearchDefaultBaseDN() {
+ return searchDefaultBaseDN;
+ }
+
+ public void setSearchDefaultBaseDN(String searchDefaultBaseDN) {
+ this.searchDefaultBaseDN = searchDefaultBaseDN;
+ }
+
+ public String getLdapAdminUserDN() {
+ return ldapAdminUserDN;
+ }
+
+ public void setLdapAdminUserDN(String ldapAdminUserDN) {
+ this.ldapAdminUserDN = ldapAdminUserDN;
+ }
+
+ public String getLdapAdminUserPassword() {
+ return ldapAdminUserPassword;
+ }
+
+ public void setLdapAdminUserPassword(String ldapAdminUserPassword) {
+ this.ldapAdminUserPassword = ldapAdminUserPassword;
+ }
+
+ public boolean isRestrictToObjectClass() {
+ return restrictToObjectClass;
+ }
+
+ public void setRestrictToObjectClass(Boolean restrictToObjectClass) {
+ this.restrictToObjectClass = restrictToObjectClass.booleanValue();
+ }
+
+ public long getLdapTxnTimeoutInMillis() {
+ return ldapTxnTimeoutInMillis;
+ }
+
+ public void setLdapTxnTimeoutInMillis(Long ldapTxnTimeoutInMillis) {
+ this.ldapTxnTimeoutInMillis = ldapTxnTimeoutInMillis.longValue();
+ }
+
+ public String getLdapUrl() {
+ return ldapUrl;
+ }
+
+ public void setLdapUrl(String ldapUrl) {
+ this.ldapUrl = ldapUrl;
+ }
+
+ public String getSearchDefaultScope() {
+ return searchDefaultScope;
+ }
+
+ public void setSearchDefaultScope(String searchDefaultScope) {
+ this.searchDefaultScope = searchDefaultScope;
+ }
+}
Modified:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -110,15 +110,14 @@
*/
public class LDAPSyncQueryExecution extends BasicExecution implements ResultSetExecution
{
- private ConnectorLogger logger;
private LDAPSearchDetails searchDetails;
private RuntimeMetadata rm;
private InitialLdapContext initialLdapContext;
private LdapContext ldapCtx;
private NamingEnumeration searchEnumeration;
private IQueryToLdapSearchParser parser;
- private Properties props;
private IQuery query;
+ private LDAPManagedConnectionFactory config;
/**
* Constructor
@@ -128,14 +127,11 @@
* @param logger the ConnectorLogger
* @param ldapCtx the LDAP Context
*/
- public LDAPSyncQueryExecution(IQuery query, ExecutionContext ctx,
- RuntimeMetadata rm, ConnectorLogger logger,
- InitialLdapContext ldapCtx, Properties props) throws ConnectorException {
+ public LDAPSyncQueryExecution(IQuery query, ExecutionContext ctx, RuntimeMetadata rm,
InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config) throws ConnectorException
{
this.rm = rm;
- this.logger = logger;
this.initialLdapContext = ldapCtx;
- this.props = props;
this.query = query;
+ this.config = config;
}
/**
@@ -146,7 +142,7 @@
@Override
public void execute() throws ConnectorException {
// Parse the IQuery, and translate it into an appropriate LDAP search.
- this.parser = new IQueryToLdapSearchParser(logger, this.rm, this.props);
+ this.parser = new IQueryToLdapSearchParser(this.rm, this.config);
searchDetails = parser.translateSQLQueryToLDAPSearch(query);
// Create and configure the new search context.
@@ -167,7 +163,7 @@
try {
sortCtrl[0] = new SortControl(keys, Control.NONCRITICAL);
this.ldapCtx.setRequestControls(sortCtrl);
- logger.logTrace("Sort ordering was requested, and sort control was created
successfully."); //$NON-NLS-1$
+ this.config.getLogger().logTrace("Sort ordering was requested, and sort control
was created successfully."); //$NON-NLS-1$
} catch (NamingException ne) {
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") +
//$NON-NLS-1$
" : "+ne.getExplanation(); //$NON-NLS-1$
@@ -189,7 +185,7 @@
ldapCtx = (LdapContext)
this.initialLdapContext.lookup(searchDetails.getContextName());
} catch (NamingException ne) {
if (searchDetails.getContextName() != null) {
- logger.logError("Attempted to search context: " //$NON-NLS-1$
+ this.config.getLogger().logError("Attempted to search context: "
//$NON-NLS-1$
+ searchDetails.getContextName());
}
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.createContextError");
//$NON-NLS-1$
@@ -215,11 +211,6 @@
i++;
}
- if(attrs == null) {
- final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.configAttrsError");
//$NON-NLS-1$
- throw new ConnectorException(msg);
- }
-
ctrls.setSearchScope(searchDetails.getSearchScope());
ctrls.setReturningAttributes(attrs);
@@ -238,17 +229,17 @@
String ctxName = searchDetails.getContextName();
String filter = searchDetails.getContextFilter();
if (ctxName == null || filter == null || ctrls == null) {
- logger.logError("Search context, filter, or controls were null. Cannot execute
search."); //$NON-NLS-1$
+ this.config.getLogger().logError("Search context, filter, or controls were null.
Cannot execute search."); //$NON-NLS-1$
}
try {
searchEnumeration = this.ldapCtx.search("", filter, ctrls); //$NON-NLS-1$
} catch (NamingException ne) {
- logger.logError("LDAP search failed. Attempted to search context "
//$NON-NLS-1$
+ this.config.getLogger().logError("LDAP search failed. Attempted to search context
" //$NON-NLS-1$
+ ctxName + " using filter " + filter); //$NON-NLS-1$
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError");
//$NON-NLS-1$
throw new ConnectorException(msg + " : " + ne.getExplanation());
//$NON-NLS-1$
} catch(Exception e) {
- logger.logError("LDAP search failed. Attempted to search context "
//$NON-NLS-1$
+ this.config.getLogger().logError("LDAP search failed. Attempted to search context
" //$NON-NLS-1$
+ ctxName + " using filter " + filter); //$NON-NLS-1$
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError");
//$NON-NLS-1$
throw new ConnectorException(e, msg);
@@ -283,7 +274,7 @@
ldapCtx.close();
} catch (NamingException ne) {
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.closeContextError",ne.getExplanation());
//$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
}
}
}
@@ -312,12 +303,12 @@
return result;
} catch (SizeLimitExceededException e) {
- logger.logWarning("Search results exceeded size limit. Results may be
incomplete."); //$NON-NLS-1$
+ this.config.getLogger().logWarning("Search results exceeded size limit. Results
may be incomplete."); //$NON-NLS-1$
searchEnumeration = null; // GHH 20080326 - NamingEnumartion's are no longer good
after an exception so toss it
return null; // GHH 20080326 - if size limit exceeded don't try to read more
results
} catch (NamingException ne) {
final String msg = "Ldap error while processing next batch of results: " +
ne.getExplanation(); //$NON-NLS-1$
- logger.logError(msg); // GHH 20080326 - changed to output explanation from LDAP
server
+ this.config.getLogger().logError(msg); // GHH 20080326 - changed to output
explanation from LDAP server
searchEnumeration = null; // GHH 20080326 - NamingEnumertion's are no longer good
after an exception so toss it
throw new ConnectorException(msg);
}
@@ -330,7 +321,7 @@
*/
// GHH 20080326 - added fetching of DN of result, for directories that
// do not include it as an attribute
- private List getRow(SearchResult result) throws ConnectorException, NamingException {
+ private List getRow(SearchResult result) throws ConnectorException {
Attributes attrs = result.getAttributes();
String resultDN = result.getNameInNamespace(); // added GHH 20080326
ArrayList attributeList = searchDetails.getElementList();
@@ -358,11 +349,11 @@
// value for that column in the result
// GHH 20080326 - added handling of ClassCastException when non-string
// attribute is returned
- private void addResultToRow(Element modelElement, String resultDistinguishedName,
Attributes attrs, List row) throws ConnectorException, NamingException {
+ private void addResultToRow(Element modelElement, String resultDistinguishedName,
Attributes attrs, List row) throws ConnectorException {
String strResult;
String modelAttrName = parser.getNameFromElement(modelElement);
- Class modelAttrClass = (Class)modelElement.getJavaType();
+ Class modelAttrClass = modelElement.getJavaType();
if(modelAttrName == null) {
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError");
//$NON-NLS-1$
throw new ConnectorException(msg);
@@ -398,7 +389,7 @@
objResult = resultAttr.get();
} catch (NamingException ne) {
final String msg =
LDAPPlugin.Util.getString("LDAPSyncQueryExecution.attrValueFetchError",modelAttrName);
//$NON-NLS-1$
- logger.logWarning(msg+" : "+ne.getExplanation()); //$NON-NLS-1$
+ this.config.getLogger().logWarning(msg+" : "+ne.getExplanation());
//$NON-NLS-1$
throw new ConnectorException(msg+" : "+ne.getExplanation()); //$NON-NLS-1$
}
Modified:
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -34,7 +34,6 @@
import javax.naming.ldap.LdapContext;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.UpdateExecution;
@@ -71,19 +70,18 @@
* of attributes to assign values in an INSERT operation * Responsible for
update/insert/delete operations against LDAP
*/
public class LDAPUpdateExecution extends BasicExecution implements UpdateExecution {
- private ConnectorLogger logger;
private RuntimeMetadata rm;
private InitialLdapContext initialLdapContext;
private LdapContext ldapCtx;
private ICommand command;
+ private LDAPManagedConnectionFactory config;
public LDAPUpdateExecution(ICommand command, ExecutionContext ctx,
- RuntimeMetadata rm, ConnectorLogger logger,
- InitialLdapContext ldapCtx) throws ConnectorException {
+ RuntimeMetadata rm, InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config)
throws ConnectorException {
this.rm = rm;
- this.logger = logger;
this.initialLdapContext = ldapCtx;
this.command = command;
+ this.config = config;
}
/** execute generic update-class (either an update, delete, or insert)
@@ -440,7 +438,7 @@
}
} catch (NamingException ne) {
final String msg =
LDAPPlugin.Util.getString("LDAPUpdateExecution.closeContextError",ne.getExplanation());
//$NON-NLS-1$
- logger.logError(msg);
+ this.config.getLogger().logError(msg);
}
}
Added: branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
(rev 0)
+++ branches/JCA/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2009-12-15
20:07:33 UTC (rev 1670)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid JDBC Connector</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ 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.
+ </description>
+ <license-required>true</license-required>
+ </license>
+ <resourceadapter>
+
<resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+
<managedconnectionfactory-class>com.metamatrix.connector.ldap.LDAPManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Connector Class</description>
+ <config-property-name>ConnectorClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>com.metamatrix.connector.ldap.LDAPConnector</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Connector Capabilities</description>
+ <description>The class to use to provide the Connector
Capabilities</description>
+
<config-property-name>CapabilitiesClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>com.metamatrix.connector.ldap.LDAPConnectorCapabilities</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is Immutable</description>
+ <description>Is Immutable, True if the source never
changes.</description>
+ <config-property-name>Immutable</config-property-name>
+
<config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Is XA Capable</description>
+ <description>True, if this connector supports XA
Transactions</description>
+ <config-property-name>XaCapable</config-property-name>
+
<config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Exception on Exceeding Max Rows</description>
+ <description>Indicates if an Exception should be thrown if the
specified value for Maximum Result Rows is exceeded; else no exception and no more than
the maximum will be returned</description>
+
<config-property-name>ExceptionOnMaxRows</config-property-name>
+
<config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Maximum Result Rows</description>
+ <description>Maximum Result Rows allowed</description>
+ <config-property-name>MaxResultRows</config-property-name>
+
<config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+
+ <!-- Loopback Specific properties -->
+
+ <config-property>
+ <description>Default Search Base DN</description>
+ <description>Default Base DN for LDAP Searches</description>
+
<config-property-name>SearchDefaultBaseDN</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Admin User DN</description>
+ <description>User DN for the LDAP admin account</description>
+ <config-property-name>LdapAdminUserDN</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>cn=<>,ou=<>,dc=<></config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Admin Password</description>
+ <description>Password of the LDAP admin user
account</description>
+
<config-property-name>LdapAdminUserPassword</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Restrict Searches To Named Object
Class</description>
+ <description>Restrict Searches to objectClass named in the Name
field for a table</description>
+
<config-property-name>RestrictToObjectClass</config-property-name>
+
<config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap Transaction Timeout (ms)</description>
+ <description>Timeout value for LDAP searches. Defaults to TCP
timeout value.</description>
+
<config-property-name>LdapTxnTimeoutInMillis</config-property-name>
+ <config-property-type>java.lang.Long</config-property-type>
+ <config-property-value>-1</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Ldap URL</description>
+ <description>Ldap URL of the server, including port
number.</description>
+ <config-property-name>LdapUrl</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+
<config-property-value>ldap://<ldapServer>:<389></config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>Default Search Scope</description>
+ <description>Default Scope for LDAP Searches</description>
+
<description>${ALLOWED}:OBJECT_SCOPE,ONELEVEL_SCOPE,SUBTREE_SCOPE</description>
+
<config-property-name>SearchDefaultScope</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>SUBTREE_SCOPE</config-property-value>
+ </config-property>
+
+
<connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
+
<connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
+
<connection-interface>org.teiid.connector.api.Connection</connection-interface>
+
<connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+
<authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+
<credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Modified:
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -21,15 +21,19 @@
*/
package com.metamatrix.connector.ldap;
+import static org.mockito.Mockito.mock;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import javax.naming.directory.Attribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.ICommand;
@@ -37,10 +41,7 @@
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import junit.framework.TestCase;
-
import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -249,13 +250,14 @@
}
private LDAPSearchDetails helpGetSearchDetails(String queryString) throws
ConnectorException {
- ConnectorLogger logger = new SysLogger(false);
QueryMetadataInterface metadata = exampleLdap();
RuntimeMetadata rm = new RuntimeMetadataImpl(metadata);
- Properties props = new Properties();
- IQueryToLdapSearchParser searchParser = new
IQueryToLdapSearchParser(logger,rm,props);
+ LDAPManagedConnectionFactory config = mock(LDAPManagedConnectionFactory.class);
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+ IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(rm, config);
+
IQuery query = (IQuery)getCommand(queryString, metadata);
LDAPSearchDetails searchDetails =
searchParser.translateSQLQueryToLDAPSearch(query);
Modified:
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java
===================================================================
---
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java 2009-12-15
19:24:54 UTC (rev 1669)
+++
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestLDAPConnection.java 2009-12-15
20:07:33 UTC (rev 1670)
@@ -22,8 +22,10 @@
package com.metamatrix.connector.ldap;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+
import java.util.Hashtable;
-import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -31,9 +33,8 @@
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.cdk.api.SysLogger;
public class TestLDAPConnection {
@@ -46,11 +47,15 @@
}
@Test public void testInitialization() throws Exception {
- Properties p = new Properties();
- p.setProperty(LDAPConnectorPropertyNames.LDAP_URL, "ldap://foo");
//$NON-NLS-1$
- p.setProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_DN, "admin");
//$NON-NLS-1$
- p.setProperty(LDAPConnectorPropertyNames.LDAP_ADMIN_USER_PASSWORD,
"password"); //$NON-NLS-1$
- new LDAPConnection(EnvironmentUtility.createExecutionContext("1",
"1"), p, EnvironmentUtility.createStdoutLogger(SysLogger.ERROR),
FakeFactory.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ LDAPManagedConnectionFactory config = mock(LDAPManagedConnectionFactory.class);
+ stub(config.getLdapUrl()).toReturn("ldap://foo");
+ stub(config.getLdapAdminUserDN()).toReturn("admin");
+ stub(config.getLdapAdminUserPassword()).toReturn("password");
+
+ Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
+
+ new LDAPConnection(config, FakeFactory.class.getName());
}
}
Modified: branches/JCA/connectors/pom.xml
===================================================================
--- branches/JCA/connectors/pom.xml 2009-12-15 19:24:54 UTC (rev 1669)
+++ branches/JCA/connectors/pom.xml 2009-12-15 20:07:33 UTC (rev 1670)
@@ -84,13 +84,14 @@
<module>connector-jdbc</module>
<module>connector-loopback</module>
<module>connector-text</module>
+ <module>connector-ldap</module>
+
<!--
-
<module>connector-xml</module>
<module>sandbox</module>
<module>connector-salesforce</module>
<module>salesforce-api</module>
- <module>connector-ldap</module>
+
<module>connector-xml-common</module>
-->
</modules>