List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:org.springsource.ide.eclipse.commons.gettingstarted.dashboard.ExtensionsEditor.java
private void initialize(final DashboardDiscoveryViewer viewer) { Dictionary<Object, Object> environment = viewer.getEnvironment(); // add the installed version to the environment so that we can // have connectors that are filtered based on the version Version version = IdeUiUtils.getVersion(); environment.put("com.springsource.sts.version", version.toString()); //$NON-NLS-1$ environment.put("com.springsource.sts.version.major", version.getMajor()); environment.put("com.springsource.sts.version.minor", version.getMinor()); environment.put("com.springsource.sts.version.micro", version.getMicro()); environment.put("com.springsource.sts.nightly", version.getQualifier().contains("-CI-")); version = IdeUiUtils.getPlatformVersion(); environment.put("platform.version", version.toString()); //$NON-NLS-1$ environment.put("platform.major", version.getMajor()); environment.put("platform.minor", version.getMinor()); environment.put("platform.micro", version.getMicro()); environment.put("platform", version.getMajor() + "." + version.getMinor()); viewer.setEnvironment(environment);/*from w ww .j a va 2 s. c o m*/ viewer.setShowInstalledFilterEnabled(true); viewer.addFilter(new ViewerFilter() { private Boolean svnInstalled; @Override public boolean select(Viewer viewer, Object parentElement, Object element) { DiscoveryConnector connector = (DiscoveryConnector) element; // filter out Collabnet on non-Windows platforms if (connector.getId().startsWith("com.collabnet") && !Platform.getOS().equals(Platform.OS_WIN32)) { return false; } // don't show SVN team providers if one is already // installed unless it is the installed connector if (SVN_FEATURES.contains(connector.getId()) && !isInstalled(connector) && isSvnInstalled()) { return false; } // filter out Atlassian JIRA connector if (connector.getId().startsWith("com.atlassian")) { return false; } return true; } private boolean isInstalled(DiscoveryConnector connector) { Set<String> installedFeatures = viewer.getInstalledFeatures(); return installedFeatures != null && installedFeatures.contains(connector.getId() + ".feature.group"); } /** * Returns true, if an SVN team provider is installed. */ private boolean isSvnInstalled() { if (svnInstalled == null) { svnInstalled = Boolean.FALSE; Set<String> installedFeatures = viewer.getInstalledFeatures(); if (installedFeatures != null) { for (String svn : SVN_FEATURES) { if (installedFeatures.contains(svn + ".feature.group")) { svnInstalled = Boolean.TRUE; break; } } } } return svnInstalled.booleanValue(); } }); }
From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdminTest.java
private void performCreateEvent() throws Exception { List<Map<String, Object>> result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary() .get("nodes"); assertThat(result.size(), is(0));// w w w .jav a2 s . co m Date timestamp = setupSummary(false); Dictionary<String, Object> eventProperties = new Hashtable<>(); eventProperties.put("ddf.catalog.event.metacard", mcard); Event event = new Event("ddf/catalog/event/CREATED", eventProperties); federationAdmin.handleEvent(event); setupDefaultFilterProps(); result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary().get("nodes"); assertThat(result.size(), is(1)); Map<String, Object> mcardMap = result.get(0); assertSummary(mcardMap, timestamp); }
From source file:fragment.web.WorkflowControllerTest.java
/** * Private method to setup the initial configurations for a workflow * //from w ww . ja va 2 s. co m * @author vinayv */ 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); } customizationResourceService .setWorkflows(this.getClass().getClassLoader().getResourceAsStream("workflowsTest.xml")); customizationResourceService.setTransactionWorkflowMap( this.getClass().getClassLoader().getResourceAsStream("transactionWorkflowMapTest.xml")); customizationInitializerService.initialize(); workflowJob.run(null); // setupMail(); }
From source file:org.talend.osgi.hook.OsgiLoaderTest.java
@Before public void init() throws IOException, ConfigurationException { // we use osgi bundle because the context of this bundle may not be created this.osgiBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$ // remove any file copied in the lib folder FileUtils.deleteDirectory(libJavaFolderFile); libJavaFolderFile.mkdirs();// www . j a v a 2 s . co m // create a temporary maven repo and setup pax service to use it as a local repo. File base = new File("target"); base.mkdirs(); try { temp_maven_repo = File.createTempFile("talend.hook.maven", ".dir", base); temp_maven_repo.delete(); temp_maven_repo.mkdirs(); System.out.println("Caching" + " to " + temp_maven_repo.getAbsolutePath()); } catch (IOException exc) { throw new AssertionError("cannot create cache", exc); } ServiceReference<ManagedService> managedServiceRef = osgiBundle.getBundleContext() .getServiceReference(ManagedService.class); if (managedServiceRef != null) { ManagedService managedService = osgiBundle.getBundleContext().getService(managedServiceRef); Dictionary<String, String> props = new Hashtable<String, String>(); props.put(ServiceConstants.PID + "." + ServiceConstants.PROPERTY_LOCAL_REPOSITORY, temp_maven_repo.toURI().toASCIIString()); managedService.updated(props); ServiceReference<org.ops4j.pax.url.mvn.MavenResolver> mavenResolverService = osgiBundle .getBundleContext().getServiceReference(org.ops4j.pax.url.mvn.MavenResolver.class); paxResolver = osgiBundle.getBundleContext().getService(mavenResolverService); } else { throw new RuntimeException("Failed to load the service :" + ManagedService.class.getCanonicalName()); //$NON-NLS-1$ } }
From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdminTest.java
@Test public void testHandleEventUpdate() throws Exception { performCreateEvent();//from w w w .j av a 2s .co m Dictionary<String, Object> eventProperties = new Hashtable<>(); mcard.setTitle("UpdatedTitle"); eventProperties.put("ddf.catalog.event.metacard", mcard); Event event = new Event("ddf/catalog/event/UPDATED", eventProperties); federationAdmin.handleEvent(event); setupDefaultFilterProps(); List<Map<String, Object>> result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary() .get("nodes"); assertThat(result.size(), is(1)); Map<String, Object> mcardMap = result.get(0); assertThat(mcardMap.get(FederationAdmin.SUMMARY_NAME), is("UpdatedTitle")); }
From source file:org.codice.ddf.spatial.ogc.wfs.v110.catalog.source.WfsSource.java
private FeatureMetacardType createFeatureMetacardTypeRegistration(FeatureTypeType featureTypeType, String ftName, XmlSchema schema) { MetacardTypeEnhancer metacardTypeEnhancer = metacardTypeEnhancers.stream() .filter(me -> me.getFeatureName() != null) .filter(me -> me.getFeatureName().equalsIgnoreCase(ftName)).findAny() .orElse(FeatureMetacardType.DEFAULT_METACARD_TYPE_ENHANCER); FeatureMetacardType ftMetacard = new FeatureMetacardType(schema, featureTypeType.getName(), nonQueryableProperties != null ? Arrays.asList(nonQueryableProperties) : new ArrayList<>(), Wfs11Constants.GML_3_1_1_NAMESPACE, metacardTypeEnhancer); Dictionary<String, Object> props = new DictionaryMap<>(); props.put(Metacard.CONTENT_TYPE, new String[] { ftName }); LOGGER.debug("WfsSource {}: Registering MetacardType: {}", getId(), ftName); return ftMetacard; }
From source file:ch.entwine.weblounge.contentrepository.impl.ContentRepositoryServiceFactory.java
/** * {@inheritDoc}/*from w ww . j a va 2 s . c o m*/ * * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, * java.util.Dictionary) */ public void updated(String pid, Dictionary properties) throws ConfigurationException { // is this an update to an existing service? if (services.containsKey(pid)) { ServiceRegistration registration = services.get(pid); ManagedService service = (ManagedService) bundleCtx.getService(registration.getReference()); service.updated(properties); } // Create a new content repository service instance else { String className = (String) properties.get(OPT_TYPE); if (StringUtils.isBlank(className)) { className = repositoryType; } Class<ContentRepository> repositoryImplementation; ContentRepository repository = null; try { repositoryImplementation = (Class<ContentRepository>) Class.forName(className); repository = repositoryImplementation.newInstance(); repository.setEnvironment(environment); repository.setSerializer(serializer); // If this is a managed service, make sure it's configured properly // before the site is connected if (repository instanceof ManagedService) { Dictionary<Object, Object> finalProperties = new Hashtable<Object, Object>(); // Add the default configuration according to the repository type Dictionary<Object, Object> configuration = loadConfiguration(repository.getType()); if (configuration != null) { for (Enumeration<Object> keys = configuration.keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = configuration.get(key); if (value instanceof String) value = ConfigurationUtils.processTemplate((String) value); finalProperties.put(key, value); } } // Overwrite the default configuration with what was passed in for (Enumeration<Object> keys = properties.keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = properties.get(key); if (value instanceof String) value = ConfigurationUtils.processTemplate((String) value); finalProperties.put(key, value); } // push the repository configuration ((ManagedService) repository).updated(finalProperties); } // Register the service String serviceType = ContentRepository.class.getName(); properties.put("service.pid", pid); services.put(pid, bundleCtx.registerService(serviceType, repository, properties)); } catch (ClassNotFoundException e) { throw new ConfigurationException(OPT_TYPE, "Repository implementation class " + className + " not found", e); } catch (InstantiationException e) { throw new ConfigurationException(OPT_TYPE, "Error instantiating repository implementation class " + className + " not found", e); } catch (IllegalAccessException e) { throw new ConfigurationException(OPT_TYPE, "Error accessing repository implementation class " + className + " not found", e); } } }
From source file:org.ops4j.pax.web.service.tomcat.internal.TomcatServerWrapper.java
private Context createContext(final ContextModel contextModel) { final Bundle bundle = contextModel.getBundle(); final BundleContext bundleContext = BundleUtils.getBundleContext(bundle); final Context context = server.addContext(contextModel.getContextParams(), getContextAttributes(bundleContext), contextModel.getContextName(), contextModel.getHttpContext(), contextModel.getAccessControllerContext(), contextModel.getContainerInitializers(), contextModel.getJettyWebXmlURL(), contextModel.getVirtualHosts(), null /*contextModel.getConnectors() */, server.getBasedir()); context.setParentClassLoader(contextModel.getClassLoader()); // TODO: is the context already configured? // TODO: how about security, classloader? // TODO: compare with JettyServerWrapper.addContext // TODO: what about the init parameters? configureJspConfigDescriptor(context, contextModel); final LifecycleState state = context.getState(); if (state != LifecycleState.STARTED && state != LifecycleState.STARTING && state != LifecycleState.STARTING_PREP) { LOG.debug("Registering ServletContext as service. "); final Dictionary<String, String> properties = new Hashtable<String, String>(); properties.put("osgi.web.symbolicname", bundle.getSymbolicName()); final Dictionary<String, String> headers = bundle.getHeaders(); final String version = (String) headers.get(Constants.BUNDLE_VERSION); if (version != null && version.length() > 0) { properties.put("osgi.web.version", version); }// w w w . ja v a 2s. c o m String webContextPath = (String) headers.get(WEB_CONTEXT_PATH); final String webappContext = (String) headers.get("Webapp-Context"); final ServletContext servletContext = context.getServletContext(); // This is the default context, but shouldn't it be called default? // See PAXWEB-209 if ("/".equalsIgnoreCase(context.getPath()) && (webContextPath == null || webappContext == null)) { webContextPath = context.getPath(); } // makes sure the servlet context contains a leading slash webContextPath = webContextPath != null ? webContextPath : webappContext; if (webContextPath != null && !webContextPath.startsWith("/")) { webContextPath = "/" + webContextPath; } if (webContextPath == null) { LOG.warn("osgi.web.contextpath couldn't be set, it's not configured"); } properties.put("osgi.web.contextpath", webContextPath); servletContextService = bundleContext.registerService(ServletContext.class, servletContext, properties); LOG.debug("ServletContext registered as service. "); } contextMap.put(contextModel.getHttpContext(), context); return context; }
From source file:net.cellar.hazelcast.HazelcastGroupManager.java
@Override public void registerGroup(Group group) { String groupName = group.getName(); createGroup(groupName);/*from ww w. ja v a 2 s . c o m*/ ITopic topic = instance.getTopic(Constants.TOPIC + "." + groupName); Properties serviceProperties = new Properties(); serviceProperties.put("type", "group"); serviceProperties.put("name", groupName); if (!producerRegistrations.containsKey(groupName)) { TopicProducer producer = new TopicProducer(); producer.setTopic(topic); producer.setNode(getNode()); ServiceRegistration producerRegistration = bundleContext .registerService(EventProducer.class.getCanonicalName(), producer, serviceProperties); producerRegistrations.put(groupName, producerRegistration); } if (!consumerRegistrations.containsKey(groupName)) { TopicConsumer consumer = new TopicConsumer(); consumer.setDispatcher(dispatcher); consumer.setTopic(topic); consumer.setNode(getNode()); consumer.init(); ServiceRegistration consumerRegistration = bundleContext .registerService(EventConsumer.class.getCanonicalName(), consumer, serviceProperties); consumerRegistrations.put(groupName, consumerRegistration); } group.getMembers().add(getNode()); listGroups().put(groupName, group); //Add group to configuration try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE); Dictionary<String, String> properties = configuration.getProperties(); String groups = properties.get(Configurations.GROUPS_KEY); if (groups == null || groups.isEmpty()) { groups = groupName; } else { Set<String> groupNamesSet = convertStringToSet(groups); groupNamesSet.add(groupName); groups = convertSetToString(groupNamesSet); } if (groups == null || groups.isEmpty()) { groups = groupName; } properties.put(Configurations.GROUPS_KEY, groups); configuration.update(properties); } catch (IOException e) { logger.error("Error reading group configuration {}", group); } //Sync try { ServiceReference[] serviceReferences = bundleContext .getAllServiceReferences("net.cellar.core.Synchronizer", null); if (serviceReferences != null && serviceReferences.length > 0) { for (ServiceReference ref : serviceReferences) { Synchronizer synchronizer = (Synchronizer) bundleContext.getService(ref); if (synchronizer.isSyncEnabled(group)) { synchronizer.pull(group); synchronizer.push(group); } bundleContext.ungetService(ref); } } } catch (InvalidSyntaxException e) { logger.error("Error looking up for Synchronizers", e); } }
From source file:com.whizzosoftware.hobson.bootstrap.api.hub.OSGIHubManager.java
@Override public void setHubPassword(String userId, String hubId, PasswordChange change) { try {// ww w . j a v a 2s . c o m Configuration config = getConfiguration(); Dictionary props = getConfigurationProperties(config); // verify the old password String shaOld = DigestUtils.sha256Hex(change.getCurrentPassword()); String hubPassword = (String) props.get(ADMIN_PASSWORD); if (hubPassword != null && !hubPassword.equals(shaOld)) { throw new HobsonRuntimeException("The current hub password is invalid"); } // verify the password meets complexity requirements if (!change.isValid()) { throw new HobsonInvalidRequestException("New password does not meet complexity requirements"); } // set the new password props.put(ADMIN_PASSWORD, DigestUtils.sha256Hex(change.getNewPassword())); updateConfiguration(config, props); } catch (IOException e) { throw new HobsonRuntimeException("Error setting hub password", e); } }