// no search criteria supported in csw harvest, leave empty
Element searches = new Element("searches");
node.addContent(searches);
// no privileges settings supported in csw harvest; use GN-specific setting (if enabled, make metadata public)
GeonetContext geonetContext = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
SettingManager sm = geonetContext.getBean(SettingManager.class);
boolean metadataPublic = sm.getValueAsBool("system/csw/metadataPublic", false);
if(metadataPublic) {
// <privileges>
// <group id="1">
// <operation name="view" />
// <operation name="dynamic" />
// <operation name="featured" />
// </group>
// </privileges>
Element privileges = new Element("privileges");
Element group = new Element("group");
group.setAttribute("id", "1");
Element operation1 = new Element("operation");
operation1.setAttribute("name", "view");
group.addContent(operation1);
Element operation2 = new Element("operation");
operation2.setAttribute("name", "dynamic");
group.addContent(operation2);
Element operation3 = new Element("operation");
operation3.setAttribute("name", "featured");
group.addContent(operation3);
privileges.addContent(group);
node.addContent(privileges);
}
/*
heikki: not so easy as we can't identify harvesters from their target url or anything else
for the moment, no updates take place, the harvester is simply saved
// Check if harvester already exist
// FIXME : Unable to find the getHarvesterID method from patch provided for now id is null
// String id = hm.getHarvesterID(source);
// Here we should do an update of an existing node if exist.
// if (id == null) {
//
// } else {
// node.setAttribute("id", id);
// if (!hm.update(dbms, node))
// return null;
// }
*/
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
HarvestManager hm = gc.getBean(HarvestManager.class);
String uuid = hm.addHarvesterReturnUUID(node);
node.setAttribute("uuid", uuid);
node.addContent(new Element("info"));
AbstractHarvester harvester = hm.getHarvester(uuid);
String id = harvester.getID();