Exemple #1
0
/////////////////////////////////////////////////////////////////////////////
// WMIBaseProvider::execCIMQuery - retrieves a query result
//
// ///////////////////////////////////////////////////////////////////////////
Array<CIMObject> WMIBaseProvider::execCIMQuery(
	const String& nameSpace,
	const String& userName,
	const String& password,
    const String& queryLanguage,
    const String& query,
	const CIMPropertyList& propertyList,
	Boolean includeQualifiers,
	Boolean includeClassOrigin)
{
	Array<CIMObject> objects;

	CIMInstance cimInstance;
	CIMStatusCode errorCode = CIM_ERR_SUCCESS;
	String errorDescription;
	WMIQueryProvider provider;

	PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIBaseProvider::execCIMQuery()");

	try
	{
        // This fix uses the current boolean value stored in collector
        // to initialize it. 
        provider.initialize(_collector->isLocalConnection()); 

		objects = provider.execQuery(nameSpace,
					userName,
					password,
					queryLanguage,
					query,
					propertyList,
					includeQualifiers,
					includeClassOrigin);
		
		provider.terminate();
	}
	catch(CIMException& exception)
	{
		provider.terminate();
		errorCode = exception.getCode();
		errorDescription = exception.getMessage();
		throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription);
	}
	catch(Exception& exception)
	{
		provider.terminate();
		errorCode = CIM_ERR_FAILED;
		errorDescription = exception.getMessage();
		throw PEGASUS_CIM_EXCEPTION(errorCode, errorDescription);
	}
	catch(...)
	{
		provider.terminate();
		throw CIMException(CIM_ERR_FAILED);
	}

	PEG_METHOD_EXIT();

	return objects;
}
Exemple #2
0
Array<CIMObject> WMIClientRep::execQuery(
    const CIMNamespaceName& nameSpace,
    const String& queryLanguage,
    const String& query)
{
    Array<CIMObject> cimObjects;
	CIMException cimException;
	
	try
	{
		//Initializes the WMI Provider Interface
    	WMIQueryProvider provider;
		provider.initialize(TRUE);

		//Performs the WMI call
		cimObjects = provider.execQuery(
			nameSpace.getString(),
			String::EMPTY,
			String::EMPTY,
			queryLanguage,
			query);

		//terminate the provider
		provider.terminate();
	}
	catch(CIMException&)
	{
		throw;
	}
	catch(Exception& exception)
	{
	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());
	   throw cimException;
	}
	catch(...)
	{
		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "execQuery() failed!");
		throw cimException;
	}

	return(cimObjects);
}