public void doHarvest(Logger log) throws Exception
{
CategoryMapper localCateg = new CategoryMapper(context);
XmlRequest req = context.getBean(GeonetHttpRequestFactory.class).createXmlRequest(params.host);
servletName = req.getAddress();
Lib.net.setupProxy(context, req);
String name = getParams().name;
//--- login
if (params.useAccount)
{
log.info("Login into : "+ name);
req.setAddress(servletName +"/srv/en/"+ Geonet.Service.XML_LOGIN);
req.addParam("username", params.username);
req.addParam("password", params.password);
Element response = req.execute();
if (!response.getName().equals("ok"))
throw new UserNotFoundEx(params.username);
}
//--- search
result = new GeonetResult();
Aligner aligner = new Aligner(log, req, params, dataMan, context,
localCateg);
for(Search s : params.getSearches())
{
log.info("Searching on : "+ name +"/"+ s.siteId);
req.setAddress(servletName +"/srv/en/"+ Geonet.Service.XML_SEARCH);
Element searchResult = req.execute(s.createRequest());
if(log.isDebugEnabled()) log.debug("Obtained:\n"+Xml.getString(searchResult));
//--- site alignment
HarvestResult ar = aligner.align(searchResult, s.siteId);
//--- collect some stats
result.alResult.add(ar);
}
//--- logout
if (params.useAccount)
{
log.info("Logout from : "+ name);
req.clearParams();
req.setAddress("/"+ params.getServletPath() +"/srv/en/"+ Geonet.Service.XML_LOGOUT);
}
dataMan.flush();
}