Пример #1
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::performInitialCheck
//
// ///////////////////////////////////////////////////////////////////////////
void WMIClassProvider::performInitialCheck(const CIMClass& newClass,
										   Boolean updateClass)
{
	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WmiClassProvider::performInitialCheck()");
	
	// check if class already exists, just for createClass calls
	if ((classAlreadyExists(newClass.getClassName().getString())) && (!updateClass))
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::performInitialCheck - class already exists, throw CIM_ERR_ALREADY_EXISTS exception");

		throw CIMException(CIM_ERR_ALREADY_EXISTS);
	}

	// check if newClass has a superclass
	if (newClass.getSuperClassName().getString() != String::EMPTY)
	{
		// verifies if the superclass exists
		if (!classAlreadyExists(newClass.getSuperClassName().getString()))
		{
			// superclass doesn't exist, trace and throw error
			String tmp = newClass.getSuperClassName().getString();

			Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
				"WMIClassProvider::performInitialCheck() - the superclass %s wasn't yet registered", tmp.getCString()); 

			throw CIMException(CIM_ERR_INVALID_SUPERCLASS);
		}
	}

	PEG_METHOD_EXIT();

	return;
}
Пример #2
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::createMethods  create methods 
//									  
/////////////////////////////////////////////////////////////////////////////
void WMIClassProvider::createMethods(const CIMClass& newClass,
								     IWbemServices *pServices,
									 IWbemClassObject *pNewClass)
{

	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WMIClassProvider::createMethods ()");

	// create all methods
	for (Uint32 i = 0; i < newClass.getMethodCount(); i++)
	{
		CIMConstMethod method;
		method = newClass.getMethod(i);

		try 
		{
			createMethod(method, pServices, pNewClass);
		}
		catch (CIMException&)
		{
			throw;
		}
	}

	PEG_METHOD_EXIT();

	return;
}
Пример #3
0
Boolean ProcessValueObjectElement(CIMRepository& repository, XmlParser& parser)
{
    XmlEntry entry;

    if (!XmlReader::testStartTag(parser, entry, "VALUE.OBJECT"))
	return false;

    CIMClass cimClass;
    CIMQualifierDecl qualifierDecl;

    if (XmlReader::getClassElement(parser, cimClass))
    {
	cout << "Creating: class ";
	cout << cimClass.getClassName() << endl;

	repository.createClass(CIMV2_NAMESPACE, cimClass);
	repository.createClass(ROOT_NAMESPACE, cimClass);
    }
    else if (XmlReader::getQualifierDeclElement(parser, qualifierDecl))
    {
	cout << "Creating: qualifier ";
	cout << qualifierDecl.getName() << endl;

	repository.setQualifier(CIMV2_NAMESPACE, qualifierDecl);
	repository.setQualifier(ROOT_NAMESPACE, qualifierDecl);
    }

    XmlReader::expectEndTag(parser, "VALUE.OBJECT");

    return true;
}
Пример #4
0
/*
    Build an instance of the test class
*/
CIMInstance buildInstance(CIMClient& client, String& instanceId)
{
    CIMClass cl = client.getClass(PROVIDERNS, TEST_CLASS);
    CIMInstance inst = cl.buildInstance(false, false, CIMPropertyList());
    setPropertyValue(inst, "Id", CIMValue(instanceId));

    return inst;
}
Пример #5
0
void IndicationFormatter::validateTextFormatParameters (
    const CIMPropertyList & propertyList,
    const CIMClass & indicationClass,
    const Array<String> & textFormatParams)
{
    PEG_METHOD_ENTER (TRC_IND_FORMATTER,
	"IndicationFormatter::validateTextFormatParameters");

    Array <String> indicationClassProperties;
    String exceptionStr;

    // All the properties are selected
    if (propertyList.isNull ())
    {
       for (Uint32 i = 0; i < indicationClass.getPropertyCount (); i++)
       {
	   indicationClassProperties.append(
	       indicationClass.getProperty (i).getName ().getString());
       }
    }
    // partial properties are selected
    else
    {
        Array<CIMName> propertyNames = propertyList.getPropertyNameArray();

	for (Uint32 j = 0; j < propertyNames.size(); j++)
	{
	    indicationClassProperties.append(propertyNames[j].getString());
	}
    }

    // check if the textFormatParams is contained in the
    // indicationClassProperties
    for (Uint32 k = 0; k < textFormatParams.size(); k++)
    {
        if (!Contains(indicationClassProperties, textFormatParams[k]))
	{
	    // The property name in TextFormatParameters is not
	    // included in the select clause of the associated filter query
	    MessageLoaderParms parms(
	    "IndicationFormatter.IndicationFormatter._MSG_MISS_MATCHED_PROPERTY_NAME",
	    "The property name $0 in $1 does not match the properties in the select clause",
	    textFormatParams[k],
	    _PROPERTY_TEXTFORMATPARAMETERS.getString());

	    exceptionStr.append(MessageLoader::getMessage(parms));

	    PEG_METHOD_EXIT();
	    throw PEGASUS_CIM_EXCEPTION (
		CIM_ERR_INVALID_PARAMETER, exceptionStr);
	}
    }

    PEG_METHOD_EXIT();
}
Пример #6
0
int _getProperty(const int argc, const char **argv)
{
  // need to get class definition to find keys
  // first arg is name of class
  CIMClass cldef;
  try
  {
    cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] );
  }
  catch(Exception& e)
  {
    cerr << /* "getProperty: " << */ e.getMessage() << endl;
    return 1;
  }

  CIMObjectPath ref;
  CIMInstance inst;

  // If next arg is "ask", prompt user for keys
  if (String::equalNoCase("ask",argv[1])) ref = 
            CIMObjectPath(String::EMPTY,
                          PEGASUS_NAMESPACENAME_INTEROP,
                          argv[0],
                          _inputInstanceKeys(cldef) );

  // else if the next arg and is "list", enumInstNames and print
  // a list from which user will select  
  else if (String::equalNoCase("list",argv[1]))
  {
    ref = _selectInstance( argv[0] );
    if (ref.identical(CIMObjectPath())) return 0;
  }

  // else there's another arg but it's invalid
  else
  {
    return 1;
  }

  CIMProperty pDef;
  // if no more args, display property names and ask which
  if (argc < 3)
  {
    int n;
    for (n=0; n<cldef.getPropertyCount(); n++)
      cerr << n+1 << ": " << cldef.getProperty(n).getName().getString() << endl;
    cerr << "Property (1.." << cldef.getPropertyCount() << ")? ";
    cin >> n;
    pDef = cldef.getProperty(n-1);
  }
PEGASUS_NAMESPACE_BEGIN

//
// Given the two references in the association, this function creates an
// instance of the PG_ElementConformsToProfile class.
//
CIMInstance buildElementConformsToProfile(
    const CIMObjectPath & currentProfile,
    const CIMObjectPath & currentElement,
    const CIMClass & elementConformsClass)
{
    Array<CIMName> elementPropArray;
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD);
    elementPropArray.append(
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT);
    CIMPropertyList elementPropList(elementPropArray);

    CIMInstance tmpInstance =
        elementConformsClass.buildInstance(false, false,
            elementPropList);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD,
        currentProfile);
    setPropertyValue(tmpInstance,
        ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT,
        currentElement);
    tmpInstance.setPath(tmpInstance.buildPath(
        elementConformsClass));
    return tmpInstance;
}
Пример #8
0
static bool _testBooleanQualifier(const CIMClass& cc, const CIMName& name)
{
    Uint32 pos = cc.findQualifier(name);

    if (pos == PEG_NOT_FOUND)
        return false;

    CIMConstQualifier cq = cc.getQualifier(pos);

    if (cq.getType() != CIMTYPE_BOOLEAN || cq.isArray())
        return false;

    Boolean x;
    cq.getValue().get(x);
    return x;
}
Пример #9
0
void CIMPropertyRep::resolve(
    DeclContext* declContext,
    const CIMNamespaceName& nameSpace,
    Boolean isInstancePart,
    Boolean propagateQualifiers)
{
    CIMQualifierList dummy;

    CIMScope scope = CIMScope::PROPERTY;

    if (_value.getType() == CIMTYPE_REFERENCE)
    {
        scope = CIMScope::REFERENCE;

        // Validate that the reference class exists.

        CIMName referenceClassName;
        if (_referenceClassName.isNull())
        {
            CIMObjectPath reference;
            _value.get(reference);
            referenceClassName = reference.getClassName();
        }
        else
        {
            referenceClassName = _referenceClassName;
        }

        CIMClass referenceClass = declContext->lookupClass(
            nameSpace, referenceClassName);
        if (referenceClass.isUninitialized())
        {
            throw PEGASUS_CIM_EXCEPTION(
                CIM_ERR_INVALID_PARAMETER, referenceClassName.getString());
        }
    }

    _qualifiers.resolve(
        declContext,
        nameSpace,
        scope,
        isInstancePart,
        dummy,
        propagateQualifiers);
}
Пример #10
0
void CIMtoXML(CIMClass const& cc, ostream& ostr)
{
	if (cc.getName().empty())
	{
		OW_THROWCIMMSG(CIMException::FAILED, "class must have name");
	}
	ostr << "<CLASS NAME=\"";
	ostr << cc.getName();
	if (!cc.getSuperClass().empty())
	{
		ostr << "\" SUPERCLASS=\"";
		ostr << cc.getSuperClass();
	}

	ostr << "\">";
	const CIMQualifierArray& ccquals = cc.getQualifiers();
	for (size_t i = 0; i < ccquals.size(); i++)
	{
		CIMtoXML(ccquals[i], ostr);
	}
	const CIMPropertyArray& props = cc.getAllProperties();
	for (size_t i = 0; i < props.size(); i++)
	{
		CIMtoXML(props[i], ostr);
	}
	const CIMMethodArray& meths = cc.getAllMethods();
	for (size_t i = 0; i < meths.size(); i++)
	{
		CIMtoXML(meths[i], ostr);
	}
	ostr << "</CLASS>";
}
Пример #11
0
SCMOClass CIMServer::_scmoClassCache_GetClass(
    const CIMNamespaceName& nameSpace,
    const CIMName& className)
{
    CIMClass cc;

    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_scmoClassCache_GetClass()");
    try
    {
        cc = _cimserver->_repository->getClass(
            nameSpace,
            className,
            false, // localOnly
            true, // includeQualifiers
            true, // includeClassOrigin
            CIMPropertyList());
    }
    catch (Exception& e)
    {
        PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
                   "The class '%s' in the name space '%s' was not found. "
                       "The repository throws the following exception: %s",
                   (const char*)className.getString().getCString(),
                   (const char*)nameSpace.getString().getCString(),
                   (const char*)e.getMessage().getCString()));
        // Return a empty class.
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }

    if (cc.isUninitialized())
    {
        // The requested class was not found !
        // Return a empty class.
        PEG_METHOD_EXIT();
        return SCMOClass("","");
    }
    PEG_METHOD_EXIT();
    return SCMOClass(cc,(const char*)nameSpace.getString().getCString());

}
Пример #12
0
CIMClass LocalRepository::getClass(
    const String & nameSpace,
    const String & className,
    Boolean includeQualifiers,
    Boolean includeClassOrigin,
    const CIMPropertyList & propertyList)
{
    // create a duplicate object before modifying
    CIMClass cimClass = context->lookupClass("test_namespace", className).clone();

    if(!includeQualifiers)
    {
        // remove qualifiers from class
        for(Uint32 i = 0, n = cimClass.getQualifierCount(); i < n; i++)
        {
            cimClass.removeQualifier(i);
        }

        // remove qualifiers from properties
        for(Uint32 i = 0, n = cimClass.getPropertyCount(); i < n; i++)
        {
            CIMProperty cimProperty = cimClass.getProperty(i);

            for(Uint32 j = 0, m = cimProperty.getQualifierCount(); j < m; j++)
            {
                cimProperty.removeQualifier(j);
            }
        }
    }

    if(!includeClassOrigin)
    {
        // remove class origin
        for(Uint32 i = 0, n = cimClass.getPropertyCount(); i < n; i++)
        {
            cimClass.getProperty(i).setClassOrigin(CIMName());
        }
    }

    cimClass.setPath(CIMObjectPath("localhost", "test_namespace", cimClass.getClassName()));

    return(cimClass);
}
Пример #13
0
//
// Builds an instance of the class named className. Gets Class defintion and
// fills in the correct properties from the class.  This requires a repository
// getClass request for each instance built. The skeleton is built by
// creating the instance and copying qualifiers and properties from
// the class. Finally the instance is cloned to separate it from the
// original objects.
// NOTE: This is very inefficient for anything larger than a few instances.
// We should separate the get from the createSkeleton.
// @param className CIMName of the class for which the instance is to be built
// @return CIMInstance of this class with properties complete.
// @exception passes on any exceptions received from the repository request.
//
CIMInstance InteropProvider::buildInstanceSkeleton(
      const CIMNamespaceName & nameSpace,
      const CIMName& className,
      Boolean includeQualifiers,
      CIMClass& returnedClass)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
        "InteropProvider::_buildInstanceSkeleton()");
    // get class with lo = false, qualifier = true classorig = true
    returnedClass = repository->getClass(nameSpace,
        className, false, true, true);
    CIMInstance skeleton = returnedClass.buildInstance(
        includeQualifiers, true, CIMPropertyList());

    PEG_METHOD_EXIT();
    return skeleton;
}
Пример #14
0
void test01()
{
    // class MyClass : YourClass
    // {
    //     string message = "Hello";
    // }
    try
    {
        CIMName a = "A_class1";
        CIMName b = "A_class2";
        CIMClass c0(a, b);
        CIMClass c1(a, CIMName("A_class2"));
        CIMClass c2(CIMName("A_class1"), b);
        CIMClass c3(b, a);
    }
    catch (InvalidNameException & ine)
    {
        if (verbose)
        {
        cout << "Caught unexpected exception: " << ine.getMessage() << endl;
        }
    }
    try
    {
        //
        //  Invalid class name
        //
        CIMClass class0(CIMName ("//localhost/root/cimv2:MyClass"),
            CIMName ("YourClass"));

        PEGASUS_TEST_ASSERT(class0.getPath() ==
            CIMObjectPath("//localhost/root/cimv2:MyClass"));
    }
    catch (InvalidNameException & ine)
    {
        if (verbose)
        {
        cout << "Caught expected exception: " << ine.getMessage() << endl;
        }
    }

    CIMClass class1(CIMName ("MyClass"), CIMName ("YourClass"));

    class1
    .addQualifier(CIMQualifier(CIMName ("association"), true))
    .addQualifier(CIMQualifier(CIMName ("q1"), Uint32(55)))
    .addQualifier(CIMQualifier(CIMName ("q2"), String("Hello")))
    .addProperty(CIMProperty(CIMName ("message"), String("Hello")))
    .addProperty(CIMProperty(CIMName ("count"), Uint32(77), 0, CIMName(),
            CIMName("YourClass"), true))
    .addMethod(CIMMethod(CIMName ("isActive"), CIMTYPE_BOOLEAN)
        .addParameter(CIMParameter(CIMName ("hostname"), CIMTYPE_STRING))
        .addParameter(CIMParameter(CIMName ("port"), CIMTYPE_UINT32)));

    // Test the method count function
    PEGASUS_TEST_ASSERT(class1.getClassName().equal(CIMName ("myclass")));
    PEGASUS_TEST_ASSERT(class1.getSuperClassName() == CIMName ("YourClass"));

    PEGASUS_TEST_ASSERT(class1.getMethodCount() ==1);


    // Test the findMethod and isMethod functions
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("isActive")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("isActive")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);

    // Test the manipulation of an embeddedObjectProperty
    CIMClass embedClass(CIMName ("embedObj"), CIMName ());
    class1.addProperty(CIMProperty(CIMName ("embedObj"),
        CIMObject(embedClass), 0, CIMName(),
            CIMName(), false));

    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("embedObj")) != PEG_NOT_FOUND);
    Uint32  posProp = class1.findProperty(CIMName ("embedObj"));
    CIMConstProperty constprop1 = class1.getProperty(posProp);
    PEGASUS_TEST_ASSERT(constprop1.getClassOrigin() == CIMName());
    PEGASUS_TEST_ASSERT(constprop1.getType() == CIMTYPE_OBJECT);
    class1.removeProperty(posProp);

    // Now add another method and reconfirm.

    class1.addMethod(CIMMethod(CIMName ("makeActive"), CIMTYPE_BOOLEAN)
    .addParameter(CIMParameter(CIMName ("hostname"), CIMTYPE_STRING))
    .addParameter(CIMParameter(CIMName ("port"), CIMTYPE_UINT32)));

    PEGASUS_TEST_ASSERT(class1.getMethodCount() == 2);

    // Test the findMethod and isMethod functions
    // with two methods defined
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("isActive")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("makeActive")) != PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("isActive")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("makeActive")) != PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);


    // Test RemoveMethod function
    Uint32 posMethod;
    posMethod = class1.findMethod(CIMName ("isActive"));
    PEGASUS_TEST_ASSERT(posMethod != PEG_NOT_FOUND);

    class1.removeMethod(posMethod);

    PEGASUS_TEST_ASSERT(class1.findMethod(
                CIMName ("isActive")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.getMethodCount() == 1);

    //ATTN: P3 TODO add tests for different case names

    //Qualifier manipulation tests  (find, remove)

    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("qx")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(
                CIMName ("association")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.isAssociation());

    // Remove middle Qualifier "q2"
    Uint32 posQualifier;
    posQualifier = class1.findQualifier(CIMName ("q2"));
    CIMConstQualifier qconst = class1.getQualifier(posQualifier);

    PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 3);
    PEGASUS_TEST_ASSERT(posQualifier <= class1.getQualifierCount());
    class1.removeQualifier(posQualifier);
    PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 2);

    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.isAssociation());


    // Remove the first parameter "q1"
    posQualifier = class1.findQualifier(CIMName ("q1"));

    PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 2);
    CIMQualifier cq = class1.getQualifier( class1.findQualifier(
                CIMName ("q1")));
    PEGASUS_TEST_ASSERT(posQualifier <= class1.getQualifierCount());
    class1.removeQualifier(posQualifier);
    PEGASUS_TEST_ASSERT(class1.getQualifierCount() == 1);

    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q1")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.isAssociation());


    // ATTH: P3 Add tests for try block for outofbounds



    //The property manipulation tests.

    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("count")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("message")) != PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("isActive")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.getPropertyCount() == 2);


    Uint32  posProperty;
    posProperty = class1.findProperty(CIMName ("count"));
    CIMConstProperty constprop = class1.getProperty(posProperty);
    PEGASUS_TEST_ASSERT(constprop.getClassOrigin() == CIMName("YourClass"));
    PEGASUS_TEST_ASSERT(constprop.getPropagated());
    class1.removeProperty(posProperty);
    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("message")) != PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(class1.findProperty(
                CIMName ("count")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(class1.getPropertyCount() == 1);
    CIMProperty cp = class1.getProperty( class1.findProperty
        (CIMName ("message")));
    PEGASUS_TEST_ASSERT(cp.getClassOrigin().isNull());
    PEGASUS_TEST_ASSERT(!cp.getPropagated());

    if(verbose)
    {
        XmlWriter::printClassElement(class1);
        MofWriter::printClassElement(class1);
    }

    Buffer out;
    MofWriter::appendClassElement(out, class1);
    out.clear();
    XmlWriter::appendClassElement(out, class1);

    PEGASUS_TEST_ASSERT(!class1.isAbstract());

    CIMName squal("q1");
    PEGASUS_TEST_ASSERT(class1.findQualifier(squal) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(!class1.hasKeys());

    Array<CIMName> keyNames;
    class1.getKeyNames(keyNames);

    CIMClass c2(CIMName ("MyClass"));

    PEGASUS_TEST_ASSERT(c2.getClassName().equal(CIMName ("myclass")));


    // Error uninitialized handle
    c2.setSuperClassName(CIMName ("CIM_Element"));
    PEGASUS_TEST_ASSERT(c2.getSuperClassName() == CIMName ("CIM_Element"));

    CIMClass c3 = c2.clone();
    c3 = c2;


    try
    {
        CIMMethod cm = c2.getMethod(0);
    }
    catch(IndexOutOfBoundsException& e)
    {
        if(verbose)
            cout << "Exception: " << e.getMessage() << endl;
    }

    const CIMClass c4(CIMName ("MyClass"), CIMName ("YourClass"));

    CIMConstClass c5(CIMName ("MyClass"), CIMName ("YourClass"));
    CIMConstClass c6(CIMName ("MyClass"));
    CIMConstClass cc7(c6);
    CIMClass c7 = c5.clone();
    const CIMClass c8(class1);

    // Test the findMethod and isMethod functions
    PEGASUS_TEST_ASSERT(c7.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(c7.findQualifier(CIMName ("dummy")) == PEG_NOT_FOUND);

    try
    {
        CIMConstMethod cm = c8.getMethod(0);
    }
    catch(IndexOutOfBoundsException& e)
    {
        if(verbose)
            cout << "Exception: " << e.getMessage() << endl;
    }

    try
    {
        CIMConstProperty ccp = c8.getProperty(c8.findProperty
            (CIMName ("count")));
    }
    catch(IndexOutOfBoundsException& e)
    {
        if(verbose)
            cout << "Exception: " << e.getMessage() << endl;
    }

    if(verbose)
    {
    XmlWriter::printClassElement(c5);
    }

    try
    {
        CIMConstMethod cm = cc7.getMethod(0);
    }
    catch(IndexOutOfBoundsException& e)
    {
    if(verbose)
        cout << "Exception: " << e.getMessage() << endl;
    }
    // Test the findMethod and isMethod functions
    PEGASUS_TEST_ASSERT(c4.findMethod(
                CIMName ("DoesNotExist")) == PEG_NOT_FOUND);

    //Qualifier manipulation tests  (find, remove)

    PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("qx")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("q1")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(c4.findQualifier(CIMName ("q2")) == PEG_NOT_FOUND);
    PEGASUS_TEST_ASSERT(c4.findQualifier(
                CIMName ("association")) == PEG_NOT_FOUND);

    posProperty = c4.findProperty(CIMName ("count"));

    try
    {
        CIMConstQualifier ccq = c4.getQualifier(c4.findQualifier
            (CIMName ("q1")));
    }
    catch (IndexOutOfBoundsException& e)
    {
        if(verbose)
            cout << "Exception: " << e.getMessage() << endl;
    }

    PEGASUS_TEST_ASSERT(c4.findProperty(CIMName ("count")) == PEG_NOT_FOUND);

    PEGASUS_TEST_ASSERT(c4.getClassName() == CIMName ("MyClass"));
    PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("MyClass")));
    PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("MYCLASS")));
    PEGASUS_TEST_ASSERT(c4.getClassName().equal(CIMName ("myclass")));
    PEGASUS_TEST_ASSERT(!c4.getClassName().equal(CIMName ("blob")));


    PEGASUS_TEST_ASSERT(c4.getSuperClassName() == CIMName ("YourClass"));

    // test the setSuperClassName function
    /* ATTN KS 29 April.  This test has problems.  Relook later.
      Think test, not code.
    c4.setSuperClassName(CIMName ("JunkClass"));
    PEGASUS_TEST_ASSERT(c4.getSuperClassName() == CIMName ("JunkClass"));
    c4.setSuperClassName(CIMName ("YourClass"));
    */
    PEGASUS_TEST_ASSERT(c5.getSuperClassName() == CIMName ("YourClass"));

    PEGASUS_TEST_ASSERT(c5.getQualifierCount() == 0);
    posQualifier = c5.findQualifier(CIMName ("q2"));

    // throws out of bounds
    try
    {
        CIMConstQualifier qconst1 = c5.getQualifier(posQualifier);
    }
    catch(IndexOutOfBoundsException& e)
    {
        if(verbose)
            cout << "Exception: " << e.getMessage() << endl;
    }
    if(verbose)
    {
        cout << "All tests" << endl;
    }
}
Пример #15
0
// l10n - note: ignoring indication language
void snmpIndicationHandler::handleIndication(
    const OperationContext& context,
    const String nameSpace,
    CIMInstance& indication,
    CIMInstance& handler,
    CIMInstance& subscription,
    ContentLanguageList & contentLanguages)
{
    Array<String> propOIDs;
    Array<String> propTYPEs;
    Array<String> propVALUEs;

    Array<String> mapStr;

    PEG_METHOD_ENTER(TRC_IND_HANDLER,
        "snmpIndicationHandler::handleIndication");

    try
    {
        PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
            "snmpIndicationHandler %s:%s.%s processing %s Indication",
           (const char*)(nameSpace.getCString()),
           (const char*)(handler.getClassName().getString().getCString()),
           (const char*)(handler.getProperty(
           handler.findProperty(PEGASUS_PROPERTYNAME_NAME)).
           getValue().toString().getCString()),
           (const char*)(indication.getClassName().getString().
           getCString())));
        CIMClass indicationClass = _repository->getClass(
            nameSpace, indication.getClassName(), false, true,
            false, CIMPropertyList());

        Uint32 propertyCount = indication.getPropertyCount();

        for (Uint32 i=0; i < propertyCount; i++)
        {
            CIMProperty prop = indication.getProperty(i);

            Uint32 propDeclPos = indicationClass.findProperty(prop.getName());
            if (propDeclPos != PEG_NOT_FOUND)
            {
                CIMProperty propDecl = indicationClass.getProperty(propDeclPos);

                Uint32 qualifierPos =
                    propDecl.findQualifier(CIMName("MappingStrings"));
                if (qualifierPos != PEG_NOT_FOUND)
                {
                    //
                    // We are looking for following fields:
                    // MappingStrings {"OID.IETF | SNMP." oidStr,
                    //     "DataType.IETF |" dataType}
                    // oidStr is the object identifier (e.g. "1.3.6.1.2.1.5..."
                    // dataType is either Integer, or OctetString,
                    // or OID
                    // Following is one example:
                    // MappingStrings {"OID.IETF | SNMP.1.3.6.6.3.1.1.5.2",
                    //    "DataType.IETF | Integer"}
                    //

                    propDecl.getQualifier(qualifierPos).getValue().get(
                        mapStr);

                    String oidStr, dataType;
                    String mapStr1, mapStr2;
                    Boolean isValidAuthority = false;
                    Boolean isValidDataType = false;

                    for (Uint32 j=0; j < mapStr.size(); j++)
                    {
                        Uint32 barPos = mapStr[j].find("|");

                        if (barPos != PEG_NOT_FOUND)
                        {
                            mapStr1 = mapStr[j].subString(0, barPos);
                            mapStr2 = mapStr[j].subString(barPos + 1);

                            _trimWhitespace(mapStr1);
                            _trimWhitespace(mapStr2);

                            if ((mapStr1 == "OID.IETF") &&
                                (String::compare(mapStr2,
                                 String("SNMP."), 5) == 0))
                            {
                                isValidAuthority = true;
                                oidStr = mapStr2.subString(5);
                            }
                            else if (mapStr1 == "DataType.IETF")
                            {
                                isValidDataType = true;
                                dataType = mapStr2;
                            }

                            if (isValidAuthority && isValidDataType)
                            {
                                propOIDs.append(oidStr);
                                propTYPEs.append(dataType);
                                propVALUEs.append(prop.getValue().toString());

                                break;
                            }
                        }
                    }
                }
            }
        }

        // Collected complete data in arrays and ready to send the trap.
        // trap destination and SNMP type are defined in handlerInstance
        // and passing this instance as it is to deliverTrap() call

        Uint32 targetHostPos = handler.findProperty(CIMName("TargetHost"));
        Uint32 targetHostFormatPos =
            handler.findProperty(CIMName("TargetHostFormat"));
        Uint32 otherTargetHostFormatPos =
            handler.findProperty(CIMName("OtherTargetHostFormat"));
        Uint32 portNumberPos = handler.findProperty(CIMName("PortNumber"));
        Uint32 snmpVersionPos = handler.findProperty(CIMName("SNMPVersion"));
        Uint32 securityNamePos =
            handler.findProperty(CIMName("SNMPSecurityName"));
        Uint32 engineIDPos = handler.findProperty(CIMName("SNMPEngineID"));
        Uint32 snmpSecLevelPos = 
            handler.findProperty(CIMName("SNMPSecurityLevel"));
        Uint32 snmpSecAuthProtoPos = 
            handler.findProperty(CIMName("SNMPSecurityAuthProtocol"));
        Uint32 snmpSecAuthKeyPos =
            handler.findProperty(CIMName("SNMPSecurityAuthKey"));
        Uint32 snmpSecPrivProtoPos =
            handler.findProperty(CIMName("SNMPSecurityPrivProtocol"));
        Uint32 snmpSecPrivKeyPos =
            handler.findProperty(CIMName("SNMPSecurityPrivKey"));

        if (targetHostPos == PEG_NOT_FOUND)
        {
            PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
                "Target host is not set for IndicationHandlerSNMPMapper %s"
                " Indication.",
                (const char*)(indication.getClassName().getString().
                getCString())));
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                "Handler.snmpIndicationHandler.snmpIndicationHandler."
                "INVALID_SNMP_INSTANCE",
                "Invalid IndicationHandlerSNMPMapper instance"));
        }
        if (targetHostFormatPos == PEG_NOT_FOUND)
        {
            PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
                "Target host format is not set for IndicationHandlerSNMPMapper"
                " %s Indication.",
                (const char*)(indication.getClassName().getString().
                getCString())));
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                "Handler.snmpIndicationHandler.snmpIndicationHandler."
                "INVALID_SNMP_INSTANCE",
                "Invalid IndicationHandlerSNMPMapper instance"));
        }
        if (snmpVersionPos == PEG_NOT_FOUND)
        {
            PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
                "SNMP Version is not set for IndicationHandlerSNMPMapper %s"
                " Indication.",
                (const char*)(indication.getClassName().getString().
                getCString())));
            PEG_METHOD_EXIT();
            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                "Handler.snmpIndicationHandler.snmpIndicationHandler."
                "INVALID_SNMP_INSTANCE",
                "Invalid IndicationHandlerSNMPMapper instance"));
        }
        else
        {
            // properties from the handler instance
            String targetHost;
            String otherTargetHostFormat = String();
            String securityName = String();
            String engineID = String();
            Uint16 targetHostFormat = 0;
            Uint16 snmpVersion = 0;
            Uint32 portNumber;
            Uint8 snmpSecLevel = 1; // noAuthnoPriv
            Uint8 snmpSecAuthProto = 0; 
            Array<Uint8> snmpSecAuthKey;// no key
            Uint8 snmpSecPrivProto = 0; 
            Array<Uint8> snmpSecPrivKey ;// no key

            String trapOid;
            Boolean trapOidAvailable = false;
            //
            //  Get snmpTrapOid from context
            //
            if (context.contains(SnmpTrapOidContainer::NAME))
            {
                SnmpTrapOidContainer trapContainer =
                    context.get(SnmpTrapOidContainer::NAME);

                trapOid = trapContainer.getSnmpTrapOid();
                trapOidAvailable = true;
            }
            else
            {
                // get trapOid from indication Class

                Uint32 pos =
                    indicationClass.findQualifier(CIMName("MappingStrings"));
                if (pos != PEG_NOT_FOUND)
                {
                    Array<String> classMapStr;
                    indicationClass.getQualifier(pos).getValue().
                        get(classMapStr);

                    for (Uint32 i=0; i < classMapStr.size(); i++)
                    {
                        Uint32 barPos = classMapStr[i].find("|");

                        if (barPos != PEG_NOT_FOUND)
                        {
                            String authorityName =
                                classMapStr[i].subString(0, barPos);
                            String oidStr = classMapStr[i].subString(
                                barPos+1, PEG_NOT_FOUND);

                            _trimWhitespace(authorityName);
                            _trimWhitespace(oidStr);

                            if ((authorityName == "OID.IETF") &&
                                (String::compare(oidStr,
                                 String("SNMP."), 5) == 0))
                            {
                                trapOid = oidStr.subString(5);
                                trapOidAvailable = true;
                                break;
                            }
                        }
                    }

                    if (!trapOidAvailable)
                    {
                        PEG_TRACE((
                            TRC_IND_HANDLER,
                            Tracer::LEVEL1,
                            "No MappingStrings for snmp trap is specified "
                                "for class: %s",
                            (const char*)
                              indication.getClassName().getString().getCString()
                            ));

                        PEG_METHOD_EXIT();

                        throw PEGASUS_CIM_EXCEPTION_L(
                            CIM_ERR_FAILED,
                            MessageLoaderParms(
                                "Handler.snmpIndicationHandler."
                                "snmpIndicationHandler.NO_MS_FOR_SNMP_TRAP",
                                "No MappingStrings for snmp trap is specified "
                                    "for class: $0",
                                indication.getClassName().getString()));
                    }
                }
                else
                {
                    PEG_TRACE_CSTRING(TRC_IND_HANDLER, Tracer::LEVEL1,
                        "Qualifier MappingStrings can not be found.");
                    PEG_METHOD_EXIT();
                    MessageLoaderParms parms(
                        "Handler.snmpIndicationHandler.snmpIndicationHandler."
                            "QUALIFIER_MAPPINGS_NOT_FOUND",
                        "Qualifier MappingStrings can not be found");
                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
                }
            }

            handler.getProperty(targetHostPos).getValue().get(targetHost);
            handler.getProperty(targetHostFormatPos).getValue().get(
                targetHostFormat);
            if (otherTargetHostFormatPos != PEG_NOT_FOUND)
            {
                handler.getProperty(otherTargetHostFormatPos).getValue().get(
                    otherTargetHostFormat);
            }
            if (portNumberPos != PEG_NOT_FOUND)
            {
                handler.getProperty(portNumberPos).getValue().get(portNumber);
            }
            else
            {
                // default port
                portNumber = SNMP_TRAP_DEFAULT_PORT;
            }

            handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
            if (securityNamePos != PEG_NOT_FOUND)
            {
                handler.getProperty(securityNamePos).getValue().get(
                    securityName);
            }
            if (engineIDPos != PEG_NOT_FOUND)
            {
                handler.getProperty(engineIDPos).getValue().get(engineID);
            }

            if(snmpVersion == 5) // SNMPv3 Trap
            {
                //fetch the security data
                if(snmpSecLevelPos != PEG_NOT_FOUND)
                {
                    handler.getProperty(snmpSecLevelPos).getValue(). \
                        get(snmpSecLevel);
                }
                if(snmpSecAuthProtoPos != PEG_NOT_FOUND)
                {
                    handler.getProperty(snmpSecAuthProtoPos).getValue(). \
                        get(snmpSecAuthProto);
                }
                if(snmpSecAuthKeyPos != PEG_NOT_FOUND)
                {
                    handler.getProperty(snmpSecAuthKeyPos).getValue(). \
                        get(snmpSecAuthKey);
                }
                if(snmpSecPrivProtoPos != PEG_NOT_FOUND)
                {
                    handler.getProperty(snmpSecPrivProtoPos).getValue(). \
                        get(snmpSecPrivProto);
                }
                if(snmpSecPrivKeyPos!= PEG_NOT_FOUND)
                {
                    handler.getProperty(snmpSecPrivKeyPos).getValue(). \
                        get(snmpSecPrivKey);
                }
            }

            PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
               "snmpIndicationHandler sending %s Indication trap %s to target"
               " host %s target port %d",
               (const char*)(indication.getClassName().getString().
               getCString()),
               (const char*)(trapOid.getCString()),
               (const char*)(targetHost.getCString()),portNumber));
           _snmpTrapSender->deliverTrap(
                trapOid,
                securityName,
                targetHost,
                targetHostFormat,
                otherTargetHostFormat,
                portNumber,
                snmpVersion,
                engineID,
                snmpSecLevel,
                snmpSecAuthProto,
                snmpSecAuthKey,
                snmpSecPrivProto,
                snmpSecPrivKey,
                propOIDs,
                propTYPEs,
                propVALUEs);

        PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4,
           "%s Indication trap %s sent to target host %s target port %d "
           "successfully",
           (const char*)(indication.getClassName().getString().getCString()),
           (const char*)(trapOid.getCString()),
           (const char*)(targetHost.getCString()),portNumber));
        }
    }
    catch (CIMException& c)
    {
        PEG_TRACE((TRC_IND_HANDLER, Tracer::LEVEL1, "CIMException %s",
            (const char*)c.getMessage().getCString()));
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, c.getMessage());
    }
    catch (Exception& e)
    {
        PEG_TRACE((TRC_IND_HANDLER, Tracer::LEVEL1, "Exception %s",
            (const char*)e.getMessage().getCString()));
        PEG_METHOD_EXIT();

        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
    }
    catch (...)
    {
        PEG_TRACE_CSTRING(TRC_IND_HANDLER, Tracer::LEVEL1,
            "Failed to deliver trap.");
        PEG_METHOD_EXIT();

        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
            "Handler.snmpIndicationHandler.snmpIndicationHandler."
                "FAILED_TO_DELIVER_TRAP",
            "Failed to deliver trap."));
    }
    PEG_METHOD_EXIT();
}
Пример #16
0
// l10n - note: ignoring indication language
void snmpIndicationHandler::handleIndication(
    const OperationContext& context,
    const String nameSpace,
    CIMInstance& indication,
    CIMInstance& handler, 
    CIMInstance& subscription,
    ContentLanguages & contentLanguages)
{
    Array<String> propOIDs;
    Array<String> propTYPEs;
    Array<String> propVALUEs;

    CIMProperty prop;
    CIMQualifier trapQualifier;

    Uint32 qualifierPos;
    
    String propValue;

    String mapstr1;
    String mapstr2;

    PEG_METHOD_ENTER (TRC_IND_HANDLER, 
	"snmpIndicationHandler::handleIndication");

    try
    {
    	CIMClass indicationClass = _repository->getClass(
	    nameSpace, indication.getClassName(), false, true, 
	    false, CIMPropertyList());

    	Uint32 propertyCount = indication.getPropertyCount();

    	for (Uint32 i=0; i < propertyCount; i++)
    	{
	    prop = indication.getProperty(i);

	    if (!prop.isUninitialized())
            {
                CIMName propName = prop.getName();
                Uint32 propPos = indicationClass.findProperty(propName);
                if (propPos != PEG_NOT_FOUND)
                {
                    CIMProperty trapProp = indicationClass.getProperty(propPos);

                    qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
                    if (qualifierPos != PEG_NOT_FOUND)
                    {
		        trapQualifier = trapProp.getQualifier(qualifierPos);
		
		        mapstr1.clear();
		        mapstr1 = trapQualifier.getValue().toString();

		        if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
		            (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
		        {
		            if (mapstr1.subString(0, 8) == "OID.IETF")
		            {
			        mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
                                if (mapstr1.find("|") != PEG_NOT_FOUND)
                                {
			            mapstr2.clear();
			            mapstr2 = mapstr1.subString(0, 
				        mapstr1.find("DataType.IETF")-1);
			            propOIDs.append(mapstr2);
                            
			            propValue.clear();
                                    propValue = prop.getValue().toString();
			            propVALUEs.append(propValue);
                            
			            mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
                                    mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
			            propTYPEs.append(mapstr2);
                                }
		            }
		        }
	            }
                }
            }
        }

        // Collected complete data in arrays and ready to send the trap.
        // trap destination and SNMP type are defined in handlerInstance
        // and passing this instance as it is to deliverTrap() call

#ifdef HPUX_EMANATE
        static snmpDeliverTrap_emanate emanateTrap;
#else
        static snmpDeliverTrap_stub emanateTrap;
#endif

        Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
        Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
        Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
				      "OtherTargetHostFormat"));
        Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
        Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
        Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
        Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));

        if ((targetHostPos != PEG_NOT_FOUND) &&
            (targetHostFormatPos != PEG_NOT_FOUND) && 
            (snmpVersionPos != PEG_NOT_FOUND) && 
            (indicationClass.findQualifier(CIMName ("MappingStrings")) != 
                PEG_NOT_FOUND))
        {
    	    // properties from the handler instance
            String targetHost;
	    String otherTargetHostFormat = String();
	    String securityName = String();
	    String engineID = String();
	    Uint16 targetHostFormat = 0;
	    Uint16 snmpVersion = 0;
	    Uint32 portNumber;

	    String trapOid;
	    //
            //  Get snmpTrapOid from context
            //
	    try
	    {
                SnmpTrapOidContainer trapContainer = context.get
                    (SnmpTrapOidContainer::NAME);

                trapOid = trapContainer.getSnmpTrapOid();
	    }
	    catch (Exception& e)
            {
	        // get trapOid from indication Class

	        Uint32 pos = indicationClass.findQualifier(CIMName ("MappingStrings"));
	        if (pos != PEG_NOT_FOUND)
	        {
	            trapOid = indicationClass.getQualifier(pos).getValue().toString();

		    trapOid = trapOid.subString(11, PEG_NOT_FOUND);

                    if ((String::compare(trapOid, "SNMP.", 5)) == 0)
                    {
                        trapOid = trapOid.subString(5, (trapOid.size()-6));
                    }
	            else
	            {
			PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
			    		 "Invalid MappingStrings Value " + trapOid);
			PEG_METHOD_EXIT();
		        // l10n
	                // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");
		        throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
						   MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_MS_VALUE",
								       "Invalid MappingStrings Value")); 
	            }
	        }
	        else
	        {
		    PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
		    		 "Qualifier MappingStrings can not be found.");
		    PEG_METHOD_EXIT();
	    	    //L10N_ TODO DONE
	            //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Qualifier MappingStrings can not be found");
		    MessageLoaderParms parms("Handler.snmpIndicationHandler.snmpIndicationHandler.QUALIFIER_MAPPINGS_NOT_FOUND",
								 "Qualifier MappingStrings can not be found");
		    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
	        }
	    }

	    handler.getProperty(targetHostPos).getValue().get(targetHost);
	    handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);
	    if (otherTargetHostFormatPos != PEG_NOT_FOUND)
	    { 
	        handler.getProperty(otherTargetHostFormatPos).getValue().get
		    (otherTargetHostFormat);
	    }
	    if (portNumberPos != PEG_NOT_FOUND)
	    {
	        handler.getProperty(portNumberPos).getValue().get(portNumber);
	    }
	    else
	    {
	        // default port
	        portNumber = SNMP_TRAP_DEFAULT_PORT;
	    }

	    handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
	    if (securityNamePos != PEG_NOT_FOUND)
	    {
	        handler.getProperty(securityNamePos).getValue().get(securityName);
	    }
	    if (engineIDPos != PEG_NOT_FOUND)
	    {
	        handler.getProperty(engineIDPos).getValue().get(engineID);
	    }

	    emanateTrap.deliverTrap(
                trapOid,
                securityName,
                targetHost,
                targetHostFormat,
	        otherTargetHostFormat,
	        portNumber,
	        snmpVersion,
	        engineID,
                propOIDs,  
                propTYPEs, 
                propVALUEs);
        }
        else
        {
	    PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
		"Invalid IndicationHandlerSNMPMapper instance.");
	    PEG_METHOD_EXIT();
          // l10n

          // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, 
          // "Invalid IndicationHandlerSNMPMapper instance");

          throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, 
				     MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_SNMP_INSTANCE", 
							"Invalid IndicationHandlerSNMPMapper instance"));
        }
    } 
    catch (CIMException & c)
    {
	PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, c.getMessage()); 
	PEG_METHOD_EXIT();

	throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, c.getMessage());
    }
    catch (Exception& e)
    {
	PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, e.getMessage());
	PEG_METHOD_EXIT();

	throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, e.getMessage());
    }
    catch (...)
    {
	PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
		"Failed to deliver trap.");
	PEG_METHOD_EXIT();

	throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
		MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP", 
				   "Failed to deliver trap."));
    }
}
Пример #17
0
void DefaultInstanceProvider::_copySuperClasses(
    CIMClient & client,
    const String & nameSpace,
    const CIMClass & cimClass,
    Array<CIMClass> & superClasses)
{
    // get the super class name
    CIMName superClassName = cimClass.getSuperClassName();

    if (superClassName.isNull())
    {
        Uint32 numSuperClasses = superClasses.size();
        if (numSuperClasses == 0)
        {
            // No super class, just return
            return;
        }

        // copy the super classes
        for (Uint32 i = numSuperClasses; i > 0; i--)
        {
            // check to see if class already exists
            //
            CIMClass cimClass;
            try
            {
                cimClass = _repository->getClass(nameSpace, 
                                          superClasses[i-1].getClassName());
            }
            catch (Exception&)
            {
                //
                // Super class does not exist, create the super class
                //
                try
                {
                    _repository->createClass( nameSpace, superClasses[i-1] );
                }
                catch( Exception& ex )
                {
                    const String msg  = "Create superClass failed. " + ex.getMessage();
                    throw CIMOperationFailedException( msg );
                }
            }
        }
        return;
    }

    // get the super class 
    CIMClass superClass;
    Boolean localOnly = false;
    Boolean includeQualifiers = true;
    Boolean includeClassOrigin = false;

    try
    {
        superClass = client.getClass(nameSpace, superClassName,
                                     localOnly, includeQualifiers,
                                     includeClassOrigin);

        // add superclass to array
        superClasses.append(superClass);
    }
    catch( Exception& ex )
    {
        const String msg = "Get Super Class failed. " + ex.getMessage();
        throw CIMOperationFailedException( msg );
    }

    // recursive call.  copy superclasses of this class
    _copySuperClasses( client, nameSpace, superClass, superClasses); 
}
Пример #18
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::getClass
//
/// virtual class CIMClass. From the operations class
// ///////////////////////////////////////////////////////////////////////////
CIMClass WMIClassProvider::getClass(
        const String& nameSpace,
		const String& userName,
		const String& password,
        const String& className,
        Boolean localOnly,
        Boolean includeQualifiers,
        Boolean includeClassOrigin,
        const CIMPropertyList& propertyList)
{
	PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIClassProvider::getClass()");

	CComPtr<IWbemClassObject> pClass;

	setup(nameSpace,userName,password);

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"getClass - localOnly %x, includeQualifiers %x, includeClassOrigin %x", 
		localOnly, includeQualifiers, includeClassOrigin);

	if (!m_bInitialized)
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::getClass - m_bInitilized= %x, throw CIM_ERR_FAILED exception",  
			m_bInitialized);

		throw CIMException(CIM_ERR_FAILED);
	}
	
	try 
	{
		if (!(_collector->getObject(&pClass, className)))
		{
			if (pClass) 
				pClass.Release();

			throw CIMException(CIM_ERR_NOT_FOUND);
		}
		else if (_collector->isInstance(pClass))
		{
			if (pClass) 
				pClass.Release();

			throw CIMException(CIM_ERR_INVALID_PARAMETER);
		}
	}
	catch (CIMException &e)
	{
		if (pClass) 
			pClass.Release();

		switch(e.getCode())
		{
			case CIM_ERR_INVALID_CLASS: 
                throw CIMException(CIM_ERR_NOT_FOUND); 
                break;
			default: throw;
		}
	}

	String superClass = _collector->getSuperClass(pClass);
	CIMName objName = className;
	CIMClass cimClass = CIMClass(objName);

	if (0 != superClass.size())
	{
		CIMName superclassName = superClass;
		cimClass.setSuperClassName(superclassName);
	}

	if (!(_collector->getCIMClass(pClass, 
				cimClass,
				localOnly,
				includeQualifiers,
				includeClassOrigin,
				propertyList)))
	{
		throw CIMException(CIM_ERR_NOT_FOUND);
	}

	if (pClass)
		pClass.Release();
	
    PEG_METHOD_EXIT();

	return cimClass;
}
Пример #19
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::createProperties creates all properties including keys 
//									  add the qualifiers too
// ///////////////////////////////////////////////////////////////////////////
void WMIClassProvider::createProperties(const CIMClass& newClass,
									    IWbemServices *pServices,
										IWbemClassObject *pNewClass)
{
	HRESULT hr;
	
	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WmiClassProvider::createProperties()");

	// create the properties but don't create the keys again
	CIMProperty prop;

	for (Uint32 i = 0; i < newClass.getPropertyCount(); i++)
	{
		prop = newClass.getProperty(i).clone();

		// create the properties
		try 
		{
			createProperty(prop, pNewClass);
		}
		catch (CIMException&)
		{
			throw;
		}
		
		// get a pointer to work with qualifiers 
		CComPtr<IWbemQualifierSet> pQual;
		CComBSTR bs = prop.getName().getString().getCString();
		
		hr = pNewClass->GetPropertyQualifierSet(bs, &pQual);
		bs.Empty();

		if (FAILED(hr))
		{
			CMyString msg;
			msg.Format("Failed get Qualifier set of [%s]. Error: 0x%X", 255, 
				prop.getName().getString().getCString(), hr);
		
			Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
						  "WMIClassProvider::createProperties() - %s", (LPCTSTR)msg);

			if (pQual)
				pQual.Release();
			
			throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg); 
		}

		// set the qualifiers to the property
		for (Uint32 j = 0; j < prop.getQualifierCount(); j++)
		{
			WMIQualifier qualifier(prop.getQualifier(j));
			try 
			{
				createQualifier(qualifier, pQual);
			}
			catch (CIMException&)
			{
				if (pQual)
					pQual.Release();

				throw;
			}
		}

		// set the CLASSORIGIN qualifier if it wasn't set yet
		String strClassorigin = prop.getClassOrigin().getString();
		
		if (strClassorigin.size() == 0)
		{
			strClassorigin = newClass.getClassName().getString();
		}

		WMIFlavor flavor(CIMFlavor::DEFAULTS);
		
		/*
		v.vt = VT_BSTR;
		v.bstrVal = strClassorigin.getCString();
		*/
		CComVariant v;
		v = strClassorigin.getCString();
		
		hr = pQual->Put(L"CLASSORIGIN", &v, flavor.getAsWMIValue());
		v.Clear();

		if (pQual)
			pQual.Release();

		if (FAILED(hr))
		{
			CMyString msg;
			msg.Format("Failed to add CLASSORIGIN qualifier in [%s]. Error: 0x%X", 255, 
				prop.getName().getString().getCString(), hr);

			Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
						  "WMIClassProvider::createProperties () - %s", (LPCTSTR)msg);
			
			throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
		}
	}

	PEG_METHOD_EXIT();

	return;
}
Пример #20
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::createClassNameAndClassQualifiers
//
// ///////////////////////////////////////////////////////////////////////////
void WMIClassProvider::createClassNameAndClassQualifiers(const CIMClass& newClass,
														 IWbemServices *pServices,
														 IWbemClassObject **pNewClass,
														 const bool hasSuperClass)
{
	HRESULT hr;

	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WmiClassProvider::createClassNameAndClassQualifiers()");

	// if the class has a superclass, we need to spwan a derived
	if (hasSuperClass)
	{
		// get the superclass name
		CComPtr<IWbemClassObject> pSuperClass;
		String tmp = newClass.getSuperClassName().getString();
		CComBSTR bs = tmp.getCString();

		hr = pServices->GetObject(
				bs, 
				NULL, 
				NULL, 
				&pSuperClass, 
				NULL);

		bs.Empty();

		if (FAILED(hr))
		{
			if (pSuperClass)
				pSuperClass.Release();

			CMyString msg;
			msg.Format("Failed to get a pointer to Superclass [%s]. Error: 0x%X", 255, tmp.getCString(), hr);

			Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
						  "WMIClassProvider::createClassNameAndClassQualifiers() - %s", (LPCTSTR)msg);

			throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg); 
		}

		//Creates the new class
		pSuperClass->SpawnDerivedClass(NULL, pNewClass);
		if (pSuperClass)
			pSuperClass.Release();
	}
	else
	{
		// we are creating a base class
		hr = pServices->GetObject(NULL, 
								  NULL, 
								  NULL, 
								  pNewClass, 
								  NULL);

		if (FAILED(hr))
		{
			CMyString msg;
			msg.Format("Failed to get a pointer to a new class. Error: 0x%X", hr);

			Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
						  "WMIClassProvider::createClassNameAndClassQualifiers() - %s", (LPCTSTR)msg);
			
			throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
		}
	}
	
	// create the class name
	CComVariant v;
	v = newClass.getClassName().getString().getCString();
	hr = (*pNewClass)->Put(L"__CLASS", 0, &v, 0);
	
	v.Clear();

	if (FAILED(hr))
	{
		CMyString msg;
		msg.Format("Failed to add class name on class [%s]. Error: 0x%X", 255, 
			newClass.getClassName().getString().getCString(), hr);

		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
			          "WMIClassProvider::createClassNameAndClassQualifiers() - %s", (LPCTSTR)msg);

		if (*pNewClass)
			(*pNewClass)->Release();
		
		throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
	}

	// get a pointer to work with qualifiers
	CComPtr<IWbemQualifierSet> pNewClassQualifier;
	hr = (*pNewClass)->GetQualifierSet(&pNewClassQualifier);

	if (FAILED(hr))
	{
		CMyString msg;
		msg.Format("Failed to get the Qualifier set pointer of class [%s]. Error: 0x%X", 255, 
			newClass.getClassName().getString().getCString(), hr);

		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
			          "WMIClassProvider::createClassNameAndClassQualifiers() - %s", (LPCTSTR)msg);
		
		if (*pNewClass)
			(*pNewClass)->Release();

		if (pNewClassQualifier)
			pNewClassQualifier.Release();

		throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
	}
	
	// check the class qualifiers and create them if they are valid
	// we are taking care of the class qualifiers and not methods/properties qualifiers :D
	for (Uint32 i = 0; i < newClass.getQualifierCount(); i++)
	{
		try 
		{
			WMIQualifier qualifier(newClass.getQualifier(i).clone());
			
			createQualifier(qualifier, pNewClassQualifier);
		}
		catch (CIMException&)
		{
			if (*pNewClass)
				(*pNewClass)->Release();

			if (pNewClassQualifier)
				pNewClassQualifier.Release();

			throw;
		}
	}

	if (pNewClassQualifier)
		pNewClassQualifier.Release();

	PEG_METHOD_EXIT();

	return;
}
static void
_test2 (CIMClient & client)
{
  Uint32 exceptions = 0;
  CIMObjectPath instanceName;
  Array < CIMKeyBinding > keyBindings;

  keyBindings.append (CIMKeyBinding ("ElementNameName",
                                     "TestCMPI_ExecQuery",
                                     CIMKeyBinding::STRING));

  instanceName.setNameSpace (providerNamespace);
  instanceName.setClassName ("TestCMPI_ExecQuery");
  instanceName.setKeyBindings (keyBindings);

  /* Call the unsupported functions of the provider. */
  try
  {
    CIMInstance instance (client.getInstance (providerNamespace,
                                              instanceName));
  } catch (const CIMException &)
  {
     exceptions ++;
  }


  try
  {
    client.deleteInstance (providerNamespace, instanceName);

  } catch (const CIMException & )
  {
     exceptions ++;
  }
  CIMClass thisClass = client.getClass(
                           providerNamespace,
                           "TestCMPI_ExecQuery",
                           false,
                           true,
                           true,
                           CIMPropertyList());
  Array<CIMName> propertyNameList;
  propertyNameList.append(CIMName("ElementName"));
  CIMPropertyList myPropertyList(propertyNameList);
  // create the instance with the defined properties
  CIMInstance newInstance = thisClass.buildInstance(true, true, myPropertyList);
  newInstance.getProperty(0).setValue(CIMValue(String("TestCMPI_execQuery") ));
  try
  {

    CIMObjectPath objectPath (client.createInstance (providerNamespace,
                                                     newInstance));


  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    client.modifyInstance (providerNamespace, newInstance);

  } catch (const CIMException &)
  {
     exceptions ++;
  }
  try
  {

    Array < CIMInstance > instances =
      client.enumerateInstances (providerNamespace,
                                 CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  try
  {
    Array < CIMObjectPath > objectPaths =
      client.enumerateInstanceNames (providerNamespace,
                                     CIMName ("TestCMPI_ExecQuery"));
  } catch (const CIMException &)
  {
     exceptions ++;
  }

  PEGASUS_TEST_ASSERT(exceptions ==  6);

}
Пример #22
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::modifyClass
//
// ///////////////////////////////////////////////////////////////////////////
void WMIClassProvider::modifyClass(const String& nameSpace,
								   const String& userName,
								   const String& password,
								   const CIMClass& modifiedClass)
{

	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WMIClassProvider::modifyClass()");

	setup(nameSpace, userName, password);

	if (!m_bInitialized)
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::modifyClass - m_bInitilized= %x, throw CIM_ERR_FAILED exception",  
			m_bInitialized);

		throw CIMException(CIM_ERR_FAILED);
	}

	// check if class does exist
	if (!classAlreadyExists(modifiedClass.getClassName().getString()))
	{
		throw CIMException(CIM_ERR_NOT_FOUND);
	}

	// check if superclass does exist
	if (!classAlreadyExists(modifiedClass.getSuperClassName().getString()))
	{
		// superclass doesn't exist
		throw CIMException(CIM_ERR_INVALID_SUPERCLASS);
	}

	//
	// By Jair
	//
	// If the class already has a superclass and it isn't explicitly 
	// defined in the <modifiedClass> definition, we must set it 
	// before changing the control to the createClass method. This way 
	// we don't change the Class definition, as specified in DSP0200.
	//
	CIMClass updatedClass = modifiedClass;

	if ((updatedClass.getSuperClassName().getString()).size() == 0)
	{
		// set the superclass

		CComPtr<IWbemClassObject> pClass;
	
		if (!(_collector->getObject(&pClass, updatedClass.getClassName().getString())))
		{
			if (pClass)
				pClass.Release();

			throw CIMException(CIM_ERR_NOT_FOUND);
		}

		String superClass = _collector->getSuperClass(pClass);
		
		if (0 != superClass.size())
		{	
			CIMName superclassName = superClass;
			updatedClass.setSuperClassName(superclassName);
		}

		if (pClass)
			pClass.Release();
	}
		
	//update the class using createClass
	createClass(nameSpace,
			    userName,
				password,
				updatedClass,
				true);

	PEG_METHOD_EXIT();

	return;
}
Пример #23
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::createClass
//
// ///////////////////////////////////////////////////////////////////////////
void WMIClassProvider::createClass(const String& nameSpace,
								   const String& userName,
								   const String& password,
								   const CIMClass& newClass,
								   Boolean updateClass)
{
	
	PEG_METHOD_ENTER(TRC_WMIPROVIDER, "WmiClassProvider::createClass()");

	setup(nameSpace, userName, password);

	if (!m_bInitialized)
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::createClass - m_bInitilized= %x, throw CIM_ERR_FAILED exception",  
			m_bInitialized);

		throw CIMException(CIM_ERR_FAILED);
	}
	
	// Check if the class does not exist and if if has a valid
	// superclass
	performInitialCheck(newClass, updateClass);
	bool hasSuperClass = (newClass.getSuperClassName().getString() != String::EMPTY);

	// gets the pointers
	CComPtr<IWbemServices> pServices;
	CComPtr<IWbemClassObject> pNewClass;

	if (!_collector->Connect(&pServices))
	{
		if (pServices)
			pServices.Release();

		throw CIMException (CIM_ERR_FAILED);
	}

	try 
	{
	    // starts the class creation by name and class qualifiers
		createClassNameAndClassQualifiers(
			newClass, 
			pServices, 
			&pNewClass, 
			hasSuperClass);

		// create properties
		createProperties(
			newClass, 
			pServices, 
			pNewClass);

		// create methods
		createMethods(
			newClass, 
			pServices, 
			pNewClass);
	}
	catch (CIMException&) 
	{
		if (pServices)
			pServices.Release();

		if (pNewClass)
			pNewClass.Release();

		throw;
	}
	
	// Store the new class into WMI
	LONG lFlags = 0L;
	
	//if updateClass is set, we are trying a modifyclass
	if (updateClass) lFlags = WBEM_FLAG_UPDATE_ONLY;

	HRESULT hr = pServices->PutClass(pNewClass, lFlags, NULL, NULL);
	
	if (pServices)
		pServices.Release();
	
	if (pNewClass)
		pNewClass.Release();
	
	if (FAILED(hr))
	{
		CMyString msg;
		msg.Format("It is not possible to create the class [%s]. Error: 0x%X", 255, 
					newClass.getClassName().getString(), hr);

		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3, 
						  "WMIClassProvider::createClass() - %s", (LPCTSTR)msg);

		switch(hr)
		{
			case E_ACCESSDENIED: throw CIMException(CIM_ERR_ACCESS_DENIED); break;
			case WBEM_E_ACCESS_DENIED: throw CIMException(CIM_ERR_ACCESS_DENIED); break;
			case WBEM_E_CLASS_HAS_CHILDREN: throw CIMException(CIM_ERR_CLASS_HAS_CHILDREN); break;
			case WBEM_E_CLASS_HAS_INSTANCES: throw CIMException(CIM_ERR_CLASS_HAS_INSTANCES); break;
			case WBEM_E_NOT_FOUND: throw CIMException(CIM_ERR_NOT_FOUND); break;
			case WBEM_E_INVALID_CLASS: throw CIMException(CIM_ERR_INVALID_PARAMETER); break;
			default: throw CIMException(CIM_ERR_FAILED, (LPCTSTR)msg);
		}
	}

	PEG_METHOD_EXIT();

	return;
}
void WQLSelectStatementRep::validate()
{
    if(_ctx == NULL){
        MessageLoaderParms parms(
            "WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
            "Trying to process a query with a NULL Query Context.");
      throw QueryValidationException(parms);
   }
    CIMClass fromClass;
    try
   {
     fromClass = _ctx->getClass(_className);

    CIMObjectPath className (String::EMPTY, _ctx->getNamespace (), _className);
     Array<CIMName> whereProps =
        getWherePropertyList(className).getPropertyNameArray();
     Array<CIMName> selectProps =
        getSelectPropertyList(className).getPropertyNameArray();

     // make sure all properties match properties on the from class
     for(Uint32 i = 0; i < whereProps.size(); i++){
         Uint32 index = fromClass.findProperty(whereProps[i]);
            if(index == PEG_NOT_FOUND){
                MessageLoaderParms parms(
                    "WQL.WQLSelectStatementRep.PROP_NOT_FOUND",
                    "The property $0 was not found in the FROM class $1",
                    whereProps[i].getString(),
                    fromClass.getClassName().getString());
            throw QueryMissingPropertyException(parms);
            }
         else
         {
           //
           //  Property exists in class
           //  Verify it is not an array property
           //
           CIMProperty classProperty = fromClass.getProperty(index);
           if (classProperty.isArray ())
           {
             MessageLoaderParms parms(
                 "WQL.WQLSelectStatementRep.WHERE_PROP_IS_ARRAY",
                 "Array property $0 is not supported in the WQL WHERE clause.",
                 whereProps[i].getString());
             throw QueryValidationException(parms);
           }
         }
        }

     for(Uint32 i = 0; i < selectProps.size(); i++){
       if(fromClass.findProperty(selectProps[i]) == PEG_NOT_FOUND){
         MessageLoaderParms parms(
             "WQL.WQLSelectStatementRep.PROP_NOT_FOUND",
             "The property $0 was not found in the FROM class $1",
             selectProps[i].getString(),
             fromClass.getClassName().getString());
         throw QueryMissingPropertyException(parms);
       }
     }
   }
   catch (const CIMException& ce)
   {
     if (ce.getCode() == CIM_ERR_INVALID_CLASS ||
         ce.getCode() == CIM_ERR_NOT_FOUND)
     {
       MessageLoaderParms parms(
           "WQL.WQLSelectStatementRep.CLASSNAME_NOT_IN_REPOSITORY",
           "The class name $0 was not found in the repository.",
           _className.getString());
       throw QueryValidationException(parms);
     }
     else
     {
       throw;
     }
   }
}
Пример #25
0
void CIMPropertyRep::resolve(
    DeclContext* declContext,
    const CIMNamespaceName& nameSpace,
    Boolean isInstancePart,
    const CIMConstProperty& inheritedProperty,
    Boolean propagateQualifiers)
{
    PEGASUS_ASSERT(!inheritedProperty.isUninitialized());

    // Check the type:

    if (!inheritedProperty.getValue().typeCompatible(_value))
    {
        if (!(
            (inheritedProperty.getValue().getType() == CIMTYPE_OBJECT) &&
            (_value.getType() == CIMTYPE_STRING) &&
            (_qualifiers.find(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)
                 != PEG_NOT_FOUND) &&
            (inheritedProperty.getValue().isArray() == _value.isArray())
            ) &&
            !(
            (inheritedProperty.getValue().getType() == CIMTYPE_INSTANCE) &&
            (_value.getType() == CIMTYPE_STRING) &&
            (_qualifiers.find(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)
                 != PEG_NOT_FOUND) &&
            (inheritedProperty.getValue().isArray() == _value.isArray())
            ))
        {
            throw TypeMismatchException();
        }
    }

    // Validate the qualifiers of the property (according to
    // superClass's property with the same name). This method
    // will throw an exception if the validation fails.

    CIMScope scope = CIMScope::PROPERTY;

    if (_value.getType() == CIMTYPE_REFERENCE)
        scope = CIMScope::REFERENCE;

    // Test the reference class name against the inherited property
    if (_value.getType() == CIMTYPE_REFERENCE ||
        _value.getType() == CIMTYPE_INSTANCE)
    {
        CIMName inheritedClassName;
        Array<CIMName> classNames;

        if (_value.getType() == CIMTYPE_INSTANCE)
        {
            Uint32 pos = inheritedProperty.findQualifier(
                             PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
            if (pos != PEG_NOT_FOUND)
            {
                String qualStr;
                inheritedProperty.getQualifier(pos).getValue().get(qualStr);
                inheritedClassName = qualStr;
            }

            if (_value.isArray())
            {
                Array<CIMInstance> embeddedInstances;
                _value.get(embeddedInstances);
                for (Uint32 i = 0, n = embeddedInstances.size(); i < n; ++i)
                {
                    classNames.append(embeddedInstances[i].getClassName());
                }
            }
            else
            {
                CIMInstance embeddedInst;
                _value.get(embeddedInst);
                classNames.append(embeddedInst.getClassName());
            }
        }
        else
        {
            CIMName referenceClass;
            if (_referenceClassName.isNull())
            {
                CIMObjectPath reference;
                _value.get(reference);
                referenceClass = reference.getClassName();
            }
            else
            {
                referenceClass = _referenceClassName;
            }

            inheritedClassName = inheritedProperty.getReferenceClassName();
            classNames.append(referenceClass);
        }

        // This algorithm is friendly to arrays of embedded instances. It
        // remembers the class names that are found to be subclasses of the
        // inherited class name retrieved from the inherited property. This
        // ensures that any branch in the inheritance hierarchy will only be
        // traversed once. This provides significant optimization given that
        // most elements of an array of embedded instances will probably be of
        // very closely related types.
        Array<CIMName> successTree;
        successTree.append(inheritedClassName);
        for (Uint32 i = 0, n = classNames.size(); i < n; ++i)
        {
            Array<CIMName> traversalHistory;
            CIMName currentName = classNames[i];
            Boolean found = false;
            while (!found && !currentName.isNull())
            {
                for (Uint32 j = 0, m = successTree.size(); j < m; ++j)
                {
                    if (currentName == successTree[j])
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    traversalHistory.append(currentName);
                    CIMClass currentClass = declContext->lookupClass(
                            nameSpace, currentName);
                    if (currentClass.isUninitialized())
                    {
                        throw PEGASUS_CIM_EXCEPTION(
                            CIM_ERR_INVALID_PARAMETER, currentName.getString());
                    }
                    currentName = currentClass.getSuperClassName();
                }
            }

            if (!found)
            {
                throw TypeMismatchException();
            }

            successTree.appendArray(traversalHistory);
        }
    }

    _qualifiers.resolve(
        declContext, nameSpace, scope, isInstancePart,
        inheritedProperty._rep->_qualifiers, propagateQualifiers);

    _classOrigin = inheritedProperty.getClassOrigin();
}
Пример #26
0
//
// Initialize the namespaces so that all namespaces with the
// CIM_ElementConformsToProfile class also have the
// PG_ElementConformsToProfile class. Needed in order to implement
// the cross-namespace ElementConformsToProfile association in both
// directions.
//
void InteropProvider::initializeNamespaces()
{
    Array<CIMNamespaceName> namespaceNames =  repository->enumerateNameSpaces();
    // get the PG_ElementConformstoProfile class without the qualifiers
    // and then add just the required ASSOCIATION qualifier, so that
    // resolveclass doesn't fail for the test/EmbeddedInstance/Dynamic
    // namespace, which uses the CIM25 schema that doesn't include any
    // of the new qualifiers added to this class in later versions of
    // the CIMSchema.
    CIMClass conformsClass = repository->getClass(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE,
        true,
        false);
    conformsClass.addQualifier(
        CIMQualifier(CIMName("ASSOCIATION"), CIMValue(true)));
    CIMClass profileClass = repository->getClass(
        PEGASUS_NAMESPACENAME_INTEROP,
        PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE,
        true,
        false);
    for(Uint32 i = 0, n = namespaceNames.size(); i < n; ++i)
    {
        // Check if the PG_ElementConformsToProfile class is present
        CIMNamespaceName & currentNamespace = namespaceNames[i];
        CIMClass tmpCimClass;
        CIMClass tmpPgClass;
        CIMClass tmpPgProfileClass;
        try
        {
            // Look for these classes in the same try-block since the
            // second depends on the first
            tmpCimClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_CIM_ELEMENTCONFORMSTOPROFILE);
            tmpPgClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_PG_ELEMENTCONFORMSTOPROFILE);
        }
        catch(const Exception &)
        {
        }
        try
        {
            tmpPgProfileClass = repository->getClass(
                currentNamespace,
                PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE);
        }
        catch(const Exception &)
        {
            // Note: if any of the above three classes aren't found,
            // an exception will be thrown, which we can ignore since it's
            // an expected case
            // TBD: Log trace message?
        }

        // If the CIM_ElementConformsToProfile class is present, but
        // the PG_ElementConformsToProfile or PG_RegisteredProfile
        // class is not, then add it to that namespace.
        //
        // Note that we don't have to check for the
        // CIM_RegisteredProfile class because if the
        // CIM_ElementConformsToProfile class is present, the
        // CIM_RegisteredProfile class must also be present.
        if(!tmpCimClass.isUninitialized())
        {
            if(tmpPgClass.isUninitialized())
            {
                CIMClass newclass = conformsClass.clone();
                CIMObjectPath newPath = conformsClass.getPath();
                newPath.setNameSpace(currentNamespace);
                newclass.setPath(newPath);
                repository->createClass(
                    currentNamespace,
                    newclass);
            }
            if(tmpPgProfileClass.isUninitialized())
            {
                CIMClass newclass = profileClass.clone();
                CIMObjectPath newPath = profileClass.getPath();
                newPath.setNameSpace(currentNamespace);
                newclass.setPath(newPath);
                repository->createClass(
                    currentNamespace,
                    newclass);
            }
        }
    }
}
Пример #27
0
int _getClass(const int argc, const char **argv)
{
  CIMClass cldef;
  try
  {
    cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] );
  }
  catch (Exception& e)
  {
    cerr << /* "getClass: " << */ e.getMessage() << endl;
    return 1;
  }

  // Display the class definition
  // without qualifiers, for the moment

  // First the class name and superclass
  cout << "class " << cldef.getClassName().getString() << " : "
    << cldef.getSuperClassName().getString() << endl;
  cout << "{" << endl;
  
  // Now the properties
  // No qualifiers except [key], but specify type, array
  for (int i=0; i<cldef.getPropertyCount(); i++)
  {
    CIMProperty p = cldef.getProperty(i);
    cout << "  ";
    // output key, if required
    if (_isKey(p)) cout << "[ Key ] ";
    // prepare to output type, but
    // first, if type is "reference", find target class
    if (p.getType() == CIMTYPE_REFERENCE)
      cout << p.getReferenceClassName().getString() << " REF ";
    // output type
    else cout << cimTypeToString(p.getType()) << " ";
    // output name
    cout << p.getName().getString();
    // output array, if required
    if (p.isArray()) cout << "[]";
    // final eol
    cout << ";" << endl;
  }
  
  // need to do methods
  for (int i=0; i<cldef.getMethodCount(); i++)
  {
    CIMMethod m = cldef.getMethod(i);
    // output type
    cout << "  " << cimTypeToString(m.getType()) << " ";
    // output name
    cout << m.getName().getString() << "(";
    // output parameters
    // new line if there are any parameters
    for (int j=0; j<m.getParameterCount(); j++)
    {
      CIMParameter p = m.getParameter(j);
      // output IN/OUT qualifiers on a fresh line
      cout << endl << "    [ ";
      // loop through qualifiers looking for IN, OUT
      for (int k=0; k<p.getQualifierCount(); k++)
      {
        // when one found, output its value
        CIMQualifier q = p.getQualifier(k);
        if (q.getName().equal("in") ||
            q.getName().equal("out"))
        {
          cout << q.getName().getString() << " ";
        }
      }
      // Now the type
      cout << "] " << cimTypeToString(p.getType()) << " ";
      // finally the name
      cout << p.getName().getString();
      // array brackets
      if (p.isArray()) cout << "[]";
      // closing , on parameter if not last
      if (j != m.getParameterCount()-1) cout << ",";
    }
    // after last param, indent before closing paren

    // close paren
    cout << ")";
    // if (m.isArray()) cout << "[]";
    // finish output
    cout << ";" << endl;
  }
  
  // final brace and done
  cout << "};" << endl;

  return 0; 
}
Пример #28
0
void CIMQualifierList::resolve(
    DeclContext* declContext,
    const CIMNamespaceName & nameSpace,
    CIMScope scope, // Scope of the entity being resolved.
    Boolean isInstancePart,
    CIMQualifierList& inheritedQualifiers,
    Boolean propagateQualifiers)
{
    _keyIndex = PEGASUS_ORDEREDSET_INDEX_UNKNOWN;

    PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMQualifierList::resolve()");
    // For each qualifier in the qualifiers array, the following
    // is checked:
    //
    //     1. Whether it is declared (can be obtained from the declContext).
    //
    //     2. Whether it has the same type as the declaration.
    //
    //     3. Whether the qualifier is valid for the given scope.
    //
    //     4. Whether the qualifier can be overriden (the flavor is
    //        ENABLEOVERRIDE on the corresponding reference qualifier).
    //
    //     5. Whether the qualifier should be propagated to the subclass.
    //
    // If the qualifier should be overriden, then it is injected into the
    // qualifiers array (from the inheritedQualifiers array).

    for (Uint32 i = 0, n = _qualifiers.size(); i < n; i++)
    {
        CIMQualifier q = _qualifiers[i];
        //----------------------------------------------------------------------
        // 1. Check to see if it's declared.
        //----------------------------------------------------------------------
        // set this back to  CIMConstQualifierDecl
        CIMQualifierDecl qd = declContext->lookupQualifierDecl(
            nameSpace, q.getName());

        if (qd.isUninitialized())
        {
            PEG_METHOD_EXIT();
            throw UndeclaredQualifier(q.getName().getString ());
        }

        //----------------------------------------------------------------------
        // 2. Check the type and isArray.  Must be the same:
        //----------------------------------------------------------------------

        if (!(q.getType() == qd.getType() && q.isArray() == qd.isArray()))
        {
            PEG_METHOD_EXIT();
            throw BadQualifierType(q.getName().getString ());
        }

        //----------------------------------------------------------------------
        // 3. If the qualifier is the EmbeddedInstance qualifier, then check
        // that the class specified by the qualifier exists in the namespace.
        //----------------------------------------------------------------------
        if (q.getName().equal(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE))
        {
            String className;
            q.getValue().get(className);
            CIMClass classDef = declContext->lookupClass(nameSpace,
                    CIMName(className));
            if (classDef.isUninitialized())
            {
                String embeddedInstType("EmbeddedInstance(\"");
                embeddedInstType = embeddedInstType + className + "\")";
                PEG_METHOD_EXIT();
                throw BadQualifierType(embeddedInstType);
            }
        }

        //----------------------------------------------------------------------
        // 4. Check the scope: Must be legal for this qualifier
        //----------------------------------------------------------------------
        // ATTN:  These lines throw a bogus exception if the qualifier has
        // a valid scope (such as Scope::ASSOCIATION) which is not Scope::CLASS
        // ks Mar 2002. Reinstalled 23 March 2002 to test.

        if (!(qd.getScope().hasScope (scope)))
        {
            PEG_METHOD_EXIT();
            throw BadQualifierScope
                (qd.getName().getString (), scope.toString ());
        }

        //----------------------------------------------------------------------
        // Resolve the qualifierflavor. Since Flavors are a combination of
        // inheritance and input characteristics, resolve the inherited
        // characteristics against those provided with the creation.  If
        // there is a superclass the flavor is resolved against that
        // superclass.  If not, it is resolved against the declaration. If
        // the flavor is disableoverride and tosubclass the resolved
        // qualifier value must be identical to the original
        //----------------------------------------------------------------------
        // Test for Qualifier found in SuperClass. If found and qualifier
        // is not overridable.
        // Abstract (not Overridable and restricted) can be found in subclasses
        // Can have nonabstracts below abstracts. That is function of
        // nottosubclass Association (notOverridable and tosubclass) can be
        // found in subclasses but cannot be changed. No non-associatons below
        // associations. In other words once a class becomes an association,
        // no subclass can override that definition apparently
        // Throw exception if DisableOverride and tosubclass and different
        // value.  Gets the source from superclass if qualifier exists or from
        // declaraction.
        // If we do not throw the exception, resolve the flavor from the
        // inheritance point and resolve against current input.
        // Diableoverride is defined in the CIM Spec to mean that the value
        // cannot change.
        // The other characteristics including the flavor can change
        // apparently. Thus, we need only confirm that the value is the same
        // (2.2 pp 33).  Strange since we would think that override implies
        // that you cannot override any of the characteristics (value, type,
        // flavor, etc.) This also leaves the question of NULL or no values.
        // The implication is that we must move the value from the superclass
        // or declaration.

        Uint32 index = inheritedQualifiers.find(q.getName());

        if (index == PEG_NOT_FOUND)
        {   // Qualifier does not exist in superclass
            /* If from declaration, we can override the default value.
              However, we need some way to get the value if we have a Null.
            if (!qd.getFlavor().hasFlavor(CIMFlavor::OVERRIDABLE) &&
                qd.getFlavor().hasFlavor(CIMFlavor::TOSUBCLASS))
            {
                //throw BadQualifierOverride(q.getName());
            }
            */
            // Do not allow change from disable override to enable override.
            if ((!qd.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                  && (q.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE)))
            {
                PEG_METHOD_EXIT();
                throw BadQualifierOverride(q.getName().getString ());
            }

            Resolver::resolveQualifierFlavor(
                q, CIMFlavor (qd.getFlavor ()), false);
        }
        else  // qualifier exists in superclass
        {   ////// Make Const again
            CIMQualifier iq = inheritedQualifiers.getQualifier(index);
            // don't allow change override to notoverride.
            if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                  && q.getFlavor ().hasFlavor (CIMFlavor::OVERRIDABLE))
            {
                PEG_METHOD_EXIT();
                throw BadQualifierOverride(q.getName().getString ());
            }

            if (!(iq.getFlavor ().hasFlavor(CIMFlavor::OVERRIDABLE))
                  && iq.getFlavor ().hasFlavor(CIMFlavor::TOSUBCLASS))
            {
                // test if values the same.
                CIMValue qv = q.getValue();
                CIMValue iqv = iq.getValue();
                if (!(qv == iqv))
                {
                    PEG_METHOD_EXIT();
                    throw BadQualifierOverride(q.getName().getString());
                }
            }

            Resolver::resolveQualifierFlavor(
                q, CIMFlavor(iq.getFlavor()), true);
        }
    }   // end of this objects qualifier loop

    //--------------------------------------------------------------------------
    // Propagate qualifiers to subclass or to instance that do not have
    // already have those qualifiers:
    //--------------------------------------------------------------------------

    if (propagateQualifiers)
    {
        for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)
        {
            CIMQualifier iq = inheritedQualifiers.getQualifier(i);

            if (isInstancePart)
            {
                if (!(iq.getFlavor().hasFlavor(CIMFlavor::TOINSTANCE)))
                    continue;
            }
            else
            {
                if (!(iq.getFlavor().hasFlavor(CIMFlavor::TOSUBCLASS)))
                    continue;
            }

            // If the qualifiers list does not already contain this qualifier,
            // then propagate it (and set the propagated flag to true).  Else
            // we keep current value. Note we have already eliminated any
            // possibility that a nonoverridable qualifier can be in the list.
            if (find(iq.getName()) != PEG_NOT_FOUND)
                continue;

            CIMQualifier q = iq.clone();
            q.setPropagated(true);
            _qualifiers.insert(0, q);
        }
    }
    PEG_METHOD_EXIT();
}
Пример #29
0
//
//  Test identical() function with keys that are references
//
void test04()
{
    //
    // Create classes A and B referenced classes, C - Association
    //
    CIMClass classA (CIMName ("A"), CIMName ());
    CIMProperty propertyX ("x", String ());
    propertyX.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyY ("y", String ());
    propertyY.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyZ ("z", String ());
    propertyZ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classA.addProperty (propertyX);
    classA.addProperty (propertyY);
    classA.addProperty (propertyZ);

    CIMClass classB ("B");
    CIMProperty propertyQ ("q", String ());
    propertyQ.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyR ("r", String ());
    propertyR.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyS ("s", String ());
    propertyS.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classB.addProperty (propertyQ);
    classB.addProperty (propertyR);
    classB.addProperty (propertyS);

    CIMClass classC ("C");
    CIMProperty propertyA ("a", CIMValue ());
    propertyA.addQualifier (CIMQualifier (CIMName ("Key"), true));
    CIMProperty propertyB ("b", CIMValue ());
    propertyB.addQualifier (CIMQualifier (CIMName ("Key"), true));
    classC.addProperty (propertyA);
    classC.addProperty (propertyB);

    //
    //  Create instances of each classa
    //
    CIMInstance instanceA (CIMName ("A"));
    instanceA.addProperty (CIMProperty (CIMName ("x"), String ("rose")));
    instanceA.addProperty (CIMProperty (CIMName ("y"), String ("lavender")));
    instanceA.addProperty (CIMProperty (CIMName ("z"), String ("rosemary")));
    CIMObjectPath aPath = instanceA.buildPath (classA);
    CIMObjectPath aPath2 ("A.y=\"lavender\",x=\"rose\",z=\"rosemary\"");
    PEGASUS_TEST_ASSERT (aPath.identical (aPath2));

    CIMInstance instanceB (CIMName ("B"));
    instanceB.addProperty (CIMProperty (CIMName ("q"),
        String ("pelargonium")));
    instanceB.addProperty (CIMProperty (CIMName ("r"), String ("thyme")));
    instanceB.addProperty (CIMProperty (CIMName ("s"), String ("sage")));

    // Test to assure that the buildpath function works.
    CIMObjectPath bPath = instanceB.buildPath (classB);
    CIMObjectPath bPath2 ("B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"");
    PEGASUS_TEST_ASSERT (bPath.identical (bPath2));

    // Build instance of C and build path from buildPath function.
    CIMInstance instanceC (CIMName ("C"));
    instanceC.addProperty (CIMProperty (CIMName ("a"), aPath, 0,
        CIMName ("A")));
    instanceC.addProperty (CIMProperty (CIMName ("b"), bPath, 0,
        CIMName ("B")));
    CIMObjectPath cPath = instanceC.buildPath (classC);

    // Build CIMObjectPath from keybindings.
    Array <CIMKeyBinding> keyBindings;
    CIMKeyBinding aBinding ("a", "A.y=\"lavender\",x=\"rose\",z=\"rosemary\"",
        CIMKeyBinding::REFERENCE);
    CIMKeyBinding bBinding ("b", "B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"",
        CIMKeyBinding::REFERENCE);
    keyBindings.append (aBinding);
    keyBindings.append (bBinding);

    CIMObjectPath cPath2 ("", CIMNamespaceName (),
        cPath.getClassName (), keyBindings);

    // Assert that the CIMObjectPaths for C from build path and direct
    // from keybindings are equal.
    PEGASUS_TEST_ASSERT (cPath.identical (cPath2));

    // ATTN: KS 25 Feb 2003 P3 - Think we can extend these tests
    // since this is creation of classes and
    // instnaces for associations and referenced classes.
}
Пример #30
0
/////////////////////////////////////////////////////////////////////////////
// WMIClassProvider::enumerateClasses
//
// ///////////////////////////////////////////////////////////////////////////
Array<CIMClass> WMIClassProvider::enumerateClasses(
        const String& nameSpace,
		const String& userName,
		const String& password,
        const String& className,
        Boolean deepInheritance ,
        Boolean localOnly,
        Boolean includeQualifiers,
        Boolean includeClassOrigin)
{
	PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIClassProvider::enumerateClasses()");
	
	HRESULT hr;
	long lCount = 0;
	DWORD dwReturned;
	CComPtr<IEnumWbemClassObject>	pClassEnum;
	CComPtr<IWbemClassObject>		pClass;
	Array<CIMClass>					cimClasses;

	setup(nameSpace,userName,password);

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"enumerateClasses - deepInheritance %x, localOnly %x, includeQualifiers %x, includeClassOrigin %x", 
		deepInheritance, localOnly, includeQualifiers, includeClassOrigin);
	
	if (!m_bInitialized)
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::enumerateClasses - m_bInitilized= %x, throw CIM_ERR_FAILED exception",  
			m_bInitialized);

		throw CIMException(CIM_ERR_FAILED);
	}

	if (!(_collector->getClassEnum(&pClassEnum, className, deepInheritance)))
	{
		if (pClassEnum) 
			pClassEnum.Release();

		throw CIMException(CIM_ERR_FAILED);
	}

	// set proxy security on pClassEnum
	bool bSecurity = _collector->setProxySecurity(pClassEnum);

	//
	//TODO:  What happens if bSecurity is false
	//

	// get the classes and append them to the array
	hr = pClassEnum->Next(WBEM_INFINITE, 1, &pClass, &dwReturned);

	while (SUCCEEDED(hr) && (1 == dwReturned))
	{
		String className = _collector->getClassName(pClass);
		String superClass = _collector->getSuperClass(pClass);

		CIMName objName = className;

		CIMClass tempClass = CIMClass(objName);

		if (0 != superClass.size())
		{
			CIMName superclassName = superClass;
			tempClass.setSuperClassName(superclassName);
		}

		if (_collector->getCIMClass(pClass,
					tempClass,
					localOnly,
					includeQualifiers,
					includeClassOrigin))
		{
			lCount++;
			cimClasses.append(tempClass);
		}
		
		if (pClass) 
			pClass.Release();

		hr = pClassEnum->Next(WBEM_INFINITE, 1, &pClass, &dwReturned);
	}

	if (pClassEnum) 
		pClassEnum.Release();

	Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
		"WMIClassProvider::enumerateClasses() - Class count is %d", lCount); 

	if (lCount == 0)
	{
		Tracer::trace(TRC_WMIPROVIDER, Tracer::LEVEL3,
			"WMIClassProvider::enumerateClasses() - no classes found, hResult value is %x", hr);
	}

	PEG_METHOD_EXIT();

	return cimClasses;
}