use of org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException in project ddf by codice.
the class RegistryPublicationManagerTest method testInitFederationAdminException.
@Test
public void testInitFederationAdminException() throws Exception {
when(federationAdmin.getRegistryMetacards()).thenThrow(new FederationAdminException("Test error"));
publicationManager.init();
verify(executorService).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
publicationManager.destroy();
verify(executorService).shutdown();
}
use of org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException in project ddf by codice.
the class FederationAdmin method createLocalEntry.
@Override
public String createLocalEntry(Map<String, Object> registryMap) throws FederationAdminException {
Optional<RegistryPackageType> registryPackageOptional = registryTypeConverter.convert(registryMap);
RegistryPackageType registryPackage = registryPackageOptional.orElseThrow(() -> new FederationAdminException("Error creating local registry entry. Couldn't convert registry map to a registry package."));
if (!registryPackage.isSetHome()) {
registryPackage.setHome(SystemBaseUrl.getBaseUrl());
}
if (!registryPackage.isSetObjectType()) {
registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);
}
if (!registryPackage.isSetId()) {
String registryPackageId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
registryPackage.setId(registryPackageId);
}
updateDateFields(registryPackage);
Metacard metacard = getRegistryMetacardFromRegistryPackage(registryPackage);
metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true));
return federationAdminService.addRegistryEntry(metacard);
}
use of org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException in project ddf by codice.
the class FederationAdminServiceImpl method addRegistryEntries.
@Override
public List<String> addRegistryEntries(List<Metacard> metacards, Set<String> destinations) throws FederationAdminException {
validateRegistryMetacards(metacards);
List<String> registryIds;
Map<String, Serializable> properties = new HashMap<>();
CreateRequest createRequest = new CreateRequestImpl(metacards, properties, destinations);
try {
CreateResponse createResponse = security.runWithSubjectOrElevate(() -> catalogFramework.create(createRequest));
//loop through to get id's
if (!createResponse.getProcessingErrors().isEmpty()) {
throw new FederationAdminException("Processing error occurred while creating registry entry. Details:" + System.lineSeparator() + stringifyProcessingErrors(createResponse.getProcessingErrors()));
}
registryIds = createResponse.getCreatedMetacards().stream().filter(RegistryUtility::isRegistryMetacard).map(RegistryUtility::getRegistryId).collect(Collectors.toList());
} catch (SecurityServiceException | InvocationTargetException e) {
throw new FederationAdminException("Error adding local registry entry.", e);
}
return registryIds;
}
use of org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException in project ddf by codice.
the class FederationAdmin method allRegistryMetacardsSummary.
@Override
public Map<String, Object> allRegistryMetacardsSummary() {
Map<String, Object> nodes = new HashMap<>();
if (!cacheInitialized) {
try {
federationAdminService.getRegistryMetacards().stream().forEach(metacard -> summaryCache.put(RegistryUtility.getRegistryId(metacard), getSummaryMap(metacard)));
cacheInitialized = true;
} catch (FederationAdminException e) {
LOGGER.info("Couldn't get remote registry metacards ", e);
}
}
if (customSlots != null) {
nodes.put(CUSTOM_SLOTS_KEY, customSlots);
}
Map<String, Object> autoPopulateMap = new HashMap<>();
autoPopulateMap.put(SERVICE_BINDINGS_KEY, endpointMap.values());
nodes.put(AUTO_POPULATE_VALUES_KEY, autoPopulateMap);
nodes.put(NODES_KEY, new ArrayList(summaryCache.values()));
return nodes;
}
use of org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException in project ddf by codice.
the class RegistryRestEndpointTest method testPublishHelperException.
@Test
public void testPublishHelperException() throws Exception {
doThrow(new FederationAdminException("error")).when(registryPublicationService).publish(REGISTRY_ID, DESTINATION_ID);
Response response = restEndpoint.publish(REGISTRY_ID, DESTINATION_ID);
verify(registryPublicationService).publish(REGISTRY_ID, DESTINATION_ID);
assertThat(response.getStatusInfo().getStatusCode(), is(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
}
Aggregations