axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: ws-axis/c/src/soap/xsd/constraints Length.cpp Length.hpp
Date Tue, 25 Jan 2005 12:04:52 GMT
dicka       2005/01/25 04:04:52

  Modified:    c/src/soap Makefile.am
               c/src/soap/xsd AnyURI.cpp AnyURI.hpp Base64Binary.cpp
                        Base64Binary.hpp HexBinary.cpp HexBinary.hpp
                        NOTATION.cpp NOTATION.hpp String.cpp String.hpp
                        XSD_QName.cpp XSD_QName.hpp
               c/vc     AxisClientDLL.dsp AxisServerDLL.dsp
  Added:       c/src/soap/xsd/constraints Length.cpp Length.hpp
  Log:
  Adding constraint validation/processing to XSD SOAP objects.  Addition of Length constraint.
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.24      +1 -0      ws-axis/c/src/soap/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Makefile.am,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Makefile.am	24 Jan 2005 17:21:25 -0000	1.23
  +++ Makefile.am	25 Jan 2005 12:04:51 -0000	1.24
  @@ -48,6 +48,7 @@
           xsd/constraints/Pattern.cpp \
           xsd/constraints/MinLength.cpp \
           xsd/constraints/MaxLength.cpp \
  +        xsd/constraints/Length.cpp \
           xsd/constraints/MinInclusive.cpp \
           xsd/constraints/MinExclusive.cpp \
           xsd/constraints/MaxInclusive.cpp \
  
  
  
  1.7       +27 -0     ws-axis/c/src/soap/xsd/AnyURI.cpp
  
  Index: AnyURI.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/AnyURI.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AnyURI.cpp	25 Jan 2005 11:26:38 -0000	1.6
  +++ AnyURI.cpp	25 Jan 2005 12:04:51 -0000	1.7
  @@ -61,6 +61,28 @@
               }
           }
           delete maxLength;
  +
  +        Length* length = getLength();
  +        if (length->isSet())
  +        {
  +            if (strlen(value) != (unsigned int) length->getLength())
  +            {
  +                AxisString exceptionMessage =
  +                "Length of value to be serialized is not the same as Length specified for
this type.  Length = ";
  +                AxisChar* lengthAsString = new AxisChar[10];
  +                sprintf(lengthAsString, "%d", length->getLength());
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ", Length of value = ";
  +                sprintf(lengthAsString, "%d", strlen(value));
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ".";
  +                delete [] lengthAsString;
  +                
  +                throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                    const_cast<AxisChar*>(exceptionMessage.c_str()));
  +            }
  +        }
  +        delete length;
                
   		AxisString valueAsString = value;
   		AxisChar* serializedValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
  @@ -95,6 +117,11 @@
       MaxLength* AnyURI::getMaxLength()
       {
           return new MaxLength();
  +    }
  +
  +    Length* AnyURI::getLength()
  +    {
  +        return new Length();
       }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.5       +7 -0      ws-axis/c/src/soap/xsd/AnyURI.hpp
  
  Index: AnyURI.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/AnyURI.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AnyURI.hpp	21 Jan 2005 15:06:56 -0000	1.4
  +++ AnyURI.hpp	25 Jan 2005 12:04:51 -0000	1.5
  @@ -25,6 +25,7 @@
   #include "IAnySimpleType.hpp"
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -88,6 +89,12 @@
        */
       MaxLength* getMaxLength();
   
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the AnyURI
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
       
   private:
       AxisChar* m_AnyURI;
  
  
  
  1.8       +27 -0     ws-axis/c/src/soap/xsd/Base64Binary.cpp
  
  Index: Base64Binary.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Base64Binary.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Base64Binary.cpp	21 Jan 2005 15:17:19 -0000	1.7
  +++ Base64Binary.cpp	25 Jan 2005 12:04:52 -0000	1.8
  @@ -71,6 +71,28 @@
               }
           }
           delete maxLength;
  +
  +        Length* length= getLength();
  +        if (length->isSet())
  +        {
  +            if (value->__size != length->getLength())
  +            {
  +                AxisString exceptionMessage =
  +                "Length of value to be serialized is not the same as Length specified for
this type.  Length = ";
  +                AxisChar* lengthAsString = new AxisChar[10];
  +                sprintf(lengthAsString, "%d", length->getLength());
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ", Length of value = ";
  +                sprintf(lengthAsString, "%d", value->__size);
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ".";
  +                delete [] lengthAsString;
  +                
  +                throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                    const_cast<AxisChar*>(exceptionMessage.c_str()));
  +            }
  +        }
  +        delete length;
        
   	    int len = apr_base64_encode_len (value->__size);	    
   	    AxisChar* serializedValue = new AxisChar[len + 1];
  @@ -109,6 +131,11 @@
       MaxLength* Base64Binary::getMaxLength()
       {
           return new MaxLength();
  +    }
  +
  +    Length* Base64Binary::getLength()
  +    {
  +        return new Length();
       }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.6       +8 -0      ws-axis/c/src/soap/xsd/Base64Binary.hpp
  
  Index: Base64Binary.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Base64Binary.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Base64Binary.hpp	21 Jan 2005 15:06:56 -0000	1.5
  +++ Base64Binary.hpp	25 Jan 2005 12:04:52 -0000	1.6
  @@ -27,6 +27,7 @@
   #include <axis/AxisUserAPI.hpp>
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -88,6 +89,13 @@
        * @return An unset MaxLength object
        */
       MaxLength* getMaxLength();
  +
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the Base64Binary
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
   
   private:
   	xsd__base64Binary* m_Base64Binary;
  
  
  
  1.10      +27 -0     ws-axis/c/src/soap/xsd/HexBinary.cpp
  
  Index: HexBinary.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/HexBinary.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HexBinary.cpp	21 Jan 2005 15:17:19 -0000	1.9
  +++ HexBinary.cpp	25 Jan 2005 12:04:52 -0000	1.10
  @@ -70,6 +70,28 @@
               }
           }
           delete maxLength;
  +
  +        Length* length= getLength();
  +        if (length->isSet())
  +        {
  +            if (value->__size != length->getLength())
  +            {
  +                AxisString exceptionMessage =
  +                "Length of value to be serialized is not the same as Length specified for
this type.  Length = ";
  +                AxisChar* lengthAsString = new AxisChar[10];
  +                sprintf(lengthAsString, "%d", length->getLength());
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ", Length of value = ";
  +                sprintf(lengthAsString, "%d", value->__size);
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ".";
  +                delete [] lengthAsString;
  +                
  +                throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                    const_cast<AxisChar*>(exceptionMessage.c_str()));
  +            }
  +        }
  +        delete length;
        
   		char* serializedValue = new char[value->__size * 2 + 1];
   	    Hex_Encode (serializedValue, value->__ptr, value->__size);
  @@ -108,6 +130,11 @@
       MaxLength* HexBinary::getMaxLength()
       {
           return new MaxLength();
  +    }
  +
  +    Length* HexBinary::getLength()
  +    {
  +        return new Length();
       }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.6       +8 -0      ws-axis/c/src/soap/xsd/HexBinary.hpp
  
  Index: HexBinary.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/HexBinary.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HexBinary.hpp	21 Jan 2005 15:06:56 -0000	1.5
  +++ HexBinary.hpp	25 Jan 2005 12:04:52 -0000	1.6
  @@ -27,6 +27,7 @@
   #include "../HexCoder.h"
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -88,6 +89,13 @@
        * @return An unset MaxLength object
        */
       MaxLength* getMaxLength();
  +
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the HexBinary
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
   
   private:
   	xsd__hexBinary* m_HexBinary;
  
  
  
  1.7       +27 -0     ws-axis/c/src/soap/xsd/NOTATION.cpp
  
  Index: NOTATION.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/NOTATION.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NOTATION.cpp	25 Jan 2005 11:26:38 -0000	1.6
  +++ NOTATION.cpp	25 Jan 2005 12:04:52 -0000	1.7
  @@ -61,6 +61,28 @@
           }
       }
       delete maxLength;
  +
  +    Length* length = getLength();
  +    if (length->isSet())
  +    {
  +        if (strlen(value) != (unsigned int) length->getLength())
  +        {
  +            AxisString exceptionMessage =
  +            "Length of value to be serialized is not the same as Length specified for this
type.  Length = ";
  +            AxisChar* lengthAsString = new AxisChar[10];
  +            sprintf(lengthAsString, "%d", length->getLength());
  +            exceptionMessage += lengthAsString;
  +            exceptionMessage += ", Length of value = ";
  +            sprintf(lengthAsString, "%d", strlen(value));
  +            exceptionMessage += lengthAsString;
  +            exceptionMessage += ".";
  +            delete [] lengthAsString;
  +            
  +            throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                const_cast<AxisChar*>(exceptionMessage.c_str()));
  +        }
  +    }
  +    delete length;
       
   	AxisString valueAsString = value;
   	AxisChar* serializedValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
  @@ -94,6 +116,11 @@
   MaxLength* NOTATION::getMaxLength()
   {
       return new MaxLength();
  +}
  +
  +Length* NOTATION::getLength()
  +{
  +    return new Length();
   }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.5       +7 -0      ws-axis/c/src/soap/xsd/NOTATION.hpp
  
  Index: NOTATION.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/NOTATION.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NOTATION.hpp	21 Jan 2005 15:06:56 -0000	1.4
  +++ NOTATION.hpp	25 Jan 2005 12:04:52 -0000	1.5
  @@ -25,6 +25,7 @@
   #include "IAnySimpleType.hpp"
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -88,6 +89,12 @@
        */
       MaxLength* getMaxLength();
   
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the NOTATION
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
   
   private:
       AxisChar* m_NOTATION;
  
  
  
  1.7       +27 -0     ws-axis/c/src/soap/xsd/String.cpp
  
  Index: String.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/String.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- String.cpp	25 Jan 2005 11:26:38 -0000	1.6
  +++ String.cpp	25 Jan 2005 12:04:52 -0000	1.7
  @@ -61,6 +61,28 @@
           }
       }
       delete maxLength;
  +
  +    Length* length = getLength();
  +    if (length->isSet())
  +    {
  +        if (strlen(value) != (unsigned int) length->getLength())
  +        {
  +            AxisString exceptionMessage =
  +            "Length of value to be serialized is not the same as Length specified for this
type.  Length = ";
  +            AxisChar* lengthAsString = new AxisChar[10];
  +            sprintf(lengthAsString, "%d", length->getLength());
  +            exceptionMessage += lengthAsString;
  +            exceptionMessage += ", Length of value = ";
  +            sprintf(lengthAsString, "%d", strlen(value));
  +            exceptionMessage += lengthAsString;
  +            exceptionMessage += ".";
  +            delete [] lengthAsString;
  +            
  +            throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                const_cast<AxisChar*>(exceptionMessage.c_str()));
  +        }
  +    }
  +    delete length;
    
   	AxisString valueAsString = value;
   	AxisChar* serializedValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
  @@ -89,6 +111,11 @@
   MaxLength* String::getMaxLength()
   {
       return new MaxLength();
  +}
  +
  +Length* String::getLength()
  +{
  +    return new Length();
   }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.5       +8 -0      ws-axis/c/src/soap/xsd/String.hpp
  
  Index: String.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/String.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- String.hpp	21 Jan 2005 15:06:56 -0000	1.4
  +++ String.hpp	25 Jan 2005 12:04:52 -0000	1.5
  @@ -25,6 +25,7 @@
   #include "IAnySimpleType.hpp"
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -81,6 +82,13 @@
        * @return An unset MaxLength object
        */
       MaxLength* getMaxLength();
  +
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the String
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
   
   private:
       AxisChar* m_String;
  
  
  
  1.7       +27 -0     ws-axis/c/src/soap/xsd/XSD_QName.cpp
  
  Index: XSD_QName.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/XSD_QName.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSD_QName.cpp	25 Jan 2005 11:26:38 -0000	1.6
  +++ XSD_QName.cpp	25 Jan 2005 12:04:52 -0000	1.7
  @@ -61,6 +61,28 @@
               }
           }
           delete maxLength;
  +
  +        Length* length = getLength();
  +        if (length->isSet())
  +        {
  +            if (strlen(value) != (unsigned int) length->getLength())
  +            {
  +                AxisString exceptionMessage =
  +                "Length of value to be serialized is not the same as Length specified for
this type.  Length = ";
  +                AxisChar* lengthAsString = new AxisChar[10];
  +                sprintf(lengthAsString, "%d", length->getLength());
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ", Length of value = ";
  +                sprintf(lengthAsString, "%d", strlen(value));
  +                exceptionMessage += lengthAsString;
  +                exceptionMessage += ".";
  +                delete [] lengthAsString;
  +                
  +                throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
  +                    const_cast<AxisChar*>(exceptionMessage.c_str()));
  +            }
  +        }
  +        delete length;
       
   		AxisString valueAsString = value;
   		AxisChar* serializedValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
  @@ -90,5 +112,10 @@
       {
           return new MaxLength();
       }   
  +
  +    Length* XSD_QName::getLength()
  +    {
  +        return new Length();
  +    }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.5       +7 -0      ws-axis/c/src/soap/xsd/XSD_QName.hpp
  
  Index: XSD_QName.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/xsd/XSD_QName.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XSD_QName.hpp	21 Jan 2005 15:06:56 -0000	1.4
  +++ XSD_QName.hpp	25 Jan 2005 12:04:52 -0000	1.5
  @@ -25,6 +25,7 @@
   #include "IAnySimpleType.hpp"
   #include "constraints/MinLength.hpp"
   #include "constraints/MaxLength.hpp"
  +#include "constraints/Length.hpp"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -88,6 +89,12 @@
        */
       MaxLength* getMaxLength();
   
  +    /**
  +     * Creates a Length object, used to allocate storage.  By default the QName
  +     * object does not have this specified, so this is an unset Length object.
  +     * @return An unset Length object
  +     */
  +    Length* getLength();
   
   private:
       AxisChar* m_QName;
  
  
  
  1.34      +4 -0      ws-axis/c/vc/AxisClientDLL.dsp
  
  Index: AxisClientDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisClientDLL.dsp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AxisClientDLL.dsp	24 Jan 2005 17:21:26 -0000	1.33
  +++ AxisClientDLL.dsp	25 Jan 2005 12:04:52 -0000	1.34
  @@ -290,6 +290,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\constraints\Length.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\soap\xsd\Long.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.33      +4 -0      ws-axis/c/vc/AxisServerDLL.dsp
  
  Index: AxisServerDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisServerDLL.dsp,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- AxisServerDLL.dsp	24 Jan 2005 17:21:26 -0000	1.32
  +++ AxisServerDLL.dsp	25 Jan 2005 12:04:52 -0000	1.33
  @@ -286,6 +286,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\constraints\Length.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\soap\xsd\Long.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/constraints/Length.cpp
  
  Index: Length.cpp
  ===================================================================
  #include "Length.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
      Length::Length():m_Length(0)
      {
          m_isSet = false;
      }
  
      Length::Length(int length)
      {
          m_Length = length;
          m_isSet = true;
      }
  
      int Length::getLength()
      {
          return m_Length;
      }
      
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/constraints/Length.hpp
  
  Index: Length.hpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed 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.
   */
   
   /*
    * @file Length.hpp
    */
    
  #if !defined(_LENGTH_HPP____OF_AXIS_INCLUDED_)
  #define _LENGTH_HPP____OF_AXIS_INCLUDED_
  
  #include "IConstrainingFacet.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  /**
   *   @class Length
   *
   *   @author Adrian Dick (adrian.dick@uk.ibm.com)
   *
   */
  class Length : public IConstrainingFacet {
  
  public:
  
      Length();
      
      Length(int maxLength);
  
      int getLength();
      
  private:
      int m_Length;
  
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif
  
  
  

Mime
View raw message