(file) Return to InteropAssociationProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / InteropProvider

  1 martin 1.8 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.9 //
  3 martin 1.8 // Licensed to The Open Group (TOG) under one or more contributor license
  4            // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5            // this work for additional information regarding copyright ownership.
  6            // Each contributor licenses this file to you under the OpenPegasus Open
  7            // Source License; you may not use this file except in compliance with the
  8            // License.
  9 martin 1.9 //
 10 martin 1.8 // Permission is hereby granted, free of charge, to any person obtaining a
 11            // copy of this software and associated documentation files (the "Software"),
 12            // to deal in the Software without restriction, including without limitation
 13            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14            // and/or sell copies of the Software, and to permit persons to whom the
 15            // Software is furnished to do so, subject to the following conditions:
 16 martin 1.9 //
 17 martin 1.8 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.9 //
 20 martin 1.8 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.9 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.8 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23            // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24            // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25            // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26            // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.9 //
 28 martin 1.8 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.5 //
 30 s.manicka 1.6 //%////////////////////////////////////////////////////////////////////////////
 31 a.dunfey  1.1 
 32               
 33               ///////////////////////////////////////////////////////////////////////////////
 34               //  Interop Provider - This provider services those classes from the
 35               //  DMTF Interop schema in an implementation compliant with the SMI-S v1.1
 36               //  Server Profile
 37               //
 38               //  Please see PG_ServerProfile20.mof in the directory
 39 s.manicka 1.6 //  $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for details regarding the
 40 a.dunfey  1.1 //  classes supported by this control provider.
 41               //
 42 kumpf     1.5 //  Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
 43               //  namespace. There is a test on each operation that returns
 44 a.dunfey  1.1 //  the Invalid Class CIMDError
 45               //  This is a control provider and as such uses the Tracer functions
 46               //  for data and function traces.  Since we do not expect high volume
 47               //  use we added a number of traces to help diagnostics.
 48               ///////////////////////////////////////////////////////////////////////////////
 49               
 50               #include "InteropProvider.h"
 51               #include "InteropProviderUtils.h"
 52               #include "InteropConstants.h"
 53 sahana.prabhakar 1.12 #include <Pegasus/Common/ArrayIterator.h>
 54 a.dunfey         1.1  
 55                       PEGASUS_USING_STD;
 56 a.dunfey         1.2  PEGASUS_NAMESPACE_BEGIN
 57 a.dunfey         1.1  
 58                       /*****************************************************************************
 59                        *
 60                        * Implementation of AssociationProvider associators method
 61                        *
 62                        *****************************************************************************/
 63                       void InteropProvider::associators(
 64                           const OperationContext & context,
 65                           const CIMObjectPath & objectName,
 66                           const CIMName & associationClass,
 67                           const CIMName & resultClass,
 68                           const String & role,
 69                           const String & resultRole,
 70                           const Boolean includeQualifiers,
 71                           const Boolean includeClassOrigin,
 72                           const CIMPropertyList & propertyList,
 73                           ObjectResponseHandler & handler)
 74                       {
 75                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 76                                   "InteropProvider::associators()");
 77 a.dunfey         1.2      initProvider();
 78 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
 79 kumpf            1.5          "%s associators. objectName= %s, assocClass= %s resultClass= %s "
 80                                   "role= %s resultRole %s, includeQualifiers= %s, "
 81                                   "includeClassOrigin= %s, PropertyList= %s",
 82 a.dunfey         1.1          thisProvider,
 83                               (const char *)objectName.toString().getCString(),
 84                               (const char *)associationClass.getString().getCString(),
 85                               (const char *)resultClass.getString().getCString(),
 86                               (const char *)role.getCString(),
 87                               (const char *)resultRole.getCString(),
 88                                             boolToString(includeQualifiers),
 89                                             boolToString(includeClassOrigin),
 90 marek            1.3          (const char *)propertyListToString(propertyList).getCString()));
 91 a.dunfey         1.1  
 92                           handler.processing();
 93                           String originRole = role;
 94                           String targetRole = resultRole;
 95 s.manicka        1.6      Uint32 numIterations = 1;
 96 a.dunfey         1.1      //
 97                           // The localReferences call retrieves instances of the desired association
 98                           // class and sets the originRole and targetRole properties if currently
 99                           // empty.
100                           //
101 s.manicka        1.6      if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
102                           {
103                               if (originRole.size() == 0 && targetRole.size() == 0)
104                               {
105                                   originRole = String("Antecedent");
106                                   targetRole = String("Dependent");
107                                   numIterations = 2;
108                               }
109                           }
110                           for (Uint32 i = 0; i < numIterations; ++i)
111                           {
112                               Array<CIMInstance> refs = localReferences(
113 kumpf            1.10             context,
114 s.manicka        1.6              objectName,
115                                   associationClass,
116 kumpf            1.10             originRole,
117                                   targetRole,
118 s.manicka        1.6              CIMPropertyList(),
119                                   resultClass);
120 sahana.prabhakar 1.12 
121                               if( refs.size() )
122 s.manicka        1.6          {
123 sahana.prabhakar 1.12             Array<CIMInstance> refObjs = 
124                                       getReferencedInstances(refs,targetRole,context,propertyList);
125                                   ConstArrayIterator<CIMInstance> refsIterator(refObjs);
126                                   for(Uint32 i = 0; i < refsIterator.size(); i++)
127                                   {
128                                       handler.deliver(refsIterator[i]);
129                                   }
130 s.manicka        1.6          }
131 sahana.prabhakar 1.12 
132 s.manicka        1.6          if (numIterations == 2)
133                               {
134                                   originRole = String("Dependent");
135                                   targetRole = String("Antecedent");
136                               }
137 a.dunfey         1.1      }
138                           handler.complete();
139                       
140                           PEG_METHOD_EXIT();
141                       }
142                       
143                       /*****************************************************************************
144                        *
145                        * Implementation of AssociationProvider associatorNames method
146                        *
147                        *****************************************************************************/
148                       void InteropProvider::associatorNames(
149                           const OperationContext & context,
150                           const CIMObjectPath & objectName,
151                           const CIMName & associationClass,
152                           const CIMName & resultClass,
153                           const String & role,
154                           const String & resultRole,
155                           ObjectPathResponseHandler & handler)
156                       {
157                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
158 a.dunfey         1.1          "InteropProvider::associatorNames()");
159 a.dunfey         1.2      initProvider();
160 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
161 kumpf            1.5          "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s "
162                                   "role= %s resultRole = %s",
163 a.dunfey         1.1          thisProvider,
164                               (const char *)objectName.toString().getCString(),
165                               (const char *)associationClass.getString().getCString(),
166                               (const char *)resultClass.getString().getCString(),
167                               (const char *)role.getCString(),
168 marek            1.3          (const char *)resultRole.getCString()));
169 a.dunfey         1.1  
170                           handler.processing();
171 s.manicka        1.6      String originRole = role;
172 a.dunfey         1.1      String targetRole = resultRole;
173 s.manicka        1.6      Uint32 numIterations = 1;
174 a.dunfey         1.1      //
175                           // The localReferences call retrieves instances of the desired association
176                           // class and sets the originRole and targetRole properties if currently
177                           // empty.
178                           //
179 s.manicka        1.6      if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
180                           {
181                               if (originRole.size() == 0 && targetRole.size() == 0)
182                               {
183                                   originRole = String("Antecedent");
184                                   targetRole = String("Dependent");
185                                   numIterations = 2;
186                               }
187                           }
188                           for (Uint32 i = 0; i < numIterations; ++i)
189                           {
190                               Array<CIMInstance> refs = localReferences(
191 kumpf            1.10             context,
192 s.manicka        1.6              objectName,
193 kumpf            1.10             associationClass,
194                                   originRole,
195                                   targetRole,
196 s.manicka        1.6              CIMPropertyList(),
197                                   resultClass);
198 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
199 s.manicka        1.6          {
200 kumpf            1.7              CIMInstance & currentRef = refs[j];
201 s.manicka        1.6              CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
202                                       currentRef,
203                                       targetRole);
204                                   handler.deliver(currentTarget);
205                               }
206                               if (numIterations == 2)
207                               {
208                                   originRole = String("Dependent");
209                                   targetRole = String("Antecedent");
210                               }
211 a.dunfey         1.1      }
212                           handler.complete();
213                           PEG_METHOD_EXIT();
214                       }
215                       
216                       
217                       /*****************************************************************************
218                        *
219                        * Implementation of AssociationProvider references method
220                        *
221                        *****************************************************************************/
222                       void InteropProvider::references(
223                           const OperationContext & context,
224                           const CIMObjectPath & objectName,
225                           const CIMName & resultClass,
226                           const String & role,
227                           const Boolean includeQualifiers,
228                           const Boolean includeClassOrigin,
229                           const CIMPropertyList & propertyList,
230                           ObjectResponseHandler & handler)
231                       {
232 a.dunfey         1.1      PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
233                               "InteropProvider::references()");
234 a.dunfey         1.2      initProvider();
235 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
236 kumpf            1.5          "%s references. objectName= %s, resultClass= %s role= %s "
237                                   "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s",
238 a.dunfey         1.1          thisProvider,
239                               (const char *)objectName.toString().getCString(),
240                               (const char *)resultClass.getString().getCString(),
241                               (const char *)role.getCString(),
242                                             boolToString(includeQualifiers),
243                                             boolToString(includeClassOrigin),
244 marek            1.3          (const char *)propertyListToString(propertyList).getCString()));
245 a.dunfey         1.1  
246                           handler.processing();
247                           String tmpRole = role;
248                           String tmpTarget;
249 s.manicka        1.6      Uint32 numIterations = 1;
250 a.dunfey         1.1      //
251                           // Makes call to internal references method to get result, supplying the
252                           // role parameter, but obviously not setting a resultRole/target parameter.
253                           //
254 s.manicka        1.6      if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
255                           {
256                               if (tmpRole.size() == 0)
257                               {
258                                   tmpRole = String("Antecedent");
259                                   tmpTarget = String("Dependent");
260                                   numIterations = 2;
261                               }
262                           }
263                           for (Uint32 i = 0; i < numIterations; ++i)
264                           {
265                               Array<CIMInstance> refs = localReferences(
266 kumpf            1.10             context,
267                                   objectName,
268                                   resultClass,
269                                   tmpRole,
270 s.manicka        1.6              tmpTarget);
271 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
272 s.manicka        1.6          {
273 kumpf            1.7              handler.deliver((CIMObject)refs[j]);
274 s.manicka        1.6          }
275                               if (numIterations == 2)
276                               {
277                                   tmpRole = String("Dependent");
278                                   tmpTarget = String("Antecedent");
279                               }
280                           }
281 a.dunfey         1.1      handler.complete();
282                           PEG_METHOD_EXIT();
283                       }
284                       
285                       /*****************************************************************************
286                        *
287                        * Implementation of AssociationProvider referenceNames method
288                        *
289                        *****************************************************************************/
290                       void InteropProvider::referenceNames(
291                           const OperationContext & context,
292                           const CIMObjectPath & objectName,
293                           const CIMName & resultClass,
294                           const String & role,
295                           ObjectPathResponseHandler & handler)
296                       {
297                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
298                               "InteropProvider::referenceNames()");
299 a.dunfey         1.2      initProvider();
300 a.dunfey         1.1      handler.processing();
301                       
302                           String tmpRole = role;
303                           String tmpTarget;
304 s.manicka        1.6      Uint32 numIterations = 1;
305 a.dunfey         1.1      //
306                           // Makes call to internal references method to get result, supplying the
307                           // role parameter, but obviously not setting a resultRole/target parameter.
308                           //
309 s.manicka        1.6      if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
310                           {
311                               if (tmpRole.size() == 0)
312                               {
313                                   tmpRole = String("Antecedent");
314                                   tmpTarget = String("Dependent");
315                                   numIterations = 2;
316                               }
317                           }
318                           for (Uint32 i = 0; i < numIterations; ++i)
319 a.dunfey         1.1      {
320 s.manicka        1.6          Array<CIMInstance> refs = localReferences(
321 kumpf            1.10             context,
322 s.manicka        1.6              objectName,
323                                   resultClass,
324 kumpf            1.10             tmpRole,
325 s.manicka        1.6              tmpTarget);
326 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
327 s.manicka        1.6          {
328 kumpf            1.7              handler.deliver(refs[j].getPath());
329 s.manicka        1.6          }
330                               if (numIterations == 2)
331                               {
332                                   tmpRole = String("Dependent");
333                                   tmpTarget = String("Antecedent");
334                               }
335 a.dunfey         1.1      }
336                       
337                           handler.complete();
338                       
339                           PEG_METHOD_EXIT();
340                       }
341                       
342                       
343 a.dunfey         1.2  PEGASUS_NAMESPACE_END
344 a.dunfey         1.1  // END_OF_FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2