You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 15:53:11 UTC
svn commit: r592023 [5/25] - in
/directory/sandbox/felixk/studio-dsml-parser: ./ META-INF/ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/mai...
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java Mon Nov 5 06:52:22 2007
@@ -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.LdapResponse;
+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 LdapResponse 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ErrorResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ExtendedResponseDsml( LdapMessage 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" );
+ ExtendedResponse extendedResponse = ( ExtendedResponse ) 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ExtendedResponseDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java Mon Nov 5 06:52:22 2007
@@ -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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+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( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResponseLength()
+ */
+ public int getLdapResponseLength()
+ {
+ return ( ( LdapResponse ) instance ).getLdapResponseLength();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#getLdapResult()
+ */
+ public LdapResult getLdapResult()
+ {
+ return ( ( LdapResponse ) instance ).getLdapResult();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.shared.ldap.codec.LdapResponse#setLdapResult(org.apache.directory.shared.ldap.codec.LdapResult)
+ */
+ public void setLdapResult( LdapResult ldapResult )
+ {
+ ( ( LdapResponse ) instance ).setLdapResult( ldapResult );
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResponseDecorator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,113 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.util.LdapURL;
+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 LdapResult result;
+
+ /** The associated LDAP Message */
+ private LdapMessage message;
+
+
+ /**
+ * Creates a new instance of LdapResultDsml.
+ *
+ * @param result
+ * the LdapResult to decorate
+ * @param message
+ * the associated message
+ */
+ public LdapResultDsml( LdapResult result, LdapMessage 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java Mon Nov 5 06:52:22 2007
@@ -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";
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/LdapResultEnum.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponse;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ModDNResponseDsml( LdapMessage 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( ( ( ModifyDNResponse ) instance ).getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModDNResponseDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.modify.ModifyResponse;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public ModifyResponseDsml( LdapMessage 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( ( ( ModifyResponse ) instance ).getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/ModifyResponseDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java Mon Nov 5 06:52:22 2007
@@ -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.LdapResponse;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+
+
+/**
+ * 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 LdapResponse
+{
+ /** The List of contained Search Result Entries */
+ private List<SearchResultEntry> searchResultEntryList;
+
+ /** The List of contained Search Result References */
+ private List<SearchResultReference> searchResultReferenceList;
+
+ /** The Search Result Done object */
+ private SearchResultDone searchResultDone;
+
+
+ /**
+ * Creates a new instance of SearchResponse.
+ */
+ public SearchResponse()
+ {
+ searchResultEntryList = new ArrayList<SearchResultEntry>();
+ searchResultReferenceList = new ArrayList<SearchResultReference>();
+ }
+
+
+ /**
+ * 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( SearchResultEntry searchResultEntry )
+ {
+ return searchResultEntryList.add( searchResultEntry );
+ }
+
+
+ /**
+ * Gets the Current Search Result Entry
+ *
+ * @return
+ * the current Searche Result Entry
+ */
+ public SearchResultEntry 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<SearchResultEntry> 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( SearchResultReference searchResultReference )
+ {
+ return searchResultReferenceList.add( searchResultReference );
+ }
+
+
+ /**
+ * Gets the current Search Result Reference
+ *
+ * @return
+ * the current Search Result Reference
+ */
+ public SearchResultReference 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<SearchResultReference> getSearchResultReferenceList()
+ {
+ return searchResultReferenceList;
+ }
+
+
+ /**
+ * Gets the Search Result Entry
+ *
+ * @return
+ * the Search Result Entry
+ */
+ public SearchResultDone getSearchResultDone()
+ {
+ return searchResultDone;
+ }
+
+
+ /**
+ * Sets the Search Result Entry
+ *
+ * @param searchResultDone
+ * the Search Result Entry to set
+ */
+ public void setSearchResultDone( SearchResultDone searchResultDone )
+ {
+ this.searchResultDone = searchResultDone;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.LdapMessage;
+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;
+
+
+ /**
+ * Creates a new instance of SearchResponseDsml.
+ */
+ public SearchResponseDsml()
+ {
+ super( new LdapMessage() );
+ }
+
+
+ /**
+ * 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResponseDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultDoneDsml( LdapMessage 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( ( ( SearchResultDone ) instance ).getLdapResult(), instance );
+ ldapResultDsml.toDsml( element );
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultDoneDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,121 @@
+/*
+ * 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 javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultEntryDsml( LdapMessage 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" );
+ SearchResultEntry searchResultEntry = ( SearchResultEntry ) instance;
+ element.addAttribute( "dn", searchResultEntry.getObjectName().toString() );
+
+ Attributes attributes = searchResultEntry.getPartialAttributeList();
+ NamingEnumeration ne = attributes.getAll();
+
+ // Looping on Attributes Enumeration
+ while ( ne.hasMoreElements() )
+ {
+ Attribute attribute = ( Attribute ) ne.nextElement();
+
+ Element attributeElement = element.addElement( "attr" );
+ attributeElement.addAttribute( "name", attribute.getID() );
+
+ // Looping on Values Enumeration
+ try
+ {
+ NamingEnumeration ne2 = attribute.getAll();
+
+ while ( ne2.hasMoreElements() )
+ {
+ Object value = ne2.nextElement();
+
+ if ( ParserUtils.needsBase64Encoding( value ) )
+ {
+ 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 ) );
+ valueElement
+ .addAttribute( new QName( "type", xsiNamespace ), ParserUtils.XSD + ":" + ParserUtils.BASE64BINARY );
+ }
+ else
+ {
+ attributeElement.addElement( "value" ).addText( value.toString() );
+ }
+ }
+ }
+ catch ( NamingException e )
+ {
+ }
+ }
+
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultEntryDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java Mon Nov 5 06:52:22 2007
@@ -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 java.util.List;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+import org.apache.directory.shared.ldap.codec.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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public SearchResultReferenceDsml( LdapMessage 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" );
+ SearchResultReference searchResultReference = ( SearchResultReference ) 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/reponse/SearchResultReferenceDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.abandon.AbandonRequest;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AbandonRequestDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ AbandonRequest request = ( AbandonRequest ) instance;
+
+ // AbandonID
+ if ( request.getAbandonedMessageId() != 0 )
+ {
+ element.addAttribute( "abandonID", "" + request.getAbandonedMessageId() );
+ }
+
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbandonRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -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.LdapMessage;
+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( LdapMessage 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";
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AbstractRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.add.AddRequest;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AddRequestDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ AddRequest request = ( AddRequest ) instance;
+
+ // DN
+ if ( request.getEntry() != null )
+ {
+ element.addAttribute( "dn", request.getEntry().toString() );
+ }
+
+ // Attributes
+ Attributes attributes = request.getAttributes();
+ if ( attributes != null )
+ {
+ NamingEnumeration ne = attributes.getAll();
+ while ( ne.hasMoreElements() )
+ {
+ Attribute attribute = ( Attribute ) ne.nextElement();
+ Element attributeElement = element.addElement( "attr" );
+ attributeElement.addAttribute( "name", attribute.getID() );
+
+ // Looping on Values Enumeration
+ try
+ {
+ NamingEnumeration ne2 = attribute.getAll();
+
+ while ( ne2.hasMoreElements() )
+ {
+ Object value = ne2.nextElement();
+
+ if ( ParserUtils.needsBase64Encoding( value ) )
+ {
+ 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 ) );
+ valueElement
+ .addAttribute( new QName( "type", xsiNamespace ), "xsd:" + ParserUtils.BASE64BINARY );
+ }
+ else
+ {
+ attributeElement.addElement( "value" ).addText( value.toString() );
+ }
+ }
+ }
+ catch ( NamingException e )
+ {
+ }
+ }
+ }
+
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AddRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.bind.BindRequest;
+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.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public AuthRequestDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ BindRequest request = ( BindRequest ) instance;
+
+ // AbandonID
+ String name = request.getName().toString();
+ if ( ( name != null ) && ( !"".equals( name ) ) )
+ {
+ element.addAttribute( "principal", name );
+ }
+
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/AuthRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java Mon Nov 5 06:52:22 2007
@@ -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.LdapMessage;
+
+
+/**
+ * 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<LdapMessage> 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<LdapMessage>();
+ 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( LdapMessage request )
+ {
+ return requests.add( request );
+ }
+
+
+ /**
+ * Gets the current request
+ *
+ * @return
+ * the current request
+ */
+ public LdapMessage 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();
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -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();
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/BatchRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/CompareRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/CompareRequestDsml.java?rev=592023&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/CompareRequestDsml.java (added)
+++ directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/CompareRequestDsml.java Mon Nov 5 06:52:22 2007
@@ -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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.compare.CompareRequest;
+import org.dom4j.Element;
+
+/**
+ * DSML Decorator for CompareRequest
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompareRequestDsml extends AbstractRequestDsml
+{
+ /**
+ * Creates a new instance of CompareRequestDsml.
+ *
+ * @param ldapMessage
+ * the message to decorate
+ */
+ public CompareRequestDsml( LdapMessage ldapMessage )
+ {
+ super( ldapMessage );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMessageType()
+ {
+ return instance.getMessageType();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Element toDsml( Element root )
+ {
+ Element element = super.toDsml( root );
+
+ CompareRequest request = ( CompareRequest ) instance;
+
+ // DN
+ if ( request.getEntry() != null )
+ {
+ element.addAttribute( "dn", request.getEntry().toString() );
+ }
+
+ // Assertion
+ Element assertionElement = element.addElement( "assertion");
+ if ( request.getAttributeDesc() != null )
+ {
+ assertionElement.addAttribute( "name", request.getAttributeDesc() );
+ }
+ if ( request.getAssertionValue() != null )
+ {
+ assertionElement.addElement( "value").setText( (String) request.getAssertionValue() );
+ }
+
+ return element;
+ }
+}
Propchange: directory/sandbox/felixk/studio-dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/request/CompareRequestDsml.java
------------------------------------------------------------------------------
svn:eol-style = native