(file) Return to WBEMValue.java CVS log (file) (dir) Up to [Pegasus] / pegasus-JavaCIMClient / cimclient / tests / ProviderClientTest

File: [Pegasus] / pegasus-JavaCIMClient / cimclient / tests / ProviderClientTest / WBEMValue.java (download)
Revision: 1.1, Thu Jul 17 17:32:55 2003 UTC (20 years, 11 months ago) by kumpf
Branch: MAIN
CVS Tags: test, pegasus25BeforeLicenseUpdate, local, TEST, SLPPERFINST-root, SLPPERFINST-branch, RELEASE_2_4_FC_CANDIDATE_1, RELEASE_2_4_1-BETA3, RELEASE_2_4_1-BETA2, RELEASE_2_4_1-BETA1, RELEASE_2_4_1, RELEASE_2_4_0-RC3, RELEASE_2_4_0-RC2, RELEASE_2_4_0, RELEASE_2_4-root, RELEASE_2_4-branch, RELEASE_2_3_2-testfreeze, RELEASE_2_3_2-root, RELEASE_2_3_2-releasesnapshot, RELEASE_2_3_2-branch-freeze, RELEASE_2_3_2-branch, RELEASE_2_3_1-root, RELEASE_2_3_1-branch, RELEASE_2_3_0-root, RELEASE_2_3_0-msg-freeze, RELEASE_2_3_0-branch, PRE_LICENSE_UPDATE_2003, POST_LICENSE_UPDATE_2003, PEP217_PRE_BRANCH, PEP217_POST_BRANCH, PEP217_BRANCH, PEP214ROOT, PEP214BRANCH, PEP214-root, PEP214-branch, PEP213_SIZE_OPTIMIZATIONS, PEP-214B-root, PEG25_IBM_5_16_05, MONITOR_CONSOLIDATION_2_5_BRANCH, IBM_241_April1405, HPUX_TEST, HEAD, CQL_2_5_BRANCH, CHUNKTESTDONE_PEP140, BUG2493_BINREP-root, BUG2493_BINREP-branch
Branch point for: pep_88
HP-BAPU: PEP-64 CIM Client and CIM Listener Java Interface

package tests.ProviderClientTest;

import java.io.*;
import org.snia.wbem.client.CIMClient;
import org.snia.wbem.cim.*;
import java.util.*;

public class WBEMValue
{

	Properties wbemProps = new Properties();
	DataInputStream in;


	public WBEMValue()
	{
	}


	public void setNamespace(String nameSpace)
	{
	}

	public String getPropertyValue(CIMClient cc, String nameSpace, String className, String propName)
	{
		CIMProperty valProp;
		CIMInstance currentInstance;
		CIMObjectPath currentInstancePath;
		CIMValue value = null;

		try
		{
			System.out.println("WBEMValue::getPropertyValue::"+className+"::"+propName);
			// 1) get the path
			CIMObjectPath pa1 = new CIMObjectPath(className, nameSpace);
			//
			// 2) enumerate the instances
			Enumeration instances =cc.enumInstances(new CIMObjectPath(className,
						nameSpace), CIMClient.DEEP);
			int instCount = 0;
			while (instances.hasMoreElements())
			{
				Object obj2=instances.nextElement();
				//
				// 3) get value of the property for this instance
				currentInstancePath=(CIMObjectPath)obj2;
				currentInstance=cc.getInstance(currentInstancePath,false);
				//System.out.println("WBEMValue::getPropertyValue::getting property: "+propName);
				valProp = currentInstance.getProperty(propName);
				try
				{
					value = valProp.getValue();

				// BAPU
				System.out.println("WBEMValue::getPropertyValue::value: "+value.toString());
					if (value != null && value.getValue() != null)
						return(value.toString());
					else
						return(null);
				}

				catch (NullPointerException nex)
				{
					return(null);
				}
			}
		}
		catch (CIMException e)
		{
			System.out.println("WBEMValue::getPropertyValue::Enum class exception: "+e);
			return(null);
		}
		catch (NullPointerException ne)
		{
			System.out.println("Null Pointer Encountered....proceed");
			return(null);
		}

		return(value.toString());

	}
	public Vector getPropertyValues(CIMClient cc, String nameSpace, String className, String propName)
	{
		CIMProperty valProp;
		CIMInstance currentInstance;
		CIMObjectPath currentInstancePath;
		CIMValue value = null;

		Vector properties = new Vector();

		try
		{
			System.out.println("WBEMValue::getPropertyValue::"+className+"::"+propName);
			// 1) get the path
			CIMObjectPath pa1 = new CIMObjectPath(className, nameSpace);
			//
			// 2) enumerate the instances
			Enumeration instances =cc.enumInstances(new CIMObjectPath(className,
						nameSpace), CIMClient.DEEP);
			int instCount = 0;
			while (instances.hasMoreElements())
			{
				Object obj2=instances.nextElement();
				//
				// 3) get value of the property for this instance
				currentInstancePath=(CIMObjectPath)obj2;
				currentInstance=cc.getInstance(currentInstancePath,false);
				//System.out.println("WBEMValue::getPropertyValue::getting property: "+propName);
				valProp = currentInstance.getProperty(propName);
				try
				{
					value = valProp.getValue();

					if (value != null && value.getValue() != null)
						properties.addElement(value.toString());
					else
						properties.addElement("null");
				}

				catch (NullPointerException nex)
				{
					return(properties);
				}
			}
		}
		catch (CIMException e)
		{
			System.out.println("WBEMValue::getPropertyValue::Enum class exception: "+e);
			return(properties);
		}
		catch (NullPointerException ne)
		{
			System.out.println("Null Pointer Encountered....proceed");
			return(properties);
		}

		return(properties);

	}

	public Vector getClassProperties(CIMClient cc, String nameSpace, String className)
	{
		Vector properties=null;

		try
		{
			// 1) get the path
			CIMObjectPath pa1 = new CIMObjectPath(className, nameSpace);
			//CIMObjectPath pa1 = new CIMObjectPath(className);
			//
			// 2) get the class
			CIMClass sysClass = cc.getClass(pa1, false);
			//System.out.println("System Class Properties: "+sysClass.numberOfProperties());
			//
			// 3) get all the properties
			properties = sysClass.getAllProperties();
			//
			// 4) enumerate the class instances
			Enumeration instances =cc.enumInstances(new CIMObjectPath(className,
						nameSpace), CIMClient.DEEP);

			while(instances.hasMoreElements())
			{
				int instCount = 0;
				Object obj2=instances.nextElement();
				//
				// 5) get value of the property for this instance
				CIMObjectPath currentInstancePath=(CIMObjectPath)obj2;
				//
				// 6) get the current instance to "unroll"
				CIMInstance currentInstance=cc.getInstance(currentInstancePath,false);

				for (int i = 0; i < properties.size(); i++)
				{
					CIMProperty cp = (CIMProperty)(properties.elementAt(i));
					String propName = cp.getName();
					//System.out.print("Property: "+propName+" ");


					CIMProperty valProp = currentInstance.getProperty(propName);
					try
					{
						CIMValue value = valProp.getValue();
						//if (value != null && value.getValue() != null)
						//	System.out.println("	Value: "+value.toString());
						//else
						//	System.out.println("	Value: NULL");
					}
					catch (NullPointerException nex)
					{
						System.out.println("	Value: NULL");
					}
				}
			}

		}
		catch (CIMException e)
		{
			System.out.println("WBEMValue::getClassProperties::Enum class exception: "+e);
		}
		catch (NullPointerException ne)
		{
			System.out.println("Null Pointer Encountered....proceed");
		}

		return(properties);

	}

	public void dumpProperties()
	{
		Enumeration enum = wbemProps.propertyNames();
		while(enum.hasMoreElements())
		{
			String object = (String)enum.nextElement();
			System.out.println("Object name: "+object);
			String property = (wbemProps.getProperty(object));
			System.out.println("Object: "+object+" Property: "+property);
		}
	}


}

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2