All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.spi.remote.http.MapResponseHandler Maven / Gradle / Ivy

Go to download

bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com

There is a newer version: 6.3.5
Show newest version
package org.frameworkset.spi.remote.http;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.Map;

public class MapResponseHandler extends BaseResponseHandler implements ResponseHandler {

	public MapResponseHandler() {
		// TODO Auto-generated constructor stub
	}
	
	 @Override
     public Map handleResponse(final HttpResponse response)
             throws ClientProtocolException, IOException {
         int status = response.getStatusLine().getStatusCode();

         if (status >= 200 && status < 300) {
             HttpEntity entity = response.getEntity();
             return super.converJson(entity,Map.class);

			 //return entity != null ? EntityUtils.toString(entity) : null;
         } else {
             HttpEntity entity = response.getEntity();
             if (entity != null )
//            	 return SimpleStringUtil.json2Object(entity.getContent(), Map.class);
				 throw new HttpRuntimeException(EntityUtils.toString(entity));
             else
                 throw new HttpRuntimeException("Unexpected response status: " + status);
         }
     }
	
	

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy