public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
{
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);
HarvestManager hm = gc.getBean(HarvestManager.class);
String id = Utils.getIdentifierFromParameters(params, context);
String rat = Util.getParam(params, Params.RATING);
String ip = context.getIpAddress();
int iLocalId = Integer.parseInt(id);
if (!dm.existsMetadata(iLocalId))
throw new IllegalArgumentException("Metadata not found --> " + id);
if (ip == null)
ip = "???.???.???.???";
if (!Lib.type.isInteger(rat))
throw new BadParameterEx(Params.RATING, rat);
int rating = Integer.parseInt(rat);
if (rating < 1 || rating > 5)
throw new BadParameterEx(Params.RATING, rat);
String harvUuid = getHarvestingUuid(context, id);
// look up value of localrating/enable
SettingManager settingManager = gc.getBean(SettingManager.class);
boolean localRating = settingManager.getValueAsBool("system/localrating/enable", false);
if (localRating || harvUuid == null)
//--- metadata is local, just rate it
rating = dm.rateMetadata(Integer.valueOf(id), ip, rating);
else
{
//--- the metadata is harvested, is type=geonetwork?
AbstractHarvester ah = hm.getHarvester(harvUuid);
if (ah.getType().equals(GeonetHarvester.TYPE)) {
String uuid = dm.getMetadataUuid(id);
rating = setRemoteRating(context, (GeonetParams) ah.getParams(), uuid, rating);
} else {