qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1688819 - /qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
Date Thu, 02 Jul 2015 13:10:26 GMT
Author: orudyy
Date: Thu Jul  2 13:10:26 2015
New Revision: 1688819

URL: http://svn.apache.org/r1688819
Log:
QPID-6617: Set correct error response in case of exception in RestServlet GET handling (work
by Lorenz Quack)

Modified:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1688819&r1=1688818&r2=1688819&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
Thu Jul  2 13:10:26 2015
@@ -339,68 +339,75 @@ public class RestServlet extends Abstrac
     @Override
     protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
     {
-        String[] pathInfoElements = getPathInfoElements(request);
-        if (pathInfoElements != null && pathInfoElements.length == _hierarchy.length
+ 1)
+        try
         {
-            doOperation(request, response);
-        }
-        else
-        {
-            // TODO - sort special params, everything else should act as a filter
-            String attachmentFilename = request.getParameter(CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM);
-            boolean extractInitialConfig = getBooleanParameterFromRequest(request, EXTRACT_INITIAL_CONFIG_PARAM);
-
-            if (attachmentFilename != null)
-            {
-                setContentDispositionHeaderIfNecessary(response, attachmentFilename);
-            }
-
-            Collection<ConfiguredObject<?>> allObjects = getObjects(request);
-
-            if (allObjects.isEmpty() && isSingleObjectRequest(request))
+            String[] pathInfoElements = getPathInfoElements(request);
+            if (pathInfoElements != null && pathInfoElements.length == _hierarchy.length
+ 1)
             {
-                sendJsonErrorResponse(request, response, HttpServletResponse.SC_NOT_FOUND,
"Not Found");
-                return;
-            }
-
-            int depth;
-            boolean actuals;
-            boolean includeSystemContext;
-            boolean inheritedActuals;
-            int oversizeThreshold;
-
-            if (extractInitialConfig)
-            {
-                depth = Integer.MAX_VALUE;
-                oversizeThreshold = Integer.MAX_VALUE;
-                actuals = true;
-                includeSystemContext = false;
-                inheritedActuals = false;
+                doOperation(request, response);
             }
             else
             {
-                depth = getIntParameterFromRequest(request, DEPTH_PARAM, DEFAULT_DEPTH);
-                oversizeThreshold = getIntParameterFromRequest(request, OVERSIZE_PARAM, DEFAULT_OVERSIZE);
-                actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM);
-                includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM);
-                inheritedActuals = getBooleanParameterFromRequest(request, INHERITED_ACTUALS_PARAM);
-            }
-
-            List<Map<String, Object>> output = new ArrayList<>();
-            for (ConfiguredObject configuredObject : allObjects)
-            {
-
-                output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(),
-                        depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig,
oversizeThreshold, request.isSecure()));
+                // TODO - sort special params, everything else should act as a filter
+                String attachmentFilename = request.getParameter(CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM);
+                boolean extractInitialConfig = getBooleanParameterFromRequest(request, EXTRACT_INITIAL_CONFIG_PARAM);
+
+                if (attachmentFilename != null)
+                {
+                    setContentDispositionHeaderIfNecessary(response, attachmentFilename);
+                }
+
+                Collection<ConfiguredObject<?>> allObjects = getObjects(request);
+
+                if (allObjects.isEmpty() && isSingleObjectRequest(request))
+                {
+                    sendJsonErrorResponse(request, response, HttpServletResponse.SC_NOT_FOUND,
"Not Found");
+                    return;
+                }
+
+                int depth;
+                boolean actuals;
+                boolean includeSystemContext;
+                boolean inheritedActuals;
+                int oversizeThreshold;
+
+                if (extractInitialConfig)
+                {
+                    depth = Integer.MAX_VALUE;
+                    oversizeThreshold = Integer.MAX_VALUE;
+                    actuals = true;
+                    includeSystemContext = false;
+                    inheritedActuals = false;
+                }
+                else
+                {
+                    depth = getIntParameterFromRequest(request, DEPTH_PARAM, DEFAULT_DEPTH);
+                    oversizeThreshold = getIntParameterFromRequest(request, OVERSIZE_PARAM,
DEFAULT_OVERSIZE);
+                    actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM);
+                    includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM);
+                    inheritedActuals = getBooleanParameterFromRequest(request, INHERITED_ACTUALS_PARAM);
+                }
+
+                List<Map<String, Object>> output = new ArrayList<>();
+                for (ConfiguredObject configuredObject : allObjects)
+                {
+
+                    output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(),
+                            depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig,
oversizeThreshold, request.isSecure()));
+                }
+
+
+                boolean sendCachingHeaders = attachmentFilename == null;
+                sendJsonResponse(extractInitialConfig && output.size() == 1 ? output.get(0)
: output,
+                        request,
+                        response,
+                        HttpServletResponse.SC_OK,
+                        sendCachingHeaders);
             }
-
-
-            boolean sendCachingHeaders = attachmentFilename == null;
-            sendJsonResponse(extractInitialConfig && output.size() == 1 ? output.get(0)
: output,
-                    request,
-                    response,
-                    HttpServletResponse.SC_OK,
-                    sendCachingHeaders);
+        }
+        catch (RuntimeException e)
+        {
+            setResponseStatus(request, response, e);
         }
     }
 



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


Mime
View raw message