Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.kingmed.dp.ndp.impl; import com.google.common.base.Strings; import java.io.IOException; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.jdom2.Element; import org.jdom2.JDOMException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author zhengjunjie */ public class UpdateLinkedFoldersResponseHandler extends NDPServeResponseHandler { private static final Logger log = LoggerFactory.getLogger(UpdateLinkedFoldersResponseHandler.class); @Override public String handleResponse(HttpResponse hr) throws ClientProtocolException, IOException { String responseBody = null; String status = null; try { responseBody = super.handleResponse(hr); if (responseBody == null) { log.warn(""); return status; } status = checkStatus(responseBody); //?? if (Strings.isNullOrEmpty(status) || !status.equals(NDPServeImpl.STATUS_SUCCEEDED)) { log.error(""); } } catch (Exception e) { log.error("", e); throw new IOException(e); } return status; } /** * ?NDP.serve?XML * * @param responseBody * @return true : NDP.serve??, * <br/> * false : NDP.serve ? * @throws Exception */ private String checkStatus(String responseBody) throws JDOMException, IOException { String status = null; String expression = "//" + NDPServeImpl.UPDATERESULT; List<Element> items = null; items = checkStatus(responseBody, expression); if (items == null) { log.warn("?"); return status; } for (Element itemElement : items) { status = itemElement.getChildText(NDPServeImpl.STATUS); log.info("Status=" + status); if (NDPServeImpl.STATUS_SUCCEEDED.equals(status)) { break; } //?500? //statusfailedmessage?? } return status; } }