/** * Returns a map of all <i>direct</i> children of this Configuration that are of type {@link PropertyList}. The * returned map is keyed on the {@link PropertyList}'s names. * * @return map containing of all of the Configuration's direct {@link PropertyList} children */ @NotNull public Map<String, PropertyList> getListProperties() { Map<String, PropertyList> map = new LinkedHashMap<String, PropertyList>(); for (Property prop : this.getProperties()) { if (prop instanceof PropertyList) { map.put(prop.getName(), (PropertyList) prop); } } return map; }
/** * Returns a map of all <i>direct</i> children of this Configuration that are of type {@link PropertySimple}. The * returned map is keyed on the {@link PropertySimple}'s names. * * @return map containing of all of the Configuration's direct {@link PropertySimple} children */ @NotNull public Map<String, PropertySimple> getSimpleProperties() { Map<String, PropertySimple> map = new LinkedHashMap<String, PropertySimple>(); for (Property prop : this.getProperties()) { if (prop instanceof PropertySimple) { map.put(prop.getName(), (PropertySimple) prop); } } return map; }
/** * Returns a map of all <i>direct</i> children of this Configuration that are of type {@link PropertyMap}. The * returned map is keyed on the {@link PropertyMap}'s names. * * @return map containing of all of the Configuration's direct {@link PropertyMap} children */ @NotNull public Map<String, PropertyMap> getMapProperties() { Map<String, PropertyMap> map = new LinkedHashMap<String, PropertyMap>(); for (Property prop : this.getProperties()) { if (prop instanceof PropertyMap) { map.put(prop.getName(), (PropertyMap) prop); } } return map; }
public AlertNotification getAlertNotification(Subject user, int alertNotificationId) { AlertNotification notification = entityManager.find(AlertNotification.class, alertNotificationId); if (notification == null) { return null; } notification.getConfiguration().getProperties().size(); // eager load the alert properties if (notification.getExtraConfiguration() != null) { notification.getExtraConfiguration().getProperties().size(); // eager load the extra alert properties } return notification; }
private void showConfig(Configuration config, String[] tokens) { if (tokens==null || tokens.length<2) { for (Property p : config.getProperties()) { System.out.println(p); } } 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); } } }
/** * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#loadUserConfiguration(Integer) */ public Subject loadUserConfiguration(Integer subjectId) { Subject subject = entityManager.find(Subject.class, subjectId); Configuration config = subject.getUserConfiguration(); if ((config != null) && (config.getProperties() != null)) { config.getProperties().size(); // force it to load } if (subject.getRoles() != null) { subject.getRoles().size(); } return subject; }
private void prepareConfigForMergeIntoStructured(Configuration config, Configuration latestStructured) { config.getAllProperties().clear(); for (Property property : latestStructured.getProperties()) { config.put(property); } }
public static void prettyPrintConfiguration(Configuration configuration) { System.out.println("Configuration: " + configuration.getNotes()); for (Property p : configuration.getProperties()) { prettyPrintProperty(p, 1); } }
/** * Allow users to see a preview of the stored configuration data without having to edit it. * A default implementation is already provided which will print the properties in alphabetical * order, one per line, each followed by a string representation of that property's data. */ public String previewConfiguration() { StringBuilder builder = new StringBuilder(); List<Property> properties = new ArrayList<Property>(alertParameters.getProperties()); Collections.sort(properties); // alpha sort by property name boolean first = true; for (Property next : properties) { if (first) { first = false; } else { builder.append(" | "); } builder.append(next.getName()); builder.append(": "); builder.append(printProperty(next)); } return builder.toString(); }
private void compactConfiguration(Configuration config) { if (config == null) { return; } if (config.getProperties() == null) { return; } for (Property prop : config.getProperties()) { if (prop.getName() != null) { prop.setName(prop.getName().intern()); } } config.resize(); }
if (configuration.getProperties().isEmpty()) { return result; for (Property property : configuration.getProperties()) {
/** * Return notifications for a certain alertDefinitionId * * NOTE: this only returns notifications that have an AlertSender defined. * * @param user Subject of the caller * @param alertDefinitionId Id of the alert definition * @return list of defined notification of the passed alert definition * * */ public List<AlertNotification> getNotificationsForAlertDefinition(Subject user, int alertDefinitionId) { AlertDefinition definition = alertDefinitionManager.getAlertDefinition(user, alertDefinitionId); if (definition == null) { LOG.error("Did not find definition for id [" + alertDefinitionId + "]"); return new ArrayList<AlertNotification>(); } List<AlertNotification> notifications = definition.getAlertNotifications(); for (AlertNotification notification : notifications) { notification.getConfiguration().getProperties().size(); // eager load if (notification.getExtraConfiguration() != null) { notification.getExtraConfiguration().getProperties().size(); } } return notifications; }
@Override public DriftDefinition getDriftDefinition(Subject subject, int driftDefId) { DriftDefinition result = entityManager.find(DriftDefinition.class, driftDefId); if (null == result) { throw new IllegalArgumentException("Drift Definition Id [" + driftDefId + "] not found."); } // force lazy loads result.getConfiguration().getProperties(); Hibernate.initialize(result.getResource()); Hibernate.initialize(result.getTemplate()); return result; }
public void updateResourceConfiguration(AugeasNode node, ConfigurationDefinition resourceConfigDef, Configuration resourceConfig) throws AugeasRhqException { Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values(); PropertyMap startProp = new PropertyMap(); for (Property property : resourceConfig.getProperties()) startProp.put(property); for (PropertyDefinition propDef : propDefs) { updateProperty(propDef, startProp, node, 0); } }
ConnectionStringAvailableProperties(ResourceContainer container, MeasurementManager measurementManager, Configuration deploymentConfiguration) { this.resourceContainer = container; this.measurementManager = measurementManager; this.pluginConfiguration = new HashMap<String, Property>(); for (Property p : container.getResource().getPluginConfiguration().getProperties()) { pluginConfiguration.put("pluginConfiguration." + p.getName(), p); } this.resourceConfiguration = new HashMap<String, Property>(); for (Property p : InventoryManager.getResourceConfiguration(container.getResource()) .getProperties()) { resourceConfiguration.put("resourceConfiguration." + p.getName(), p); } this.traits = new HashMap<String, String>(); for (MeasurementScheduleRequest r : container.getMeasurementSchedule()) { if (r.getDataType() == DataType.TRAIT) { traits.put("measurementTrait." + r.getName(), r.getName()); } } this.deploymentConfiguration = new HashMap<String, Property>(); for (Property p : deploymentConfiguration.getProperties()) { this.deploymentConfiguration.put("deploymentConfiguration." + p.getName(), p); } }
@Override public AlertDefinition getAlertDefinitionById(Subject subject, int alertDefinitionId) { AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefinitionId); if (alertDefinition == null) { return null; // fail-fast to avoid downstream NPEs } if (checkViewPermission(subject, alertDefinition) == false) { throw new PermissionException("User[" + subject.getName() + "] does not have permission to view alertDefinition[id=" + alertDefinitionId + "] for resource[id=" + alertDefinition.getResource().getId() + "]"); } alertDefinition.getConditions().size(); // this is now lazy for (AlertCondition cond : alertDefinition.getConditions()) { if (cond.getMeasurementDefinition() != null) { cond.getMeasurementDefinition().getId(); } } // DO NOT LOAD ALL ALERTS FOR A DEFINITION... This would be all alerts that have been fired //alertDefinition.getAlertsForResource().size(); for (AlertNotification notification : alertDefinition.getAlertNotifications()) { notification.getConfiguration().getProperties().size(); // eager load configuration and properties too if (notification.getExtraConfiguration() != null) { notification.getExtraConfiguration().getProperties().size(); } } return alertDefinition; }
/** * This will populate the given configuration definition with a default template. * A default template will only be created if one or more properties are required * or have default values. If no property definition is required or has a default value, * the default template will remain <code>null</code> in the given config definition. * * Note that if the given configuration definition already has a default template defined * for it, this method is a no-op and will return immediately. * * @param configDef the configuration definition whose default template is to be created and set */ public static void initializeDefaultTemplate(ConfigurationDefinition configDef) { ConfigurationTemplate defaultTemplate = configDef.getDefaultTemplate(); if (defaultTemplate == null) { Configuration defaultConfig = createDefaultConfiguration(configDef); // not everything should have a default template - only stuff that has default values if (!defaultConfig.getProperties().isEmpty()) { defaultTemplate = new ConfigurationTemplate(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME, ConfigurationTemplate.DEFAULT_TEMPLATE_NAME); defaultTemplate.setDefault(true); defaultTemplate.setConfiguration(defaultConfig); configDef.putTemplate(defaultTemplate); } } return; }
config.getProperties().add(ps);
for (Property property : newConfig.getProperties()) { templateConfig.put(property);
int numberOfProperties = pluginConfiguration.getProperties().size(); pluginConfiguration.put(templateProperty.deepCopy(false)); modified = true; int numberOfProperties = pluginConfiguration.getProperties().size(); String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null); if (propertyValue == null) {