Search in sources :

Example 1 with CasRegisteredServicesRefreshEvent

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));
}
Also used : CasRegisteredServicesRefreshEvent(org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent)

Example 2 with CasRegisteredServicesRefreshEvent

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));
}
Also used : CasRegisteredServicesRefreshEvent(org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent)

Example 3 with CasRegisteredServicesRefreshEvent

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);
}
Also used : lombok.val(lombok.val) EnvironmentChangeEvent(org.springframework.cloud.context.environment.EnvironmentChangeEvent) CasRegisteredServicesRefreshEvent(org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent) CasRegisteredServiceExpiredEvent(org.apereo.cas.support.events.service.CasRegisteredServiceExpiredEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CasRegisteredServicesRefreshEvent

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());
        }
    }
}
Also used : CasRegisteredServicesRefreshEvent(org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent)

Aggregations

CasRegisteredServicesRefreshEvent (org.apereo.cas.support.events.service.CasRegisteredServicesRefreshEvent)4 lombok.val (lombok.val)1 CasRegisteredServiceExpiredEvent (org.apereo.cas.support.events.service.CasRegisteredServiceExpiredEvent)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 EnvironmentChangeEvent (org.springframework.cloud.context.environment.EnvironmentChangeEvent)1