Search in sources :

Example 96 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQuery method evaluateResults.

private List<List<Object>> evaluateResults(final List<ConfiguredObject<?>> filteredObjects, List<Expression> valueExpressions) {
    List<List<Object>> values = new ArrayList<>();
    for (ConfiguredObject<?> object : filteredObjects) {
        List<Object> objectVals = new ArrayList<>();
        for (Expression<ConfiguredObject<?>> evaluator : valueExpressions) {
            Object value;
            try {
                value = evaluator.evaluate(object);
            } catch (RuntimeException e) {
                LOGGER.debug("Error while evaluating select clause", e);
                value = null;
            }
            objectVals.add(value);
        }
        values.add(objectVals);
    }
    return values;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 97 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class DestinationController method findExchange.

private LegacyConfiguredObject findExchange(final ConfiguredObject<?> root, final List<String> path, final Predicate<LegacyConfiguredObject> predicate) {
    final Collection<String> hierarchy = getNextVersionManagementController().getCategoryHierarchy(root, ExchangeController.TYPE);
    final List<String> exchangePath = path.size() > hierarchy.size() - 1 ? path.subList(0, hierarchy.size() - 1) : path;
    final Object result = getNextVersionManagementController().get(root, ExchangeController.TYPE, exchangePath, Collections.emptyMap());
    if (result instanceof Collection) {
        final Collection<?> exchanges = (Collection<?>) result;
        return exchanges.stream().filter(LegacyConfiguredObject.class::isInstance).map(LegacyConfiguredObject.class::cast).filter(predicate).findFirst().orElse(null);
    } else {
        throw createBadRequestManagementException("Cannot find alternate exchange");
    }
}
Also used : GenericLegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Collection(java.util.Collection) GenericLegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)

Example 98 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class GenericCategoryController method createOrUpdate.

@Override
public LegacyConfiguredObject createOrUpdate(ConfiguredObject<?> root, List<String> path, Map<String, Object> attributes, boolean isPost) throws ManagementException {
    final Map<String, Object> body = convertAttributesToNextVersion(root, path, attributes);
    final Object configuredObject = _nextVersionManagementController.createOrUpdate(root, getNextVersionCategory(), path, body, isPost);
    if (configuredObject instanceof LegacyConfiguredObject) {
        LegacyConfiguredObject object = (LegacyConfiguredObject) configuredObject;
        return convertFromNextVersion(object);
    }
    return null;
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 99 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class MetaDataServlet method processType.

private Map<String, Object> processType(final Class<? extends ConfiguredObject> type, final Model model) {
    Map<String, Object> typeDetails = new LinkedHashMap<>();
    typeDetails.put("attributes", processAttributes(type, model));
    typeDetails.put("statistics", processStatistics(type, model));
    typeDetails.put("operations", processOperations(type, model));
    typeDetails.put("managedInterfaces", getManagedInterfaces(type, model));
    typeDetails.put("validChildTypes", getValidChildTypes(type, model));
    typeDetails.put("contextDependencies", getContextDependencies(type, model));
    ManagedObject annotation = type.getAnnotation(ManagedObject.class);
    if (annotation != null) {
        if (annotation.deprecated()) {
            typeDetails.put("deprecated", true);
        }
        if (!"".equals(annotation.description())) {
            typeDetails.put("description", annotation.description());
        }
    }
    return typeDetails;
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ManagedObject(org.apache.qpid.server.model.ManagedObject) ManagedObject(org.apache.qpid.server.model.ManagedObject) LinkedHashMap(java.util.LinkedHashMap)

Example 100 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class MetaDataServlet method processAttributes.

private Map<String, Map> processAttributes(final Class<? extends ConfiguredObject> type, final Model model) {
    Collection<ConfiguredObjectAttribute<?, ?>> attributes = model.getTypeRegistry().getAttributeTypes(type).values();
    Map<String, Map> attributeDetails = new LinkedHashMap<>();
    for (ConfiguredObjectAttribute<?, ?> attribute : attributes) {
        Map<String, Object> attrDetails = new LinkedHashMap<>();
        attrDetails.put("type", attribute.getType().getSimpleName());
        if (!"".equals(attribute.getDescription())) {
            attrDetails.put("description", attribute.getDescription());
        }
        if (attribute.isDerived()) {
            attrDetails.put("derived", attribute.isDerived());
        }
        if (!attribute.isDerived()) {
            ConfiguredSettableAttribute automatedAttribute = (ConfiguredSettableAttribute) attribute;
            if (!"".equals(automatedAttribute.defaultValue())) {
                attrDetails.put("defaultValue", automatedAttribute.defaultValue());
            }
            if (automatedAttribute.isMandatory()) {
                attrDetails.put("mandatory", automatedAttribute.isMandatory());
            }
            if (automatedAttribute.isImmutable()) {
                attrDetails.put("immutable", automatedAttribute.isImmutable());
            }
            if (!(automatedAttribute.validValues()).isEmpty()) {
                Collection<String> validValues = ((ConfiguredSettableAttribute<?, ?>) attribute).validValues();
                Collection<Object> convertedValues = new ArrayList<>(validValues.size());
                for (String value : validValues) {
                    convertedValues.add(((ConfiguredSettableAttribute<?, ?>) attribute).convert(value, null));
                }
                attrDetails.put("validValues", convertedValues);
            } else if (!"".equals(automatedAttribute.validValuePattern())) {
                attrDetails.put("validValuesPattern", automatedAttribute.validValuePattern());
            }
        }
        if (attribute.isSecure()) {
            attrDetails.put("secure", attribute.isSecure());
        }
        if (attribute.isOversized()) {
            attrDetails.put("oversize", attribute.isOversized());
        }
        attributeDetails.put(attribute.getName(), attrDetails);
    }
    return attributeDetails;
}
Also used : ConfiguredObjectAttribute(org.apache.qpid.server.model.ConfiguredObjectAttribute) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ConfiguredSettableAttribute(org.apache.qpid.server.model.ConfiguredSettableAttribute) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ManagedObject(org.apache.qpid.server.model.ManagedObject) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)117 ArrayList (java.util.ArrayList)43 HashMap (java.util.HashMap)35 Test (org.junit.Test)33 Map (java.util.Map)29 List (java.util.List)27 LinkedHashMap (java.util.LinkedHashMap)25 UUID (java.util.UUID)21 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)21 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)15 Collection (java.util.Collection)12 LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)12 ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)12 ManagedObject (org.apache.qpid.server.model.ManagedObject)11 State (org.apache.qpid.server.model.State)10 Date (java.util.Date)7 TreeMap (java.util.TreeMap)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 GenericLegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject)6 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)6