Search in sources :

Example 1 with EventException

use of ddf.catalog.event.EventException in project ddf by codice.

the class RegistryStorePublisher method registryPublish.

void registryPublish(RegistryStore registryStore, String publish) {
    if (registryStore.getRegistryId().isEmpty()) {
        LOGGER.info(String.format("RegistryStore missing id. Unable to complete %s request.", publish));
        return;
    }
    executor.schedule(() -> {
        try {
            Security security = Security.getInstance();
            Optional<Metacard> registryIdentityMetacardOpt = security.runAsAdminWithException(() -> federationAdminService.getLocalRegistryIdentityMetacard());
            if (registryIdentityMetacardOpt.isPresent()) {
                Metacard registryIdentityMetacard = registryIdentityMetacardOpt.get();
                String localRegistryId = RegistryUtility.getRegistryId(registryIdentityMetacard);
                if (localRegistryId == null) {
                    throw new EventException();
                }
                security.runAsAdminWithException(() -> {
                    if (publish.equals(PUBLISH)) {
                        registryPublicationService.publish(localRegistryId, registryStore.getRegistryId());
                    } else {
                        registryPublicationService.unpublish(localRegistryId, registryStore.getRegistryId());
                    }
                    return null;
                });
            }
        } catch (Exception e) {
            LOGGER.debug("Failed to {} registry configuration to {}", publish, ((RegistryStoreImpl) registryStore).getId());
        }
    }, 3, TimeUnit.SECONDS);
}
Also used : Metacard(ddf.catalog.data.Metacard) EventException(ddf.catalog.event.EventException) Security(org.codice.ddf.security.common.Security) EventException(ddf.catalog.event.EventException)

Example 2 with EventException

use of ddf.catalog.event.EventException in project ddf by codice.

the class ExceptionsTest method testEventException.

@Test
public void testEventException() {
    EventException ee = new EventException();
    assertNotNull(ee);
    ee = new EventException(msg);
    assertEquals(ee.getMessage(), msg);
    ee = new EventException(testCause);
    assertEquals(ee.getCause(), testCause);
    ee = new EventException(msg, testCause);
    assertEquals(ee.getMessage(), msg);
    assertEquals(ee.getCause(), testCause);
}
Also used : EventException(ddf.catalog.event.EventException) Test(org.junit.Test)

Aggregations

EventException (ddf.catalog.event.EventException)2 Metacard (ddf.catalog.data.Metacard)1 Security (org.codice.ddf.security.common.Security)1 Test (org.junit.Test)1