📄 jmpiexpassociationprovider.java
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Mark Hamzy, hamzy@us.ibm.com//// Modified By: Mark Hamzy, hamzy@us.ibm.com////%/////////////////////////////////////////////////////////////////////////////package Associations;import java.util.Iterator;import java.util.Vector;import org.pegasus.jmpi.AssociatorProvider2;import org.pegasus.jmpi.CIMClass;import org.pegasus.jmpi.CIMDataType;import org.pegasus.jmpi.CIMException;import org.pegasus.jmpi.CIMInstance;import org.pegasus.jmpi.CIMObjectPath;import org.pegasus.jmpi.CIMOMHandle;import org.pegasus.jmpi.CIMProperty;import org.pegasus.jmpi.CIMValue;import org.pegasus.jmpi.InstanceProvider2;import org.pegasus.jmpi.OperationContext;import org.pegasus.jmpi.UnsignedInt8;import org.pegasus.jmpi.UnsignedInt64;public class JMPIExpAssociationProvider implements InstanceProvider2, AssociatorProvider2{ private CIMOMHandle handle = null; private Vector paths = new Vector (); private Vector instances = new Vector (); private boolean fEnableModifications = true; private final boolean DEBUG = false; public void initialize (CIMOMHandle handle) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::initialize: handle = " + handle); } this.handle = handle; createDefaultInstances (); } public void cleanup () throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::cleanup"); } } public CIMObjectPath createInstance (OperationContext oc, CIMObjectPath cop, CIMInstance cimInstance) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::createInstance: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::createInstance: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::createInstance: cimInstance = " + cimInstance); } throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED); } public void deleteInstance (OperationContext oc, CIMObjectPath cop) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::deleteInstance: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::deleteInstance: cop = " + cop); } throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED); } public Vector enumerateInstanceNames (OperationContext oc, CIMObjectPath cop, CIMClass cimClass) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::enumerateInstanceNames: cimClass = " + cimClass); } // Enusre 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 (SAMPLE_TEACHER)) { return _enumerateInstanceNames (teacherInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT)) { return _enumerateInstanceNames (studentInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT)) { return _enumerateInstanceNames (TSassociationInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT)) { return _enumerateInstanceNames (ASassociationInstances); } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } } public Vector enumerateInstances (OperationContext oc, CIMObjectPath cop, CIMClass cimClass, boolean includeQualifiers, boolean includeClassOrigin, String propertyList[]) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::enumerateInstances: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::enumerateInstances: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::enumerateInstances: cimClass = " + cimClass); System.err.println ("JMPIExpAssociationProvider::enumerateInstances: includeQualifiers = " + includeQualifiers); System.err.println ("JMPIExpAssociationProvider::enumerateInstances: includeClassOrigin = " + includeClassOrigin); System.err.println ("JMPIExpAssociationProvider::enumerateInstances: propertyList = " + propertyList); } // Enusre that the namespace is valid if (!cop.getNameSpace ().equalsIgnoreCase (NAMESPACE)) { throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE); } Vector vectorReturn = null; // Ensure that the class exists in the specified namespace if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER)) { vectorReturn = _enumerateInstances (teacherInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT)) { vectorReturn = _enumerateInstances (studentInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT)) { vectorReturn = _enumerateInstances (TSassociationInstances); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT)) { vectorReturn = _enumerateInstances (ASassociationInstances); } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::enumerateInstances: returning " + vectorReturn.size () + " instances"); } return vectorReturn; } public CIMInstance getInstance (OperationContext oc, CIMObjectPath cop, CIMClass cimClass, boolean includeQualifiers, boolean includeClassOrigin, String propertyList[]) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::getInstance: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::getInstance: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::getInstance: cimClass = " + cimClass); System.err.println ("JMPIExpAssociationProvider::getInstance: includeQualifiers = " + includeQualifiers); System.err.println ("JMPIExpAssociationProvider::getInstance: includeClassOrigin = " + includeClassOrigin); System.err.println ("JMPIExpAssociationProvider::getInstance: propertyList = " + propertyList); } CIMObjectPath localObjectPath = (CIMObjectPath)cop.clone (); localObjectPath.setHost (""); localObjectPath.setNameSpace (NAMESPACE); // Ensure that the class exists in the specified namespace if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHER)) { return _getInstance (teacherInstances, localObjectPath); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_STUDENT)) { return _getInstance (studentInstances, localObjectPath); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT)) { return _getInstance (TSassociationInstances, localObjectPath); } else if (cop.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT)) { return _getInstance (ASassociationInstances, localObjectPath); } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS); } } public void setInstance (OperationContext oc, CIMObjectPath cop, CIMInstance cimInstance) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::modifyInstance: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::modifyInstance: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::modifyInstance: cimInstance = " + cimInstance); } throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED); } public Vector execQuery (OperationContext oc, CIMObjectPath cop, CIMClass cimClass, String queryStatement, String queryLanguage) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::execQuery: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::execQuery: cop = " + cop); System.err.println ("JMPIExpAssociationProvider::execQuery: cimClass = " + cimClass); System.err.println ("JMPIExpAssociationProvider::execQuery: queryStatement = " + queryStatement); System.err.println ("JMPIExpAssociationProvider::execQuery: queryLanguage = " + queryLanguage); } throw new CIMException (CIMException.CIM_ERR_NOT_SUPPORTED); } public Vector associatorNames (OperationContext oc, CIMObjectPath assocName, CIMObjectPath objectName, String resultClass, String role, String resultRole) throws CIMException { if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::associatorNames: oc = " + oc); System.err.println ("JMPIExpAssociationProvider::associatorNames: assocName = " + assocName); System.err.println ("JMPIExpAssociationProvider::associatorNames: objectName = " + objectName); System.err.println ("JMPIExpAssociationProvider::associatorNames: resultClass = " + resultClass); System.err.println ("JMPIExpAssociationProvider::associatorNames: role = " + role); System.err.println ("JMPIExpAssociationProvider::associatorNames: resultRole = " + resultRole); } // Enusre that the namespace is valid if (!assocName.getNameSpace ().equalsIgnoreCase (NAMESPACE)) { throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE); } CIMObjectPath localObjectPath = new CIMObjectPath (objectName.getObjectName (), objectName.getKeys ()); localObjectPath.setHost (""); localObjectPath.setNameSpace (NAMESPACE); Vector vectorReturn = null; if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_TEACHERSTUDENT)) { vectorReturn = _associatorNames (TSassociationInstances, localObjectPath, role, resultClass, resultRole); } else if (assocName.getObjectName ().equalsIgnoreCase (SAMPLE_ADVISORSTUDENT)) { vectorReturn = _associatorNames (ASassociationInstances, localObjectPath, role, resultClass, resultRole); } else { throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS, assocName.getObjectName () + " is not supported"); } if (DEBUG) { System.err.println ("JMPIExpAssociationProvider::associatorNames: returning " + vectorReturn.size () + " instances"); } return vectorReturn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -