version 1.76, 2009/12/15 11:39:33
|
version 1.76.4.3, 2013/06/03 22:35:12
|
|
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
// From PEP 194: EmbeddedObjects cannot be keys. | // From PEP 194: EmbeddedObjects cannot be keys. |
return false; | return false; |
break; |
|
default: // Numerics | default: // Numerics |
if (getType() != NUMERIC) return false; | if (getType() != NUMERIC) return false; |
kbValue = XmlReader::stringToValue(0, getValue().getCString(), | kbValue = XmlReader::stringToValue(0, getValue().getCString(), |
|
|
// If CIMObjectPath parsing fails, just compare strings | // If CIMObjectPath parsing fails, just compare strings |
return String::equal(x.getValue(), y.getValue()); | return String::equal(x.getValue(), y.getValue()); |
} | } |
break; |
|
case CIMKeyBinding::BOOLEAN: | case CIMKeyBinding::BOOLEAN: |
// Case-insensitive comparison is sufficient for booleans | // Case-insensitive comparison is sufficient for booleans |
return String::equalNoCase(x.getValue(), y.getValue()); | return String::equalNoCase(x.getValue(), y.getValue()); |
break; |
|
case CIMKeyBinding::NUMERIC: | case CIMKeyBinding::NUMERIC: |
// Note: This comparison assumes XML syntax for integers | // Note: This comparison assumes XML syntax for integers |
// First try comparing as unsigned integers | // First try comparing as unsigned integers |
|
|
// Note: Keys may not be real values, so don't try comparing as reals | // Note: Keys may not be real values, so don't try comparing as reals |
// We couldn't parse the numbers, so just compare the strings | // We couldn't parse the numbers, so just compare the strings |
return String::equal(x.getValue(), y.getValue()); | return String::equal(x.getValue(), y.getValue()); |
break; |
|
default: // CIMKeyBinding::STRING | default: // CIMKeyBinding::STRING |
return String::equal(x.getValue(), y.getValue()); | return String::equal(x.getValue(), y.getValue()); |
break; |
|
} | } |
| |
PEGASUS_UNREACHABLE(return false;) | PEGASUS_UNREACHABLE(return false;) |
|
|
{ | { |
if ((host != String::EMPTY) && !CIMObjectPathRep::isValidHostname(host)) | if ((host != String::EMPTY) && !CIMObjectPathRep::isValidHostname(host)) |
{ | { |
throw MalformedObjectNameException(host); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
host); |
|
|
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
_rep = _copyOnWriteCIMObjectPathRep(_rep); | _rep = _copyOnWriteCIMObjectPathRep(_rep); |
|
|
char* slash = strchr(p, '/'); | char* slash = strchr(p, '/'); |
if (!slash) | if (!slash) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.MISSING_SLASH_AFTER_HOST", |
|
"$0, reason:\"missing slash after hostname\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
String hostname = String(p, (Uint32)(slash - p)); | String hostname = String(p, (Uint32)(slash - p)); |
if (!CIMObjectPathRep::isValidHostname(hostname)) | if (!CIMObjectPathRep::isValidHostname(hostname)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
host = hostname; | host = hostname; |
| |
|
|
String namespaceName = String(p, (Uint32)(colon - p)); | String namespaceName = String(p, (Uint32)(colon - p)); |
if (!CIMNamespaceName::legal(namespaceName)) | if (!CIMNamespaceName::legal(namespaceName)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NAMESPACE", |
|
"$0, reason:\"invalid namespace name\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
nameSpace = namespaceName; | nameSpace = namespaceName; |
| |
|
|
char* equalsign = strchr(p, '='); | char* equalsign = strchr(p, '='); |
if (!equalsign) | if (!equalsign) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR", |
|
"$0, reason:\"invalid key-value pair, missing equal sign\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
*equalsign = 0; | *equalsign = 0; |
| |
if (!CIMName::legal(p)) | if (!CIMName::legal(p)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYNAME", |
|
"$0, reason:\"invalid key-value pair, invalid key name:$1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
CIMName keyName (p); | CIMName keyName (p); |
| |
|
|
| |
if ((*p != '\\') && (*p != '"')) | if ((*p != '\\') && (*p != '"')) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"malformed value\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
} | } |
| |
|
|
} | } |
| |
if (*p++ != '"') | if (*p++ != '"') |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR_MISSINGQUOTE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"missing quote in key value\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
// Convert the UTF-8 value to a UTF-16 String | // Convert the UTF-8 value to a UTF-16 String |
| |
|
|
| |
if (!(((strncmp(p, "TRUE", n) == 0) && n == 4) || | if (!(((strncmp(p, "TRUE", n) == 0) && n == 4) || |
((strncmp(p, "FALSE", n) == 0) && n == 5))) | ((strncmp(p, "FALSE", n) == 0) && n == 5))) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_BOOLVALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"value should be TRUE or FALSE\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
valueString.assign(p, n); | valueString.assign(p, n); |
| |
|
|
{ | { |
Sint64 x; | Sint64 x; |
if (!StringConversion::stringToSignedInteger(p, x)) | if (!StringConversion::stringToSignedInteger(p, x)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NEGATIVNUMBER_VALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"invalid negative number value $1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
} | } |
else | else |
{ | { |
Uint64 x; | Uint64 x; |
if (!StringConversion::stringToUnsignedInteger(p, x)) | if (!StringConversion::stringToUnsignedInteger(p, x)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NEGATIVNUMBER_VALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"invalid number value $1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
} | } |
| |
valueString.assign(p, n); | valueString.assign(p, n); |
|
|
{ | { |
if (*p++ != ',') | if (*p++ != ',') |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR_MISSCOMMA", |
|
"$0, reason:\"invalid key-value pair, " |
|
"next key-value pair has to start with comma\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
} | } |
} | } |
|
|
| |
if (gotHost && !gotNamespace) | if (gotHost && !gotNamespace) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.MISSING_NAMESPACE", |
|
"$0, reason:\"host specified, missing namespace\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
// Extract the class name: | // Extract the class name: |
|
|
{ | { |
if (!CIMName::legal(p)) | if (!CIMName::legal(p)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_CLASSNAME", |
|
"$0, reason:\"class name $1 not a legal CIM name\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
// ATTN: remove this later: a reference should only be able to hold | // ATTN: remove this later: a reference should only be able to hold |
|
|
String className = String(p, (Uint32)(dot - p)); | String className = String(p, (Uint32)(dot - p)); |
if (!CIMName::legal(className)) | if (!CIMName::legal(className)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_CLASSNAME", |
|
"$0, reason:\"class name $1 not a legal CIM name\"", |
|
objectName, |
|
className); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
_rep->_className = className; | _rep->_className = className; |
| |
|
|
(host != System::getHostName()) && | (host != System::getHostName()) && |
!CIMObjectPathRep::isValidHostname(host)) | !CIMObjectPathRep::isValidHostname(host)) |
{ | { |
throw MalformedObjectNameException(host); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
host); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
_rep = _copyOnWriteCIMObjectPathRep(_rep); | _rep = _copyOnWriteCIMObjectPathRep(_rep); |
| |
|
|
// ATTN-CAKG-P2-20020726: The following condition does not correctly | // ATTN-CAKG-P2-20020726: The following condition does not correctly |
// distinguish instanceNames from classNames in every case | // distinguish instanceNames from classNames in every case |
// The instanceName of a singleton instance of a keyless class has no | // The instanceName of a singleton instance of a keyless class has no |
// key bindings |
// key bindings. See BUG_3302 |
// | // |
if (_rep->_keyBindings.size () != 0) | if (_rep->_keyBindings.size () != 0) |
{ | { |