Example #1
0
void InstanceProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
    // Validate the class name
    if (!instanceObject.getClassName().equal("Sample_InstanceProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("Identifier");

    if (idIndex == PEG_NOT_FOUND)
    {
        throw CIMInvalidParameterException("Missing key value");
    }

    CIMInstance cimInstance = instanceObject.clone();

    // Create the new instance name
    CIMValue idValue = instanceObject.getProperty(idIndex).getValue();
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding("Identifier", idValue));
    CIMObjectPath instanceName = CIMObjectPath(
        String(),
        CIMNamespaceName(),
        instanceObject.getClassName(),
        keys);

    cimInstance.setPath(instanceName);
    
    // Determine whether this instance already exists
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(instanceName == _instances[i].getPath())
        {
            throw CIMObjectAlreadyExistsException(instanceName.toString());
        }
    }

    // begin processing the request
    handler.processing();

    // add the new instance to the array
    _instances.append(cimInstance);

    // deliver the new instance name
    handler.deliver(instanceName);

    // complete processing the request
    handler.complete();
}
Example #2
0
void InstanceProvider::modifyInstance(
	const OperationContext & context,
	const CIMObjectPath & instanceReference,
	const CIMInstance & instanceObject,
	const Boolean includeQualifiers,
	const CIMPropertyList & propertyList,
	ResponseHandler & handler)
{
	// convert a potential fully qualified reference into a local reference
	// (class name and keys only).
	CIMObjectPath localReference = CIMObjectPath(
		String(),
		CIMNamespaceName(),
		instanceReference.getClassName(),
		instanceReference.getKeyBindings());
	
	// begin processing the request
	handler.processing();

	// instance index corresponds to reference index
	for(Uint32 i = 0, n = _instances.size(); i < n; i++)
	{
		if(localReference == _instances[i].getPath())
		{
                       CIMInstance cimInstance = instanceObject.clone();

                       CIMObjectPath instanceName = CIMObjectPath(
                               String(),
                               CIMNamespaceName(),
                               instanceReference.getClassName(),
                               instanceReference.getKeyBindings());

                        cimInstance.setPath(instanceName);

			// overwrite existing instance
			_instances[i] = instanceObject;
			
			break;
		}
	}
	
	// complete processing the request
	handler.complete();
}
Example #3
0
void testEmbeddedValueArray(const CIMInstance & startInstance,
                            const CIMNamespaceName & NAMESPACE,
                            SimpleDeclContext * context)
{
    CIMInstance instance1(startInstance.clone());
    // Test an array of CIMObjects that are CIMInstances
    CIMInstance instance2(CIMName ("MyClass"));
    instance2.addQualifier(CIMQualifier(CIMName ("classcounter"), true));
    instance2.addProperty(CIMProperty(CIMName ("message"), String("Adios")));
    Resolver::resolveInstance (instance2, context, NAMESPACE, true);

    CIMInstance instance3(CIMName ("MyClass"));
    instance3.addQualifier(CIMQualifier(CIMName ("classcounter"), false));
    instance3.addProperty(CIMProperty(CIMName ("message"),
                String("Au Revoir")));
    Resolver::resolveInstance (instance3, context, NAMESPACE, true);

    Array<EmbeddedType> arr16;
    arr16.append(EmbeddedType(instance1));
    arr16.append(EmbeddedType(instance2));
    arr16.append(EmbeddedType(instance3));
    test02(arr16);

    // Specific test to verify the cloning of CIMObjects when set as and
    // gotten from a CIMValue.
    CIMValue v1array;
    // Create CIMValue v1 of type CIMTYPE_OBJECT (ie. CIMObject)
    v1array.set(arr16);
    // Change the "count" property of arr16[1], and then verify
    // that the CIMValue v1array, that was set from arr16, is
    // not affected (ie. tests clone() on CIMValue::set() ).
    Uint32 propIx = arr16[1].findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v2 = arr16[1].getProperty(propIx).getValue();
    Uint32 propCount;
    v2.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);
    arr16[1].removeProperty(propIx);
    arr16[1].addProperty(CIMProperty(CIMName ("count"), Uint32(65))
        .addQualifier(CIMQualifier(CIMName ("counter"), true))
        .addQualifier(CIMQualifier(CIMName ("min"), String("0")))
        .addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
    Array<EmbeddedType> object2array;
    v1array.get(object2array);
    CIMInstance instance2a(object2array[1]);
    propIx = instance2a.findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v3 = instance2a.getProperty(propIx).getValue();
    v3.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);
    // Now change the "count" property of instance2a, which was obtained
    // from a get of CIMValue v1array. Again, the underlying CIMValue should
    // not be affected (ie. tests clone() on CIMValue::get() ).
    instance2a.removeProperty(propIx);
    instance2a.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
       .addQualifier(CIMQualifier(CIMName ("counter"), true))
       .addQualifier(CIMQualifier(CIMName ("min"), String("0")))
       .addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
    Array<EmbeddedType> object3array;
    v1array.get(object3array);
    CIMInstance instance2b(object3array[1]);
    propIx = instance2b.findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v4 = instance2b.getProperty(propIx).getValue();
    v4.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);

    // Specific test for setting value as a null CIMObject() (see bug 3373).
    // Confirm that CIMValue() with an uninitialized CIMObject in the input
    // array will throw exception.
    arr16.append(EmbeddedType());
    bool caught_exception = false;
    try
    {
        CIMValue y(arr16);
    }
    catch(UninitializedObjectException&)
    {
        caught_exception = true;
    }
    PEGASUS_TEST_ASSERT (caught_exception == true);
    // Confirm that set() with an uninitialized CIMObject in the input
    // array will throw exception.
    caught_exception = false;
    try
    {
        CIMValue y;
        y.set(arr16);
    }
    catch(UninitializedObjectException&)
    {
        caught_exception = true;
    }
    PEGASUS_TEST_ASSERT (caught_exception == true);
}
Example #4
0
void testEmbeddedValue(const CIMInstance & instance)
{
    CIMInstance instance1 = instance.clone();
    // Specific test to verify the cloning of CIMObjects/CIMInstances when set
    // and gotten from a CIMValue.
    CIMValue v1;
    // Create CIMValue v1 of type CIMTYPE_OBJECT/CIMTYPE_INSTANCE
    v1.set(EmbeddedType(instance1));
    // Change the "count" property of instance1, and then verify
    // that the CIMValue v1, that was set from instance1, is
    // not affected (ie. tests clone() on CIMValue::set() ).
    Uint32 propIx = instance1.findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v2 = instance1.getProperty(propIx).getValue();
    Uint32 propCount;
    v2.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);
    instance1.removeProperty(propIx);
    instance1.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
        .addQualifier(CIMQualifier(CIMName ("counter"), true))
        .addQualifier(CIMQualifier(CIMName ("min"), String("0")))
        .addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
    EmbeddedType object2;
    v1.get(object2);
    CIMInstance instance1a(object2);
    propIx = instance1a.findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v3 = instance1a.getProperty(propIx).getValue();
    v3.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);
    // Now change the "count" property of instance1a, which was obtained
    // from a get of CIMValue v1. Again, the underlying CIMValue should
    // not be affected (ie. tests clone() on CIMValue::get() ).
    instance1a.removeProperty(propIx);
    instance1a.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
        .addQualifier(CIMQualifier(CIMName ("counter"), true))
        .addQualifier(CIMQualifier(CIMName ("min"), String("0")))
        .addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
    EmbeddedType object3;
    v1.get(object3);
    CIMInstance instance1b(object3);
    propIx = instance1b.findProperty(CIMName("count"));
    PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
    CIMValue v4 = instance1b.getProperty(propIx).getValue();
    v4.get(propCount);
    PEGASUS_TEST_ASSERT(propCount == 55);

    // Specific test for setting value as a null CIMObject/CIMInstance
    // (see bug 3373).
    // Confirm that CIMValue() with an uninitialized CIMObject/CIMInstance will
    // throw exception.
    Boolean caught_exception = false;
    try
    {
        EmbeddedType obj = EmbeddedType();
        CIMValue y(obj);
    }
    catch(UninitializedObjectException&)
    {
        caught_exception = true;
    }
    PEGASUS_TEST_ASSERT (caught_exception == true);
    // Confirm that set() with an uninitialized CIMObject/CIMInstance will
    // throw exception.
    caught_exception = false;
    try
    {
        CIMValue y;
        y.set(EmbeddedType());
    }
    catch(UninitializedObjectException&)
    {
        caught_exception = true;
    }
    PEGASUS_TEST_ASSERT (caught_exception == true);
}
Example #5
0
//
// Modify instance based on modifiedInstance.
//
void UserAuthProvider::modifyInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance& modifiedIns,
    const Boolean includeQualifiers,
    const CIMPropertyList & propertyList,
    ResponseHandler & handler)
{
    PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance");

    //
    // get userName
    //
    String user;
    try
    {
        IdentityContainer container = context.get(IdentityContainer::NAME);
        user= container.getUserName();
    }
    catch (...)
    {
        user= String::EMPTY;
    }

    //
    // verify user authorizations
    //
    if ( user != String::EMPTY || user != "" )
    {
        _verifyAuthorization(user);
    }

    //
    // check if the class name requested is PG_Authorization
    //
    if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION))
    {
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION (
            CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString());
    }

    CIMInstance newInstance = modifiedIns;

    // begin processing the request
    handler.processing();

    try
    {
        //
        // Get the user name from the instance
        //
        String userNameStr;
        String namespaceStr;
        String authorizationStr;

        Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME );
        CIMProperty prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(userNameStr);

        //
        // Get the namespace from the instance
        //
        pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE );
        prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(namespaceStr);

        //
        // Get the authorization from the instance
        //
        pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION );
        prop = (CIMProperty)newInstance.getProperty(pos);
        prop.getValue().get(authorizationStr);

        //
        // ATTN: Note that the following is a hack, because
        // modifyInstance() in repository does not like
        // the hostname and namespace included in the CIMObjectPath
        // passed to it as a parameter.
        //
        CIMObjectPath ref("", CIMNamespaceName (),
                          modifiedIns.getClassName(), instanceReference.getKeyBindings());

        CIMInstance newModifiedIns = modifiedIns.clone ();
        newModifiedIns.setPath (ref);

        //
        // call modifyInstances of the repository
        //
        _repository->modifyInstance(
            instanceReference.getNameSpace(), newModifiedIns);

        //
        // set authorization in the UserManager
        //
        _userManager->setAuthorization(
            userNameStr, namespaceStr, authorizationStr );

    }
    catch(Exception& e)
    {
        PEG_METHOD_EXIT();
        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
    }

    // complete processing the request
    handler.complete();

    PEG_METHOD_EXIT();
    return;
}
Example #6
0
//
// Test of the Instance creation and instance filtering
//
void test04()
{
    if (verbose)
    {
        cout << "Test04 - Create instance from Class. " << endl;
    }

    const CIMNamespaceName NAMESPACE = CIMNamespaceName("/zzz");

    // Create and populate a declaration context:

    SimpleDeclContext* context = new SimpleDeclContext;

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("counter"), false,
        CIMScope::PROPERTY));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("classcounter"), false,
        CIMScope::CLASS));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("min"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(
        NAMESPACE, CIMQualifierDecl(CIMName("max"), String(),
        CIMScope::PROPERTY));

    context->addQualifierDecl(NAMESPACE,
        CIMQualifierDecl(CIMName("Description"), String(),
        CIMScope::PROPERTY));

    CIMClass class1(CIMName("MyClass"));

    class1
        .addProperty(CIMProperty(CIMName("count"), Uint32(55))
            .addQualifier(CIMQualifier(CIMName("counter"), true))
            .addQualifier(CIMQualifier(CIMName("min"), String("0")))
            .addQualifier(CIMQualifier(CIMName("max"), String("1"))))
        .addProperty(CIMProperty(CIMName("message"), String("Hello"))
            .addQualifier(CIMQualifier(CIMName("description"),
                String("My Message"))))
        .addProperty(CIMProperty(CIMName("ratio"), Real32(1.5)));


    Resolver::resolveClass(class1, context, NAMESPACE);
    context->addClass(NAMESPACE, class1);


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

    //
    // Create instance with qualifiers, classorigin, and Null propertyList
    //
    {
        CIMInstance newInstance;

        newInstance = class1.buildInstance(true, true, CIMPropertyList());

        if (verbose)
        {
            XmlWriter::printInstanceElement(newInstance);
        }

        assert(newInstance.getPropertyCount() == class1.getPropertyCount());
        assert(newInstance.getQualifierCount() == class1.getQualifierCount());
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") != PEG_NOT_FOUND);

    }

    //
    // Test with include qualifiers false. Should be no qualifiers in result
    //
    {
        CIMInstance newInstance =
            class1.buildInstance(false, true, CIMPropertyList());

        assert(newInstance.getQualifierCount() == 0);
        assert(newInstance.getPropertyCount() == class1.getPropertyCount());
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") != PEG_NOT_FOUND);
    }

    //
    // Test with empty property list.  Should have no properties.
    //
    {
        Array<CIMName> pl1Array;
        CIMPropertyList pl1(pl1Array);

        CIMInstance newInstance = class1.buildInstance(false, true, pl1);

        assert(newInstance.getQualifierCount() == 0);
        assert(newInstance.getPropertyCount() == 0);
    }

    //
    // Test with a property that exists in property list.
    //
    {
        Array<CIMName> pl1Array;
        pl1Array.append("ratio");
        CIMPropertyList pl1(pl1Array);

        CIMInstance newInstance = class1.buildInstance(false, true, pl1);

        if (verbose)
        {
            cout << "Test with one property in new instance" << endl;
            XmlWriter::printInstanceElement(newInstance);
        }

        assert(newInstance.getPropertyCount() == 1);
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") == PEG_NOT_FOUND);
        assert(newInstance.getQualifierCount() == 0);
    }

    //
    // Test with a property that does/does not exist in property list
    //
    {
        Array<CIMName> pl1Array;
        CIMPropertyList pl1(pl1Array);
        pl1.clear();
        pl1Array.append("blob");
        pl1Array.append("ratio");
        pl1.set(pl1Array);

        CIMInstance newInstance = class1.buildInstance(false, true, pl1);

        assert(newInstance.getPropertyCount() == 1);
        assert(newInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(newInstance.findProperty("blob") == PEG_NOT_FOUND);
        assert(newInstance.findProperty("message") == PEG_NOT_FOUND);
        assert(newInstance.getQualifierCount() == 0);
    }

    ///////////////////////////////////////////////////////////////////////
    //
    // Instance Filtering function tests
    //
    ///////////////////////////////////////////////////////////////////////

    // build instance as starting point for tests.
    CIMInstance tstInstance =
        class1.buildInstance(true, true, CIMPropertyList());

    //
    // Test complete copy, no change
    //
    {
        if (verbose)
        {
            cout << "Test1" << endl;
        }

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, CIMPropertyList());

        assert(tstInstance.identical(filterInstance));
        assert(filterInstance.getPropertyCount() == 3);
        assert(filterInstance.getQualifierCount() ==
            tstInstance.getQualifierCount());
    }

    //
    // Filter to one property, ratio
    //
    {
        if (verbose)
        {
            cout << "Test2" << endl;
        }

        Array<CIMName> pl1Array;
        pl1Array.append("ratio");
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        if (verbose)
        {
            XmlWriter::printInstanceElement(filterInstance);
        }

        assert(filterInstance.getPropertyCount() == 1);
        assert(filterInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(_propertyIdentical("ratio", filterInstance, tstInstance));
        assert(filterInstance.getQualifierCount() ==
                tstInstance.getQualifierCount());
    }

    //
    // Filter to one property, message
    //
    {
        if (verbose)
        {
            cout << "Test3" << endl;
        }

        Array<CIMName> pl1Array;
        pl1Array.append("message");
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        if (verbose)
        {
            XmlWriter::printInstanceElement(filterInstance);
        }

        assert(filterInstance.getPropertyCount() == 1);
        assert(filterInstance.findProperty("message") != PEG_NOT_FOUND);
        assert(_propertyIdentical("message", filterInstance, tstInstance));
        assert(filterInstance.getQualifierCount() ==
                tstInstance.getQualifierCount());
    }

    //
    // Filter to one property, count
    //
    {
        if (verbose)
        {
            cout << "Test4" << endl;
        }

        Array<CIMName> pl1Array;
        pl1Array.append("count");
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        if (verbose)
        {
            XmlWriter::printInstanceElement(filterInstance);
        }

        assert(filterInstance.getPropertyCount() == 1);
        assert(filterInstance.findProperty("count") != PEG_NOT_FOUND);
        assert(filterInstance.getQualifierCount() ==
                tstInstance.getQualifierCount());
    }

    //
    // Filter to no properties
    //
    {
        if (verbose)
        {
            cout << "Test5a" << endl;
        }

        Array<CIMName> pl1Array;
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        assert(filterInstance.getPropertyCount() == 0);
        assert(filterInstance.findProperty("ratio") == PEG_NOT_FOUND);
        assert(filterInstance.getQualifierCount() ==
            tstInstance.getQualifierCount());
    }

    //
    // Filter to two properties
    //
    {
        if (verbose)
        {
            cout << "Test5b" << endl;
        }

        Array<CIMName> pl1Array;
        pl1Array.append("count");
        pl1Array.append("message");
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(true, true, pl1);

        assert(filterInstance.getPropertyCount() == 2);
        assert(filterInstance.findProperty("ratio") == PEG_NOT_FOUND);
        assert(filterInstance.findProperty("message") != PEG_NOT_FOUND);
        assert(_propertyIdentical("message", filterInstance, tstInstance));
        assert(filterInstance.findProperty("count") != PEG_NOT_FOUND);
        assert(_propertyIdentical("count", filterInstance, tstInstance));
        assert(filterInstance.getQualifierCount() ==
                tstInstance.getQualifierCount());
    }

    //
    // Filter to no qualifiers and all properties.
    //
    {
        if (verbose)
        {
            cout << "Test6" << endl;
        }

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(false, true, CIMPropertyList());

        assert(filterInstance.getPropertyCount() == 3);
        assert(filterInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(filterInstance.getQualifierCount() == 0);
        for (Uint32 i = 0; i < filterInstance.getPropertyCount() ; i++)
        {
            CIMConstProperty p = filterInstance.getProperty(i);
            assert(p.getQualifierCount() == 0);
        }
    }

    //
    // Filter to no qualifiers and no properties.
    //
    {
        if (verbose)
        {
            cout << "Test6a" << endl;
        }

        Array<CIMName> pl1Array;
        CIMPropertyList pl1(pl1Array);

        CIMInstance filterInstance = tstInstance.clone();
        filterInstance.filter(false, true, pl1);

        assert(filterInstance.getPropertyCount() == 0);
        assert(filterInstance.findProperty("ratio") == PEG_NOT_FOUND);
        assert(filterInstance.getQualifierCount() == 0);
    }

    //
    // Test Class Origin Filter
    //
    {
        if (verbose)
        {
            cout << "Test7 Class Origin" << endl;
        }

        // Create a subclass to do classOrigin testing
        CIMClass mySubClass(CIMName("subclass"));
        mySubClass.setSuperClassName(CIMName("MyClass"));

        Resolver::resolveClass(mySubClass, context, NAMESPACE);
        context->addClass(NAMESPACE, mySubClass);

        // build instance
        CIMInstance filterInstance =
            mySubClass.buildInstance(true, true, CIMPropertyList());
        filterInstance.filter(false, true, CIMPropertyList());

        assert(filterInstance.getPropertyCount() == 3);
        assert(filterInstance.findProperty("ratio") != PEG_NOT_FOUND);
        assert(filterInstance.getQualifierCount() == 0);
        for (Uint32 i = 0 ; i < filterInstance.getPropertyCount() ; i++)
        {
            CIMProperty p = filterInstance.getProperty(i);
            assert(!(p.getClassOrigin() == CIMName()));

        }
        filterInstance.filter(false, false, CIMPropertyList());

        for (Uint32 i = 0 ; i < filterInstance.getPropertyCount() ; i++)
        {
            CIMProperty p = filterInstance.getProperty(i);
            assert(p.getClassOrigin() == CIMName());
        }

        CIMInstance filterInstance2 =
            mySubClass.buildInstance(true, false, CIMPropertyList());

        for (Uint32 i = 0 ; i < filterInstance2.getPropertyCount() ; i++)
        {
            CIMProperty p = filterInstance2.getProperty(i);
            assert(p.getClassOrigin() == CIMName());
        }
    }
    delete context;
}
void LifecycleIndicationProvider::createInstance(
    const OperationContext & context,
    const CIMObjectPath & instanceReference,
    const CIMInstance & instanceObject,
    ObjectPathResponseHandler & handler)
{
//  cout << "LifecycleIndicationProvider::createInstance()" << endl;
    // Validate the class name
    if(!instanceObject.getClassName().equal(
           "Sample_LifecycleIndicationProviderClass"))
    {
        throw CIMNotSupportedException(
            instanceObject.getClassName().getString());
    }

    // Find the key property
    Uint32 idIndex = instanceObject.findProperty("uniqueId");

    if(idIndex == PEG_NOT_FOUND)
    {
        throw CIMInvalidParameterException("Missing key value");
    }

    CIMInstance cimInstance = instanceObject.clone();

    // Create the new instance name
    CIMValue idValue = instanceObject.getProperty(idIndex).getValue();
    Array<CIMKeyBinding> keys;
    keys.append(CIMKeyBinding("uniqueId", idValue));

    CIMObjectPath instanceName =
        CIMObjectPath(
            String(),
            CIMNamespaceName(),
            instanceObject.getClassName(),
            keys);

    cimInstance.setPath(instanceName);

    // Determine whether this instance already exists
    for(Uint32 i = 0, n = _instances.size(); i < n; i++)
    {
        if(instanceName == _instances[i].getPath())
        {
            throw CIMObjectAlreadyExistsException(instanceName.toString());
        }
    }

    // begin processing the request
    handler.processing();

    // add the new instance to the array
    _instances.append(cimInstance);

    // deliver the new instance name
    handler.deliver(instanceName);

    // complete processing the request
    handler.complete();

    // If there is at least one subscription active for the lifecycle indication
    // InstCreation_for_Sample_LifecycleIndicationProviderClass, then generate
    // that indication here, embedding the newly-created instance as
    // the SourceInstance property. See LifecycleIndicationProviderR.mof.
    if (_lifecycle_indications_enabled)
    {
        CIMInstance indicationInstance(
            CIMName(
                "InstCreation_for_Sample_LifecycleIndicationProviderClass"));
        CIMObjectPath path;
        path.setNameSpace("root/SampleProvider");
        path.setClassName(
            "InstCreation_for_Sample_LifecycleIndicationProviderClass");
        indicationInstance.setPath(path);

        char buffer[32];
        sprintf(buffer, "%d", _nextUID++);
        indicationInstance.addProperty
            (CIMProperty ("IndicationIdentifier",String(buffer)));

        CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
        indicationInstance.addProperty
            (CIMProperty ("IndicationTime", currentDateTime));

        indicationInstance.addProperty
            (CIMProperty ("SourceInstance",CIMObject(cimInstance)));

        _indication_handler->deliver (indicationInstance);

//      cout << "LifecycleIndicationProvider::createInstance() sent "
//                  "InstCreation_for_Sample_LifecycleIndicationProviderClass"
//           << endl;
    }
}
String IndicationFormatter::_getIndPropertyValue(
    const String & specifiedPropertyName,
    const String & arrayIndexStr,
    const CIMInstance & indication,
    const ContentLanguages & contentLangs)
{
    PEG_METHOD_ENTER (TRC_IND_FORMATTER,
        "IndicationFormatter::_getIndPropertyValue");

    CIMInstance indicationInstance = indication.clone();
    String propertyName;

    Boolean canLocalize = false;

#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
    Locale locale;
    canLocalize = _canLocalize(contentLangs, locale);
#endif

    for (Uint32 i=0; i < indicationInstance.getPropertyCount(); i++)
    {
        CIMProperty property = indicationInstance.getProperty(i);
        propertyName = property.getName().getString();

        // get specified property value
        if (String::equalNoCase(propertyName, specifiedPropertyName))
        {
            CIMValue propertyValue = property.getValue();
            Boolean valueIsNull = propertyValue.isNull();
	    CIMType type = propertyValue.getType();

            if (!valueIsNull)
            {
                Boolean isArray = propertyValue.isArray();

                if (isArray)
                {
                    PEG_METHOD_EXIT();
		    return (_getArrayValues(propertyValue, arrayIndexStr,
			                    contentLangs));
                }
                else // value is not an array
                {
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
		    if (canLocalize)
		    {
                        if (type == CIMTYPE_DATETIME)
		        {
			    CIMDateTime dateTimeValue;
			    propertyValue.get(dateTimeValue);
                            PEG_METHOD_EXIT();
			    return(_localizeDateTime(dateTimeValue, locale));
		        }
                        else if (type == CIMTYPE_BOOLEAN)
		        {
			    Boolean booleanValue;
			    propertyValue.get(booleanValue);
                            PEG_METHOD_EXIT();
			    return(_localizeBooleanStr(booleanValue, locale));
		        }
                        else
                        {
                            PEG_METHOD_EXIT();
                            return (propertyValue.toString());
                        }
		    }
		    else
		    {
			if (type == CIMTYPE_BOOLEAN)
			{
                            PEG_METHOD_EXIT();
                            return (_getBooleanStr(propertyValue));
			}
			else
			{
                            PEG_METHOD_EXIT();
                            return (propertyValue.toString());
			}
		    }
#else
		    if (type == CIMTYPE_BOOLEAN)
		    {
                        PEG_METHOD_EXIT();
                        return (_getBooleanStr(propertyValue));
		    }
		    else
		    {
                        PEG_METHOD_EXIT();
                        return (propertyValue.toString());
		    }
#endif
                }

            }
            else // value is NULL
            {
                PEG_METHOD_EXIT();
                return ("NULL");
            }

        }
        propertyName.clear();
    }

    PEG_METHOD_EXIT();

    return ("UNKNOWN");
}
String IndicationFormatter::_formatDefaultIndicationText(
    const CIMInstance & indication,
    const ContentLanguages & contentLangs)
{
    PEG_METHOD_ENTER (TRC_IND_FORMATTER,
        "IndicationFormatter::_formatDefaultIndicationText");

    CIMInstance indicationInstance = indication.clone();
    String propertyName;
    String indicationStr;
    Uint32 propertyCount = indicationInstance.getPropertyCount();

    indicationStr.append("Indication (default format):");

    Boolean canLocalize = false;

#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
    Locale locale;
    canLocalize = _canLocalize(contentLangs, locale);
#endif

    for (Uint32 i=0; i < propertyCount; i++)
    {
        CIMProperty property = indicationInstance.getProperty(i);
        propertyName = property.getName().getString();
        CIMValue propertyValue = property.getValue();
        Boolean valueIsNull = propertyValue.isNull();
        Boolean isArray = propertyValue.isArray();

        indicationStr.append(propertyName);
        indicationStr.append(" = ");

	CIMType type = propertyValue.getType();

        if (!valueIsNull)
        {
            if (isArray)
            {
		indicationStr.append(_getArrayValues(propertyValue, "",
		    contentLangs));
            }
            else // value is not an array
            {
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
		if (canLocalize)
		{
		    if (type == CIMTYPE_DATETIME)
		    {
			CIMDateTime dateTimeValue;
			propertyValue.get(dateTimeValue);
		        indicationStr.append(_localizeDateTime(dateTimeValue,
		    	    locale));
		    }
		    else if (type == CIMTYPE_BOOLEAN)
		    {
			Boolean booleanValue;
			propertyValue.get(booleanValue);
		        indicationStr.append(_localizeBooleanStr(booleanValue,
		    	    locale));
		    }
		    else
		    {
			indicationStr.append(propertyValue.toString());
		    }
		}
		else
		{
		    if (type == CIMTYPE_BOOLEAN)
		    {
                        indicationStr.append(_getBooleanStr(propertyValue));
		    }
		    else
		    {
                        indicationStr.append(propertyValue.toString());
		    }
		}
#else
		if (type == CIMTYPE_BOOLEAN)
		{
                    indicationStr.append(_getBooleanStr(propertyValue));
		}
		else
		{
                    indicationStr.append(propertyValue.toString());
		}
#endif
            }
        }
	else
	{
	    indicationStr.append("NULL");
	}

        if (i < propertyCount -1)
        {
            indicationStr.append(", ");
        }

        propertyName.clear();
    }

    PEG_METHOD_EXIT();

    return (indicationStr);
}