/**
   * Adds the computer system to DB and determines what path to go based on the
   * CIM_ComputerSystem.dedicated
   *
   * @param cc
   * @param cim_class
   */
  @SuppressWarnings("unchecked")
  public void getComputerSystem(WBEMClient cc, String cim_class, String namespace) {
    if (cc != null) {
      try {

        this.cim_DT = new CIM_DataTypes();
        CIMObjectPath cop = new CIMObjectPath(cim_class, namespace);
        PerformanceMetrics pm = new PerformanceMetrics();
        long statInstanceMean = pm.enumerationTime(cc, cop);
        CloseableIterator computerSystemEnum = cc.enumerateInstances(cop, true, false, false, null);
        while (computerSystemEnum.hasNext()) {
          this.cs = new CIM_ComputerSystem();
          Calendar statCalBefore = Calendar.getInstance();
          long msBeforeforTotalDisc = statCalBefore.getTimeInMillis();
          this.cs.setInstanceTimeMean(Long.valueOf(statInstanceMean));
          CIMInstance ci = (CIMInstance) computerSystemEnum.next();
          int instancePropertySize = ci.getPropertyCount();
          this.cs.setInstancePropertySize(instancePropertySize);
          CIMObjectPath instanceCOP = ci.getObjectPath();
          CIMProperty cp = instanceCOP.getKey("Name");
          this.enumerationNameKey = cp.getValue().toString();

          // this.logger.info("Name = " + this.enumerationNameKey);
          // this.logger.debug(this.CN + " computerSystemName " + this.enumerationNameKey);

          String enumerationNameKey = null;
          String enumerationCreationClassNameKey = null;
          String elementName = "Not Available";
          String operationalStatus = null;
          String statusDescriptions = null;
          String description = null;
          int enabledState = 0;

          enumerationNameKey = cp.getValue().toString();
          cp = instanceCOP.getKey("CreationClassName");
          enumerationCreationClassNameKey = cp.getValue().toString();
          // this.logger.info("CreationClassName = " + enumerationCreationClassNameKey);

          String caption = "";
          try {
            caption = this.cim_DT.getCIMInstancePropertyValueString(ci, "Caption");
          } catch (Exception e) {
            caption = "Not Available";
          }
          // this.logger.info("Caption = " + caption);

          String description1 = "";
          try {
            description1 = this.cim_DT.getCIMInstancePropertyValueString(ci, "Description");
          } catch (Exception e) {
            description1 = "Not Available";
          }
          // this.logger.info("Description = " + description1);
          try {
            elementName = this.cim_DT.getCIMInstancePropertyValueString(ci, "ElementName");
          } catch (Exception e) {
            elementName = "Not Available";
          }
          // this.logger.info("ElementName = " + elementName);

          int requestedState = 0;
          try {
            requestedState =
                this.cim_DT
                    .getCIMInstancePropertyUnsignedInt16Value(ci, "RequestedState")
                    .intValue();
          } catch (Exception localException1) {
          }
          int enabledDefault = 0;
          try {
            enabledDefault =
                this.cim_DT
                    .getCIMInstancePropertyUnsignedInt16Value(ci, "EnabledDefault")
                    .intValue();
          } catch (Exception localException2) {
          }
          String nameFormat = null;
          try {
            nameFormat = this.cim_DT.getCIMInstancePropertyValueString(ci, "NameFormat");
          } catch (Exception e) {
            // this.logger.error(this.CN, e);
          }

          try {
            UnsignedInteger16[] operationalStatusArray =
                this.cim_DT.getUint16ArrayPropertyValue(ci, "OperationalStatus");
            int operationalStatusSize = 0;
            if (operationalStatusArray != null) {
              operationalStatusSize = operationalStatusArray.length;
            }
            // this.logger.debug("operationalStatusSize = " + operationalStatusSize);
            Vector operationalStatusString = new Vector();
            for (int x = 0; x < operationalStatusSize; ++x) {
              UnsignedInteger16 opstsint = operationalStatusArray[x];

              int operationalStatusInt = Integer.parseInt(opstsint.toString());

              String operationalStatusValue = this.cim_Q.operationalStatus(operationalStatusInt);

              operationalStatusString.add(operationalStatusValue);
            }
            String operationalStatusFinal =
                this.cim_Q.buildStringFromVector(operationalStatusString, ",");
            this.cs.setOperationalStatus(operationalStatusFinal);
          } catch (Exception e) {
            // this.logger.error("OperationalStatus", e);
            this.cs.setOperationalStatus("Unknown");
          }

          String statusDescriptionsFinal = null;
          try {
            String[] statusDescriptionsArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "StatusDescriptions");
            int statusDescriptionsSize = 0;
            if (statusDescriptionsArray != null) {
              statusDescriptionsSize = statusDescriptionsArray.length;
            }
            // this.logger.debug("statusDescriptionsSize = " + statusDescriptionsSize);
            Vector statusDescriptionsString = new Vector();
            for (int y = 0; y < statusDescriptionsSize; ++y) {
              String statusDescriptionsValue = statusDescriptionsArray[y].toString();

              statusDescriptionsString.add(statusDescriptionsValue);
            }
            statusDescriptionsFinal =
                this.cim_Q.buildStringFromVector(statusDescriptionsString, ",");
          } catch (Exception e) {
            // this.logger.error("StatusDescriptions", e);
          }

          String otherIdentifyingInfoFinal = null;
          try {
            String[] otherIdentifyingInfoArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "OtherIdentifyingInfo");
            int otherIdentifyingInfoSize = 0;
            if (otherIdentifyingInfoArray != null) {
              otherIdentifyingInfoSize = otherIdentifyingInfoArray.length;
            }
            // this.logger.debug("otherIdentifyingInfoSize = " + otherIdentifyingInfoSize);
            Vector otherIdentifyingInfoString = new Vector();
            for (int y = 0; y < otherIdentifyingInfoSize; ++y) {
              String otherIdentifyingInfoValue = otherIdentifyingInfoArray[y].toString();

              otherIdentifyingInfoString.add(otherIdentifyingInfoValue);
            }
            otherIdentifyingInfoFinal =
                this.cim_Q.buildStringFromVector(otherIdentifyingInfoString, ",");
            // this.logger.info("OtherIdentifyingInfo = " + otherIdentifyingInfoFinal);
          } catch (Exception e) {
            // this.logger.error("OtherIdentifyingInfo", e);
          }

          String identifyingDescriptionsFinal = null;
          try {
            String[] identifyingDescriptionsArray =
                this.cim_DT.getStringArrayPropertyValue(ci, "IdentifyingDescriptions");
            int identifyingDescriptionsSize = 0;
            if (identifyingDescriptionsArray != null) {
              identifyingDescriptionsSize = identifyingDescriptionsArray.length;
            }
            // this.logger.debug("identifyingDescriptinsSize = " + identifyingDescriptionsSize);
            Vector identifyingDescriptionsString = new Vector();
            for (int y = 0; y < identifyingDescriptionsSize; ++y) {
              String identfyingDescriptionsValue = identifyingDescriptionsArray[y].toString();

              identifyingDescriptionsString.add(identfyingDescriptionsValue);
            }
            identifyingDescriptionsFinal =
                this.cim_Q.buildStringFromVector(identifyingDescriptionsString, ",");
            // this.logger.info("IdentifyingDescriptions = " + identifyingDescriptionsFinal);
          } catch (Exception e) {
            // this.logger.error("IdentifyingDescriptions", e);
          }
          try {
            enabledState =
                Integer.parseInt(
                    this.cim_DT
                        .getCIMInstancePropertyUnsignedInt16Value(ci, "enabledState")
                        .toString());
          } catch (Exception e) {
            // this.logger.warn("enabledState does not exist for CIMOM = " + enumerationNameKey);
          }

          //		        this.logger.debug("description = " + description +
          //		          " operationalStatus = " + operationalStatus + " statusDescriptions = " +
          // statusDescriptions +
          //		          " enabledState = " + enabledState);

          this.cs.setName(enumerationNameKey);
          this.cs.setCreationClassName(enumerationCreationClassNameKey);
          this.cs.setCaption(caption);
          this.cs.setDescription(description1);
          this.cs.setRequestedState(requestedState);
          this.cs.setElementName(elementName);
          this.cs.setStatusDescriptions(statusDescriptionsFinal);
          this.cs.setEnabledDefault(enabledDefault);
          this.cs.setNameFormat(nameFormat);
          this.cs.setEnabledState(enabledState);

          Calendar cal = Calendar.getInstance();
          Date now = new Date();

          this.cs.setTimeOfCreation(cal);
          this.cs.setTimeOfCreationString(
              DateFormat.getDateTimeInstance(3, 3).format(now).toString());
          //		        Integer cimom_Id_Integer = new Integer(cimom_Id);
          //		        this.cs.setCimomID(cimom_Id_Integer);

          int dedicatedSize = 0;
          UnsignedInteger16 dedicatedFill = new UnsignedInteger16("555");
          UnsignedInteger16[] dedicated = {dedicatedFill};
          try {
            dedicated = this.cim_DT.getUint16ArrayPropertyValue(ci, "Dedicated");

            if (dedicated != null) dedicatedSize = dedicated.length;
          } catch (Exception e) {
            // this.logger.error(this.CN, e);
          }
          // this.logger.info("dedicatedSize = " + dedicatedSize);

          int intDedicated1 = 0;

          int intDedicated2 = 0;

          int intDedicated3 = 0;

          int intDedicated4 = 0;

          int intDedicated5 = 0;
          this.cs.setDedicated("555");
          String dedicated1;
          if (dedicatedSize == 1) {
            dedicated1 = dedicated[0].toString();
            intDedicated1 = Integer.parseInt(dedicated1);
            this.cs.setDedicated(dedicated1);
            // this.logger.info("DedicateFilter1 = " + intDedicated1);
          } else {
            String dedicated2;
            if (dedicatedSize == 2) {
              dedicated1 = dedicated[0].toString();
              intDedicated1 = Integer.parseInt(dedicated1);
              dedicated2 = dedicated[1].toString();
              intDedicated2 = Integer.parseInt(dedicated2);
              this.cs.setDedicated(dedicated1 + "," + dedicated2);
              // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = " +
              // intDedicated2);
            } else {
              String dedicated3;
              if (dedicatedSize == 3) {
                dedicated1 = dedicated[0].toString();
                intDedicated1 = Integer.parseInt(dedicated1);
                dedicated2 = dedicated[1].toString();
                intDedicated2 = Integer.parseInt(dedicated2);
                dedicated3 = dedicated[2].toString();
                intDedicated3 = Integer.parseInt(dedicated3);
                this.cs.setDedicated(dedicated1 + "," + dedicated2 + "," + dedicated3);
                // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = " +
                // intDedicated2 + " DedicatedFilter3 = " + intDedicated3);
              } else {
                String dedicated4;
                if (dedicatedSize == 4) {
                  dedicated1 = dedicated[0].toString();
                  intDedicated1 = Integer.parseInt(dedicated1);
                  dedicated2 = dedicated[1].toString();
                  intDedicated2 = Integer.parseInt(dedicated2);
                  dedicated3 = dedicated[2].toString();
                  intDedicated3 = Integer.parseInt(dedicated3);
                  dedicated4 = dedicated[3].toString();
                  intDedicated4 = Integer.parseInt(dedicated4);
                  this.cs.setDedicated(
                      dedicated1 + "," + dedicated2 + "," + dedicated3 + "," + dedicated4);
                  // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = "
                  // + intDedicated2 + " DedicateFilter3 = " + intDedicated3 + " DedicatedFilter4 =
                  // " + intDedicated4);
                } else if (dedicatedSize == 5) {
                  dedicated1 = dedicated[0].toString();
                  intDedicated1 = Integer.parseInt(dedicated1);
                  dedicated2 = dedicated[1].toString();
                  intDedicated2 = Integer.parseInt(dedicated2);
                  dedicated3 = dedicated[2].toString();
                  intDedicated3 = Integer.parseInt(dedicated3);
                  dedicated4 = dedicated[3].toString();
                  intDedicated4 = Integer.parseInt(dedicated4);
                  String dedicated5 = dedicated[4].toString();
                  intDedicated5 = Integer.parseInt(dedicated5);
                  this.cs.setDedicated(
                      dedicated1
                          + ","
                          + dedicated2
                          + ","
                          + dedicated3
                          + ","
                          + dedicated4
                          + ","
                          + dedicated5);
                  // this.logger.info("DedicateFilter1 = " + intDedicated1 + " DedicatedFilter2 = "
                  // + intDedicated2 + " DedicateFilter3 = " + intDedicated3 + " DedicatedFilter4 =
                  // " + intDedicated4 + " DedicatedFilter5 = " + intDedicated5);
                }
              }
            }
          }
          // this.logger.info("Dedicated = " + this.cs.getDedicated());
          // this.logger.info("------------------------------------------COMPUTER SYSTEM
          // END------------------------------------------");
          try {
            CloseableIterator cim_PhysicalPackageEnum =
                cc.associators(
                    instanceCOP,
                    "CIM_SystemPackaging",
                    "CIM_PhysicalPackage",
                    "Dependent",
                    "Antecedent",
                    false,
                    false,
                    null);
            this.fujitsuE6000Model = false;
            this.ibm511Model = false;
            this.netappManufacturer = false;
            while (cim_PhysicalPackageEnum.hasNext()) {
              // this.logger.debug(this.CN + " Enumerated PhysicalPackage and has more elements");
              CIMInstance cim_PhysicalPackageCI = (CIMInstance) cim_PhysicalPackageEnum.next();

              this.fujitsuE6000Model = false;
              this.ibm511Model = false;
              if (cim_PhysicalPackageEnum == null) continue;
              try {
                this.model =
                    this.cim_DT.getCIMInstancePropertyValueString(cim_PhysicalPackageCI, "Model");
                this.fujitsuE6000Model = this.model.startsWith("E6000");
                this.ibm511Model = this.model.startsWith("511");
                this.ibm921Model = this.model.startsWith("921");
                this.ibm931Model = this.model.startsWith("931");
              } catch (NullPointerException npe) {
                this.model = null;
              }
              try {
                this.manufacturer =
                    this.cim_DT.getCIMInstancePropertyValueString(
                        cim_PhysicalPackageCI, "Manufacturer");
                this.netappManufacturer = this.manufacturer.startsWith("Network Appliance");
              } catch (NullPointerException npe) {
                this.manufacturer = null;
              }
            }
          } catch (Exception e) {
            // this.logger.warn("No Physical Package for " + this.cs.getCreationClassName());
          }

          if ((!(this.cs.getDedicated().equals("555")))
              && (!(this.cs.getCreationClassName().equals("LSISSI_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("HPEVA_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("HITACHI_StorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("Brocade_PhysicalComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("CISCO_LogicalComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("SunStorEdge_DSPStorageProcessorSystem")))
              && (!(this.cs.getCreationClassName().equals("OpenWBEM_UnitaryComputerSystem")))
              && (!(this.cs.getCreationClassName().equals("IBMTSSVC_IOGroup")))
              && (!(this.cs.getCreationClassName().equals("HPMSA_ArrayController")))
              && (((this.cs.getDedicated().equals("3,15"))
                  || (this.cs.getDedicated().equals("15,3"))
                  || (this.cs.getDedicated().equals("3"))
                  || (this.cs.getDedicated().equals("0"))
                  || (this.cs.getDedicated().equals("3,15,16,25"))
                  || (this.cs.getDedicated().equals("3,15,16,21,25"))
                  || (this.cs.getDedicated().equals("3,15,25"))
                  || (this.cs.getDedicated().equals("15"))
                  || (this.cs.getDedicated().equals("5"))
                  || (this.cs.getDedicated().equals("3,22"))
                  || (this.cs.getDedicated().equals("3,15,21"))
                  || (this.cs.getDedicated().equals("15,21"))))) {
            // session.save(this.cs);

            /* String computerSystemID = session.getIdentifier(this.cs).toString();
            Integer computerSystemIDp = Integer.valueOf(computerSystemID);
            setComputerSystemIDFinal(computerSystemIDp);
            */
            // this.logger.debug("computerSystemIDp = " + computerSystemIDp);

            ///// && (computerSystemIDp != null)
            if ((enumerationNameKey != null) && (dedicated != null)) {
              // this.logger.info("Started Discovery For " + this.cs.getCreationClassName());

              if (((intDedicated1 == 3) && (intDedicated2 == 15) && (intDedicated3 != 25))
                  || ((intDedicated1 == 15) && (intDedicated2 == 3) && (intDedicated3 != 25))) {
                if (this.cs.getCreationClassName().equals("Symm_StorageSystem")) {
                  this.mapSymmDD = new MapSymmetrixDiskDrives(cc, instanceCOP, this.cs);
                } else {
                  this.mapDD = new MapDiskDrives(cc, instanceCOP, this.cs);
                }
                this.mapIP = new MapInitiatorPorts(cc, instanceCOP, this.cs);
                if ((this.fujitsuE6000Model)
                    || (this.ibm511Model)
                    || (this.ibm921Model)
                    || (this.ibm931Model)
                    || (this.netappManufacturer)) {
                  this.mapFujitsuFCP = new MapFCPortsFujitsuE6000(cc, instanceCOP, cs);
                } else {
                  this.mapFCP = new MMapFCPorts(cc, instanceCOP, this.cs, "");
                }
                this.mapV = new MMapVolumes(cc, instanceCOP, this.cs, "");
                this.mapPP = new MapPhysicalPackages(cc, instanceCOP, this.cs);
                this.mapSI = new MapSoftwareIdentity(cc, instanceCOP, this.cs);
                this.mapAS = new MapArrayStats(cc, instanceCOP, this.cs);
              } else if ((intDedicated1 == 15) && (intDedicated2 == 21)) {
                this.mapFCP = new MMapFCPorts(cc, instanceCOP, this.cs, this.ftag);
                this.mapV = new MMapVolumes(cc, instanceCOP, this.cs, this.ftag);
              } else if (intDedicated1 == 0) {
                if (this.cs.getCreationClassName().equals("Linux_ComputerSystem")) {
                  // this.logger.debug("Host For Linux");
                  //		                this.mapBase = new MapBase(session, cc, instanceCOP,
                  // computerSystemIDp);
                  //		                this.mapFSVol = new MapFSVol(session, cc, instanceCOP,
                  // computerSystemIDp);
                  //		                this.mapNetwork = new MapNetwork(session, cc, instanceCOP,
                  // computerSystemIDp);
                } else {
                  // this.logger.debug("Host For FCHBA");
                  // session,  , computerSystemIDp
                  this.mapHBA = new MapHBA(cc, instanceCOP, this.cs);
                }
              } else if ((intDedicated1 == 5)
                  && (!(this.cs.getCreationClassName().equals("CISCO_LogicalComputerSystem")))) {
                if ((this.cs.getElementName() != null)
                    || (!(this.cs.getElementName().equals("")))) {
                  // this.logger.debug("Switch");
                  this.mapSwitchPP = new MapSwitchPhysicalPackages(cc, instanceCOP, cs);
                  this.mapSwitchSI = new MapSwitchSoftwareIdentity(cc, instanceCOP, cs);
                  this.mapSwitchFCP = new MapSwitchFCPorts(cc, instanceCOP, cs);
                  this.mapSwitchF = new MapSwitchFabric(cc, instanceCOP, cs);
                }
              } else if ((intDedicated1 == 3) && (intDedicated2 == 22)) {
                // this.logger.debug("Tape");
                //			              this.mapPhysicalPackagesTape = new
                // MapPhysicalPackagesTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapSoftwareIdentityTape = new
                // MapSoftwareIdentityTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapMediaAccessDevicesTape = new
                // MapMediaAccessDevicesTape(session, cc, instanceCOP, computerSystemIDp);
                //			              this.mapChangerDeviceTape = new MapChangerDeviceTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapAccessPointsTape = new MapAccessPointsTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapFCPortsTape = new MapFCPortsTape(session, cc,
                // instanceCOP, computerSystemIDp);
                //			              this.mapLimitedAccessPortTape = new MapLimitedAccessPort(session,
                // cc, instanceCOP, computerSystemIDp);
              } else if ((intDedicated1 == 3) && (intDedicated2 == 15) && (intDedicated3 == 25)) {
                //			              new MapNASDiskDrives(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASInitiatorPorts(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASFCPorts(session, cc, instanceCOP, computerSystemIDp);
                //			              new MapNASVolumes(session, cc, instanceCOP, computerSystemIDp);
                //			              new MapNASPhysicalPackages(session, cc, instanceCOP,
                // computerSystemIDp);
                //			              new MapNASSoftwareIdentity(session, cc, instanceCOP,
                // computerSystemIDp);
              } else if ((intDedicated1 == 15)
                  && (this.cs.getCreationClassName().equals("VMWARE_ESXComputerSystem"))) {
                // this.logger.debug("VMWare");
                // this.mapVM = new MapVirtualMachines(session, cc, instanceCOP, computerSystemIDp);
                // this.mapESXStorageExtents = new MapESXStorageExtents(session, cc, instanceCOP,
                // computerSystemIDp);
                // this.mapESXStoragePools = new MapESXStoragePools(session, cc, instanceCOP,
                // computerSystemIDp);
                // this.mapESXStorageVolumes = new MapESXStorageVolumes(session, cc, instanceCOP,
                // computerSystemIDp);
              } else {
                // this.logger.info("NOTHING");
              }
              // this.logger.info("Finished Discovery For " + this.cs.getCreationClassName());
            }
          }

          try {
            /* Calendar statCalAfter = Calendar.getInstance();
            long msAfterforTotalDisc = statCalAfter.getTimeInMillis();
            long totalDiscoveryTimeFinal = (msAfterforTotalDisc - msBeforeforTotalDisc) / 1000L;
            //this.logger.info("MSAFTERTIME = " + msAfterforTotalDisc + "MSBEFORE = " + msBeforeforTotalDisc);
            //this.logger.info("Discovery Time = " + totalDiscoveryTimeFinal);
            //this.logger.info("COMUTERSYSTEMID = " + getComputerSystemIDFinal());
            CIM_ComputerSystem ccs1 = (CIM_ComputerSystem)session.get(CIM_ComputerSystem.class, getComputerSystemIDFinal());
            ccs1.setTotalDiscoveryTime(Long.valueOf(totalDiscoveryTimeFinal));
            //session.save(ccs1);
            setComputerSystemIDFinal(null);
            */

          } catch (Exception localException3) {
          }
        }

        // session.getTransaction().commit();
        // session.close();
        // session.disconnect();
        // session.flush();

        // close session.
        if (cc != null) cc.close();

        // Call the garbage collection to run
        // System.gc();

      } catch (WBEMException ce) {
        ce.printStackTrace();
        // logger.warn("Unable to login at this time");
      } catch (Exception e) {
        e.printStackTrace();
        e.getCause();
      } finally {
        // session.close();
      }
    } else {
      // logger.info("Unable to login at this time");
    }
  }
  /**
   * Called to update the job status when the volume expand job completes.
   *
   * @param jobContext The job context.
   */
  public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> associatorIterator = null;
    CloseableIterator<CIMInstance> instanceIterator = null;
    JobStatus jobStatus = getJobStatus();

    try {
      if (jobStatus == JobStatus.IN_PROGRESS) {
        return;
      }

      DbClient dbClient = jobContext.getDbClient();
      CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
      WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);

      // If terminal state update storage pool capacity and remove reservation for volume capacity
      // from pool's reserved capacity map.
      if (jobStatus == JobStatus.SUCCESS
          || jobStatus == JobStatus.FAILED
          || jobStatus == JobStatus.FATAL_ERROR) {
        SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);

        StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
        StringMap reservationMap = pool.getReservedCapacityMap();
        URI volumeId = getTaskCompleter().getId();
        // remove from reservation map
        reservationMap.remove(volumeId.toString());
        dbClient.persistObject(pool);
      }

      String opId = getTaskCompleter().getOpId();
      StringBuilder logMsgBuilder =
          new StringBuilder(
              String.format(
                  "Updating status of job %s to %s, task: %s",
                  this.getJobName(), jobStatus.name(), opId));

      if (jobStatus == JobStatus.SUCCESS) {
        VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
        Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
        // set requested capacity
        volume.setCapacity(taskCompleter.getSize());
        // set meta related properties
        volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
        volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
        volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
        volume.setIsComposite(taskCompleter.isComposite());
        volume.setCompositionType(taskCompleter.getMetaVolumeType());

        // set provisioned capacity
        associatorIterator =
            client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
        if (associatorIterator.hasNext()) {
          CIMObjectPath volumePath = associatorIterator.next();
          CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
          if (volumeInstance != null) {
            CIMProperty consumableBlocks =
                volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate provisionedCapacity = consumableBlocks * block size
            Long provisionedCapacity =
                Long.valueOf(consumableBlocks.getValue().toString())
                    * Long.valueOf(blockSize.getValue().toString());
            volume.setProvisionedCapacity(provisionedCapacity);
          }

          // set allocated capacity
          instanceIterator =
              client.referenceInstances(
                  volumePath,
                  SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL,
                  null,
                  false,
                  SmisConstants.PS_SPACE_CONSUMED);
          if (instanceIterator.hasNext()) {
            CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
            CIMProperty spaceConsumed =
                allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
            if (null != spaceConsumed) {
              volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
            }
          }
        }
        logMsgBuilder.append(
            String.format(
                "%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s",
                volume.getCapacity(),
                volume.getProvisionedCapacity(),
                volume.getAllocatedCapacity()));
        if (volume.getIsComposite()) {
          logMsgBuilder.append(
              String.format(
                  "%n   Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s",
                  volume.getIsComposite(),
                  volume.getTotalMetaMemberCapacity(),
                  volume.getMetaMemberCount(),
                  volume.getMetaMemberSize()));
        }

        _log.info(logMsgBuilder.toString());

        // Reset list of meta member volumes in the volume
        if (volume.getMetaVolumeMembers() != null) {
          volume.getMetaVolumeMembers().clear();
        }

        StorageSystem storageSystem =
            dbClient.queryObject(StorageSystem.class, volume.getStorageController());
        // set the RP tag on the volume if the volume is RP protected
        if (volume.checkForRp()
            && storageSystem.getSystemType() != null
            && storageSystem
                .getSystemType()
                .equalsIgnoreCase(DiscoveredDataObject.Type.vmax.toString())) {
          SmisCommandHelper helper = jobContext.getSmisCommandHelper();
          List<CIMObjectPath> volumePathList = new ArrayList<CIMObjectPath>();
          volumePathList.add(helper.getVolumeMember(storageSystem, volume));
          helper.setRecoverPointTag(storageSystem, volumePathList, true);
        }

        dbClient.persistObject(volume);
        // Reset list of meta members native ids in WF data (when meta is created meta members are
        // removed from array)
        WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
      }
    } catch (Exception e) {
      _log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
      setPostProcessingErrorStatus(
          "Encountered an internal error during volume expand job status processing : "
              + e.getMessage());
    } finally {
      _metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
      if (associatorIterator != null) {
        associatorIterator.close();
      }
      if (instanceIterator != null) {
        instanceIterator.close();
      }
      super.updateStatus(jobContext);
    }
  }
  /**
   * Method to print arguments for debug purpose
   *
   * @param commandObject
   */
  public void printArgs(Command commandObject) {
    try {
      StringBuilder logMessage = new StringBuilder();
      logMessage.append(NEWLINE).append("{");
      for (Object obj : commandObject.retreiveArguments()) {
        if (null == obj) {
          logMessage.append("NULL").append(SEMICOLON);
        } else {
          if (obj instanceof CIMArgument<?>[]) {
            logMessage.append("Input CIMArgument Array : {");
            CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) obj;
            for (CIMArgument<?> outArg : outputArguments) {
              if (null != outArg) {
                logMessage.append(TAB);
                logMessage
                    .append("Name:")
                    .append(null == outArg.getName() ? "unknown" : outArg.getName())
                    .append(SEMICOLON);
                logMessage
                    .append("DataType:")
                    .append(null == outArg.getDataType() ? "unknown" : outArg.getDataType())
                    .append(SEMICOLON);
                logMessage
                    .append("Value :")
                    .append(null == outArg.getValue() ? "unknown" : outArg.getValue())
                    .append(SEMICOLON);
              } else {
                logMessage.append("NULL").append(SEMICOLON);
              }
            }
            logMessage.append("}").append(SEMICOLON).append(NEWLINE);
          } else if (obj instanceof CIMProperty<?>[]) {
            logMessage.append(NEWLINE).append("Input CIMProperty Array : {");

            CIMProperty<?>[] args = (CIMProperty<?>[]) obj;
            for (CIMProperty<?> p : args) {
              if (null != p) {
                logMessage
                    .append("Name:")
                    .append(null == p.getName() ? "unknown" : p.getName())
                    .append(SEMICOLON);
                logMessage
                    .append("DataType:")
                    .append(null == p.getDataType() ? "unknown" : p.getDataType())
                    .append(SEMICOLON);
                logMessage
                    .append("Value :")
                    .append(null == p.getValue() ? "unknown" : p.getValue())
                    .append(SEMICOLON);
              }
            }
            logMessage.append("}").append(SEMICOLON).append(NEWLINE);
          } else if (obj instanceof String[]) {
            logMessage.append(Arrays.toString((String[]) obj)).append(SEMICOLON);
          } else {
            logMessage.append(obj.toString()).append(SEMICOLON);
          }
        }
      }
      logMessage.append("}");
      _LOGGER.debug(logMessage.toString());

    } catch (Exception e) {
      _LOGGER.debug("Logging operations failed", e);
    }
  }