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

  1 a.dunfey 1.1 //%2006////////////////////////////////////////////////////////////////////////
  2              //
  3              // 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              // IBM Corp.; EMC Corporation, The Open Group.
  7              // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8              // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9              // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10              // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11              // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12              // EMC Corporation; Symantec Corporation; The Open Group.
 13              //
 14              // Permission is hereby granted, free of charge, to any person obtaining a copy
 15              // 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              // 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              // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 a.dunfey 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              // 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              // 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 s.manicka 1.5.4.1 //=============================================================================
 31 kumpf     1.5     //
 32 s.manicka 1.5.4.1 //%////////////////////////////////////////////////////////////////////////////
 33 a.dunfey  1.1     
 34                   
 35                   ///////////////////////////////////////////////////////////////////////////////
 36                   //  Interop Provider - This provider services those classes from the
 37                   //  DMTF Interop schema in an implementation compliant with the SMI-S v1.1
 38                   //  Server Profile
 39                   //
 40                   //  Please see PG_ServerProfile20.mof in the directory
 41 s.manicka 1.5.4.1 //  $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for details regarding the
 42 a.dunfey  1.1     //  classes supported by this control provider.
 43                   //
 44 kumpf     1.5     //  Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
 45                   //  namespace. There is a test on each operation that returns
 46 a.dunfey  1.1     //  the Invalid Class CIMDError
 47                   //  This is a control provider and as such uses the Tracer functions
 48                   //  for data and function traces.  Since we do not expect high volume
 49                   //  use we added a number of traces to help diagnostics.
 50                   ///////////////////////////////////////////////////////////////////////////////
 51                   
 52                   #include "InteropProvider.h"
 53                   #include "InteropProviderUtils.h"
 54                   #include "InteropConstants.h"
 55                   
 56                   PEGASUS_USING_STD;
 57 a.dunfey  1.2     PEGASUS_NAMESPACE_BEGIN
 58 a.dunfey  1.1     
 59                   /*****************************************************************************
 60                    *
 61                    * Implementation of AssociationProvider associators method
 62                    *
 63                    *****************************************************************************/
 64                   void InteropProvider::associators(
 65                       const OperationContext & context,
 66                       const CIMObjectPath & objectName,
 67                       const CIMName & associationClass,
 68                       const CIMName & resultClass,
 69                       const String & role,
 70                       const String & resultRole,
 71                       const Boolean includeQualifiers,
 72                       const Boolean includeClassOrigin,
 73                       const CIMPropertyList & propertyList,
 74                       ObjectResponseHandler & handler)
 75                   {
 76                       PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 77                               "InteropProvider::associators()");
 78 a.dunfey  1.2         initProvider();
 79 marek     1.3         PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
 80 kumpf     1.5             "%s associators. objectName= %s, assocClass= %s resultClass= %s "
 81                               "role= %s resultRole %s, includeQualifiers= %s, "
 82                               "includeClassOrigin= %s, PropertyList= %s",
 83 a.dunfey  1.1             thisProvider,
 84                           (const char *)objectName.toString().getCString(),
 85                           (const char *)associationClass.getString().getCString(),
 86                           (const char *)resultClass.getString().getCString(),
 87                           (const char *)role.getCString(),
 88                           (const char *)resultRole.getCString(),
 89                                         boolToString(includeQualifiers),
 90                                         boolToString(includeClassOrigin),
 91 marek     1.3             (const char *)propertyListToString(propertyList).getCString()));
 92 a.dunfey  1.1     
 93                       handler.processing();
 94                       String originRole = role;
 95                       String targetRole = resultRole;
 96 s.manicka 1.5.4.1     Uint32 numIterations = 1;
 97 a.dunfey  1.1         //
 98                       // The localReferences call retrieves instances of the desired association
 99                       // class and sets the originRole and targetRole properties if currently
100                       // empty.
101                       //
102 s.manicka 1.5.4.1     if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
103                       {
104                           if (originRole.size() == 0 && targetRole.size() == 0)
105                           {
106                               originRole = String("Antecedent");
107                               targetRole = String("Dependent");
108                               numIterations = 2;
109                           }
110                       }
111                       for (Uint32 i = 0; i < numIterations; ++i)
112                       {
113                           Array<CIMInstance> refs = localReferences(
114                               context, 
115                               objectName,
116                               associationClass,
117                               originRole, 
118                               targetRole, 
119                               CIMPropertyList(),
120                               resultClass);
121                           for (Uint32 i = 0, n = refs.size(); i < n; ++i)
122                           {
123 s.manicka 1.5.4.1             CIMInstance & currentRef = refs[i];
124                               // Retrieve the "other side" of the association
125                               CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
126                                   currentRef, 
127                                   targetRole);
128                               CIMInstance tmpInstance = localGetInstance(
129                                   context, 
130                                   currentTarget,
131                                   propertyList);
132                               tmpInstance.setPath(currentTarget);
133                               handler.deliver(tmpInstance);
134                           }
135                           if (numIterations == 2)
136                           {
137                               originRole = String("Dependent");
138                               targetRole = String("Antecedent");
139                           }
140 a.dunfey  1.1         }
141                       handler.complete();
142                   
143                       PEG_METHOD_EXIT();
144                   }
145                   
146                   /*****************************************************************************
147                    *
148                    * Implementation of AssociationProvider associatorNames method
149                    *
150                    *****************************************************************************/
151                   void InteropProvider::associatorNames(
152                       const OperationContext & context,
153                       const CIMObjectPath & objectName,
154                       const CIMName & associationClass,
155                       const CIMName & resultClass,
156                       const String & role,
157                       const String & resultRole,
158                       ObjectPathResponseHandler & handler)
159                   {
160                       PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
161 a.dunfey  1.1             "InteropProvider::associatorNames()");
162 a.dunfey  1.2         initProvider();
163 marek     1.3         PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
164 kumpf     1.5             "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s "
165                               "role= %s resultRole = %s",
166 a.dunfey  1.1             thisProvider,
167                           (const char *)objectName.toString().getCString(),
168                           (const char *)associationClass.getString().getCString(),
169                           (const char *)resultClass.getString().getCString(),
170                           (const char *)role.getCString(),
171 marek     1.3             (const char *)resultRole.getCString()));
172 a.dunfey  1.1     
173                       handler.processing();
174 s.manicka 1.5.4.1     String originRole = role;
175 a.dunfey  1.1         String targetRole = resultRole;
176 s.manicka 1.5.4.1     Uint32 numIterations = 1;
177 a.dunfey  1.1         //
178                       // The localReferences call retrieves instances of the desired association
179                       // class and sets the originRole and targetRole properties if currently
180                       // empty.
181                       //
182 s.manicka 1.5.4.1     if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
183                       {
184                           if (originRole.size() == 0 && targetRole.size() == 0)
185                           {
186                               originRole = String("Antecedent");
187                               targetRole = String("Dependent");
188                               numIterations = 2;
189                           }
190                       }
191                       for (Uint32 i = 0; i < numIterations; ++i)
192                       {
193                           Array<CIMInstance> refs = localReferences(
194                               context,  
195                               objectName,
196                               associationClass, 
197                               originRole, 
198                               targetRole, 
199                               CIMPropertyList(),
200                               resultClass);
201                           for (Uint32 i = 0, n = refs.size(); i < n; ++i)
202                           {
203 s.manicka 1.5.4.1             CIMInstance & currentRef = refs[i];
204                               CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
205                                   currentRef,
206                                   targetRole);
207                               handler.deliver(currentTarget);
208                           }
209                           if (numIterations == 2)
210                           {
211                               originRole = String("Dependent");
212                               targetRole = String("Antecedent");
213                           }
214 a.dunfey  1.1         }
215                       handler.complete();
216                       PEG_METHOD_EXIT();
217                   }
218                   
219                   
220                   /*****************************************************************************
221                    *
222                    * Implementation of AssociationProvider references method
223                    *
224                    *****************************************************************************/
225                   void InteropProvider::references(
226                       const OperationContext & context,
227                       const CIMObjectPath & objectName,
228                       const CIMName & resultClass,
229                       const String & role,
230                       const Boolean includeQualifiers,
231                       const Boolean includeClassOrigin,
232                       const CIMPropertyList & propertyList,
233                       ObjectResponseHandler & handler)
234                   {
235 a.dunfey  1.1         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
236                           "InteropProvider::references()");
237 a.dunfey  1.2         initProvider();
238 marek     1.3         PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
239 kumpf     1.5             "%s references. objectName= %s, resultClass= %s role= %s "
240                               "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s",
241 a.dunfey  1.1             thisProvider,
242                           (const char *)objectName.toString().getCString(),
243                           (const char *)resultClass.getString().getCString(),
244                           (const char *)role.getCString(),
245                                         boolToString(includeQualifiers),
246                                         boolToString(includeClassOrigin),
247 marek     1.3             (const char *)propertyListToString(propertyList).getCString()));
248 a.dunfey  1.1     
249                       handler.processing();
250                       String tmpRole = role;
251                       String tmpTarget;
252 s.manicka 1.5.4.1     Uint32 numIterations = 1;
253 a.dunfey  1.1         //
254                       // Makes call to internal references method to get result, supplying the
255                       // role parameter, but obviously not setting a resultRole/target parameter.
256                       //
257 s.manicka 1.5.4.1     if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
258                       {
259                           if (tmpRole.size() == 0)
260                           {
261                               tmpRole = String("Antecedent");
262                               tmpTarget = String("Dependent");
263                               numIterations = 2;
264                           }
265                       }
266                       for (Uint32 i = 0; i < numIterations; ++i)
267                       {
268                           Array<CIMInstance> refs = localReferences(
269                               context, 
270                               objectName, 
271                               resultClass, 
272                               tmpRole, 
273                               tmpTarget);
274                           for (Uint32 i = 0, n = refs.size(); i < n; ++i)
275                           {
276                               handler.deliver((CIMObject)refs[i]);
277                           }
278 s.manicka 1.5.4.1         if (numIterations == 2)
279                           {
280                               tmpRole = String("Dependent");
281                               tmpTarget = String("Antecedent");
282                           }
283                       }
284 a.dunfey  1.1         handler.complete();
285                       PEG_METHOD_EXIT();
286                   }
287                   
288                   /*****************************************************************************
289                    *
290                    * Implementation of AssociationProvider referenceNames method
291                    *
292                    *****************************************************************************/
293                   void InteropProvider::referenceNames(
294                       const OperationContext & context,
295                       const CIMObjectPath & objectName,
296                       const CIMName & resultClass,
297                       const String & role,
298                       ObjectPathResponseHandler & handler)
299                   {
300                       PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
301                           "InteropProvider::referenceNames()");
302 a.dunfey  1.2         initProvider();
303 a.dunfey  1.1         handler.processing();
304                   
305                       String tmpRole = role;
306                       String tmpTarget;
307 s.manicka 1.5.4.1     Uint32 numIterations = 1;
308 a.dunfey  1.1         //
309                       // Makes call to internal references method to get result, supplying the
310                       // role parameter, but obviously not setting a resultRole/target parameter.
311                       //
312 s.manicka 1.5.4.1     if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
313                       {
314                           if (tmpRole.size() == 0)
315                           {
316                               tmpRole = String("Antecedent");
317                               tmpTarget = String("Dependent");
318                               numIterations = 2;
319                           }
320                       }
321                       for (Uint32 i = 0; i < numIterations; ++i)
322 a.dunfey  1.1         {
323 s.manicka 1.5.4.1         Array<CIMInstance> refs = localReferences(
324                               context, 
325                               objectName,
326                               resultClass,
327                               tmpRole, 
328                               tmpTarget);
329                           for (Uint32 i = 0, n = refs.size(); i < n; ++i)
330                           {
331                               handler.deliver(refs[i].getPath());
332                           }
333                           if (numIterations == 2)
334                           {
335                               tmpRole = String("Dependent");
336                               tmpTarget = String("Antecedent");
337                           }
338 a.dunfey  1.1         }
339                   
340                       handler.complete();
341                   
342                       PEG_METHOD_EXIT();
343                   }
344                   
345                   
346 a.dunfey  1.2     PEGASUS_NAMESPACE_END
347 a.dunfey  1.1     // END_OF_FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2