org.apache.directory.shared.dsmlv2.engine
Class Dsmlv2Engine

java.lang.Object
  extended by org.apache.directory.shared.dsmlv2.engine.Dsmlv2Engine

public class Dsmlv2Engine
extends Object

This is the DSMLv2Engine. It can be use to execute operations on a LDAP Server and get the results of these operations. The format used for request and responses is the DSMLv2 format.

Author:
Apache Directory Project

Field Summary
protected  BatchRequestDsml batchRequest
          The batch request.
protected  BatchResponseDsml batchResponse
          The batch response.
protected  LdapConnection connection
          The LDAP connection
protected  boolean continueOnError
          The continue on error flag.
protected  boolean exit
          The exit flag.
protected  boolean generateSoapResp
          flag to indicate to generate the response in a SOAP envelope
protected  Dsmlv2Grammar grammar
           
protected  Dsmlv2Parser parser
          The DSVMv2 parser.
protected  String password
          The password.
protected  String user
          The user.
 
Constructor Summary
Dsmlv2Engine(LdapConnection connection, String user, String password)
          Creates a new instance of Dsmlv2Engine.
Dsmlv2Engine(String host, int port, String user, String password)
          Creates a new instance of Dsmlv2Engine.
 
Method Summary
protected  void bind(int messageId)
          Binds to the ldap server
 BatchResponseDsml getBatchResponse()
           
 LdapConnection getConnection()
           
 boolean isGenerateSoapResp()
           
protected  void processBatchRequest()
          Processes the BatchRequest Parsing and Getting BatchRequest Getting and registering options from BatchRequest
 void processDSML(InputStream inputStream, OutputStream out)
          uses the default UTF-8 encoding for processing the DSML
 void processDSML(InputStream inputStream, String inputEncoding, OutputStream out)
          process the DSML request(s) from the given input stream with the specified encoding and writes the response to the output stream
protected  void processDSML(OutputStream outStream)
          processes the DSML batch request and writes the response of each operation will be written to the given response stream if it is not null
 String processDSML(String dsmlInput)
          Processes the file given and return the result of the operations
 void processDSMLFile(File file, OutputStream respStream)
          process the given file and optionally writing the output to the output stream(if not null)
 String processDSMLFile(String fileName)
          Processes the file given and return the result of the operations
protected  void processRequest(DsmlDecorator<? extends Request> request, BufferedWriter respWriter)
          Processes a single request
 void setGenerateSoapResp(boolean generateSoapResp)
           
protected  void writeResponse(BufferedWriter respWriter, DsmlDecorator respDsml)
          write the response to the writer of the underlying output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

user

protected String user
The user.


password

protected String password
The password.


connection

protected LdapConnection connection
The LDAP connection


parser

protected Dsmlv2Parser parser
The DSVMv2 parser.


continueOnError

protected boolean continueOnError
The continue on error flag.


exit

protected boolean exit
The exit flag.


batchRequest

protected BatchRequestDsml batchRequest
The batch request.


batchResponse

protected BatchResponseDsml batchResponse
The batch response.


grammar

protected Dsmlv2Grammar grammar

generateSoapResp

protected boolean generateSoapResp
flag to indicate to generate the response in a SOAP envelope

Constructor Detail

Dsmlv2Engine

public Dsmlv2Engine(String host,
                    int port,
                    String user,
                    String password)
Creates a new instance of Dsmlv2Engine.

Parameters:
host - the server host
port - the server port
user - the server admin Dn
password - the server admin's password

Dsmlv2Engine

public Dsmlv2Engine(LdapConnection connection,
                    String user,
                    String password)
Creates a new instance of Dsmlv2Engine.

Parameters:
connection - an unbound active connection
user - the user name to be used to bind this connection to the server
password - user's credentials
Method Detail

processDSML

public String processDSML(String dsmlInput)
                   throws org.xmlpull.v1.XmlPullParserException
Processes the file given and return the result of the operations

Parameters:
dsmlInput - the DSMLv2 formatted request input
Returns:
the XML response in DSMLv2 Format
Throws:
org.xmlpull.v1.XmlPullParserException - if an error occurs in the parser

processDSMLFile

public String processDSMLFile(String fileName)
                       throws org.xmlpull.v1.XmlPullParserException,
                              FileNotFoundException
Processes the file given and return the result of the operations

Parameters:
fileName - the path to the file
Returns:
the XML response in DSMLv2 Format
Throws:
org.xmlpull.v1.XmlPullParserException - if an error occurs in the parser
FileNotFoundException - if the file does not exist

processDSMLFile

public void processDSMLFile(File file,
                            OutputStream respStream)
                     throws Exception
process the given file and optionally writing the output to the output stream(if not null)

Parameters:
file - the DSML file
respStream - the output stream to which response will be written, skipped if null
Throws:
Exception

processDSML

public void processDSML(InputStream inputStream,
                        OutputStream out)
                 throws Exception
uses the default UTF-8 encoding for processing the DSML

Throws:
Exception
See Also:
processDSML(InputStream, String, OutputStream)

processDSML

public void processDSML(InputStream inputStream,
                        String inputEncoding,
                        OutputStream out)
                 throws Exception
process the DSML request(s) from the given input stream with the specified encoding and writes the response to the output stream

Parameters:
inputStream - the input stream for DSML batch request
inputEncoding - encoding to be used while reading the DSML request data
out - the output stream to which DSML response will be written
Throws:
Exception

processDSML

protected void processDSML(OutputStream outStream)
                    throws IOException
processes the DSML batch request and writes the response of each operation will be written to the given response stream if it is not null

Parameters:
outStream - the stream to which the responses will be written, can be null
Throws:
IOException

writeResponse

protected void writeResponse(BufferedWriter respWriter,
                             DsmlDecorator respDsml)
                      throws IOException
write the response to the writer of the underlying output stream

Parameters:
respWriter -
respDsml -
Throws:
IOException

isGenerateSoapResp

public boolean isGenerateSoapResp()
Returns:
the generateSoapResp

setGenerateSoapResp

public void setGenerateSoapResp(boolean generateSoapResp)
Parameters:
generateSoapResp - the generateSoapResp to set

getBatchResponse

public BatchResponseDsml getBatchResponse()
Returns:
the batchResponse

getConnection

public LdapConnection getConnection()
Returns:
the connection

processRequest

protected void processRequest(DsmlDecorator<? extends Request> request,
                              BufferedWriter respWriter)
                       throws Exception
Processes a single request

Parameters:
request - the request to process
Throws:
Exception

processBatchRequest

protected void processBatchRequest()
                            throws org.xmlpull.v1.XmlPullParserException
Processes the BatchRequest

Throws:
org.xmlpull.v1.XmlPullParserException - if an error occurs in the parser

bind

protected void bind(int messageId)
             throws LdapException,
                    EncoderException,
                    DecoderException,
                    IOException
Binds to the ldap server

Parameters:
messageId - the message Id
Throws:
EncoderException
DecoderException
IOException
LdapException


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.