edu.vt.middleware.ldap.dsml.DsmlSearch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vt-ldap Show documentation
Show all versions of vt-ldap Show documentation
Library for performing common LDAP operations
/*
$Id: DsmlSearch.java 1330 2010-05-23 22:10:53Z dfisher $
Copyright (C) 2003-2010 Virginia Tech.
All rights reserved.
SEE LICENSE FOR MORE INFORMATION
Author: Middleware Services
Email: [email protected]
Version: $Revision: 1330 $
Updated: $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
*/
package edu.vt.middleware.ldap.dsml;
import java.io.IOException;
import java.io.Writer;
import javax.naming.NamingException;
import edu.vt.middleware.ldap.Ldap;
import edu.vt.middleware.ldap.LdapSearch;
import edu.vt.middleware.ldap.pool.LdapPool;
/**
* DsmlSearch
queries an LDAP and returns the result as DSML. Each
* instance of DsmlSearch
maintains it's own pool of LDAP
* connections.
*
* @author Middleware Services
* @version $Revision: 1330 $ $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
*/
public class DsmlSearch extends LdapSearch
{
/** Valid DSML versions. */
public enum Version {
/** DSML version 1. */
ONE,
/** DSML version 2. */
TWO
}
/** Version of DSML to produce, default is 1. */
private Version version = Version.ONE;
/** Dsml version 1 object. */
private Dsmlv1 dsmlv1 = new Dsmlv1();
/** Dsml version 2 object. */
private Dsmlv2 dsmlv2 = new Dsmlv2();
/**
* This creates a new DsmlSearch
with the supplied pool.
*
* @param pool LdapPool
*/
public DsmlSearch(final LdapPool pool)
{
super(pool);
}
/**
* This gets the version of dsml to produce.
*
* @return Version
of DSML to produce
*/
public Version getVersion()
{
return this.version;
}
/**
* This sets the version of dsml to produce.
*
* @param v Version
of DSML to produce
*/
public void setVersion(final Version v)
{
this.version = v;
}
/**
* This will perform an LDAP search with the supplied query and return
* attributes. The results will be written to the supplied
* Writer
. Use {@link #version} to control which version of DSML is
* written.
*
* @param query String
to search for
* @param attrs String[]
to return
* @param writer Writer
to write to
*
* @throws NamingException if an error occurs while searching
* @throws IOException if an error occurs while writing search results
*/
public void search(
final String query,
final String[] attrs,
final Writer writer)
throws NamingException, IOException
{
if (this.version == Version.TWO) {
this.dsmlv2.outputDsml(this.search(query, attrs), writer);
} else {
this.dsmlv1.outputDsml(this.search(query, attrs), writer);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy