use of org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent in project cas by apereo.
the class ServiceRegistryConfigWatcher method handleCreateEvent.
/**
* Handle create event.
*
* @param file the file
*/
private void handleCreateEvent(final File file) {
//load the entry and add it to the map
final RegisteredService service = this.serviceRegistryDao.load(file);
if (service == null) {
LOGGER.warn("No service definition was loaded from [{}]", file);
return;
}
if (this.serviceRegistryDao.findServiceById(service.getId()) != null) {
LOGGER.warn("Found a service definition [{}] with a duplicate id [{}] in [{}]. " + "This will overwrite previous service definitions and is likely a " + "configuration problem. Make sure all services have a unique id and try again.", service.getServiceId(), service.getId(), file.getAbsolutePath());
}
this.serviceRegistryDao.update(service);
this.applicationEventPublisher.publishEvent(new CasRegisteredServicesRefreshEvent(this));
}
use of org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent in project cas by apereo.
the class ServiceRegistryConfigWatcher method handleDeleteEvent.
/**
* Handle delete event.
*/
private void handleDeleteEvent() {
this.serviceRegistryDao.load();
this.applicationEventPublisher.publishEvent(new CasRegisteredServicesRefreshEvent(this));
}
use of org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent in project cas by apereo.
the class RegisteredServicesEventListenerTests method verifyServiceExpirationWithRemovalEvent.
@Test
public void verifyServiceExpirationWithRemovalEvent() {
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
val contact = new DefaultRegisteredServiceContact();
contact.setName("Test");
contact.setEmail("casuser@example.org");
contact.setPhone("13477465421");
registeredService.getContacts().add(contact);
val listener = new DefaultRegisteredServicesEventListener(this.servicesManager, casProperties, communicationsManager);
listener.handleRefreshEvent(new CasRegisteredServicesRefreshEvent(this));
listener.handleEnvironmentChangeEvent(new EnvironmentChangeEvent(Set.of()));
val event = new CasRegisteredServiceExpiredEvent(this, registeredService, true);
listener.handleRegisteredServiceExpiredEvent(event);
}
use of org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent in project cas by apereo.
the class ServiceRegistryConfigWatcher method handleModifyEvent.
/**
* Handle modify event.
*
* @param file the file
*/
private void handleModifyEvent(final File file) {
final RegisteredService newService = this.serviceRegistryDao.load(file);
if (newService == null) {
LOGGER.warn("New service definition could not be loaded from [{}]", file.getAbsolutePath());
} else {
final RegisteredService oldService = this.serviceRegistryDao.findServiceById(newService.getId());
if (!newService.equals(oldService)) {
this.serviceRegistryDao.update(newService);
this.applicationEventPublisher.publishEvent(new CasRegisteredServicesRefreshEvent(this));
} 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