summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2015-03-16 09:08:59 +0000
committerRobert Godfrey <rgodfrey@apache.org>2015-03-16 09:08:59 +0000
commit15a0805961d67db689552c1a2494909b29d1cb00 (patch)
tree3c6bddd54403699db357a5db1f589dcc5dd4d17a /qpid/java
parent1fa496fbf25aa9b30c61a0b73ded9549d407aa3c (diff)
downloadqpid-python-15a0805961d67db689552c1a2494909b29d1cb00.tar.gz
QPID-6454 : [Java Broker] Improve rendering of attribute types
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1666934 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java98
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/resources/css/apidocs.css5
2 files changed, 52 insertions, 51 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
index 817fab7689..5ef7a80660 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ApiDocsServlet.java
@@ -48,6 +48,7 @@ import org.slf4j.LoggerFactory;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredAutomatedAttribute;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ConfiguredObjectAttribute;
import org.apache.qpid.server.model.IllegalStateTransitionException;
@@ -62,31 +63,6 @@ import org.apache.qpid.util.DataUrlUtils;
public class ApiDocsServlet extends AbstractServlet
{
private static final Logger LOGGER = LoggerFactory.getLogger(ApiDocsServlet.class);
-
- public static final String DEPTH_PARAM = "depth";
- public static final String OVERSIZE_PARAM = "oversize";
- public static final String ACTUALS_PARAM = "actuals";
- public static final String SORT_PARAM = "sort";
- public static final String INCLUDE_SYS_CONTEXT_PARAM = "includeSysContext";
- public static final String INHERITED_ACTUALS_PARAM = "inheritedActuals";
- public static final String EXTRACT_INITIAL_CONFIG_PARAM = "extractInitialConfig";
- public static final int SC_UNPROCESSABLE_ENTITY = 422;
-
- /**
- * Signifies that the agent wishes the servlet to set the Content-Disposition on the
- * response with the value attachment. This filename will be derived from the parameter value.
- */
- public static final String CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM = "contentDispositionAttachmentFilename";
-
- public static final Set<String> RESERVED_PARAMS =
- new HashSet<>(Arrays.asList(DEPTH_PARAM,
- SORT_PARAM,
- OVERSIZE_PARAM,
- ACTUALS_PARAM,
- INCLUDE_SYS_CONTEXT_PARAM,
- EXTRACT_INITIAL_CONFIG_PARAM,
- INHERITED_ACTUALS_PARAM,
- CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM));
private final Model _model;
private final Collection<Class<? extends ConfiguredObject>> _types;
@@ -278,41 +254,61 @@ public class ApiDocsServlet extends AbstractServlet
private String renderType(final ConfiguredObjectAttribute attribute)
{
final Class type = attribute.getType();
- if(Number.class.isAssignableFrom(type))
- {
- return "number";
- }
- else if(Enum.class.isAssignableFrom(type))
- {
- return "<span title=\"enum: " + EnumSet.allOf(type) + "\">string</span>";
- }
- else if(Boolean.class == type)
+ if(Enum.class.isAssignableFrom(type))
{
- return "boolean";
+ return "<div class=\"restriction\" title=\"enum: " + EnumSet.allOf(type) + "\">string</div>";
}
- else if(String.class == type)
+ else if(ConfiguredObject.class.isAssignableFrom(type))
{
- return "string";
+ return "<div class=\"restriction\" title=\"name or id of a" + (VOWELS.contains(type.getSimpleName().toLowerCase().charAt(0)) ? "n " : " ") + type.getSimpleName() + "\">string</div>";
}
else if(UUID.class == type)
{
- return "<span title=\"\">string</span>";
- }
- else if(List.class.isAssignableFrom(type))
- {
- // TODO - generate a description of the type in the array
- return "array";
+ return "<div class=\"restriction\" title=\"must be a UUID\">string</div>";
}
- else if(Map.class.isAssignableFrom(type))
+ else
{
- // TODO - generate a description of the type in the object
- return "object";
- }
- else if(ConfiguredObject.class.isAssignableFrom(type))
- {
- return "<span title=\"name or id of a" + (VOWELS.contains(type.getSimpleName().toLowerCase().charAt(0)) ? "n " : " ") + type.getSimpleName() + "\">string</span>";
+ boolean hasValuesRestriction = attribute instanceof ConfiguredAutomatedAttribute
+ && ((ConfiguredAutomatedAttribute)attribute).hasValidValues();
+
+ StringBuilder returnVal = new StringBuilder();
+ if(hasValuesRestriction)
+ {
+ returnVal.append("<div class=\"restricted\" title=\"Valid values: " + ((ConfiguredAutomatedAttribute)attribute).validValues() + "\">");
+ }
+
+ if(Number.class.isAssignableFrom(type))
+ {
+ returnVal.append("number");
+ }
+ else if(Boolean.class == type)
+ {
+ returnVal.append("boolean");
+ }
+ else if(String.class == type)
+ {
+ returnVal.append("string");
+ }
+ else if(Collection.class.isAssignableFrom(type))
+ {
+ // TODO - generate a description of the type in the array
+ returnVal.append("array");
+ }
+ else if(Map.class.isAssignableFrom(type))
+ {
+ // TODO - generate a description of the type in the object
+ returnVal.append("object");
+ }
+ else
+ {
+ returnVal.append(type.getSimpleName());
+ }
+ if(hasValuesRestriction)
+ {
+ returnVal.append("</div>");
+ }
+ return returnVal.toString();
}
- return type.getSimpleName();
}
private void writeFoot(final PrintWriter writer)
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/apidocs.css b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/apidocs.css
index bb1bf292d3..f79eaaaa50 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/apidocs.css
+++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/apidocs.css
@@ -50,3 +50,8 @@ table.attributes td.name {
table.attributes td.type {
width: 7em;
}
+
+div.restriction {
+ border-bottom: 1px dotted #666;
+ display: inline;
+}