// Clean all before harvest : Remove/Add mechanism
// If harvest failed (ie. if node unreachable), metadata will be removed, and
// the node will not be referenced in the catalogue until next harvesting.
// TODO : define a rule for UUID in order to be able to do an update operation ?
UUIDMapper localUuids = new UUIDMapper(context.getBean(MetadataRepository.class), params.uuid);
// Try to load capabilities document
this.capabilitiesUrl = getBaseUrl(params.url) +
"SERVICE=" + params.ogctype.substring(0,3) +
"&VERSION=" + params.ogctype.substring(3) +
"&REQUEST=" + GETCAPABILITIES
;
if(log.isDebugEnabled()) {
log.debug("GetCapabilities document: " + this.capabilitiesUrl);
}
XmlRequest req = context.getBean(GeonetHttpRequestFactory.class).createXmlRequest();
req.setUrl(new URL(this.capabilitiesUrl));
req.setMethod(XmlRequest.Method.GET);
Lib.net.setupProxy(context, req);
if (params.useAccount) {
req.setCredentials(params.username, params.password);
}
xml = req.execute();
//-----------------------------------------------------------------------
//--- remove old metadata
for (String uuid : localUuids.getUUIDs())
{
String id = localUuids.getID (uuid);
if(log.isDebugEnabled()) log.debug (" - Removing old metadata before update with id: " + id);
// Remove thumbnails
unsetThumbnail (id);