HP-RK Bugzilla 1079 (Mismanaged messages in IndicationHandlerService and CIMExportReq...
authorkumpf <kumpf>
Fri, 21 Nov 2003 01:12:03 +0000 (01:12 +0000)
committerkumpf <kumpf>
Fri, 21 Nov 2003 01:12:03 +0000 (01:12 +0000)
src/Pegasus/ExportServer/CIMExportRequestDispatcher.cpp
src/Pegasus/ExportServer/CIMExportRequestDispatcher.h
src/Pegasus/HandlerService/IndicationHandlerService.cpp
src/Pegasus/HandlerService/IndicationHandlerService.h

index 02c7e948af4b353b105a47a283463574ede6cfe0..35565971d1833230e27bfe85871ad680fdc00ff7 100644 (file)
@@ -84,6 +84,8 @@ void CIMExportRequestDispatcher::_handle_async_request(AsyncRequest *req)
    PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
       "CIMExportRequestDispatcher::_handle_async_request");
 
+    PEGASUS_ASSERT(req != 0 && req->op != 0 );
+
     if ( req->getType() == async_messages::CIMSERVICE_STOP )
     {
         req->op->processing();
@@ -91,18 +93,31 @@ void CIMExportRequestDispatcher::_handle_async_request(AsyncRequest *req)
     }
     else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
     {
-       try 
-       {
         req->op->processing();
-        Message *legacy = (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
-       handleEnqueue(legacy);
-       }
-       catch(Exception & )
-       {
-         _make_response(req, async_results::CIM_NAK);
-       }
-        PEG_METHOD_EXIT();
-        return;
+        Message *legacy =
+            (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
+        if (legacy->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
+        {
+            Message* legacy_response = _handleExportIndicationRequest(
+                (CIMExportIndicationRequestMessage*) legacy);
+            AsyncLegacyOperationResult *async_result =
+                new AsyncLegacyOperationResult(
+                    req->getKey(),
+                    req->getRouting(),
+                    req->op,
+                    legacy_response);
+
+            _complete_op_node(req->op, ASYNC_OPSTATE_COMPLETE, 0, 0);
+            delete legacy;
+        }
+        else
+        {
+            Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
+                "CIMExportRequestDispatcher::_handle_async_request got "
+                    "unexpected legacy message type '%u'", legacy->getType());
+           _make_response(req, async_results::CIM_NAK);
+            delete legacy;
+        }
     }
     else
     {
@@ -111,10 +126,15 @@ void CIMExportRequestDispatcher::_handle_async_request(AsyncRequest *req)
     PEG_METHOD_EXIT();
 }
 
+// This callback method is currently unused.  ExportIndication messages
+// are passed to the ProviderManager using SendWait rather than SendAsync
+// so the responses can be routed correctly.
 void CIMExportRequestDispatcher::_forwardRequestCallback(AsyncOpNode *op, 
                                                         MessageQueue *q, 
                                                         void *parm)
 {
+   PEGASUS_ASSERT(0);
+#if 0
    CIMExportRequestDispatcher *service = 
       static_cast<CIMExportRequestDispatcher *>(q);
 
@@ -127,19 +147,22 @@ void CIMExportRequestDispatcher::_forwardRequestCallback(AsyncOpNode *op,
 
     if(msgType == async_messages::ASYNC_LEGACY_OP_RESULT)
     {
-        response = reinterpret_cast<CIMResponseMessage *>
-            ((static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result())
-;
+        response = reinterpret_cast<CIMResponseMessage *>(
+            (static_cast<AsyncLegacyOperationResult *>(asyncReply))->
+                get_result());
     }
     else if(msgType == async_messages::ASYNC_MODULE_OP_RESULT)
     {
-        response = reinterpret_cast<CIMResponseMessage *>
-            ((static_cast<AsyncModuleOperationResult *>(asyncReply))->get_result())
-;
+        response = reinterpret_cast<CIMResponseMessage *>(
+            (static_cast<AsyncModuleOperationResult *>(asyncReply))->
+                get_result());
     }
     else
     {
         // Error
+        Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
+            "CIMExportRequestDispatcher::_forwardRequestCallback got "
+                "unexpected message type '%u'", msgType);
     }
 
    PEGASUS_ASSERT(response != 0);
@@ -163,6 +186,7 @@ void CIMExportRequestDispatcher::_forwardRequestCallback(AsyncOpNode *op,
     delete asyncReply;
     op->release();
     service->return_op(op);
+#endif
 }
 
 void CIMExportRequestDispatcher::handleEnqueue(Message* message)
@@ -179,13 +203,21 @@ void CIMExportRequestDispatcher::handleEnqueue(Message* message)
     switch (message->getType())
     {
        case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
-           _handleExportIndicationRequest(
-               (CIMExportIndicationRequestMessage*) message);
+        {
+            CIMExportIndicationResponseMessage* response =
+                _handleExportIndicationRequest(
+                    (CIMExportIndicationRequestMessage*) message);
+            SendForget(response);
            break;
+        }
 
         default:
+            Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
+                "CIMExportRequestDispatcher::handleEnqueue got unexpected "
+                    "message type '%u'", message->getType());
             break;
     }
+
     delete message;
 
     PEG_METHOD_EXIT();
@@ -205,7 +237,8 @@ void CIMExportRequestDispatcher::handleEnqueue()
 }
 
 
-void CIMExportRequestDispatcher::_handleExportIndicationRequest(
+CIMExportIndicationResponseMessage*
+CIMExportRequestDispatcher::_handleExportIndicationRequest(
     CIMExportIndicationRequestMessage* request)
 {
     PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP,
@@ -219,9 +252,6 @@ void CIMExportRequestDispatcher::_handleExportIndicationRequest(
     find_services(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 0, 0, &serviceIds);
     PEGASUS_ASSERT(serviceIds.size() != 0);
 
-    CIMExportIndicationRequestMessage* request_copy =
-       new CIMExportIndicationRequestMessage(*request);
     AsyncOpNode * op = this->get_op();
 
     AsyncLegacyOperationStart * asyncRequest =
@@ -229,28 +259,31 @@ void CIMExportRequestDispatcher::_handleExportIndicationRequest(
            get_next_xid(),
            op,
            serviceIds[0],
-           request_copy,
+           new CIMExportIndicationRequestMessage(*request),
            this->getQueueId());
 
     asyncRequest->dest = serviceIds[0];
 
-    SendAsync(op,
-             serviceIds[0],
-             CIMExportRequestDispatcher::_forwardRequestCallback,
-             this,
-             (void *)request->queueIds.top());
-
-
-    //
-    //  Set response destination
-    //
-    PEG_TRACE_STRING(TRC_EXP_REQUEST_DISP, Tracer::LEVEL4, 
-                    "CIMExportRequestDispatcher setting export indication response dest " +
-                    ((MessageQueue::lookup(request->queueIds.top())) ? 
-                     String( ((MessageQueue::lookup(request->queueIds.top()))->getQueueName()) ) : 
-                     String("BAD queue name")));
-    
+    //SendAsync(op,
+    //          serviceIds[0],
+    //          CIMExportRequestDispatcher::_forwardRequestCallback,
+    //          this,
+    //          (void *)request->queueIds.top());
+    AsyncReply *asyncReply = SendWait(asyncRequest);
+
+    CIMExportIndicationResponseMessage* response =
+        reinterpret_cast<CIMExportIndicationResponseMessage *>(
+            (static_cast<AsyncLegacyOperationResult *>(
+                asyncReply))->get_result());
+    response->dest = request->queueIds.top();
+    response->synch_response(request);
+
+    delete asyncReply;    // Recipient deletes request
+    op->release();
+    this->return_op(op);
+
     PEG_METHOD_EXIT();
+    return response;
 }
 
 PEGASUS_NAMESPACE_END
index 76ef6e0ee9284fdbf8b0dce5c69bc158b3085eaf..afbeaeb5ee98ca10d0143cf0eeb5655a61d8f8a2 100644 (file)
@@ -27,6 +27,7 @@
 //
 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 //             Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
+//             Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //
 //%/////////////////////////////////////////////////////////////////////////////
 
@@ -76,8 +77,8 @@ class PEGASUS_EXPORT_SERVER_LINKAGE CIMExportRequestDispatcher
 
    private:
 
-      void _handleExportIndicationRequest(
-        CIMExportIndicationRequestMessage* request);
+      CIMExportIndicationResponseMessage* _handleExportIndicationRequest(
+         CIMExportIndicationRequestMessage* request);
 
       Boolean _dynamicReg;
       Boolean _staticConsumers;
index c014531b77742992ca8dc3fac84b0d0b04300757..6891d28bd09a5bd4eabda4301e69ce36676dcc29 100644 (file)
@@ -27,7 +27,8 @@
 //
 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 //                (carolann_graves@hp.com)
-//           : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
+//              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
+//              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //
 //%/////////////////////////////////////////////////////////////////////////////
 
@@ -62,56 +63,88 @@ IndicationHandlerService::IndicationHandlerService(CIMRepository* repository)
 
 void IndicationHandlerService::_handle_async_request(AsyncRequest *req)
 {
-   if ( req->getType() == async_messages::CIMSERVICE_STOP )
-   {
-      req->op->processing();
-      handle_CimServiceStop(static_cast<CimServiceStop *>(req));
-   }
-   else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
-   {
-      req->op->processing();
-      Message *legacy = (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
-      handleEnqueue(legacy);
-      return;
-   }
-   else
-      Base::_handle_async_request(req);
+    if ( req->getType() == async_messages::CIMSERVICE_STOP )
+    {
+        req->op->processing();
+        handle_CimServiceStop(static_cast<CimServiceStop *>(req));
+    }
+    else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
+    {
+        req->op->processing();
+        Message *legacy =
+            (static_cast<AsyncLegacyOperationStart *>(req)->get_action());
+        if (legacy->getType() == CIM_HANDLE_INDICATION_REQUEST_MESSAGE)
+        {
+            Message* legacy_response = _handleIndication(
+                (CIMHandleIndicationRequestMessage*) legacy);
+            AsyncLegacyOperationResult *async_result =
+                new AsyncLegacyOperationResult(
+                    req->getKey(),
+                    req->getRouting(),
+                    req->op,
+                    legacy_response);
+
+            _complete_op_node(req->op, ASYNC_OPSTATE_COMPLETE, 0, 0);
+            delete legacy;
+        }
+        else
+        {
+            Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
+                "IndicationHandlerService::_handle_async_request got "
+                    "unexpected legacy message type '%u'", legacy->getType());
+            _make_response(req, async_results::CIM_NAK);
+            delete legacy;
+        }
+    }
+    else
+    {
+        Base::_handle_async_request(req);
+    }
 }
 
 void IndicationHandlerService::handleEnqueue(Message* message)
 {
-   if( ! message )
-      return;
-   
+    if (!message)
+    {
+        return;
+    }
+
 // l10n
-   // Set the client's requested language into this service thread.
-   // This will allow functions in this service to return messages
-   // in the correct language.
-   CIMMessage * msg = dynamic_cast<CIMMessage *>(message);
-   if (msg != NULL)
-   {
-       if (msg->thread_changed())
+    // Set the client's requested language into this service thread.
+    // This will allow functions in this service to return messages
+    // in the correct language.
+    CIMMessage * msg = dynamic_cast<CIMMessage *>(message);
+    if (msg != NULL)
+    {
+        if (msg->thread_changed())
         {
-          AcceptLanguages *langs = 
-                       new AcceptLanguages(msg->acceptLanguages);      
-          Thread::setLanguages(langs);                 
+            AcceptLanguages *langs = new AcceptLanguages(msg->acceptLanguages);
+            Thread::setLanguages(langs);
+        }
+    }
+    else
+    {
+        Thread::clearLanguages();
+    }
+
+    switch (message->getType())
+    {
+        case CIM_HANDLE_INDICATION_REQUEST_MESSAGE:
+        {
+            CIMHandleIndicationResponseMessage* response = _handleIndication(
+                (CIMHandleIndicationRequestMessage*) message);
+            SendForget(response);
+            break;
         }
-   }  
-   else
-   {
-               Thread::clearLanguages();
-   }       
 
-   switch (message->getType())
-   {
-      case CIM_HANDLE_INDICATION_REQUEST_MESSAGE:
-        _handleIndication(message);
-        break;
-   
-      default:
-        break;
-   }
-   delete message;
+        default:
+            Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
+                "IndicationHandlerService::handleEnqueue got unexpected "
+                    "message type '%u'", message->getType());
+            break;
+    }
+
+    delete message;
 }
 
 void IndicationHandlerService::handleEnqueue()
@@ -119,16 +152,22 @@ void IndicationHandlerService::handleEnqueue()
    Message * message = dequeue();
 
    PEGASUS_ASSERT(message != 0);
-   if( message )
-      handleEnqueue(message);
+   if (message)
+   {
+       handleEnqueue(message);
+   }
 }
 
-
-void IndicationHandlerService::_handleIndicationCallBack(AsyncOpNode *op, 
-                                                        MessageQueue *q, 
-                                                        void *parm)
+// This callback method is currently unused.  ExportIndication messages
+// are passed to the CIMExportRequestDispatcher using SendWait rather than
+// SendAsync so the responses can be routed correctly.
+void IndicationHandlerService::_handleIndicationCallBack(AsyncOpNode *op,
+                                                         MessageQueue *q,
+                                                         void *parm)
 {
-   IndicationHandlerService *service = 
+   PEGASUS_ASSERT(0);
+#if 0
+   IndicationHandlerService *service =
       static_cast<IndicationHandlerService *>(q);
 
    AsyncRequest *asyncRequest = static_cast<AsyncRequest *>(op->get_request());
@@ -139,7 +178,7 @@ void IndicationHandlerService::_handleIndicationCallBack(AsyncOpNode *op,
       ((static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
    PEGASUS_ASSERT(response != 0);
    // ensure that the destination queue is in response->dest
-#ifdef PEGASUS_ARCHITECTURE_IA64   
+#ifdef PEGASUS_ARCHITECTURE_IA64
    response->dest = (Uint64)parm;
 #elif PEGASUS_PLATFORM_AIX_RS_IBMCXX
    // We cast to unsigned long
@@ -153,187 +192,197 @@ void IndicationHandlerService::_handleIndicationCallBack(AsyncOpNode *op,
    delete asyncReply;
 //   op->release();
 //   service->return_op(op);
+#endif
 }
 
 
 String IndicationHandlerService::_parseDestination(String dest)
 {
-       CString pCString = dest.getCStringUTF8();
-  char* p = const_cast<char*>((const char*) pCString);
-
-       static char schemeType[] = "HTTP:";     
-       Boolean hasSchemeType = true;
-       for(int i= 0; i<5; i++)
-       {
-               if(::toupper(p[i]) != schemeType[i])
-               {
-                       hasSchemeType = false;
-                       break;
-               }
-       }
-       if(hasSchemeType)
-       {
-               p += 5;
-       }
-
-  // See if there is a host name begins with "//":
-  if (p[0] == '/' && p[1] == '/')
-  {
-               p += 2;
-       }
-       return String(p);
+    CString pCString = dest.getCStringUTF8();
+    char* p = const_cast<char*>((const char*) pCString);
+
+    static char schemeType[] = "HTTP:";
+    Boolean hasSchemeType = true;
+    for(int i= 0; i<5; i++)
+    {
+        if(::toupper(p[i]) != schemeType[i])
+        {
+            hasSchemeType = false;
+            break;
+        }
+    }
+    if(hasSchemeType)
+    {
+        p += 5;
+    }
+
+    // See if there is a host name begins with "//":
+    if (p[0] == '/' && p[1] == '/')
+    {
+        p += 2;
+    }
+    return String(p);
 }
 
-void IndicationHandlerService::_handleIndication(const Message* message)
+CIMHandleIndicationResponseMessage*
+IndicationHandlerService::_handleIndication(
+    CIMHandleIndicationRequestMessage* request)
 {
-       PEG_METHOD_ENTER (TRC_IND_HANDLE,
-                    "IndicationHandlerService::_handleIndication");
-
-   CIMHandleIndicationRequestMessage* request = 
-      (CIMHandleIndicationRequestMessage*) message;
-
-   CIMException cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_SUCCESS, String::EMPTY);
-
-   CIMName className = request->handlerInstance.getClassName();
-    
-   CIMNamespaceName nameSpace = request->nameSpace;
-
-   CIMInstance indication = request->indicationInstance;
-   CIMInstance handler = request->handlerInstance;
-
-   Uint32 pos = PEG_NOT_FOUND;
-
-   if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) 
-                || className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML)
-        )
-   {
-       pos = handler.findProperty(CIMName ("destination"));
-   }
-   else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
-   {
-       pos = handler.findProperty(CIMName ("TargetHost"));
-   }
-
-   if (pos == PEG_NOT_FOUND)
-   {
-     // l10n
-     // cimException = 
-     //   PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("Handler without destination"));
-
-     cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, 
-                                           MessageLoaderParms("HandlerService.IndicationHandlerService.HANDLER_WITHOUT_DESTINATION", "Handler without destination"));
-   }
-   else
-   {
-       CIMProperty prop = handler.getProperty(pos);
-       String destination = prop.getValue().toString();
-
-
-                        //filter out http:// // ATTN: Do not enable yet.
-                       // destination = _parseDestination(destination);
-
-       if (destination.size() == 0)
-       {
-        // l10n
-
-        // cimException = 
-        //   PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("invalid destination"));
+    PEG_METHOD_ENTER (TRC_IND_HANDLE,
+                      "IndicationHandlerService::_handleIndication");
+
+    CIMException cimException =
+        PEGASUS_CIM_EXCEPTION(CIM_ERR_SUCCESS, String::EMPTY);
+
+    CIMName className = request->handlerInstance.getClassName();
+    CIMNamespaceName nameSpace = request->nameSpace;
+
+    CIMInstance indication = request->indicationInstance;
+    CIMInstance handler = request->handlerInstance;
+
+    Uint32 pos = PEG_NOT_FOUND;
+
+    if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) ||
+        className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))
+    {
+        pos = handler.findProperty(CIMName ("destination"));
+    }
+    else if (className.equal (PEGASUS_CLASSNAME_INDHANDLER_SNMP))
+    {
+        pos = handler.findProperty(CIMName ("TargetHost"));
+    }
+
+    if (pos == PEG_NOT_FOUND)
+    {
+        // l10n
+        // cimException =
+        //   PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("Handler without destination"));
+
+        cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
+            MessageLoaderParms("HandlerService.IndicationHandlerService."
+                "HANDLER_WITHOUT_DESTINATION", "Handler without destination"));
+    }
+    else
+    {
+        CIMProperty prop = handler.getProperty(pos);
+        String destination = prop.getValue().toString();
+
+        //filter out http:// // ATTN: Do not enable yet.
+        // destination = _parseDestination(destination);
+
+        if (destination.size() == 0)
+        {
+            // l10n
 
-           cimException = 
-               PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, 
-                                           MessageLoaderParms("HandlerService.IndicationHandlerService.INVALID_DESTINATION", "invalid destination"));
+            // cimException =
+            //   PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("invalid destination"));
 
-       }
-       else if ((className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML)
-                                || className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML)
-                                ) &&
+            cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
+                MessageLoaderParms("HandlerService.IndicationHandlerService."
+                    "INVALID_DESTINATION", "invalid destination"));
+        }
+        else if ((className.equal (PEGASUS_CLASSNAME_INDHANDLER_CIMXML) ||
+                  className.equal (PEGASUS_CLASSNAME_LSTNRDST_CIMXML)) &&
 //compared index 10 is not :
-           (destination.subString(0, 10) == String("localhost/")))
-       {
-          Array<Uint32> exportServer;
-
-          find_services(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER, 0, 0, &exportServer);
-
-          // Listener is build with Cimom, so send message to ExportServer
-       
-          CIMExportIndicationRequestMessage* exportmessage =
-            new CIMExportIndicationRequestMessage(
-               "1234",
-               destination.subString(21), //taking localhost/CIMListener portion out from reg
-               indication,
-               QueueIdStack(exportServer[0], getQueueId()),
-               String::EMPTY,
-               String::EMPTY,
-               request->contentLanguages);
-       
-          AsyncOpNode* op = this->get_op();
-
-          AsyncLegacyOperationStart *req =
-            new AsyncLegacyOperationStart(
-               get_next_xid(),
-               op,
-               exportServer[0],
-               exportmessage,
-               _queueId);
-
-          PEG_TRACE_STRING(TRC_IND_HANDLE, Tracer::LEVEL4, 
-                      "Indication handler forwarding message to " +
-                      ((MessageQueue::lookup(exportServer[0])) ? 
-                       String( ((MessageQueue::lookup(exportServer[0]))->getQueueName()) ) : 
-                       String("BAD queue name")));
-            
-          SendAsync(op, 
-               exportServer[0],
-               IndicationHandlerService::_handleIndicationCallBack,
-               this, 
-               (void *)request->queueIds.top());
-
-       }
-       else
-       {
-                                
-          // generic handler. So load it and let it to do.
-          CIMHandler* handlerLib = _lookupHandlerForClass(className);
-
-          if (handlerLib)
-          {
-             try
-             {
-                  handlerLib->handleIndication(
-                       request->operationContext,
-                       handler,
-                       indication,
-                       nameSpace.getString(),
-                   request->contentLanguages);
-             }
-             catch(CIMException& e)
-             {
-                   cimException =
-                       PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
-             }
-          }
-          else {
-
-           // l10n
-
-           // cimException =
-           // PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("Failed to load Handler"));
-
-             cimException =
-                PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, 
-                                           MessageLoaderParms("HandlerService.IndicationHandlerService.FAILED_TO_LOAD", "Failed to load Handler"));
-
-         }
-       }
-   }
+                 (destination.subString(0, 10) == String("localhost/")))
+        {
+            Array<Uint32> exportServer;
+
+            find_services(PEGASUS_QUEUENAME_EXPORTREQDISPATCHER, 0, 0,
+                          &exportServer);
+
+            // Listener is build with Cimom, so send message to ExportServer
+
+            CIMExportIndicationRequestMessage* exportmessage =
+                new CIMExportIndicationRequestMessage(
+                    XmlWriter::getNextMessageId(),
+                    destination.subString(21), //taking localhost/CIMListener portion out from reg
+                    indication,
+                    QueueIdStack(exportServer[0], getQueueId()),
+                    String::EMPTY,
+                    String::EMPTY,
+                    request->contentLanguages);
+
+            AsyncOpNode* op = this->get_op();
+
+            AsyncLegacyOperationStart *asyncRequest =
+                new AsyncLegacyOperationStart(
+                    get_next_xid(),
+                    op,
+                    exportServer[0],
+                    exportmessage,
+                    _queueId);
+
+            PEG_TRACE_STRING(TRC_IND_HANDLE, Tracer::LEVEL4,
+               "Indication handler forwarding message to " +
+               ((MessageQueue::lookup(exportServer[0])) ?
+                   String( ((MessageQueue::lookup(exportServer[0]))->
+                       getQueueName()) ) :
+                   String("BAD queue name")));
+
+            //SendAsync(op,
+            //      exportServer[0],
+            //      IndicationHandlerService::_handleIndicationCallBack,
+            //      this,
+            //      (void *)request->queueIds.top());
+            AsyncReply *asyncReply = SendWait(asyncRequest);
+
+            // Return the ExportIndication results in HandleIndication response
+            CIMExportIndicationResponseMessage* exportResponse =
+                reinterpret_cast<CIMExportIndicationResponseMessage *>(
+                    (static_cast<AsyncLegacyOperationResult *>(
+                        asyncReply))->get_result());
+            cimException = exportResponse->cimException;
+
+            delete exportResponse;
+            delete asyncReply;
+            op->release();
+            this->return_op(op);
+        }
+        else
+        {
+            // generic handler. So load it and let it to do.
+            CIMHandler* handlerLib = _lookupHandlerForClass(className);
+
+            if (handlerLib)
+            {
+                try
+                {
+                    handlerLib->handleIndication(
+                        request->operationContext,
+                        handler,
+                        indication,
+                        nameSpace.getString(),
+                    request->contentLanguages);
+                }
+                catch(CIMException& e)
+                {
+                    cimException =
+                        PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
+                }
+            }
+            else
+            {
+                // l10n
+
+                // cimException =
+                // PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String("Failed to load Handler"));
+
+                cimException = PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
+                    MessageLoaderParms("HandlerService."
+                        "IndicationHandlerService.FAILED_TO_LOAD",
+                        "Failed to load Handler"));
+            }
+        }
+    }
 
-   CIMHandleIndicationResponseMessage* response =
-         new CIMHandleIndicationResponseMessage(
+    CIMHandleIndicationResponseMessage* response =
+        new CIMHandleIndicationResponseMessage(
             request->messageId,
             cimException,
             request->queueIds.copyAndPop());
 
-    _enqueueResponse(request, response);
+    return response;
 }
 
 CIMHandler* IndicationHandlerService::_lookupHandlerForClass(
@@ -357,7 +406,7 @@ CIMHandler* IndicationHandlerService::_lookupHandlerForClass(
       handler = _handlerTable.loadHandler(handlerId);
 
       if (!handler)
-        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
+          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
 
       handler->initialize(_repository);
    }
index 8c19aba3ff999921806c2c6a0a8733041c927f20..21846b8e6f2c88b83fbd3637914adefe098b8e55 100644 (file)
@@ -27,6 +27,7 @@
 //
 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 //                (carolann_graves@hp.com)
+//              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //
 //%/////////////////////////////////////////////////////////////////////////////
 
 
 #include <Pegasus/Common/Config.h>
 #include <sys/types.h>
-//#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
-//#else
-//#include <unistd.h>
-//#endif 
 #include <iostream>
 #include <stdio.h>
 #include <string.h>
 
 #include <Pegasus/Common/Config.h>
-#include <Pegasus/Common/InternalException.h>
-#include <Pegasus/Common/DQueue.h>
-#include <Pegasus/Common/Thread.h>
-#include <Pegasus/Common/ArrayInternal.h>
 #include <Pegasus/Common/AsyncOpNode.h>
-#include <Pegasus/Common/CimomMessage.h>
-#include <Pegasus/Common/Cimom.h>
 #include <Pegasus/Common/MessageQueueService.h>
 #include <Pegasus/Common/CIMMessage.h>
-#include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Handler/CIMHandler.h>
 #include <Pegasus/Repository/CIMRepository.h>
 
@@ -91,7 +81,8 @@ class PEGASUS_HANDLER_SERVICE_LINKAGE IndicationHandlerService
 
    protected:
 
-      void _handleIndication(const Message* message);
+      CIMHandleIndicationResponseMessage* _handleIndication(
+          CIMHandleIndicationRequestMessage* request);
 
       HandlerTable _handlerTable;