susantha    2003/08/13 06:31:42

  Modified:    c/src/wsdd WSDDTransport.h WSDDTransport.cpp WSDDService.h
                        WSDDService.cpp WSDDHandler.h WSDDHandler.cpp
                        WSDDDocument.h WSDDDocument.cpp WSDDDeployment.h
                        WSDDDeployment.cpp
  Log:
  After making code base thread safe. Also changed Module writing API accordingly. 
WSDD module too improved.
  
  Revision  Changes    Path
  1.2       +5 -6      xml-axis/c/src/wsdd/WSDDTransport.h
  
  Index: WSDDTransport.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDTransport.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSDDTransport.h   25 Jun 2003 05:36:18 -0000      1.1
  +++ WSDDTransport.h   13 Aug 2003 13:31:42 -0000      1.2
  @@ -78,15 +78,14 @@
   class WSDDTransport  
   {
   public:
  -     void SetRequestFlowHandlers(AXIS_PROTOCOL_TYPE protocolType, WSDDHandlerList * 
TrReqHList);
  -     void SetResponseFlowHandlers(AXIS_PROTOCOL_TYPE protocolType, WSDDHandlerList 
* TrResHList);
  -     WSDDHandlerList* GetResponseFlowHandlers(AXIS_PROTOCOL_TYPE Protocol);
  -     WSDDHandlerList* GetRequestFlowHandlers(AXIS_PROTOCOL_TYPE Protocol);
  +     void AddHandler(bool bRequestFlow, AXIS_PROTOCOL_TYPE protocol, WSDDHandler* 
pHandler);
  +     const WSDDHandlerList* GetResponseFlowHandlers(AXIS_PROTOCOL_TYPE Protocol);
  +     const WSDDHandlerList* GetRequestFlowHandlers(AXIS_PROTOCOL_TYPE Protocol);
        WSDDTransport();
        virtual ~WSDDTransport();
   private:
  -     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList*> * m_RequestHandlers;
  -     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList*> * m_ResponseHandlers;
  +     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList>* m_RequestHandlers;
  +     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList>* m_ResponseHandlers;
   };
   
   #endif // 
!defined(AFX_WSDDTRANSPORT_H__A7F3A046_7764_4EAB_8867_B26A18F1A931__INCLUDED_)
  
  
  
  1.2       +28 -32    xml-axis/c/src/wsdd/WSDDTransport.cpp
  
  Index: WSDDTransport.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDTransport.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSDDTransport.cpp 25 Jun 2003 05:46:08 -0000      1.1
  +++ WSDDTransport.cpp 13 Aug 2003 13:31:42 -0000      1.2
  @@ -73,68 +73,64 @@
   
   WSDDTransport::WSDDTransport()
   {
  -     m_RequestHandlers = new map<AXIS_PROTOCOL_TYPE, WSDDHandlerList*>;
  -     m_ResponseHandlers = new map<AXIS_PROTOCOL_TYPE, WSDDHandlerList*>;
  +     m_RequestHandlers = NULL;
  +     m_ResponseHandlers = NULL;
   }
   
   WSDDTransport::~WSDDTransport()
   {
  -     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList*>::iterator iter;
  +     map<AXIS_PROTOCOL_TYPE, WSDDHandlerList>::iterator iter;
        WSDDHandlerList * hl = NULL;
        WSDDHandlerList::iterator iter2;
        if(m_RequestHandlers)
        {
  -             for(iter=m_RequestHandlers->begin()
  -                             ;iter!=m_RequestHandlers->end();iter++)
  +             for(iter = m_RequestHandlers->begin(); iter != 
m_RequestHandlers->end(); iter++)
                {
  -                     hl = iter->second;
  -                     if(hl)
  +                     for(iter2 = iter->second.begin(); iter2 != iter->second.end(); 
iter2++)
                        {
  -                             for(iter2=hl->begin();iter2!=hl->end();iter2++)
  -                             {
  -                                     delete (*iter2);
  -                             }
  -                             delete hl;
  +                             delete (*iter2);
                        }
                }
        }
   
        if(m_ResponseHandlers)
        {
  -             for(iter=m_ResponseHandlers->begin()
  -                             ;iter!=m_ResponseHandlers->end();iter++)
  +             for(iter = m_ResponseHandlers->begin(); iter != 
m_ResponseHandlers->end(); iter++)
                {
  -                     hl = iter->second;
  -                     if(hl)
  +                     for(iter2 = iter->second.begin(); iter2 != 
iter->second.end();iter2++)
                        {
  -                             for(iter2=hl->begin();iter2!=hl->end();iter2++)
  -                             {
  -                                     delete (*iter2);
  -                             }
  -                             delete hl;
  +                             delete (*iter2);
                        }
                }
        }
   
   }
   
  -void WSDDTransport::SetRequestFlowHandlers(AXIS_PROTOCOL_TYPE protocolType, 
WSDDHandlerList * TrReqHList)
  +const WSDDHandlerList* WSDDTransport::GetRequestFlowHandlers(AXIS_PROTOCOL_TYPE 
Protocol)
   {
  -     (*m_RequestHandlers)[protocolType] = TrReqHList;
  +     if (m_RequestHandlers && m_RequestHandlers->find(Protocol) != 
m_RequestHandlers->end())
  +             return &(*m_RequestHandlers)[Protocol];
  +     return NULL;
   }
   
  -WSDDHandlerList* WSDDTransport::GetRequestFlowHandlers(AXIS_PROTOCOL_TYPE Protocol)
  -{
  -     return (*m_RequestHandlers)[Protocol];
  -}
   
  -void WSDDTransport::SetResponseFlowHandlers(AXIS_PROTOCOL_TYPE protocolType, 
WSDDHandlerList * TrResHList)
  +const WSDDHandlerList* WSDDTransport::GetResponseFlowHandlers(AXIS_PROTOCOL_TYPE 
Protocol)
   {
  -     (*m_ResponseHandlers)[protocolType] = TrResHList;
  +     if (m_ResponseHandlers && m_ResponseHandlers->find(Protocol) != 
m_ResponseHandlers->end())
  +             return &(*m_ResponseHandlers)[Protocol];
  +     return NULL;
   }
   
  -
  -WSDDHandlerList* WSDDTransport::GetResponseFlowHandlers(AXIS_PROTOCOL_TYPE Protocol)
  +void WSDDTransport::AddHandler(bool bRequestFlow, AXIS_PROTOCOL_TYPE protocol, 
WSDDHandler* pHandler)
   {
  -     return (*m_ResponseHandlers)[Protocol];
  +     if (bRequestFlow)
  +     {
  +             if (!m_RequestHandlers) m_RequestHandlers = new 
map<AXIS_PROTOCOL_TYPE, WSDDHandlerList>;
  +             (*m_RequestHandlers)[protocol].push_back(pHandler);
  +     }
  +     else
  +     {
  +             if (!m_ResponseHandlers) m_ResponseHandlers = new 
map<AXIS_PROTOCOL_TYPE, WSDDHandlerList>;
  +             (*m_ResponseHandlers)[protocol].push_back(pHandler);
  +     }
   }
  
  
  
  1.3       +14 -18    xml-axis/c/src/wsdd/WSDDService.h
  
  Index: WSDDService.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDService.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSDDService.h     8 Jul 2003 12:22:52 -0000       1.2
  +++ WSDDService.h     13 Aug 2003 13:31:42 -0000      1.3
  @@ -82,29 +82,25 @@
   class WSDDService : public WSDDHandler 
   {
   public:
  -     void SetServiceName(string& sServiceName);
  -     string& GetServiceName();
  -     bool IsAllowedMethod(string& sServiceName);
  -     void SetAllowedMethod(string& sMethodName);
  -     WSDDHandlerList* GetResponseFlowHandlers();
  -     void SetRequestFlowHandlers(WSDDHandlerList * reqFlowHList);
  -     void SetResponseFlowHandlers(WSDDHandlerList * resFlowHList);
  -
  -     WSDDHandlerList* GetRequestFlowHandlers();
  -  void SetAllowedRoles(string& sRole);
  -  list<string> GetAllowedRoles();
  -  void SetIsServiceAllowed(int m_IsServiceAllowed);
  -     int GetIsServiceAllowed();
  -
  +     void SetServiceName(const string& sServiceName);
  +     void SetProvider(const string& sProvider);
  +     const string& GetServiceName();
  +     bool IsAllowedMethod(const string& sMethodName) const;
  +     void AddAllowedMethod(const string& sMethodName);
  +     const WSDDHandlerList* GetResponseFlowHandlers() const;
  +     void AddHandler(bool bRequestFlow, WSDDHandler* pHandler);
  +     const WSDDHandlerList* GetRequestFlowHandlers() const;
  +     void AddAllowedRole(const string& sRole);
  +     const list<string>& GetAllowedRoles();
        WSDDService();
        virtual ~WSDDService();
  +
   private:
        string m_sProvider;
        list<string> m_AllowedMethods;
  -     WSDDHandlerList * m_RequestHandlers;
  -     WSDDHandlerList * m_ResponseHandlers;
  -  list<string> m_AllowedRoles;
  -  int m_IsServiceAllowed;
  +     WSDDHandlerList* m_RequestHandlers;
  +     WSDDHandlerList* m_ResponseHandlers;
  +     list<string> m_AllowedRoles;
   };
   
   typedef map<string, WSDDService*> WSDDServiceMap;
  
  
  
  1.4       +27 -32    xml-axis/c/src/wsdd/WSDDService.cpp
  
  Index: WSDDService.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDService.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSDDService.cpp   4 Aug 2003 06:54:21 -0000       1.3
  +++ WSDDService.cpp   13 Aug 2003 13:31:42 -0000      1.4
  @@ -101,78 +101,73 @@
                        delete (*iter);
                }
        }
  -
  -
   }
   
  -void WSDDService::SetServiceName(string& sServiceName)
  +void WSDDService::SetServiceName(const string& sServiceName)
   {
        m_sName = sServiceName;
   }
   
  -string& WSDDService::GetServiceName()
  +void WSDDService::SetProvider(const string& sProvider)
  +{
  +     m_sProvider = sProvider;
  +}
  +
  +const string& WSDDService::GetServiceName()
   {
        return m_sName;
   }
   
  -void WSDDService::SetAllowedMethod(string& sMethodName)
  +void WSDDService::AddAllowedMethod(const string& sMethodName)
   {
        m_AllowedMethods.push_back(sMethodName);
   }
   
  -bool WSDDService::IsAllowedMethod(string& sServiceName)
  +bool WSDDService::IsAllowedMethod(const string& sServiceName) const
   {
  -     list<string>::iterator iter;
  +     list<string>::const_iterator iter;
   
  -     for(iter=m_AllowedMethods.begin();iter!=m_AllowedMethods.end();iter++)
  +     for(iter = m_AllowedMethods.begin();iter != m_AllowedMethods.end();iter++)
        {
  -             if((*iter)==sServiceName)
  +             if((*iter) == sServiceName)
                {
  -//                   cout<<"we have a service by that name";
                        return true;
                }
        }
        return false;
   }
   
  -void WSDDService::SetRequestFlowHandlers(WSDDHandlerList * reqFlowHList)
  -{
  -  DEBUG1("WSDDService::SetRequestFlowHandlers");
  -     m_RequestHandlers = reqFlowHList;
  -}
  -
  -
  -WSDDHandlerList* WSDDService::GetRequestFlowHandlers()
  +const WSDDHandlerList* WSDDService::GetRequestFlowHandlers() const
   {
        return m_RequestHandlers;
   }
   
  -void WSDDService::SetResponseFlowHandlers(WSDDHandlerList * resFlowHList)
  -{
  -     m_ResponseHandlers = resFlowHList;
  -}
  -
  -WSDDHandlerList* WSDDService::GetResponseFlowHandlers()
  +const WSDDHandlerList* WSDDService::GetResponseFlowHandlers() const
   {
        return m_ResponseHandlers;
   }
   
  -void WSDDService::SetAllowedRoles(string& sRole)
  +void WSDDService::AddAllowedRole(const string& sRole)
   {
        m_AllowedRoles.push_back(sRole);
   }
   
  -list<string> WSDDService::GetAllowedRoles()
  +const list<string>& WSDDService::GetAllowedRoles()
   {
        return m_AllowedRoles;
   }
   
  -void WSDDService::SetIsServiceAllowed(int m_IsServiceAllowed)
  +void  WSDDService::AddHandler(bool bRequestFlow, WSDDHandler* pHandler)
   {
  -  m_IsServiceAllowed = m_IsServiceAllowed;
  +     if (bRequestFlow)
  +     {
  +             if (!m_RequestHandlers) m_RequestHandlers = new WSDDHandlerList;
  +             m_RequestHandlers->push_back(pHandler);
  +     }
  +     else
  +     {
  +             if (!m_ResponseHandlers) m_ResponseHandlers = new WSDDHandlerList;
  +             m_ResponseHandlers->push_back(pHandler);
  +     }
   }
   
  -int WSDDService::GetIsServiceAllowed()
  -{
  -  return m_IsServiceAllowed;
  -}
  \ No newline at end of file
  
  
  
  1.5       +14 -8     xml-axis/c/src/wsdd/WSDDHandler.h
  
  Index: WSDDHandler.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDHandler.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSDDHandler.h     6 Aug 2003 10:26:37 -0000       1.4
  +++ WSDDHandler.h     13 Aug 2003 13:31:42 -0000      1.5
  @@ -81,26 +81,32 @@
   using namespace std;
   
   enum AXIS_HANDLER_SCOPE {AH_APPLICATION=1, AH_SESSION, AH_REQUEST};
  +const char kw_scope_app[] = "application";
  +const char kw_scope_ses[] = "session";
  +const char kw_scope_req[] = "request";
   
   class WSDDHandler  
   {
   public:
  -     virtual string& GetLibName();
  -     virtual int GetLibID();
  -     virtual int GetScope();
  -     virtual void SetLibName(string& sLibName);
  +     const string& GetLibName() const;
  +     int GetLibId() const;
  +     int GetScope() const;
  +     void SetScope(const string& sScope);
  +     void SetLibName(const string& sLibName);
  +     void SetLibId(int nLibId);
  +     const string& GetParameter(const string& sKey) const;
  +     void AddParameter(const string& sKey, const string& sValue);
  +     const map<string, string>* GetParameterList() const; 
        WSDDHandler();
        virtual ~WSDDHandler();
  -  string GetOption(string sArg);
  -  void SetOption(string sOption, string Value);
  -  virtual map<string, string>* GetOptionList(); 
   
   protected:
        int m_nLibId;
        int m_nScope;
        string m_sName;
        string m_sLibName;
  -     map<string, string>* m_Option;
  +     map<string, string>* m_Params;
  +     string m_sAux;
   };
   
   typedef list<WSDDHandler*> WSDDHandlerList;
  
  
  
  1.5       +32 -12    xml-axis/c/src/wsdd/WSDDHandler.cpp
  
  Index: WSDDHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDHandler.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSDDHandler.cpp   6 Aug 2003 10:26:37 -0000       1.4
  +++ WSDDHandler.cpp   13 Aug 2003 13:31:42 -0000      1.5
  @@ -73,47 +73,67 @@
   
   WSDDHandler::WSDDHandler()
   {
  -  m_Option = new map<string, string>;
     m_nLibId = 0;
  +  m_nScope = AH_REQUEST; //default
  +  m_sAux = "";
  +  m_Params = NULL;
   }
   
   WSDDHandler::~WSDDHandler()
   {
  -  delete(m_Option);
  +  if (m_Params) delete m_Params;
   }
   
  -void WSDDHandler::SetLibName(string& sLibName)
  +void WSDDHandler::SetLibName(const string& sLibName)
   {
        m_sLibName = sLibName;
   }
   
  -int WSDDHandler::GetLibID()
  +void WSDDHandler::SetLibId(int nLibId)
  +{
  +     m_nLibId = nLibId;
  +}
  +
  +int WSDDHandler::GetLibId() const
   {
        return m_nLibId;
   }
   
  -string& WSDDHandler::GetLibName()
  +const string& WSDDHandler::GetLibName() const
   {
        return m_sLibName;
   }
   
  -int WSDDHandler::GetScope()
  +int WSDDHandler::GetScope() const
   {
        return m_nScope;
   }
   
  -string WSDDHandler::GetOption(string sArg)
  +void WSDDHandler::SetScope(const string& sScope)
  +{
  +     if (sScope == kw_scope_app)
  +             m_nScope = AH_APPLICATION;      
  +     else if (sScope == kw_scope_ses)
  +             m_nScope = AH_SESSION;  
  +     else
  +             m_nScope = AH_REQUEST;  
  +}
  +
  +const string& WSDDHandler::GetParameter(const string& sKey) const
   {
  -  return (*m_Option)[sArg]; 
  +     if (m_Params->find(sKey) != m_Params->end())
  +             return (*m_Params)[sKey];
  +     return m_sAux;
   }
   
  -void WSDDHandler::SetOption(string sOption, string sValue)
  +void WSDDHandler::AddParameter(const string& sKey, const string& sValue)
   {
  -  (*m_Option)[sOption] = sValue; 
  +     if (!m_Params) m_Params = new map<string, string>;
  +     (*m_Params)[sKey] = sValue; 
   }
   
  -map<string, string>* WSDDHandler::GetOptionList()
  +const map<string, string>* WSDDHandler::GetParameterList() const
   {
  -  return m_Option;
  +  return m_Params;
   }
   
  
  
  
  1.4       +52 -33    xml-axis/c/src/wsdd/WSDDDocument.h
  
  Index: WSDDDocument.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDDocument.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSDDDocument.h    8 Jul 2003 12:22:52 -0000       1.3
  +++ WSDDDocument.h    13 Aug 2003 13:31:42 -0000      1.4
  @@ -58,6 +58,7 @@
    *
    *
    * @author sanjaya
  + * @author Suasntha Kumara ([EMAIL PROTECTED], [EMAIL PROTECTED])
    *
    */
   
  @@ -78,51 +79,69 @@
   #include <string>
   #include <map>
   
  -
  -
   using namespace std;
   
  -enum WSDDLevels {WSDD_UNKNOWN=1, WSDD_DEPLOYMENT, WSDD_GLOBCONF, WSDD_SERVICE, 
WSDD_HANDLER, WSDD_PARAM, WSDD_REQFLOW, WSDD_RESFLOW, WSDD_TRANSPORT};
  +enum WSDDLevels {WSDD_UNKNOWN=1, WSDD_DEPLOYMENT, WSDD_UNDEPLOYMENT, WSDD_GLOBCONF, 
WSDD_SERVICE, WSDD_HANDLER, WSDD_CHAIN, WSDD_TRANSPORT, WSDD_REQFLOW, WSDD_RESFLOW, 
WSDD_PARAM };
   
   XERCES_CPP_NAMESPACE_USE;
   
  +//wsdd file related defines
  +#define METHODNAME_SEPARATOR " "
  +#define ROLENAME_SEPARATOR ","
  +
  +//keywords used in the wsdd file
  +const char kw_depl[] = "deployment";
  +const char kw_srv[] = "service";
  +const char kw_glconf[] = "globalConfiguration";
  +const char kw_param[] = "parameter"; 
  +const char kw_hdl[] = "handler";
  +const char kw_chain[] = "chain";
  +const char kw_ns[] = "namespace";
  +const char kw_prv[] = "provider";
  +const char kw_cn[] = "className"; //must be changed to libname or so
  +const char kw_am[] = "allowedMethods";
  +const char kw_ar[] = "allowedRoles";
  +const char kw_rqf[] = "requestFlow";
  +const char kw_rsf[] = "responseFlow";
  +const char kw_tr[] = "transport";
  +const char kw_name[] = "name";
  +const char kw_value[] = "value";
  +const char kw_type[] = "type"; //what about this ? change to libname ?
  +const char kw_scope[] = "scope";
  +const char kw_http[] = "http";
  +const char kw_smtp[] = "smtp";
  +
   class WSDDDocument:public DefaultHandler
   {
   private:
  +     int m_nLibId;
  +     map<string, int>* m_pLibNameIdMap;
  +     WSDDDeployment* m_pDeployment; 
  +     WSDDLevels m_lev0;
  +     WSDDLevels m_lev1; //gets values WSDD_REQFLOW or WSDD_RESFLOW
  +     WSDDLevels m_lev2; //gets values WSDD_HANDLER or WSDD_CHAIN
  +     map<string, string> m_NsStack;
  +     WSDDService* m_pService; //Place holder for currently created Service object
  +     WSDDHandler* m_pHandler; //Place holder for currently created Handler object
  +     //map<string, string> m_GlobalConfParams;
  +     AXIS_PROTOCOL_TYPE m_CurTrType; //Current transport type of transport handlers
  +
  +private:
  +     void ProcessAttributes(WSDDLevels ElementType, const Attributes &attrs);
  +     void GetParameters(WSDDLevels ElementType, const Attributes &attrs);
  +     void AddAllowedRolesToService(string& value);
  +     void AddAllowedMethodsToService(string& value);
   
  -     WSDDServiceMap * dsmap;
  -     WSDDService * ds;
  -     char * serviceName;
  -     WSDDLevels lev0;
  -     WSDDLevels lev1;
  -     WSDDLevels lev2;
  -     WSDDHandlerList * globReqFlowHanList;
  -     WSDDHandlerList * globResFlowHanList;
  -     WSDDHandlerList * tempHandlerList;
  -     WSDDHandler * tempHandler;
  -     WSDDServiceMap * svsMap;
  -     WSDDService * tempService;
  -     WSDDTransport * tempTr;
  -     AXIS_PROTOCOL_TYPE protocol;
  -     char * ch;
  -     XMLCh * xch;
  -     XMLCh * xchName;
  -     XMLCh * xchValue;
  -     XMLCh * xchType;
  -     char * svsch;
   public:
        WSDDDocument();
        ~WSDDDocument();
  -     int ParseDocument(string& sWSDD);
  -     int GetDeployment(string& sWSDD, WSDDDeployment * dep);
  -     void startElement(const XMLCh *const uri,
  -                                                     const XMLCh *const localname,
  -                                                     const XMLCh *const qname,
  -                                                     const Attributes &attrs);
  -     void  characters (const XMLCh *const chars, const unsigned int length);
  -     void  endElement (const XMLCh *const uri,
  -                                             const XMLCh *const localname,
  -                                             const XMLCh *const qname);
  +     int ParseDocument(const string& sWSDD);
  +     int GetDeployment(const string& sWSDD, WSDDDeployment* pDeployment);
  +     void startElement(const XMLCh *const uri, const XMLCh *const localname, const 
XMLCh *const qname, const Attributes &attrs);
  +     void characters (const XMLCh *const chars, const unsigned int length);
  +     void endElement (const XMLCh *const uri, const XMLCh *const localname,  const 
XMLCh *const qname);
  +     void startPrefixMapping(const XMLCh* const prefix, const XMLCh* const uri);
  +     void endPrefixMapping(const XMLCh* const prefix);
   };
   
   #endif //__WSDDDOCUMENTS_H_INCLUDED__
  
  
  
  1.5       +393 -412  xml-axis/c/src/wsdd/WSDDDocument.cpp
  
  Index: WSDDDocument.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDDocument.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSDDDocument.cpp  4 Aug 2003 06:54:21 -0000       1.4
  +++ WSDDDocument.cpp  13 Aug 2003 13:31:42 -0000      1.5
  @@ -58,6 +58,7 @@
    *
    *
    * @author Sanjaya Singharage
  + * @author Suasntha Kumara ([EMAIL PROTECTED], [EMAIL PROTECTED])
    *
    */
   
  @@ -66,28 +67,18 @@
   #include <string>
   #include "../common/Debug.h"
   
  -#define toString(X) XMLString::transcode(X)
  -#define toXMLCh(X) XMLString::transcode(X)
  -#define REL(X) XMLString::release(X);
  +#define __TRC(X) XMLString::transcode(X)
  +#define __REL(X) XMLString::release(X)
   
   
   WSDDDocument::WSDDDocument()
   {
  -     lev0 =WSDD_UNKNOWN;
  -     lev1 =WSDD_UNKNOWN;
  -     lev2 =WSDD_UNKNOWN;
  -     tempHandlerList=NULL;
  -     globReqFlowHanList=NULL;
  -     globResFlowHanList=NULL;
  -     svsMap = new WSDDServiceMap();
  -     tempTr = new WSDDTransport();
  -     protocol = APTOTHER;
  -     ch = NULL;
  -     //xch = NULL;
  -     xchName = NULL;
  -     xchValue = NULL;
  -     xchType = NULL;
  -     svsch = NULL;
  +     m_lev0 = WSDD_UNKNOWN;
  +     m_lev1 = WSDD_UNKNOWN;
  +     m_lev2 = WSDD_UNKNOWN;
  +     m_CurTrType = APTHTTP;//default is HTTP
  +     m_nLibId = 0;
  +     m_pLibNameIdMap = new map<string, int>;
   }
   
   WSDDDocument::~WSDDDocument()
  @@ -95,28 +86,23 @@
   
   }
   
  -int WSDDDocument::GetDeployment(string& sWSDD, WSDDDeployment * dep)
  +int WSDDDocument::GetDeployment(const string& sWSDD, WSDDDeployment* pDeployment)
   {
  -     if (SUCCESS != ParseDocument(sWSDD)) return FAIL;    
  -
  -     dep->SetGlobalRequestFlowHandlers(globReqFlowHanList);
  -     dep->SetGlobalResponseFlowHandlers(globResFlowHanList);
  -     dep->SetServices(svsMap);
  -     dep->SetTransport(tempTr);
  -
  +     m_pDeployment = pDeployment; //this enables the access to Deployment object 
while parsing
  +     if (SUCCESS != ParseDocument(sWSDD)) return FAIL;
  +     m_pDeployment->SetLibIdMap(m_pLibNameIdMap);
        return SUCCESS;
   }
   
  -int WSDDDocument::ParseDocument(string& sWSDD)
  +int WSDDDocument::ParseDocument(const string& sWSDD)
   {
        try
        {
                SAX2XMLReader * parser = XMLReaderFactory::createXMLReader();
                parser->setContentHandler(this);
                parser->setErrorHandler(this);     
  -    DEBUG1("BEFORE parser->parse(sWSDD.c_str());");
  +             DEBUG1("BEFORE parser->parse(sWSDD.c_str());");
                parser->parse(sWSDD.c_str());      
  -
        }
        catch (...)
        {
  @@ -125,444 +111,439 @@
        return SUCCESS;
   }
   
  -
  -void WSDDDocument::startElement(const XMLCh *const uri,
  -                                                     const XMLCh *const localname,
  -                                                     const XMLCh *const qname,
  -                                                     const Attributes &attrs)
  +void  WSDDDocument::endElement (const XMLCh *const uri, const XMLCh *const 
localname, const XMLCh *const qname)
   {
  -
  -     ch = XMLString::transcode(localname);
  -     xchName = toXMLCh("name");
  -     xchValue = toXMLCh("value");
  -     xchType = toXMLCh("type");
  -     svsch = toString(attrs.getValue(xchName));
  -
  -     switch(lev0)
  +     char *pcLocalName = __TRC(localname);
  +     if (pcLocalName)
        {
  -             case WSDD_UNKNOWN:
  -
  -                     if(strcmp(ch, "globalConfiguration")==0)
  -                     {  
  -
  -                             lev0=WSDD_GLOBCONF;
  -                     }
  -                     if(strcmp(ch, "service")==0)
  -                     {  
  -
  -                             lev0=WSDD_SERVICE;
  -                     }
  -                     if(strcmp(ch, "transport")==0)
  -                     {  
  -
  -                             lev0=WSDD_TRANSPORT;
  -                     }
  -                     if(lev0==WSDD_UNKNOWN)
  -                     {
  -                             break;
  -                     }
  -             break;
  -     }
  -
  -
  -     switch(lev0)
  -     {  
  -
  -             case WSDD_GLOBCONF:
  -                     //cout<<"we are in glob conf"<<endl;  
  -
  -                     if(strcmp(ch, "requestFlow")==0)
  -                     {
  -                             globReqFlowHanList = new WSDDHandlerList();
  -                             lev1=WSDD_REQFLOW;
  -                     }  
  -
  -                     if(strcmp(ch, "responseFlow")==0)
  +             if (0 != strcmp(pcLocalName, kw_param)) //just neglect endElement of 
parameter
  +             {
  +                     if (m_lev1 == WSDD_UNKNOWN) //not inside a requestFlow or 
responseFlow elements
                        {
  -                             globResFlowHanList = new WSDDHandlerList();
  -                             lev1=WSDD_RESFLOW;
  -                     }  
  -
  -                     //xch = toXMLCh("type");
  -                     switch(lev1)
  -                     {
  -                             case WSDD_REQFLOW:
  -                                     //cout<<"we are in glob 
conf>requestflow"<<endl;  
  -
  -                                     if(strcmp(ch, "handler")==0)
  +                             switch(m_lev0)
  +                             {
  +                             case WSDD_DEPLOYMENT:
  +                                     m_lev0 = WSDD_UNKNOWN;
  +                                     break;
  +                             case WSDD_GLOBCONF:
  +                                     m_lev0 = WSDD_DEPLOYMENT;
  +                                     break;
  +                             case WSDD_SERVICE:
  +                                     if (0 == strcmp(pcLocalName, kw_srv))
                                        {
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
globReqFlowHanList->push_back(tempHandler);
  -                                             tempHandler = NULL;
  -                                     }  
  -
  -                             break;
  -                             case WSDD_RESFLOW:
  -                                     if(strcmp(ch, "handler")==0)
  +                                             //add service object to Deployment 
object
  +                                             m_pDeployment->AddService(m_pService);
  +                                             m_pService = NULL;
  +                                             m_lev0 = WSDD_DEPLOYMENT;
  +                                     }
  +                                     else
                                        {
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
globResFlowHanList->push_back(tempHandler);
  -                                             tempHandler = NULL;
  -                                     }  
   
  +                                     }
  +                                     break;
  +                             case WSDD_HANDLER:
  +                                     //just ignore the handlers defined outside ??? 
//TODO
  +                                     delete m_pHandler;
  +                                     m_pHandler = NULL;
  +                                     m_lev0 = WSDD_DEPLOYMENT;
  +                                     break;
  +                             case WSDD_TRANSPORT:
  +                                     m_CurTrType = APTHTTP;//default is HTTP
  +                                     m_lev0 = WSDD_DEPLOYMENT;
  +                                     break;
                                break;
  +                             }
                        }
  -
  -                     //REL(&xch);
  -             break;
  -
  -
  -             case WSDD_SERVICE:      
  -                     if(strcmp(ch, "service")==0)
  -                     {
  -
  -                             tempService = new WSDDService();
  -                             string sSrvName = toString(attrs.getValue(xchName));
  -                             tempService->SetServiceName(sSrvName);
  -                             
(*svsMap)[toString(attrs.getValue(xchName))]=tempService;
  -
  -                     //      cout<<toString(attrs.getValue(toXMLCh("name")))<<endl;
  -                     }  
  -
  -                     //The check for lev1==WSDD_UNKNOWN is necessary because
  -                     //parameter elements can occur inside handler elements
  -                     if(strcmp(ch, "parameter")==0 && (lev1==WSDD_UNKNOWN))
  -                     {
  -                             lev1=WSDD_PARAM;
  -                     } 
  -
  -
  -      if(strcmp(ch, "requestFlow")==0)
  -                     {
  -                             lev1=WSDD_REQFLOW;
  -                             tempHandlerList = new WSDDHandlerList();
  -                     }  
  -
  -      if(strcmp(ch, "responseFlow")==0)
  -                     {
  -                             lev1=WSDD_RESFLOW;
  -                             tempHandlerList = new WSDDHandlerList();
  -                     }
  -
  -
  -      switch(lev1)
  +                     else // inside a requestFlow or responseFlow elements
                        {
  -                             case WSDD_PARAM:
  -                                     if(strcmp(svsch, "className")==0)
  -                                     { 
  -
  -                                             string sLibName = 
toString(attrs.getValue(xchValue));
  -                                             tempService->SetLibName(sLibName);
  -                                             
//cout<<toString(attrs.getValue(toXMLCh("value")))<<" The class name"<<endl;
  -                                     }
  -                                     if(strcmp(svsch, "allowedMethods")==0)
  +                             if(0 == strcmp(pcLocalName, kw_hdl))
  +                             {
  +                                     m_lev2 = WSDD_UNKNOWN;
  +                                     //add handler in m_pHandler to the 
corresponding container.
  +                                     switch (m_lev0)
                                        {
  -                                             string sLibName = 
toString(attrs.getValue(xchValue));
  -                                             
//cout<<toString(attrs.getValue(toXMLCh("value")))<<" The class name"<<endl;
  -
  -                                             char * x = 
toString(attrs.getValue(xchValue));
  -                                             char * y;
  -                                             if(x)
  -                                             {
  -                                                     y=strtok(x," ");
  -                                                     while (y!=NULL)
  +                                             case WSDD_GLOBCONF:
                                                        {
  -                                                             string sY = y;
  -                                                             
tempService->SetAllowedMethod(sY);
  -                                                             y=strtok(NULL," ");
  +                                                             
m_pDeployment->AddHandler(true,(m_lev1 == WSDD_REQFLOW) , m_pHandler);
  +                                                             m_pHandler = NULL;
                                                        }
  -                                             }
  -                                             REL(&x);
  -                                             delete y;
  -
  -                                             x=NULL;
  -                                             y=NULL;
  -                                     }
  -                             break;
  -
  -                             case WSDD_REQFLOW:
  -                                     if(strcmp(ch, "handler")==0)
  -                                     {
  -                                             lev2=WSDD_HANDLER;
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
tempHandlerList->push_back(tempHandler);
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "parameter")==0)
  +                                                     break;
  +                                             case WSDD_TRANSPORT:
                                                        {
  -                                                             
tempHandler->SetOption(toString(attrs.getValue(xchName)),
  -                                                                                    
                         toString(attrs.getValue(xchValue)));
  -
  -                  DEBUG1("After tempHandler->SetOption");
  -
  +                                                             
m_pDeployment->AddHandler(false,(m_lev1 == WSDD_REQFLOW) , m_pHandler, m_CurTrType);
  +                                                             m_pHandler = NULL;
                                                        }
  -                                             break;
  -                                     }
  -                             break;
  -
  -                             case WSDD_RESFLOW:
  -                                     if(strcmp(ch, "handler")==0)
  -                                     {
  -                                             lev2=WSDD_HANDLER;
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
tempHandlerList->push_back(tempHandler);
  -                                             //tempHandler = NULL;
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "parameter")==0)
  +                                                     break;
  +                                             case WSDD_SERVICE:
                                                        {
  -                                                             
tempHandler->SetOption(toString(attrs.getValue(xchName)),
  -                                                                                    
                         toString(attrs.getValue(xchValue)));
  +                                                             
m_pService->AddHandler((m_lev1 == WSDD_REQFLOW) , m_pHandler);
  +                                                             m_pHandler = NULL;
                                                        }
  -                                             break;
  +                                                     break;
  +                                             default: ; //this cannot happen ?? 
                                        }
  -                             break;
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rqf))
  +                             {  
  +                                     m_lev1 = WSDD_UNKNOWN;
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rsf))
  +                             {  
  +                                     m_lev1 = WSDD_UNKNOWN;
  +                             }                                               
                        }
  +             }
  +             __REL(&pcLocalName);
  +     }
  +}
   
  -             break;  
  -
  -             case WSDD_TRANSPORT:
  -                     if(strcmp(ch, "transport")==0)
  +void WSDDDocument::ProcessAttributes(WSDDLevels ElementType, const Attributes 
&attrs)
  +{
  +     char* pc; 
  +     for (int i = 0; i < attrs.getLength(); i++) 
  +     {
  +             pc = __TRC(attrs.getLocalName(i));
  +             string local = pc;
  +             __REL(&pc);
  +             pc = __TRC(attrs.getValue(i));
  +             string value = pc;
  +             __REL(&pc);
  +             switch(ElementType)
  +             {
  +             case WSDD_SERVICE: //add this attribute to current service object
  +                     if (local == kw_name)
                        {
  -                             //tempHandlerList = new WSDDHandlerList();
  -                             if(strcmp(svsch, "http")==0)
  -                             {
  -                                     protocol =APTHTTP;
  -                             }
  -                             if(strcmp(svsch, "local")==0)
  +                             m_pService->SetServiceName(value);
  +                     }
  +                     else if (local == kw_prv)
  +                     {
  +                             m_pService->SetProvider(value);
  +                     }
  +                     else
  +                     {
  +                             //unknown attribute
  +                     }
  +                     break;
  +             case WSDD_HANDLER: //add this attribute to current handler object
  +                     if (local == kw_name)
  +                     {
  +                             //usefull ? ignore for now .. //TODO
  +                     }
  +                     else if (local == kw_type)
  +                     {
  +                             //we get the libname for the hanlder here ???
  +                             m_pHandler->SetLibName(value);
  +                             if (m_pLibNameIdMap->find(value.c_str()) != 
m_pLibNameIdMap->end()) //libray name already in the map
                                {
  -                                     protocol =APTFTP;
  +                                     
m_pHandler->SetLibId((*m_pLibNameIdMap)[value.c_str()]);
                                }
  -                             if(protocol==APTOTHER)
  +                             else
                                {
  -                                     break;
  +                                     (*m_pLibNameIdMap)[value.c_str()] = ++m_nLibId;
  +                                     
m_pHandler->SetLibId((*m_pLibNameIdMap)[value.c_str()]);
                                }
  -
                        }
  -                     if(strcmp(ch, "requestFlow")==0)
  +                     else
                        {
  -                             lev1=WSDD_REQFLOW;
  -                             tempHandlerList = new WSDDHandlerList();
  +                             //unknown attribute
                        }
  -                     if(strcmp(ch, "responseFlow")==0)
  +                     break;
  +             case WSDD_REQFLOW:
  +             case WSDD_RESFLOW:
  +                     if (local == kw_name)
                        {
  -                             lev1=WSDD_RESFLOW;
  -                             tempHandlerList = new WSDDHandlerList();
  +                             //usefull ? ignore for now .. //TODO
                        }
  -                     switch(lev1)
  +                     else
                        {
  -                             case WSDD_REQFLOW:
  -                                     //cout<<"we are in glob 
conf>requestflow"<<endl;
  -                                     if(strcmp(ch, "handler")==0)
  -                                     {
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
tempHandlerList->push_back(tempHandler);
  -                                             tempHandler = NULL;
  -                                     }
  -                             break;
  -
  -                             case WSDD_RESFLOW:
  -                                     //cout<<"we are in glob 
conf>requestflow"<<endl;
  -                                     if(strcmp(ch, "handler")==0)
  -                                     {
  -                                             tempHandler = new WSDDHandler();
  -                                             string sLibName = 
toString(attrs.getValue(xchType));
  -                                             tempHandler->SetLibName(sLibName);
  -                                             
tempHandlerList->push_back(tempHandler);
  -                                             tempHandler = NULL;
  -                                     }
  -                             break;
  -
  +                             //unknown attribute
  +                     }
  +                     break;
  +             case WSDD_TRANSPORT:
  +                     if (local == kw_name)
  +                     {
  +                             //get tranport type
  +                             if (value == kw_http)
  +                                     m_CurTrType = APTHTTP;
  +                             else if (value == kw_smtp)
  +                                     m_CurTrType = APTSMTP;
  +                             else
  +                             {
  +                                     //unhandled transport type
  +                             }
  +                     }
  +                     else
  +                     {
  +                             //unknown attribute
                        }
  +                     break;
  +             }
  +     }
  +}
   
  +void WSDDDocument::GetParameters(WSDDLevels ElementType, const Attributes &attrs)
  +{
  +     char* pc; 
  +     string name, value, type;
  +     bool locked;
  +     string Localname, Value;
  +     for (int i = 0; i < attrs.getLength(); i++) 
  +     {
  +             pc = __TRC(attrs.getLocalName(i));
  +             Localname = pc;
  +             __REL(&pc);
  +             pc = __TRC(attrs.getValue(i));
  +             Value = pc;
  +             __REL(&pc);
  +             if (Localname == kw_name)
  +             {
  +                     name = Value;
  +             }
  +             else if (Localname == kw_value)
  +             {
  +                     value = Value;
  +             }
  +             else if (Localname == kw_type)
  +             {
  +                     type = Value;
  +             }
  +     }
  +     switch(ElementType)
  +     {
  +     case WSDD_GLOBCONF: //parameters just inside globalConfiguration
  +             //TODO
  +             break;
  +     case WSDD_SERVICE:
  +             if (name == kw_am)
  +             {
  +                     AddAllowedMethodsToService(value);
  +             }
  +             else if(name == kw_cn)
  +             {
  +                     m_pService->SetLibName(value);
  +                     if (m_pLibNameIdMap->find(value.c_str()) != 
m_pLibNameIdMap->end()) //libray name already in the map
  +                     {
  +                             
m_pService->SetLibId((*m_pLibNameIdMap)[value.c_str()]);
  +                     }
  +                     else
  +                     {
  +                             (*m_pLibNameIdMap)[value.c_str()] = ++m_nLibId;
  +                             
m_pService->SetLibId((*m_pLibNameIdMap)[value.c_str()]);
  +                     }
  +             }
  +             else if (name == kw_scope)
  +             {
  +                     m_pService->SetScope(value);
  +             }
  +             else if (name == kw_ar)
  +             {
  +                     AddAllowedRolesToService(value);
  +             }
  +             else
  +             {
  +                     m_pService->AddParameter(name, value);
  +             }
  +             break;
  +     case WSDD_HANDLER:
  +             if (name == kw_scope)
  +             {
  +                     m_pHandler->SetScope(value);
  +             }
  +             else
  +             {
  +                     m_pHandler->AddParameter(name, value);
  +             }
                break;
        }
  -     REL(&ch);
  -     REL(&xchName);
  -     REL(&xchValue);
  -     REL(&xchType);
  -     REL(&svsch);
  -
   }
   
  -void  WSDDDocument::endElement (const XMLCh *const uri,
  -                               const XMLCh *const localname,
  -                               const XMLCh *const qname)
  +void WSDDDocument::AddAllowedRolesToService(string& value)
   {
  -     ch = XMLString::transcode(localname);
  -     switch (lev0)
  -     {  
  +     int prepos = 0, pos = 0;
  +     if (value.find('*') == string::npos)
  +     {
  +             do 
  +             {
  +                     pos = value.find(ROLENAME_SEPARATOR, prepos);
  +//                   cout << value.substr(prepos, pos) << endl;
  +                     m_pService->AddAllowedRole(value.substr(prepos, pos));
  +                     prepos = pos + 1;
  +             } while(string::npos != pos);
  +     }
  +}
   
  -             case WSDD_GLOBCONF:
  -                     if(strcmp(ch, "globalConfiguration")==0)
  -                     {
  -                             lev0=WSDD_UNKNOWN;
  -                     }
  -                     switch(lev1)
  -                     {
  -                             case WSDD_REQFLOW:
  -                                     if(strcmp(ch, "requestFlow")==0)
  -                                     {
  -                                             lev1=WSDD_UNKNOWN;
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "handler")==0)
  -                                                     {
  -                                                             lev2=WSDD_UNKNOWN;
  -                                                     }
  -                                             break;
  -                                     }
  +void WSDDDocument::AddAllowedMethodsToService(string& value)
  +{
  +     int prepos = 0, pos = 0;
  +     if (value.find('*') == string::npos)
  +     {
  +             do 
  +             {
  +                     pos = value.find(METHODNAME_SEPARATOR, prepos);
  +//                   cout << value.substr(prepos, pos) << endl;
  +                     m_pService->AddAllowedMethod(value.substr(prepos, pos));
  +                     prepos = pos + 1;
  +             } while(string::npos != pos);
  +     }
  +}
   
  +void WSDDDocument::startElement(const XMLCh *const uri,      const XMLCh *const 
localname, const XMLCh *const qname, const Attributes &attrs)
  +{
  +     char *pcLocalName = __TRC(localname);
  +     if (pcLocalName)
  +     {
  +             if (m_lev1 == WSDD_UNKNOWN) //not inside a requestFlow or responseFlow 
elements
  +             {
  +                     switch(m_lev0)
  +                     {
  +                     case WSDD_UNKNOWN:
  +                             if(0 == strcmp(pcLocalName, kw_depl))
  +                             {  
  +                                     m_lev0 = WSDD_DEPLOYMENT;
  +                                     //nothing to get
  +                             }
                                break;
  -                             case WSDD_RESFLOW:
  -                                     if(strcmp(ch, "responseFlow")==0)
  -                                     {
  -                                             lev1=WSDD_UNKNOWN;
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "handler")==0)
  -                                                     {
  -                                                             lev2=WSDD_UNKNOWN;
  -                                                     }
  -                                             break;
  -                                     }
  +                     case WSDD_DEPLOYMENT:
  +                             if(0 == strcmp(pcLocalName, kw_glconf))
  +                             {  
  +                                     m_lev0 = WSDD_GLOBCONF;
  +                                     //nothing to get
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_srv))
  +                             {  
  +                                     m_lev0 = WSDD_SERVICE;
  +                                     m_pService = new WSDDService();
  +                                     //get service name and proider if any
  +                                     ProcessAttributes(WSDD_SERVICE, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_hdl))
  +                             {  
  +                                     m_lev0 = WSDD_HANDLER;
  +                                     m_pHandler = new WSDDHandler();
  +                                     ProcessAttributes(WSDD_HANDLER, attrs);
  +                                     //get handler name and type if any
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_tr))
  +                             {  
  +                                     m_lev0 = WSDD_TRANSPORT;
  +                                     ProcessAttributes(WSDD_TRANSPORT, attrs);
  +                             }
  +                             else
  +                             {
  +                                     //error : unknown element type in wsdd file
  +                             }
                                break;
  -                     }
  -             break;
  +                     case WSDD_GLOBCONF:
  +                             if(0 == strcmp(pcLocalName, kw_param))
  +                             {  
  +                                     GetParameters(WSDD_GLOBCONF, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rqf))
  +                             {  
  +                                     m_lev1 = WSDD_REQFLOW;
  +                                     ProcessAttributes(WSDD_REQFLOW, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rsf))
  +                             {  
  +                                     m_lev1 = WSDD_RESFLOW;
  +                                     ProcessAttributes(WSDD_RESFLOW, attrs);
  +                             }
  +                             else
  +                             {
  +                                     //yet unhandled element type
  +                             }
  +                     break; 
  +                     case WSDD_SERVICE:
  +                             if(0 == strcmp(pcLocalName, kw_param))
  +                             {  
  +                                     GetParameters(WSDD_SERVICE, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rqf))
  +                             {  
  +                                     m_lev1 = WSDD_REQFLOW;
  +                                     ProcessAttributes(WSDD_REQFLOW, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rsf))
  +                             {  
  +                                     m_lev1 = WSDD_RESFLOW;
  +                                     ProcessAttributes(WSDD_RESFLOW, attrs);
  +                             }
  +                             else
  +                             {
  +                                     //yet unhandled element type like namespace
  +                             }
  +                     break;
  +                     case WSDD_HANDLER:
  +                             if(0 == strcmp(pcLocalName, kw_param))
  +                             {  
  +                                     GetParameters(WSDD_HANDLER, attrs);
  +                             }
   
  -             case WSDD_REQFLOW:
  -                     if(strcmp(ch, "requestFlow")==0)
  -                     {
  -                             lev0=WSDD_UNKNOWN;
  +                     break;
  +                     case WSDD_TRANSPORT:
  +                             if(0 == strcmp(pcLocalName, kw_rqf))
  +                             {  
  +                                     m_lev1 = WSDD_REQFLOW;
  +                                     ProcessAttributes(WSDD_REQFLOW, attrs);
  +                             }
  +                             else if(0 == strcmp(pcLocalName, kw_rsf))
  +                             {  
  +                                     m_lev1 = WSDD_RESFLOW;
  +                                     ProcessAttributes(WSDD_RESFLOW, attrs);
  +                             }
  +                     break;
  +                     }
  +             }
  +             else // inside a requestFlow or responseFlow elements
  +             {
  +                     if(0 == strcmp(pcLocalName, kw_param))
  +                     {  
  +                             GetParameters(m_lev2, attrs); //must be parameters of 
a handler or a chain
                        }
  -             break; 
   
  -             case WSDD_SERVICE:
  -                     if(strcmp(ch, "service")==0)
  -                     {
  -                             lev0=WSDD_UNKNOWN;
  -                             tempService = NULL;
  +                     else if(0 == strcmp(pcLocalName, kw_hdl))
  +                     {  
  +                             m_lev2 = WSDD_HANDLER;
  +                             m_pHandler = new WSDDHandler();
  +                             ProcessAttributes(WSDD_HANDLER, attrs);
  +                             //get handler name and type if any
                        }
  -                     switch(lev1)
  +                     else if(0 == strcmp(pcLocalName, kw_chain))
                        {
  -                             case WSDD_PARAM:
  -                                     if(strcmp(ch, "parameter")==0)
  -                                     {
  -                                             lev1=WSDD_UNKNOWN;
  -                                     }
  -                             break;
  -                             case WSDD_REQFLOW:
  -                                     if(strcmp(ch, "requestFlow")==0)
  -                                     {
  -                                             lev1=WSDD_UNKNOWN;
  -                                             if(!tempHandlerList->empty())
  -                                             {
  -                                                     
tempService->SetRequestFlowHandlers(tempHandlerList);
  -                                             }
  -                                             else
  -                                             {
  -                                                     delete tempHandlerList;
  -                                                     
tempService->SetRequestFlowHandlers(NULL);
  -                                             }
  -                                             tempHandlerList = NULL;
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "handler")==0)
  -                                                     {
  -                                                             lev2=WSDD_UNKNOWN;
  -                                                             tempHandler = NULL;
  -                                                     }
   
  -                                             break;
  -                                     }
  -                             break;
  -                             case WSDD_RESFLOW:
  -                                     if(strcmp(ch, "responseFlow")==0)
  -                                     {
  -                                             lev1=WSDD_UNKNOWN;
  -                                             if(!tempHandlerList->empty())
  -                                             {
  -                                                     
tempService->SetResponseFlowHandlers(tempHandlerList);
  -                                             }
  -                                             else
  -                                             {
  -                                                     delete tempHandlerList;
  -                                                     
tempService->SetResponseFlowHandlers(NULL);
  -                                             }
  -                                             tempHandlerList= NULL;
  -                                     }
  -                                     switch(lev2)
  -                                     {
  -                                             case WSDD_HANDLER:
  -                                                     if(strcmp(ch, "handler")==0)
  -                                                     {
  -                                                             lev2=WSDD_UNKNOWN;
  -                                                             tempHandler = NULL;
  -                                                     }
  -
  -                                             break;
  -                                     }
  -                             break;
                        }
  -             break;  
  -
  -             case WSDD_TRANSPORT:
  -                     if(strcmp(ch, "transport")==0)
  +                     else
                        {
  -                             protocol=APTOTHER;
  -                             lev0=WSDD_UNKNOWN;
  +                             //error : unknown element type in wsdd file
                        }
   
  -                     switch(lev1)
  -                     {
  -                             case WSDD_REQFLOW:
  -                                     if(strcmp(ch, "requestFlow")==0)
  -                                     {
  -                                             
tempTr->SetRequestFlowHandlers(protocol, tempHandlerList);
  -                                             tempHandlerList = NULL;
  -                                             lev1=WSDD_UNKNOWN;
  -                                     }
  -                             break;
  -
  -                             case WSDD_RESFLOW:
  -
  -                                     if(strcmp(ch, "responseFlow")==0)
  -                                     {
  -                                             
tempTr->SetResponseFlowHandlers(protocol, tempHandlerList);
  -                                             tempHandlerList = NULL;
  -                                             lev1=WSDD_UNKNOWN;
  -                                     }
  -
  -                             break;
  -                     }
  -             break;
  +             }
  +             __REL(&pcLocalName);
        }
  -     REL(&ch);
  +}
  +
  +void WSDDDocument::startPrefixMapping(const XMLCh* const prefix, const XMLCh* const 
uri)
  +{
  +     char* pc; 
  +     pc = __TRC(prefix);
  +     string sPrifix = pc;
  +     __REL(&pc);
  +     pc = __TRC(uri);
  +     string sUri = pc;
  +     __REL(&pc);
  +     m_NsStack[sPrifix] = sUri; //I think the same prifix cannot repeat ???
  +}
   
  +void WSDDDocument::endPrefixMapping(const XMLCh* const prefix)
  +{
  +     char* pc; 
  +     pc = __TRC(prefix);
  +     string sPrifix = pc;
  +     __REL(&pc);
  +     m_NsStack.erase(sPrifix); //I think the same prifix cannot repeat ???
   }
   
  -void  WSDDDocument::characters (const XMLCh *const chars,
  -                               const unsigned int length)
  +void  WSDDDocument::characters (const XMLCh *const chars, const unsigned int length)
   {
        //cout<<"==="<<XMLString::transcode(chars)<<"==="<<endl;
   }
  
  
  
  1.4       +19 -12    xml-axis/c/src/wsdd/WSDDDeployment.h
  
  Index: WSDDDeployment.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDDeployment.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WSDDDeployment.h  6 Aug 2003 10:26:37 -0000       1.3
  +++ WSDDDeployment.h  13 Aug 2003 13:31:42 -0000      1.4
  @@ -83,25 +83,32 @@
   
   class WSDDDeployment  
   {
  +     friend class WSDDDocument;
   public:
  -     string& GetLibName(int nLibId);
  -     int SetServices(WSDDServiceMap * svs);
  -     WSDDService* GetService(string& sServiceName);
        int LoadWSDD(string& sWSDD);
  -     int SetTransport(WSDDTransport * trans);
  -     WSDDTransport* GetTransport();
  -     int SetGlobalRequestFlowHandlers(WSDDHandlerList * greqflow);
  -     WSDDHandlerList* GetGlobalRequestFlowHandlers();
  -     int SetGlobalResponseFlowHandlers(WSDDHandlerList * gresflow);
  -     WSDDHandlerList* GetGlobalResponseFlowHandlers();
  +     int UpdateWSDD(string& sWSDDNew);
  +     const string& GetLibName(int nLibId);
  +     const WSDDService* GetService(const string& sServiceName);
  +     const WSDDHandlerList* GetGlobalRequestFlowHandlers();
  +     const WSDDHandlerList* GetGlobalResponseFlowHandlers();
  +     const WSDDHandlerList* GetTransportRequestFlowHandlers(AXIS_PROTOCOL_TYPE 
protocol);
  +     const WSDDHandlerList* GetTransportResponseFlowHandlers(AXIS_PROTOCOL_TYPE 
protocol);
        const WSDDServiceMap* GetWSDDServiceMap();
        WSDDDeployment();
        virtual ~WSDDDeployment();
  +private: //methods that only be used by WSDDDepolyment.
  +     void SetLibIdMap(map<string, int>* pLibNameIdMap);
  +     int AddService(WSDDService* pService);
  +     int AddHandler(bool bGlobal, bool bRequestFlow, WSDDHandler* pHandler, 
AXIS_PROTOCOL_TYPE protocol=APTHTTP);
  +     int RemoveService(WSDDService* pService);
  +     int RemoveHandler(bool bGlobal, bool bRequestFlow, WSDDHandler* pHandler, 
AXIS_PROTOCOL_TYPE protocol=APTHTTP);
   private:
  -     WSDDServiceMap * m_DeployedServices;
  -     WSDDHandlerList * m_GlobalRequestHandlers;
  -     WSDDHandlerList * m_GlobalResponseHandlers;
  +     WSDDServiceMap* m_DeployedServices;
  +     WSDDHandlerList* m_GlobalRequestHandlers;
  +     WSDDHandlerList* m_GlobalResponseHandlers;
        WSDDTransport* m_pTransportHandlers;
  +     map<string, int>* m_pLibNameIdMap;
  +     string m_sAux;
   };
   
   #endif // 
!defined(AFX_WSDDDEPLOYMENT_H__2B3E0205_06F3_47C1_8D9C_479CBFB8ACC2__INCLUDED_)
  
  
  
  1.5       +69 -29    xml-axis/c/src/wsdd/WSDDDeployment.cpp
  
  Index: WSDDDeployment.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/wsdd/WSDDDeployment.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSDDDeployment.cpp        6 Aug 2003 10:26:37 -0000       1.4
  +++ WSDDDeployment.cpp        13 Aug 2003 13:31:42 -0000      1.5
  @@ -77,6 +77,10 @@
   
   WSDDDeployment::WSDDDeployment()
   {
  +     m_DeployedServices = NULL;
  +     m_sAux = "";
  +     m_pTransportHandlers = NULL;
  +
        m_GlobalResponseHandlers = NULL;
        m_GlobalRequestHandlers = NULL;
   }
  @@ -119,36 +123,18 @@
   
   }
   
  -int WSDDDeployment::SetTransport(WSDDTransport * trans)
  +void WSDDDeployment::SetLibIdMap(map<string, int>* pLibNameIdMap)
   {
  -     m_pTransportHandlers = trans;
  -     return SUCCESS;
  +     m_pLibNameIdMap = pLibNameIdMap;
   }
   
  -WSDDTransport* WSDDDeployment::GetTransport()
  -{
  -     return m_pTransportHandlers;
  -}
   
  -int WSDDDeployment::SetGlobalRequestFlowHandlers(WSDDHandlerList * greqflow)
  -{
  -     m_GlobalRequestHandlers = greqflow;
  -     return SUCCESS;
  -}
  -
  -
  -WSDDHandlerList* WSDDDeployment::GetGlobalRequestFlowHandlers()
  +const WSDDHandlerList* WSDDDeployment::GetGlobalRequestFlowHandlers()
   {
        return m_GlobalRequestHandlers;
   }
   
  -int WSDDDeployment::SetGlobalResponseFlowHandlers(WSDDHandlerList * gresflow)
  -{
  -     m_GlobalResponseHandlers = gresflow;
  -     return SUCCESS;
  -}
  -
  -WSDDHandlerList* WSDDDeployment::GetGlobalResponseFlowHandlers()
  +const WSDDHandlerList* WSDDDeployment::GetGlobalResponseFlowHandlers()
   {
        return m_GlobalResponseHandlers;
   }
  @@ -163,18 +149,19 @@
        return SUCCESS;
   }
   
  -int WSDDDeployment::SetServices(WSDDServiceMap * svs)
  +int WSDDDeployment::UpdateWSDD(string& sWSDDNew)
   {
  -     m_DeployedServices = svs;
  +     //TODO
        return SUCCESS;
   }
   
  -WSDDService* WSDDDeployment::GetService(string &sServiceName)
  +
  +const WSDDService* WSDDDeployment::GetService(const string &sServiceName)
   {
        WSDDServiceMap::iterator iter;
   
        iter = m_DeployedServices->find(sServiceName);
  -     if(iter!=m_DeployedServices->end())
  +     if (iter != m_DeployedServices->end())
        {
                return (*iter).second;
        }
  @@ -189,11 +176,64 @@
        return m_DeployedServices;
   }
   
  +const string& WSDDDeployment::GetLibName(int nLibId)
  +{
  +     for (map<string, int>::iterator it = m_pLibNameIdMap->begin(); it != 
m_pLibNameIdMap->end(); it++)
  +     {
  +             if ((*it).second == nLibId)
  +                     return (*it).first;
  +     }
  +     return m_sAux;
  +}
   
  +int WSDDDeployment::AddService(WSDDService* pService)
  +{
  +     if (!m_DeployedServices) m_DeployedServices = new WSDDServiceMap;
  +     (*m_DeployedServices)[pService->GetServiceName().c_str()] = pService;
  +     return SUCCESS;
  +}            
   
  +int WSDDDeployment::AddHandler(bool bGlobal, bool bRequestFlow, WSDDHandler* 
pHandler, AXIS_PROTOCOL_TYPE protocol)
  +{
  +     if (bGlobal)
  +     {
  +             if (bRequestFlow)
  +             {
  +                     if(!m_GlobalRequestHandlers) m_GlobalRequestHandlers = new 
WSDDHandlerList;
  +                     m_GlobalRequestHandlers->push_back(pHandler);
  +             }
  +             else
  +             {
  +                     if(!m_GlobalResponseHandlers) m_GlobalResponseHandlers = new 
WSDDHandlerList;
  +                     m_GlobalResponseHandlers->push_back(pHandler);
  +             }
  +     }
  +     else //transport
  +     {
  +             if (!m_pTransportHandlers) m_pTransportHandlers = new WSDDTransport();
  +             m_pTransportHandlers->AddHandler(bRequestFlow, protocol, pHandler);
  +     }
  +     return SUCCESS;
  +}
  +
  +const WSDDHandlerList* 
WSDDDeployment::GetTransportRequestFlowHandlers(AXIS_PROTOCOL_TYPE protocol)
  +{
  +     if (!m_pTransportHandlers) return NULL;
  +     return m_pTransportHandlers->GetRequestFlowHandlers(protocol);
  +}
  +
  +const WSDDHandlerList* 
WSDDDeployment::GetTransportResponseFlowHandlers(AXIS_PROTOCOL_TYPE protocol)
  +{
  +     if (!m_pTransportHandlers) return NULL;
  +     return m_pTransportHandlers->GetResponseFlowHandlers(protocol);
  +}
  +
  +int WSDDDeployment::RemoveService(WSDDService* pService)
  +{
  +     return SUCCESS;
  +}
   
  -string& WSDDDeployment::GetLibName(int nLibId)
  +int WSDDDeployment::RemoveHandler(bool bGlobal, bool bRequestFlow, WSDDHandler* 
pHandler, AXIS_PROTOCOL_TYPE protocol)
   {
  -     string xx;
  -     return xx;
  +     return SUCCESS; 
   }
  
  
  

Reply via email to