⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repositoryupgrade.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            pos1 = iMajor;            iMajor = atoi((const char*)                      (version.subString(pos, iMajor).getCString()));            if (iMinor >= 0)            {                pos2 = iMinor;                iMinor = atoi((const char*)                          (version.subString(pos1+1, iMinor).getCString()));                iUpdate = atoi((const char*)                          (version.subString(pos2+1).getCString()));            }            else            {                iMinor = atoi((const char*)                          (version.subString(pos1+1).getCString()));            }        }        else        {            iMajor = atoi((const char*)(version.subString(pos).getCString()));        }    }    return ret;}void RepositoryUpgrade::_processNewClasses(                          const CIMNamespaceName& namespaceName,                          Array<CIMName>&   missingClasses,                          Array<CIMName>&   currClasses){    Boolean		allSuperClassesExist = true;    Uint32 		missingCount         = missingClasses.size();    Uint32 		superClassCount      = 0;    Uint32 		saveCount            = 0;    Array<CIMName>      superClassList;    while (missingCount > 0)    {        for ( Uint32 i=0; i < missingCount; i++)        {            allSuperClassesExist 	= true;            //            // Check if the class already exists in the new repository.            //            if (!Contains (currClasses,missingClasses[i]))            {                //                // Check if this class has Super Classes.                //                _oldRepository->getSuperClassNames(	    			namespaceName,	    			missingClasses[i],	    			superClassList);                superClassCount = superClassList.size();                saveCount       = superClassCount;                while ( superClassCount > 0 && allSuperClassesExist)                {                    //                    // Check if all the super classes exist in the                    // new repository.                    //                    if (!Contains(currClasses,                                     superClassList[superClassCount-1]))                    {                        allSuperClassesExist = false;                    }                    --superClassCount;                }                //                // If all the super classes existed or if the class did not have                // any super classes then try to add the class to the                // new Repository.                //                if (allSuperClassesExist || (saveCount==0))                {                    Uint32 retCode =                          _addClassToRepository (namespaceName,                                             missingClasses[i],                                             currClasses);                    //                    // Check if the class was added successfully.                    //                    if (retCode == 0)                    {                         currClasses.append(missingClasses[i]);                         missingClasses.remove(i);                    }                }            }            missingCount = missingClasses.size();            superClassList.clear();        }    }}Uint32 RepositoryUpgrade::_addClassToRepository (                      const CIMNamespaceName& namespaceName,                      const CIMName&          className,                      const Array<CIMName>    existingClasses){    Uint32 retCode = 0;    CIMClass                oldClass;    // Get the missing class info from the old repository.    try    {        oldClass = _oldRepository->getClass(                          namespaceName,                          className,                          true,                          true,                          true);    }    catch (Exception& e)    {        String message = localizeMessage (MSG_PATH,                           REPOSITORY_UPGRADE_FAILURE_KEY,                           REPOSITORY_UPGRADE_FAILURE) +                         e.getMessage() +                         localizeMessage (MSG_PATH,                           OLD_CLASS_RETRIEVAL_ERROR_KEY,                           OLD_CLASS_RETRIEVAL_ERROR,                           className.getString(),                           namespaceName.getString());    }    catch (...)    {        String message = localizeMessage ( MSG_PATH,                                           REPOSITORY_UPGRADE_FAILURE_KEY,                                           REPOSITORY_UPGRADE_FAILURE ) +                         localizeMessage ( MSG_PATH,                                           OLD_CLASS_RETRIEVAL_ERROR_KEY,                                           OLD_CLASS_RETRIEVAL_ERROR,                                           className.getString(),                                           namespaceName.getString());        throw RepositoryUpgradeException (message);    }    //    // Invoke the Special Processing modules.    //    //    // Check if the class must be created. If true, use the    // processed class. If the SSP Modules have chosen to    // to ignore the class then skip the class creation.    //    CIMClass processedClass = oldClass.clone();#ifdef ENABLE_MODULE_PROCESSING    if (!_invokeModules (oldClass, processedClass))    {#ifdef REPUPGRADE_DEBUG        cerr << "Ignoring class creation : "        << oldClass.getClassName() << endl;#endif    }    else    {#endif        try        {#ifdef REPUPGRADE_DEBUG            cout << "Creating class : " << className.getString() << endl;#endif            _newRepository->createClass (namespaceName, processedClass);#ifdef REPUPGRADE_DEBUG            cout << "Class created : " << className.getString() << endl;#endif        }        catch (CIMException& ce)        {            if (ce.getCode() == CIM_ERR_NOT_FOUND)            {                CIMName dependentClassName(ce.getMessage());                //                // Check if the error was due to a non-existent class, if so                // will try to create this class later. This error could be                // because a dependent class of an Association class                // has not yet been created.                //                if (! Contains( existingClasses, dependentClassName))                {                    //                     // Check if the class that we depend on exists in                     // the old repository.                    // If it doesn't exist, error out.                    //                    try                    {                         oldClass = _oldRepository->getClass(                                            namespaceName,                                            dependentClassName,                                            true,                                            true,                                            true);                    }                    catch (const CIMException&)                    {                        //                        // We have an exception case here.                        //                        String message = localizeMessage (MSG_PATH,                               REPOSITORY_UPGRADE_FAILURE_KEY,                               REPOSITORY_UPGRADE_FAILURE) + " " +                              localizeMessage ( MSG_PATH,                              CLASS_CREATION_ERROR_KEY,                              CLASS_CREATION_ERROR,                              className.getString(),                              namespaceName.getString()) + " " +                               localizeMessage (MSG_PATH,                               OLD_DEPENDENT_CLASS_RETRIEVAL_ERROR_KEY,                               OLD_DEPENDENT_CLASS_RETRIEVAL_ERROR,                               dependentClassName.getString(),                               namespaceName.getString());                         throw RepositoryUpgradeException(message);                    }#ifdef REPUPGRADE_DEBUG                    cout << "Adding to retry list Class name : "                         << ce.getMessage() << endl;#endif                    retCode = 1;                }                else                {                    _logCreateClassError (namespaceName,                                      oldClass,                                      (ce.getMessage()+". "));                }            }            else            {                _logCreateClassError (namespaceName,                                          oldClass,                                          (ce.getMessage()+". "));            }        }        catch (Exception& e)        {           _logCreateClassError (namespaceName,                                      oldClass,                                      (e.getMessage()+". "));        }        catch (...)        {           _logCreateClassError (namespaceName,                                      oldClass,                                      String::EMPTY);        }#ifdef ENABLE_MODULE_PROCESSING    }#endif    return retCode;}void RepositoryUpgrade::_addInstances(void){    Array<CIMNamespaceName>                  oldNamespaces;    oldNamespaces = _oldRepository->enumerateNameSpaces();    if (oldNamespaces.size() > 0)    {        CIMName			className;        for ( Uint32 i = 0; i < oldNamespaces.size(); i++)        {            //            // Get the list of class names.            //            Array<CIMName>                  oldClassNames;            //            // Gather class information for each namespace.            //            oldClassNames = _oldRepository->enumerateClassNames(                       oldNamespaces[i],                       className,                       true);            //            // Enumerate the instances for each class.            //            if (oldClassNames.size() > 0)            {                for ( Uint32 ctr=0; ctr < oldClassNames.size(); ctr++)                {#ifdef REPUPGRADE_DEBUG            cout << "Processing namespace : " << oldNamespaces[i]                 << "class name : " <<  oldClassNames[ctr] << endl;#endif                    Array<CIMInstance>         instances;                    Uint32                     n = 0;                    Uint32                     ictr = 0;                        instances = _oldRepository->enumerateInstancesForClass(                                            oldNamespaces[i],                                            oldClassNames[ctr],                                            true,                                            true,                                            true);                        if (instances.size() > 0)                        {#ifdef REPUPGRADE_DEBUG                            cout << "Found instances : "                                 << instances.size() << endl;#endif                            for ( ictr=0; ictr<instances.size(); ictr++)                            {                                try                                {                                    //                                    // Check if the instance must be created.                                    // If true, use the processed instance.                                    // If an SSP Module has chosen to ignore                                    // the instance then skip the                                    // instance creation.                                    //                                    CIMInstance processedInstance =                                               instances[ictr].clone();#ifdef ENABLE_MODULE_PROCESSING                                    if (!_invokeModules(instances[ictr],                                              processedInstance))                                    {#ifdef REPUPGRADE_DEBUG                                        cerr << "Ignoring instance creation : "                                        << instances[ictr].getPath().toString()                                        << endl;#endif                                        continue;                                    }#endif                                    //                                    // Create the instance.                                    //#ifdef REPUPGRADE_DEBUG				    cout << "Creating instance" << endl;#endif                                    _newRepository->createInstance(                                                         oldNamespaces[i],                                                         processedInstance);#ifdef REPUPGRADE_DEBUG		                    cout << "Instance created" << endl;#endif                                }                                catch (CIMException &ce)                                {                                    if (ce.getCode() == CIM_ERR_ALREADY_EXISTS)                                    {#ifdef REPUPGRADE_DEBUG                                       cout <<                                       "Instance already exists." << endl;#endif                                    }                                    else                                    {                                        _logCreateInstanceError(                                         oldNamespaces[i],                                                        instances[ictr],                                         (ce.getMessage()+". "));                                    }                                }                                catch (Exception& e)                                {                                    _logCreateInstanceError(oldNamespaces[i],                                                   instances[ictr],                                                   (e.getMessage()+". "));                                }                                catch (...)                                {                                    _logCreateInstanceError(oldNamespaces[i],                                                    instances[ictr],                                                    String::EMPTY);                                }                 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -