Class Dsmlv2Engine
- java.lang.Object
-
- org.apache.directory.api.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
Fields Modifier and Type Field Description protected BatchRequestDsmlbatchRequestThe batch request.protected BatchResponseDsmlbatchResponseThe batch response.protected LdapConnectionconnectionThe LDAP connectionprotected booleancontinueOnErrorThe continue on error flag.protected booleanexitThe exit flag.protected booleangenerateSoapRespflag to indicate to generate the response in a SOAP envelopeprotected Dsmlv2Grammargrammarprotected Dsmlv2ParserparserThe DSVMv2 parser.protected StringpasswordThe password.protected StringuserThe user.
-
Constructor Summary
Constructors Constructor Description Dsmlv2Engine(String host, int port, String user, String password)Creates a new instance of Dsmlv2Engine.Dsmlv2Engine(LdapConnection connection, String user, String password)Creates a new instance of Dsmlv2Engine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbind(int messageId)Binds to the ldap serverBatchResponseDsmlgetBatchResponse()LdapConnectiongetConnection()booleanisGenerateSoapResp()protected voidprocessBatchRequest()Processes the BatchRequest Parsing and Getting BatchRequest Getting and registering options from BatchRequestvoidprocessDSML(InputStream inputStream, OutputStream out)Uses the default UTF-8 encoding for processing the DSMLvoidprocessDSML(InputStream inputStream, String inputEncoding, OutputStream out)Processes the DSML request(s) from the given input stream with the specified encoding and writes the response to the output streamprotected voidprocessDSML(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 nullStringprocessDSML(String dsmlInput)Processes the file given and return the result of the operationsvoidprocessDSMLFile(File file, OutputStream respStream)Process the given file and optionally writing the output to the output stream(if not null)StringprocessDSMLFile(String fileName)Processes the file given and return the result of the operationsprotected voidprocessRequest(DsmlDecorator<? extends Request> request, BufferedWriter respWriter)Processes a single requestvoidsetGenerateSoapResp(boolean generateSoapResp)protected voidwriteResponse(BufferedWriter respWriter, DsmlDecorator<?> respDsml)Writes the response to the writer of the underlying output stream
-
-
-
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 hostport- the server portuser- the server admin Dnpassword- 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 connectionuser- the user name to be used to bind this connection to the serverpassword- user's credentials
-
-
Method Detail
-
processDSML
public String processDSML(String dsmlInput) throws 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:
XmlPullParserException- if an error occurs in the parser
-
processDSMLFile
public String processDSMLFile(String fileName) throws XmlPullParserException, IOException
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:
XmlPullParserException- if an error occurs in the parserIOException- 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 filerespStream- the output stream to which response will be written, skipped if null- Throws:
Exception- If the processing fails
-
processDSML
public void processDSML(InputStream inputStream, OutputStream out) throws Exception
Uses the default UTF-8 encoding for processing the DSML- Parameters:
inputStream- The Stream containing the DSML to processout- The Stream where to put the result- Throws:
Exception- If we had an error while processing the DSML- See Also:
processDSML(InputStream, String, OutputStream)
-
processDSML
public void processDSML(InputStream inputStream, String inputEncoding, OutputStream out) throws Exception
Processes 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 requestinputEncoding- encoding to be used while reading the DSML request dataout- the output stream to which DSML response will be written- Throws:
Exception- If the processing fails
-
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- If we had an issue while reading or writing the data
-
writeResponse
protected void writeResponse(BufferedWriter respWriter, DsmlDecorator<?> respDsml) throws IOException
Writes the response to the writer of the underlying output stream- Parameters:
respWriter- The writer used to write the responserespDsml- The decorator containing the response- Throws:
IOException- If we had an error while writing the DSML response
-
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 processrespWriter- The writer used to store the DSML response- Throws:
Exception- If we had an error while processing the request
-
processBatchRequest
protected void processBatchRequest() throws XmlPullParserExceptionProcesses the BatchRequest- Parsing and Getting BatchRequest
- Getting and registering options from BatchRequest
- Throws:
XmlPullParserException- if an error occurs in the parser
-
bind
protected void bind(int messageId) throws LdapException, IOExceptionBinds to the ldap server- Parameters:
messageId- the message Id- Throws:
LdapException- If we had an issue while bindingIOException- If we had an issue while transmitting the request or re ceiving the response
-
-