Search in sources :

Example 1 with OperationParameter

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

the class ManagementNode method performGetOperations.

private Map<String, Map<String, List<String>>> performGetOperations(final Map<String, Object> headers) {
    // TODO - enumerate management operations
    final Map<String, List<String>> managementOperations = new HashMap<>();
    return performManagementOperation(headers, clazz -> {
        final Map<String, ConfiguredObjectOperation<?>> operations = _model.getTypeRegistry().getOperations(clazz);
        Map<String, List<String>> result = new HashMap<>();
        for (Map.Entry<String, ConfiguredObjectOperation<?>> operation : operations.entrySet()) {
            List<String> arguments = new ArrayList<>();
            for (OperationParameter param : operation.getValue().getParameters()) {
                arguments.add(param.getName());
            }
            result.put(operation.getKey(), arguments);
        }
        return result;
    }, managementOperations);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) OperationParameter(org.apache.qpid.server.model.OperationParameter) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ConfiguredObjectOperation(org.apache.qpid.server.model.ConfiguredObjectOperation) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with OperationParameter

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

the class MetaDataServlet method processOperations.

private Map<String, Map> processOperations(final Class<? extends ConfiguredObject> type, final Model model) {
    Collection<ConfiguredObjectOperation<?>> operations = model.getTypeRegistry().getOperations(type).values();
    Map<String, Map> attributeDetails = new LinkedHashMap<>();
    for (ConfiguredObjectOperation<?> operation : operations) {
        Map<String, Object> attrDetails = new LinkedHashMap<>();
        attrDetails.put("name", operation.getName());
        attrDetails.put("returnType", operation.getReturnType().getSimpleName());
        if (!"".equals(operation.getDescription())) {
            attrDetails.put("description", operation.getDescription());
        }
        List<OperationParameter> parameters = operation.getParameters();
        if (!parameters.isEmpty()) {
            Map<String, Map> paramDetails = new LinkedHashMap<>();
            for (OperationParameter param : parameters) {
                Map<String, Object> paramAttrs = new LinkedHashMap<>();
                paramAttrs.put("type", param.getType().getSimpleName());
                paramAttrs.put("mandatory", param.isMandatory());
                if (!"".equals(param.getDefaultValue())) {
                    paramAttrs.put("defaultValue", param.getDefaultValue());
                }
                paramDetails.put(param.getName(), paramAttrs);
            }
            attrDetails.put("parameters", paramDetails);
        }
        attributeDetails.put(operation.getName(), attrDetails);
    }
    return attributeDetails;
}
Also used : OperationParameter(org.apache.qpid.server.model.OperationParameter) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ManagedObject(org.apache.qpid.server.model.ManagedObject) ConfiguredObjectOperation(org.apache.qpid.server.model.ConfiguredObjectOperation) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with OperationParameter

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

the class ApiDocsServlet method renderParameters.

private String renderParameters(final List<OperationParameter> parameters) {
    StringBuilder writer = new StringBuilder();
    writer.append("<table class=\"parameters\">");
    writer.append("<thead>");
    writer.append("<tr><th class=\"name\">Parameter Name</th><th>Type</th><th>Default</th><th>Mandatory?</th><th>Description</th></tr>");
    writer.append("</thead>");
    writer.append("<tbody>");
    for (OperationParameter param : parameters) {
        writer.append("<tr><td class=\"name\">" + param.getName() + "</td><td class=\"type\">" + renderType(param) + "</td><td class=\"default\">" + param.getDefaultValue() + "</td><td class=\"mandatory\">" + param.isMandatory() + "</td><td class=\"description\">" + param.getDescription() + "</td></tr>");
    }
    writer.append("</tbody>");
    writer.append("</table>");
    return writer.toString();
}
Also used : OperationParameter(org.apache.qpid.server.model.OperationParameter)

Aggregations

OperationParameter (org.apache.qpid.server.model.OperationParameter)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConfiguredObjectOperation (org.apache.qpid.server.model.ConfiguredObjectOperation)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 ManagedObject (org.apache.qpid.server.model.ManagedObject)1