You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ro...@apache.org on 2005/01/12 14:50:30 UTC

cvs commit: ws-axis/c/src/soap Namespace.cpp Namespace.h Attribute.cpp HeaderBlock.cpp HeaderBlock.h

roshan      2005/01/12 05:50:30

  Modified:    c/include/axis IHeaderBlock.hpp
               c/src/soap Attribute.cpp HeaderBlock.cpp HeaderBlock.h
  Added:       c/include/axis INamespace.hpp
               c/src/soap Namespace.cpp Namespace.h
  Log:
  fixes for JIRA issues 370, 372. Added the new class Namespace for dealing with namespace declartions
  
  Revision  Changes    Path
  1.6       +6 -2      ws-axis/c/include/axis/IHeaderBlock.hpp
  
  Index: IHeaderBlock.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/IHeaderBlock.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IHeaderBlock.hpp	7 Jan 2005 12:05:40 -0000	1.5
  +++ IHeaderBlock.hpp	12 Jan 2005 13:50:30 -0000	1.6
  @@ -20,6 +20,7 @@
   #include "BasicNode.hpp"
   #include "SoapEnvVersions.hpp"
   #include <axis/IAttribute.hpp>
  +#include <axis/INamespace.hpp>
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -52,7 +53,10 @@
         * namespace declartion Attribute. 
         * @return AXIS_SUCCESS to indicate successfull operation. 
         */ 
  -    virtual int addNamespaceDecl(IAttribute *pAttribute)=0;
  +	/* TO DO: We need to remove this completely
  +	*
  +	virtual int addNamespaceDecl(INamespace *pAttribute)=0;
  +	*/
   
       /** 
         * Creates a Attribute and adds it to this Header Block as a namespace. 
  @@ -62,7 +66,7 @@
         * 
         * @return A pointer to the created Attribute will be returned. 
         */ 
  -    virtual IAttribute* createNamespaceDecl(const AxisChar *prefix, 
  +    virtual INamespace* createNamespaceDecl(const AxisChar *prefix, 
               const AxisChar *uri)=0; 
   
       virtual BasicNode* getFirstChild() =0;
  
  
  
  1.1                  ws-axis/c/include/axis/INamespace.hpp
  
  Index: INamespace.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 INamespace.h
   *
   *
   */
  
  /**
   *   @class INamespace
   *   @brief interface for the Namespace.
   *
   *   @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com, roshan_444@yahoo.com)
   *
   */
  
  #if !defined(AFX_INAMESPACE_H__A4213FD6_AA6B_41BF_A72E_735167A02C69__INCLUDED_)
  #define AFX_INAMESPACE_H__A4213FD6_AA6B_41BF_A72E_735167A02C69__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  AXIS_CPP_NAMESPACE_START
  
  class INamespace  
  {
  public:
  	virtual const AxisChar* getPrefix()=0;
  	virtual const AxisChar* getURI()=0;
  	virtual void setURI(const AxisChar* achURI)=0;
  	virtual void setPrefix(const AxisChar* achPrefix)=0;
  	virtual ~INamespace() {};
  
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif // !defined(AFX_INAMESPACE_H__A4213FD6_AA6B_41BF_A72E_735167A02C69__INCLUDED_)
  
  
  
  1.29      +8 -2      ws-axis/c/src/soap/Attribute.cpp
  
  Index: Attribute.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Attribute.cpp,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Attribute.cpp	4 Nov 2004 14:42:21 -0000	1.28
  +++ Attribute.cpp	12 Jan 2005 13:50:30 -0000	1.29
  @@ -154,13 +154,19 @@
           pSZ.serialize(" ", NULL);
   
           /*
  -         * Following code figures out the prefix to be serialized and 
  -         * serialize it.
  +         * User has provided the prefix. So we just have to serialilze. We will
  +		 *  not worry to declare the namespace at all. Because it is the users
  +		 *  responsibiltiy to add his/her namespace declaration seperately.
            */
           if(!m_prefix.empty())
           {            
               pSZ.serialize(m_prefix.c_str(), ":", NULL);
           }
  +		/*
  +         * User hasn't provided the prefix. So we have to do the following.
  +		 *  - get the prefix from the Serializer
  +		 *  - if this is a new namespace, then also declare the namespace.
  +         */
           else if (!m_uri.empty())
           {
               bool blnIsNewNamespace = false;
  
  
  
  1.44      +21 -14    ws-axis/c/src/soap/HeaderBlock.cpp
  
  Index: HeaderBlock.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.cpp,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- HeaderBlock.cpp	6 Jan 2005 05:21:52 -0000	1.43
  +++ HeaderBlock.cpp	12 Jan 2005 13:50:30 -0000	1.44
  @@ -58,6 +58,7 @@
   #include <axis/BasicNode.hpp>
   #include "ComplexElement.h"
   #include "CharacterElement.h"
  +#include "Namespace.h"
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -95,13 +96,16 @@
           this->m_attributes.push_back( (*itCurrAttribute)->clone() );
           itCurrAttribute++;        
       }
  -    
  -    list<Attribute*>::const_iterator itCurrNamespace= rCopy.m_namespaceDecls.begin();
  +
  +	/* TO DO: check whether we have to do this 
  +	*
  +	list<Namespace*>::const_iterator itCurrNamespace= rCopy.m_namespaceDecls.begin();
       while(itCurrNamespace != rCopy.m_namespaceDecls.end())
       {        
           this->m_namespaceDecls.push_back( (*itCurrNamespace)->clone() );
           itCurrNamespace++;        
       }
  +	*/
   }
   
   IHeaderBlock* HeaderBlock::clone()
  @@ -125,7 +129,7 @@
       /*
        *Clear the Namespaces
        */
  -    list<Attribute*>::iterator itCurrNamespace= m_namespaceDecls.begin();
  +    list<Namespace*>::iterator itCurrNamespace= m_namespaceDecls.begin();
       while(itCurrNamespace != m_namespaceDecls.end())
       {        
           delete (*itCurrNamespace);
  @@ -240,7 +244,7 @@
               break;
           }
   
  -        iStatus= serializeNamespaceDecl(pSZ);
  +        iStatus= serializeNamespaceDecl(pSZ, lstTmpNameSpaceStack);
           if(iStatus==AXIS_FAIL)
           {
               break;
  @@ -359,20 +363,22 @@
       return AXIS_SUCCESS;
   }
   
  -IAttribute* HeaderBlock::createNamespaceDecl(const AxisChar *prefix,
  +INamespace* HeaderBlock::createNamespaceDecl(const AxisChar *prefix,
           const AxisChar *uri) 
   {
  -    Attribute* pAttribute = new Attribute(prefix, "xmlns", uri);
  -    m_namespaceDecls.push_back(pAttribute);
  +    Namespace* pNamespace = new Namespace(prefix, uri);
  +    m_namespaceDecls.push_back(pNamespace);
   
  -    return (IAttribute*)pAttribute; 
  +    return (INamespace*)pNamespace; 
   }
   
  -int HeaderBlock::addNamespaceDecl(IAttribute *pAttribute)
  +/* TO DO: We need to remove this completely
  +*
  +int HeaderBlock::addNamespaceDecl(INamespace *pNamespace)
   {
  -    if (pAttribute)
  +    if (pNamespace)
       {
  -        m_namespaceDecls.push_back((Attribute*)pAttribute);
  +        m_namespaceDecls.push_back((Namespace*)pNamespace);
           return AXIS_SUCCESS;
       }
       else
  @@ -380,14 +386,15 @@
           return AXIS_FAIL;
       }
   }
  +*/
   
  -int HeaderBlock::serializeNamespaceDecl(SoapSerializer &pSZ)
  +int HeaderBlock::serializeNamespaceDecl(SoapSerializer &pSZ, std::list<AxisChar*>& lstTmpNameSpaceStack)
   {
  -    list<Attribute*>::iterator itCurrNamespaceDecl= m_namespaceDecls.begin();
  +    list<Namespace*>::iterator itCurrNamespaceDecl= m_namespaceDecls.begin();
   
       while(itCurrNamespaceDecl != m_namespaceDecls.end())
       {        
  -        (*itCurrNamespaceDecl)->serialize(pSZ);
  +        (*itCurrNamespaceDecl)->serialize(pSZ, lstTmpNameSpaceStack);
           itCurrNamespaceDecl++;        
       }    
   
  
  
  
  1.24      +10 -5     ws-axis/c/src/soap/HeaderBlock.h
  
  Index: HeaderBlock.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.h,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- HeaderBlock.h	6 Jan 2005 05:21:52 -0000	1.23
  +++ HeaderBlock.h	12 Jan 2005 13:50:30 -0000	1.24
  @@ -26,6 +26,7 @@
   using namespace std;
   class BasicNode;
   class Attribute;
  +class Namespace;
   
   
   /*
  @@ -71,7 +72,8 @@
       /**
         * Serializes the namespace decl.
         */
  -    int serializeNamespaceDecl(SoapSerializer& pSZ);
  +    int serializeNamespaceDecl(SoapSerializer& pSZ,
  +			std::list<AxisChar*>& lstTmpNameSpaceStack);
   
       int serializeChildren(SoapSerializer& pSZ, 
           std::list<AxisChar*>& lstTmpNameSpaceStack);
  @@ -89,8 +91,8 @@
       AxisString m_localname;
       AxisString m_sPrefix;
       AxisString m_uri;
  -    std::list<Attribute*> m_attributes;
  -    std::list<Attribute*> m_namespaceDecls;
  +    std::list<Attribute*> m_attributes;    
  +	std::list<Namespace*> m_namespaceDecls;	
   
   public:	
   
  @@ -102,7 +104,7 @@
         * 
         * @return A pointer to the created Attribute will be returned. 
         */
  -    IAttribute* createNamespaceDecl(const AxisChar *prefix, 
  +    INamespace* createNamespaceDecl(const AxisChar *prefix, 
               const AxisChar *uri); 
   
       BasicNode* getFirstChild();
  @@ -350,7 +352,10 @@
         * @return AXIS_SUCCESS to indicate successfull operation. AXIS_FAIL to
         *  to indicate unsuccessfull operation.
         */
  -    int addNamespaceDecl(IAttribute *pAttribute);
  +	/* TO DO: We need to remove this completely
  +	*
  +	int addNamespaceDecl(INamespace *pAttribute);
  +	*/
   
   	/**
         * The Constructor.
  
  
  
  1.1                  ws-axis/c/src/soap/Namespace.cpp
  
  Index: Namespace.cpp
  ===================================================================
  /*
   *   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.
   */
  
  /**
   *  @author Roshan Weerasuriya (roshan@opensource.lk, roshan@jkcsworld.com, roshan_444@yahoo.com)
   */
  
  #include "Namespace.h"
  #include "SoapSerializer.h"
  
  AXIS_CPP_NAMESPACE_START
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  
  Namespace::Namespace()
  {
  
  }
  
  Namespace::~Namespace()
  {
  
  }
  
  Namespace::Namespace(const AxisChar* achPrefix, const AxisChar* achURI)
  {
  	m_asPrefix = achPrefix;
  	m_asURI = achURI;
  }
  
  void Namespace::setPrefix(const AxisChar* achPrefix)
  {
  	m_asPrefix = achPrefix;
  }
  
  void Namespace::setURI(const AxisChar* achURI)
  {
  	m_asURI = achURI;
  }
  
  const AxisChar* Namespace::getURI()
  {
  	return m_asURI.c_str();
  }
  
  const AxisChar* Namespace::getPrefix()
  {
  	return m_asPrefix.c_str();
  }
  
  int Namespace::serialize(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack)
  {
  	/*Adding the new namespace to the Serializer*/
  	pSZ.addNamespaceToNamespaceList(m_asURI.c_str(), m_asPrefix.c_str());
  	/*Adding the namespace to the temporary stack, so that it will be removed
  	*  at the end of the logical block. The logical block could be a HeaderBlock,
  	*  a Soap Method etc.
  	*/
  	lstTmpNameSpaceStack.push_back((AxisChar*)m_asURI.c_str());
  
  	pSZ.serialize(" xmlns:", m_asPrefix.c_str(), "=\"", m_asURI.c_str(), "\"", NULL);
  
  	return AXIS_SUCCESS;
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  1.1                  ws-axis/c/src/soap/Namespace.h
  
  Index: Namespace.h
  ===================================================================
  /*
   *   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.
   */
  
  /**
   *  @class Namespace
   *  @brief interface for the Namespace class.
   *
   *
   *
   *  @author Roshan Weerasuriya (roshan@opensource.lk, roshan@jkcsworld.com, roshan_444@yahoo.com)
   */
  
  #if !defined(AFX_NAMESPACE_H__9B3E8218_FB18_4AE0_B88E_899B0A01549D__INCLUDED_)
  #define AFX_NAMESPACE_H__9B3E8218_FB18_4AE0_B88E_899B0A01549D__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include <axis/AxisUserAPI.hpp>
  #include <axis/INamespace.hpp>
  #include <string>
  #include <list>
  
  AXIS_CPP_NAMESPACE_START
  using namespace std;
  
  class SoapSerializer;
  
  class Namespace : public INamespace
  {
  public:
  	int serialize(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack);
  	const AxisChar* getPrefix();
  	const AxisChar* getURI();
  	void setURI(const AxisChar* achURI);
  	void setPrefix(const AxisChar* achPrefix);
  	Namespace(const AxisChar* achPrefix, const AxisChar* achURI);
  	Namespace();
  	virtual ~Namespace();
  
  private:
  	AxisString m_asPrefix;
  	AxisString m_asURI;
  
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif // !defined(AFX_NAMESPACE_H__9B3E8218_FB18_4AE0_B88E_899B0A01549D__INCLUDED_)