package com.shopwiki.messaging.rpc;

import java.util.*;

import com.rabbitmq.client.AMQP.BasicProperties;
import com.shopwiki.messaging.*;

/**
 * Only used by the RpcClient
 *
 * @owner rstewart
 */
public class RpcResponse {

    private BasicProperties props;
    private MapMessage body; // Make generic ???
    private ResponseStatus status;

    public RpcResponse(BasicProperties props, MapMessage body) {
        this.props = props;
        this.body = body;

        Object statusObj = getHeaders().get("status");
        String statusStr = String.valueOf(statusObj);
        status = ResponseStatus.valueOf(statusStr);
    }

    public Map<String, Object> getHeaders() {
        Map<String,Object> headers = props.getHeaders();
        if (headers == null) {
            return Collections.emptyMap();
        }
        return headers;
    }

    public ResponseStatus getStatus() {
        return status;
    }

    public MapMessage getBody() {
        return body;
    }
}

@@ -51,16 +51,55 @@
 til.*;%0A%0A
+import com.google.common.collect.Maps;%0A
 import c
@@ -139,16 +139,16 @@
 erties;%0A
-
 import c
@@ -273,16 +273,22 @@
 private 
+final 
 BasicPro
@@ -314,16 +314,22 @@
 private 
+final 
 MapMessa
@@ -369,16 +369,22 @@
 private 
+final 
 Response
@@ -531,24 +531,24 @@
     
-Object
+String
  status
-Obj
+Str
  = g
@@ -578,62 +578,8 @@
 %22);%0A
-        String statusStr = String.valueOf(statusObj);%0A
     
@@ -656,22 +656,22 @@
 String, 
-Object
+String
 %3E getHea
@@ -820,24 +820,25 @@
       %7D%0A
+%0A
         
 return h
@@ -833,22 +833,221 @@
     
-return headers
+Map%3CString, String%3E map = Maps.newHashMap();%0A        for (Map.Entry%3CString, Object%3E entry : headers.entrySet()) %7B%0A            map.put(entry.getKey(), String.valueOf(entry.getValue()));%0A        %7D%0A        return map
 ;%0A  

Make the RpcResponse headers a map of strings, not Objects