📄 commoninstanceprovider.java
字号:
throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } } public Vector enumerateInstances (OperationContext oc, CIMObjectPath cop, CIMClass cimClass, boolean deepInheritance, boolean localOnly, boolean includeQualifiers, boolean includeClassOrigin, String propertyList[]) throws CIMException { if (DEBUG) { System.err.println (providerName + "::enumerateInstances: oc = " + oc); System.err.println (providerName + "::enumerateInstances: cop = " + cop); System.err.println (providerName + "::enumerateInstances: cimClass = " + cimClass); System.err.println (providerName + "::enumerateInstances: deepInheritance = " + deepInheritance); System.err.println (providerName + "::enumerateInstances: localOnly = " + localOnly); System.err.println (providerName + "::enumerateInstances: includeQualifiers = " + includeQualifiers); System.err.println (providerName + "::enumerateInstances: includeClassOrigin = " + includeClassOrigin); System.err.println (providerName + "::enumerateInstances: propertyList = " + propertyList); } // Esure that the namespace is valid if (!cop.getNameSpace ().equalsIgnoreCase (namespace)) { throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE); } // Ensure that the class exists in the specified namespace if (cop.getObjectName ().equalsIgnoreCase (instanceClassname)) { return instances; } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } } public Vector execQuery (OperationContext oc, CIMObjectPath cop, String queryStatement, String queryLanguage, CIMClass cimClass) throws CIMException { if (DEBUG) { System.err.println (providerName + "::execQuery: oc = " + oc); System.err.println (providerName + "::execQuery: cop = " + cop); System.err.println (providerName + "::execQuery: queryStatement = " + queryStatement); System.err.println (providerName + "::execQuery: queryLanguage = " + queryLanguage); System.err.println (providerName + "::execQuery: cimClass = " + cimClass); } // Esure that the namespace is valid if (!cop.getNameSpace ().equalsIgnoreCase (namespace)) { throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE); } // Ensure that the class exists in the specified namespace if (cop.getObjectName ().equalsIgnoreCase (instanceClassname)) { if (!queryLanguage.equals ("WQL")) { throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED); } SelectExp q = new SelectExp (queryStatement); SelectList attrs = q.getSelectList (); NonJoinExp from = (NonJoinExp)q.getFromClause (); QueryExp where = q.getWhereClause (); Vector instances = enumerateInstances (oc, cop, cimClass, false, // deepInheritance, true, // localOnly, true, // includeQualifiers, true, // includeClassOrigin, null); Vector ret = new Vector (); // filter the instances for (int i = 0; i < instances.size (); i++) { if ( where == null || where.apply ((CIMInstance)instances.elementAt (i)) ) { ret.addElement (attrs.apply ((CIMInstance)instances.elementAt (i))); } } return ret; } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } } public CIMValue invokeMethod (OperationContext oc, CIMObjectPath cop, String methodName, Vector in, Vector out) throws CIMException { if (DEBUG) { System.err.println (providerName + "::invokeMethod: oc = " + oc); System.err.println (providerName + "::invokeMethod: cop = " + cop); System.err.println (providerName + "::invokeMethod: methodName = " + methodName); System.err.print (providerName + "::invokeMethod: in = "); if (in != null) { System.err.print ("{"); for (int i = 0; i < in.size (); i++) { System.err.print (in.elementAt (i)); if (i < in.size () - 1) { System.err.print (","); } } System.err.println ("}"); } else { System.err.println ("null"); } System.err.print (providerName + "::invokeMethod: out = "); if (out != null) { System.err.print ("{"); for (int i = 0; i < out.size (); i++) { System.err.print (out.elementAt (i)); if (i < out.size () - 1) { System.err.print (","); } } System.err.println ("}"); } else { System.err.println ("null"); } } // Esure that the namespace is valid if (!cop.getNameSpace ().equalsIgnoreCase (namespace)) { throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE); } // Ensure that the class exists in the specified namespace if (!cop.getObjectName ().equalsIgnoreCase (instanceClassname)) { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } if (methodName.equalsIgnoreCase ("SendTestIndicationNormal")) { if (in == null) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } else if (in.size () != 1) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } CIMProperty cp = (CIMProperty)in.elementAt (0); if (!cp.getName ().equalsIgnoreCase ("indicationSendCount")) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } else if (cp.getType ().getType () != CIMDataType.UINT64) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } CIMValue cvIndicationSendCount = cp.getValue (); UnsignedInt64 uiIndicationSendCount = (UnsignedInt64)cvIndicationSendCount.getValue (); if (DEBUG) { System.err.println ("JMPIExpIndicationProvider::invokeMethod: uiIndicationSendCount = " + uiIndicationSendCount); } CIMClass ccIndication; CIMInstance ciIndication; CIMObjectPath copIndication; ccIndication = ch.getClass (cop, true, true, true, null); ciIndication = ccIndication.newInstance (); ciIndication.setProperty ("InstanceId", new CIMValue (uiIndicationSendCount)); ciIndication.setProperty ("PropertyString", new CIMValue ("Hello")); copIndication = createInstance (oc, cop, ciIndication); if (DEBUG) { System.err.println ("JMPIExpIndicationProvider::invokeMethod: deliverEvent: copIndication = " + copIndication); System.err.println ("JMPIExpIndicationProvider::invokeMethod: deliverEvent: ciIndication = " + ciIndication); } ch.deliverEvent (copIndication.getNameSpace (), ciIndication); return new CIMValue (new UnsignedInt32 ("0")); } else if (methodName.equalsIgnoreCase ("enableModifications")) { if (in == null) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } else if (in.size () != 1) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } else { String name = null; CIMValue value = null; CIMDataType type = null; Object o0 = in.elementAt (0); if (DEBUG) { System.err.println (providerName + "::invokeMethod: o0 class = " + o0.getClass ()); } if (o0 instanceof CIMArgument) { CIMArgument ca = (CIMArgument)in.elementAt (0); name = ca.getName (); value = ca.getValue (); type = ca.getType (); } else if (o0 instanceof CIMProperty) { CIMProperty cp = (CIMProperty)in.elementAt (0); name = cp.getName (); value = cp.getValue (); type = cp.getType (); } if (!name.equalsIgnoreCase ("fState")) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } else if (type.getType () != CIMDataType.BOOLEAN) { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } Boolean fNewState = (Boolean)value.getValue (); if (DEBUG) { System.err.println (providerName + "::invokeMethod: Setting fEnableModifications to " + fNewState); } fEnableModifications = fNewState.booleanValue (); return new CIMValue (new Boolean (true)); } } else if (methodName.equalsIgnoreCase ("resetProvider")) { if ( in == null || in.size () == 0 ) { if (DEBUG) { System.err.println (providerName + "::invokeMethod: resetting the provider's state!"); } paths = new SortableVector (new CIMObjectPathComparer ()); instances = new SortableVector (new CIMInstanceComparer ()); fEnableModifications = false; initialize (ch); return new CIMValue (new Boolean (true)); } else { throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER); } } else { throw new CIMException (CIMException.CIM_ERR_METHOD_NOT_AVAILABLE); } } private boolean validatePropertyTypePath (CIMObjectPath cop) { Vector keys = cop.getKeys (); if (keys.size () != INDICATION_KEYS.length) { if (DEBUG) { System.err.println (providerName + "::validatePropertyTypePath: Bad1: " + keys.size () + " != " + INDICATION_KEYS.length); } return false; } for (int i = 0, is = INDICATION_KEYS.length; i < is; i++) { boolean fFound = false; for (int j = 0, js = keys.size (); j < js; j++) { CIMProperty cp = (CIMProperty)keys.elementAt (j); if (INDICATION_KEYS[i].equalsIgnoreCase (cp.getName ())) { fFound = true; } } if (!fFound) { if (DEBUG) { System.err.println (providerName + "::validatePropertyTypePath: Bad2: " + INDICATION_KEYS[i] + " not in " + keys); } return false; } } return true; } private CIMObjectPath validatePropertyTypeInstance (CIMInstance cimInstance, boolean fStrict) { if (cimInstance.getPropertyCount () != INDICATION_PROPS.length) { if (DEBUG) { System.err.println (providerName + "::validatePropertyTypeInstance: Bad1: " + cimInstance.getPropertyCount () + " != " + INDICATION_PROPS.length); } if (fStrict) { return null; } } for (int i = 0, is = INDICATION_PROPS.length; i < is; i++) { CIMProperty cp = cimInstance.getProperty (INDICATION_PROPS[i]); if (cp == null) { if (DEBUG) { System.err.println (providerName + "::validatePropertyTypeInstance: Bad2: " + INDICATION_PROPS[i]); } if (fStrict) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -