(file) Return to CIMClientException.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Client

  1 karl  1.14 //%2006////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1  //
  3 karl  1.12 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.9  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.12 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.13 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.14 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 kumpf 1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.3  // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 kumpf 1.1  // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20            // 
 21 kumpf 1.3  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 kumpf 1.1  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 kumpf 1.3  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 kumpf 1.1  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #include <cstdio>
 35            #include "CIMClientException.h"
 36            #include <Pegasus/Common/Tracer.h>
 37 kumpf 1.7  #include <Pegasus/Common/ExceptionRep.h>
 38 kumpf 1.1  
 39            PEGASUS_NAMESPACE_BEGIN
 40            
 41            ////////////////////////////////////////////////////////////////////////////////
 42            //
 43            // CIMClientMalformedHTTPException
 44            //
 45            ////////////////////////////////////////////////////////////////////////////////
 46            
 47            CIMClientMalformedHTTPException::CIMClientMalformedHTTPException(
 48                const String& message)
 49 kumpf 1.5      : Exception(message)
 50 kumpf 1.15 {
 51 kumpf 1.1  }
 52            
 53            
 54            ////////////////////////////////////////////////////////////////////////////////
 55            //
 56 kumpf 1.6  // CIMClientHTTPErrorException
 57 kumpf 1.1  //
 58            ////////////////////////////////////////////////////////////////////////////////
 59            
 60 kumpf 1.7  class CIMClientHTTPErrorExceptionRep : public ExceptionRep
 61            {
 62            public:
 63 kumpf 1.16 
 64                // Note:  The default implementations of the default constructor, copy
 65                // constructor, and assignment operator are used.
 66            
 67 kumpf 1.7      Uint32 httpStatusCode;
 68 kumpf 1.10     String reasonPhrase;
 69 kumpf 1.7      String cimError;
 70 kumpf 1.8      String cimErrorDetail;
 71 kumpf 1.7  };
 72            
 73 kumpf 1.1  static String _makeHTTPErrorMessage(
 74 kumpf 1.15     Uint32 httpStatusCode,
 75 kumpf 1.10     const String& reasonPhrase,
 76 kumpf 1.1      const String& cimError,
 77 kumpf 1.8      const String& cimErrorDetail)
 78 kumpf 1.1  {
 79 kumpf 1.10     String tmp = "HTTP Error (";
 80 kumpf 1.1      char buffer[32];
 81                sprintf(buffer, "%u", httpStatusCode);
 82                tmp.append(buffer);
 83 kumpf 1.10     if (reasonPhrase != String::EMPTY)
 84                {
 85                    tmp.append(" ");
 86                    tmp.append(reasonPhrase);
 87                }
 88 kumpf 1.1      tmp.append(")");
 89            
 90 kumpf 1.8      if ((cimError != String::EMPTY) || (cimErrorDetail != String::EMPTY))
 91 kumpf 1.1      {
 92                    tmp.append(":");
 93                    if (cimError != String::EMPTY)
 94                    {
 95                        tmp.append(" CIMError = \"");
 96                        tmp.append(cimError);
 97                        tmp.append("\"");
 98                    }
 99 kumpf 1.8          if (cimErrorDetail != String::EMPTY)
100 kumpf 1.1          {
101                        tmp.append(" Detail = \"");
102 kumpf 1.8              tmp.append(cimErrorDetail);
103 kumpf 1.1              tmp.append("\"");
104                    }
105                }
106                tmp.append(".");
107                return tmp;
108            }
109            
110 kumpf 1.6  CIMClientHTTPErrorException::CIMClientHTTPErrorException(
111 kumpf 1.15     Uint32 httpStatusCode,
112 kumpf 1.1      const String& cimError,
113 kumpf 1.8      const String& cimErrorDetail)
114 kumpf 1.16     : Exception()
115 kumpf 1.1  {
116 kumpf 1.15     CIMClientHTTPErrorExceptionRep* tmp =
117 kumpf 1.7          new CIMClientHTTPErrorExceptionRep ();
118 kumpf 1.10     tmp->message = _makeHTTPErrorMessage (httpStatusCode, String::EMPTY,
119                                                      cimError, cimErrorDetail);
120                tmp->httpStatusCode = httpStatusCode;
121                tmp->reasonPhrase = String::EMPTY;
122                tmp->cimError = cimError;
123                tmp->cimErrorDetail = cimErrorDetail;
124                _rep = tmp;
125            }
126            
127            CIMClientHTTPErrorException::CIMClientHTTPErrorException(
128 kumpf 1.15     Uint32 httpStatusCode,
129 kumpf 1.10     const String& reasonPhrase,
130                const String& cimError,
131                const String& cimErrorDetail)
132 kumpf 1.16     : Exception()
133 kumpf 1.10 {
134 kumpf 1.15     CIMClientHTTPErrorExceptionRep* tmp =
135 kumpf 1.10         new CIMClientHTTPErrorExceptionRep ();
136                tmp->message = _makeHTTPErrorMessage (httpStatusCode, reasonPhrase,
137                                                      cimError, cimErrorDetail);
138 kumpf 1.7      tmp->httpStatusCode = httpStatusCode;
139 kumpf 1.10     tmp->reasonPhrase = reasonPhrase;
140 kumpf 1.7      tmp->cimError = cimError;
141 kumpf 1.8      tmp->cimErrorDetail = cimErrorDetail;
142 kumpf 1.7      _rep = tmp;
143 kumpf 1.1  }
144            
145 kumpf 1.6  CIMClientHTTPErrorException::CIMClientHTTPErrorException(
146                const CIMClientHTTPErrorException& httpError)
147 kumpf 1.16     : Exception()
148 kumpf 1.7  {
149 kumpf 1.16     _rep = new CIMClientHTTPErrorExceptionRep(
150                    *reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep));
151 kumpf 1.7  }
152            
153            CIMClientHTTPErrorException::~CIMClientHTTPErrorException()
154 kumpf 1.1  {
155            }
156            
157 kumpf 1.16 CIMClientHTTPErrorException& CIMClientHTTPErrorException::operator=(
158                const CIMClientHTTPErrorException& httpError)
159            {
160                if (&httpError != this)
161                {
162                    CIMClientHTTPErrorExceptionRep* left =
163                        reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(this->_rep);
164                    CIMClientHTTPErrorExceptionRep* right =
165                        reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(httpError._rep);
166                    *left = *right;
167                }
168                return *this;
169            }
170            
171 kumpf 1.6  Uint32 CIMClientHTTPErrorException::getCode() const
172 kumpf 1.1  {
173 kumpf 1.7      CIMClientHTTPErrorExceptionRep* rep;
174                rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
175                return rep->httpStatusCode;
176 kumpf 1.1  }
177            
178 kumpf 1.6  String CIMClientHTTPErrorException::getCIMError() const
179 kumpf 1.1  {
180 kumpf 1.7      CIMClientHTTPErrorExceptionRep* rep;
181                rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
182                return rep->cimError;
183 kumpf 1.1  }
184            
185 kumpf 1.8  String CIMClientHTTPErrorException::getCIMErrorDetail() const
186 kumpf 1.1  {
187 kumpf 1.7      CIMClientHTTPErrorExceptionRep* rep;
188                rep = reinterpret_cast<CIMClientHTTPErrorExceptionRep*>(_rep);
189 kumpf 1.8      return rep->cimErrorDetail;
190 kumpf 1.1  }
191            
192            
193            ////////////////////////////////////////////////////////////////////////////////
194            //
195            // CIMClientXmlException
196            //
197            ////////////////////////////////////////////////////////////////////////////////
198            
199            CIMClientXmlException::CIMClientXmlException(const String& message)
200 kumpf 1.5      : Exception(message)
201 kumpf 1.15 {
202 kumpf 1.1  }
203            
204            
205            ////////////////////////////////////////////////////////////////////////////////
206            //
207            // CIMClientResponseException
208            //
209            ////////////////////////////////////////////////////////////////////////////////
210            
211            CIMClientResponseException::CIMClientResponseException(const String& message)
212 kumpf 1.5      : Exception(message)
213 kumpf 1.15 {
214 kumpf 1.1  }
215            
216            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2