//
// CIMOMHandleGeneric.java
//
// The contents of this file are subject to the SNIA Public License Version 1.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.snia.org/resources/openSource.html
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is CIMOMHandleGeneric.java
// 
// The Initial Developer of the Original Code is David Simons.
//
// Contributor(s):
//
//
// This source uses the Solaris WBEM APIs version 2.2. 
// Synchronization will be maintained with the Solaris WBEM APIS,
// which are being standardized through the Java Community Process.
//
//
// $Id: CIMOMHandleGeneric.java,v 1.1 2003/07/17 18:32:55 kumpf Exp $
//
package org.snia.wbemcmd.cimom;

import java.rmi.*;
import java.util.*;
import java.util.Enumeration;
import java.util.Vector;
import org.snia.wbem.client.*;
import org.snia.wbem.cim.*;

//
// This class provides functionality that can be shared either
// by local CIMOM handles or RMI based ones.
//
public abstract class CIMOMHandleGeneric implements CIMOMHandleSNIA {
    CIMImplementation cs;

    
    public static String CIMOMName="OpenCIMOM";

    public void authenticate(String userName,String password) throws CIMException{
       try {
	    cs.authenticate(userName,password);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
    
     public void createNameSpace(CIMNameSpace ns) throws CIMException{
       try {
	    cs.createNameSpace(ns);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

    //Not implemented.
    public void setTimeout(int timeout)
    {
    }

    //Not implemented.
    public int getTimeout()
    {
        return 0;
    }

    //close 
    public void close() throws CIMException {
	cs=null;
    }

    // deleteNameSpace 
    public void deleteNameSpace(CIMNameSpace cns) throws CIMException{
	try {
	    cs.deleteNameSpace(cns);
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }



    //deleteClass 
    public void deleteClass(CIMObjectPath path) throws CIMException{
	try {
	    cs.deleteClass(path);
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }



    //deleteInstance 
    public void deleteInstance(CIMObjectPath path) throws CIMException{
       try {
	    cs.deleteInstance(path);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }




    //deleteQualifierType 
    //
    public void deleteQualifierType(CIMObjectPath path) throws CIMException{
	try {
	    cs.deleteQualifierType(path);
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }



    // deleteQualifier
    //
    public void deleteQualifier(CIMObjectPath path) throws CIMException{
	try {
	    cs.deleteQualifierType(path);
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }

    //enumNameSpace 
    //
    public Enumeration enumNameSpace(CIMObjectPath path,boolean deep) throws CIMException {
	try {
	    return(cs.enumNameSpace(path,deep));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }

    //enumerateNameSpaces
    //
    public Enumeration enumerateNameSpaces(
        CIMObjectPath path,
        boolean deepInheritance) throws CIMException
    {
	try {
	    return(cs.enumNameSpace(path,deepInheritance));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
	}
    }


    //enumClass 
    public Enumeration enumClass(CIMObjectPath path,
		   boolean deep,
		   boolean localOnly) throws CIMException {
       try {
	    return(cs.enumClass(path,deep,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

    // enumerateClasses
    //
    public Enumeration enumerateClasses(
        CIMObjectPath path,
        boolean deepInheritance,
        boolean localOnly,
        boolean includeQualifiers,
        boolean includeClassOrigin) throws CIMException
    {
       try {
	    return(cs.enumClass(path,deepInheritance,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
		   


    //enumClass 
    public Enumeration enumClass(CIMObjectPath path,
		   boolean deep) throws CIMException {
	try {
	    return(cs.enumClass(path,deep));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

    //enumerateClassNames 
    //
    public Enumeration enumerateClassNames(
        CIMObjectPath path,
        boolean deepInheritance) throws CIMException
    {
	try {
	    return(cs.enumClass(path,deepInheritance));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
		   


    //enumInstances 
    public Enumeration enumInstances(CIMObjectPath path,
		       boolean deep) throws CIMException{
       try {
	    return(cs.enumInstances(path,deep));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

    //enumerateInstanceNames
    //
    public Enumeration enumerateInstanceNames(
        CIMObjectPath path) throws CIMException
    {
       try {
	    return(cs.enumInstances(path,false));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

		       

    //enumInstances 
    //
    public Enumeration enumInstances(CIMObjectPath path,
		       boolean deep,
		       boolean localOnly) throws CIMException{
       try {
	    return(cs.enumInstances(path,deep,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }

    //enumerateInstances
    //
    public Enumeration enumerateInstances(
        CIMObjectPath path,
        boolean deepInheritance,
        boolean localOnly,
        boolean includeQualifiers,
        boolean includeClassOrigin,
        String propertyList[]) throws CIMException
    {
       try {
	    return(cs.enumInstances(path,deepInheritance,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
		       

    //enumQualifierTypes 
    //
    public Enumeration enumQualifierTypes(CIMObjectPath path) throws CIMException{
       try {
	    return(cs.enumQualifierTypes(path));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }


    //enumerateQualifiers
    //
    public Enumeration enumerateQualifiers(
        CIMObjectPath path) throws CIMException
    {
       try {
	    return(cs.enumQualifierTypes(path));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }



    //getClass 
    public CIMClass getClass(CIMObjectPath name,
	       boolean localOnly) throws CIMException{
       try {
	    return(cs.getClass(name,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       } 
    }


    //getClass 
    //
    public CIMClass getClass(
        CIMObjectPath path,
        boolean localOnly,
        boolean includeQualifiers,
        boolean includeClassOrigin,
        String [] propertyList) throws CIMException
    {
       try {
	    return(cs.getClass(path,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       } 
    }


    //getInstance 
    //
    public CIMInstance getInstance(CIMObjectPath name,
		     boolean localOnly) throws CIMException {
       try {
	    return(cs.getInstance(name,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
		     
		     
    //getInstance 
    //
    public CIMInstance getInstance(
        CIMObjectPath path,
        boolean localOnly,
        boolean includeQualifiers,
        boolean includeClassOrigin,
        String propertyList[]) throws CIMException
    {
       try {
	    return(cs.getInstance(path,localOnly));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,re.toString());
       }
    }
		     
		     
    //invokeMethod 
    //
    public CIMValue invokeMethod(CIMObjectPath name,
		   String methodName,
		   Vector inParams,
		   Vector outParams) throws CIMException{
       try {
	    return(cs.invokeMethod(name,methodName,inParams,outParams));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }



    //getQualifierType 
    public CIMQualifierType getQualifierType(CIMObjectPath name) 
	    throws CIMException{
       try {
	    return(cs.getQualifierType(name));
       } catch (RemoteException re) {
		   throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    // getQualifier
    //
    public CIMQualifierType getQualifier(CIMObjectPath path)
	    throws CIMException{
       try {
	    return(cs.getQualifierType(path));
       } catch (RemoteException re) {
		   throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    //createQualifierType 
    public void createQualifierType(CIMObjectPath name,
		      CIMQualifierType qt) throws CIMException{
	   try {
	    cs.createQualifierType(name,qt);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }
		      
		      
		      
		      
    //setQualifierType 
    //
    public void setQualifierType(CIMObjectPath name,
		   CIMQualifierType qt) throws CIMException{
       try {
	    cs.setQualifierType(name,qt);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    // setQualifier
    //
    public void setQualifier(CIMObjectPath path,
		   CIMQualifierType qt) throws CIMException{
       try {
	    cs.setQualifierType(path,qt);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    //createClass 
    //
    public void createClass(CIMObjectPath name,
	      CIMClass cc) throws CIMException {
	  
       try {
	    cs.createClass(name,cc);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }     
    }



    //setClass 
    //
   public void setClass(CIMObjectPath name,
	   CIMClass cc) throws CIMException {
       try {
	    cs.setClass(name,cc);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    // modifyClass()
    //
    public void modifyClass(
        CIMObjectPath path,
        CIMClass cc) throws CIMException {
       try {
	    cs.setClass(path,cc);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    // createInstance 
    //
    public CIMObjectPath createInstance(CIMObjectPath name,
		 CIMInstance ci) throws CIMException{
       try {
	   return(cs.createInstance(name,ci));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }



    //setInstance 
    //
    public void setInstance(CIMObjectPath path,
	      CIMInstance ci) throws CIMException{
	try {
	   cs.setInstance(path,ci);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    // modifyInstance
    //
    public void modifyInstance(
        CIMObjectPath path,
        CIMInstance modifiedInstance,
        boolean includeQualifiers,
        String propertyList[]) throws CIMException
    {
	try {
	   cs.setInstance(path,modifiedInstance);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    //getProperty 
    //
    public CIMValue getProperty(CIMObjectPath name,
			    String propertyName)throws CIMException{
       try {
	    return(cs.getProperty(name,propertyName));
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }


    //setProperty 
    //
    public void setProperty(CIMObjectPath name,
	      String propertyName,
	      CIMValue newValue) throws CIMException{
	   try {
	    cs.setProperty(name,propertyName,newValue);
       } catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
       }
    }





    
    public Enumeration associatorNames(CIMObjectPath path,String assocClass,
					String resultClass,
					String role,String resultRole) throws CIMException {
	try {
	    return(cs.associatorNames(path,assocClass,
					resultClass,
					role,resultRole));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
	}
    }
    
    public Enumeration associators(CIMObjectPath path,
					String assocClass,
					String resultClass,
					String role,
					String resultRole,
					boolean includeQualifiers,
					boolean includeClassOrigin,
					String propertyList[])throws CIMException {
	try {
	    return(cs.associators(path,assocClass,resultClass,role,resultRole,includeQualifiers,
					includeClassOrigin,
					propertyList));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
	}
    }
    
    public Enumeration referenceNames(CIMObjectPath path,
				    String resultClass,
				    String role) throws CIMException {
	try {
	    return(cs.referenceNames(path,resultClass,role));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
	}
    }
    public Enumeration references(CIMObjectPath path,String resultClass,
					   String role,
					   boolean includeQualifiers,
					   boolean includeClassOrigin,
					   String [] propertyList)throws CIMException {
	try {
	    return(cs.references(path,resultClass,role,includeQualifiers,
					includeClassOrigin,
					propertyList));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
	}
    }
    public String encryptData(String data) throws CIMException {
	return(data);	// SUNDIFF - no encryption 
    }
    public Enumeration execQuery(CIMObjectPath cop,
				 String query,
				 int ql) throws CIMException {
	try {
	    return(cs.execQuery(cop,query,ql));
	} catch (RemoteException re) {
	    throw new CIMException(CIMException.CIM_ERR_FAILED,"Error:"+re);
	}
    }


/*
    // addCIMListener is irrelevant for this particular class.
    public void addCIMListener(CIMListener listener) throws CIMException {
	throw new CIMException(CIMException.CIM_ERR_METHOD_NOT_AVAILABLE);
    }

    // removeCIMListener is irrelevant for this particular class.
    public void removeCIMListener(CIMListener listener) throws CIMException {
	throw new CIMException(CIMException.CIM_ERR_METHOD_NOT_AVAILABLE);
    }

*/

    //
    // SUNDIFF START 
    //
    
    public CIMFeatures getServerFeatures() throws CIMException
    {	
	return(new CIMOMFeatures());
    }
    
    //
    // SUNDIFF END
    //

}
