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

📄 repositoryupgrade.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        {            /** This check is required to ignore PG_Ind* classes                in the interop namespace. These classes were                replaced with CIM_Ind* in CIM 2.7            */            if ( namespaceName == PEGASUS_NAMESPACENAME_INTEROP &&                Contains( _interopIgnoreClasses, oldClasses[oldclasses] ) )            {#ifdef REPUPGRADE_DEBUG                cout << "Now ignoring: " << oldClasses[oldclasses] << endl;#endif                continue;            }            /** Ignore any "CIM_" classes in pegasus namespaces, except root/cimv2.                 Since they don't exist in 2.7 they must have been renamed or deleted.            */            if ( ( (namespaceName == PEGASUS_NAMESPACENAME_INTEROP) ||                   (namespaceName == "root/PG_Internal")) &&                   (oldClasses[oldclasses].getString().subString(0,4))=="CIM_")            {#ifdef REPUPGRADE_DEBUG                cout << "Now ignoring: " << oldClasses[oldclasses] << endl;#endif                continue;            }#ifdef REPUPGRADE_DEBUG            cout << "Now appending to missing: "                 << oldClasses[oldclasses] << endl;#endif            missingClasses.append(oldClasses[oldclasses]);        }        else        {#ifdef REPUPGRADE_DEBUG        cout << "Now appending to existing: "             << oldClasses[oldclasses] << endl;#endif            existingClasses.append(oldClasses[oldclasses]);        }    }    // Check if any missing classes existed and add them.    if (missingClasses.size() > 0)    {        _processNewClasses (namespaceName, missingClasses, newClasses);    }    // Check for existing classes and process them.    if (existingClasses.size() > 0)    {        _processExistingClasses (namespaceName, existingClasses);    }    newClasses.clear();}void RepositoryUpgrade::_processExistingClasses(                      const CIMNamespaceName& namespaceName,                      const Array<CIMName>&   existingClasses){    Uint32 			idx;    Uint32 			existingClassCount = existingClasses.size();    for ( Uint32 i=0; i < existingClassCount; i++)    {        CIMClass		oldClass;	CIMClass 		newClass;	String 			oldVersion;	String 			newVersion;	Boolean 		oldVersionFound=false;	Boolean 		newVersionFound=false;#ifdef REPUPGRADE_DEBUG        cout << "In Namespace: " << namespaceName             << "Existing Classname: " << existingClasses[i] << endl;#endif        try        {            oldClass = _oldRepository->getClass(namespaceName,                                            existingClasses[i],					    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,                               existingClasses[i].getString(),                               namespaceName.getString());        }        catch (...)        {            String errMsg = localizeMessage ( MSG_PATH,                                              REPOSITORY_UPGRADE_FAILURE_KEY,                                              REPOSITORY_UPGRADE_FAILURE )                            + localizeMessage ( MSG_PATH,                                                OLD_CLASS_RETRIEVAL_ERROR_KEY,                                                OLD_CLASS_RETRIEVAL_ERROR,                                                existingClasses[i].getString(),                                                namespaceName.getString());            throw RepositoryUpgradeException (errMsg);        }        try        {            newClass = _newRepository->getClass(namespaceName,                                            existingClasses[i],					    true,					    true,					    true);        }        catch (Exception& e)        {            String message = localizeMessage (MSG_PATH,                               REPOSITORY_UPGRADE_FAILURE_KEY,                               REPOSITORY_UPGRADE_FAILURE) +                             e.getMessage() +                             localizeMessage (MSG_PATH,                               NEW_CLASS_RETRIEVAL_ERROR_KEY,                               NEW_CLASS_RETRIEVAL_ERROR,                               existingClasses[i].getString(),                               namespaceName.getString());        }        catch (...)        {            String errMsg = localizeMessage ( MSG_PATH,                                              REPOSITORY_UPGRADE_FAILURE_KEY,                                              REPOSITORY_UPGRADE_FAILURE )                            + localizeMessage ( MSG_PATH,                                                NEW_CLASS_RETRIEVAL_ERROR_KEY,                                                NEW_CLASS_RETRIEVAL_ERROR,                                                existingClasses[i].getString(),                                                namespaceName.getString());            throw RepositoryUpgradeException (errMsg);        }        // Get the version qualifier from the old Class.        idx = oldClass.findQualifier(_VERSION_QUALIFIER_NAME);        if (idx != PEG_NOT_FOUND)        {            CIMQualifier rVer = oldClass.getQualifier(idx);            CIMValue rVal = rVer.getValue();            rVal.get(oldVersion);            oldVersionFound = true;        }        // Get the version qualifier from the new Class.        idx = newClass.findQualifier(_VERSION_QUALIFIER_NAME);        if (idx != PEG_NOT_FOUND)        {            CIMQualifier rVer = newClass.getQualifier(idx);            CIMValue rVal = rVer.getValue();            rVal.get(newVersion);            newVersionFound = true;        }        //        // 1. If the class in old Repository contains a version number        //    and the new Repository class does not have a version number then        //    print a warning message        // 2. If the class in old Repository contains a higher version number        //    than the new Repository class then print a warning message        //        if ( oldVersionFound && !newVersionFound )        {            //            // The old Repository has a higher version of the class.            // Log a warning message and ignore the class.            //            cerr << localizeMessage (MSG_PATH,                                     HIGHER_VERSION_OLD_CLASS_KEY,                                     HIGHER_VERSION_OLD_CLASS,                                     oldClass.getClassName().getString(),                                     namespaceName.getString()) << endl;        }        else if ( oldVersionFound && newVersionFound )        {            // Compare the version            if (_compareVersion (oldVersion, newVersion) == true)            {                //                // The old Repository has a higher version of the class.                // Log a warning message and ignore the class.                //                cerr << localizeMessage (MSG_PATH,                                         HIGHER_VERSION_OLD_CLASS_KEY,                                         HIGHER_VERSION_OLD_CLASS,                                         oldClass.getClassName().getString(),                                         namespaceName.getString()) << endl;            }        }    }}//// Return true if old repository class has a higher version, else return false.//Boolean RepositoryUpgrade::_compareVersion(const String& oldVersion,                                           const String& newVersion){    Sint32 			iMinorOld = -1;    Sint32 			iMajorOld = -1;    Sint32			iUpdateOld = -1;    Sint32 			iMinorNew = -1;    Sint32 			iMajorNew = -1;    Sint32			iUpdateNew = -1;    Boolean			retVal = false;    retVal = _parseVersion (oldVersion, iMajorOld, iMinorOld, iUpdateOld);    // cimmof compiler rejects invalid versions.    // ATTN-SF-P3-20050209: Need to identify invalid version formats and assert    // here.    // PEGASUS_ASSERT(retVal != false);    retVal = _parseVersion (newVersion, iMajorNew, iMinorNew, iUpdateNew);    // cimmof compiler rejects invalid versions.    // ATTN-SF-P3-20050209: Need to identify invalid version formats and assert    // here.    // PEGASUS_ASSERT(retVal != false);#ifdef REPUPGRADE_DEBUG    cout << "old Version : " << iMajorOld << "."                             << iMinorOld << "."                             << iUpdateOld << endl;    cout << "new Version : " << iMajorNew << "."                             << iMinorNew << "."                             << iUpdateNew << endl;#endif    retVal = false;    if ( iMajorOld > iMajorNew )    {        retVal = true;    }    else if ( iMajorOld == iMajorNew )    {        if ( iMinorOld > iMinorNew )        {            retVal = true;        }        else if ( iMinorOld == iMinorNew )        {            if ( iUpdateOld > iUpdateNew )            {                retVal = true;            }        }    }    return retVal;}//// ATTN-SF-P3-20050209: The following needs to be consolidated with//                      cimmofParser::verifyVersion method.//Boolean RepositoryUpgrade::_parseVersion(const String& version,                                               Sint32& iMajor,                                               Sint32& iMinor,                                               Sint32& iUpdate){    Boolean ret = true;    Sint32 pos   = -1;    Sint32 pos1  = -1;    Sint32 pos2  = -1;    const char CHAR_PERIOD = '.';    // Parse the input version    if (version.size())    {        // If "V" specified as first character go ahead and ignore        if ((version[0] >= '0') && (version[0] <= '9'))        {            pos = 0;            iMajor = version.find(0, CHAR_PERIOD);        }        else        {            pos = 1;            if (String::equalNoCase(version.subString(0,1), "V"))            {                iMajor = version.find(1, CHAR_PERIOD);            }            else            {                // First character is unknown.                // Examples of invalid version:  ".2.7", ".", "..", "...", "AB"                return false;            }        }        // Find the second and possible third period        if (iMajor >=0)        {            iMinor = version.find(iMajor+1, CHAR_PERIOD);        }        if (iMinor >= 0)        {            iUpdate = version.find(iMinor+1, CHAR_PERIOD);        }        // There should be no additional identifiers after the update identifier        if (iUpdate >= 0 && iUpdate != (Sint32)PEG_NOT_FOUND)        {            // Examples of invalid version:  "2.7.0.", "2.7.0.1",            //                               "2.7.0.a", "2.7.0.1."            return false;        }        // Check for trailing period        if ((iMajor >=0 && iMajor+1 == (int)version.size()) ||            (iMinor >=0 && iMinor+1 == (int)version.size()) ||            (iUpdate >=0 && iUpdate+1 == (int)version.size()))        {            // Examples of invalid version:  "2.", "2.7.", "V.", "9.."            return false;        }        // Major identifier is not specified        if (((pos > 0) && (iMajor < 0) && (!version.subString(pos).size())) ||            ((pos > 0) && (iMajor >= 0) && (iMajor <= pos)))        {            // Examples of invalid version: "V.2.7", "V"            return false;        }        // Check Major identifier for invalid format        int endM = iMajor;        if (iMajor < 0)        {           endM = version.size();        }        for (int i = pos; i < endM; i++)        {             if (!((version[i] >= '0') && (version[i] <= '9')))             {                 // Example of invalid version:  "1B.2D.3F"                 return false;             }        }        // Minor identifier is not specified        if (iMajor+1 == iMinor)        {            // Example of invalid version:  "2..9"            return false;        }        // Check Minor identifier for invalid format        if (iMajor > 0)        {            int endN = iMinor;            if (iMinor < 0)            {                endN = version.size();            }            for (int i = iMajor+1; i < endN; i++)            {                 if (!((version[i] >= '0') && (version[i] <= '9')))                 {                     // Example of invalid version:  "99.CD", "11.2D.3F"                     return false;                 }            }        }        // Check Update identifier for invalid format        if (iMinor > 0)        {            for (int i = iMinor+1; i < (int)version.size(); i++)            {                 if (!((version[i] >= '0') && (version[i] <= '9')))                 {                      // Example of invalid version: "99.88.EF", "11.22.3F"                      return false;                 }            }        }        // Set major, minor, and update values as integers        if (iMajor >= 0)        {

⌨️ 快捷键说明

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