version 1.1, 2008/11/25 19:27:27
|
version 1.9, 2009/07/08 13:48:26
|
|
|
//%2006//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// Source License; you may not use this file except in compliance with the |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// License. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// |
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Permission is hereby granted, free of charge, to any person obtaining a |
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// copy of this software and associated documentation files (the "Software"), |
// EMC Corporation; Symantec Corporation; The Open Group. |
// to deal in the Software without restriction, including without limitation |
// |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// and/or sell copies of the Software, and to permit persons to whom the |
// of this software and associated documentation files (the "Software"), to |
// Software is furnished to do so, subject to the following conditions: |
// deal in the Software without restriction, including without limitation the |
// |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// The above copyright notice and this permission notice shall be included |
// sell copies of the Software, and to permit persons to whom the Software is |
// in all copies or substantial portions of the Software. |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// 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. |
|
// | // |
//============================================================================== |
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
OP_DeleteQualifier, | OP_DeleteQualifier, |
OP_EnumerateQualifiers, | OP_EnumerateQualifiers, |
OP_InvokeMethod, | OP_InvokeMethod, |
OP_Count, |
OP_Count |
}; |
|
|
|
struct CIMBufferReleaser |
|
{ |
|
CIMBufferReleaser(CIMBuffer& buf) : _buf(buf) |
|
{ |
|
} |
|
|
|
~CIMBufferReleaser() |
|
{ |
|
_buf.release(); |
|
} |
|
|
|
private: |
|
CIMBuffer& _buf; |
|
}; | }; |
| |
static Operation _NameToOp(const CIMName& name) | static Operation _NameToOp(const CIMName& name) |
|
|
| |
Uint32 flags = 0; | Uint32 flags = 0; |
| |
if (msg->localOnly) |
|
flags |= LOCAL_ONLY; |
|
|
|
if (msg->deepInheritance) | if (msg->deepInheritance) |
flags |= DEEP_INHERITANCE; | flags |= DEEP_INHERITANCE; |
| |
|
|
nameSpace, | nameSpace, |
className, | className, |
deepInheritance, | deepInheritance, |
false, // Bug 1985 localOnly is deprecated |
|
#ifdef PEGASUS_DISABLE_INSTANCE_QUALIFIERS | #ifdef PEGASUS_DISABLE_INSTANCE_QUALIFIERS |
false, | false, |
#else | #else |
|
|
| |
static void _encodeEnumerateInstancesResponseBody( | static void _encodeEnumerateInstancesResponseBody( |
CIMBuffer& out, | CIMBuffer& out, |
CIMEnumerateInstancesResponseMessage* msg, |
CIMInstancesResponseData& data, |
CIMName& name) | CIMName& name) |
{ | { |
/* See ../Server/CIMOperationResponseEncoder.cpp */ | /* See ../Server/CIMOperationResponseEncoder.cpp */ |
|
|
static const CIMName NAME("EnumerateInstances"); | static const CIMName NAME("EnumerateInstances"); |
name = NAME; | name = NAME; |
| |
if (msg->resolveCallback && msg->binaryEncoding) |
data.encodeBinaryResponse(out); |
{ |
|
const Array<Uint8>& data = msg->binaryData; |
|
out.putBytes((char*)data.getData(), data.size()); |
|
} |
|
else |
|
{ |
|
out.putInstanceA(msg->getNamedInstances(), false); |
|
} |
|
} | } |
| |
static CIMEnumerateInstancesResponseMessage* _decodeEnumerateInstancesResponse( | static CIMEnumerateInstancesResponseMessage* _decodeEnumerateInstancesResponse( |
|
|
Uint32 flags, | Uint32 flags, |
const String& messageId) | const String& messageId) |
{ | { |
/* See ../Client/CIMOperationResponseDecoder.cpp */ |
|
|
|
Array<CIMInstance> instances; |
|
|
|
while (in.more()) |
|
{ |
|
Array<CIMInstance> tmp; |
|
|
|
if (!in.getInstanceA(tmp)) |
|
return 0; |
|
|
|
instances.append(tmp.getData(), tmp.size()); |
|
} |
|
|
|
CIMEnumerateInstancesResponseMessage* msg; | CIMEnumerateInstancesResponseMessage* msg; |
CIMException cimException; | CIMException cimException; |
| |
|
|
cimException, | cimException, |
QueueIdStack()); | QueueIdStack()); |
| |
msg->setNamedInstances(instances); |
// Instead of resolving the binary data right here, we delegate this |
|
// to a later point in time when the data is actually retrieved through |
|
// a call to getNamedInstances, which is going to resolve the binary |
|
// data when the callback function is registered. |
|
// This allows an alternate client implementation to gain direct access |
|
// to the binary data and pass this for example to the JNI implementation |
|
// of the JSR48 CIM Client for Java. |
|
CIMInstancesResponseData& responseData = msg->getResponseData(); |
|
responseData.setBinaryCimInstances(in,false); |
|
|
msg->binaryRequest = true; | msg->binaryRequest = true; |
return msg; | return msg; |
} | } |
|
|
messageId, | messageId, |
nameSpace, | nameSpace, |
instanceName, | instanceName, |
false, // Bug 1985 localOnly is deprecated |
|
#ifdef PEGASUS_DISABLE_INSTANCE_QUALIFIERS | #ifdef PEGASUS_DISABLE_INSTANCE_QUALIFIERS |
false, | false, |
#else | #else |
|
|
Uint32 flags, | Uint32 flags, |
const String& messageId) | const String& messageId) |
{ | { |
CIMInstance instance; |
|
|
|
if (!in.getInstance(instance)) |
|
return 0; |
|
|
|
CIMGetInstanceResponseMessage* msg; | CIMGetInstanceResponseMessage* msg; |
CIMException cimException; | CIMException cimException; |
| |
|
|
cimException, | cimException, |
QueueIdStack()); | QueueIdStack()); |
| |
msg->setCimInstance(instance); |
// Instead of resolving the binary data right here, we delegate this |
|
// to a later point in time when the data is actually retrieved through |
|
// a call to getNamedInstances, which is going to resolve the binary |
|
// data when the callback function is registered. |
|
// This allows an alternate client implementation to gain direct access |
|
// to the binary data and pass this for example to the JNI implementation |
|
// of the JSR48 CIM Client for Java. |
|
CIMInstanceResponseData& responseData = msg->getResponseData(); |
|
responseData.setBinaryCimInstance(in,false); |
|
|
msg->binaryRequest = true; | msg->binaryRequest = true; |
return msg; | return msg; |
} | } |
|
|
| |
Uint32 flags = 0; | Uint32 flags = 0; |
| |
if (msg->localOnly) |
|
flags |= LOCAL_ONLY; |
|
|
|
if (msg->includeQualifiers) | if (msg->includeQualifiers) |
flags |= INCLUDE_QUALIFIERS; | flags |= INCLUDE_QUALIFIERS; |
| |
|
|
| |
static void _encodeGetInstanceResponseBody( | static void _encodeGetInstanceResponseBody( |
CIMBuffer& out, | CIMBuffer& out, |
CIMGetInstanceResponseMessage* msg, |
CIMInstanceResponseData& data, |
CIMName& name) | CIMName& name) |
{ | { |
static const CIMName NAME("GetInstance"); | static const CIMName NAME("GetInstance"); |
name = NAME; | name = NAME; |
| |
if (msg->resolveCallback && msg->binaryEncoding) |
data.encodeBinaryResponse(out); |
{ |
|
const Array<Uint8>& data = msg->binaryData; |
|
out.putBytes((char*)data.getData(), data.size()); |
|
} |
|
else |
|
{ |
|
out.putInstance(msg->getCimInstance(), false, false); |
|
} |
|
} | } |
| |
//============================================================================== | //============================================================================== |
|
|
| |
static void _encodeAssociatorsResponseBody( | static void _encodeAssociatorsResponseBody( |
CIMBuffer& out, | CIMBuffer& out, |
CIMAssociatorsResponseMessage* msg, |
CIMObjectsResponseData& data, |
CIMName& name) | CIMName& name) |
{ | { |
/* See ../Server/CIMOperationResponseEncoder.cpp */ | /* See ../Server/CIMOperationResponseEncoder.cpp */ |
|
|
static const CIMName NAME("Associators"); | static const CIMName NAME("Associators"); |
name = NAME; | name = NAME; |
| |
out.putObjectA(msg->cimObjects); |
|
|
data.encodeBinaryResponse(out); |
} | } |
| |
static CIMAssociatorsResponseMessage* _decodeAssociatorsResponse( | static CIMAssociatorsResponseMessage* _decodeAssociatorsResponse( |
|
|
Uint32 flags, | Uint32 flags, |
const String& messageId) | const String& messageId) |
{ | { |
/* See ../Client/CIMOperationResponseDecoder.cpp */ |
|
|
|
Array<CIMObject> cimObjects; |
|
|
|
while (in.more()) |
|
{ |
|
Array<CIMObject> tmp; |
|
|
|
if (!in.getObjectA(tmp)) |
|
return 0; |
|
|
|
cimObjects.append(tmp.getData(), tmp.size()); |
|
} |
|
|
|
CIMAssociatorsResponseMessage* msg; | CIMAssociatorsResponseMessage* msg; |
CIMException cimException; | CIMException cimException; |
| |
msg = new CIMAssociatorsResponseMessage( | msg = new CIMAssociatorsResponseMessage( |
messageId, | messageId, |
cimException, | cimException, |
QueueIdStack(), |
QueueIdStack()); |
cimObjects); |
|
|
// Instead of resolving the binary data right here, we delegate this |
|
// to a later point in time when the data is actually retrieved through |
|
// a call to getNamedInstances, which is going to resolve the binary |
|
// data when the callback function is registered. |
|
// This allows an alternate client implementation to gain direct access |
|
// to the binary data and pass this for example to the JNI implementation |
|
// of the JSR48 CIM Client for Java. |
|
CIMObjectsResponseData& responseData = msg->getResponseData(); |
|
responseData.setBinaryCimObjects(in,false); |
| |
msg->binaryRequest = true; | msg->binaryRequest = true; |
return msg; | return msg; |
|
|
| |
static void _encodeExecQueryResponseBody( | static void _encodeExecQueryResponseBody( |
CIMBuffer& out, | CIMBuffer& out, |
CIMExecQueryResponseMessage* msg, |
CIMObjectsResponseData& data, |
CIMName& name) | CIMName& name) |
{ | { |
/* See ../Server/CIMOperationResponseEncoder.cpp */ | /* See ../Server/CIMOperationResponseEncoder.cpp */ |
|
|
static const CIMName NAME("ExecQuery"); | static const CIMName NAME("ExecQuery"); |
name = NAME; | name = NAME; |
| |
out.putObjectA(msg->cimObjects, false); |
data.encodeBinaryResponse(out); |
} | } |
| |
static CIMExecQueryResponseMessage* _decodeExecQueryResponse( | static CIMExecQueryResponseMessage* _decodeExecQueryResponse( |
|
|
Uint32 flags, | Uint32 flags, |
const String& messageId) | const String& messageId) |
{ | { |
/* See ../Client/CIMOperationResponseDecoder.cpp */ |
|
|
|
Array<CIMObject> cimObjects; |
|
|
|
while (in.more()) |
|
{ |
|
Array<CIMObject> tmp; |
|
|
|
if (!in.getObjectA(tmp)) |
|
return 0; |
|
|
|
cimObjects.append(tmp.getData(), tmp.size()); |
|
} |
|
|
|
CIMExecQueryResponseMessage* msg; | CIMExecQueryResponseMessage* msg; |
CIMException cimException; | CIMException cimException; |
| |
msg = new CIMExecQueryResponseMessage( | msg = new CIMExecQueryResponseMessage( |
messageId, | messageId, |
cimException, | cimException, |
QueueIdStack(), |
QueueIdStack()); |
cimObjects); |
|
|
// Instead of resolving the binary data right here, we delegate this |
|
// to a later point in time when the data is actually retrieved through |
|
// a call to getNamedInstances, which is going to resolve the binary |
|
// data when the callback function is registered. |
|
// This allows an alternate client implementation to gain direct access |
|
// to the binary data and pass this for example to the JNI implementation |
|
// of the JSR48 CIM Client for Java. |
|
CIMObjectsResponseData& responseData = msg->getResponseData(); |
|
responseData.setBinaryCimObjects(in,false); |
| |
msg->binaryRequest = true; | msg->binaryRequest = true; |
return msg; | return msg; |
|
|
CIMBuffer buf((char*)in.getData(), in.size()); | CIMBuffer buf((char*)in.getData(), in.size()); |
CIMBufferReleaser buf_(buf); | CIMBufferReleaser buf_(buf); |
| |
|
return decodeResponse(buf); |
|
} |
|
|
|
CIMResponseMessage* BinaryCodec::decodeResponse( |
|
CIMBuffer& buf) |
|
{ |
// Turn on validation: | // Turn on validation: |
#if defined(ENABLE_VALIDATION) | #if defined(ENABLE_VALIDATION) |
buf.setValidate(true); | buf.setValidate(true); |
|
|
{ | { |
case CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE: | case CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE: |
{ | { |
_encodeEnumerateInstancesResponseBody(buf, |
_encodeEnumerateInstancesResponseBody( |
(CIMEnumerateInstancesResponseMessage*)msg, name); |
buf, |
|
((CIMEnumerateInstancesResponseMessage*)msg)->getResponseData(), |
|
name); |
break; | break; |
} | } |
| |
|
|
| |
case CIM_GET_INSTANCE_RESPONSE_MESSAGE: | case CIM_GET_INSTANCE_RESPONSE_MESSAGE: |
{ | { |
_encodeGetInstanceResponseBody(buf, |
_encodeGetInstanceResponseBody( |
(CIMGetInstanceResponseMessage*)msg, name); |
buf, |
|
((CIMGetInstanceResponseMessage*)msg)->getResponseData(), |
|
name); |
break; | break; |
} | } |
| |
|
|
| |
case CIM_ASSOCIATORS_RESPONSE_MESSAGE: | case CIM_ASSOCIATORS_RESPONSE_MESSAGE: |
{ | { |
_encodeAssociatorsResponseBody(buf, |
_encodeAssociatorsResponseBody( |
(CIMAssociatorsResponseMessage*)msg, name); |
buf, |
|
((CIMAssociatorsResponseMessage*)msg)->getResponseData(), |
|
name); |
break; | break; |
} | } |
| |
|
|
| |
case CIM_EXEC_QUERY_RESPONSE_MESSAGE: | case CIM_EXEC_QUERY_RESPONSE_MESSAGE: |
{ | { |
_encodeExecQueryResponseBody(buf, |
_encodeExecQueryResponseBody( |
(CIMExecQueryResponseMessage*)msg, name); |
buf, |
|
((CIMExecQueryResponseMessage*)msg)->getResponseData(), |
|
name); |
break; | break; |
} | } |
| |