use of org.codice.ddf.registry.schemabindings.helper.RegistryPackageTypeHelper in project ddf by codice.
the class IdentityNodeInitialization method updateIdentityNodeName.
private void updateIdentityNodeName(Metacard metacard) throws FederationAdminException, ParserException {
RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
String siteName = SystemInfo.getSiteName();
RegistryPackageTypeHelper registryPackageTypeHelper = new RegistryPackageTypeHelper();
registryPackageTypeHelper.getExtrinsicObjects(registryPackage.getRegistryObjectList()).stream().filter(extrinsicObjectType -> extrinsicObjectType.getObjectType().equals(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE)).findFirst().ifPresent(extrinsicObjectType -> extrinsicObjectType.setName(internationalStringTypeHelper.create(siteName)));
Metacard identityMetacard = getRegistryMetacardFromRegistryPackage(registryPackage);
if (identityMetacard != null) {
federationAdminService.updateRegistryEntry(identityMetacard);
}
}
use of org.codice.ddf.registry.schemabindings.helper.RegistryPackageTypeHelper in project ddf by codice.
the class SourceConfigurationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
parser = new XmlParser();
adminService = mock(FederationAdminService.class);
configAdmin = mock(ConfigurationAdmin.class);
metaTypeService = mock(MetaTypeService.class);
bundleContext = mock(BundleContext.class);
executorService = mock(ExecutorService.class);
sch = new SourceConfigurationHandler(adminService, executorService) {
@Override
protected BundleContext getBundleContext() {
return bundleContext;
}
};
sch.setMetacardMarshaller(new MetacardMarshaller(parser));
sch.setConfigurationAdmin(configAdmin);
sch.setMetaTypeService(metaTypeService);
sch.setSlotHelper(new SlotTypeHelper());
sch.setRegistryTypeHelper(new RegistryPackageTypeHelper());
sch.setActivateConfigurations(false);
sch.setPreserveActiveConfigurations(true);
sch.setUrlBindingName("urlBindingName");
sch.setBindingTypeFactoryPid(Collections.singletonList("CSW_2.0.2=Csw_Federated_Source"));
sch.setSourceActivationPriorityOrder(Collections.singletonList("CSW_2.0.2"));
sch.setCleanUpOnDelete(false);
Bundle bundle = mock(Bundle.class);
mti = mock(MetaTypeInformation.class);
ocd = mock(ObjectClassDefinition.class);
config = mock(Configuration.class);
AttributeDefinition adi = new AttributeDefinitionImpl("attId", "attName", "attDesc", "attValue");
when(adminService.getRegistryMetacards()).thenReturn(new ArrayList());
when(bundleContext.getBundles()).thenReturn(new Bundle[] { bundle });
when(configAdmin.listConfigurations("(id=TestRegNode")).thenReturn(null);
when(configAdmin.listConfigurations("(registry-id=urn:uuid:2014ca7f59ac46f495e32b4a67a51276")).thenReturn(null);
when(metaTypeService.getMetaTypeInformation(any(Bundle.class))).thenReturn(mti);
when(mti.getObjectClassDefinition(anyString(), anyString())).thenReturn(ocd);
when(ocd.getAttributeDefinitions(anyInt())).thenReturn(new AttributeDefinition[] { adi });
when(configAdmin.createFactoryConfiguration(anyString(), anyString())).thenReturn(config);
mcard = new MetacardImpl(new RegistryObjectMetacardType());
mcard.setTags(Collections.singleton(RegistryConstants.REGISTRY_TAG));
mcard.setId("2014ca7f59ac46f495e32b4a67a51276");
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
mcard.setMetadata(getMetadata("/csw-rim-node-csw-binding.xml"));
mcard.setTitle("TestRegNode");
Dictionary<String, Object> eventProperties = new Hashtable<>();
eventProperties.put("ddf.catalog.event.metacard", mcard);
createEvent = new Event("ddf/catalog/event/CREATED", eventProperties);
updateEvent = new Event("ddf/catalog/event/UPDATED", eventProperties);
deleteEvent = new Event("ddf/catalog/event/DELETED", eventProperties);
System.setProperty(RegistryConstants.REGISTRY_ID_PROPERTY, "myRegId");
}
use of org.codice.ddf.registry.schemabindings.helper.RegistryPackageTypeHelper in project ddf by codice.
the class RegistryReportBuilder method getOrganizationMap.
private Map<String, Object> getOrganizationMap(RegistryPackageType registryPackage) {
Map<String, Object> organizationMap = new HashMap<>();
List<Map<String, Object>> organizations = new ArrayList<>();
RegistryPackageTypeHelper rpt = new RegistryPackageTypeHelper(registryPackage);
OrganizationWebConverter owc = new OrganizationWebConverter();
organizations.addAll(rpt.getOrganizations().stream().map(owc::convert).collect(Collectors.toList()));
webMapHelper.putIfNotEmpty(organizationMap, ORGANIZATION_KEY, organizations);
return organizationMap;
}
Aggregations