You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2009/07/21 19:04:29 UTC
svn commit: r796383 [5/23] - in /directory/shared/trunk: ./ dsml-parser/
dsml-parser/src/ dsml-parser/src/main/ dsml-parser/src/main/java/
dsml-parser/src/main/java/org/ dsml-parser/src/main/java/org/apache/
dsml-parser/src/main/java/org/apache/directo...
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * Class representing Error Response. <br>
+ * <br>
+ * An Error Response has a requestID, a message, and a type which can be :
+ * <ul>
+ * <li>NOT_ATTEMPTED,</li>
+ * <li>COULD_NOT_CONNECT,</li>
+ * <li>CONNECTION_CLOSED,</li>
+ * <li>MALFORMED_REQUEST,</li>
+ * <li>GATEWAY_INTERNAL_ERROR,</li>
+ * <li>AUTHENTICATION_FAILED,</li>
+ * <li>UNRESOLVABLE_URI,</li>
+ * <li>OTHER</li>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ErrorResponse extends LdapResponseCodec implements DsmlDecorator
+{
+ /**
+ * This enum represents the different types of error response
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum ErrorResponseType
+ {
+ NOT_ATTEMPTED, COULD_NOT_CONNECT, CONNECTION_CLOSED, MALFORMED_REQUEST, GATEWAY_INTERNAL_ERROR, AUTHENTICATION_FAILED, UNRESOLVABLE_URI, OTHER
+ };
+
+ /** The type of error response */
+ private ErrorResponseType type;
+
+ /** The associated message */
+ private String message;
+
+ /** The request ID */
+ private int requestID;
+
+
+ /**
+ * Creates a new instance of ErrorResponse.
+ */
+ public ErrorResponse()
+ {
+ }
+
+
+ /**
+ * Creates a new instance of ErrorResponse.
+ *
+ * @param requestID
+ * the requestID of the response
+ * @param type
+ * the type of the response
+ * @param message
+ * the associated message
+ */
+ public ErrorResponse( int requestID, ErrorResponseType type, String message )
+ {
+ this.requestID = requestID;
+ this.type = type;
+ this.message = message;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "errorResponse" );
+
+ // RequestID
+ if ( requestID != 0 )
+ {
+ element.addAttribute( "requestID", "" + requestID );
+ }
+
+ // Type
+ element.addAttribute( "type", getTypeDescr( type ) );
+
+ // TODO Add Detail
+
+ if ( ( message != null ) && ( !"".equals( message ) ) )
+ {
+ Element messageElement = element.addElement( "message" );
+ messageElement.addText( message );
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Returns the String associated to the error response type
+ *
+ * @param type
+ * the error response type
+ * @return
+ * the corresponding String
+ */
+ public String getTypeDescr( ErrorResponseType type )
+ {
+ if ( type.equals( ErrorResponseType.NOT_ATTEMPTED ) )
+ {
+ return "notAttempted";
+ }
+ else if ( type.equals( ErrorResponseType.COULD_NOT_CONNECT ) )
+ {
+ return "couldNotConnect";
+ }
+ else if ( type.equals( ErrorResponseType.CONNECTION_CLOSED ) )
+ {
+ return "connectionClosed";
+ }
+ else if ( type.equals( ErrorResponseType.MALFORMED_REQUEST ) )
+ {
+ return "malformedRequest";
+ }
+ else if ( type.equals( ErrorResponseType.GATEWAY_INTERNAL_ERROR ) )
+ {
+ return "gatewayInternalError";
+ }
+ else if ( type.equals( ErrorResponseType.AUTHENTICATION_FAILED ) )
+ {
+ return "authenticationFailed";
+ }
+ else if ( type.equals( ErrorResponseType.UNRESOLVABLE_URI ) )
+ {
+ return "unresolvableURI";
+ }
+ else if ( type.equals( ErrorResponseType.OTHER ) )
+ {
+ return "other";
+ }
+ else
+ {
+ return "unknown";
+ }
+ }
+
+
+ /**
+ * Gets the message
+ *
+ * @return
+ * the message
+ */
+ public String getMessage()
+ {
+ return message;
+ }
+
+
+ /**
+ * Sets the message
+ *
+ * @param message
+ * the message to set
+ */
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+
+ /**
+ * Gets the request ID
+ *
+ * @return
+ * the request ID
+ */
+ public int getRequestID()
+ {
+ return requestID;
+ }
+
+
+ /**
+ * Sets the request ID
+ *
+ * @param requestID
+ * the request ID to set
+ */
+ public void setRequestID( int requestID )
+ {
+ this.requestID = requestID;
+ }
+
+
+ /**
+ * Gets the type of error response
+ *
+ * @return
+ * the type of error response
+ */
+ public ErrorResponseType getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * Sets the type of error response
+ *
+ * @param type
+ * the type of error response to set
+ */
+ public void setType( ErrorResponseType type )
+ {
+ this.type = type;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+
+/**
+ * DSML Decorator for ExtendedResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExtendedResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of ExtendedResponseDsml.
+ */
+ public ExtendedResponseDsml()
+ {
+ super( new ExtendedResponseCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of ExtendedResponseDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ExtendedResponseDsml( ExtendedResponseCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "extendedResponse" );
+ ExtendedResponseCodec extendedResponse = ( ExtendedResponseCodec ) instance;
+
+ // LDAP Result
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( extendedResponse.getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+
+ // ResponseName
+ String responseName = extendedResponse.getResponseName();
+ if ( responseName != null )
+ {
+ element.addElement( "responseName" ).addText( responseName );
+ }
+
+ // Response
+ Object response = extendedResponse.getResponse();
+ if ( response != null )
+ {
+ if ( ParserUtils.needsBase64Encoding( response ) )
+ {
+ Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI );
+ Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI );
+ element.getDocument().getRootElement().add( xsdNamespace );
+ element.getDocument().getRootElement().add( xsiNamespace );
+
+ Element responseElement = element.addElement( "response" )
+ .addText( ParserUtils.base64Encode( response ) );
+ responseElement.addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD + ":"
+ + ParserUtils.BASE64BINARY );
+ }
+ else
+ {
+ element.addElement( "response" ).addText( response.toString() );
+ }
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Get the extended response name
+ *
+ * @return Returns the name.
+ */
+ public String getResponseName()
+ {
+ return ( ( ExtendedResponseCodec ) instance ).getResponseName();
+ }
+
+
+ /**
+ * Set the extended response name
+ *
+ * @param responseName The name to set.
+ */
+ public void setResponseName( OID responseName )
+ {
+ ( ( ExtendedResponseCodec ) instance ).setResponseName( responseName );
+ }
+
+
+ /**
+ * Get the extended response
+ *
+ * @return Returns the response.
+ */
+ public Object getResponse()
+ {
+ return ( ( ExtendedResponseCodec ) instance ).getResponse();
+ }
+
+
+ /**
+ * Set the extended response
+ *
+ * @param response The response to set.
+ */
+ public void setResponse( Object response )
+ {
+ ( ( ExtendedResponseCodec ) instance ).setResponse( response );
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.shared.ldap.codec.LdapResultCodec;
+import org.apache.directory.studio.dsmlv2.LdapMessageDecorator;
+
+
+/**
+ * Decorator abstract class for LdapResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class LdapResponseDecorator extends LdapMessageDecorator
+{
+ /**
+ * Creates a new instance of LdapResponseDecorator.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public LdapResponseDecorator( LdapMessageCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResponseLength()
+ */
+ public int getLdapResponseLength()
+ {
+ return ( ( LdapResponseCodec ) instance ).getLdapResponseLength();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResult()
+ */
+ public LdapResultCodec getLdapResult()
+ {
+ return ( ( LdapResponseCodec ) instance ).getLdapResult();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#setLdapResult(org.apache.directory.shared.ldap.codec.LdapResult)
+ */
+ public void setLdapResult( LdapResultCodec ldapResult )
+ {
+ ( ( LdapResponseCodec ) instance ).setLdapResult( ldapResult );
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.shared.ldap.codec.LdapResultCodec;
+import org.apache.directory.shared.ldap.util.LdapURL;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for the LdapResult class.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapResultDsml implements DsmlDecorator
+{
+ /** The LDAP Result to decorate */
+ private LdapResultCodec result;
+
+ /** The associated LDAP Message */
+ private LdapMessageCodec message;
+
+
+ /**
+ * Creates a new instance of LdapResultDsml.
+ *
+ * @param result
+ * the LdapResult to decorate
+ * @param message
+ * the associated message
+ */
+ public LdapResultDsml( LdapResultCodec result, LdapMessageCodec message )
+ {
+ this.result = result;
+ this.message = message;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+
+ // RequestID
+ int requestID = message.getMessageId();
+ if ( requestID != 0 )
+ {
+ root.addAttribute( "requestID", "" + requestID );
+ }
+
+ // Matched DN
+ String matchedDN = result.getMatchedDN();
+ if ( !matchedDN.equals( "" ) )
+ {
+ root.addAttribute( "matchedDN", matchedDN );
+ }
+
+ // Controls
+ ParserUtils.addControls( root, message.getControls() );
+
+ // ResultCode
+ Element resultCodeElement = root.addElement( "resultCode" );
+ resultCodeElement.addAttribute( "code", "" + result.getResultCode().getResultCode() );
+ resultCodeElement.addAttribute( "descr", LdapResultEnum.getResultCodeDescr( result.getResultCode() ) );
+
+ // ErrorMessage
+ String errorMessage = ( result.getErrorMessage() );
+ if ( ( errorMessage != null ) && ( !errorMessage.equals( "" ) ) )
+ {
+ Element errorMessageElement = root.addElement( "errorMessage" );
+ errorMessageElement.addText( errorMessage );
+ }
+
+ // Referals
+ List<LdapURL> referals = result.getReferrals();
+ if ( referals != null )
+ {
+ for ( int i = 0; i < referals.size(); i++ )
+ {
+ Element referalElement = root.addElement( "referal" );
+ referalElement.addText( referals.get( i ).toString() );
+ }
+ }
+
+ return root;
+ }
+
+
+ /**
+ * Initialize the referrals list
+ */
+ public void initReferrals()
+ {
+ result.initReferrals();
+ }
+
+
+ /**
+ * Get the error message
+ *
+ * @return Returns the errorMessage.
+ */
+ public String getErrorMessage()
+ {
+ return result.getErrorMessage();
+ }
+
+
+ /**
+ * Set the error message
+ *
+ * @param errorMessage The errorMessage to set.
+ */
+ public void setErrorMessage( String errorMessage )
+ {
+ result.setErrorMessage( errorMessage );
+ }
+
+
+ /**
+ * Get the matched DN
+ *
+ * @return Returns the matchedDN.
+ */
+ public String getMatchedDN()
+ {
+ return result.getMatchedDN();
+ }
+
+
+ /**
+ * Set the Matched DN
+ *
+ * @param matchedDN The matchedDN to set.
+ */
+ public void setMatchedDN( LdapDN matchedDN )
+ {
+ result.setMatchedDN( matchedDN );
+ }
+
+
+ /**
+ * Get the referrals
+ *
+ * @return Returns the referrals.
+ */
+ public List<LdapURL> getReferrals()
+ {
+ return result.getReferrals();
+ }
+
+
+ /**
+ * Add a referral
+ *
+ * @param referral The referral to add.
+ */
+ public void addReferral( LdapURL referral )
+ {
+ result.addReferral( referral );
+ }
+
+
+ /**
+ * Get the result code
+ *
+ * @return Returns the resultCode.
+ */
+ public ResultCodeEnum getResultCode()
+ {
+ return result.getResultCode();
+ }
+
+
+ /**
+ * Set the result code
+ *
+ * @param resultCode The resultCode to set.
+ */
+ public void setResultCode( ResultCodeEnum resultCode )
+ {
+ result.setResultCode( resultCode );
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+
+
+/**
+ * This Class helps to get resultCodeDesc for a ResultCode of a LdapResult.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapResultEnum
+{
+ /**
+ * Gets the String description of a given result code
+ *
+ * @param resultCode
+ * a result code
+ * @return
+ * the String description corresponding to the result code
+ */
+ public static String getResultCodeDescr( ResultCodeEnum resultCode )
+ {
+ switch ( resultCode )
+ {
+ case SUCCESS:
+ return "success";
+ case OPERATIONS_ERROR:
+ return "operationsError";
+ case PROTOCOL_ERROR:
+ return "protocolError";
+ case TIME_LIMIT_EXCEEDED:
+ return "timeLimitExceeded";
+ case SIZE_LIMIT_EXCEEDED:
+ return "sizeLimitExceeded";
+ case COMPARE_FALSE:
+ return "compareFalse";
+ case COMPARE_TRUE:
+ return "compareTrue";
+ case AUTH_METHOD_NOT_SUPPORTED:
+ return "authMethodNotSupported";
+ case STRONG_AUTH_REQUIRED:
+ return "strongAuthRequired";
+ case PARTIAL_RESULTS:
+ return "partialResults";
+ case REFERRAL:
+ return "referral";
+ case ADMIN_LIMIT_EXCEEDED:
+ return "adminLimitExceeded";
+ case UNAVAILABLE_CRITICAL_EXTENSION:
+ return "unavailableCriticalExtension";
+ case CONFIDENTIALITY_REQUIRED:
+ return "confidentialityRequired";
+ case SASL_BIND_IN_PROGRESS:
+ return "saslBindInProgress";
+ case NO_SUCH_ATTRIBUTE:
+ return "noSuchAttribute";
+ case UNDEFINED_ATTRIBUTE_TYPE:
+ return "undefinedAttributeType";
+ case INAPPROPRIATE_MATCHING:
+ return "inappropriateMatching";
+ case CONSTRAINT_VIOLATION:
+ return "constraintViolation";
+ case ATTRIBUTE_OR_VALUE_EXISTS:
+ return "attributeOrValueExists";
+ case INVALID_ATTRIBUTE_SYNTAX:
+ return "invalidAttributeSyntax";
+ case NO_SUCH_OBJECT:
+ return "NO_SUCH_OBJECT";
+ case ALIAS_PROBLEM:
+ return "aliasProblem";
+ case INVALID_DN_SYNTAX:
+ return "invalidDNSyntax";
+ case ALIAS_DEREFERENCING_PROBLEM:
+ return "aliasDereferencingProblem";
+ case INAPPROPRIATE_AUTHENTICATION:
+ return "inappropriateAuthentication";
+ case INVALID_CREDENTIALS:
+ return "invalidCredentials";
+ case INSUFFICIENT_ACCESS_RIGHTS:
+ return "insufficientAccessRights";
+ case BUSY:
+ return "busy";
+ case UNAVAILABLE:
+ return "unavailable";
+ case UNWILLING_TO_PERFORM:
+ return "unwillingToPerform";
+ case LOOP_DETECT:
+ return "loopDetect";
+ case NAMING_VIOLATION:
+ return "namingViolation";
+ case OBJECT_CLASS_VIOLATION:
+ return "objectClassViolation";
+ case NOT_ALLOWED_ON_NON_LEAF:
+ return "notAllowedOnNonLeaf";
+ case NOT_ALLOWED_ON_RDN:
+ return "notAllowedOnRDN";
+ case ENTRY_ALREADY_EXISTS:
+ return "entryAlreadyExists";
+ case OBJECT_CLASS_MODS_PROHIBITED:
+ return "objectClassModsProhibited";
+ case AFFECTS_MULTIPLE_DSAS:
+ return "affectsMultipleDSAs";
+ case OTHER:
+ return "other";
+ case UNKNOWN:
+ return "unknown";
+
+ default:
+ return "unknoxn";
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for ModDNResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModDNResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of ModDNResponseDsml.
+ */
+ public ModDNResponseDsml()
+ {
+ super( new ModifyDNResponseCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of ModDNResponseDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ModDNResponseDsml( ModifyDNResponseCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "modDNResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( ModifyDNResponseCodec ) instance ).getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for ModifyResponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of ModifyResponseDsml.
+ */
+ public ModifyResponseDsml()
+ {
+ super( new ModifyResponseCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of ModifyResponseDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ModifyResponseDsml( ModifyResponseCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "modifyResponse" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( ModifyResponseCodec ) instance ).getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
+
+
+/**
+ * This class represents the DSML Search Response
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResponse extends LdapResponseCodec
+{
+ /** The List of contained Search Result Entries */
+ private List<SearchResultEntryCodec> searchResultEntryList;
+
+ /** The List of contained Search Result References */
+ private List<SearchResultReferenceCodec> searchResultReferenceList;
+
+ /** The Search Result Done object */
+ private SearchResultDoneCodec searchResultDone;
+
+
+ /**
+ * Creates a new instance of SearchResponse.
+ */
+ public SearchResponse()
+ {
+ searchResultEntryList = new ArrayList<SearchResultEntryCodec>();
+ searchResultReferenceList = new ArrayList<SearchResultReferenceCodec>();
+ }
+
+
+ /**
+ * Adds a Search Result Entry
+ *
+ * @param searchResultEntry
+ * the Search Result Entry to add
+ * @return
+ * true (as per the general contract of the Collection.add method)
+ */
+ public boolean addSearchResultEntry( SearchResultEntryCodec searchResultEntry )
+ {
+ return searchResultEntryList.add( searchResultEntry );
+ }
+
+
+ /**
+ * Gets the Current Search Result Entry
+ *
+ * @return
+ * the current Searche Result Entry
+ */
+ public SearchResultEntryCodec getCurrentSearchResultEntry()
+ {
+ if ( searchResultEntryList.size() > 0 )
+ {
+ return searchResultEntryList.get( searchResultEntryList.size() - 1 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets the Search Result Entry List
+ *
+ * @return
+ * the Search Result Entry List
+ */
+ public List<SearchResultEntryCodec> getSearchResultEntryList()
+ {
+ return searchResultEntryList;
+ }
+
+
+ /**
+ * Adds a Search Result Reference
+ *
+ * @param searchResultReference
+ * the Search Result Reference to add
+ * @return
+ * true (as per the general contract of the Collection.add method)
+ */
+ public boolean addSearchResultReference( SearchResultReferenceCodec searchResultReference )
+ {
+ return searchResultReferenceList.add( searchResultReference );
+ }
+
+
+ /**
+ * Gets the current Search Result Reference
+ *
+ * @return
+ * the current Search Result Reference
+ */
+ public SearchResultReferenceCodec getCurrentSearchResultReference()
+ {
+ if ( searchResultReferenceList.size() > 0 )
+ {
+ return searchResultReferenceList.get( searchResultReferenceList.size() - 1 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets the Search Result Reference List
+ *
+ * @return
+ * the Search Result Reference List
+ */
+ public List<SearchResultReferenceCodec> getSearchResultReferenceList()
+ {
+ return searchResultReferenceList;
+ }
+
+
+ /**
+ * Gets the Search Result Entry
+ *
+ * @return
+ * the Search Result Entry
+ */
+ public SearchResultDoneCodec getSearchResultDone()
+ {
+ return searchResultDone;
+ }
+
+
+ /**
+ * Sets the Search Result Entry
+ *
+ * @param searchResultDone
+ * the Search Result Entry to set
+ */
+ public void setSearchResultDone( SearchResultDoneCodec searchResultDone )
+ {
+ this.searchResultDone = searchResultDone;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * This class represents the Search Response Dsml Container.
+ * It is used to store Search Responses (Search Result Entry,
+ * Search Result Reference and SearchResultDone).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResponseDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /** The responses */
+ private List<DsmlDecorator> responses = new ArrayList<DsmlDecorator>();
+
+
+ /**
+ * Creates a new instance of SearchResponseDsml.
+ */
+ public SearchResponseDsml()
+ {
+ super( new LdapMessageCodec() );
+ }
+
+
+ /**
+ * Adds a response.
+ *
+ * @param response
+ * the response to add
+ * @return
+ * true (as per the general contract of the Collection.add method).
+ */
+ public boolean addResponse( DsmlDecorator response )
+ {
+ return responses.add( response );
+ }
+
+
+ /**
+ * Removes a response.
+ *
+ * @param response
+ * the response to remove
+ * @return
+ * true if this list contained the specified element.
+ */
+ public boolean removeResponse( DsmlDecorator response )
+ {
+ return responses.remove( response );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "searchResponse" );
+
+ // RequestID
+ int requestID = instance.getMessageId();
+ if ( requestID != 0 )
+ {
+ element.addAttribute( "requestID", "" + requestID );
+ }
+
+ for ( DsmlDecorator response : responses )
+ {
+ response.toDsml( element );
+ }
+
+ return element;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for SearchResultDone
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResultDoneDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of SearchResultDoneDsml.
+ */
+ public SearchResultDoneDsml()
+ {
+ super( new SearchResultDoneCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of SearchResultDoneDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultDoneDsml( SearchResultDoneCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "searchResultDone" );
+
+ LdapResultDsml ldapResultDsml = new LdapResultDsml( ( ( SearchResultDoneCodec ) instance ).getLdapResult(), instance );
+ if ( ldapResultDsml != null)
+ {
+ ldapResultDsml.toDsml( element );
+ }
+
+ return element;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+
+/**
+ * DSML Decorator for SearchResultEntry
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResultEntryDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of SearchResultEntryDsml.
+ */
+ public SearchResultEntryDsml()
+ {
+ super( new SearchResultEntryCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of SearchResultEntryDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultEntryDsml( SearchResultEntryCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "searchResultEntry" );
+ SearchResultEntryCodec searchResultEntry = ( SearchResultEntryCodec ) instance;
+ element.addAttribute( "dn", searchResultEntry.getObjectName().getUpName() );
+
+ Entry entry = searchResultEntry.getEntry();
+ for ( EntryAttribute attribute : entry )
+ {
+
+ Element attributeElement = element.addElement( "attr" );
+ attributeElement.addAttribute( "name", attribute.getId() );
+
+ for ( Value<?> value : attribute )
+ {
+ if ( ParserUtils.needsBase64Encoding( value.get() ) )
+ {
+ Namespace xsdNamespace = new Namespace( ParserUtils.XSD, ParserUtils.XML_SCHEMA_URI );
+ Namespace xsiNamespace = new Namespace( ParserUtils.XSI, ParserUtils.XML_SCHEMA_INSTANCE_URI );
+ attributeElement.getDocument().getRootElement().add( xsdNamespace );
+ attributeElement.getDocument().getRootElement().add( xsiNamespace );
+
+ Element valueElement = attributeElement.addElement( "value" ).addText(
+ ParserUtils.base64Encode( value.get() ) );
+ valueElement.addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD + ":"
+ + ParserUtils.BASE64BINARY );
+ }
+ else
+ {
+ attributeElement.addElement( "value" ).addText( value.get().toString() );
+ }
+ }
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Get the entry DN
+ *
+ * @return Returns the objectName.
+ */
+ public LdapDN getObjectName()
+ {
+ return ( ( SearchResultEntryCodec ) instance ).getObjectName();
+ }
+
+
+ /**
+ * Set the entry DN
+ *
+ * @param objectName The objectName to set.
+ */
+ public void setObjectName( LdapDN objectName )
+ {
+ ( ( SearchResultEntryCodec ) instance ).setObjectName( objectName );
+ }
+
+
+ /**
+ * Get the entry.
+ *
+ * @return Returns the entry.
+ */
+ public Entry getEntry()
+ {
+ return ( ( SearchResultEntryCodec ) instance ).getEntry();
+ }
+
+
+ /**
+ * Initialize the entry.
+ *
+ * @param entry the entry
+ */
+ public void setEntry( Entry entry )
+ {
+ ( ( SearchResultEntryCodec ) instance ).setEntry( entry );
+ }
+
+
+ /**
+ * Create a new attributeValue
+ *
+ * @param type The attribute's name
+ */
+ public void addAttributeValues( String type )
+ {
+ ( ( SearchResultEntryCodec ) instance ).addAttributeValues( type );
+ }
+
+
+ /**
+ * Add a new value to the current attribute
+ *
+ * @param value
+ */
+ public void addAttributeValue( Object value )
+ {
+ ( ( SearchResultEntryCodec ) instance ).addAttributeValue( value );
+ }
+
+
+ /**
+ * @return Returns the currentAttributeValue.
+ */
+ public String getCurrentAttributeValueType()
+ {
+ return ( ( SearchResultEntryCodec ) instance ).getCurrentAttributeValueType();
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.reponse;
+
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
+import org.apache.directory.shared.ldap.util.LdapURL;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for SearchResultReference
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchResultReferenceDsml extends LdapResponseDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of SearchResultReferenceDsml.
+ */
+ public SearchResultReferenceDsml()
+ {
+ super( new SearchResultReferenceCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of SearchResultReferenceDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultReferenceDsml( LdapMessageCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.LdapMessageDecorator#getMessageType()
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.reponse.DsmlDecorator#toDsml(org.dom4j.Element)
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( "searchResultReference" );
+ SearchResultReferenceCodec searchResultReference = ( SearchResultReferenceCodec ) instance;
+
+ // Adding References
+ List<LdapURL> refsList = searchResultReference.getSearchResultReferences();
+ for ( int i = 0; i < refsList.size(); i++ )
+ {
+ element.addElement( "ref" ).addText( refsList.get( i ).toString() );
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Add a new reference to the list.
+ *
+ * @param searchResultReference The search result reference
+ */
+ public void addSearchResultReference( LdapURL searchResultReference )
+ {
+ ( ( SearchResultReferenceCodec ) instance ).addSearchResultReference( searchResultReference );
+ }
+
+
+ /**
+ * Get the list of references
+ *
+ * @return An ArrayList of SearchResultReferences
+ */
+ public List<LdapURL> getSearchResultReferences()
+ {
+ return ( ( SearchResultReferenceCodec ) instance ).getSearchResultReferences();
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.dsmlv2.request;
+
+
+import org.apache.directory.shared.ldap.codec.abandon.AbandonRequestCodec;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for AbandonRequest
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AbandonRequestDsml extends AbstractRequestDsml
+{
+ /**
+ * Creates a new instance of AbandonRequestDsml.
+ */
+ public AbandonRequestDsml()
+ {
+ super( new AbandonRequestCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of AbandonRequestDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AbandonRequestDsml( AbandonRequestCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ AbandonRequestCodec request = ( AbandonRequestCodec ) instance;
+
+ // AbandonID
+ if ( request.getAbandonedMessageId() != 0 )
+ {
+ element.addAttribute( "abandonID", "" + request.getAbandonedMessageId() );
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Get the abandoned message ID
+ *
+ * @return Returns the abandoned MessageId.
+ */
+ public int getAbandonedMessageId()
+ {
+ return ( ( AbandonRequestCodec ) instance ).getAbandonedMessageId();
+ }
+
+
+ /**
+ * Set the abandoned message ID
+ *
+ * @param abandonedMessageId The abandoned messageID to set.
+ */
+ public void setAbandonedMessageId( int abandonedMessageId )
+ {
+ ( ( AbandonRequestCodec ) instance ).setAbandonedMessageId( abandonedMessageId );
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+ package org.apache.directory.studio.dsmlv2.request;
+
+
+import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Element;
+
+
+public abstract class AbstractRequestDsml extends LdapRequestDecorator implements DsmlDecorator
+{
+ /**
+ * Creates a new instance of AbstractRequestDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AbstractRequestDsml( LdapMessageCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * Creates the Request Element and adds RequestID and Controls.
+ *
+ * @param root
+ * the root element
+ * @return
+ * the Request Element of the given name containing
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = root.addElement( getRequestName() );
+
+ // Request ID
+ int requestID = instance.getMessageId();
+ if ( requestID != 0 )
+ {
+ element.addAttribute( "requestID", "" + requestID );
+ }
+
+ // Controls
+ ParserUtils.addControls( element, instance.getControls() );
+
+ return element;
+ }
+
+ /**
+ * Gets the name of the request according to the type of the decorated element.
+ *
+ * @return
+ * the name of the request according to the type of the decorated element.
+ */
+ private String getRequestName()
+ {
+ switch ( instance.getMessageType() )
+ {
+ case LdapConstants.ABANDON_REQUEST:
+ return "abandonRequest";
+ case LdapConstants.ADD_REQUEST:
+ return "addRequest";
+ case LdapConstants.BIND_REQUEST:
+ return "authRequest";
+ case LdapConstants.COMPARE_REQUEST:
+ return "compareRequest";
+ case LdapConstants.DEL_REQUEST:
+ return "delRequest";
+ case LdapConstants.EXTENDED_REQUEST:
+ return "extendedRequest";
+ case LdapConstants.MODIFYDN_REQUEST:
+ return "modDNRequest";
+ case LdapConstants.MODIFY_REQUEST:
+ return "modifyRequest";
+ case LdapConstants.SEARCH_REQUEST:
+ return "searchRequest";
+ default:
+ return "error";
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.dsmlv2.request;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.codec.add.AddRequestCodec;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.QName;
+
+
+/**
+ * DSML Decorator for AddRequest
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddRequestDsml extends AbstractRequestDsml
+{
+ /**
+ * Creates a new instance of AddRequestDsml.
+ */
+ public AddRequestDsml()
+ {
+ super( new AddRequestCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of AddRequestDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AddRequestDsml( AddRequestCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ AddRequestCodec request = ( AddRequestCodec ) instance;
+
+ // DN
+ if ( request.getEntry() != null )
+ {
+ element.addAttribute( "dn", request.getEntry().getDn().getUpName() );
+ }
+
+ // Attributes
+ Entry entry = request.getEntry();
+ if ( entry != null )
+ {
+ for ( EntryAttribute attribute : entry )
+ {
+ Element attributeElement = element.addElement( "attr" );
+ attributeElement.addAttribute( "name", attribute.getId() );
+ // Looping on Values
+ for ( Value<?> value : attribute )
+ {
+ if ( ParserUtils.needsBase64Encoding( value.get() ) )
+ {
+ Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
+ Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
+ attributeElement.getDocument().getRootElement().add( xsdNamespace );
+ attributeElement.getDocument().getRootElement().add( xsiNamespace );
+
+ Element valueElement = attributeElement.addElement( "value" ).addText(
+ ParserUtils.base64Encode( value.get() ) );
+ valueElement
+ .addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY );
+ }
+ else
+ {
+ attributeElement.addElement( "value" ).addText( value.get().toString() );
+ }
+ }
+ }
+ }
+
+ return element;
+ }
+
+
+ /**
+ * Initialize the Entry.
+ */
+ public void initEntry()
+ {
+ ( ( AddRequestCodec ) instance ).initEntry();
+ }
+
+
+ /**
+ * Get the entry with its attributes.
+ *
+ * @return Returns the entry.
+ */
+ public Entry getEntry()
+ {
+ return ( ( AddRequestCodec ) instance ).getEntry();
+ }
+
+
+ /**
+ * Create a new attributeValue
+ *
+ * @param type The attribute's name (called 'type' in the grammar)
+ * @throws NamingException
+ */
+ public void addAttributeType( String type ) throws NamingException
+ {
+ ( ( AddRequestCodec ) instance ).addAttributeType( type );
+ }
+
+
+ /**
+ * Add a new value to the current attribute
+ *
+ * @param value The value to be added
+ */
+ public void addAttributeValue( Object value )
+ {
+ ( ( AddRequestCodec ) instance ).addAttributeValue( value );
+ }
+
+
+ /**
+ * Get the added DN
+ *
+ * @return Returns the entry DN.
+ */
+ public LdapDN getEntryDn()
+ {
+ return ( ( AddRequestCodec ) instance ).getEntryDn();
+ }
+
+
+ /**
+ * Set the added DN.
+ *
+ * @param entry The entry DN to set.
+ */
+ public void setEntryDn( LdapDN entryDn )
+ {
+ ( ( AddRequestCodec ) instance ).setEntryDn( entryDn );
+ }
+
+
+ /**
+ * Sets the entry.
+ *
+ * @param entry
+ * the entry
+ */
+ public void setEntry( Entry entry )
+ {
+ ( ( AddRequestCodec ) instance ).setEntry( entry );
+ }
+
+
+ /**
+ * @return Returns the currentAttribute type.
+ */
+ public String getCurrentAttributeType()
+ {
+ return ( ( AddRequestCodec ) instance ).getCurrentAttributeType();
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.dsmlv2.request;
+
+
+import org.apache.directory.shared.ldap.codec.bind.BindRequestCodec;
+import org.dom4j.Element;
+
+
+/**
+ * DSML Decorator for BindRequest
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AuthRequestDsml extends AbstractRequestDsml
+{
+ /**
+ * Creates a new instance of AuthRequestDsml.
+ */
+ public AuthRequestDsml()
+ {
+ super( new BindRequestCodec() );
+ }
+
+
+ /**
+ * Creates a new instance of AuthRequestDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AuthRequestDsml( BindRequestCodec ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ BindRequestCodec request = ( BindRequestCodec ) instance;
+
+ // AbandonID
+ String name = request.getName().getUpName();
+ if ( ( name != null ) && ( !"".equals( name ) ) )
+ {
+ element.addAttribute( "principal", name );
+ }
+
+ return element;
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2.request;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+
+
+/**
+ * This class represents the Batch Request of a DSML Request
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BatchRequest
+{
+ /**
+ * The requests contained in the Batch Request
+ */
+ private List<LdapMessageCodec> requests;
+
+ /**
+ * The ID of the request
+ */
+ private int requestID;
+
+ /**
+ * This enum represents the different types of processing for a Batch Request
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum Processing
+ {
+ SEQUENTIAL, PARALLEL
+ };
+
+ /**
+ * The type of processing of the Batch Request
+ */
+ private Processing processing;
+
+ /**
+ * This enum represents the different types of on error handling for a BatchRequest
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum OnError
+ {
+ RESUME, EXIT
+ };
+
+ /**
+ * The type of on error handling
+ */
+ private OnError onError;
+
+ /**
+ * This enum represents the different types of response order for a Batch Request
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum ResponseOrder
+ {
+ SEQUENTIAL, UNORDERED
+ };
+
+ /**
+ * The response order
+ */
+ private ResponseOrder responseOrder;
+
+
+ /**
+ * Creates a new instance of BatchRequest.
+ */
+ public BatchRequest()
+ {
+ requests = new ArrayList<LdapMessageCodec>();
+ responseOrder = ResponseOrder.SEQUENTIAL;
+ processing = Processing.SEQUENTIAL;
+ onError = OnError.EXIT;
+ }
+
+
+ /**
+ * Adds a request
+ *
+ * @param request
+ * the resquest to add
+ * @return
+ * true (as per the general contract of the Collection.add method)
+ */
+ public boolean addRequest( LdapMessageCodec request )
+ {
+ return requests.add( request );
+ }
+
+
+ /**
+ * Gets the current request
+ *
+ * @return
+ * the current request
+ */
+ public LdapMessageCodec getCurrentRequest()
+ {
+ return requests.get( requests.size() - 1 );
+ }
+
+
+ /**
+ * Gets the ID of the request
+ *
+ * @return
+ * the ID of the request
+ */
+ public int getRequestID()
+ {
+ return requestID;
+ }
+
+
+ /**
+ * Sets the ID of the request
+ *
+ * @param requestID
+ * the ID to set
+ */
+ public void setRequestID( int requestID )
+ {
+ this.requestID = requestID;
+ }
+
+
+ /**
+ * Gets the processing type of the request
+ *
+ * @return
+ * the processing type of the request
+ */
+ public Processing getProcessing()
+ {
+ return processing;
+ }
+
+
+ /**
+ * Sets the processing type of the request
+ *
+ * @param processing
+ * the processing type to set
+ */
+ public void setProcessing( Processing processing )
+ {
+ this.processing = processing;
+ }
+
+
+ /**
+ * Gets the on error handling type of the request
+ *
+ * @return
+ * the on error handling type of the request
+ */
+ public OnError getOnError()
+ {
+ return onError;
+ }
+
+
+ /**
+ * Sets the on error handling type of the request
+ *
+ * @param onError
+ * the on error handling type to set
+ */
+ public void setOnError( OnError onError )
+ {
+ this.onError = onError;
+ }
+
+
+ /**
+ * Gets the reponse order type of the request
+ *
+ * @return
+ * the reponse order type of the request
+ */
+ public ResponseOrder getResponseOrder()
+ {
+ return responseOrder;
+ }
+
+
+ /**
+ * Sets the reponse order type of the request
+ *
+ * @param responseOrder
+ * the reponse order type to set
+ */
+ public void setResponseOrder( ResponseOrder responseOrder )
+ {
+ this.responseOrder = responseOrder;
+ }
+
+
+ /**
+ * Gets the List of all the requests in the Batch Request
+ *
+ * @return
+ * the List of all the requests in the Batch Request
+ */
+ public List getRequests()
+ {
+ return requests;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( "[" );
+ sb.append( "processing: " + processing );
+ sb.append( " - " );
+ sb.append( "onError: " + onError );
+ sb.append( " - " );
+ sb.append( "responseOrder: " + responseOrder );
+ sb.append( "]" );
+
+ return sb.toString();
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.dsmlv2.request;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.studio.dsmlv2.DsmlDecorator;
+import org.apache.directory.studio.dsmlv2.ParserUtils;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.OnError;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.Processing;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest.ResponseOrder;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+
+/**
+ * This class represents the Batch Request. It can be used to generate an the XML String of a BatchRequest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BatchRequestDsml
+{
+ /** The Requests list */
+ private List<DsmlDecorator> requests;
+
+ /** The ID of the request */
+ private int requestID;
+
+ /** The type of processing of the Batch Request */
+ private Processing processing;
+
+ /** The type of on error handling */
+ private OnError onError;
+
+ /** The response order */
+ private ResponseOrder responseOrder;
+
+
+ /**
+ * Creates a new instance of BatchResponseDsml.
+ */
+ public BatchRequestDsml()
+ {
+ requests = new ArrayList<DsmlDecorator>();
+ responseOrder = ResponseOrder.SEQUENTIAL;
+ processing = Processing.SEQUENTIAL;
+ onError = OnError.EXIT;
+ }
+
+
+ /**
+ * Adds a request to the Batch Request DSML.
+ *
+ * @param request
+ * the request to add
+ * @return
+ * true (as per the general contract of the Collection.add method).
+ */
+ public boolean addRequest( DsmlDecorator request )
+ {
+ return requests.add( request );
+ }
+
+
+ /**
+ * Removes a request from the Batch Request DSML.
+ *
+ * @param request
+ * the request to remove
+ * @return
+ * true if this list contained the specified element.
+ */
+ public boolean removeRequest( DsmlDecorator request )
+ {
+ return requests.remove( request );
+ }
+
+
+ /**
+ * Gets the ID of the request
+ *
+ * @return
+ * the ID of the request
+ */
+ public int getRequestID()
+ {
+ return requestID;
+ }
+
+
+ /**
+ * Sets the ID of the request
+ *
+ * @param requestID
+ * the ID to set
+ */
+ public void setRequestID( int requestID )
+ {
+ this.requestID = requestID;
+ }
+
+
+ /**
+ * Gets the processing type of the request
+ *
+ * @return
+ * the processing type of the request
+ */
+ public Processing getProcessing()
+ {
+ return processing;
+ }
+
+
+ /**
+ * Sets the processing type of the request
+ *
+ * @param processing
+ * the processing type to set
+ */
+ public void setProcessing( Processing processing )
+ {
+ this.processing = processing;
+ }
+
+
+ /**
+ * Gets the on error handling type of the request
+ *
+ * @return
+ * the on error handling type of the request
+ */
+ public OnError getOnError()
+ {
+ return onError;
+ }
+
+
+ /**
+ * Sets the on error handling type of the request
+ *
+ * @param onError
+ * the on error handling type to set
+ */
+ public void setOnError( OnError onError )
+ {
+ this.onError = onError;
+ }
+
+
+ /**
+ * Gets the reponse order type of the request
+ *
+ * @return
+ * the reponse order type of the request
+ */
+ public ResponseOrder getResponseOrder()
+ {
+ return responseOrder;
+ }
+
+
+ /**
+ * Sets the reponse order type of the request
+ *
+ * @param responseOrder
+ * the reponse order type to set
+ */
+ public void setResponseOrder( ResponseOrder responseOrder )
+ {
+ this.responseOrder = responseOrder;
+ }
+
+
+ /**
+ * Converts the Batch Request to its XML representation in the DSMLv2 format.
+ */
+ public String toDsml()
+ {
+ Document document = DocumentHelper.createDocument();
+ Element element = document.addElement( "batchRequest" );
+
+ // RequestID
+ if ( requestID != 0 )
+ {
+ element.addAttribute( "requestID", "" + requestID );
+ }
+
+ // ResponseOrder
+ if ( responseOrder == ResponseOrder.UNORDERED )
+ {
+ element.addAttribute( "responseOrder", "unordered" );
+ }
+
+ // Processing
+ if ( processing == Processing.PARALLEL )
+ {
+ element.addAttribute( "processing", "parallel" );
+ }
+
+ // On Error
+ if ( onError == OnError.RESUME )
+ {
+ element.addAttribute( "onError", "resume" );
+ }
+
+ // Requests
+ for ( DsmlDecorator request : requests )
+ {
+ request.toDsml( element );
+ }
+
+ return ParserUtils.styleDocument( document ).asXML();
+ }
+}