use of org.apereo.cas.support.events.service.CasRegisteredServicePreSaveEvent in project cas by apereo.
the class CreateResourceBasedRegisteredServiceWatcher method accept.
@Override
public void accept(final File file) {
LOGGER.debug("New service definition [{}] was created. Locating service entry from cache...", file);
final Collection<RegisteredService> services = serviceRegistryDao.load(file);
services.stream().filter(Objects::nonNull).forEach(service -> {
if (serviceRegistryDao.findServiceById(service.getId()) != null) {
LOG_SERVICE_DUPLICATE.accept(service);
}
LOGGER.debug("Updating service definitions with [{}]", service);
serviceRegistryDao.publishEvent(new CasRegisteredServicePreSaveEvent(this, service));
serviceRegistryDao.update(service);
serviceRegistryDao.publishEvent(new CasRegisteredServiceSavedEvent(this, service));
});
}
use of org.apereo.cas.support.events.service.CasRegisteredServicePreSaveEvent in project cas by apereo.
the class AbstractServicesManager method save.
@Audit(action = "SAVE_SERVICE", actionResolverName = "SAVE_SERVICE_ACTION_RESOLVER", resourceResolverName = "SAVE_SERVICE_RESOURCE_RESOLVER")
@Override
public synchronized RegisteredService save(final RegisteredService registeredService, final boolean publishEvent) {
publishEvent(new CasRegisteredServicePreSaveEvent(this, registeredService));
final RegisteredService r = this.serviceRegistry.save(registeredService);
this.services.put(r.getId(), r);
saveInternal(registeredService);
if (publishEvent) {
publishEvent(new CasRegisteredServiceSavedEvent(this, r));
}
return r;
}
use of org.apereo.cas.support.events.service.CasRegisteredServicePreSaveEvent in project cas by apereo.
the class ModifyResourceBasedRegisteredServiceWatcher method accept.
@Override
public void accept(final File file) {
LOGGER.debug("New service definition [{}] was modified. Locating service entry from cache...", file);
final Collection<RegisteredService> newServices = serviceRegistryDao.load(file);
newServices.stream().filter(Objects::nonNull).forEach(newService -> {
final RegisteredService oldService = serviceRegistryDao.findServiceById(newService.getId());
if (!newService.equals(oldService)) {
LOGGER.debug("Updating service definitions with [{}]", newService);
serviceRegistryDao.publishEvent(new CasRegisteredServicePreSaveEvent(this, newService));
serviceRegistryDao.update(newService);
serviceRegistryDao.publishEvent(new CasRegisteredServiceSavedEvent(this, newService));
} else {
LOGGER.debug("Service [{}] loaded from [{}] is identical to the existing entry. Entry may have already been saved " + "in the event processing pipeline", newService.getId(), file.getName());
}
});
}
Aggregations