org.ametys.plugins.datainclusion.data.ldap
Class LdapQuery

java.lang.Object
  extended by org.ametys.plugins.datainclusion.data.AbstractQuery
      extended by org.ametys.plugins.datainclusion.data.ldap.LdapQuery
All Implemented Interfaces:
Query

public class LdapQuery
extends AbstractQuery

A LDAP query.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ametys.plugins.datainclusion.data.Query
Query.ResultType
 
Field Summary
protected  Map<String,String> _attributeMap
          The decoded attributes.
protected  String _attributes
          The LDAP attributes to return.
protected  String _constraint
          The LDAP constraint, optionally contains parameters.
protected  LdapDataSource _dataSource
          The LDAP data source.
static Pattern ATTRIBUTE_MATCHER
          Attribute matcher.
static String ATTRIBUTE_PATTERN
          Attribute pattern (matches attributeName[attributeLabel]).
 
Fields inherited from class org.ametys.plugins.datainclusion.data.AbstractQuery
_description, _id, _name, _parameters, _resultType
 
Fields inherited from interface org.ametys.plugins.datainclusion.data.Query
PARAMETER_MATCHER, PARAMETER_PATTERN
 
Constructor Summary
LdapQuery()
           
 
Method Summary
protected  Map<String,String> _buildAttributesMap(String query)
          Extract attributes from a query string in the form "attr1[label1], attr2[label2], attr3".
protected  void _cleanup(Context context, NamingEnumeration<SearchResult> result)
          Cleans a connection to a LDAP server.
protected  int _getScope(String scopeStr)
          Get the scope as an integer (handlable by the SearchControls) from the scope string.
protected  SearchControls _getSearchControls(Collection<String> attributes, String scopeStr)
          Get the LDAP search controls.
 QueryResult execute(Map parameterValues)
          Execute the query with the specified parameter values.
 Map<String,String> getAdditionalConfiguration()
          Get the additional query configuration information.
 String getAttributes()
          Get the LDAP attributes to return.
 Map<String,String> getAttributesAsMap()
          Get attributes as Map.
 String getConstraint()
          Get the LDAP constraint.
 LdapDataSource getDataSource()
          Get the datasource on which depends this query.
 List<String> getParameterNames()
          Get the query parameter names.
 String getType()
          Get the query type.
 void setAttributes(String attributes)
          Set the LDAP attributes to return.
 void setConstraint(String constraint)
          Set the LDAP constraint.
 void setDataSource(LdapDataSource dataSource)
          Set this query data source.
 
Methods inherited from class org.ametys.plugins.datainclusion.data.AbstractQuery
_buildParameters, getDescription, getId, getName, getResultType, setDescription, setId, setName, setResultType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_PATTERN

public static final String ATTRIBUTE_PATTERN
Attribute pattern (matches attributeName[attributeLabel]).

See Also:
Constant Field Values

ATTRIBUTE_MATCHER

public static final Pattern ATTRIBUTE_MATCHER
Attribute matcher.


_attributes

protected String _attributes
The LDAP attributes to return.


_constraint

protected String _constraint
The LDAP constraint, optionally contains parameters.


_attributeMap

protected Map<String,String> _attributeMap
The decoded attributes.


_dataSource

protected LdapDataSource _dataSource
The LDAP data source.

Constructor Detail

LdapQuery

public LdapQuery()
Method Detail

getType

public String getType()
Description copied from interface: Query
Get the query type.

Returns:
the query type.

getAttributes

public String getAttributes()
Get the LDAP attributes to return.

Returns:
the LDAP attributes.

setAttributes

public void setAttributes(String attributes)
Set the LDAP attributes to return.

Parameters:
attributes - LDAP attributes to return.

getConstraint

public String getConstraint()
Get the LDAP constraint.

Returns:
the LDAP constraint.

setConstraint

public void setConstraint(String constraint)
Set the LDAP constraint.

Parameters:
constraint - the LDAP constraint to set.

getParameterNames

public List<String> getParameterNames()
Description copied from interface: Query
Get the query parameter names.

Returns:
the query parameter names as a Collection.

getDataSource

public LdapDataSource getDataSource()
Description copied from interface: Query
Get the datasource on which depends this query.

Returns:
the datasource on which depends this query.

setDataSource

public void setDataSource(LdapDataSource dataSource)
Set this query data source.

Parameters:
dataSource -

getAdditionalConfiguration

public Map<String,String> getAdditionalConfiguration()
Description copied from interface: Query
Get the additional query configuration information.

Returns:
the additional query configuration information as a Map of String -> String.

getAttributesAsMap

public Map<String,String> getAttributesAsMap()
Get attributes as Map.

Returns:
the attributes as a Map of attributeName -> label.

_buildAttributesMap

protected Map<String,String> _buildAttributesMap(String query)
Extract attributes from a query string in the form "attr1[label1], attr2[label2], attr3".

Parameters:
query - the query containing parameters.
Returns:
the attributes as a Map of label -> attributeName. If no label was provided between brackets, the name is used.

execute

public QueryResult execute(Map parameterValues)
                    throws DataInclusionException
Description copied from interface: Query
Execute the query with the specified parameter values.

Parameters:
parameterValues - the parameter values as a Map (name -> value).
Returns:
the query result.
Throws:
DataInclusionException

_getSearchControls

protected SearchControls _getSearchControls(Collection<String> attributes,
                                            String scopeStr)
Get the LDAP search controls.

Parameters:
attributes - the attributes to return.
scopeStr - the scope as a String.
Returns:
the search controls.

_getScope

protected int _getScope(String scopeStr)
Get the scope as an integer (handlable by the SearchControls) from the scope string.

Parameters:
scopeStr - the scope string.
Returns:
the scope as an integer.

_cleanup

protected void _cleanup(Context context,
                        NamingEnumeration<SearchResult> result)
Cleans a connection to a LDAP server.

Parameters:
context - The connection to the database to close.
result - The result to close.


Copyright © 2010 Anyware Services. All Rights Reserved.