(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 dl.meetei 1.15 
 51 a.dunfey  1.1  #include "InteropProvider.h"
 52                #include "InteropProviderUtils.h"
 53                #include "InteropConstants.h"
 54 sahana.prabhakar 1.12 #include <Pegasus/Common/ArrayIterator.h>
 55 dl.meetei        1.15 #include <Pegasus/Common/Pegasus_inl.h>
 56 a.dunfey         1.1  
 57                       PEGASUS_USING_STD;
 58 a.dunfey         1.2  PEGASUS_NAMESPACE_BEGIN
 59 a.dunfey         1.1  
 60                       /*****************************************************************************
 61                        *
 62                        * Implementation of AssociationProvider associators method
 63                        *
 64                        *****************************************************************************/
 65                       void InteropProvider::associators(
 66                           const OperationContext & context,
 67                           const CIMObjectPath & objectName,
 68                           const CIMName & associationClass,
 69                           const CIMName & resultClass,
 70                           const String & role,
 71                           const String & resultRole,
 72                           const Boolean includeQualifiers,
 73                           const Boolean includeClassOrigin,
 74                           const CIMPropertyList & propertyList,
 75                           ObjectResponseHandler & handler)
 76                       {
 77                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 78                                   "InteropProvider::associators()");
 79 a.dunfey         1.2      initProvider();
 80 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
 81 kumpf            1.5          "%s associators. objectName= %s, assocClass= %s resultClass= %s "
 82                                   "role= %s resultRole %s, includeQualifiers= %s, "
 83                                   "includeClassOrigin= %s, PropertyList= %s",
 84 a.dunfey         1.1          thisProvider,
 85                               (const char *)objectName.toString().getCString(),
 86                               (const char *)associationClass.getString().getCString(),
 87                               (const char *)resultClass.getString().getCString(),
 88                               (const char *)role.getCString(),
 89                               (const char *)resultRole.getCString(),
 90                                             boolToString(includeQualifiers),
 91                                             boolToString(includeClassOrigin),
 92 karl             1.14         (const char *)propertyList.toString().getCString()));
 93 a.dunfey         1.1  
 94                           handler.processing();
 95                           String originRole = role;
 96                           String targetRole = resultRole;
 97 s.manicka        1.6      Uint32 numIterations = 1;
 98 a.dunfey         1.1      //
 99                           // The localReferences call retrieves instances of the desired association
100                           // class and sets the originRole and targetRole properties if currently
101                           // empty.
102                           //
103 s.manicka        1.6      if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
104                           {
105                               if (originRole.size() == 0 && targetRole.size() == 0)
106                               {
107                                   originRole = String("Antecedent");
108                                   targetRole = String("Dependent");
109                                   numIterations = 2;
110                               }
111                           }
112                           for (Uint32 i = 0; i < numIterations; ++i)
113                           {
114                               Array<CIMInstance> refs = localReferences(
115 kumpf            1.10             context,
116 s.manicka        1.6              objectName,
117                                   associationClass,
118 kumpf            1.10             originRole,
119                                   targetRole,
120 s.manicka        1.6              CIMPropertyList(),
121                                   resultClass);
122 sahana.prabhakar 1.12 
123                               if( refs.size() )
124 s.manicka        1.6          {
125 sahana.prabhakar 1.12             Array<CIMInstance> refObjs = 
126                                       getReferencedInstances(refs,targetRole,context,propertyList);
127                                   ConstArrayIterator<CIMInstance> refsIterator(refObjs);
128                                   for(Uint32 i = 0; i < refsIterator.size(); i++)
129                                   {
130                                       handler.deliver(refsIterator[i]);
131                                   }
132 s.manicka        1.6          }
133 sahana.prabhakar 1.12 
134 s.manicka        1.6          if (numIterations == 2)
135                               {
136                                   originRole = String("Dependent");
137                                   targetRole = String("Antecedent");
138                               }
139 a.dunfey         1.1      }
140                           handler.complete();
141                       
142                           PEG_METHOD_EXIT();
143                       }
144                       
145                       /*****************************************************************************
146                        *
147                        * Implementation of AssociationProvider associatorNames method
148                        *
149                        *****************************************************************************/
150                       void InteropProvider::associatorNames(
151                           const OperationContext & context,
152                           const CIMObjectPath & objectName,
153                           const CIMName & associationClass,
154                           const CIMName & resultClass,
155                           const String & role,
156                           const String & resultRole,
157                           ObjectPathResponseHandler & handler)
158                       {
159                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
160 a.dunfey         1.1          "InteropProvider::associatorNames()");
161 a.dunfey         1.2      initProvider();
162 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
163 kumpf            1.5          "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s "
164                                   "role= %s resultRole = %s",
165 a.dunfey         1.1          thisProvider,
166                               (const char *)objectName.toString().getCString(),
167                               (const char *)associationClass.getString().getCString(),
168                               (const char *)resultClass.getString().getCString(),
169                               (const char *)role.getCString(),
170 marek            1.3          (const char *)resultRole.getCString()));
171 a.dunfey         1.1  
172                           handler.processing();
173 s.manicka        1.6      String originRole = role;
174 a.dunfey         1.1      String targetRole = resultRole;
175 s.manicka        1.6      Uint32 numIterations = 1;
176 a.dunfey         1.1      //
177                           // The localReferences call retrieves instances of the desired association
178                           // class and sets the originRole and targetRole properties if currently
179                           // empty.
180                           //
181 s.manicka        1.6      if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
182                           {
183                               if (originRole.size() == 0 && targetRole.size() == 0)
184                               {
185                                   originRole = String("Antecedent");
186                                   targetRole = String("Dependent");
187                                   numIterations = 2;
188                               }
189                           }
190                           for (Uint32 i = 0; i < numIterations; ++i)
191                           {
192                               Array<CIMInstance> refs = localReferences(
193 kumpf            1.10             context,
194 s.manicka        1.6              objectName,
195 kumpf            1.10             associationClass,
196                                   originRole,
197                                   targetRole,
198 s.manicka        1.6              CIMPropertyList(),
199                                   resultClass);
200 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
201 s.manicka        1.6          {
202 kumpf            1.7              CIMInstance & currentRef = refs[j];
203 s.manicka        1.6              CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
204                                       currentRef,
205                                       targetRole);
206                                   handler.deliver(currentTarget);
207                               }
208                               if (numIterations == 2)
209                               {
210                                   originRole = String("Dependent");
211                                   targetRole = String("Antecedent");
212                               }
213 a.dunfey         1.1      }
214                           handler.complete();
215                           PEG_METHOD_EXIT();
216                       }
217                       
218                       
219                       /*****************************************************************************
220                        *
221                        * Implementation of AssociationProvider references method
222                        *
223                        *****************************************************************************/
224                       void InteropProvider::references(
225                           const OperationContext & context,
226                           const CIMObjectPath & objectName,
227                           const CIMName & resultClass,
228                           const String & role,
229                           const Boolean includeQualifiers,
230                           const Boolean includeClassOrigin,
231                           const CIMPropertyList & propertyList,
232                           ObjectResponseHandler & handler)
233                       {
234 a.dunfey         1.1      PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
235                               "InteropProvider::references()");
236 a.dunfey         1.2      initProvider();
237 marek            1.3      PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
238 kumpf            1.5          "%s references. objectName= %s, resultClass= %s role= %s "
239                                   "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s",
240 a.dunfey         1.1          thisProvider,
241                               (const char *)objectName.toString().getCString(),
242                               (const char *)resultClass.getString().getCString(),
243                               (const char *)role.getCString(),
244                                             boolToString(includeQualifiers),
245                                             boolToString(includeClassOrigin),
246 karl             1.14         (const char *)propertyList.toString().getCString()));
247 a.dunfey         1.1  
248                           handler.processing();
249                           String tmpRole = role;
250                           String tmpTarget;
251 s.manicka        1.6      Uint32 numIterations = 1;
252 a.dunfey         1.1      //
253                           // Makes call to internal references method to get result, supplying the
254                           // role parameter, but obviously not setting a resultRole/target parameter.
255                           //
256 s.manicka        1.6      if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
257                           {
258                               if (tmpRole.size() == 0)
259                               {
260                                   tmpRole = String("Antecedent");
261                                   tmpTarget = String("Dependent");
262                                   numIterations = 2;
263                               }
264                           }
265                           for (Uint32 i = 0; i < numIterations; ++i)
266                           {
267                               Array<CIMInstance> refs = localReferences(
268 kumpf            1.10             context,
269                                   objectName,
270                                   resultClass,
271                                   tmpRole,
272 s.manicka        1.6              tmpTarget);
273 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
274 s.manicka        1.6          {
275 kumpf            1.7              handler.deliver((CIMObject)refs[j]);
276 s.manicka        1.6          }
277                               if (numIterations == 2)
278                               {
279                                   tmpRole = String("Dependent");
280                                   tmpTarget = String("Antecedent");
281                               }
282                           }
283 a.dunfey         1.1      handler.complete();
284                           PEG_METHOD_EXIT();
285                       }
286                       
287                       /*****************************************************************************
288                        *
289                        * Implementation of AssociationProvider referenceNames method
290                        *
291                        *****************************************************************************/
292                       void InteropProvider::referenceNames(
293                           const OperationContext & context,
294                           const CIMObjectPath & objectName,
295                           const CIMName & resultClass,
296                           const String & role,
297                           ObjectPathResponseHandler & handler)
298                       {
299                           PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
300                               "InteropProvider::referenceNames()");
301 a.dunfey         1.2      initProvider();
302 a.dunfey         1.1      handler.processing();
303                       
304                           String tmpRole = role;
305                           String tmpTarget;
306 s.manicka        1.6      Uint32 numIterations = 1;
307 a.dunfey         1.1      //
308                           // Makes call to internal references method to get result, supplying the
309                           // role parameter, but obviously not setting a resultRole/target parameter.
310                           //
311 s.manicka        1.6      if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
312                           {
313                               if (tmpRole.size() == 0)
314                               {
315                                   tmpRole = String("Antecedent");
316                                   tmpTarget = String("Dependent");
317                                   numIterations = 2;
318                               }
319                           }
320                           for (Uint32 i = 0; i < numIterations; ++i)
321 a.dunfey         1.1      {
322 s.manicka        1.6          Array<CIMInstance> refs = localReferences(
323 kumpf            1.10             context,
324 s.manicka        1.6              objectName,
325                                   resultClass,
326 kumpf            1.10             tmpRole,
327 s.manicka        1.6              tmpTarget);
328 kumpf            1.7          for (Uint32 j = 0, n = refs.size(); j < n; ++j)
329 s.manicka        1.6          {
330 kumpf            1.7              handler.deliver(refs[j].getPath());
331 s.manicka        1.6          }
332                               if (numIterations == 2)
333                               {
334                                   tmpRole = String("Dependent");
335                                   tmpTarget = String("Antecedent");
336                               }
337 a.dunfey         1.1      }
338                       
339                           handler.complete();
340                       
341                           PEG_METHOD_EXIT();
342                       }
343                       
344                       
345 a.dunfey         1.2  PEGASUS_NAMESPACE_END
346 a.dunfey         1.1  // END_OF_FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2