const CIMPropertyList WQLSelectStatementRep::getSelectPropertyList(
    const CIMObjectPath& inClassName) const
{
    //
    //  Check for "*"
    //
    if (_allProperties)
    {
        //
        //  Return null CIMPropertyList for all properties
        //
        return CIMPropertyList ();
    }

    CIMName className = inClassName.getClassName();
    if (className.isNull())
    {
        //
        //  If the caller passed in an empty className, then the FROM class is
        //  to be used
        //
        className = _className;
    }

    //
    //  Check if inClassName is the FROM class
    //
    if (!(className == _className))
    {
        //
        //  Check for NULL Query Context
        //
        if (_ctx == NULL)
        {
            MessageLoaderParms parms
                ("WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
                "Trying to process a query with a NULL Query Context.");
            throw QueryRuntimeException(parms);
        }

        //
        //  Check if inClassName is a subclass of the FROM class
        //
        if (!_ctx->isSubClass(_className,className))
        {
            MessageLoaderParms parms
                ("WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS",
                "Class $0 does not match the FROM class or any of its "
                "subclasses.",
                className.getString());
            throw QueryRuntimeException(parms);
        }
    }

    //
    //  Return CIMPropertyList for properties referenced in the projection
    //  list (SELECT clause)
    //
    return CIMPropertyList (_selectPropertyNames);
}
Beispiel #2
0
/**
 ***************************************************************************
   _filterAssociationInstances is used to filter the set of possible return
   instances against the filters (resultClass and resultRole) provided with
   the associators and associatorNames operations.  It returns the ObjectPaths
   of the set of objects that pass the filter tests.

    @param assocInstance     - The target association class instance
    @param sourceObjectPath  - The source ObjectPath
    @param resultClass       - The result class. If there is no resultClass,
                               this is String::EMPTY.
    @param resultRole        - The result role. If there is no role, this is
                               String::EMPTY

    @return   the ObjectPaths of the set of association instances that pass
              the filter tests.
 ***************************************************************************
*/
Array<CIMObjectPath> ANHProvider::_filterAssociationInstances(
    CIMInstance& assocInstance,
    const CIMObjectPath& sourceObjectPath,
    CIMName resultClass,
    String resultRole)
{
    Array<CIMObjectPath> returnPaths;

    // get all Reference properties
    for (Uint32 i = 0, n = assocInstance.getPropertyCount(); i < n; i++)
    {
        CIMProperty p = assocInstance.getProperty(i);

        if (p.getType() == CIMTYPE_REFERENCE)
        {
            CIMValue v = p.getValue();
            CIMObjectPath path;
            v.get(path);

            if (!sourceObjectPath.identical(path))
            {
                if (resultClass.isNull() || resultClass == path.getClassName())
                {
                    if (resultRole == String::EMPTY ||
                        (p.getName() == CIMName(resultRole)))
                    {
                        returnPaths.append(path);
                    }
                }
            }
        }
    }
    return returnPaths;
}
Beispiel #3
0
CIMPropertyRep::CIMPropertyRep(
    const CIMName& name,
    const CIMValue& value,
    Uint32 arraySize,
    const CIMName& referenceClassName,
    const CIMName& classOrigin,
    Boolean propagated)
    :
    _name(name), _value(value), _arraySize(arraySize),
    _referenceClassName(referenceClassName), _classOrigin(classOrigin),
    _propagated(propagated), _refCounter(1), _ownerCount(0)
{
    // ensure name is not null
    if (name.isNull())
    {
        throw UninitializedObjectException();
    }

    // Set the CIM name tag.
    _nameTag = generateCIMNameTag(_name);

    if ((arraySize != 0) &&
        (!value.isArray() || value.getArraySize() != arraySize))
    {
        throw TypeMismatchException();
    }

    // A CIM Property may not be of reference array type
    if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))
    {
        throw TypeMismatchException();
    }

    // if referenceClassName exists, must be CIMType REFERENCE.
    if (!referenceClassName.isNull())
    {
        if (_value.getType() != CIMTYPE_REFERENCE)
        {
            throw TypeMismatchException();
        }
    }

    // Can a property be of reference type with a null referenceClassName?
    // The DMTF says yes if it is a property of an instance; no if it is a
    // property of a class.  We'll allow it here, but check in the CIMClass
    // addProperty() method.
}
void CIMParameterRep::setName(const CIMName& name)
{
    // ensure name is not null
    if(name.isNull())
    {
        throw UninitializedObjectException();
    }

    _name = name;
}
Beispiel #5
0
inline String DynamicRoutingTable::_getWildRoutingKey(
    const CIMName& className) const
{
    //ATTN: We don't support wild class names.
    PEGASUS_ASSERT(!className.isNull());
    String key(":");
    key.append(className.getString());

    return key;
}
CIMPropertyList WQLSelectStatementRep::getPropertyList(
        const CIMObjectPath& inClassName)
{
    if(_ctx == NULL){
        MessageLoaderParms parms(
            "WQL.WQLSelectStatementRep.QUERY_CONTEXT_IS_NULL",
            "Trying to process a query with a NULL Query Context.");
      throw QueryRuntimeException(parms);
    }

    if(_allProperties)
     return CIMPropertyList();

    CIMName className = inClassName.getClassName();
    if (className.isNull())
    {
     // If the caller passed in an empty className, then the
     // FROM class is to be used.
     className = _className;
    }

    // check if inClassName is the From class
    if(!(className == _className)){
        // check if inClassName is a subclass of the From class
        if(!_ctx->isSubClass(_className,className)){
            MessageLoaderParms parms(
                "WQL.WQLSelectStatementRep.CLASS_NOT_FROM_LIST_CLASS",
                "Class $0 does not match the FROM class or any of its"
                    " subclasses.",
                className.getString());
            throw QueryRuntimeException(parms);
        }
    }

    Array<CIMName> names =
            getWherePropertyList(inClassName).getPropertyNameArray();
    Array<CIMName> selectList =
            getSelectPropertyList(inClassName).getPropertyNameArray();

    // check for duplicates and remove them
    for(Uint32 i = 0; i < names.size(); i++){
        for(Uint32 j = 0; j < selectList.size(); j++){
            if(names[i] == selectList[j])
                selectList.remove(j);
            }
    }

    names.appendArray(selectList);
    CIMPropertyList list = CIMPropertyList();
    list.set(names);
    return list;
}
CIMParameterRep::CIMParameterRep(
    const CIMName& name,
    CIMType type,
    Boolean isArray,
    Uint32 arraySize,
    const CIMName& referenceClassName)
    : _name(name), _type(type),
    _isArray(isArray), _arraySize(arraySize),
    _referenceClassName(referenceClassName)
{
    // ensure name is not null
    if(name.isNull())
    {
        throw UninitializedObjectException();
    }

    if((_arraySize != 0) && !_isArray)
    {
        throw TypeMismatchException();
    }

    if (!referenceClassName.isNull())
    {
        if (_type != CIMTYPE_REFERENCE)
        {
            throw TypeMismatchException();
        }
    }
    else
    {
        if (_type == CIMTYPE_REFERENCE)
        {
            throw TypeMismatchException();
        }
    }
}
Beispiel #8
0
void CIMPropertyRep::setName(const CIMName& name)
{
    // ensure name is not null
    if (name.isNull())
    {
        throw UninitializedObjectException();
    }

    if (_ownerCount != 0 && _name != name)
    {
        MessageLoaderParms parms(
            "Common.CIMPropertyRep.CONTAINED_PROPERTY_NAMECHANGEDEXCEPTION",
            "Attempted to change the name of a property"
                " already in a container.");
        throw Exception(parms);
    }

    _name = name;

    // Set the CIM name tag.
    _nameTag = generateCIMNameTag(_name);
}
Beispiel #9
0
void CIMPropertyRep::resolve(
    DeclContext* declContext,
    const CIMNamespaceName& nameSpace,
    Boolean isInstancePart,
    const CIMConstProperty& inheritedProperty,
    Boolean propagateQualifiers)
{
    PEGASUS_ASSERT(!inheritedProperty.isUninitialized());

    // Check the type:

    if (!inheritedProperty.getValue().typeCompatible(_value))
    {
        if (!(
            (inheritedProperty.getValue().getType() == CIMTYPE_OBJECT) &&
            (_value.getType() == CIMTYPE_STRING) &&
            (_qualifiers.find(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)
                 != PEG_NOT_FOUND) &&
            (inheritedProperty.getValue().isArray() == _value.isArray())
            ) &&
            !(
            (inheritedProperty.getValue().getType() == CIMTYPE_INSTANCE) &&
            (_value.getType() == CIMTYPE_STRING) &&
            (_qualifiers.find(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)
                 != PEG_NOT_FOUND) &&
            (inheritedProperty.getValue().isArray() == _value.isArray())
            ))
        {
            throw TypeMismatchException();
        }
    }

    // Validate the qualifiers of the property (according to
    // superClass's property with the same name). This method
    // will throw an exception if the validation fails.

    CIMScope scope = CIMScope::PROPERTY;

    if (_value.getType() == CIMTYPE_REFERENCE)
        scope = CIMScope::REFERENCE;

    // Test the reference class name against the inherited property
    if (_value.getType() == CIMTYPE_REFERENCE ||
        _value.getType() == CIMTYPE_INSTANCE)
    {
        CIMName inheritedClassName;
        Array<CIMName> classNames;

        if (_value.getType() == CIMTYPE_INSTANCE)
        {
            Uint32 pos = inheritedProperty.findQualifier(
                             PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
            if (pos != PEG_NOT_FOUND)
            {
                String qualStr;
                inheritedProperty.getQualifier(pos).getValue().get(qualStr);
                inheritedClassName = qualStr;
            }

            if (_value.isArray())
            {
                Array<CIMInstance> embeddedInstances;
                _value.get(embeddedInstances);
                for (Uint32 i = 0, n = embeddedInstances.size(); i < n; ++i)
                {
                    classNames.append(embeddedInstances[i].getClassName());
                }
            }
            else
            {
                CIMInstance embeddedInst;
                _value.get(embeddedInst);
                classNames.append(embeddedInst.getClassName());
            }
        }
        else
        {
            CIMName referenceClass;
            if (_referenceClassName.isNull())
            {
                CIMObjectPath reference;
                _value.get(reference);
                referenceClass = reference.getClassName();
            }
            else
            {
                referenceClass = _referenceClassName;
            }

            inheritedClassName = inheritedProperty.getReferenceClassName();
            classNames.append(referenceClass);
        }

        // This algorithm is friendly to arrays of embedded instances. It
        // remembers the class names that are found to be subclasses of the
        // inherited class name retrieved from the inherited property. This
        // ensures that any branch in the inheritance hierarchy will only be
        // traversed once. This provides significant optimization given that
        // most elements of an array of embedded instances will probably be of
        // very closely related types.
        Array<CIMName> successTree;
        successTree.append(inheritedClassName);
        for (Uint32 i = 0, n = classNames.size(); i < n; ++i)
        {
            Array<CIMName> traversalHistory;
            CIMName currentName = classNames[i];
            Boolean found = false;
            while (!found && !currentName.isNull())
            {
                for (Uint32 j = 0, m = successTree.size(); j < m; ++j)
                {
                    if (currentName == successTree[j])
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    traversalHistory.append(currentName);
                    CIMClass currentClass = declContext->lookupClass(
                            nameSpace, currentName);
                    if (currentClass.isUninitialized())
                    {
                        throw PEGASUS_CIM_EXCEPTION(
                            CIM_ERR_INVALID_PARAMETER, currentName.getString());
                    }
                    currentName = currentClass.getSuperClassName();
                }
            }

            if (!found)
            {
                throw TypeMismatchException();
            }

            successTree.appendArray(traversalHistory);
        }
    }

    _qualifiers.resolve(
        declContext, nameSpace, scope, isInstancePart,
        inheritedProperty._rep->_qualifiers, propagateQualifiers);

    _classOrigin = inheritedProperty.getClassOrigin();
}
//
// Local version of the references operation. It validates the input
// parameters, setting the origin and target property values if not set
// already, and then performs an enumeration on the association class. It then
// filters the results of that enumeration to see if one of the reference
// properties matches the objectName parameter passed into the method. If so,
// then it is added to the array of association instances to be returned.
//
Array<CIMInstance> InteropProvider::localReferences(
    const OperationContext & context,
    const CIMObjectPath & objectName,
    const CIMName & assocClass,
    String & originProperty,
    String & targetProperty,
    const CIMPropertyList & propertyList,
    const CIMName & targetClass)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
        "InteropProvider::localReferences()");

    Array<CIMInstance> instances;
    CIMName originClass = objectName.getClassName();

    Array<CIMName> targetSubclasses;
    CIMNamespaceName lastTargetNamespace;
    CIMNamespaceName originNamespace(objectName.getNameSpace());

    // Check that the association traversal request is valid
    if (validAssocClassForObject(
        context, 
        assocClass, 
        objectName,
        originNamespace, 
        originProperty, 
        targetProperty))
    {
        // retrieve all of the association class instances
        Array<CIMInstance> localInstances = localEnumerateInstances(context,
            CIMObjectPath(hostName, originNamespace,
                assocClass));
        // Filter the association class instances based on the origin instance
        // and other input parameters.
        for(Uint32 i = 0, n = localInstances.size(); i < n; ++i)
        {
            CIMInstance & currentInstance = localInstances[i];
            CIMObjectPath originPath = getRequiredValue<CIMObjectPath>(
                currentInstance, originProperty);
            originPath.setNameSpace(objectName.getNameSpace());
            originPath.setHost(objectName.getHost());
            // Only include instances where the origin instance is present in
            // the association.
            if(originPath.identical(objectName))
            {
                if(!targetClass.isNull())
                {
                    // Have to check if the target reference is of the
                    // targetClass type. We first must determine all the
                    // possible subclasses of the targetClass in the target
                    // namespace.
                    CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>(
                        currentInstance, targetProperty);

                    CIMNamespaceName targetNamespace(
                        targetPath.getNameSpace());
                    if(targetNamespace.isNull())
                    {
                        targetNamespace = originNamespace;
                        targetPath.setNameSpace(targetNamespace);
                    }
                    if(targetNamespace != lastTargetNamespace)
                    {
                        try
                        {
                            targetSubclasses = repository->enumerateClassNames(
                                targetNamespace, targetClass, true);
                        }
                        catch(...)
                        {
                            // If an exception was thrown during enumeration,
                            // then the base class didn't exist in the
                            // namespace, so the target instance retrieved
                            // must not match the targetClass parameter.
                            continue;
                        }
                        targetSubclasses.append(targetClass);
                        lastTargetNamespace = targetNamespace;
                    }

                    // Try to find the targetPath's class in the search space
                    CIMName targetPathClass = targetPath.getClassName();
                    for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j)
                    {
                        if(targetPathClass == targetSubclasses[j])
                        {
                            instances.append(currentInstance);
                            break;
                        }
                    }
                }
                else
                {
                    instances.append(currentInstance);
                }
            }
        }
    }

    PEG_METHOD_EXIT();
    return instances;
}
//
// Class that determines whether or not the origin class in an association
// operation is valid for the given association class, and also determines
// the origin and target "roles". These values generally correspond to the
// role and resultRole parameter of an associators/associatorNames operation.
//
bool InteropProvider::validAssocClassForObject(
    const OperationContext & context,
    const CIMName & assocClass, 
    const CIMObjectPath & objectName,
    const CIMNamespaceName & opNamespace,
    String & originProperty, 
    String & targetProperty)
{
    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
        "InteropProvider::validAssocClassForObject()");
    TARGET_CLASS assocClassEnum = translateClassInput(assocClass);
    TARGET_CLASS originClassEnum;
    CIMName originClass = objectName.getClassName();
    // If the association class is PG_ElementConformsToProfile, we'll have to
    // do some special processing in case the origin instance for the operation
    // is managed by another provider.
    if(assocClassEnum == PG_ELEMENTCONFORMSTOPROFILE)
    {
        // Test if the origin is an element managed by another provider
        // that has implemented a registered profile.
        if(opNamespace != PEGASUS_NAMESPACENAME_INTEROP ||
            (originClass != PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE &&
             originClass != PEGASUS_CLASSNAME_PG_OBJECTMANAGER ))
        {
            //
            // Search the cached conformingElements list for the originClass,
            // returning false if it is not found
            //
            bool found = false;

            PEGASUS_ASSERT(conformingElements.size() ==
                elementNamespaces.size());
            for(Uint32 i = 0, n = conformingElements.size(); i < n; ++i)
            {
                CIMNameArray & elementList = conformingElements[i];
                CIMNamespaceArray & namespaceList = elementNamespaces[i];
                PEGASUS_ASSERT(elementList.size() == namespaceList.size());
                for(Uint32 j = 0, m = elementList.size(); j < m; ++j)
                {
                    CIMName & curElement = elementList[j];
                    if((curElement == originClass ||
                      curElement.getString().find(PEGASUS_DYNAMIC) == 0) &&
                      opNamespace == namespaceList[j])
                    {
                        found = true;
                        break;
                    }
                }
                if(found)
                    break;
            }

            if(!found)
            {
                PEG_METHOD_EXIT();
                return false;
            }
        }
    }
    else
    {
        // Otherwise, just get the enum value representing the origin class
        // for this operation
        originClassEnum = translateClassInput(originClass);
    }

    CIMName expectedTargetRole;
    CIMName expectedOriginRole;

    Array<CIMName> propNames;
    String profileName;
    CIMPropertyList propertyList;
    CIMInstance tmpInstance;
    Uint32 index;
    propNames.clear();
    
    //
    // Set the target and origin role values. Note that if these values are
    // not set following the switch block, that implies that the origin class
    // is not valid for the supplied association class.
    //
    switch(assocClassEnum)
    {
      case PG_NAMESPACEINMANAGER:
          if(originClassEnum == PG_OBJECTMANAGER)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_NAMESPACE)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          break;
      case PG_COMMMECHANISMFORMANAGER:
          if(originClassEnum == PG_OBJECTMANAGER)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          break;
      case PG_ELEMENTCONFORMSTOPROFILE:
          if(originClass.equal(PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE))
          {
              expectedTargetRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
              expectedOriginRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
          }
          else
          {
              expectedTargetRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
              expectedOriginRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
          }
          break;
      case PG_ELEMENTCONFORMSTOPROFILE_RP_RP:
          propNames.append(CIMName("RegisteredName"));
          propertyList = CIMPropertyList(propNames);
          tmpInstance = localGetInstance(
              context, 
              objectName,
              propertyList);
          if (!tmpInstance.isUninitialized())
          {
              index = tmpInstance.findProperty("RegisteredName");
              if (index != PEG_NOT_FOUND)
              {
                  const CIMValue &tmpVal = 
                      tmpInstance.getProperty(index).getValue();
                  if (!tmpVal.isNull())
                  {
                      tmpVal.get(profileName);
                  }
              }
          }
          if (String::compareNoCase(profileName, String("SMI-S")) == 0)
          {
              expectedTargetRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
              expectedOriginRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
          }
          else
          {
              expectedTargetRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_CONFORMANTSTANDARD;
              expectedOriginRole =
                  ELEMENTCONFORMSTOPROFILE_PROPERTY_MANAGEDELEMENT;
          }
          break;
      case PG_SUBPROFILEREQUIRESPROFILE:
          if(originClassEnum == PG_REGISTEREDPROFILE)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_REGISTEREDSUBPROFILE)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          break;
      case PG_REFERENCEDPROFILE:
          if (originClassEnum == PG_REGISTEREDSUBPROFILE)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          else if (originClassEnum == PG_REGISTEREDPROFILE)
          {
              if ((targetProperty.size() != 0) &&
                  (originProperty.size() != 0) &&
                  String::equalNoCase(targetProperty, originProperty))
              {
                  return false;
              }
              if (targetProperty.size() != 0)
              {
                  if (!(String::equalNoCase(targetProperty, "Antecedent") ||
                      String::equalNoCase(targetProperty, "Dependent") ))
                  {
                      return false;
                  }
              }
              if (originProperty.size() != 0)
              {
                  if (!(String::equalNoCase(originProperty, "Antecedent") ||
                      String::equalNoCase(originProperty, "Dependent") ))
                  {
                      return false;
                  }
              }
              if (String::equalNoCase(originProperty, "Antecedent") &&
                  targetProperty.size() == 0)
              {
                  targetProperty = String("Dependent");
              }
              if (String::equalNoCase(originProperty, "Dependent") &&
                  targetProperty.size() == 0)
              {
                  targetProperty = String("Antecedent");
              }
              if (String::equalNoCase(targetProperty, "Antecedent") &&
                  originProperty.size() == 0)
              {
                  originProperty = String("Dependent");
              }
              if (String::equalNoCase(targetProperty, "Dependent") &&
                  originProperty.size() == 0)
              {
                  originProperty = String("Antecedent");
              }
              return true;
          }
          break;
      case PG_ELEMENTSOFTWAREIDENTITY:
          if(originClassEnum == PG_SOFTWAREIDENTITY)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_REGISTEREDPROFILE ||
              originClassEnum == PG_REGISTEREDSUBPROFILE)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          break;
      case PG_INSTALLEDSOFTWAREIDENTITY:
          if(originClassEnum == PG_SOFTWAREIDENTITY)
          {
              expectedTargetRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM;
              expectedOriginRole =
                  INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE;
          }
          else if(originClassEnum == PG_COMPUTERSYSTEM)
          {
              expectedTargetRole =
                  INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE;
              expectedOriginRole = INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM;
          }
          break;
      case PG_HOSTEDACCESSPOINT:
          if(originClassEnum == PG_COMPUTERSYSTEM)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
      case PG_HOSTEDOBJECTMANAGER:
          if(originClassEnum == PG_COMPUTERSYSTEM)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          else if(originClassEnum == PG_OBJECTMANAGER)
          {
              expectedTargetRole = PROPERTY_ANTECEDENT;
              expectedOriginRole = PROPERTY_DEPENDENT;
          }
          break;
#ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
      case PG_HOSTEDINDICATIONSERVICE:
          if(originClassEnum == PG_COMPUTERSYSTEM)
          {
              expectedTargetRole = PROPERTY_DEPENDENT;
              expectedOriginRole = PROPERTY_ANTECEDENT;
          }
          break;
#endif
      default:
          break;
    }

    //
    // The rest of this method checks to see if target role and origin roles
    // were found for the association and origin class combination and, if
    // found, checks against the input target and origin roles if provided.
    // Failure for any of these tests points to an invalid association
    // traversal request.
    //
    if(expectedTargetRole.isNull() ||
        expectedOriginRole.isNull())
    {
        PEG_METHOD_EXIT();
        return false;
    }

    if(targetProperty.size() == 0)
    {
        targetProperty = expectedTargetRole.getString();
    }
    else if(!expectedTargetRole.equal(targetProperty))
    {
        PEG_METHOD_EXIT();
        return false;
    }

    if(originProperty.size() == 0)
    {
        originProperty = expectedOriginRole.getString();
    }
    else if(!expectedOriginRole.equal(originProperty))
    {
        PEG_METHOD_EXIT();
        return false;
    }

    PEG_METHOD_EXIT();
    return true;
}
Beispiel #12
0
void DefaultInstanceProvider::_copySuperClasses(
    CIMClient & client,
    const String & nameSpace,
    const CIMClass & cimClass,
    Array<CIMClass> & superClasses)
{
    // get the super class name
    CIMName superClassName = cimClass.getSuperClassName();

    if (superClassName.isNull())
    {
        Uint32 numSuperClasses = superClasses.size();
        if (numSuperClasses == 0)
        {
            // No super class, just return
            return;
        }

        // copy the super classes
        for (Uint32 i = numSuperClasses; i > 0; i--)
        {
            // check to see if class already exists
            //
            CIMClass cimClass;
            try
            {
                cimClass = _repository->getClass(nameSpace, 
                                          superClasses[i-1].getClassName());
            }
            catch (Exception&)
            {
                //
                // Super class does not exist, create the super class
                //
                try
                {
                    _repository->createClass( nameSpace, superClasses[i-1] );
                }
                catch( Exception& ex )
                {
                    const String msg  = "Create superClass failed. " + ex.getMessage();
                    throw CIMOperationFailedException( msg );
                }
            }
        }
        return;
    }

    // get the super class 
    CIMClass superClass;
    Boolean localOnly = false;
    Boolean includeQualifiers = true;
    Boolean includeClassOrigin = false;

    try
    {
        superClass = client.getClass(nameSpace, superClassName,
                                     localOnly, includeQualifiers,
                                     includeClassOrigin);

        // add superclass to array
        superClasses.append(superClass);
    }
    catch( Exception& ex )
    {
        const String msg = "Get Super Class failed. " + ex.getMessage();
        throw CIMOperationFailedException( msg );
    }

    // recursive call.  copy superclasses of this class
    _copySuperClasses( client, nameSpace, superClass, superClasses); 
}
Beispiel #13
0
void CIMPropertyRep::resolve(
    DeclContext* declContext,
    const CIMNamespaceName& nameSpace,
    Boolean isInstancePart,
    const CIMConstProperty& inheritedProperty,
    Boolean propagateQualifiers)
{
    PEGASUS_ASSERT(!inheritedProperty.isUninitialized());

    // Check the type:

    if (!inheritedProperty.getValue().typeCompatible(_value))
    {
        if (!(
            (inheritedProperty.getValue().getType() == CIMTYPE_OBJECT) &&
            (_value.getType() == CIMTYPE_STRING) &&
            (_qualifiers.find(CIMName("EmbeddedObject")) != PEG_NOT_FOUND) &&
            (inheritedProperty.getValue().isArray() == _value.isArray())
            ))
        {
            throw TypeMismatchException();
        }
    }

    // Validate the qualifiers of the property (according to
    // superClass's property with the same name). This method
    // will throw an exception if the validation fails.

    CIMScope scope = CIMScope::PROPERTY;

    if (_value.getType() == CIMTYPE_REFERENCE)
	scope = CIMScope::REFERENCE;

    // Test the reference class name against the inherited property
    if (_value.getType() == CIMTYPE_REFERENCE)
    {
        CIMName inheritedReferenceClassName = inheritedProperty.getReferenceClassName();
        CIMName referenceClassName;
        if(!_referenceClassName.isNull() && !_value.isNull())
        {
            CIMObjectPath valuePath;
            _value.get(valuePath);
            referenceClassName = valuePath.getClassName();
            bool found = _referenceClassName.equal(referenceClassName);
            while(!found)
            {
                CIMClass referenceClass = declContext->lookupClass(nameSpace, referenceClassName);
                if(referenceClass.isUninitialized())
                {
                    throw PEGASUS_CIM_EXCEPTION(
                      CIM_ERR_NOT_FOUND, referenceClassName.getString());
                }
                referenceClassName = referenceClass.getSuperClassName();
                if(referenceClassName.isNull())
                    throw TypeMismatchException();

                found = inheritedReferenceClassName.equal(referenceClassName);
            }
        }
        else if(!_referenceClassName.isNull())
        {
            referenceClassName = _referenceClassName;
        }
        else if(!_value.isNull())
        {
            CIMObjectPath valuePath;
            _value.get(valuePath);
            referenceClassName = valuePath.getClassName();
        }

        if(!referenceClassName.isNull())
        {
            bool found = inheritedReferenceClassName.equal(referenceClassName);
            while(!found)
            {
                CIMClass referenceClass = declContext->lookupClass(nameSpace, referenceClassName);
                if(referenceClass.isUninitialized())
                {
                    throw PEGASUS_CIM_EXCEPTION(
                        CIM_ERR_NOT_FOUND, referenceClassName.getString());
                }
                referenceClassName = referenceClass.getSuperClassName();
                if(referenceClassName.isNull())
                    throw TypeMismatchException();

                found = inheritedReferenceClassName.equal(referenceClassName);
            }
        }
    }

    _qualifiers.resolve(
	declContext,
	nameSpace,
	scope,
	isInstancePart,
	inheritedProperty._rep->_qualifiers,
	propagateQualifiers);

    _classOrigin = inheritedProperty.getClassOrigin();
}