use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testConfigurationCreateActivateConfigWithExistingDisabledConfig.
@Test
public void testConfigurationCreateActivateConfigWithExistingDisabledConfig() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, null);
when(configAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { config });
Hashtable<String, Object> props = new Hashtable<>();
props.put("id", "TestRegNode");
props.put("origConfig", "origConfigValue");
props.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
props.put("bindingType", "CSW_2.0.2");
when(config.getProperties()).thenReturn(props);
when(config.getFactoryPid()).thenReturn("Csw_Federated_Source_disabled");
sch.setActivateConfigurations(true);
setupSerialExecutor();
sch.handleEvent(createEvent);
verify(config, times(1)).delete();
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source", null);
verify(config, times(2)).update(captor.capture());
Dictionary passedValues = captor.getAllValues().get(1);
assertCswProperties(passedValues);
assertThat(passedValues.get("origConfig"), equalTo("origConfigValue"));
}
use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testConfigurationUpdateActivateConfigNotFirstPriority.
@Test
public void testConfigurationUpdateActivateConfigNotFirstPriority() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, null);
when(configAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { config });
Hashtable<String, Object> props = new Hashtable<>();
props.put("id", "TestRegNode");
props.put("origConfig", "origConfigValue");
props.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
props.put("bindingType", "SomeOtherBindingType");
when(config.getProperties()).thenReturn(props);
when(config.getFactoryPid()).thenReturn("Some_Other_Source");
Configuration newConfig = mock(Configuration.class);
when(newConfig.getFactoryPid()).thenReturn("Some_Other_Source_disabled");
when(configAdmin.createFactoryConfiguration("Some_Other_Source_disabled", null)).thenReturn(newConfig);
List<String> priority = new ArrayList();
priority.add("Top_Priority_Source");
priority.add("CSW_2.0.2");
sch.setSourceActivationPriorityOrder(priority);
sch.setPreserveActiveConfigurations(false);
sch.setActivateConfigurations(true);
setupSerialExecutor();
sch.handleEvent(updateEvent);
verify(config, times(1)).delete();
verify(configAdmin, times(1)).createFactoryConfiguration("Some_Other_Source_disabled", null);
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source", null);
verify(configAdmin, times(1)).createFactoryConfiguration("Some_Other_Source_disabled", null);
verify(config).update(captor.capture());
List<Dictionary> values = captor.getAllValues();
assertThat(values.size(), equalTo(1));
Dictionary passedValues = values.get(0);
assertThat(passedValues.get("attId"), equalTo("attValue"));
assertCswProperties(passedValues);
}
use of java.util.Dictionary in project ddf by codice.
the class CamelServletCreator method registerServlet.
/**
* Register the Camel Servlet with the HTTP Service
*/
public void registerServlet() {
Dictionary props = new Hashtable();
props.put("alias", SERVLET_PATH);
props.put("servlet-name", SERVLET_NAME);
bundleContext.registerService("javax.servlet.Servlet", new HttpProxyCamelHttpTransportServlet(camelContext), props);
}
use of java.util.Dictionary in project ddf by codice.
the class ActionProviderRegistryProxy method bind.
public void bind(ServiceReference<MetacardTransformer> reference) {
LOGGER.info("New service registered [{}]", reference);
String transformerId = null;
if (reference.getProperty(Constants.SERVICE_ID) != null) {
transformerId = reference.getProperty(Constants.SERVICE_ID).toString();
// backwards compatibility
}
if (StringUtils.isBlank(transformerId) && reference.getProperty(Constants.SERVICE_SHORTNAME) != null) {
transformerId = reference.getProperty(Constants.SERVICE_SHORTNAME).toString();
}
if (StringUtils.isBlank(transformerId)) {
return;
}
String actionProviderId = ACTION_ID_PREFIX + transformerId;
String attributeName = getAttributeName(reference);
ActionProvider provider = actionFactory.createActionProvider(actionProviderId, transformerId, attributeName);
Dictionary actionProviderProperties = new Hashtable<String, String>();
actionProviderProperties.put(Constants.SERVICE_ID, actionProviderId);
ServiceRegistration actionServiceRegistration = getBundleContext().registerService(PROVIDER_INTERFACE_NAME, provider, actionProviderProperties);
LOGGER.info("Registered new {} [{}]", PROVIDER_INTERFACE_NAME, actionServiceRegistration);
actionProviderRegistry.put(reference, actionServiceRegistration);
}
use of java.util.Dictionary in project sling by apache.
the class OsgiInstallerImpl method getInstallationState.
/**
* @see org.apache.sling.installer.api.info.InfoProvider#getInstallationState()
*/
@Override
public InstallationState getInstallationState() {
synchronized (this.resourcesLock) {
final InstallationState state = new InstallationState() {
private final List<ResourceGroup> activeResources = new ArrayList<>();
private final List<ResourceGroup> installedResources = new ArrayList<>();
private final List<RegisteredResource> untransformedResources = new ArrayList<>();
@Override
public List<ResourceGroup> getActiveResources() {
return activeResources;
}
@Override
public List<ResourceGroup> getInstalledResources() {
return installedResources;
}
@Override
public List<RegisteredResource> getUntransformedResources() {
return untransformedResources;
}
@Override
public String toString() {
return "InstallationState[active resources: " + this.activeResources + ", installed resources: " + this.installedResources + ", untransformed resources: " + this.untransformedResources + "]";
}
};
for (final String entityId : this.persistentList.getEntityIds()) {
if (!this.persistentList.isSpecialEntityId(entityId)) {
final EntityResourceList group = this.persistentList.getEntityResourceList(entityId);
final String alias = group.getAlias();
final List<Resource> resources = new ArrayList<>();
boolean first = true;
boolean isActive = false;
for (final TaskResource tr : group.getResources()) {
final ResourceState resourceState = tr.getState();
if (first) {
if (resourceState == ResourceState.INSTALL || resourceState == ResourceState.UNINSTALL) {
isActive = true;
}
first = false;
}
resources.add(new Resource() {
@Override
public String getScheme() {
return tr.getScheme();
}
@Override
public String getURL() {
return tr.getURL();
}
@Override
public String getType() {
return tr.getType();
}
@Override
public InputStream getInputStream() throws IOException {
return tr.getInputStream();
}
@Override
public Dictionary<String, Object> getDictionary() {
return tr.getDictionary();
}
@Override
public String getDigest() {
return tr.getDigest();
}
@Override
public int getPriority() {
return tr.getPriority();
}
@Override
public String getEntityId() {
return tr.getEntityId();
}
@Override
public ResourceState getState() {
return resourceState;
}
@Override
public Version getVersion() {
return tr.getVersion();
}
@Override
public long getLastChange() {
return ((RegisteredResourceImpl) tr).getLastChange();
}
@Override
public Object getAttribute(final String key) {
return tr.getAttribute(key);
}
@Override
@CheckForNull
public String getError() {
return tr.getError();
}
@Override
public String toString() {
return "resource[entityId=" + getEntityId() + ", scheme=" + getScheme() + ", url=" + getURL() + ", type=" + getType() + ", error=" + getError() + ", state=" + getState() + ", version=" + getVersion() + ", lastChange=" + getLastChange() + ", priority=" + getPriority() + ", digest=" + getDigest() + "]";
}
});
}
final ResourceGroup rg = new ResourceGroup() {
@Override
public List<Resource> getResources() {
return resources;
}
@Override
public String getAlias() {
return alias;
}
@Override
public String toString() {
return "group[" + resources + "]";
}
};
if (isActive) {
state.getActiveResources().add(rg);
} else {
state.getInstalledResources().add(rg);
}
}
}
Collections.sort(state.getActiveResources(), COMPARATOR);
Collections.sort(state.getInstalledResources(), COMPARATOR);
state.getUntransformedResources().addAll(this.persistentList.getUntransformedResources());
return state;
}
}
Aggregations