You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-commits@incubator.apache.org by jn...@apache.org on 2008/02/14 20:52:47 UTC

svn commit: r627867 [2/3] - in /incubator/imperius/trunk: imperius-cimsplclientsideprovider/ imperius-cimsplclientsideprovider/resources/ imperius-cimsplclientsideprovider/resources/mofs/ imperius-cimsplclientsideprovider/resources/policies/ imperius-c...

Added: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMClientSideDataCollectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMClientSideDataCollectorImpl.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMClientSideDataCollectorImpl.java (added)
+++ incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMClientSideDataCollectorImpl.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,677 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+/**
+ * @author Neeraj Joshi <jn...@us.ibm.com>
+ *
+ */
+
+
+
+package org.apache.imperius.cimspl.client;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.sblim.wbem.cim.CIMClass;
+import org.sblim.wbem.cim.CIMException;
+import org.sblim.wbem.cim.CIMInstance;
+import org.sblim.wbem.cim.CIMMethod;
+import org.sblim.wbem.cim.CIMObjectPath;
+import org.sblim.wbem.cim.CIMParameter;
+import org.sblim.wbem.cim.CIMProperty;
+import org.sblim.wbem.client.CIMClient;
+
+import org.apache.imperius.spl.external.Argument;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.symboltable.MethodSymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.PropertySymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.ClassDoesNotExistException;
+import org.apache.imperius.spl.parser.exceptions.InstanceDoesNotExistException;
+import org.apache.imperius.spl.parser.exceptions.InvalidCIMParameterException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.ArgumentImpl;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class CIMClientSideDataCollectorImpl implements DataCollector 
+{
+	private static CIMClient _handle; 
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+	private static String sourceClass = "CIM_SPLPolicyRuleProvider"; 
+
+
+	public CIMClientSideDataCollectorImpl(CIMClient ch)
+	{
+		_handle=ch;
+	}
+	
+	private void _populateClassProperties(CIMClass cimClass, String classPath, Map symbols) throws SPLException
+	{
+		Vector properties=_getPropertiesOfClass(cimClass ,classPath );
+
+		for(int i=0;i<properties.size();i++)
+		{
+			CIMProperty cimproperty=(CIMProperty) properties.get(i);
+			String qualifiedPropertyName=  cimproperty.getName();
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" PropertyName "+cimproperty.getName().toLowerCase());
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" qualifiedPropertyName "+qualifiedPropertyName);
+//			//add the property to the HashMap as(class.propertyName, PropertySymbol)
+			if( ! symbols.containsKey(qualifiedPropertyName))
+			{
+
+				int type=CIMSPLTypeConstants.convertCIMTypeToInternalType(cimproperty.getType().getType());
+				String referenceTypeName=""; 
+				if(type == TypeConstants.referenceType)
+				{
+					String path=(String)cimproperty.getValue().getValue();
+					//the property is a CIMObjectPath
+					referenceTypeName=CIMSPLTypeConstants.getReferenceTypeName(path);
+				}
+				boolean isArray = CIMSPLTypeConstants.getIsArray(cimproperty.getType().getType());
+
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" symboltable does not currently contain the given property, so creating property symbol");
+				Symbol symbol = new PropertySymbol(qualifiedPropertyName,type,referenceTypeName,isArray,_isKey(cimproperty),true);
+				//add property to properties list 
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" adding property to Map in datacollector : "+qualifiedPropertyName);
+				symbols.put(qualifiedPropertyName, symbol);
+
+			}
+			else
+			{
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" symboltable already contains the given symbol "+cimproperty.getName().toLowerCase());
+				logger.severe(qualifiedPropertyName+" symbol Already exists in SymbolTable");
+				throw new SPLException("symbol Already exists in SymbolTable");
+			}
+
+		}
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" done adding all the properties");
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" get all methods of the class and iterate over them");
+
+		
+	}
+	
+	private void _populateClassMethods(CIMClass cimClass, Map symbols) throws SPLException
+	{
+		Vector methods = cimClass.getAllMethods();
+		//get all methods of the class and iterate over them
+		for(int i=0;i<methods.size();i++)
+		{
+			CIMMethod cimMethod= (CIMMethod)methods.get(i);
+
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" method : "+cimMethod.getName()+ 
+						" Parameter count "+cimMethod.getParameters()+" is of type "+cimMethod.getType());
+//			//ArrayList argTypeList=new ArrayList ();
+			List methodArgs=new ArrayList();
+			SPLSymbolTable methodArgsSymbolTable=new SPLSymbolTable();
+			
+            Vector parameters = cimMethod.getParameters();
+			for(int j=0; j<parameters.size(); j++)
+			{
+				CIMParameter cimparameter = (CIMParameter)parameters.get(j);
+				String parameterName=cimparameter.getName();
+				//boolean isArr=cimparameter.isArray();
+				int type=CIMSPLTypeConstants.convertCIMTypeToInternalType(cimparameter.getType().getType());
+				boolean isArray = CIMSPLTypeConstants.getIsArray(cimparameter.getType().getType());
+				String referenceTypeName=""; 
+				
+				if(type == TypeConstants.referenceType)
+				{	
+					referenceTypeName = CIMSPLTypeConstants.getReferenceTypeName(cimparameter.getName());
+				}
+				Argument arg=new ArgumentImpl(type, parameterName, isArray, referenceTypeName);
+				
+				methodArgsSymbolTable.insertVariableSymbol(parameterName, type, referenceTypeName, isArray, false, false);
+				//System.out.println(" inserted variable symbol into methodArgsSymbolTable "+parameterName);
+				methodArgs.add(arg);
+			}
+			String methodName=cimMethod.getName();
+			if( ! symbols.containsKey(methodName))
+			{
+				int localReturnType=CIMSPLTypeConstants.convertCIMTypeToInternalType(cimMethod.getType().getType());
+
+				Symbol methodSymbol = new MethodSymbol(methodName,localReturnType,
+						CIMSPLTypeConstants.getIsArray(localReturnType),cimClass.getName(),methodArgs,methodArgsSymbolTable);
+				//add property to properties list 
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" adding method to symbol table" + methodName);
+				symbols.put(methodName, methodSymbol);
+			}
+			else
+			{
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" SymbolTable already contains the given method "+methodName);
+				logger.severe(Thread.currentThread().getName()+" "+"SymbolTable already contains the given method "+methodName);
+				throw new CIMException("SymbolTable already contains the given method "+methodName);
+			}
+
+		}
+	}
+
+
+	private void _populateClassMembers(String className,String classPath, Map symbolMap) throws SPLException
+	{
+		if(className!=null && classPath!=null)
+		{
+			CIMObjectPath cop=new CIMObjectPath(className,classPath);
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" cop   "+cop);
+			Map symbols=symbolMap;
+			//get class
+			try
+			{
+				//System.out.println("_handle.getClass");
+
+				CIMClass cimClass=_handle.getClass(cop, true, true, true, null);
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" got class "+cimClass.getName());
+				if(cimClass!=null)
+				{
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" get all the properties of the class and iterate over them");
+					//System.out.println("get all the properties of the class and iterate over them");
+					//get all the properties of the class and iterate over them
+
+					
+					_populateClassProperties(cimClass, classPath, symbols);
+					
+					_populateClassMethods(cimClass,symbols);
+					
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" done adding methods to the symboltable");
+
+					logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSymbolsForClass");
+					//return symbols;
+				}
+				else 
+				{
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" handle : the cimclass is null");
+					logger.severe(Thread.currentThread().getName()+" "+"This CIM class does not exist");
+					throw new ClassDoesNotExistException("This CIM class does not exist");
+				}
+
+			}
+			catch (CIMException e){
+				logger.severe(Thread.currentThread().getName()+" "+"Failed to get class "+e.getMessage());
+				throw new SPLException("Failed to get class");
+			}
+
+		}
+		else 
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"This CIM class is not handled by the Policy Provider");
+			throw new InvalidCIMParameterException("This CIM class is not handled by the Policy Provider");
+		}   				
+
+
+
+
+
+	}
+
+	public Map getSymbolsForClass(String className, String qualifier)
+	throws SPLException
+	{
+		String formattedClass = null;
+		if(className.startsWith("\"")) // string of form ""lkasdlk""
+		{	
+			formattedClass = className.substring(1, className.length() -1 );
+		}
+		else
+		{
+			formattedClass = className;
+		}
+		//System.out.println("formatted class" + formattedClass);
+		Map symbolMap = new Hashtable();
+		_populateClassMembers(formattedClass,qualifier,symbolMap);
+
+		return symbolMap;
+
+	}
+
+	public Map getSymbolsForInstance(String className, String namespc, Object cop)
+	throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getInstanceMap");
+		if(cop instanceof CIMObjectPath)
+		{
+		//	CIMObjectPath cimObjectPath= new CIMObjectPath(className,namespc);
+		//	CIMObjectPath cop1=(CIMObjectPath)cop;
+		//	cimObjectPath.setKeys(cop1.getKeys());
+			try{
+				CIMInstance ci=_handle.getInstance((CIMObjectPath)cop, true, true, true, null);
+				Map instanceProperties=new HashMap();
+				//get all properties of the current instance
+				Vector properties=ci.getAllProperties();
+				for(int i=0;i<properties.size();i++)
+				{
+					//add property to HashMap as (class.name,value) pair
+					CIMProperty cimproperty=(CIMProperty) properties.get(i);
+					String qualifiedPropertyName=  cimproperty.getName();
+					instanceProperties.put(qualifiedPropertyName, cimproperty.getValue().getValue());
+				}
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getInstanceMap");
+
+				return instanceProperties;
+			}
+			catch(CIMException e)
+			{
+				logger.severe(e.getMessage());
+				throw new SPLException(e.getMessage());
+			}
+
+		}
+		else
+		{
+			throw new SPLException("Reference is not of Type CIMObjectPath");
+		}
+
+
+	}
+
+
+
+
+
+
+
+	public List getAssociatedInstanceNames(
+			Object srcInstanceName,
+			String nameSpace, 
+			String resultClass, 
+			String assocClass, 
+			String role, 
+			String resultRole) throws SPLException 
+			{
+		return null;
+			}
+//	public List getAssociatedInstances(Object refExpressionResult, String nameSpace, String targetClassName, String associationName, String sourceRole, String targetRole) {
+//		// TODO Auto-generated method stub
+//		return null;
+//	}
+
+	private static Vector _getPropertiesOfClass(CIMClass cimClass ,String classPath ) throws CIMException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPropertiesOfClass");
+		CIMClass cimclass=cimClass;
+		Vector propertyNames=new Vector();
+		
+		Vector properties=cimclass.getAllProperties();
+		Iterator it=properties.iterator();
+		String superClass=cimclass.getSuperClass();
+
+		while(it.hasNext())
+		{
+			CIMProperty cimProp=(CIMProperty)it.next();
+			//System.out.println("cimProp "+cimProp.toString());
+			String propName=cimProp.getName();
+			//System.out.println("propName "+propName);
+
+			propertyNames.add(propName);
+
+		}
+		superClass=cimclass.getSuperClass();
+
+		while((superClass!= null)&&(superClass!= "")&&(superClass.length()!=0))
+		{
+			CIMObjectPath cop=new CIMObjectPath(superClass,classPath);
+			cimclass=_handle.getClass(cop, true, true, true, null);
+
+			Vector propertiesSuper=cimclass.getAllProperties();
+			Iterator proppertiesSuperIt=propertiesSuper.iterator();
+			while(proppertiesSuperIt.hasNext())
+			{
+				CIMProperty cimProp=(CIMProperty)proppertiesSuperIt.next();
+				if (!propertyNames.contains(cimProp.getName()))
+				{
+					properties.add(cimProp);
+					String propName=cimProp.getName();
+					propertyNames.add(propName);
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(cimProp.getName()+"new superclass property found "+cimProp.getName());
+
+
+				}
+				else
+				{
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(cimProp.getName()+"already exists ,Super class variable ignored");
+
+				}
+
+			}
+			superClass=cimclass.getSuperClass();
+		}
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPropertiesOfClass");
+
+		return properties;
+	}
+
+
+	private boolean _isKey(CIMProperty cimProperty)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "_isKey");
+ 
+		boolean res = cimProperty.isKey();
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "_isKey" + res);
+		return res;
+
+	}
+
+	
+	public List enumerateInstanceNames(String className, String namespace)
+	throws SPLException
+	{
+		String formattedClass = null;
+		if(className.startsWith("\"")) // string of form ""lkasdlk""
+		{	
+			formattedClass = className.substring(1, className.length() -1 );
+		}
+		else
+		{
+			formattedClass = className;
+		}
+		//System.out.println("formatted class" + formattedClass);
+		CIMObjectPath classCop=new CIMObjectPath(formattedClass,namespace);
+		List instanceList=new ArrayList();
+		try{
+			Enumeration instanceEnumeration=_handle.enumerateInstanceNames(classCop);
+			while(instanceEnumeration.hasMoreElements())
+			{
+				instanceList.add(instanceEnumeration.nextElement());
+			}
+			return instanceList;
+		}
+		catch (CIMException e){
+			throw new SPLException(e.getMessage());
+		}
+		
+	}
+
+
+	public boolean associationExists(String className ,String classPath, String resultClass, 
+			   String assocClass, String role, String resultRole) throws SPLException 
+	{
+	        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "associationExists");
+	        CIMObjectPath cop=new CIMObjectPath(assocClass,classPath);
+	        if(logger.isLoggable(Level.FINE))
+	            logger.fine(Thread.currentThread().getName()+" associationExists::cop ::"+cop);
+	        try
+	        {
+	        	
+	            CIMClass associationClass=_handle.getClass(cop, true, true, true, null);
+	                        
+	            if(logger.isLoggable(Level.FINE))
+	                logger.fine(Thread.currentThread().getName()+" got class "+associationClass.getName());
+	            if(logger.isLoggable(Level.FINE))
+	                logger.fine(Thread.currentThread().getName()+" check to see if the class is an association");
+	            //check to see if the class is an association
+	            
+	            boolean isAssoc=associationClass.isAssociation();
+	            if(logger.isLoggable(Level.FINE))
+	                logger.fine(Thread.currentThread().getName()+" CIMClass, isAssociation()= "+
+	                		isAssoc+" "+associationClass.getAllProperties().toString());
+	            if(isAssoc)
+	            {
+	            	            
+	                if(logger.isLoggable(Level.FINE))
+	                    logger.fine(Thread.currentThread().getName()+" class is an association");
+	                CIMProperty srcProperty=associationClass.getProperty(role);
+	            		            
+	                if(logger.isLoggable(Level.FINE))
+	                    logger.fine(Thread.currentThread().getName()+" check to see if the role played by src class is correct");
+	                if(logger.isLoggable(Level.FINE))
+	                    logger.fine(Thread.currentThread().getName()+" src RefClassName(),className::"+
+	                    		srcProperty.getOriginClass()+" "+className);
+	                //check to see if the role played by src class is correct
+	                
+	                if(_classNameMatchesString(srcProperty.getType().getRefClassName().trim(), classPath, className))
+	                {
+	                
+	                    CIMProperty resultProperty=associationClass.getProperty(resultRole);
+	                	                    
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(Thread.currentThread().getName()+" check to see if role played by result class is corrrect");
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(Thread.currentThread().getName()+" result RefClassName(),className::"+
+	                        		resultProperty.getType().getRefClassName()+" "+resultClass);
+	                    
+	                    //check to see if role played by result class is corrrect
+	                    if(_classNameMatchesString(resultProperty.getType().getRefClassName().trim(), classPath, resultClass))
+	                    {
+	                    		                    
+	                        if(logger.isLoggable(Level.FINE))
+	                            logger.fine(Thread.currentThread().getName()+" associationExists returning true");
+	                        
+	                        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "associationExists");
+	                        return true;
+	                    }
+	                    else
+	                    {
+	                    	                    
+	                        if(logger.isLoggable(Level.FINE))
+	                            logger.fine(Thread.currentThread().getName()+" associationExists returning false " + 
+	                            		"because of resultClass "+resultClass+ " "+resultProperty.getType().getRefClassName());
+	                        
+	                        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "associationExists");
+	                        return false; 
+	                    }
+	                } 
+	                else
+	                {
+	                		                    
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(Thread.currentThread().getName()+" associationExists returning false because of className "+
+	                        		className+ " != "+srcProperty.getType().getRefClassName());
+	                    
+	                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "associationExists");
+	                    return false; 
+	                }
+	            }
+	            else
+	            {
+	            	                    
+	                if(logger.isLoggable(Level.FINE))
+	                    logger.fine(Thread.currentThread().getName()+" associationExists returning false because CIMClass.isAssociation()= "+isAssoc);
+	                
+	                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "associationExists");
+	                return false; 
+	            }
+	        }
+	        catch (CIMException e){
+	            logger.severe(Thread.currentThread().getName()+" "+"Failed to get class");
+	            throw new SPLException("Failed to get class");
+	        }
+	        
+	        
+	    }
+	
+	
+	   private static boolean _classNameMatchesString(String str,String namespace,String className ) throws CIMException
+	   {
+		   
+	        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "classNameMatchesString");
+	        //CIMClass cimclass=cimClass;
+	        //Vector propertyNames=new Vector();
+	        System.out.println("associationExists ->classnm.equalsIgnoreCase(str) "+className+" "+namespace+" "+str);
+            
+	        CIMObjectPath copOriginal=new CIMObjectPath(className,namespace);
+	        CIMClass cimclass=_handle.getClass(copOriginal, true, true, true, null);
+	        String classnm=cimclass.getName();
+	        String superClass=cimclass.getSuperClass();
+	        if(classnm.equalsIgnoreCase(str))
+	        {
+	        		            
+	            if(logger.isLoggable(Level.FINE))
+	                logger.fine(Thread.currentThread().getName()+" classNameMatchesString "+classnm+ " "+str);        
+	            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "classNameMatchesString");
+	            return true;
+	        }
+	        else if(superClass!= null)
+	        {
+	            while((superClass!= "")&&(superClass.length()!=0))
+	            {
+	                ////System.out.println("superclass "+superClass);
+	                if(superClass.equalsIgnoreCase(str))
+	                {
+	               	    	            
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(Thread.currentThread().getName()+" classNameMatchesString "+superClass+ " "+str);        
+	                    
+	                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "classNameMatchesString");
+	                    return true;
+	                }
+	                else
+	                {
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(superClass+" did not Match "+str+" ,trying superclass");        
+	                    
+	                    CIMObjectPath cop=new CIMObjectPath(superClass,namespace);
+	                    cimclass=_handle.getClass(cop, true, true, true, null);                    
+	                    superClass=cimclass.getSuperClass();
+	                    if(logger.isLoggable(Level.FINE))
+	                        logger.fine(Thread.currentThread().getName()+" new superclass= "+superClass);        
+	                    
+	                }
+	                
+	            }
+	            
+	            
+	        }
+	        if(logger.isLoggable(Level.FINE))
+	            logger.fine(Thread.currentThread().getName()+" string did not match classname or superclass names "+str);   
+	        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "classNameMatchesString");
+	                    
+	        return false;
+	        
+	    }     
+
+	    public List getAssociatedInstanceReferences(Object srcReference, String classPath, 
+	    		String resultInstancesClassFilter, String assocClass, 
+	    		String role, String resultRole) throws SPLException 
+	    {
+	        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAssociatedInstanceReferences");
+	        
+	        CIMObjectPath srcRef=(CIMObjectPath)srcReference;
+	        String className=srcRef.getObjectName();
+            
+	        if(logger.isLoggable(Level.FINE))
+	        {	
+	            logger.fine(className+" "+classPath+" "+resultInstancesClassFilter+" "
+	            		+ assocClass+" "+role+" "+ resultRole+" "+ srcReference.toString());
+	        }    
+	        
+	        
+	        if(className!=null && classPath!=null)
+	        {
+	        	try
+	        	{
+	        		
+	        		List instanceREFList = new ArrayList();
+	            //check to see if the association exists
+	        		if(logger.isLoggable(Level.FINE))
+	        			logger.fine(Thread.currentThread().getName()+" check to see if the association exists");
+	        		if(associationExists(className ,classPath,resultInstancesClassFilter,assocClass,role,resultRole))
+	        		{
+	                
+	                //create cop of anchor object
+	        			CIMObjectPath cop=new CIMObjectPath(className,classPath);
+	        			cop.setKeys(srcRef.getKeys());
+	                //add keys of the source instance to the cop
+	                
+	        			if(logger.isLoggable(Level.FINE))
+	        				logger.fine(Thread.currentThread().getName()+" Anchor Object cop "+cop);
+	        			
+	        			Enumeration targetInstances = _handle.associatorNames(srcRef, assocClass, resultInstancesClassFilter, role, resultRole);
+	                
+	        			while(targetInstances.hasMoreElements())
+	        			{
+	        				instanceREFList.add(targetInstances.nextElement());
+	        			}
+	                
+	        		
+	        			return instanceREFList;
+	        		}
+	                else 
+	                {
+	                	logger.severe(Thread.currentThread().getName()+" "+"The instance does not exist");
+	                		throw new InstanceDoesNotExistException("The instance does not exist");
+	                }
+	        	}
+	        	catch(CIMException e)
+	        	{
+	        		e.printStackTrace();
+	        		logger.severe(Thread.currentThread().getName()+" "+e.getMessage());
+	                throw new SPLException(e.getMessage());
+	            
+	        	}
+	            
+	        }
+	        else 
+	        {
+	            logger.severe(Thread.currentThread().getName()+" "+"This CIM class is not handled by the Policy Provider");
+	            throw new InvalidCIMParameterException("This CIM class is not handled by the Policy Provider");
+	        }       
+	    }
+	
+
+	   
+	    
+	    public String getReferenceTypeName(String reference) 
+		{
+
+			//extract class name and return
+			String referenceType = CIMSPLTypeConstants.getReferenceTypeName(reference);
+			
+			return referenceType;
+		}
+
+        public boolean isInstance(String className, Object instance)
+                throws SPLException
+        {
+            CIMObjectPath cop = (CIMObjectPath)instance;
+            String instClassName = cop.getObjectName();
+            if(className.equals(instClassName))
+                return true;
+            return false;
+        }
+
+}

Propchange: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMClientSideDataCollectorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMSPLTypeConstants.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMSPLTypeConstants.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMSPLTypeConstants.java (added)
+++ incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMSPLTypeConstants.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,435 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.cimspl.client;
+
+
+import java.util.logging.Logger;
+
+import org.sblim.wbem.cim.CIMObjectPath;
+
+
+import org.sblim.wbem.cim.CIMDataType;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.util.SPLLogger;
+//import com.ibm.pegasus.cimspl.parser.exceptions.TypeMismatchException;
+
+public class CIMSPLTypeConstants
+{
+
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+	private static final String sourceClass="CIMSPLTypeConstants";
+
+	public static final int SIZE_SINGLE = 0;
+
+	public static final int SIZE_UNLIMITED = 1;
+
+	public static final int SIZE_LIMITED = 2;
+
+	private final static int ARRAY = 0x10;
+
+	private final static int OTHER = 0x20;
+
+	public static final int INVALID = 0;
+
+	public static final int UINT8 = 1;
+
+	public static final int SINT8 = 2;
+
+	public static final int UINT16 = 3;
+
+	public static final int SINT16 = 4;
+
+	public static final int UINT32 = 5;
+
+	public static final int SINT32 = 6;
+
+	public static final int UINT64 = 7;
+
+	public static final int SINT64 = 8;
+
+	public static final int STRING = 9;
+
+	public static final int BOOLEAN = 10;
+
+	public static final int REAL32 = 11;
+
+	public static final int REAL64 = 12;
+
+	public static final int DATETIME = 13;
+
+	public static final int CHAR16 = 14;
+
+	public static final int OBJECT = 15;
+
+	public static final int UINT8_ARRAY = ARRAY + UINT8;
+
+	public static final int SINT8_ARRAY = ARRAY + SINT8;
+
+	public static final int UINT16_ARRAY = ARRAY + UINT16;
+
+	public static final int SINT16_ARRAY = ARRAY + SINT16;
+
+	public static final int UINT32_ARRAY = ARRAY + UINT32;
+
+	public static final int SINT32_ARRAY = ARRAY + SINT32;
+
+	public static final int UINT64_ARRAY = ARRAY + UINT64;
+
+	public static final int SINT64_ARRAY = ARRAY + SINT64;
+
+	public static final int STRING_ARRAY = ARRAY + STRING;
+
+	public static final int BOOLEAN_ARRAY = ARRAY + BOOLEAN;
+
+	public static final int REAL32_ARRAY = ARRAY + REAL32;
+
+	public static final int REAL64_ARRAY = ARRAY + REAL64;
+
+	public static final int DATETIME_ARRAY = ARRAY + DATETIME;
+
+	public static final int CHAR16_ARRAY = ARRAY + CHAR16;
+
+	public static final int OBJECT_ARRAY = ARRAY + OBJECT;
+
+	public static final int REFERENCE = OTHER + 1;
+
+	
+	public static boolean getIsArray(int type)
+	{
+		boolean isArray = false;
+		switch(type)
+		{
+			case CIMDataType.CHAR16_ARRAY :
+				
+			case CIMDataType.UINT8_ARRAY:
+				
+			case CIMDataType.UINT16_ARRAY:
+				
+			case CIMDataType.UINT32_ARRAY:
+				
+			case CIMDataType.UINT64_ARRAY:
+			case CIMDataType.SINT8_ARRAY:
+			case CIMDataType.SINT16_ARRAY:
+			case CIMDataType.SINT32_ARRAY:
+			case CIMDataType.SINT64_ARRAY:
+			case CIMDataType.BOOLEAN_ARRAY:
+			case CIMDataType.REFERENCE_ARRAY:
+			case CIMDataType.REAL32_ARRAY:
+			case CIMDataType.REAL64_ARRAY:
+			case CIMDataType.STRING_ARRAY:
+				isArray = true;
+				break;
+			default:
+				isArray = false;
+		
+		}
+		
+		return isArray;	
+		
+
+	}
+	public static int convertInternalTypeToCIMType(int type, boolean isArray, Object obj)
+	{
+		int cimType = -1;
+		if(type == TypeConstants.byteType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.UINT8_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.UINT8;
+			}
+		}
+		else if(type == TypeConstants.shortType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.UINT16_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.UINT16;
+			}
+		}
+		else if(type == TypeConstants.intType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.UINT32_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.UINT32;
+			}
+		}
+		else if(type == TypeConstants.longType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.UINT64_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.UINT64;
+			}
+		}
+		else if(type == TypeConstants.floatType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.REAL32_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.REAL32_ARRAY;
+			}
+		}
+		else if(type == TypeConstants.doubleType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.REAL64_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.REAL64;
+			}
+		}
+		else if(type == TypeConstants.booleanType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.BOOLEAN_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.BOOLEAN;
+			}
+		}
+		else if(type == TypeConstants.charType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.CHAR16_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.CHAR16;
+			}
+		}
+		else if(type == TypeConstants.stringType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.STRING_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.STRING;
+			}
+		}
+		else if(type == TypeConstants.dateTime)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.DATETIME_ARRAY;
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.DATETIME;
+			}
+		}
+		else if(type == TypeConstants.referenceType)
+		{
+			if(isArray)
+			{
+				cimType = CIMSPLTypeConstants.REFERENCE;
+				//System.out.println("encountered reference array, no equivalent CIM type");
+			}
+			else
+			{
+				cimType = CIMSPLTypeConstants.REFERENCE;
+			}
+		}
+		
+
+		return cimType;
+
+	}
+
+	public static int convertCIMTypeToInternalType(int type)
+	{
+
+
+		int retTp = -1;
+
+		if ((type == CIMDataType.UINT8)
+				|| (type == CIMDataType.SINT8)
+				|| (type == CIMDataType.UINT8_ARRAY)
+				|| (type == CIMDataType.SINT8_ARRAY))
+		{
+			retTp = TypeConstants.byteType;
+		}
+		else if ((type == CIMDataType.UINT16)
+				|| (type == CIMDataType.SINT16)
+				|| (type == CIMDataType.UINT16_ARRAY)
+				|| (type == CIMDataType.SINT16_ARRAY))
+		{
+			retTp = TypeConstants.shortType;
+		}
+		else if ((type == CIMDataType.UINT32)
+				|| (type == CIMDataType.SINT32)
+				|| (type == CIMDataType.UINT32_ARRAY)
+				|| (type == CIMDataType.SINT32_ARRAY))
+		{
+			retTp = TypeConstants.intType;
+		}
+		else if ((type == CIMDataType.UINT64)
+				|| (type == CIMDataType.SINT64)
+				|| (type == CIMDataType.UINT64_ARRAY)
+				|| (type == CIMDataType.SINT64_ARRAY))
+		{
+			retTp = TypeConstants.longType;
+		}
+		else if ((type == CIMDataType.REAL32)
+				|| (type == CIMDataType.REAL32_ARRAY))
+		{
+			retTp = TypeConstants.floatType;
+		}
+		else if ((type == CIMDataType.REAL64)
+				|| (type == CIMDataType.REAL64_ARRAY))
+		{
+			retTp = TypeConstants.doubleType;
+		}
+		else if ((type == CIMDataType.BOOLEAN)
+				|| (type == CIMDataType.BOOLEAN_ARRAY))
+		{
+			retTp = TypeConstants.booleanType;
+		}
+		else if ((type == CIMDataType.CHAR16)
+				|| (type == CIMDataType.CHAR16_ARRAY))
+		{
+			retTp = TypeConstants.charType;
+		}
+		else if ((type == CIMDataType.STRING)
+				|| (type == CIMDataType.STRING_ARRAY))
+		{
+			retTp = TypeConstants.stringType;
+		}
+		else if ((type == CIMDataType.DATETIME)
+				|| (type == CIMDataType.DATETIME_ARRAY))
+		{
+			retTp = TypeConstants.dateTime;
+		}
+		else if (type == CIMDataType.REFERENCE || type == CIMDataType.REFERENCE_ARRAY)
+		{
+			retTp = TypeConstants.referenceType;
+		}
+
+
+		//logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "cimToLocalTypeConversion");
+
+		return retTp;
+
+	}
+
+
+
+	public static int getTypeOfObject(Object ob) 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getTypeOfObject");
+
+		int currentLocaltype = -1;
+		if (ob instanceof java.lang.Boolean)
+		{	
+			currentLocaltype = TypeConstants.booleanType;
+		}    
+		else if (ob instanceof java.lang.String)
+		{	
+			currentLocaltype = TypeConstants.stringType;
+		}    
+		else if (ob instanceof java.util.Calendar)
+		{	
+			currentLocaltype = TypeConstants.dateTime;
+		}    
+		else if (ob instanceof java.lang.Byte)
+		{	
+			currentLocaltype = TypeConstants.byteType;
+		}    
+		else if (ob instanceof java.lang.Character)
+		{	
+			currentLocaltype = TypeConstants.charType;
+		}    
+		else if (ob instanceof java.lang.Short)
+		{	
+			currentLocaltype = TypeConstants.shortType;
+		}    
+		else if (ob instanceof java.lang.Integer)
+		{	
+			currentLocaltype = TypeConstants.intType;
+		}    
+		else if (ob instanceof java.lang.Long)
+		{	
+			currentLocaltype = TypeConstants.longType;
+		}    
+		else if (ob instanceof java.lang.Float)
+		{	
+			currentLocaltype = TypeConstants.floatType;
+		}    
+		else if (ob instanceof java.lang.Double)
+		{	
+			currentLocaltype = TypeConstants.doubleType;
+		}    
+		else if (ob instanceof java.util.Date)
+		{	
+			currentLocaltype = TypeConstants.dateTime;
+		}    
+		else 
+		{	
+			currentLocaltype = TypeConstants.referenceType;
+		}    
+		// if (ob instanceof com.ibm.ac.spl.parser.expressions.Reference)
+			//     currentLocaltype = 13;
+
+		// public static final int referenceType = 13;
+		// PB:what do we do about references
+
+
+		return currentLocaltype;
+	}
+	public static String getReferenceTypeName(String reference) 
+	{
+
+		//extract class name and return
+		String referenceType = null;
+		CIMObjectPath cop = new CIMObjectPath(reference);
+		//CIMObjectPath cop=CIMObjectPath.toCop(reference);
+		referenceType=cop.getObjectName();			
+
+		return referenceType;
+	}
+
+}

Propchange: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIMSPLTypeConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIM_SPLPolicyRuleClientProvider.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIM_SPLPolicyRuleClientProvider.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIM_SPLPolicyRuleClientProvider.java (added)
+++ incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIM_SPLPolicyRuleClientProvider.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,315 @@
+//(c) Copyright IBM Corp. 2007
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.cimspl.client;
+
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.sblim.wbem.cim.CIMException;
+import org.sblim.wbem.cim.CIMNameSpace;
+import org.sblim.wbem.cim.CIMObjectPath;
+import org.sblim.wbem.client.CIMClient;
+import org.sblim.wbem.client.PasswordCredential;
+import org.sblim.wbem.client.UserPrincipal;
+
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.external.InternalClient;
+import org.apache.imperius.spl.manager.PolicyManager;
+import org.apache.imperius.spl.manager.impl.PolicyManagerImpl;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.PolicyInfo;
+import org.apache.imperius.spl.parser.util.InternalClientFactory;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class CIM_SPLPolicyRuleClientProvider 
+{
+		
+	private PolicyManager _policyManager= null;
+	private CIMClient _client=null;
+	public InternalClient _internalClient=null;
+
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+	private static String sourceClass = "CIM_SPLPolicyRuleClientProvider"; 
+
+	
+	
+	
+	public static void main(String[] args) throws SPLException
+	{
+		
+		
+		
+	}
+	
+	public CIM_SPLPolicyRuleClientProvider(String url, String namespace, String username, String password) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"CIM_SPLPolicyRuleClientProvider"); 
+		
+		initialize(url, namespace, username, password);
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"CIM_SPLPolicyRuleClientProvider"); 
+		
+	}
+	
+	public void cleanup() throws SPLException {
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"cleanup"); 
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"cleanup"); 
+		
+        
+		
+	}
+
+	public void initialize(String url, String namespace, String username, String password) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"initialize"); 
+		
+		CIMClient a=getCIMClient(url, namespace, username, password);
+		DataCollector dc = new CIMClientSideDataCollectorImpl(a);
+		Actuator ac = new CIMClientSideActuatorImpl(a);
+		
+		
+		_policyManager= new PolicyManagerImpl(dc,ac);
+		_client=a;
+		_internalClient=new InternalClient(_policyManager);
+		InternalClientFactory.registerInternalClient(_internalClient);
+		
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"initialize"); 
+		
+		
+		
+	}
+
+
+	public boolean createPolicy(String name, String policyString) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"createPolicy"); 
+	
+		System.out.println("creating new client SPL policy");
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" Creating Policy instance :"+name);
+		
+		boolean result = _policyManager.createPolicy(name,policyString);
+        
+		System.out.println("done creating new client SPL policy");
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"createPolicy"); 
+		  
+		return result;
+	}
+
+	public void deletePolicy(String name) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"deletePolicy"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" deleting Policy instance :"+name);
+		
+		System.out.println("deleting client SPL policy");
+	       
+		_policyManager.deletePolicy(name);
+		System.out.println("done deleting client SPL policy");
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"deletePolicy"); 
+		  
+		return;
+	}
+
+	public List enumeratePolicyNames() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"enumeratePolicyNames"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" enumerating Policy names ");
+		
+
+        List policyNames = _policyManager.getAllPolicyNames();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"enumeratePolicyNames"); 
+		
+		return policyNames;
+	}
+
+	public Map enumeratePolicies() throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"enumeratePolicies"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" enumerating Policy instances ");
+		
+        Map policyInstances = _policyManager.getAllPolicies();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"enumeratePolicyNames"); 
+		
+		return policyInstances;
+
+	}
+
+	
+	public String getPolicy(String policyName) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"getPolicy"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" get Policy instances ");
+		
+        String policy = _policyManager.getPolicy(policyName);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"getPolicy"); 
+		
+		return policy;
+
+	}
+
+	public void modifyPolicy(String name, String policyString) throws SPLException {
+
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"modifyPolicy"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" modify Policy instances :"+name);
+		
+		_policyManager.updatePolicy(name,policyString);
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"modifyPolicy"); 
+		
+
+	}
+
+	public Object executePolicy(String policyName, Map instanceObjectMap) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+"executePolicy"); 
+		if(logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName()+" execute Policy :"+policyName);
+		Integer retVal=new Integer(-1);
+		System.out.println("executePolicy client SPL policy "+policyName);
+	    
+
+		System.out.println(" no instances passed in , evaluating against all instances");
+		PolicyInfo policyInfo=this._policyManager.getPolicyInfo(policyName);
+		Map classQuaifierMap=policyInfo.getClassQualifierMap();
+		Iterator classit=classQuaifierMap.keySet().iterator();
+		System.out.println("number of classes in policy = "+classQuaifierMap.size());
+
+		if(classQuaifierMap.size()==0 || classQuaifierMap.size()>1)
+		{
+			System.out.println("number of classes in policy should be one "+classQuaifierMap.toString());
+		}
+		while(classit.hasNext())
+		{
+			Map objMap = new Hashtable();
+			
+			String className=(String)classit.next();
+			String nameSpace=(String)classQuaifierMap.get(className);
+			CIMObjectPath classCop=new CIMObjectPath(className,nameSpace);
+			Enumeration copEnum=null;
+			try{
+				copEnum=_client.enumerateInstanceNames(classCop);
+				if(logger.isLoggable(Level.FINE))
+					logger.fine(Thread.currentThread().getName()+" enumerating instances of :"+classCop);
+				
+			}catch(CIMException e){
+				System.out.println("caught a CIMException "+e.getMessage());
+				e.printStackTrace();
+			}
+			if(logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" iteratig over instances of :"+classCop);
+			
+			while(copEnum.hasMoreElements())
+			{
+				
+				CIMObjectPath copI=(CIMObjectPath)copEnum.nextElement();
+				System.out.println("instance objectpath= "+copI.toString());
+
+				String objectName=copI.getObjectName();
+
+				if(objectName.equalsIgnoreCase(className))
+				{
+
+					if(logger.isLoggable(Level.FINE))
+						logger.fine(Thread.currentThread().getName()+" object name matches classname :"+objectName +" "+className);
+					
+				//	InstanceInfo iI=new InstanceInfo(objectName,copI);
+
+
+					//List instanceInfoList = new ArrayList();
+					//instanceInfoList.add(iI);
+
+					objMap.put(objectName, copI);
+
+
+
+
+
+					retVal=(Integer)_policyManager.evaluatePolicy(policyName,objMap);
+					if (logger.isLoggable(Level.FINE))
+						logger
+						.fine(Thread.currentThread().getName()+" return value is = "+retVal);
+
+					System.out.println(" policy evaluation complete "+ policyName +" on "+copI.toString()+" and return value= "+retVal);
+					objMap.remove(objectName);
+
+					logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"invokeMethod"); 
+
+				}
+				else
+				{
+					if (logger.isLoggable(Level.FINE))
+						logger
+						.fine(Thread.currentThread().getName()+" objectName.equalsIgnoreCase(className)  "+ objectName+ " "+className);
+
+					System.out.println(" SKIPPED >>>>>>>  "+ objectName+ " "+className);
+				}
+
+			}
+			System.out.println(" policy provider finished iterating over all instances ");
+			break;
+
+		}
+
+		System.out.println("executePolicy client SPL policy "+policyName);
+	    
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"executePolicy"); 
+		
+		return retVal;
+	}
+	
+
+	
+	private CIMClient getCIMClient(String url, String namespace, String username, String password) {
+		CIMClient client = null;
+		try {
+			
+		
+			// *****************************
+			// 1. Create user credentials
+			// *****************************
+			UserPrincipal userPr = new UserPrincipal(username);
+			char [] pwdCharArray = password.toCharArray();
+			PasswordCredential pwCred = new PasswordCredential(pwdCharArray);			
+	
+			// *****************************
+			// 2. Set NameSpace
+			// - URL is set like: http(s)://<IP>:Port
+			// - Namespace does not need to be specified in COPs if set in this constuctor
+			// - There is no server authentication being done. Thus: No need for a truststore
+			// *****************************			
+			CIMNameSpace ns = new CIMNameSpace(url,namespace);
+    
+			// *****************************
+			// 3. Create CIM Client
+			// *****************************		    				
+			client = new CIMClient(ns,userPr,pwCred);
+
+			
+			
+			System.out.println("got new cim client");
+		} catch(Exception e) {
+//			PolicyPluginLogUtil.logError("Error while connecting CIM Server", e);
+		}
+		return client;
+	}	
+}

Propchange: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/CIM_SPLPolicyRuleClientProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/TestClient.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/TestClient.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/TestClient.java (added)
+++ incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/TestClient.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,523 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+/**
+ * @author Neeraj Joshi <jn...@us.ibm.com>
+ *
+ * This class is used to invoke the client side CIM-SPL Provider
+ *
+ */
+package org.apache.imperius.cimspl.client;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+
+
+
+public class TestClient 
+{
+	
+	public static final int INVALID_OPERATION = -1;
+	public static final int LIST_POLICY = 0;
+	public static final int EXECUTE_POLICY = 1;
+	public static final int CREATE_POLICY = 2;
+	public static final int DELETE_POLICY = 3;
+	public static final int MODIFY_POLICY = 4;
+	public static final int LISTALLNAMES_POLICY = 5;
+	public static final int LISTALL_POLICY = 6;
+	private static  String USER = "";
+	private static  String PWD = "";
+	private static  int PORT = 5988;
+	private static  String SERVER = "localhost";
+	private static  String NAMESPACE = "root/cimv2";
+	private static String POLICY_NAME;
+	private static String POLICY_PATH;
+	private CIM_SPLPolicyRuleClientProvider _cimsplProvider = null;
+	
+	public TestClient(String user, String pwd, 
+			int port, String server, String ns, 
+			int operation) throws SPLException
+	{
+		
+		_establishConnection();
+	}
+
+	public TestClient() throws SPLException
+    {
+        _establishConnection();
+    }
+
+    /**
+	 * @param args
+	 */
+	public static void main(String[] args) 
+	{
+		int operation = _getInputs(args);
+		TestClient ptc = null;
+		try
+	    {  
+			try
+			{
+			
+				ptc = new TestClient(USER,PWD,PORT,SERVER,NAMESPACE,operation);
+				
+			}
+			catch (Exception e)
+			{
+				e.printStackTrace();
+				System.err.println("Error: " + e.getMessage());
+			    System.exit(0);  
+			        
+			} 
+	        switch (operation)
+	        {
+	            case CREATE_POLICY :
+	                {
+	                                      
+	                    System.out.println("create policy" + POLICY_NAME 
+	                        + " path " + POLICY_PATH);
+	                    ptc.createPolicy(POLICY_PATH, POLICY_NAME); 
+	                }
+	                break;
+	            case LIST_POLICY :
+	                {
+	                    
+	                    System.out.println("list policy" + POLICY_NAME);
+	                    ptc.listPolicy(POLICY_NAME);
+	                }
+	                break;
+	            case MODIFY_POLICY :
+	                {
+	                   
+	                   System.out.println("modify policy" + POLICY_NAME 
+	                        + " path " + POLICY_PATH);
+	                    ptc.modifyPolicy(POLICY_PATH, POLICY_NAME);
+	                }
+	                break;
+	            case LISTALL_POLICY :
+	                {
+	                    ptc.listAllPolicies();
+	                    System.out.println("list all policies" );
+	                }
+	                break;
+	            case LISTALLNAMES_POLICY :
+	                {
+	                    ptc.listAllPolicyNames();
+	                    System.out.println("list all names");
+	                }
+	                break;
+	            case DELETE_POLICY :
+	                {
+	                	System.out.println("delete policy" + POLICY_NAME);
+	                    ptc.deletePolicy(POLICY_NAME);
+	                    
+	                }
+	                break;
+	            case EXECUTE_POLICY :
+	                {
+	                	System.out.println("exec policy" + POLICY_NAME);
+	                    ptc.executePolicy(POLICY_NAME);
+	                    
+	                }
+	        
+	                break;
+	            case INVALID_OPERATION :
+	                	_throwUsage();
+	                break;
+
+	        }
+	        ptc.shutdown();
+	    }    
+		catch (Exception e)
+		{
+		    System.err.println("Error: " + e.getMessage());
+		      
+		        
+		} 
+		/*finally 
+		{
+			ptc.shutdown();
+		}*/
+		
+	}
+	
+	public void shutdown()
+	{
+		try {
+			_cimsplProvider.cleanup();
+		} catch (SPLException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+	}
+	
+	public void executePolicy(String policyName) throws SPLException 
+	{
+		Map objMap = new HashMap();
+		Object result = _cimsplProvider.executePolicy(policyName, objMap);
+		System.out.println("Result of execution" + result);
+	    
+		
+	}
+
+	public void deletePolicy(String policyName) throws SPLException 
+	{
+		_cimsplProvider.deletePolicy(policyName);
+         
+	
+		
+	}
+
+	public void listAllPolicyNames() throws SPLException 
+	{
+		List policyNames = _cimsplProvider.enumeratePolicyNames();
+		Iterator it = policyNames.iterator();
+		while (it.hasNext ())
+        {
+			String policyName = (String)it.next ();
+           
+  		   System.out.println("----------------------------");
+  		   System.out.println("Policy : " + policyName);
+  		   System.out.println("----------------------------");
+        }
+	
+		
+	}
+
+	public void listAllPolicies() throws SPLException 
+	{
+		Map policyMap = _cimsplProvider.enumeratePolicies();
+		Iterator it  = policyMap.keySet().iterator();
+		
+		while (it.hasNext())
+        {
+           String policyName = (String)it.next();
+           String policyString = (String)policyMap.get(policyName);
+          
+		  
+  		   System.out.println("----------------------------");
+  		   System.out.println("Policy Name: " + policyName);
+  		   System.out.println("Policy String: " + policyString);
+  		   System.out.println("----------------------------");
+        }
+
+		
+		
+	}
+
+	public void modifyPolicy(String policyPath, String policyName) throws SPLException 
+	{
+		String policyString = _readPolicyString(policyPath,policyName);
+		
+        _cimsplProvider.modifyPolicy(policyName, policyString);
+    	
+		
+		
+	}
+
+	public String listPolicy(String policyName) throws SPLException 
+	{
+		String policyString = _cimsplProvider.getPolicy(policyName);
+		
+		System.out.println("Policy String: " + policyString);
+        return policyString;
+
+		
+	}
+
+	public void createPolicy(String policyPath, String policyName) throws SPLException 
+	{
+		 String policyString = _readPolicyString(policyPath,policyName);
+		 
+		
+		 _cimsplProvider.createPolicy(policyName, policyString);
+		 
+		
+		
+	}
+
+	static int _getInputs(String[] args)
+	{
+	    int operation = INVALID_OPERATION;
+	    if (args.length < 1)
+	    {
+	        _throwUsage();
+	    }
+	    for (int i=0; i < args.length; i++)
+	    {
+	        if ( args[i].equalsIgnoreCase("-u")) 
+	        {
+	        	
+                if ( i + 1 < args.length )
+                {
+                	USER=args[i+1];
+                    i++;
+                }
+                else
+                {
+                	System.err.println("A user name is required");
+                	_throwUsage();
+                }
+
+	            
+            }
+	        else if (args[i].equalsIgnoreCase("-pwd"))
+	        {
+	            if (i+1 < args.length)
+                {
+	            	 PWD = args[i+1];
+	            	 i++;
+                }
+                else
+                {
+                	System.err.println("A pwd is required");
+                	_throwUsage();
+                }
+	         }
+	         else if (args[i].equalsIgnoreCase("-n"))
+	         {
+	        	
+	        	 if (i +1 < args.length)
+                 {
+	        		 NAMESPACE = args[i+1];
+	        		 i++;
+                 }
+                 else
+                 {
+                	 System.err.println("A namespace is required");
+                	 _throwUsage();
+                 }
+	         }
+	         else if (args[i].equalsIgnoreCase("-s"))
+	         {
+	        	
+	        	 if (i +1 <  args.length)
+                 {
+	        		 SERVER = args[i+1];
+	        		 i++;
+                 }
+                 else
+                 {
+                	 System.err.println("A servername is required");
+                	 _throwUsage();
+                 }
+	         }
+	         else if (args[i].equalsIgnoreCase("-p"))
+	         {
+	        	 
+	        	 if (i+1 < args.length)
+                 {
+	        		 PORT = Integer.parseInt(args[i+1]); 
+	        		 i++;
+                 }
+                 else
+                 {
+                	 System.err.println("A servername is required");
+                     _throwUsage();
+                 }
+	         }
+	         else if (args[i].equalsIgnoreCase("-l"))
+             {
+	        	 
+                 if (i+1 < args.length)
+                 {
+                	 POLICY_NAME = args[i+1];
+                     operation = LIST_POLICY;
+                     break; 
+                    
+                 }
+                 else
+                 {
+                	 
+                     _throwUsage();
+                 }
+             }
+	         else if (args[i].equalsIgnoreCase("-x"))
+	         {
+	        	 if (i + 1 < args.length)
+                 {
+                	 POLICY_NAME = args[i+1];
+	                 operation = EXECUTE_POLICY;
+	                 break;
+                	 
+                    
+                 }
+                 else
+                 {
+                	 _throwUsage();
+	             }
+	             
+	         }
+	         else if (args[i].equalsIgnoreCase("-m"))
+	         {
+	             if ((i+2) < args.length)
+	             {
+	                    POLICY_PATH = args[i+1];
+	                    POLICY_NAME = args[i+2];
+	                    operation = MODIFY_POLICY;
+	                    break;
+	             }
+	             else
+	             {
+	                    _throwUsage();
+	             }
+
+	          }
+	          else if (args[i].equalsIgnoreCase("-d"))
+	          {
+	        	  
+	              if (i+1 < args.length)
+	              {
+	                  POLICY_NAME = args[i+1];
+	                  operation = DELETE_POLICY;
+	                  break;
+	              }
+	              else
+	              {
+	                  _throwUsage();
+	              }
+	          }
+	          else if (args[i].equalsIgnoreCase("-i"))
+	          {
+	              operation = LISTALL_POLICY;
+	              break;
+	          }
+	          else if (args[i].equalsIgnoreCase("-a"))
+	          {
+	              operation = LISTALLNAMES_POLICY;
+	              break;
+	              
+	          }
+	          else if (args[i].equalsIgnoreCase("-c"))
+	          {
+	              if ((i+2) <args.length)
+	              {
+	                  POLICY_PATH = args[i+1];
+	                  POLICY_NAME = args[i+2];
+	                  operation = CREATE_POLICY;
+	                  break;
+	                    
+	              }
+	              else
+	              {
+	                  _throwUsage();
+	              }
+	          }
+	          else
+	          {
+	              _throwUsage();
+	          }
+	     }
+	     if(operation == INVALID_OPERATION)
+	     {
+	        _throwUsage();
+	     }
+	    
+	     return operation;
+	}
+
+	private static void _throwUsage() 
+	{
+		System.out.println(" Usage: PolicyClient ");
+		System.out.println( "   [-s <server name>] [-p <port>] [-u <user>] [-p <pwd>] "); 
+		System.out.println( "                 -l <policy name> OR " );
+		System.out.println( "                 -c <policy path> <policy name> OR " );
+		System.out.println( "                 -m <policy path> <policy name> OR" );
+		System.out.println( "                 -d <policy name> OR" );
+		System.out.println( "                 -x <policy name> OR" );
+		System.out.println( "                 -i  OR" );
+		System.out.println( "                 -a  " );
+	    System.exit(0);
+
+				
+	}
+	
+	private String _readPolicyString(String path, String policyName)
+	{
+		StringBuffer policy = new StringBuffer();
+		path = path + "/" + policyName;
+		//path.concat(policyName);	  
+		if(!path.endsWith(".spl"))
+		{
+			path = path  + ".spl";
+			
+		}	
+		try
+		{
+			System.out.println("path="+path);
+			FileReader input = new FileReader(path);
+			  
+			BufferedReader bufRead = new BufferedReader(input);
+			String line;    // String that holds current file line
+			int count = 0;  // Line number of count 
+			line = bufRead.readLine();
+			policy.append(line);
+			policy.append("\n");
+			count++;
+			while (line != null)
+			{
+				line = bufRead.readLine();
+				policy.append(line);
+				policy.append("\n");
+			    count++;
+			}
+			            
+			bufRead.close();
+		            
+		}
+		catch (FileNotFoundException e) 
+		{
+			System.err.println("Error Reading file");
+			e.printStackTrace();
+		} 
+		catch (IOException e) 
+		{
+			System.err.println("Error Reading file");
+			e.printStackTrace();
+		}
+		return policy.toString();
+		
+
+	}
+	void _establishConnection() throws SPLException
+    
+	{
+		
+		
+		String url = "http://" + SERVER + ":" + PORT;
+		_cimsplProvider =	new CIM_SPLPolicyRuleClientProvider(url, 
+				NAMESPACE, USER, PWD);
+		
+		
+		System.out.println("Established Connection");
+	}
+
+
+
+}

Propchange: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/main/java/org/apache/imperius/cimspl/client/TestClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/test/java/org/apache/imperius/cimspl/samples/simplepolicies/TestSimplePolicies.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/test/java/org/apache/imperius/cimspl/samples/simplepolicies/TestSimplePolicies.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/test/java/org/apache/imperius/cimspl/samples/simplepolicies/TestSimplePolicies.java (added)
+++ incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/test/java/org/apache/imperius/cimspl/samples/simplepolicies/TestSimplePolicies.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+package org.apache.imperius.cimspl.samples.simplepolicies;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.imperius.cimspl.client.TestClient;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class TestSimplePolicies extends TestCase 
+{
+	
+	public TestSimplePolicies(String arg0) {
+		super(arg0);
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(TestSimplePolicies.class);
+		TestSetup wrapper = new TestSetup(suite) {
+
+			protected void setUp() throws Exception {
+				oneTimeSetUp();
+			}
+
+			protected void tearDown() throws Exception {
+				oneTimeTearDown();
+			}
+		};
+		return wrapper;
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
+	
+	protected static void oneTimeSetUp() throws Exception {
+	}
+
+	protected static void oneTimeTearDown() throws Exception {
+
+	}
+	
+	
+	/**
+	 * @param args
+	 */
+	public static void testMain() 
+	{
+		String userDir = System.getProperty("user.dir");
+		System.out.println("user dir is " + userDir);
+		testCIMSPLClientSideProvider(userDir + "/resources/policies/");
+		
+		
+	}
+
+    private static void testCIMSPLClientSideProvider(String path)
+    {
+        try
+        {
+            TestClient tc = new TestClient();
+            List policyList = _getPolicyNames();
+            Iterator policyNameIterator = policyList.iterator();
+            while(policyNameIterator.hasNext())
+            {    
+                String policyName = (String)policyNameIterator.next();
+                try
+                {
+                    tc.deletePolicy(policyName);
+                }
+                catch(SPLException e)
+                {
+                    
+                }
+                tc.createPolicy(path, policyName);
+                tc.executePolicy(policyName);
+            }   
+            try
+            {
+                tc.deletePolicy("testElement1Policy");
+                tc.deletePolicy("CascadedPolicyInvocation");
+            }
+            catch(SPLException e)
+            {
+                
+            }    
+            tc.createPolicy(path,"testElement1Policy");
+            tc.createPolicy(path,"CascadedPolicyInvocation");
+            tc.executePolicy("CascadedPolicyInvocation");
+           
+            tc.shutdown();
+            
+        }
+        catch (SPLException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
+    }
+
+    private static List _getPolicyNames()
+    {
+       List policyNameList = new ArrayList();
+       policyNameList.add("SimplePolicy1.0.1");
+       policyNameList.add("ComplexPolicy");
+       policyNameList.add("InvokeMethodSample");
+       policyNameList.add("MacroSample");
+       policyNameList.add("MultiplePolicySample");
+      
+       
+        return policyNameList;
+    }
+
+
+
+
+	
+
+}
+
+
+
+
+
+
+
+

Propchange: incubator/imperius/trunk/imperius-cimsplclientsideprovider/src/test/java/org/apache/imperius/cimspl/samples/simplepolicies/TestSimplePolicies.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplcommon/pom.xml
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplcommon/pom.xml?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplcommon/pom.xml (added)
+++ incubator/imperius/trunk/imperius-cimsplcommon/pom.xml Thu Feb 14 12:52:39 2008
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>imperius</groupId>
+  <artifactId>imperius-cimsplcommon</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+  <name>imperius-cimsplcommon</name>
+  <dependencies>
+    <dependency>
+      <groupId>imperius</groupId>
+      <artifactId>imperius-splcore</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>sblim</groupId>
+      <artifactId>sblimCIMClient</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+        
+  </dependencies>
+ 
+</project>

Propchange: incubator/imperius/trunk/imperius-cimsplcommon/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplcommon/resources/customexpressions.properties
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplcommon/resources/customexpressions.properties?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplcommon/resources/customexpressions.properties (added)
+++ incubator/imperius/trunk/imperius-cimsplcommon/resources/customexpressions.properties Thu Feb 14 12:52:39 2008
@@ -0,0 +1,2 @@
+SPL_CUSTOM_EXPRESSIONS=org.apache.imperius.cimspl.userdefinedmethods.ToUINT8,org.apache.imperius.cimspl.userdefinedmethods.ToUINT16,org.apache.imperius.cimspl.userdefinedmethods.ToUINT32,org.apache.imperius.cimspl.userdefinedmethods.ToUINT64
+SPL_CUSTOM_ACTIONS

Propchange: incubator/imperius/trunk/imperius-cimsplcommon/resources/customexpressions.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT16.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT16.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT16.java (added)
+++ incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT16.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.cimspl.userdefinedmethods;
+
+
+import java.util.List;
+import java.util.logging.Logger;
+
+//import org.pegasus.jmpi.UnsignedInt16;
+import org.sblim.wbem.cim.UnsignedInt16;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+public class ToUINT16 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToUINT16.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToUINT16";
+    
+    
+    
+    public ToUINT16(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT16");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT16");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            if (obj instanceof Number)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return new UnsignedInt16(((Number) obj).intValue());
+                
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return new UnsignedInt16(Integer.parseInt((String) obj));
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            
+            _dataType.setType(TypeConstants.shortType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT16.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT32.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT32.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT32.java (added)
+++ incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT32.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.cimspl.userdefinedmethods;
+
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.sblim.wbem.cim.UnsignedInt32;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+public class ToUINT32 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToUINT32.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToUINT32";
+    
+    
+    
+    public ToUINT32(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT32");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT32");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            if (obj instanceof Number)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return new UnsignedInt32(((Number) obj).longValue());
+                
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return new UnsignedInt32(Long.parseLong((String) obj));
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.intType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT32.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT64.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT64.java?rev=627867&view=auto
==============================================================================
--- incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT64.java (added)
+++ incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT64.java Thu Feb 14 12:52:39 2008
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.  
+ */
+
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.cimspl.userdefinedmethods;
+
+
+import java.math.BigInteger;
+import java.util.List;
+import java.util.logging.Logger;
+
+//import org.pegasus.jmpi.UnsignedInt64;
+import org.sblim.wbem.cim.UnsignedInt64;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+public class ToUINT64 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToUINT64.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToUINT64";
+    
+    
+    
+    public ToUINT64(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT64");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ToUINT64");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            if (obj instanceof Number)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return new UnsignedInt64(new BigInteger(((Number) obj)
+                        .toString()));
+                
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return new UnsignedInt64(new BigInteger((String) obj));
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.longType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        
+        return false;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-cimsplcommon/src/main/java/org/apache/imperius/cimspl/userdefinedmethods/ToUINT64.java
------------------------------------------------------------------------------
    svn:eol-style = native