Examples of CIMValue


Examples of org.pegasus.jmpi.CIMValue

          {
            CIMArgument cimarg=in[i];
            if(cimarg.getName().equalsIgnoreCase("arrayOfInstances"))
            {
              arrayOfInstancesParamFound=true;
              CIMValue cv=cimarg.getValue();

              List arrayCop=(List)cv.getValue();

              Iterator it=arrayCop.iterator();
              while(it.hasNext())
              {
                arrayOfInstancesParamSizeGreaterThanZero=true;
                CIMObjectPath copI=(CIMObjectPath)it.next();
                String objectName=copI.getObjectName();

                //InstanceInfo iI=new InstanceInfo(objectName,copI);

                //List instanceInfoList = new ArrayList();
                //instanceInfoList.add(iI);

                objMap.put(objectName, copI);

                Integer retVal=(Integer)_policyManager.evaluatePolicy(policyRuleName,objMap);
                if (logger.isLoggable(Level.FINE))
                  logger.fine(Thread.currentThread().getName()+" return value is = "+retVal);

                objMap.remove(objectName);

                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"invokeMethod");
              }

            }
           
            break;

          }

        }

      }
      if( !inparamsIsNotNull || !inparamsLengthGreaterThanZero || !arrayOfInstancesParamFound ||
          !arrayOfInstancesParamSizeGreaterThanZero)
      {
       
        logger.fine(Thread.currentThread().getName() + "no instances passed evaluating against all");
       
        PolicyInfo policyInfo=this._policyManager.getPolicyInfo(policyRuleName);
       
        Map classQuaifierMap=policyInfo.getClassQualifierMap();
        Iterator classit=classQuaifierMap.keySet().iterator();
       
        if(classQuaifierMap.size()==0 || classQuaifierMap.size()>1)
        {
          logger.severe(Thread.currentThread().getName() + "Multiple Import classes not supported in CIM-SPL");
        }
        while(classit.hasNext())
        {
          String className=(String)classit.next();
          String nameSpace=(String)classQuaifierMap.get(className);
          CIMObjectPath classCop=new CIMObjectPath(className,nameSpace);
          Enumeration copEnum=_handle.enumerateInstanceNames(classCop);
          while(copEnum.hasMoreElements())
          {

            CIMObjectPath copI=(CIMObjectPath)copEnum.nextElement();
            logger.fine(Thread.currentThread().getName() + "instance objectpath= "+copI.toString());

            String objectName=copI.getObjectName();

            if(objectName.equalsIgnoreCase(className))
            {
//              InstanceInfo iI=new InstanceInfo(objectName,copI);
//
//              List instanceInfoList = new ArrayList();
//              instanceInfoList.add(iI);

              objMap.put(objectName, copI);

              logger.fine(Thread.currentThread().getName() + "about to invoke evaluate policy");

              returnValue=(Integer)_policyManager.evaluatePolicy(policyRuleName,objMap);
              if (logger.isLoggable(Level.FINE))
                logger.fine(Thread.currentThread().getName()+" return value is = "+returnValue);

              objMap.remove(objectName);

              logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"invokeMethod");

            }
            else{
             
            }

          }

          break;

        }

      }

      return new CIMValue(returnValue);
    }
    catch (SPLException e)
    {
      logger.severe(Thread.currentThread().getName()+" "+"getInstance failed :"+e.getMessage());
      throw new CIMException("getInstance failed :"+e.getMessage());
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

      // create a CIMPolicy Object out of the PolicyString and
      // PolicyRuleName
      CIMInstance policyInstance = new CIMInstance(POLICY_CLASS_NAME);

      policyInstance.setProperty("SystemCreationClassName",
          new CIMValue("cim_splpolicyrule"));
      policyInstance.setProperty("SystemName", new CIMValue("localhost.localdomain"));
      policyInstance.setProperty("CreationClassName", new CIMValue(POLICY_CLASS_NAME));
      policyInstance.setProperty("PolicyRuleName", new CIMValue(policyRuleName));
      policyInstance.setProperty("PolicyString", new CIMValue(PolicyString));
      logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "_createPolicyCIMInstance");
      return policyInstance;
    }
    else
    {
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

    {
      if (logger.isLoggable(Level.FINE))
        logger.fine(Thread.currentThread().getName()+" create a CIMObjectPath using the PolicyRuleName");
      // create a CIMObjectPath using the PolicyRuleName
      CIMObjectPath cop = new CIMObjectPath(POLICY_CLASS_NAME, NAMESPACE);
      cop.addKey("SystemName", new CIMValue("localhost.localdomain"));
      cop.addKey("CreationClassName", new CIMValue(POLICY_CLASS_NAME));
      cop.addKey("PolicyRuleName", new CIMValue(policyRuleName));
      logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "_createPolicyObjectPath");
      return cop;

    }
    else
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

    {
      CIMProperty prop=(CIMProperty)it.next();
      CIMProperty prop2=(CIMProperty)it2.next();
      String propertyname=prop.getName();
      String propertyname2=prop2.getName();
      CIMValue cimv1=prop.getValue();
      CIMValue cimv2=prop2.getValue();
      try
      {
        //System.out.println(" "+propertyname+" "+propertyname2+" "+cimv1.getValue()+" "+cimv2.getValue());
        if(!propertyname.equalsIgnoreCase(propertyname2))
        {
          if(logger.isLoggable(Level.FINE))
            logger.fine(Thread.currentThread().getName()+" propertyname did not match");

          return false;
        }

        if(!cimv1.getValue().toString().equalsIgnoreCase(cimv2.getValue().toString()))
        {
          if(logger.isLoggable(Level.FINE))
            logger.fine(Thread.currentThread().getName()+" getValue did not match");

          return false;
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

          CIMObjectPath instanceCop=new CIMObjectPath(className,namespace);
          instanceCop.setKeys(cop.getKeys());

          //System.out.println("cop, methodName :"+instanceCop+" "+ methodName);
          CIMValue cv=handle.invokeMethod(instanceCop, methodName, inParams, outParams);
          //System.out.println("invokeMethod complete : return value="+cv.getValue());
          if(logger.isLoggable(Level.FINE))
            logger.fine(Thread.currentThread().getName()+" Actuator::invokeMethod:done invoking method");
          if(logger.isLoggable(Level.FINE))
            logger.fine(outParams.toString());
          logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "invokeMethod");
          //Integer returnVal=new Integer(1);
          return cv.getValue();

        }
        else{
          logger.severe(Thread.currentThread().getName()+" "+"instance for method invokation is not of type CIMObjectPath");
          throw new SPLException("instance for method invokation is not of type CIMObjectPath");
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

  }

  private CIMValue getCIMObjectOfGivenType(int type, boolean isArray, Object CIMKeyValue) throws CIMException,SPLException
  {
    CIMValue cimval=null;
    if(isArray){

      if(type==CIMDataType.UINT8_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List uintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Short sht=new Short(Short.parseShort((arrayIt.next()).toString()));
          UnsignedInt8 uint8= new UnsignedInt8(sht.shortValue());
          uintArray.add(uint8);
        }
        Object actualValue=(UnsignedInt8[])uintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.UINT16_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List uintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Integer integ=new Integer(Integer.parseInt((arrayIt.next()).toString()));
          UnsignedInt16 uint16= new UnsignedInt16(integ.intValue());
          uintArray.add(uint16);
        }
        Object actualValue=(UnsignedInt16[])uintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.UINT32_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List uintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Long lng=new Long(Long.parseLong((arrayIt.next()).toString()));
          UnsignedInt32 uint32= new UnsignedInt32(lng.longValue());
          uintArray.add(uint32);
        }
        Object actualValue=(UnsignedInt32[])uintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.UINT64_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List uintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Long lng=new Long(Long.parseLong((arrayIt.next()).toString()));
          BigInteger big=BigInteger.valueOf(lng.longValue());
          UnsignedInt64 uint64= new UnsignedInt64(big.abs());
          uintArray.add(uint64);
        }
        Object actualValue=(UnsignedInt64[])uintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.SINT8_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Byte bt=new Byte(Byte.parseByte((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Byte[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.SINT16_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Short bt=new Short(Short.parseShort((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Short[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.SINT32_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Integer bt=new Integer(Integer.parseInt((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Integer[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.SINT64_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Long bt=new Long(Long.parseLong((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Long[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.REAL32_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Float bt=new Float(Float.parseFloat((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Float[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.REAL64_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Double bt=new Double(Double.parseDouble((arrayIt.next()).toString()));
          sintArray.add(bt);
        }
        Object actualValue=(Double[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.BOOLEAN_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Boolean bt=Boolean.valueOf((arrayIt.next()).toString());
          sintArray.add(bt);
        }
        Object actualValue=(Boolean[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }
      if(type==CIMDataType.CHAR16_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          Character bt=new Character(((arrayIt.next()).toString()).charAt(0));
          sintArray.add(bt);
        }
        Object actualValue=(Character[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.STRING_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List sintArray=new ArrayList();
        while(arrayIt.hasNext()){
          String bt=(arrayIt.next()).toString();
          sintArray.add(bt);
        }
        Object actualValue=(String[])sintArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }

      if(type==CIMDataType.DATETIME_ARRAY){
        if(!(CIMKeyValue instanceof List)){
          logger.severe(Thread.currentThread().getName()+" "+"expected a List");
          throw new SPLException("expected a List");
        }
        List intArray=(List)CIMKeyValue;
        Iterator arrayIt=intArray.iterator();
        List cimDateTimeArray=new ArrayList();
        while(arrayIt.hasNext()){
          Object ob=arrayIt.next();
          if(!(ob instanceof Calendar)){
            throw new SPLException("Value should be of type Calendar");
          }
          Calendar cal=(Calendar)ob;
          CIMDateTime calCIM=new CIMDateTime(cal.getTime());
          cimDateTimeArray.add(calCIM);
        }
        Object actualValue=(CIMDateTime[])cimDateTimeArray.toArray();
        cimval=new CIMValue(actualValue);                   
      }



    }else{
      if(type==CIMDataType.UINT8){
        Short sht=new Short(Short.parseShort(CIMKeyValue.toString()));
        UnsignedInt8 uint8= new UnsignedInt8(sht.shortValue());
        cimval=new CIMValue(uint8);
      }
      if(type==CIMDataType.UINT16){
        Integer integ=new Integer(Integer.parseInt(CIMKeyValue.toString()));
        UnsignedInt16 uint16= new UnsignedInt16(integ.intValue());
        cimval=new CIMValue(uint16);
      }
      if(type==CIMDataType.UINT32){
        Long lng=new Long(Long.parseLong(CIMKeyValue.toString()));
        UnsignedInt32 uint32= new UnsignedInt32(lng.longValue());
        cimval=new CIMValue(uint32);
      }
      if(type==CIMDataType.UINT64){
        Long shrt=new Long(Long.parseLong(CIMKeyValue.toString()));
        BigInteger big=BigInteger.valueOf(shrt.longValue());
        UnsignedInt64 uint64= new UnsignedInt64(big.abs());
        cimval=new CIMValue(uint64);
      }
      if(type==CIMDataType.SINT8){
        Byte byt=new Byte(Byte.parseByte(CIMKeyValue.toString()));
        cimval=new CIMValue(byt);
      }
      if(type==CIMDataType.SINT16){
        Short sht=new Short(Short.parseShort(CIMKeyValue.toString()));
        cimval=new CIMValue(sht);
      }
      if(type==CIMDataType.SINT32){
        Integer integ=new Integer(Integer.parseInt(CIMKeyValue.toString()));
        cimval=new CIMValue(integ);
      }
      if(type==CIMDataType.SINT64){
        Long lng=new Long(Long.parseLong(CIMKeyValue.toString()));
        cimval=new CIMValue(lng);
      }
      if(type==CIMDataType.REAL32){
        Float flt=new Float(Float.parseFloat(CIMKeyValue.toString()));
        cimval=new CIMValue(flt);
      }
      if(type==CIMDataType.REAL64){
        Double dbl=new Double(Double.parseDouble(CIMKeyValue.toString()));
        cimval=new CIMValue(dbl);
      }
      if(type==CIMDataType.CHAR16){
        Character cha=new Character((CIMKeyValue.toString()).charAt(0));
        cimval=new CIMValue(cha);
      }
      if(type==CIMDataType.BOOLEAN){
        Boolean booln=Boolean.valueOf(CIMKeyValue.toString());
        cimval=new CIMValue(booln);
      }
      if(type==CIMDataType.STRING){
        String str=CIMKeyValue.toString();
        cimval=new CIMValue(str);
      }
      if(type==CIMDataType.DATETIME){
        if(!(CIMKeyValue instanceof Calendar)){
          throw new SPLException("Value should be of type Calendar");
        }
        Calendar cal=(Calendar)CIMKeyValue;
        CIMDateTime calCIM=new CIMDateTime(cal.getTime());
        cimval=new CIMValue(calCIM);
      }

    }
    return cimval;
  }
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

      while(instancePropertyIterator.hasNext()){
        CIMProperty cimprop=(CIMProperty)instancePropertyIterator.next();
        String name=cimprop.getName();
        int type=cimprop.getType().getType();
        boolean isArray=cimprop.isArray();
        CIMValue instValue=cimprop.getValue();
        if(cimprop.getName().equalsIgnoreCase(keyName)){
          Object CIMKeyValue=KeyValue;
          if(logger.isLoggable(Level.FINE))
            logger.fine(Thread.currentThread().getName()+" Instance property:: Name,Type,Value,CIMKeyValue :"+name+" "+type+" "+instValue+" "+CIMKeyValue.getClass());
          try{


            CIMValue cimval=getCIMObjectOfGivenType(type, isArray, CIMKeyValue);


            cimprop.setValue(cimval);
            if(logger.isLoggable(Level.FINE))
              logger.fine(Thread.currentThread().getName()+" cimprop set to cimValue "+cimval.getValue());

          }
          catch(CIMException e){
            e.printStackTrace();
            //System.out.println(e.getMessage());
View Full Code Here

Examples of org.pegasus.jmpi.CIMValue

        //System.out.println("parameter name = "+parameterName);
        Object paramValue=cimArgNameValuePairs.get(parameterName);

        if(paramValue!=null)
        {
          CIMValue cv=getCIMObjectOfGivenType(type, isArray, paramValue);
          //System.out.println("parameter value = "+paramValue+ " "+cv.toString());
          inParams.add(new CIMProperty(parameterName,cv));
        }
        else
        {
View Full Code Here

Examples of org.sblim.wbem.cim.CIMValue

    }
  }
 
  public void executePolicy(String policyName) throws CIMException
  {
    CIMValue result = null;
    CIMObjectPath cimObjectPath = new CIMObjectPath("CIM_SPLPolicyRule");
      CIMNameSpace clientNameSpace = _cimClient.getNameSpace();
      cimObjectPath.setNameSpace(clientNameSpace.getNameSpace());
      cimObjectPath.setHost(clientNameSpace.getHost());
      System.out.println("cimObjectPath : "+cimObjectPath.toString());
     
      CIMDataType strType = new CIMDataType(CIMDataType.STRING);
    CIMValue policyNameCimValue = new CIMValue (policyName,strType);
     
      cimObjectPath.addKey("PolicyRuleName", policyNameCimValue);
      if(_cimClient.getInstance(cimObjectPath, true, true, true, null) != null)
      {
        System.out.println("before invoke method, cimObjectPath : "+cimObjectPath.toString());
View Full Code Here

Examples of org.sblim.wbem.cim.CIMValue

      CIMNameSpace clientNameSpace = _cimClient.getNameSpace();
      cimObjectPath.setNameSpace(clientNameSpace.getNameSpace());
      cimObjectPath.setHost(clientNameSpace.getHost());
     
      CIMDataType strType = new CIMDataType(CIMDataType.STRING);
    CIMValue policyNameCimValue = new CIMValue (policyName,strType);
   
      cimObjectPath.addKey("PolicyRuleName", policyNameCimValue);
        
    _cimClient.deleteInstance(cimObjectPath);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.