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;
}
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");
}
}
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;
}
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;
}
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;
}
Aggregations