filters.put(Params.FILTER_CATALOG, filterCatalog);
filters.put(Params.FILTER_GROUP, filterGroup);
filters.put(Params.FILTER_CATEGORY, filterCategory);
if (operation.equals(Params.Operation.NEWSERVICE)) {
Service service = serviceRepository.findOneByName(serviceName);
if (service != null) {
throw new IllegalArgumentException("Service with name "
+ serviceName + " already exists");
}
service = new org.fao.geonet.domain.Service();
service.setDescription(serviceDescription);
service.setClassName(className);
service.setName(serviceName);
for (Map.Entry<String, String> filter : filters.entrySet()) {
if (filter.getValue() != null && !filter.getValue().equals("")) {
service.getParameters().put(filter.getKey(), filter.getValue());
}
}
serviceRepository.save(service);
serviceId = String.valueOf(service.getId());
} else if (operation.equals(Params.Operation.UPDATESERVICE)) {
final Service service = serviceRepository.findOne(Integer.valueOf(serviceId));
service.setClassName(className);
service.setName(serviceName);
service.setDescription(serviceDescription);
for (Map.Entry<String, String> filter : filters.entrySet()) {
service.getParameters().put(filter.getKey(), filter.getValue());
}
serviceRepository.save(service);
}