You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/02/29 01:02:12 UTC
svn commit: r1294908 -
/directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
Author: elecharny
Date: Wed Feb 29 00:02:12 2012
New Revision: 1294908
URL: http://svn.apache.org/viewvc?rev=1294908&view=rev
Log:
Updated the Javadoc, cleaned up the code
Modified:
directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
Modified: directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java?rev=1294908&r1=1294907&r2=1294908&view=diff
==============================================================================
--- directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java (original)
+++ directory/shared/trunk/dsml/engine/src/main/java/org/apache/directory/shared/dsmlv2/engine/Dsmlv2Engine.java Wed Feb 29 00:02:12 2012
@@ -128,6 +128,7 @@ public class Dsmlv2Engine
/** flag to indicate to generate the response in a SOAP envelope */
protected boolean generateSoapResp = false;
+ /** A logger for this class */
private static final Logger LOG = LoggerFactory.getLogger( Dsmlv2Engine.class );
@@ -149,7 +150,6 @@ public class Dsmlv2Engine
/**
- *
* Creates a new instance of Dsmlv2Engine.
*
* @param connection an unbound active connection
@@ -168,12 +168,9 @@ public class Dsmlv2Engine
/**
* Processes the file given and return the result of the operations
*
- * @param dsmlInput
- * the DSMLv2 formatted request input
- * @return
- * the XML response in DSMLv2 Format
- * @throws XmlPullParserException
- * if an error occurs in the parser
+ * @param dsmlInput the DSMLv2 formatted request input
+ * @return the XML response in DSMLv2 Format
+ * @throws XmlPullParserException if an error occurs in the parser
*/
public String processDSML( String dsmlInput ) throws XmlPullParserException
{
@@ -187,14 +184,10 @@ public class Dsmlv2Engine
/**
* Processes the file given and return the result of the operations
*
- * @param fileName
- * the path to the file
- * @return
- * the XML response in DSMLv2 Format
- * @throws XmlPullParserException
- * if an error occurs in the parser
- * @throws FileNotFoundException
- * if the file does not exist
+ * @param fileName the path to the file
+ * @return the XML response in DSMLv2 Format
+ * @throws XmlPullParserException if an error occurs in the parser
+ * @throws FileNotFoundException if the file does not exist
*/
public String processDSMLFile( String fileName ) throws XmlPullParserException, FileNotFoundException
{
@@ -206,12 +199,12 @@ public class Dsmlv2Engine
/**
- * process the given file and optionally writing the output to the
+ * Process the given file and optionally writing the output to the
* output stream(if not null)
*
* @param file the DSML file
* @param respStream the output stream to which response will be written, skipped if null
- * @throws Exception
+ * @throws Exception If the processing fails
*/
public void processDSMLFile( File file, OutputStream respStream ) throws Exception
{
@@ -223,7 +216,7 @@ public class Dsmlv2Engine
/**
- * uses the default UTF-8 encoding for processing the DSML
+ * Uses the default UTF-8 encoding for processing the DSML
*
* @see #processDSML(InputStream, String, OutputStream)
*/
@@ -234,13 +227,13 @@ public class Dsmlv2Engine
/**
- * process the DSML request(s) from the given input stream with the specified encoding
+ * Processes the DSML request(s) from the given input stream with the specified encoding
* and writes the response to the output stream
*
* @param inputStream the input stream for DSML batch request
* @param inputEncoding encoding to be used while reading the DSML request data
* @param out the output stream to which DSML response will be written
- * @throws Exception
+ * @throws Exception If the processing fails
*/
public void processDSML( InputStream inputStream, String inputEncoding, OutputStream out ) throws Exception
{
@@ -273,11 +266,11 @@ public class Dsmlv2Engine
/**
- * processes the DSML batch request and writes the response of each operation will be
+ * 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
*
* @param outStream the stream to which the responses will be written, can be null
- * @throws IOException
+ * @throws IOException If we had an issue while reading or writing the data
*/
protected void processDSML( OutputStream outStream ) throws IOException
{
@@ -325,6 +318,7 @@ public class Dsmlv2Engine
// We create a new ErrorResponse and return the XML response.
ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT, e
.getLocalizedMessage() );
+
if ( respWriter != null )
{
writeResponse( respWriter, errorResponse );
@@ -385,6 +379,7 @@ public class Dsmlv2Engine
// We create a new ErrorResponse and return the XML response.
ErrorResponse errorResponse = new ErrorResponse( reqId, ErrorResponseType.MALFORMED_REQUEST, I18n.err(
I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber() ) );
+
if ( respWriter != null )
{
writeResponse( respWriter, errorResponse );
@@ -433,6 +428,7 @@ public class Dsmlv2Engine
ErrorResponse errorResponse = new ErrorResponse( request.getDecorated().getMessageId(),
ErrorResponseType.GATEWAY_INTERNAL_ERROR, I18n.err(
I18n.ERR_03003, e.getMessage() ) );
+
if ( respWriter != null )
{
writeResponse( respWriter, errorResponse );
@@ -461,6 +457,7 @@ public class Dsmlv2Engine
// We create a new ErrorResponse and return the XML response.
ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, I18n.err(
I18n.ERR_03001, e.getLocalizedMessage(), e.getLineNumber(), e.getColumnNumber() ) );
+
if ( respWriter != null )
{
writeResponse( respWriter, errorResponse );
@@ -490,12 +487,13 @@ public class Dsmlv2Engine
/**
- * write the response to the writer of the underlying output stream
- * @param respWriter
- * @param respDsml
- * @throws IOException
+ * Writes the response to the writer of the underlying output stream
+ *
+ * @param respWriter The writer used to write the response
+ * @param respDsml The decorator containing the response
+ * @throws IOException If we had an error while writing the DSML response
*/
- protected void writeResponse( BufferedWriter respWriter, DsmlDecorator respDsml ) throws IOException
+ protected void writeResponse( BufferedWriter respWriter, DsmlDecorator<?> respDsml ) throws IOException
{
if ( respWriter != null )
{
@@ -545,6 +543,8 @@ public class Dsmlv2Engine
* Processes a single request
*
* @param request the request to process
+ * @param respWriter The writer used to store the DSML response
+ * @exception Exception If we had an error while processing the request
*/
protected void processRequest( DsmlDecorator<? extends Request> request, BufferedWriter respWriter )
throws Exception
@@ -728,8 +728,7 @@ public class Dsmlv2Engine
* <li>Getting and registering options from BatchRequest</li>
* </ul>
*
- * @throws XmlPullParserException
- * if an error occurs in the parser
+ * @throws XmlPullParserException if an error occurs in the parser
*/
protected void processBatchRequest() throws XmlPullParserException
{
@@ -748,12 +747,9 @@ public class Dsmlv2Engine
continueOnError = false;
}
- if ( batchRequest.getRequestID() != 0 )
+ if ( ( batchRequest.getRequestID() != 0 ) && ( batchResponse != null ) )
{
- if ( batchResponse != null )
- {
- batchResponse.setRequestID( batchRequest.getRequestID() );
- }
+ batchResponse.setRequestID( batchRequest.getRequestID() );
}
}
@@ -762,9 +758,9 @@ public class Dsmlv2Engine
* Binds to the ldap server
*
* @param messageId the message Id
- * @throws EncoderException
- * @throws DecoderException
- * @throws IOException
+ * @throws EncoderException If we had an issue while encoding the request
+ * @throws DecoderException If we had an issue while decoding the request
+ * @throws IOException If we had an issue while transmitting the request or re ceiving the response
*/
protected void bind( int messageId ) throws LdapException, EncoderException, DecoderException, IOException
{