List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:ddf.test.itests.platform.TestSecurity.java
@BeforeExam public void beforeTest() throws Exception { try {/* ww w .j a v a2s .c om*/ waitForSystemReady(); Configuration config = getAdminConfig() .getConfiguration("org.codice.ddf.admin.config.policy.AdminConfigPolicy"); config.setBundleLocation( "mvn:ddf.admin.core/admin-core-configpolicy/" + System.getProperty("ddf.version")); Dictionary properties = new Hashtable<>(); List<String> featurePolicies = new ArrayList<>(); featurePolicies.addAll(Arrays.asList(getDefaultRequiredApps())); featurePolicies.addAll(FEATURES_TO_FILTER); featurePolicies.replaceAll(featureName -> featureName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\""); List<String> servicePolicies = new ArrayList<>(); servicePolicies.addAll(SERVICES_TO_FILTER); servicePolicies.replaceAll(serviceName -> serviceName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\""); properties.put("featurePolicies", featurePolicies.stream().toArray(String[]::new)); properties.put("servicePolicies", servicePolicies.stream().toArray(String[]::new)); config.update(properties); } catch (Exception e) { LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: "); } }
From source file:com.ibm.jaggr.core.impl.AbstractAggregatorImpl.java
/** * Adds the specified extension to the list of registered extensions. * * @param ext/* w ww . java 2 s . com*/ * The extension to add * @param before * Reference to an existing extension that the * new extension should be placed before in the list. If null, * then the new extension is added to the end of the list */ protected void registerExtension(IAggregatorExtension ext, IAggregatorExtension before) { final String sourceMethod = "registerExtension"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(AbstractAggregatorImpl.class.getName(), sourceMethod, new Object[] { ext, before }); } // validate type String id = ext.getExtensionPointId(); if (IHttpTransportExtensionPoint.ID.equals(id)) { if (before != null) { throw new IllegalArgumentException(before.getExtensionPointId()); } httpTransportExtension = ext; } else { List<IAggregatorExtension> list; if (IResourceFactoryExtensionPoint.ID.equals(id)) { list = resourceFactoryExtensions; } else if (IModuleBuilderExtensionPoint.ID.equals(id)) { list = moduleBuilderExtensions; } else if (IServiceProviderExtensionPoint.ID.equals(id)) { list = serviceProviderExtensions; } else { throw new IllegalArgumentException(id); } if (before == null) { list.add(ext); } else { // find the extension to insert the item in front of boolean inserted = false; for (int i = 0; i < list.size(); i++) { if (list.get(i) == before) { resourceFactoryExtensions.add(i, ext); inserted = true; break; } } if (!inserted) { throw new IllegalArgumentException(); } } // If this is a service provider extension the register the specified service if // one is indicated. if (IServiceProviderExtensionPoint.ID.equals(id)) { String interfaceName = ext.getAttribute(IServiceProviderExtensionPoint.SERVICE_ATTRIBUTE); if (interfaceName != null) { try { Dictionary<String, String> props = new Hashtable<String, String>(); // Copy init-params from extension to service dictionary Set<String> attributeNames = new HashSet<String>(ext.getAttributeNames()); attributeNames.removeAll(Arrays.asList( new String[] { "class", IServiceProviderExtensionPoint.SERVICE_ATTRIBUTE })); //$NON-NLS-1$ for (String propName : attributeNames) { props.put(propName, ext.getAttribute(propName)); } // Set name property to aggregator name props.put("name", getName()); //$NON-NLS-1$ registrations.add( getPlatformServices().registerService(interfaceName, ext.getInstance(), props)); } catch (Exception e) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, e.getMessage(), e); } } } } } if (isTraceLogging) { log.exiting(AbstractAggregatorImpl.class.getName(), sourceMethod); } }
From source file:ddf.test.itests.catalog.TestCatalog.java
@Test public void testIngestPlugin() throws Exception { //ingest a data set to make sure we don't have any issues initially String id1 = ingestGeoJson(Library.getSimpleGeoJson()); String xPath1 = String.format(METACARD_X_PATH, id1); //verify ingest by querying ValidatableResponse response = executeOpenSearch("xml", "q=*"); response.body(hasXPath(xPath1));//from w w w. ja va2 s . c o m //change ingest plugin role to ingest CatalogPolicyProperties catalogPolicyProperties = new CatalogPolicyProperties(); catalogPolicyProperties.put("createPermissions", new String[] { "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=ingest" }); Configuration config = configAdmin.getConfiguration("org.codice.ddf.catalog.security.CatalogPolicy", null); Dictionary<String, Object> configProps = new Hashtable<>(catalogPolicyProperties); config.update(configProps); waitForAllBundles(); //try ingesting again - it should fail this time given().body(Library.getSimpleGeoJson()).header(HttpHeaders.CONTENT_TYPE, "application/json").expect().log() .all().statusCode(400).when().post(REST_PATH.getUrl()); //verify query for first id works response = executeOpenSearch("xml", "q=*"); response.body(hasXPath(xPath1)); //revert to original configuration configProps.put("createPermissions", new String[] { "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=guest" }); config.update(configProps); waitForAllBundles(); deleteMetacard(id1); }
From source file:org.broad.igv.hic.MainWindow.java
private void initComponents() { JPanel mainPanel = new JPanel(); JPanel toolbarPanel = new JPanel(); //======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); mainPanel.setLayout(new BorderLayout()); toolbarPanel.setBorder(null);/* ww w .java 2s . c om*/ toolbarPanel.setLayout(new GridLayout()); JPanel chrSelectionPanel = new JPanel(); chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder()); chrSelectionPanel.setMinimumSize(new Dimension(130, 57)); chrSelectionPanel.setPreferredSize(new Dimension(130, 57)); chrSelectionPanel.setLayout(new BorderLayout()); JPanel panel10 = new JPanel(); panel10.setBackground(new Color(204, 204, 204)); panel10.setLayout(new BorderLayout()); JLabel label3 = new JLabel(); label3.setText("Chromosomes"); label3.setHorizontalAlignment(SwingConstants.CENTER); panel10.add(label3, BorderLayout.CENTER); chrSelectionPanel.add(panel10, BorderLayout.PAGE_START); JPanel panel9 = new JPanel(); panel9.setBackground(new Color(238, 238, 238)); panel9.setLayout(new BoxLayout(panel9, BoxLayout.X_AXIS)); //---- chrBox1 ---- chrBox1 = new JComboBox(); chrBox1.setModel(new DefaultComboBoxModel(new String[] { "All" })); chrBox1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox1ActionPerformed(e); } }); panel9.add(chrBox1); //---- chrBox2 ---- chrBox2 = new JComboBox(); chrBox2.setModel(new DefaultComboBoxModel(new String[] { "All" })); chrBox2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox2ActionPerformed(e); } }); panel9.add(chrBox2); //---- refreshButton ---- JideButton refreshButton = new JideButton(); refreshButton .setIcon(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { refreshButtonActionPerformed(e); } }); panel9.add(refreshButton); chrSelectionPanel.add(panel9, BorderLayout.CENTER); toolbarPanel.add(chrSelectionPanel); //======== displayOptionPanel ======== JPanel displayOptionPanel = new JPanel(); JPanel panel1 = new JPanel(); displayOptionComboBox = new JComboBox(); displayOptionPanel.setBackground(new Color(238, 238, 238)); displayOptionPanel.setBorder(LineBorder.createGrayLineBorder()); displayOptionPanel.setLayout(new BorderLayout()); //======== panel14 ======== JPanel panel14 = new JPanel(); panel14.setBackground(new Color(204, 204, 204)); panel14.setLayout(new BorderLayout()); //---- label4 ---- JLabel label4 = new JLabel(); label4.setText("Show"); label4.setHorizontalAlignment(SwingConstants.CENTER); panel14.add(label4, BorderLayout.CENTER); displayOptionPanel.add(panel14, BorderLayout.PAGE_START); //======== panel1 ======== panel1.setBorder(new EmptyBorder(0, 10, 0, 10)); panel1.setLayout(new GridLayout(1, 0, 20, 0)); //---- comboBox1 ---- displayOptionComboBox .setModel(new DefaultComboBoxModel(new String[] { DisplayOption.OBSERVED.toString() })); displayOptionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayOptionComboBoxActionPerformed(e); } }); panel1.add(displayOptionComboBox); displayOptionPanel.add(panel1, BorderLayout.CENTER); toolbarPanel.add(displayOptionPanel); //======== colorRangePanel ======== JPanel colorRangePanel = new JPanel(); JLabel colorRangeLabel = new JLabel(); colorRangeSlider = new RangeSlider(); colorRangePanel.setBorder(LineBorder.createGrayLineBorder()); colorRangePanel.setMinimumSize(new Dimension(96, 70)); colorRangePanel.setPreferredSize(new Dimension(202, 70)); colorRangePanel.setMaximumSize(new Dimension(32769, 70)); colorRangePanel.setLayout(new BorderLayout()); //======== panel11 ======== JPanel colorLabelPanel = new JPanel(); colorLabelPanel.setBackground(new Color(204, 204, 204)); colorLabelPanel.setLayout(new BorderLayout()); //---- colorRangeLabel ---- colorRangeLabel.setText("Color Range"); colorRangeLabel.setHorizontalAlignment(SwingConstants.CENTER); colorRangeLabel.setToolTipText("Range of color scale in counts per mega-base squared."); colorRangeLabel.setHorizontalTextPosition(SwingConstants.CENTER); colorRangeLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider); rangeDialog.setVisible(true); } } @Override public void mouseClicked(MouseEvent e) { ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider); rangeDialog.setVisible(true); } }); colorLabelPanel.add(colorRangeLabel, BorderLayout.CENTER); colorRangePanel.add(colorLabelPanel, BorderLayout.PAGE_START); //---- colorRangeSlider ---- colorRangeSlider.setPaintTicks(true); colorRangeSlider.setPaintLabels(true); colorRangeSlider.setLowerValue(0); colorRangeSlider.setMajorTickSpacing(500); colorRangeSlider.setMaximumSize(new Dimension(32767, 52)); colorRangeSlider.setPreferredSize(new Dimension(200, 52)); colorRangeSlider.setMinimumSize(new Dimension(36, 52)); colorRangeSlider.setMaximum(2000); colorRangeSlider.setUpperValue(500); colorRangeSlider.setMinorTickSpacing(100); colorRangeSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { colorRangeSliderStateChanged(e); } }); colorRangePanel.add(colorRangeSlider, BorderLayout.PAGE_END); // JPanel colorRangeTextPanel = new JPanel(); // colorRangeTextPanel.setLayout(new FlowLayout()); // JTextField minField = new JTextField(); // minField.setPreferredSize(new Dimension(50, 15)); // colorRangeTextPanel.add(minField); // colorRangeTextPanel.add(new JLabel(" - ")); // JTextField maxField = new JTextField(); // maxField.setPreferredSize(new Dimension(50, 15)); // colorRangeTextPanel.add(maxField); // colorRangeTextPanel.setPreferredSize(new Dimension(200, 52)); // colorRangePanel.add(colorRangeTextPanel, BorderLayout.PAGE_END); toolbarPanel.add(colorRangePanel); //======== resolutionPanel ======== JLabel resolutionLabel = new JLabel(); JPanel resolutionPanel = new JPanel(); resolutionPanel.setBorder(LineBorder.createGrayLineBorder()); resolutionPanel.setLayout(new BorderLayout()); //======== panel12 ======== JPanel panel12 = new JPanel(); panel12.setBackground(new Color(204, 204, 204)); panel12.setLayout(new BorderLayout()); //---- resolutionLabel ---- resolutionLabel.setText("Resolution"); resolutionLabel.setHorizontalAlignment(SwingConstants.CENTER); resolutionLabel.setBackground(new Color(204, 204, 204)); panel12.add(resolutionLabel, BorderLayout.CENTER); resolutionPanel.add(panel12, BorderLayout.PAGE_START); //======== panel2 ======== JPanel panel2 = new JPanel(); panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS)); //---- resolutionSlider ---- resolutionSlider = new JSlider(); resolutionSlider.setMaximum(8); resolutionSlider.setMajorTickSpacing(1); resolutionSlider.setPaintTicks(true); resolutionSlider.setSnapToTicks(true); resolutionSlider.setPaintLabels(true); resolutionSlider.setMinorTickSpacing(1); Dictionary<Integer, JLabel> resolutionLabels = new Hashtable<Integer, JLabel>(); Font f = FontManager.getFont(8); for (int i = 0; i < HiCGlobals.zoomLabels.length; i++) { if ((i + 1) % 2 == 0) { final JLabel tickLabel = new JLabel(HiCGlobals.zoomLabels[i]); tickLabel.setFont(f); resolutionLabels.put(i, tickLabel); } } resolutionSlider.setLabelTable(resolutionLabels); // Setting the zoom should always be done by calling resolutionSlider.setValue() so work isn't done twice. resolutionSlider.addChangeListener(new ChangeListener() { // Change zoom level while staying centered on current location. // Centering is relative to the bounds of the data, which might not be the bounds of the window public void stateChanged(ChangeEvent e) { if (!resolutionSlider.getValueIsAdjusting()) { int idx = resolutionSlider.getValue(); idx = Math.max(0, Math.min(idx, MAX_ZOOM)); if (hic.zd != null && idx == hic.zd.getZoom()) { // Nothing to do return; } if (hic.xContext != null) { int centerLocationX = (int) hic.xContext .getChromosomePosition(getHeatmapPanel().getWidth() / 2); int centerLocationY = (int) hic.yContext .getChromosomePosition(getHeatmapPanel().getHeight() / 2); hic.setZoom(idx, centerLocationX, centerLocationY, false); } //zoomInButton.setEnabled(newZoom < MAX_ZOOM); //zoomOutButton.setEnabled(newZoom > 0); } } }); panel2.add(resolutionSlider); resolutionPanel.add(panel2, BorderLayout.CENTER); toolbarPanel.add(resolutionPanel); mainPanel.add(toolbarPanel, BorderLayout.NORTH); //======== hiCPanel ======== final JPanel hiCPanel = new JPanel(); hiCPanel.setLayout(new HiCLayout()); //---- rulerPanel2 ---- rulerPanel2 = new HiCRulerPanel(hic); rulerPanel2.setMaximumSize(new Dimension(4000, 50)); rulerPanel2.setMinimumSize(new Dimension(1, 50)); rulerPanel2.setPreferredSize(new Dimension(1, 50)); rulerPanel2.setBorder(null); JPanel panel2_5 = new JPanel(); panel2_5.setLayout(new BorderLayout()); panel2_5.add(rulerPanel2, BorderLayout.SOUTH); trackPanel = new TrackPanel(hic); trackPanel.setMaximumSize(new Dimension(4000, 50)); trackPanel.setPreferredSize(new Dimension(1, 50)); trackPanel.setMinimumSize(new Dimension(1, 50)); trackPanel.setBorder(null); // trackPanelScrollpane = new JScrollPane(); // trackPanelScrollpane.getViewport().add(trackPanel); // trackPanelScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // trackPanelScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // trackPanelScrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102))); // trackPanelScrollpane.setBackground(new java.awt.Color(237, 237, 237)); // trackPanelScrollpane.setVisible(false); // panel2_5.add(trackPanelScrollpane, BorderLayout.NORTH); // trackPanel.setVisible(false); panel2_5.add(trackPanel, BorderLayout.NORTH); hiCPanel.add(panel2_5, BorderLayout.NORTH); //---- rulerPanel1 ---- rulerPanel1 = new HiCRulerPanel(hic); rulerPanel1.setMaximumSize(new Dimension(50, 4000)); rulerPanel1.setPreferredSize(new Dimension(50, 500)); rulerPanel1.setBorder(null); rulerPanel1.setMinimumSize(new Dimension(50, 1)); hiCPanel.add(rulerPanel1, BorderLayout.WEST); //---- heatmapPanel ---- heatmapPanel = new HeatmapPanel(this, hic); heatmapPanel.setBorder(LineBorder.createBlackLineBorder()); heatmapPanel.setMaximumSize(new Dimension(500, 500)); heatmapPanel.setMinimumSize(new Dimension(500, 500)); heatmapPanel.setPreferredSize(new Dimension(500, 500)); heatmapPanel.setBackground(new Color(238, 238, 238)); hiCPanel.add(heatmapPanel, BorderLayout.CENTER); //======== panel8 ======== JPanel rightSidePanel = new JPanel(); rightSidePanel.setMaximumSize(new Dimension(120, 100)); rightSidePanel.setBorder(new EmptyBorder(0, 10, 0, 0)); rightSidePanel.setLayout(null); //---- thumbnailPanel ---- thumbnailPanel = new ThumbnailPanel(this, hic); thumbnailPanel.setMaximumSize(new Dimension(100, 100)); thumbnailPanel.setMinimumSize(new Dimension(100, 100)); thumbnailPanel.setPreferredSize(new Dimension(100, 100)); thumbnailPanel.setBorder(LineBorder.createBlackLineBorder()); thumbnailPanel.setPreferredSize(new Dimension(100, 100)); thumbnailPanel.setBounds(new Rectangle(new Point(20, 0), thumbnailPanel.getPreferredSize())); rightSidePanel.add(thumbnailPanel); //======== xPlotPanel ======== xPlotPanel = new JPanel(); xPlotPanel.setPreferredSize(new Dimension(250, 100)); xPlotPanel.setLayout(null); rightSidePanel.add(xPlotPanel); xPlotPanel.setBounds(10, 100, xPlotPanel.getPreferredSize().width, 228); //======== yPlotPanel ======== yPlotPanel = new JPanel(); yPlotPanel.setPreferredSize(new Dimension(250, 100)); yPlotPanel.setLayout(null); rightSidePanel.add(yPlotPanel); yPlotPanel.setBounds(10, 328, yPlotPanel.getPreferredSize().width, 228); // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < rightSidePanel.getComponentCount(); i++) { Rectangle bounds = rightSidePanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = rightSidePanel.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; rightSidePanel.setMinimumSize(preferredSize); rightSidePanel.setPreferredSize(preferredSize); hiCPanel.add(rightSidePanel, BorderLayout.EAST); mainPanel.add(hiCPanel, BorderLayout.CENTER); contentPane.add(mainPanel, BorderLayout.CENTER); JMenuBar menuBar = createMenuBar(hiCPanel); contentPane.add(menuBar, BorderLayout.NORTH); // setup the glass pane to display a wait cursor when visible, and to grab all mouse events rootPane.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); rootPane.getGlassPane().addMouseListener(new MouseAdapter() { }); }
From source file:org.energy_home.jemma.ah.internal.hac.lib.HacService.java
private void createLocationService() { locationsDb = new LocationsService(); locationsDb.setConfigurationAdmin(configAdmin); Dictionary props = new Hashtable(); props.put(Constants.SERVICE_PID, "org.energy_home.jemma.osgi.ah.hac.locations"); locationsServiceReg = bc.registerService(ManagedServiceFactory.class.getName(), locationsDb, props); }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.source.CswSource.java
/** * Searches every query response for previously unknown content types * * @param response A Query Response/*from w ww . j a va2 s . c o m*/ */ private void addContentTypes(SourceResponse response) { if (response == null || response.getResults() == null) { return; } if (contentTypeMappingUpdated) { LOGGER.debug("{}: The content type mapping has been updated. Removing all old content types.", cswSourceConfiguration.getId()); contentTypes.clear(); } for (Result result : response.getResults()) { Metacard metacard = result.getMetacard(); if (metacard != null) { addContentType(metacard.getContentTypeName(), metacard.getContentTypeVersion(), metacard.getContentTypeNamespace()); } } Configuration[] managedConfigs = getManagedConfigs(); if (managedConfigs != null) { for (Configuration managedConfig : managedConfigs) { Dictionary<String, Object> properties = managedConfig.getProperties(); Set<String> current = new HashSet<String>( Arrays.asList((String[]) properties.get(CONTENTTYPES_PROPERTY))); if (contentTypeMappingUpdated || (current != null && !current.containsAll(contentTypes.keySet()))) { LOGGER.debug("{}: Adding new content types {} for content type mapping: {}.", cswSourceConfiguration.getId(), contentTypes.toString(), cswSourceConfiguration.getContentTypeMapping()); properties.put(CONTENTTYPES_PROPERTY, contentTypes.keySet().toArray(new String[0])); properties.put(CONTENT_TYPE_MAPPING_PROPERTY, cswSourceConfiguration.getContentTypeMapping()); try { LOGGER.debug("{}: Updating CSW Federated Source configuration with {}.", cswSourceConfiguration.getId(), properties.toString()); managedConfig.update(properties); } catch (IOException e) { LOGGER.warn("{}: Failed to update managedConfiguration with new contentTypes, Error: {}", cswSourceConfiguration.getId(), e); } } } } }
From source file:org.energy_home.jemma.ah.internal.zigbee.InstallationStatus.java
protected Dictionary getConfiguration() { Dictionary config = new Hashtable(); config.put("it.telecomitalia.ah.adapter.zigbee.lqi", cmProps.isLqiEnabled() + ""); config.put("it.telecomitalia.ah.adapter.zigbee.reconnect", cmProps.getReconnectToJGalDelay() + ""); config.put("it.telecomitalia.ah.adapter.zigbee.discovery.delay", cmProps.getDiscoveryDelay() + ""); config.put("it.telecomitalia.ah.adapter.zigbee.discovery.initialdelay", cmProps.getInitialDiscoveryDelay() + ""); return config; }
From source file:org.energy_home.jemma.ah.internal.hac.lib.HacService.java
/** * Called by DS when a new IManagedAppliance service is detected in OSGi * /*from ww w . j a v a 2 s .c o m*/ * @param appliance * The IManagedAppliance service object * @throws ApplianceException */ public void setManagedAppliance(IManagedAppliance appliance, Map appProps) throws ApplianceException { synchronized (lockHacService) { /* * Internally to the hac applications are identified by their pid * that should be unique and persistent. * * This helps to maintain a coherence when the HAC or an Appliance * is restarted. */ String appliancePid = appliance.getPid(); if (appliancePid == null) { LOG.warn("the managed appliance doesn't have an associated pid, discarding it!"); return; } if (!pid2appliance.contains(appliancePid)) { pid2appliance.put(appliancePid, appliance); } else { LOG.warn("discarding appliance because it has a duplicated appliance.pid"); return; } String appStatus = (String) appProps.get("ah.status"); if (appStatus != null && (appStatus.equals("installing"))) { LOG.debug("New appliance to install detected: " + appliancePid); installingAppliances.add(appliance); } else { appliances.add(appliance); } ((ApplianceManager) appliance.getApplianceManager()).setHacService(this); String applianceName = null; Configuration c; try { c = getApplianceCAConfiguration(appliancePid); } catch (Exception e) { LOG.warn(e.getMessage(), e); return; } applianceName = (String) appProps.get(IAppliance.APPLIANCE_NAME_PROPERTY); // If no name is assigned to the appliance, a unique name is // created and assigned if (applianceName == null) { if (c == null) { String factoryPid = (String) appProps.get(IAppliance.APPLIANCE_TYPE_PROPERTY); if (factoryPid == null) { if (!appliance.isSingleton()) LOG.debug( "the appliance doesn't have the ah.app.type property set and is not a singleton"); return; } IApplianceFactory applianceFactory = this.getApplianceFactory(factoryPid); if (applianceFactory == null) { LOG.debug("no factory for type " + factoryPid); return; } try { Configuration[] configurations = this.getApplianceCAConfigurations(appliancePid); if (configurations == null) { c = this.configAdmin.createFactoryConfiguration(factoryPid, null); LOG.debug("created configuration for appliance.pid " + appliancePid); } } catch (Exception e) { LOG.warn(e.getMessage(), e); return; } } Dictionary props = new Hashtable(); for (Iterator iterator = appProps.keySet().iterator(); iterator.hasNext();) { Object type = (Object) iterator.next(); props.put(type, appProps.get(type)); } if (applianceName == null) { String namePrefix = appliance.getDescriptor().getFriendlyName(); applianceName = createUniqueName(namePrefix); props.put(IAppliance.APPLIANCE_NAME_PROPERTY, applianceName); } try { c.update(props); } catch (IOException e) { LOG.debug(e.getMessage()); } } } }
From source file:org.energy_home.jemma.ah.internal.hac.lib.HacService.java
/** * Creates a factory configuration object if it doesn't exist, yet * //from w w w . j a v a2 s .co m * @param type * @param pid * @param props */ protected void createConfiguration(String factoryPid, String pid, Dictionary props) { if (pid == null) pid = generatePid(); Configuration c = null; LOG.debug("adding configuration for appliance " + pid); try { Configuration[] configurations = getApplianceCAConfigurations(pid); if (configurations == null) { c = this.configAdmin.createFactoryConfiguration(factoryPid, null); // remove old property service.pid props.remove(Constants.SERVICE_PID); props.put("appliance.pid", pid); LOG.debug("created configuration for appliance.pid " + pid); c.update(props); } } catch (Exception e) { LOG.warn(e.getMessage(), e); } }