@Override
public Element exec(Element params, ServiceContext context)
throws Exception {
GeonetContext gc = (GeonetContext) context
.getHandlerContext(Geonet.CONTEXT_NAME);
SettingManager settings = gc.getBean(SettingManager.class);
String sendTo = "";
for (Object o : params.getChildren()) {
Element param = ((Element) o);
if (param.getName().equalsIgnoreCase("recipient")) {
if (!param.getValue().trim().isEmpty()) {
if(sendTo.isEmpty()) {
sendTo = param.getValue().trim();
} else {
sendTo += "," + param.getValue().trim();
}
}
} else if (param.getName().equalsIgnoreCase("template")) {
settings.setValue("system/harvesting/mail/template",
param.getValue());
} else if (param.getName().equalsIgnoreCase("templateError")) {
settings.setValue("system/harvesting/mail/templateError",
param.getValue());
} else if (param.getName().equalsIgnoreCase("templateWarning")) {
settings.setValue("system/harvesting/mail/templateWarning",
param.getValue());
} else if (param.getName().equalsIgnoreCase("subject")) {
settings.setValue("system/harvesting/mail/subject",
param.getValue());
} else if (param.getName().equalsIgnoreCase("enabled")) {
settings.setValue("system/harvesting/mail/enabled",
param.getValue());
} else if (param.getName().equalsIgnoreCase("level1")) {
settings.setValue("system/harvesting/mail/level1",
param.getValue());
} else if (param.getName().equalsIgnoreCase("level2")) {
settings.setValue("system/harvesting/mail/level2",
param.getValue());
} else if (param.getName().equalsIgnoreCase("level3")) {
settings.setValue("system/harvesting/mail/level3",
param.getValue());
}
}
settings.setValue("system/harvesting/mail/recipient", sendTo);
return new Element("ok");
}