List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:ddf.test.itests.AbstractIntegrationTest.java
protected void configureMetacardValidityFilterPlugin(List<String> securityAttributeMappings) throws IOException { Configuration config = configAdmin .getConfiguration("ddf.catalog.metacard.validation.MetacardValidityFilterPlugin", null); Dictionary properties = new Hashtable<>(); properties.put("attributeMap", securityAttributeMappings); config.update(properties);/* w w w. j av a 2s .c om*/ }
From source file:ddf.test.itests.AbstractIntegrationTest.java
protected void configureShowInvalidMetacards(String showInvalidMetacards) throws IOException { Configuration config = configAdmin.getConfiguration("ddf.catalog.federation.impl.CachingFederationStrategy", null);/*from ww w . ja va 2 s . com*/ Dictionary properties = new Hashtable<>(); properties.put("showInvalidMetacards", showInvalidMetacards); config.update(properties); }
From source file:org.openmuc.framework.webui.bundleconfigurator.BundleConfigurator.java
@Override public View getContentView(HttpServletRequest request, PluginContext pluginContext) { if (pluginContext.getLocalPath().equals("/edit")) { Bundle bundle = getBundleById(request.getParameter("id")); BundleConfiguration bundleConfiguration = null; try {/*from w w w.j av a 2 s. c om*/ bundleConfiguration = new BundleConfiguration(bundle, configAdmin, metaTypeService); } catch (Exception e) { message = "Error: " + e.getMessage(); return new RedirectView(pluginContext.getApplicationPath()); } return new ConfigurationView(bundle, bundleConfiguration, metaTypeService, loader); } else if (pluginContext.getLocalPath().equals("/changebundle")) { String id = request.getParameter("id"); Bundle bundle = getBundleById(id); try { BundleConfiguration bundleConfiguration = new BundleConfiguration(bundle, configAdmin, metaTypeService); Dictionary<String, String> bundleProperties = new Hashtable<String, String>(); String[] keys = request.getParameterValues("keyList"); if (keys != null) { for (String key : keys) { String value = request.getParameter(key + "Property"); if (value != null && !value.isEmpty()) { bundleProperties.put(key, request.getParameter(key + "Property")); } } } String newkey = request.getParameter("newkey"); if (!newkey.equals("")) { bundleProperties.put(newkey, request.getParameter("newkeyProperty")); } bundleConfiguration.setBundleProperties(bundleProperties); return new RedirectView(pluginContext.getApplicationPath() + "/edit?id=" + id); } catch (Exception e) { message = "Error: " + e.getMessage(); return new RedirectView(pluginContext.getApplicationPath()); } } else if (pluginContext.getLocalPath().equals("/install")) { installBundle(request, pluginContext); return new RedirectView(pluginContext.getApplicationPath()); } else if (pluginContext.getLocalPath().equals("/uninstall")) { Bundle bundle = getBundleById(request.getParameter("id")); if (bundle != null) { try { message = "Info: " + bundle.getSymbolicName() + " uninstalled"; bundle.uninstall(); } catch (BundleException e) { message = "Error: " + e.getMessage(); } } return new RedirectView(pluginContext.getApplicationPath()); } else if (pluginContext.getLocalPath().equals("/update")) { Bundle bundle = getBundleById(request.getParameter("id")); if (bundle != null) { try { message = "Info: " + bundle.getSymbolicName() + " updated"; bundle.update(); } catch (BundleException e) { message = "Error: " + e.getMessage(); } } return new RedirectView(pluginContext.getApplicationPath()); } else if (pluginContext.getLocalPath().equals("/stop")) { Bundle bundle = getBundleById(request.getParameter("id")); if (bundle != null) { try { message = "Info: " + bundle.getSymbolicName() + " stoped"; bundle.stop(); } catch (BundleException e) { message = "Error: " + e.getMessage(); } } return new RedirectView(pluginContext.getApplicationPath()); } else if (pluginContext.getLocalPath().equals("/start")) { Bundle bundle = getBundleById(request.getParameter("id")); if (bundle != null) { try { message = "Info: " + bundle.getSymbolicName() + " started"; bundle.start(); } catch (BundleException e) { message = "Error: " + e.getMessage(); } } return new RedirectView(pluginContext.getApplicationPath()); } else { String temp = message; message = null; return new BundleListView(context, loader, temp); } }
From source file:org.sakaiproject.nakamura.auth.trusted.TrustedTokenServiceImpl.java
/** * Inject a token into the request/response, this assumes htat the getUserPrincipal() of the request * or the request.getRemoteUser() contain valid user ID's from which to generate the request. * * * @param req/*from w w w. jav a 2s. c om*/ * @param resp * @param readOnlyToken if true, the session or cookie will only allow read only operations in the server. */ public String injectToken(HttpServletRequest request, HttpServletResponse response, String tokenType, UserValidator userValidator) { if (testing) { calls.add(new Object[] { "injectToken", request, response }); return "testing"; } String userId = null; String remoteAddress = request.getRemoteAddr(); if (trustedProxyServerAddrSet.contains(remoteAddress)) { if (trustedHeaderName.length() > 0) { userId = request.getHeader(trustedHeaderName); if (userId != null) { LOG.debug("Injecting Trusted Token from request: Header [{}] indicated user was [{}] ", 0, userId); } } if (userId == null && trustedParameterName.length() > 0) { userId = request.getParameter(trustedParameterName); if (userId != null) { LOG.debug("Injecting Trusted Token from request: Parameter [{}] indicated user was [{}] ", trustedParameterName, userId); } } } if (userId == null) { Principal p = request.getUserPrincipal(); if (p != null) { userId = p.getName(); if (userId != null) { LOG.debug("Injecting Trusted Token from request: User Principal indicated user was [{}] ", userId); } } } if (userId == null) { userId = request.getRemoteUser(); if (userId != null) { LOG.debug("Injecting Trusted Token from request: Remote User indicated user was [{}] ", userId); } } if (userValidator != null) { userId = userValidator.validate(userId); } if (userId != null) { if (usingSession) { HttpSession session = request.getSession(true); if (session != null) { LOG.debug("Injecting Credentials into Session for " + userId); session.setAttribute(SA_AUTHENTICATION_CREDENTIALS, createCredentials(userId, tokenType)); } } else { addCookie(response, userId, tokenType); } Dictionary<String, Object> eventDictionary = new Hashtable<String, Object>(); eventDictionary.put(TrustedTokenService.EVENT_USER_ID, userId); // send an async event to indicate that the user has been trusted, things that want to create users can hook into this. eventAdmin.sendEvent(new Event(TrustedTokenService.TRUST_USER_TOPIC, eventDictionary)); return userId; } else { LOG.warn("Unable to inject token; unable to determine user from request."); } return null; }
From source file:org.openengsb.ui.admin.testClient.TestClientTest.java
private void createProviderMocks() { createDomainProviderMock(TestInterface.class, "testdomain"); createDomainProviderMock(AnotherTestInterface.class, "anotherTestDomain"); createConnectorProviderMock("testconnector", "testdomain"); ConnectorInstanceFactory factory = mock(ConnectorInstanceFactory.class); when(factory.createNewInstance(anyString())).thenAnswer(new Answer<Connector>() { @Override/*ww w . j a va 2s . c om*/ public Connector answer(InvocationOnMock invocation) throws Throwable { TestInterface newMock = mock(TestInterface.class); testService = newMock; when(newMock.getInstanceId()).thenReturn((String) invocation.getArguments()[0]); return newMock; } }); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(Constants.DOMAIN_KEY, "testdomain"); props.put(Constants.CONNECTOR_KEY, "testconnector"); registerService(factory, props, ConnectorInstanceFactory.class); }
From source file:org.paxle.tools.charts.impl.gui.ChartServlet.java
@Activate protected void activate(BundleContext context) { this.context = context; this.typeList = new HashMap<String, Integer>(); this.variableTree = new HashMap<String, HashSet<String>>(); this.buildVariableTree(); // create charts this.chartMap.put("mem", this.createMemoryChart()); this.chartMap.put("ppm", this.createPPMChart()); this.chartMap.put("index", this.createIndexChart()); this.chartMap.put("system", this.createCPUChart()); // registering servlet as event-handler: required to receive monitoring-events Dictionary<String, Object> properties = new Hashtable<String, Object>(); properties.put(EventConstants.EVENT_TOPIC, new String[] { "org/osgi/service/monitor" }); properties.put(EventConstants.EVENT_FILTER, String.format("(mon.listener.id=%s)", ChartServlet.class.getName())); this.context.registerService(EventHandler.class.getName(), this, properties); try {// ww w . j ava 2 s .c o m // detecting already registered monitorables and // determine which of their variables we need to monitor final HashSet<String> variableNames = new HashSet<String>(); final ServiceReference[] services = this.context.getServiceReferences(Monitorable.class.getName(), null); if (services != null) { for (ServiceReference reference : services) { this.addVariables4Monitor(reference, variableNames, true, true); } this.startScheduledJob(variableNames); } // registering this class as service-listener this.context.addServiceListener(this, String.format("(%s=%s)", Constants.OBJECTCLASS, Monitorable.class.getName())); } catch (InvalidSyntaxException e) { // this should not occur this.logger.error(e); } }
From source file:org.openengsb.core.test.AbstractOsgiMockServiceTest.java
private <T> ServiceReference<T> putService(T service, Dictionary<String, Object> props) { @SuppressWarnings("unchecked") ServiceReference<T> serviceReference = mock(ServiceReference.class); long serviceId = --this.serviceId; LOGGER.info("registering service with ID: " + serviceId); props.put(Constants.SERVICE_ID, serviceId); services.put(serviceReference, service); synchronized (serviceReferences) { serviceReferences.put(serviceReference, props); }/*from w ww . j a v a 2 s. c om*/ when(serviceReference.getProperty(anyString())).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return serviceReferences.get(invocation.getMock()).get(invocation.getArguments()[0]); } }); when(serviceReference.getBundle()).thenReturn(bundle); when(serviceReference.getPropertyKeys()).thenAnswer(new Answer<String[]>() { @Override public String[] answer(InvocationOnMock invocation) throws Throwable { Dictionary<String, Object> dictionary = serviceReferences.get(invocation.getMock()); List<?> list = EnumerationUtils.toList(dictionary.keys()); @SuppressWarnings("unchecked") Collection<String> typedCollection = CollectionUtils.typedCollection(list, String.class); return typedCollection.toArray(new String[0]); } }); return serviceReference; }
From source file:ddf.test.itests.AbstractIntegrationTest.java
protected void configureEnforcedMetacardValidators(List<String> enforcedValidators) throws IOException { // Update metacardMarkerPlugin config with no enforcedMetacardValidators Configuration config = configAdmin .getConfiguration("ddf.catalog.metacard.validation.MetacardValidityMarkerPlugin", null); Dictionary<String, Object> properties = new Hashtable<>(); properties.put("enforcedMetacardValidators", enforcedValidators); config.update(properties);/* w w w .ja v a2s . co m*/ }
From source file:org.eclipse.smarthome.config.dispatch.internal.ConfigDispatcher.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void processConfigFile(File configFile) throws IOException, FileNotFoundException { if (configFile.isDirectory() || !configFile.getName().endsWith(".cfg")) { logger.debug("Ignoring file '{}'", configFile.getName()); return;// w w w . j a v a2 s . c o m } logger.debug("Processing config file '{}'", configFile.getName()); // we need to remember which configuration needs to be updated // because values have changed. Map<Configuration, Dictionary> configsToUpdate = new HashMap<Configuration, Dictionary>(); // also cache the already retrieved configurations for each pid Map<Configuration, Dictionary> configMap = new HashMap<Configuration, Dictionary>(); String pid; String filenameWithoutExt = StringUtils.substringBeforeLast(configFile.getName(), "."); if (filenameWithoutExt.contains(".")) { // it is a fully qualified namespace pid = filenameWithoutExt; } else { pid = getServicePidNamespace() + "." + filenameWithoutExt; } // configuration file contains a PID Marker List<String> lines = IOUtils.readLines(new FileInputStream(configFile)); if (lines.size() > 0 && lines.get(0).startsWith(PID_MARKER)) { pid = lines.get(0).substring(PID_MARKER.length()).trim(); } for (String line : lines) { String[] contents = parseLine(configFile.getPath(), line); // no valid configuration line, so continue if (contents == null) { continue; } if (contents[0] != null) { pid = contents[0]; // PID is not fully qualified, so prefix with namespace if (!pid.contains(".")) { pid = getServicePidNamespace() + "." + pid; } } String property = contents[1]; String value = contents[2]; Configuration configuration = configAdmin.getConfiguration(pid, null); if (configuration != null) { Dictionary configProperties = configMap.get(configuration); if (configProperties == null) { configProperties = configuration.getProperties() != null ? configuration.getProperties() : new Properties(); configMap.put(configuration, configProperties); } if (!value.equals(configProperties.get(property))) { configProperties.put(property, value); configsToUpdate.put(configuration, configProperties); } } } for (Entry<Configuration, Dictionary> entry : configsToUpdate.entrySet()) { entry.getKey().update(entry.getValue()); } }
From source file:fragment.web.SanityTestSuit.java
private void setupWorkflow() { workflowJob = new WorkflowJob(); workflowJob.setWorkflowEngine(workflowEngine); workflowJob.setQueue(eventListenerJmsProducer); bundleContext = new MockCPBMBundleContext(); ((BundleContextAware) workflowService).setBundleContext(bundleContext); Map<String, Activity> beanMap = applicationContext.getBeansOfType(Activity.class); for (Entry<String, Activity> entry : beanMap.entrySet()) { Dictionary<String, String> props = new Hashtable<String, String>(); props.put("beanName", entry.getKey()); bundleContext.registerService(Activity.class.getName(), entry.getValue(), props); }/*from ww w . jav a 2 s. c om*/ customizationResourceService .setWorkflows(this.getClass().getClassLoader().getResourceAsStream("workflowsTest.xml")); customizationResourceService.setTransactionWorkflowMap( this.getClass().getClassLoader().getResourceAsStream("transactionWorkflowMapTest.xml")); customizationInitializerService.initialize(); workflowJob.run(null); setupMail(); }