Package org.rhq.core.domain.configuration

Examples of org.rhq.core.domain.configuration.PropertyList


        else if (property instanceof PropertyMap) {
            PropertyMap propertyMap = (PropertyMap) property;
            PropertyMap unmaskedPropertyMap = unmaskedParentPropertyMap.getMap(property.getName());
            unmaskPropertyMap(propertyMap, unmaskedPropertyMap);
        } else if (property instanceof PropertyList) {
            PropertyList propertyList = (PropertyList) property;
            List<Property> memberProperties = propertyList.getList();
            // If the property is a List of Maps, iterate the list, and recurse into each Map and unmask its child
            // properties.
            if (!memberProperties.isEmpty() && memberProperties.get(0) instanceof PropertyMap) {
                PropertyList unmaskedPropertyList = unmaskedParentPropertyMap.getList(propertyList.getName());
                if (unmaskedPropertyList != null) {
                    List<Property> unmaskedMemberProperties = unmaskedPropertyList.getList();
                    for (int i = 0; (i < memberProperties.size()) && (i < unmaskedMemberProperties.size()); i++) {
                        PropertyMap propertyMap = (PropertyMap) memberProperties.get(i);
                        PropertyMap unmaskedPropertyMap = (PropertyMap) unmaskedMemberProperties.get(i);
                        unmaskPropertyMap(propertyMap, unmaskedPropertyMap);
                    }
View Full Code Here


        //this is the default, but let's be specific here so that this doesn't start failing if we change the
        //default in the future.
        importConfig.put(new PropertySimple(MetricTemplateImporter.UPDATE_ALL_SCHEDULES_PROPERTY, false));

        //set the def to update the schedules anyway
        PropertyList list = new PropertyList(MetricTemplateImporter.METRIC_UPDATE_OVERRIDES_PROPERTY);
        importConfig.put(list);
        PropertyMap map = new PropertyMap(MetricTemplateImporter.METRIC_UPDATE_OVERRIDE_PROPERTY);
        list.add(map);
        map.put(new PropertySimple(MetricTemplateImporter.METRIC_NAME_PROPERTY, "def"));
        map.put(new PropertySimple(MetricTemplateImporter.RESOURCE_TYPE_NAME_PROPERTY, FAKE_RESOURCE_TYPE.getName()));
        map.put(new PropertySimple(MetricTemplateImporter.RESOURCE_TYPE_PLUGIN_PROPERTY, FAKE_RESOURCE_TYPE.getPlugin()));
        map.put(new PropertySimple(MetricTemplateImporter.UPDATE_SCHEDULES_PROPERTY, true));
View Full Code Here

            plugins = updater.getCurrentPluginFiles();
            PluginContainerConfiguration pcConfig = m_agent.getConfiguration().getPluginContainerConfiguration();
            List<String> enabledPlugins = pcConfig.getEnabledPlugins();
            List<String> disabledPlugins = pcConfig.getDisabledPlugins();

            PropertyList list = new PropertyList("plugins".intern());
            info.getComplexResults().put(list);

            if (plugins.size() > 0) {
                for (File plugin : plugins) {
                    String pluginName;
                    String pluginDisplayName;
                    try {
                        URL url = plugin.toURI().toURL();
                        PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
                        pluginName = descriptor.getName();
                        pluginDisplayName = descriptor.getDisplayName();
                    } catch (Exception t) {
                        pluginName = "?cannot-parse-descriptor?".intern();
                        pluginDisplayName = "?cannot-parse-descriptor?".intern();
                    }

                    PropertyMap map = new PropertyMap("plugin".intern());
                    map.put(new PropertySimple(PLUGIN_INFO_NAME, pluginName));
                    map.put(new PropertySimple(PLUGIN_INFO_DISPLAY_NAME, pluginDisplayName));
                    map.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
                    map.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
                    map.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
                    // plugin is either whitelisted or the white list is empty
                    boolean isEnabled = enabledPlugins.isEmpty() || enabledPlugins.contains(pluginName);
                    // ..and is not on the black list
                    isEnabled &= !disabledPlugins.contains(pluginName);
                    map.put(new PropertySimple(PLUGIN_INFO_ENABLED, isEnabled));

                    try {
                        map.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
                    } catch (IOException e) {
                        map.put(new PropertySimple(PLUGIN_INFO_MD5, e.toString()));
                    }

                    list.add(map);
                }
            }
        } finally {
            Thread.currentThread().setContextClassLoader(originalCL);
        }
View Full Code Here

        }

        OperationResult opResult = new OperationResult();
        Configuration complexResults = opResult.getComplexResults();

        PropertyList list = new PropertyList("resourceAvailabilities");
        complexResults.put(list);

        String agentName;
        Boolean changesOnlyFromReport;

        if (report != null) {
            agentName = report.getAgentName();
            changesOnlyFromReport = Boolean.valueOf(report.isChangesOnlyReport());

            List<AvailabilityReport.Datum> avails = report.getResourceAvailability();

            if (avails.size() > 0) {
                for (AvailabilityReport.Datum avail : avails) {
                    boolean isUp = avail.getAvailabilityType() == AvailabilityType.UP;

                    // lookup the heavy-weight resource object
                    int resourceId = avail.getResourceId();
                    ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resourceId);
                    Resource resource = resourceContainer.getResource();

                    PropertyMap map = new PropertyMap("resourceAvailability");
                    map.put(new PropertySimple("resourceId", Integer.valueOf(resource.getId())));
                    map.put(new PropertySimple("resourceName", resource.getName()));
                    map.put(new PropertySimple("isAvailable", Boolean.valueOf(isUp)));
                    list.add(map);
                }
            }
        } else {
            // report was null - this means there are no committed resources in inventory
            agentName = m_agent.getConfiguration().getAgentName();
View Full Code Here

            if (Boolean.parseBoolean(updateAll)) {
                return true;
            }
        }

        PropertyList perMetricOverrides = importConfiguration.getList(METRIC_UPDATE_OVERRIDES_PROPERTY);
        if (perMetricOverrides == null) {
            return UPDATE_SCHEDULES_DEFAULT;
        }

        PropertySimple override = findOverrideForMetric(def, perMetricOverrides);
View Full Code Here

        PropertyMap openPropMap2 = new PropertyMap("ReadOnlyOpenMapOfSimples");
        openPropMap2.put(new PropertySimple("ANT_HOME", "C:\\opt\\ant-1.6.5"));
        openPropMap2.put(new PropertySimple("ANT_OPTS", "-Xms128M -Xmx256M"));
        configuration.put(openPropMap2);

        configuration.put(new PropertyList("ListOfStrings", new PropertySimple("note", "Do"), new PropertySimple(
            "note", "Re"), new PropertySimple("note", "Mi"), new PropertySimple("note", "Fa"), new PropertySimple(
            "note", "So"), new PropertySimple("note", "La"), new PropertySimple("note", "Ti")));

        PropertyMap propMap2 = new PropertyMap("MapOfSimples");
        propMap2.put(new PropertySimple("String1", "Uno"));
        propMap2.put(new PropertySimple("String2", "Dos"));
        propMap2.put(new PropertySimple("Integer", Integer.MIN_VALUE));
        PropertyMap propMap3 = new PropertyMap("MapOfSimples");
        propMap3.put(new PropertySimple("String1", "Un"));
        propMap3.put(new PropertySimple("String2", "Deux"));
        propMap3.put(new PropertySimple("Integer", Integer.MAX_VALUE));
        configuration.put(new PropertyList("ListOfMaps", propMap2, propMap3));

        PropertyMap propMap4 = new PropertyMap("MapOfSimplesInReadOnlyList");
        propMap4.put(new PropertySimple("String1", "A"));
        propMap4.put(new PropertySimple("String2", "B"));
        propMap4.put(new PropertySimple("Integer", 999));
        PropertyMap propMap5 = new PropertyMap("MapOfSimplesInReadOnlyList");
        propMap5.put(new PropertySimple("String1", "a"));
        propMap5.put(new PropertySimple("String2", "b"));
        propMap5.put(new PropertySimple("Integer", 0));
        configuration.put(new PropertyList("ReadOnlyListOfMaps", propMap4, propMap5));

        configuration.put(new PropertySimple("myString1", "grouped String 1"));
        configuration.put(new PropertySimple("myString2", "grouped String 2"));
        configuration.put(new PropertySimple("myString3", "strings are cool"));
        configuration.put(new PropertySimple("myEnum", "Burlington"));
View Full Code Here

        assert cspd.getResourceVersions().contains("Mazzresource-version2") : cspd.getResourceVersions();

        Configuration extra = cspd.getExtraProperties();
        PropertySimple firstsimple = extra.getSimple("firstsimple");
        PropertySimple secondsimple = extra.getSimple("secondsimple");
        PropertyList firstlist = extra.getList("firstlist");
        PropertyList anotherlist = extra.getList("anotherlist");
        PropertyMap firstmap = extra.getMap("firstmap");
        PropertyList list_o_maps = extra.getList("list-o-maps");
        assert firstsimple != null;
        assert secondsimple != null;
        assert firstlist != null;
        assert anotherlist != null;
        assert firstmap != null;
        assert list_o_maps != null;

        assert "First Simple".equals(firstsimple.getStringValue()) : firstsimple.getStringValue();
        assert "Second Simple".equals(secondsimple.getStringValue()) : secondsimple.getStringValue();

        List<Property> list = firstlist.getList();
        assert 3 == list.size() : list;
        assert "First List #1".equals(((PropertySimple) list.get(0)).getStringValue()) : list;
        assert "First List #2".equals(((PropertySimple) list.get(1)).getStringValue()) : list;
        assert "First List #3".equals(((PropertySimple) list.get(2)).getStringValue()) : list;

        list = anotherlist.getList();
        assert 3 == list.size() : list;
        assert "Another List #1".equals(((PropertySimple) list.get(0)).getStringValue()) : list;
        assert "Another List #2".equals(((PropertySimple) list.get(1)).getStringValue()) : list;
        assert "Another List #3".equals(((PropertySimple) list.get(2)).getStringValue()) : list;

        Map<String, Property> map = firstmap.getMap();
        assert 3 == map.size() : map;
        assert "First Map #1".equals(((PropertySimple) map.get("firstmap1")).getStringValue()) : map;
        assert "First Map #2".equals(((PropertySimple) map.get("firstmap2")).getStringValue()) : map;
        assert "First Map #3".equals(((PropertySimple) map.get("firstmap3")).getStringValue()) : map;

        list = list_o_maps.getList();
        assert 2 == list.size();
        PropertyMap propmap1 = (PropertyMap) list.get(0);
        PropertyMap propmap2 = (PropertyMap) list.get(1);
        assert "map".equals(propmap1.getName());
        assert "map".equals(propmap2.getName());
View Full Code Here

        // tell us what package type a package is, we need this package type information to
        // intelligently "guess" what a package's type is.

        Map<String, SupportedPackageType> supportedPackageTypes = new HashMap<String, SupportedPackageType>();

        PropertyList list = config.getList("packageTypes");
        if (list != null) {
            // All of these properties must exist, any nulls should trigger runtime exceptions which is what we want
            // because if the configuration is bad, this content source should not initialize.
            List<Property> packageTypesList = list.getList();
            for (Property property : packageTypesList) {
                PropertyMap pkgType = (PropertyMap) property;
                SupportedPackageType supportedPackageType = new SupportedPackageType();
                supportedPackageType.packageTypeName = pkgType.getSimpleValue("packageTypeName", null);
                supportedPackageType.architectureName = pkgType.getSimpleValue("architectureName", null);
View Full Code Here

    }

    protected Property translateListProperty(ListPropertyType object, String defaultName) {
        String name = object.getName();
        List<Object> listXml = object.getSimplePropertyOrListPropertyOrMapProperty();
        PropertyList list = new PropertyList((name != null) ? name : defaultName);
        for (Object listItem : listXml) {
            if (listItem instanceof SimplePropertyType) {
                list.add(translateSimpleProperty((SimplePropertyType) listItem, name));
            } else if (listItem instanceof ListPropertyType) {
                list.add(translateListProperty((ListPropertyType) listItem, name));
            } else if (listItem instanceof MapPropertyType) {
                list.add(translateMapProperty((MapPropertyType) listItem, name));
            } else {
                throw new IllegalStateException("Unknown JAXB type: " + object); // did the schema change?
            }
        }
        return list;
View Full Code Here

    }

    public void startLogFileEventPollers() {
        // Grab the list-o-maps of event sources from the plugin config.
        Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
        PropertyList logEventSources = pluginConfig.getList(LOG_EVENT_SOURCES_CONFIG_PROP);
        if (logEventSources == null) {
            throw new IllegalStateException("List property [" + LOG_EVENT_SOURCES_CONFIG_PROP
                    + "] not defined in plugin configuration for " + this.resourceContext.getResourceType().getName()
                    + " Resource with key [" + this.resourceContext.getResourceKey() + "].");
        }

        // Build a new list containing the event sources that are enabled.
        List<PropertyMap> enabledEventSources = new ArrayList<PropertyMap>();
        for (Property prop : logEventSources.getList()) {
            PropertyMap logEventSource = (PropertyMap) prop;
            String enabled = logEventSource.getSimpleValue(LogEventSourcePropertyNames.ENABLED, null);
            if (enabled == null) {
                throw new IllegalStateException("Required property [" + LogEventSourcePropertyNames.ENABLED
                                    + "] is not defined in map.");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.PropertyList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.