You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/12/21 15:13:08 UTC

[qpid-broker-j] branch master updated (919675f -> 11f3052)

This is an automated email from the ASF dual-hosted git repository.

orudyy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git.


    from 919675f  [maven-release-plugin] prepare for next development iteration
     new eb4c0d1  QPID-8259: [Broker-J] Fix generation of json response for operations returning void
     new 92d5fa5  QPID-8259: [Broker-J] Fix handling of requests for unsupported category
     new 11f3052  QPID-8259: [Broker-J] REST requests returning inherited context should be able to return the inherited context from SystemConfig in REST API for versions 6.1 and 7.0

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../latest/LatestManagementController.java         | 20 +++++++++---
 .../controller/v6_1/category/BrokerController.java | 15 ++++++++-
 .../category/LegacyCategoryControllerFactory.java  |  1 +
 .../v7_0/category/ContainerController.java         | 14 ++++++++
 .../category/LegacyCategoryControllerFactory.java  |  2 +-
 .../plugin/servlet/rest/RestServlet.java           | 13 +++-----
 .../org/apache/qpid/tests/http/HttpTestHelper.java |  9 +++--
 .../qpid/tests/http/rest/model/OperationTest.java  | 38 ++++++++++++++++++++++
 8 files changed, 95 insertions(+), 17 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-broker-j] 03/03: QPID-8259: [Broker-J] REST requests returning inherited context should be able to return the inherited context from SystemConfig in REST API for versions 6.1 and 7.0

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git

commit 11f3052dcf847bed781236dda46fe0b72839fe3b
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Fri Dec 21 15:04:32 2018 +0000

    QPID-8259: [Broker-J] REST requests returning inherited context should be able to return the inherited context from SystemConfig in REST API for versions 6.1 and 7.0
---
 .../plugin/controller/v6_1/category/BrokerController.java | 15 ++++++++++++++-
 .../v6_1/category/LegacyCategoryControllerFactory.java    |  1 +
 .../controller/v7_0/category/ContainerController.java     | 14 ++++++++++++++
 .../v7_0/category/LegacyCategoryControllerFactory.java    |  2 +-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerController.java
index 28005df..5cdc76a 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/BrokerController.java
@@ -62,7 +62,7 @@ public class BrokerController extends LegacyCategoryController
     {
         super(legacyManagementController,
               TYPE,
-              new String[0],
+              new String[]{LegacyCategoryControllerFactory.CATEGORY_SYSTEM_CONFIG},
               "Broker",
               typeControllers);
     }
@@ -208,5 +208,18 @@ public class BrokerController extends LegacyCategoryController
         {
             return !BROKER_ATTRIBUTES_MOVED_INTO_CONTEXT.containsKey(name) && super.isOversizedAttribute(name);
         }
+
+        @Override
+        public LegacyConfiguredObject getParent(final String category)
+        {
+            if (LegacyCategoryControllerFactory.CATEGORY_SYSTEM_CONFIG.equals(category))
+            {
+                LegacyConfiguredObject nextVersionParent = getNextVersionLegacyConfiguredObject().getParent(category);
+                return new GenericLegacyConfiguredObject(getManagementController(),
+                                                         nextVersionParent,
+                                                         category);
+            }
+            return super.getParent(category);
+        }
     }
 }
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
index 9f49dab..5878851 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v6_1/category/LegacyCategoryControllerFactory.java
@@ -63,6 +63,7 @@ public class LegacyCategoryControllerFactory implements CategoryControllerFactor
     static final String CATEGORY_CONSUMER = ConsumerController.TYPE;
     static final String CATEGORY_CONNECTION = "Connection";
     static final String CATEGORY_SESSION = SessionController.TYPE;
+    static final String CATEGORY_SYSTEM_CONFIG = "SystemConfig";
     static final Set<String> SUPPORTED_CATEGORIES =
             Collections.unmodifiableSet(new HashSet<>(Arrays.asList(CATEGORY_BROKER,
                                                                     CATEGORY_BROKER_LOGGER,
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/ContainerController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/ContainerController.java
index 44a34e5..0c39f8f 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/ContainerController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/ContainerController.java
@@ -76,5 +76,19 @@ class ContainerController extends LegacyCategoryController
             }
             return super.getActualAttribute(name);
         }
+
+        @Override
+        public LegacyConfiguredObject getParent(final String category)
+        {
+            if (LegacyCategoryControllerFactory.CATEGORY_BROKER.equals(getCategory())
+                && LegacyCategoryControllerFactory.CATEGORY_SYSTEM_CONFIG.equals(category))
+            {
+                LegacyConfiguredObject nextVersionParent = getNextVersionLegacyConfiguredObject().getParent(category);
+                return new GenericLegacyConfiguredObject(getManagementController(),
+                                                         nextVersionParent,
+                                                         category);
+            }
+            return super.getParent(category);
+        }
     }
 }
diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
index 3f07cc3..92373b9 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/v7_0/category/LegacyCategoryControllerFactory.java
@@ -59,7 +59,7 @@ public class LegacyCategoryControllerFactory implements CategoryControllerFactor
     private static final String CATEGORY_CONSUMER = "Consumer";
     private static final String CATEGORY_CONNECTION = "Connection";
     private static final String CATEGORY_SESSION = "Session";
-    private static final String CATEGORY_SYSTEM_CONFIG = "SystemConfig";
+    static final String CATEGORY_SYSTEM_CONFIG = "SystemConfig";
     static final Map<String, String> SUPPORTED_CATEGORIES =
             Collections.unmodifiableMap(new HashMap<String, String>()
             {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-broker-j] 02/03: QPID-8259: [Broker-J] Fix handling of requests for unsupported category

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git

commit 92d5fa590817a2aa69840d10bcb967b31a19e2ed
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Fri Dec 21 14:50:13 2018 +0000

    QPID-8259: [Broker-J] Fix handling of requests for unsupported category
---
 .../latest/LatestManagementController.java          | 20 ++++++++++++++++----
 .../qpid/tests/http/rest/model/OperationTest.java   | 21 +++++++++++++++++++++
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
index 18b457a..7a32153 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/controller/latest/LatestManagementController.java
@@ -92,6 +92,7 @@ public class LatestManagementController extends AbstractManagementController
 
     private static final int DEFAULT_DEPTH = 0;
     private static final int DEFAULT_OVERSIZE = 120;
+    private static final Class<? extends ConfiguredObject>[] EMPTY_HIERARCHY = new Class[0];
 
 
     private final ConcurrentMap<ConfiguredObject<?>, ConfiguredObjectFinder> _configuredObjectFinders =
@@ -172,7 +173,7 @@ public class LatestManagementController extends AbstractManagementController
         final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
         final String category = request.getCategory();
         final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
-        final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+        final Class<? extends ConfiguredObject>[] hierarchy = getHierarchy(finder, configuredClass);
         return getManagementRequestType(request.getMethod(), category, request.getPath(), hierarchy);
     }
 
@@ -239,7 +240,7 @@ public class LatestManagementController extends AbstractManagementController
             if (hierarchy.size() > 1)
             {
                 final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
-                theParent = finder.findObjectParentsFromPath(path, finder.getHierarchy(categoryClass), categoryClass);
+                theParent = finder.findObjectParentsFromPath(path, getHierarchy(finder, categoryClass), categoryClass);
             }
 
             final boolean isFullObjectURL = path.size() == hierarchy.size();
@@ -628,7 +629,7 @@ public class LatestManagementController extends AbstractManagementController
         final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
         final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
         Collection<ConfiguredObject<?>> targetObjects =
-                finder.findObjectsFromPath(path, finder.getHierarchy(configuredClass), true);
+                finder.findObjectsFromPath(path, getHierarchy(finder, configuredClass), true);
 
         if (targetObjects == null)
         {
@@ -641,6 +642,17 @@ public class LatestManagementController extends AbstractManagementController
         return targetObjects;
     }
 
+    private Class<? extends ConfiguredObject>[] getHierarchy(final ConfiguredObjectFinder finder,
+                                                             final Class<? extends ConfiguredObject> configuredClass)
+    {
+        final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+        if (hierarchy == null)
+        {
+            return EMPTY_HIERARCHY;
+        }
+        return hierarchy;
+    }
+
     private RequestType getManagementRequestType(final String method,
                                                  final String categoryName,
                                                  final List<String> parts,
@@ -829,7 +841,7 @@ public class LatestManagementController extends AbstractManagementController
         final Class<? extends ConfiguredObject> configuredClass = getRequestCategoryClass(category, root.getModel());
         final ConfiguredObject<?> target;
         final ConfiguredObjectFinder finder = getConfiguredObjectFinder(root);
-        final Class<? extends ConfiguredObject>[] hierarchy = finder.getHierarchy(configuredClass);
+        final Class<? extends ConfiguredObject>[] hierarchy = getHierarchy(finder, configuredClass);
         if (names.isEmpty() && hierarchy.length == 0)
         {
             target = root;
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
index ade744a..6a06855 100644
--- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
@@ -106,4 +106,25 @@ public class OperationTest extends HttpTestBase
                                                     SC_OK);
         assertThat(response, is(nullValue()));
     }
+
+    @Test
+    public void invokeOperationForUnknownCategory() throws Exception
+    {
+
+        try
+        {
+            getHelper().postJson("broker/performGC",
+                                 Collections.emptyMap(),
+                                 new TypeReference<Void>()
+                                 {
+                                 },
+                                 SC_NOT_FOUND);
+            fail("The request is executed against root object VirtualHost. Thus, any broker request should fail.");
+        }
+        catch (FileNotFoundException e)
+        {
+            //pass
+        }
+
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-broker-j] 01/03: QPID-8259: [Broker-J] Fix generation of json response for operations returning void

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orudyy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git

commit eb4c0d16913295d8a5e081b18052bc5e93cc306c
Author: Alex Rudyy <or...@apache.org>
AuthorDate: Fri Dec 21 14:48:10 2018 +0000

    QPID-8259: [Broker-J] Fix generation of json response for operations returning void
---
 .../management/plugin/servlet/rest/RestServlet.java     | 13 ++++---------
 .../java/org/apache/qpid/tests/http/HttpTestHelper.java |  9 +++++++--
 .../qpid/tests/http/rest/model/OperationTest.java       | 17 +++++++++++++++++
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
index 9a53d11..ed41fcd 100644
--- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
+++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
@@ -255,23 +255,18 @@ public class RestServlet extends AbstractServlet
                 content.release();
             }
         }
-        else if (body != null)
+        else
         {
             response.setContentType(APPLICATION_JSON);
-            Object data;
-            if (managementResponse.getType() == ResponseType.MODEL_OBJECT)
+            if (body != null && managementResponse.getType() == ResponseType.MODEL_OBJECT)
             {
-                data = controller.formatConfiguredObject(
+                body = controller.formatConfiguredObject(
                         managementResponse.getBody(),
                         parameters,
                         managementRequest.isSecure()
                         || managementRequest.isConfidentialOperationAllowedOnInsecureChannel());
             }
-            else
-            {
-                data = managementResponse.getBody();
-            }
-            writeJsonResponse(data, request, response);
+            writeJsonResponse(body, request, response);
         }
     }
 
diff --git a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java
index 04bb288..ef6d9b1 100644
--- a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java
+++ b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java
@@ -28,6 +28,7 @@ import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.security.KeyManagementException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -241,7 +242,9 @@ public class HttpTestHelper
             responseCode = connection.getResponseCode();
             Assert.assertEquals(String.format("Unexpected response code from : %s", path), expectedResponseCode, responseCode);
 
-            return new ObjectMapper().readValue(new ByteArrayInputStream(readConnectionInputStream(connection)), valueTypeRef);
+            byte[] data = readConnectionInputStream(connection);
+            LOGGER.debug("Response : {}", new String(data, StandardCharsets.UTF_8));
+            return new ObjectMapper().readValue(new ByteArrayInputStream(data), valueTypeRef);
         }
         finally
         {
@@ -263,7 +266,9 @@ public class HttpTestHelper
             responseCode = connection.getResponseCode();
             Assert.assertEquals(String.format("Unexpected response code from : %s", path), expectedResponseCode, responseCode);
 
-            return new ObjectMapper().readValue(new ByteArrayInputStream(readConnectionInputStream(connection)), valueTypeRef);
+            byte[] buf = readConnectionInputStream(connection);
+            LOGGER.debug("Response data: {}", new String(buf, StandardCharsets.UTF_8));
+            return new ObjectMapper().readValue(new ByteArrayInputStream(buf), valueTypeRef);
         }
         finally
         {
diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
index 4ce88a4..ade744a 100644
--- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
+++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/rest/model/OperationTest.java
@@ -26,8 +26,11 @@ import static org.apache.qpid.server.management.plugin.servlet.rest.AbstractServ
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.nullValue;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
 
+import java.io.FileNotFoundException;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -37,6 +40,7 @@ import org.junit.Test;
 
 import org.apache.qpid.tests.http.HttpRequestConfig;
 import org.apache.qpid.tests.http.HttpTestBase;
+import org.apache.qpid.tests.http.HttpTestHelper;
 
 @HttpRequestConfig
 public class OperationTest extends HttpTestBase
@@ -89,4 +93,17 @@ public class OperationTest extends HttpTestBase
     {
         getHelper().submitRequest("virtualhost/notfound", "POST", Collections.emptyMap(), SC_NOT_FOUND);
     }
+
+    @Test
+    public void invokeOperationReturningVoid() throws Exception
+    {
+        final HttpTestHelper brokerHelper = new HttpTestHelper(getBrokerAdmin());
+        final Void response = brokerHelper.postJson("broker/performGC",
+                                                    Collections.emptyMap(),
+                                                    new TypeReference<Void>()
+                                                    {
+                                                    },
+                                                    SC_OK);
+        assertThat(response, is(nullValue()));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org