private ScrapingHistory getViadeoConnectionWrapper(Document document) throws ParserConfigurationException, XPathExpressionException, ParseException { ScrapingHistory result = null; Node rootEle = getFirstElementByTagName(document, "ScrappingHistory"); if (rootEle != null) { result = new ScrapingHistory(); result.setDate(getDateFormat().parse(getAttributeValue((Element) rootEle, PROPERTY_DATE))); NodeList searchConnectionNodeList = getNodeList(document, "//ScrappingHistory/ViadeoSearch"); for (int indexSearchCon = 0; indexSearchCon < searchConnectionNodeList.getLength(); indexSearchCon++) { Node searchConnectionNode = searchConnectionNodeList.item(indexSearchCon); UrlConnectionWrapper searchConnection = new UrlConnectionWrapper(); searchConnection.setUrl(getAttributeValue((Element) searchConnectionNode, PROPERTY_URL)); searchConnection.setUserAgent( getAttributeValue((Element) searchConnectionNode, PROPERTY_USERAGENT)); searchConnection.setReferer( getAttributeValue((Element) searchConnectionNode, PROPERTY_REFERER)); searchConnection.setMethod( Method.valueOf(getAttributeValue((Element) searchConnectionNode, PROPERTY_METHOD))); searchConnection.setScrapped( Boolean.valueOf((getAttributeValue((Element) searchConnectionNode, "scrapped")))); int timeOut = getRequestTimeout(); try { timeOut = (int) Float.parseFloat( getAttributeValue((Element) searchConnectionNode, PROPERTY_TIMEOUT)); } catch (NumberFormatException ex) { logger.error(ex.getMessage(), ex); } searchConnection.setTimeout(timeOut); NodeList postParamNodeList = getNodeList(searchConnectionNode, "PostParameterList/PostParameter"); for (int i = 0; i < postParamNodeList.getLength(); i++) { Element element = (Element) postParamNodeList.item(i); searchConnection.putPostParameter( element.getAttribute(PROPERTY_NAME), element.getAttribute(PROPERTY_VALUE)); } NodeList cookieNodeList = getNodeList(searchConnectionNode, "CookieList/Cookie"); for (int i = 0; i < cookieNodeList.getLength(); i++) { Element element = (Element) cookieNodeList.item(i); searchConnection.putCookie( element.getAttribute(PROPERTY_NAME), element.getAttribute(PROPERTY_VALUE)); } result.addSearchConnection(searchConnection); } } return result; }