Package org.rhq.core.domain.configuration

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


    public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) {
        PropertyList propertyList = storedPortlet.getConfiguration().getList("alert-range-resource-ids");
        if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty())
            && (propertyList.getList().get(0) != null)) {
            Property container = propertyList.getList().get(0);
            if (container instanceof PropertyList) {
                PropertyList anotherList = (PropertyList) container;
                if (anotherList.getList() != null) {
                    filterResourceIds = new Integer[anotherList.getList().size()];
                    int index = 0;
View Full Code Here


                persistedPrefs = SerialUtility.prepare(persistedPrefs, "SubjectManager.updateSubjectAndPreferences(2)");

                if (updatePrefs && changedPrefs != null) {
                    Configuration userPrefs = subjectToModify.getUserConfiguration();
                    for(String name : changedPrefs) {
                        Property prop = userPrefs.get(name);
                        if (prop == null) {
                            persistedPrefs.remove(name);
                        } else {
                            persistedPrefs.put(prop);
                        }
View Full Code Here

        if (expression.indexOf(":") != -1) {
            expression = expression.substring(0, expression.indexOf(":"));
        }

        boolean isMapOrList = expression.contains("=");
        Property p;
        if (isMapOrList) {
            String mapPropLocation = expression.substring(0, expression.indexOf("="));
            if (mapPropLocation.contains("/")) {
                mapPropLocation = mapPropLocation.substring(0, mapPropLocation.indexOf('/'));
            }
            p = configuration.get(mapPropLocation);
        } else {
            p = configuration.get(expression);
        }

        if (p == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(resource + " in " + baseResource + ": option source expression for property " + pds.getName()
                    + " and target configuration of " + foundResource + " not found");
            }
            return false;
        }
        if (!(p instanceof PropertyList)) {
            LOG.warn(resource + " in " + baseResource + ": option source expression for property " + pds.getName()
                + " and target configuration does not point to a list");
            return false;
        }
        PropertyList pl = (PropertyList) p;
        List<Property> propertyList = pl.getList();
        if (propertyList.size() == 0)
            return false;

        // Now List of simple or list of maps (of simple) ?

        if (propertyList.get(0) instanceof PropertySimple) {
            if (isMapOrList) {
                LOG.warn(resource + " in " + baseResource + ": expected a List of Maps, but got a list of simple");
                return false;
            }

            for (Property tmp : propertyList) {
                PropertySimple ps = (PropertySimple) tmp;
                String name = ps.getStringValue();
                if (name != null) {
                    PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(name, name);
                    pds.getEnumeratedValues().add(pde);
                }
            }
        } else if (propertyList.get(0) instanceof PropertyMap) {
            if (!isMapOrList) {
                LOG.warn(resource + " in " + baseResource + ": expected a List of simple, but got a list of Maps");
                return false;
            }
            String subPropName;
            subPropName = expression.substring(expression.indexOf("=") + 1);

            for (Property tmp : propertyList) {
                PropertyMap pm = (PropertyMap) tmp;
                Property ps = pm.get(subPropName);
                if (ps == null) {
                    LOG.warn(resource + " in " + baseResource + ": option source expression for property "
                        + pds.getName() + " and target configuration does not have a map element " + subPropName);
                    return false;
                }
View Full Code Here

        }
    }

    private static void unmaskProperty(String propertyName, AbstractPropertyMap parentPropertyMap,
                                       AbstractPropertyMap unmaskedParentPropertyMap) {
        Property property = parentPropertyMap.get(propertyName);
        if (property == null) {
            // The property doesn't even exist, so there's nothing to unmask.
            return;
        }
        if (unmaskedParentPropertyMap == null) {
            // The parent map does not exist in the unmasked config, so no unmasking is possible.
            return;
        }
        if (property instanceof PropertySimple) {
            PropertySimple propertySimple = (PropertySimple) property;
            unmaskPropertySimple(propertySimple, unmaskedParentPropertyMap);
        }
        // If the property is a Map, recurse into it and unmask its child properties.
        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
View Full Code Here

            ConfigurationTemplate template = updateReport.getConfigurationDefinition().getDefaultTemplate();
            Configuration templateConfiguration = template.getConfiguration();

            for (PropertyDefinition propertyDef : updateReport.getNewPropertyDefinitions()) {
                if (propertyDef.isRequired()) {
                    Property templateProperty = templateConfiguration.get(propertyDef.getName());
                    if (templateProperty == null) {
                        throw new IllegalArgumentException("The property [" + propertyDef.getName()
                            + "] marked as required in the configuration definition of ["
                            + propertyDef.getConfigurationDefinition().getName() + "] has no attribute 'default'");
                    } else {
                        // we only pull the configuration when an update is needed. The getProperties call
                        // just ensures the lazy load happens.
                        Configuration pluginConfiguration = resource.getPluginConfiguration();
                        int numberOfProperties = pluginConfiguration.getProperties().size();
                        pluginConfiguration.put(templateProperty.deepCopy(false));
                        modified = true;
                    }
                }
            }

            for (PropertyDefinition propertyDef : updateReport.getUpdatedPropertyDefinitions()) {
                if (propertyDef.isRequired()) {
                    // we only pull the configuration when an update is needed. The getProperties call
                    // just ensures the lazy load happens.
                    Configuration pluginConfiguration = resource.getPluginConfiguration();
                    int numberOfProperties = pluginConfiguration.getProperties().size();
                    String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null);
                    if (propertyValue == null) {
                        Property templateProperty = templateConfiguration.get(propertyDef.getName());
                        pluginConfiguration.put(templateProperty.deepCopy(false));
                        modified = true;
                    }
                }
            }
View Full Code Here

    private void checkForRequiredConfiguration(ServerPlugin plugin) throws Exception {
        ConfigurationDefinition configDef = getServerPluginConfigurationDefinition(new PluginKey(plugin));
        Configuration configuration = plugin.getPluginConfiguration();
        for (PropertyDefinition propDef : configDef.getPropertyDefinitions().values()) {
            if (propDef.isRequired() && propDef instanceof PropertyDefinitionSimple) {
                Property prop = configuration.get(propDef.getName());
                PropertySimple simple = (PropertySimple) prop;
                if (simple == null || simple.getStringValue() == null || "".equals(simple.getStringValue())) {
                    throw new PluginConfigurationRequiredException("Plugin [" + plugin.getDisplayName()
                        + "] could not be enabled, because some required configuration fields are not set.");
                }
View Full Code Here

            Configuration newConf = newDT.getConfiguration();
            Collection<String> exNames = existConf.getNames();
            Collection<String> newNames = newConf.getNames();
            List<String> toRemove = new ArrayList<String>();
            for (String name : exNames) {
                Property prop = newConf.get(name);
                if (prop instanceof PropertySimple) {
                    PropertySimple ps = newConf.getSimple(name);
                    if (ps != null) {
                        Property eprop = existConf.get(name);
                        if (eprop instanceof PropertySimple) {
                            PropertySimple exps = existConf.getSimple(name);
                            if (ps.getStringValue() != null) {
                                exps.setStringValue(ps.getStringValue());
                                //                                System.out.println("  updated " + name + " to value " + ps.getStringValue());
                            }
                        } else {
                            if (eprop != null) {
                                //                                System.out.println("Can't yet handle target prop: " + eprop);
                            }
                        }
                    } else { // property not in new template -> deleted
                        toRemove.add(name);
                    }
                } else {
                    if (prop != null) {
                        //                        System.out.println("Can't yet handle source prop: " + prop);
                    }
                }
            }
            for (String name : toRemove)
                existConf.remove(name);

            // now check for new names and add them
            for (String name : newNames) {
                if (!exNames.contains(name)) {
                    Property prop = newConf.get(name);
                    if (prop instanceof PropertySimple) {
                        PropertySimple ps = newConf.getSimple(name);
                        if (ps.getStringValue() != null) {
                            // TODO add a new property
                            //                            Collection<Property> properties = existConf.getProperties();
                            //                            properties = new ArrayList<Property>(properties);
                            //                            properties.add(ps);
                            //                            existConf.setProperties(properties);
                            Property property = ps.deepCopy(false);
                            existConf.put(property);
                        }
                    }
                }
            }
View Full Code Here

        Configuration defaultPluginConfig = ConfigurationUtility.createDefaultConfiguration(configDef);
        boolean configChanged = false;

        // for each property, update the existing plugin config if discovery has set a non-default value
        for (String propertyName : pluginConfig.getAllProperties().keySet()) {
            Property discoveredProp = pluginConfig.get(propertyName);
            Property defaultProp = defaultPluginConfig.get(propertyName);
            if (!discoveredProp.equals(defaultProp)) {
                if (log.isDebugEnabled()) {
                    log.debug("Discovery reported a new version of " + resource + ". Updating value of config property"
                        + " from [" + existingPluginConfig.get(propertyName) + "] to [" + discoveredProp + "].");
                }
View Full Code Here

        }
        else {
            String pList = tokens[1];
            String[] props = pList.split(",");
            for (String propName : props) {
                Property p = config.get(propName);
                if (p==null)
                    System.err.println("Property " + propName + " not found");
                else
                    System.out.println(p);
            }
View Full Code Here

        assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
        assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");

        PropertyDefinition propDef = def.get("my-name");
        Property prop = conf.get("my-name");

        assertNotNull(propDef, "Could not find the expected property definition");
        assertNotNull(prop, "Could not find the expected property");

        assertEquals(propDef.getClass(), PropertyDefinitionSimple.class, "Unexpected type of the property definition");
        assertEquals(prop.getClass(), PropertySimple.class, "Unexpecetd type of the property");

        PropertyDefinitionSimple simpleDef = (PropertyDefinitionSimple) propDef;
        PropertySimple simpleProp = (PropertySimple) prop;

        assertEquals(simpleDef.getType(), PropertySimpleType.INTEGER, "Unexpected type of the simple property definition");
View Full Code Here

TOP

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

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.