Search in sources :

Example 6 with ConfiguredObjectOperation

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

the class ManagementNode method performOperation.

private InternalMessage performOperation(final Class<? extends ConfiguredObject> clazz, final String operation, InternalMessage message) {
    try {
        if (STANDARD_OPERATIONS.contains(operation)) {
            StandardOperation standardOperation;
            if ((standardOperation = _standardOperations.get(clazz).get(operation)) != null) {
                return standardOperation.performOperation(clazz, message);
            }
        } else {
            final InternalMessageHeader requestHeader = message.getMessageHeader();
            final Map<String, Object> headers = requestHeader.getHeaderMap();
            ConfiguredObject<?> object = findObject(clazz, headers);
            if (object == null) {
                return createFailureResponse(message, STATUS_CODE_NOT_FOUND, "Not found");
            }
            final Map<String, ConfiguredObjectOperation<?>> operations = _model.getTypeRegistry().getOperations(object.getClass());
            @SuppressWarnings("unchecked") final ConfiguredObjectOperation<ConfiguredObject<?>> method = (ConfiguredObjectOperation<ConfiguredObject<?>>) operations.get(operation);
            if (method != null) {
                return performConfiguredObjectOperation(object, message, method);
            }
        }
        return createFailureResponse(message, STATUS_CODE_NOT_IMPLEMENTED, "Not implemented");
    } catch (RuntimeException e) {
        return createFailureResponse(message, STATUS_CODE_INTERNAL_ERROR, e.getMessage());
    }
}
Also used : InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) ManagedObject(org.apache.qpid.server.model.ManagedObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObjectOperation(org.apache.qpid.server.model.ConfiguredObjectOperation)

Aggregations

ConfiguredObjectOperation (org.apache.qpid.server.model.ConfiguredObjectOperation)6 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 HashMap (java.util.HashMap)3 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 ManagedObject (org.apache.qpid.server.model.ManagedObject)2 OperationParameter (org.apache.qpid.server.model.OperationParameter)2 ParameterizedType (java.lang.reflect.ParameterizedType)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)1 Content (org.apache.qpid.server.model.Content)1